This source file includes following definitions.
- nfp_nsp_has_mac_reinit
- nfp_nsp_has_stored_fw_load
- nfp_nsp_has_hwinfo_lookup
- nfp_nsp_has_hwinfo_set
- nfp_nsp_has_fw_loaded
- nfp_nsp_has_versions
- nfp_nsp_has_read_module_eeprom
- nfp_eth_can_support_fec
- nfp_eth_supported_fec_modes
   1 
   2 
   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 
 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 
 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 
 118 #define NFP_NSP_DRV_LOAD_IFC_DEFAULT            "0x10ff"
 119 
 120 
 121 
 122 
 123 
 124 
 125 
 126 
 127 
 128 
 129 
 130 
 131 
 132 
 133 
 134 
 135 
 136 
 137 
 138 
 139 
 140 
 141 
 142 
 143 
 144 
 145 
 146 
 147 
 148 
 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                 
 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 
 220 
 221 
 222 
 223 
 224 
 225 
 226 
 227 
 228 
 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 
 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