root/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. nfp_nsp_has_mac_reinit
  2. nfp_nsp_has_stored_fw_load
  3. nfp_nsp_has_hwinfo_lookup
  4. nfp_nsp_has_hwinfo_set
  5. nfp_nsp_has_fw_loaded
  6. nfp_nsp_has_versions
  7. nfp_nsp_has_read_module_eeprom
  8. nfp_eth_can_support_fec
  9. nfp_eth_supported_fec_modes

   1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
   2 /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
   3 
   4 #ifndef NSP_NSP_H
   5 #define NSP_NSP_H 1
   6 
   7 #include <linux/types.h>
   8 #include <linux/if_ether.h>
   9 
  10 struct firmware;
  11 struct nfp_cpp;
  12 struct nfp_nsp;
  13 
  14 struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);
  15 void nfp_nsp_close(struct nfp_nsp *state);
  16 u16 nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
  17 u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
  18 int nfp_nsp_wait(struct nfp_nsp *state);
  19 int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
  20 int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw);
  21 int nfp_nsp_write_flash(struct nfp_nsp *state, const struct firmware *fw);
  22 int nfp_nsp_mac_reinit(struct nfp_nsp *state);
  23 int nfp_nsp_load_stored_fw(struct nfp_nsp *state);
  24 int nfp_nsp_hwinfo_lookup(struct nfp_nsp *state, void *buf, unsigned int size);
  25 int nfp_nsp_hwinfo_lookup_optional(struct nfp_nsp *state, void *buf,
  26                                    unsigned int size, const char *default_val);
  27 int nfp_nsp_hwinfo_set(struct nfp_nsp *state, void *buf, unsigned int size);
  28 int nfp_nsp_fw_loaded(struct nfp_nsp *state);
  29 int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index,
  30                                unsigned int offset, void *data,
  31                                unsigned int len, unsigned int *read_len);
  32 
  33 static inline bool nfp_nsp_has_mac_reinit(struct nfp_nsp *state)
  34 {
  35         return nfp_nsp_get_abi_ver_minor(state) > 20;
  36 }
  37 
  38 static inline bool nfp_nsp_has_stored_fw_load(struct nfp_nsp *state)
  39 {
  40         return nfp_nsp_get_abi_ver_minor(state) > 23;
  41 }
  42 
  43 static inline bool nfp_nsp_has_hwinfo_lookup(struct nfp_nsp *state)
  44 {
  45         return nfp_nsp_get_abi_ver_minor(state) > 24;
  46 }
  47 
  48 static inline bool nfp_nsp_has_hwinfo_set(struct nfp_nsp *state)
  49 {
  50         return nfp_nsp_get_abi_ver_minor(state) > 25;
  51 }
  52 
  53 static inline bool nfp_nsp_has_fw_loaded(struct nfp_nsp *state)
  54 {
  55         return nfp_nsp_get_abi_ver_minor(state) > 25;
  56 }
  57 
  58 static inline bool nfp_nsp_has_versions(struct nfp_nsp *state)
  59 {
  60         return nfp_nsp_get_abi_ver_minor(state) > 27;
  61 }
  62 
  63 static inline bool nfp_nsp_has_read_module_eeprom(struct nfp_nsp *state)
  64 {
  65         return nfp_nsp_get_abi_ver_minor(state) > 28;
  66 }
  67 
  68 enum nfp_eth_interface {
  69         NFP_INTERFACE_NONE      = 0,
  70         NFP_INTERFACE_SFP       = 1,
  71         NFP_INTERFACE_SFPP      = 10,
  72         NFP_INTERFACE_SFP28     = 28,
  73         NFP_INTERFACE_QSFP      = 40,
  74         NFP_INTERFACE_RJ45      = 45,
  75         NFP_INTERFACE_CXP       = 100,
  76         NFP_INTERFACE_QSFP28    = 112,
  77 };
  78 
  79 enum nfp_eth_media {
  80         NFP_MEDIA_DAC_PASSIVE = 0,
  81         NFP_MEDIA_DAC_ACTIVE,
  82         NFP_MEDIA_FIBRE,
  83 };
  84 
  85 enum nfp_eth_aneg {
  86         NFP_ANEG_AUTO = 0,
  87         NFP_ANEG_SEARCH,
  88         NFP_ANEG_25G_CONSORTIUM,
  89         NFP_ANEG_25G_IEEE,
  90         NFP_ANEG_DISABLED,
  91 };
  92 
  93 enum nfp_eth_fec {
  94         NFP_FEC_AUTO_BIT = 0,
  95         NFP_FEC_BASER_BIT,
  96         NFP_FEC_REED_SOLOMON_BIT,
  97         NFP_FEC_DISABLED_BIT,
  98 };
  99 
 100 #define NFP_FEC_AUTO            BIT(NFP_FEC_AUTO_BIT)
 101 #define NFP_FEC_BASER           BIT(NFP_FEC_BASER_BIT)
 102 #define NFP_FEC_REED_SOLOMON    BIT(NFP_FEC_REED_SOLOMON_BIT)
 103 #define NFP_FEC_DISABLED        BIT(NFP_FEC_DISABLED_BIT)
 104 
 105 /* Defines the valid values of the 'abi_drv_reset' hwinfo key */
 106 #define NFP_NSP_DRV_RESET_DISK                  0
 107 #define NFP_NSP_DRV_RESET_ALWAYS                1
 108 #define NFP_NSP_DRV_RESET_NEVER                 2
 109 #define NFP_NSP_DRV_RESET_DEFAULT               "0"
 110 
 111 /* Defines the valid values of the 'app_fw_from_flash' hwinfo key */
 112 #define NFP_NSP_APP_FW_LOAD_DISK                0
 113 #define NFP_NSP_APP_FW_LOAD_FLASH               1
 114 #define NFP_NSP_APP_FW_LOAD_PREF                2
 115 #define NFP_NSP_APP_FW_LOAD_DEFAULT             "2"
 116 
 117 /* Define the default value for the 'abi_drv_load_ifc' key */
 118 #define NFP_NSP_DRV_LOAD_IFC_DEFAULT            "0x10ff"
 119 
 120 /**
 121  * struct nfp_eth_table - ETH table information
 122  * @count:      number of table entries
 123  * @max_index:  max of @index fields of all @ports
 124  * @ports:      table of ports
 125  *
 126  * @ports.eth_index:    port index according to legacy ethX numbering
 127  * @ports.index:        chip-wide first channel index
 128  * @ports.nbi:          NBI index
 129  * @ports.base:         first channel index (within NBI)
 130  * @ports.lanes:        number of channels
 131  * @ports.speed:        interface speed (in Mbps)
 132  * @ports.interface:    interface (module) plugged in
 133  * @ports.media:        media type of the @interface
 134  * @ports.fec:          forward error correction mode
 135  * @ports.aneg:         auto negotiation mode
 136  * @ports.mac_addr:     interface MAC address
 137  * @ports.label_port:   port id
 138  * @ports.label_subport:  id of interface within port (for split ports)
 139  * @ports.enabled:      is enabled?
 140  * @ports.tx_enabled:   is TX enabled?
 141  * @ports.rx_enabled:   is RX enabled?
 142  * @ports.override_changed: is media reconfig pending?
 143  *
 144  * @ports.port_type:    one of %PORT_* defines for ethtool
 145  * @ports.port_lanes:   total number of lanes on the port (sum of lanes of all
 146  *                      subports)
 147  * @ports.is_split:     is interface part of a split port
 148  * @ports.fec_modes_supported:  bitmap of FEC modes supported
 149  */
 150 struct nfp_eth_table {
 151         unsigned int count;
 152         unsigned int max_index;
 153         struct nfp_eth_table_port {
 154                 unsigned int eth_index;
 155                 unsigned int index;
 156                 unsigned int nbi;
 157                 unsigned int base;
 158                 unsigned int lanes;
 159                 unsigned int speed;
 160 
 161                 unsigned int interface;
 162                 enum nfp_eth_media media;
 163 
 164                 enum nfp_eth_fec fec;
 165                 enum nfp_eth_aneg aneg;
 166 
 167                 u8 mac_addr[ETH_ALEN];
 168 
 169                 u8 label_port;
 170                 u8 label_subport;
 171 
 172                 bool enabled;
 173                 bool tx_enabled;
 174                 bool rx_enabled;
 175 
 176                 bool override_changed;
 177 
 178                 /* Computed fields */
 179                 u8 port_type;
 180 
 181                 unsigned int port_lanes;
 182 
 183                 bool is_split;
 184 
 185                 unsigned int fec_modes_supported;
 186         } ports[0];
 187 };
 188 
 189 struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);
 190 struct nfp_eth_table *
 191 __nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp);
 192 
 193 int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, unsigned int idx, bool enable);
 194 int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx,
 195                            bool configed);
 196 int
 197 nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode);
 198 
 199 static inline bool nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
 200 {
 201         return !!eth_port->fec_modes_supported;
 202 }
 203 
 204 static inline unsigned int
 205 nfp_eth_supported_fec_modes(struct nfp_eth_table_port *eth_port)
 206 {
 207         return eth_port->fec_modes_supported;
 208 }
 209 
 210 struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx);
 211 int nfp_eth_config_commit_end(struct nfp_nsp *nsp);
 212 void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp);
 213 
 214 int __nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode);
 215 int __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed);
 216 int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes);
 217 
 218 /**
 219  * struct nfp_nsp_identify - NSP static information
 220  * @version:      opaque version string
 221  * @flags:        version flags
 222  * @br_primary:   branch id of primary bootloader
 223  * @br_secondary: branch id of secondary bootloader
 224  * @br_nsp:       branch id of NSP
 225  * @primary:      version of primarary bootloader
 226  * @secondary:    version id of secondary bootloader
 227  * @nsp:          version id of NSP
 228  * @sensor_mask:  mask of present sensors available on NIC
 229  */
 230 struct nfp_nsp_identify {
 231         char version[40];
 232         u8 flags;
 233         u8 br_primary;
 234         u8 br_secondary;
 235         u8 br_nsp;
 236         u16 primary;
 237         u16 secondary;
 238         u16 nsp;
 239         u64 sensor_mask;
 240 };
 241 
 242 struct nfp_nsp_identify *__nfp_nsp_identify(struct nfp_nsp *nsp);
 243 
 244 enum nfp_nsp_sensor_id {
 245         NFP_SENSOR_CHIP_TEMPERATURE,
 246         NFP_SENSOR_ASSEMBLY_POWER,
 247         NFP_SENSOR_ASSEMBLY_12V_POWER,
 248         NFP_SENSOR_ASSEMBLY_3V3_POWER,
 249 };
 250 
 251 int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id,
 252                           long *val);
 253 
 254 #define NFP_NSP_VERSION_BUFSZ   1024 /* reasonable size, not in the ABI */
 255 
 256 enum nfp_nsp_versions {
 257         NFP_VERSIONS_BSP,
 258         NFP_VERSIONS_CPLD,
 259         NFP_VERSIONS_APP,
 260         NFP_VERSIONS_BUNDLE,
 261         NFP_VERSIONS_UNDI,
 262         NFP_VERSIONS_NCSI,
 263         NFP_VERSIONS_CFGR,
 264 };
 265 
 266 int nfp_nsp_versions(struct nfp_nsp *state, void *buf, unsigned int size);
 267 const char *nfp_nsp_versions_get(enum nfp_nsp_versions id, bool flash,
 268                                  const u8 *buf, unsigned int size);
 269 #endif

/* [<][>][^][v][top][bottom][index][help] */