0001
0002
0003
0004 #ifndef NSP_NSP_H
0005 #define NSP_NSP_H 1
0006
0007 #include <linux/types.h>
0008 #include <linux/if_ether.h>
0009
0010 struct firmware;
0011 struct nfp_cpp;
0012 struct nfp_nsp;
0013
0014 struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);
0015 void nfp_nsp_close(struct nfp_nsp *state);
0016 u16 nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
0017 u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
0018 int nfp_nsp_wait(struct nfp_nsp *state);
0019 int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
0020 int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw);
0021 int nfp_nsp_write_flash(struct nfp_nsp *state, const struct firmware *fw);
0022 int nfp_nsp_mac_reinit(struct nfp_nsp *state);
0023 int nfp_nsp_load_stored_fw(struct nfp_nsp *state);
0024 int nfp_nsp_hwinfo_lookup(struct nfp_nsp *state, void *buf, unsigned int size);
0025 int nfp_nsp_hwinfo_lookup_optional(struct nfp_nsp *state, void *buf,
0026 unsigned int size, const char *default_val);
0027 int nfp_nsp_hwinfo_set(struct nfp_nsp *state, void *buf, unsigned int size);
0028 int nfp_nsp_fw_loaded(struct nfp_nsp *state);
0029 int nfp_nsp_read_module_eeprom(struct nfp_nsp *state, int eth_index,
0030 unsigned int offset, void *data,
0031 unsigned int len, unsigned int *read_len);
0032
0033 static inline bool nfp_nsp_has_mac_reinit(struct nfp_nsp *state)
0034 {
0035 return nfp_nsp_get_abi_ver_minor(state) > 20;
0036 }
0037
0038 static inline bool nfp_nsp_has_stored_fw_load(struct nfp_nsp *state)
0039 {
0040 return nfp_nsp_get_abi_ver_minor(state) > 23;
0041 }
0042
0043 static inline bool nfp_nsp_has_hwinfo_lookup(struct nfp_nsp *state)
0044 {
0045 return nfp_nsp_get_abi_ver_minor(state) > 24;
0046 }
0047
0048 static inline bool nfp_nsp_has_hwinfo_set(struct nfp_nsp *state)
0049 {
0050 return nfp_nsp_get_abi_ver_minor(state) > 25;
0051 }
0052
0053 static inline bool nfp_nsp_has_fw_loaded(struct nfp_nsp *state)
0054 {
0055 return nfp_nsp_get_abi_ver_minor(state) > 25;
0056 }
0057
0058 static inline bool nfp_nsp_has_versions(struct nfp_nsp *state)
0059 {
0060 return nfp_nsp_get_abi_ver_minor(state) > 27;
0061 }
0062
0063 static inline bool nfp_nsp_has_read_module_eeprom(struct nfp_nsp *state)
0064 {
0065 return nfp_nsp_get_abi_ver_minor(state) > 28;
0066 }
0067
0068 enum nfp_eth_interface {
0069 NFP_INTERFACE_NONE = 0,
0070 NFP_INTERFACE_SFP = 1,
0071 NFP_INTERFACE_SFPP = 10,
0072 NFP_INTERFACE_SFP28 = 28,
0073 NFP_INTERFACE_QSFP = 40,
0074 NFP_INTERFACE_RJ45 = 45,
0075 NFP_INTERFACE_CXP = 100,
0076 NFP_INTERFACE_QSFP28 = 112,
0077 };
0078
0079 enum nfp_eth_media {
0080 NFP_MEDIA_DAC_PASSIVE = 0,
0081 NFP_MEDIA_DAC_ACTIVE,
0082 NFP_MEDIA_FIBRE,
0083 };
0084
0085 enum nfp_eth_aneg {
0086 NFP_ANEG_AUTO = 0,
0087 NFP_ANEG_SEARCH,
0088 NFP_ANEG_25G_CONSORTIUM,
0089 NFP_ANEG_25G_IEEE,
0090 NFP_ANEG_DISABLED,
0091 };
0092
0093 enum nfp_eth_fec {
0094 NFP_FEC_AUTO_BIT = 0,
0095 NFP_FEC_BASER_BIT,
0096 NFP_FEC_REED_SOLOMON_BIT,
0097 NFP_FEC_DISABLED_BIT,
0098 };
0099
0100 #define NFP_FEC_AUTO BIT(NFP_FEC_AUTO_BIT)
0101 #define NFP_FEC_BASER BIT(NFP_FEC_BASER_BIT)
0102 #define NFP_FEC_REED_SOLOMON BIT(NFP_FEC_REED_SOLOMON_BIT)
0103 #define NFP_FEC_DISABLED BIT(NFP_FEC_DISABLED_BIT)
0104
0105
0106 #define NFP_NSP_DRV_RESET_DISK 0
0107 #define NFP_NSP_DRV_RESET_ALWAYS 1
0108 #define NFP_NSP_DRV_RESET_NEVER 2
0109 #define NFP_NSP_DRV_RESET_DEFAULT "0"
0110
0111
0112 #define NFP_NSP_APP_FW_LOAD_DISK 0
0113 #define NFP_NSP_APP_FW_LOAD_FLASH 1
0114 #define NFP_NSP_APP_FW_LOAD_PREF 2
0115 #define NFP_NSP_APP_FW_LOAD_DEFAULT "2"
0116
0117
0118 #define NFP_NSP_DRV_LOAD_IFC_DEFAULT "0x10ff"
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 struct nfp_eth_table {
0151 unsigned int count;
0152 unsigned int max_index;
0153 struct nfp_eth_table_port {
0154 unsigned int eth_index;
0155 unsigned int index;
0156 unsigned int nbi;
0157 unsigned int base;
0158 unsigned int lanes;
0159 unsigned int speed;
0160
0161 unsigned int interface;
0162 enum nfp_eth_media media;
0163
0164 enum nfp_eth_fec fec;
0165 enum nfp_eth_aneg aneg;
0166
0167 u8 mac_addr[ETH_ALEN];
0168
0169 u8 label_port;
0170 u8 label_subport;
0171
0172 bool enabled;
0173 bool tx_enabled;
0174 bool rx_enabled;
0175
0176 bool override_changed;
0177
0178
0179 u8 port_type;
0180
0181 unsigned int port_lanes;
0182
0183 bool is_split;
0184
0185 unsigned int fec_modes_supported;
0186 } ports[];
0187 };
0188
0189 struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);
0190 struct nfp_eth_table *
0191 __nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp);
0192
0193 int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, unsigned int idx, bool enable);
0194 int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx,
0195 bool configed);
0196 int
0197 nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode);
0198
0199 int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state);
0200
0201 static inline bool nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
0202 {
0203 return !!eth_port->fec_modes_supported;
0204 }
0205
0206 static inline unsigned int
0207 nfp_eth_supported_fec_modes(struct nfp_eth_table_port *eth_port)
0208 {
0209 return eth_port->fec_modes_supported;
0210 }
0211
0212 struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx);
0213 int nfp_eth_config_commit_end(struct nfp_nsp *nsp);
0214 void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp);
0215
0216 int __nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode);
0217 int __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed);
0218 int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes);
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232 struct nfp_nsp_identify {
0233 char version[40];
0234 u8 flags;
0235 u8 br_primary;
0236 u8 br_secondary;
0237 u8 br_nsp;
0238 u16 primary;
0239 u16 secondary;
0240 u16 nsp;
0241 u64 sensor_mask;
0242 };
0243
0244 struct nfp_nsp_identify *__nfp_nsp_identify(struct nfp_nsp *nsp);
0245
0246 enum nfp_nsp_sensor_id {
0247 NFP_SENSOR_CHIP_TEMPERATURE,
0248 NFP_SENSOR_ASSEMBLY_POWER,
0249 NFP_SENSOR_ASSEMBLY_12V_POWER,
0250 NFP_SENSOR_ASSEMBLY_3V3_POWER,
0251 };
0252
0253 int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id,
0254 long *val);
0255
0256 #define NFP_NSP_VERSION_BUFSZ 1024
0257
0258 enum nfp_nsp_versions {
0259 NFP_VERSIONS_BSP,
0260 NFP_VERSIONS_CPLD,
0261 NFP_VERSIONS_APP,
0262 NFP_VERSIONS_BUNDLE,
0263 NFP_VERSIONS_UNDI,
0264 NFP_VERSIONS_NCSI,
0265 NFP_VERSIONS_CFGR,
0266 };
0267
0268 int nfp_nsp_versions(struct nfp_nsp *state, void *buf, unsigned int size);
0269 const char *nfp_nsp_versions_get(enum nfp_nsp_versions id, bool flash,
0270 const u8 *buf, unsigned int size);
0271 #endif