6 struct __packed sfp_eeprom_base
{
10 #if defined __BIG_ENDIAN_BITFIELD
17 u8 if_1x_copper_active
:1;
18 u8 if_1x_copper_passive
:1;
20 u8 escon_mmf_1310_led
:1;
21 u8 escon_smf_1310_laser
:1;
22 u8 sonet_oc192_short_reach
:1;
23 u8 sonet_reach_bit1
:1;
24 u8 sonet_reach_bit2
:1;
25 u8 sonet_oc48_long_reach
:1;
26 u8 sonet_oc48_intermediate_reach
:1;
27 u8 sonet_oc48_short_reach
:1;
30 u8 sonet_oc12_smf_long_reach
:1;
31 u8 sonet_oc12_smf_intermediate_reach
:1;
32 u8 sonet_oc12_short_reach
:1;
34 u8 sonet_oc3_smf_long_reach
:1;
35 u8 sonet_oc3_smf_intermediate_reach
:1;
36 u8 sonet_oc3_short_reach
:1;
54 u8 fc_tech_electrical_inter_enclosure
:1;
56 u8 fc_tech_electrical_intra_enclosure
:1;
80 u8 unallocated_10_1
:1;
82 #elif defined __LITTLE_ENDIAN_BITFIELD
83 u8 if_1x_copper_passive
:1;
84 u8 if_1x_copper_active
:1;
92 u8 sonet_oc3_short_reach
:1;
93 u8 sonet_oc3_smf_intermediate_reach
:1;
94 u8 sonet_oc3_smf_long_reach
:1;
96 u8 sonet_oc12_short_reach
:1;
97 u8 sonet_oc12_smf_intermediate_reach
:1;
98 u8 sonet_oc12_smf_long_reach
:1;
101 u8 sonet_oc48_short_reach
:1;
102 u8 sonet_oc48_intermediate_reach
:1;
103 u8 sonet_oc48_long_reach
:1;
104 u8 sonet_reach_bit2
:1;
105 u8 sonet_reach_bit1
:1;
106 u8 sonet_oc192_short_reach
:1;
107 u8 escon_smf_1310_laser
:1;
108 u8 escon_mmf_1310_led
:1;
119 u8 fc_tech_electrical_inter_enclosure
:1;
128 u8 unallocated_8_0
:1;
129 u8 unallocated_8_1
:1;
135 u8 fc_tech_electrical_intra_enclosure
:1;
138 u8 unallocated_9_1
:1;
147 u8 unallocated_10_1
:1;
155 #error Unknown Endian
161 char vendor_name
[16];
167 __be16 optical_wavelength
;
174 struct __packed sfp_eeprom_ext
{
182 u8 sff8472_compliance
;
186 struct __packed sfp_eeprom_id
{
187 struct sfp_eeprom_base base
;
188 struct sfp_eeprom_ext ext
;
191 /* SFP EEPROM registers */
194 SFP_PHYS_EXT_ID
= 0x01,
195 SFP_CONNECTOR
= 0x02,
196 SFP_COMPLIANCE
= 0x03,
198 SFP_BR_NOMINAL
= 0x0c,
200 SFP_LINK_LEN_SM_KM
= 0x0e,
201 SFP_LINK_LEN_SM_100M
= 0x0f,
202 SFP_LINK_LEN_50UM_OM2_10M
= 0x10,
203 SFP_LINK_LEN_62_5UM_OM1_10M
= 0x11,
204 SFP_LINK_LEN_COPPER_1M
= 0x12,
205 SFP_LINK_LEN_50UM_OM4_10M
= 0x12,
206 SFP_LINK_LEN_50UM_OM3_10M
= 0x13,
207 SFP_VENDOR_NAME
= 0x14,
208 SFP_VENDOR_OUI
= 0x25,
209 SFP_VENDOR_PN
= 0x28,
210 SFP_VENDOR_REV
= 0x38,
211 SFP_OPTICAL_WAVELENGTH_MSB
= 0x3c,
212 SFP_OPTICAL_WAVELENGTH_LSB
= 0x3d,
213 SFP_CABLE_SPEC
= 0x3c,
215 SFP_OPTIONS
= 0x40, /* 2 bytes, MSB, LSB */
218 SFP_VENDOR_SN
= 0x44,
222 SFP_SFF8472_COMPLIANCE
= 0x5e,
225 SFP_PHYS_ID_SFP
= 0x03,
226 SFP_PHYS_EXT_ID_SFP
= 0x04,
227 SFP_CONNECTOR_UNSPEC
= 0x00,
228 /* codes 01-05 not supportable on SFP, but some modules have single SC */
229 SFP_CONNECTOR_SC
= 0x01,
230 SFP_CONNECTOR_FIBERJACK
= 0x06,
231 SFP_CONNECTOR_LC
= 0x07,
232 SFP_CONNECTOR_MT_RJ
= 0x08,
233 SFP_CONNECTOR_MU
= 0x09,
234 SFP_CONNECTOR_SG
= 0x0a,
235 SFP_CONNECTOR_OPTICAL_PIGTAIL
= 0x0b,
236 SFP_CONNECTOR_MPO_1X12
= 0x0c,
237 SFP_CONNECTOR_MPO_2X16
= 0x0d,
238 SFP_CONNECTOR_HSSDC_II
= 0x20,
239 SFP_CONNECTOR_COPPER_PIGTAIL
= 0x21,
240 SFP_CONNECTOR_RJ45
= 0x22,
241 SFP_CONNECTOR_NOSEPARATE
= 0x23,
242 SFP_CONNECTOR_MXC_2X16
= 0x24,
243 SFP_ENCODING_UNSPEC
= 0x00,
244 SFP_ENCODING_8B10B
= 0x01,
245 SFP_ENCODING_4B5B
= 0x02,
246 SFP_ENCODING_NRZ
= 0x03,
247 SFP_ENCODING_8472_MANCHESTER
= 0x04,
248 SFP_ENCODING_8472_SONET
= 0x05,
249 SFP_ENCODING_8472_64B66B
= 0x06,
250 SFP_ENCODING_256B257B
= 0x07,
251 SFP_ENCODING_PAM4
= 0x08,
252 SFP_OPTIONS_HIGH_POWER_LEVEL
= BIT(13),
253 SFP_OPTIONS_PAGING_A2
= BIT(12),
254 SFP_OPTIONS_RETIMER
= BIT(11),
255 SFP_OPTIONS_COOLED_XCVR
= BIT(10),
256 SFP_OPTIONS_POWER_DECL
= BIT(9),
257 SFP_OPTIONS_RX_LINEAR_OUT
= BIT(8),
258 SFP_OPTIONS_RX_DECISION_THRESH
= BIT(7),
259 SFP_OPTIONS_TUNABLE_TX
= BIT(6),
260 SFP_OPTIONS_RATE_SELECT
= BIT(5),
261 SFP_OPTIONS_TX_DISABLE
= BIT(4),
262 SFP_OPTIONS_TX_FAULT
= BIT(3),
263 SFP_OPTIONS_LOS_INVERTED
= BIT(2),
264 SFP_OPTIONS_LOS_NORMAL
= BIT(1),
265 SFP_DIAGMON_DDM
= BIT(6),
266 SFP_DIAGMON_INT_CAL
= BIT(5),
267 SFP_DIAGMON_EXT_CAL
= BIT(4),
268 SFP_DIAGMON_RXPWR_AVG
= BIT(3),
269 SFP_DIAGMON_ADDRMODE
= BIT(2),
270 SFP_ENHOPTS_ALARMWARN
= BIT(7),
271 SFP_ENHOPTS_SOFT_TX_DISABLE
= BIT(6),
272 SFP_ENHOPTS_SOFT_TX_FAULT
= BIT(5),
273 SFP_ENHOPTS_SOFT_RX_LOS
= BIT(4),
274 SFP_ENHOPTS_SOFT_RATE_SELECT
= BIT(3),
275 SFP_ENHOPTS_APP_SELECT_SFF8079
= BIT(2),
276 SFP_ENHOPTS_SOFT_RATE_SFF8431
= BIT(1),
277 SFP_SFF8472_COMPLIANCE_NONE
= 0x00,
278 SFP_SFF8472_COMPLIANCE_REV9_3
= 0x01,
279 SFP_SFF8472_COMPLIANCE_REV9_5
= 0x02,
280 SFP_SFF8472_COMPLIANCE_REV10_2
= 0x03,
281 SFP_SFF8472_COMPLIANCE_REV10_4
= 0x04,
282 SFP_SFF8472_COMPLIANCE_REV11_0
= 0x05,
283 SFP_SFF8472_COMPLIANCE_REV11_3
= 0x06,
284 SFP_SFF8472_COMPLIANCE_REV11_4
= 0x07,
285 SFP_SFF8472_COMPLIANCE_REV12_0
= 0x08,
288 /* SFP Diagnostics */
290 /* Alarm and warnings stored MSB at lower address then LSB */
291 SFP_TEMP_HIGH_ALARM
= 0x00,
292 SFP_TEMP_LOW_ALARM
= 0x02,
293 SFP_TEMP_HIGH_WARN
= 0x04,
294 SFP_TEMP_LOW_WARN
= 0x06,
295 SFP_VOLT_HIGH_ALARM
= 0x08,
296 SFP_VOLT_LOW_ALARM
= 0x0a,
297 SFP_VOLT_HIGH_WARN
= 0x0c,
298 SFP_VOLT_LOW_WARN
= 0x0e,
299 SFP_BIAS_HIGH_ALARM
= 0x10,
300 SFP_BIAS_LOW_ALARM
= 0x12,
301 SFP_BIAS_HIGH_WARN
= 0x14,
302 SFP_BIAS_LOW_WARN
= 0x16,
303 SFP_TXPWR_HIGH_ALARM
= 0x18,
304 SFP_TXPWR_LOW_ALARM
= 0x1a,
305 SFP_TXPWR_HIGH_WARN
= 0x1c,
306 SFP_TXPWR_LOW_WARN
= 0x1e,
307 SFP_RXPWR_HIGH_ALARM
= 0x20,
308 SFP_RXPWR_LOW_ALARM
= 0x22,
309 SFP_RXPWR_HIGH_WARN
= 0x24,
310 SFP_RXPWR_LOW_WARN
= 0x26,
311 SFP_LASER_TEMP_HIGH_ALARM
= 0x28,
312 SFP_LASER_TEMP_LOW_ALARM
= 0x2a,
313 SFP_LASER_TEMP_HIGH_WARN
= 0x2c,
314 SFP_LASER_TEMP_LOW_WARN
= 0x2e,
315 SFP_TEC_CUR_HIGH_ALARM
= 0x30,
316 SFP_TEC_CUR_LOW_ALARM
= 0x32,
317 SFP_TEC_CUR_HIGH_WARN
= 0x34,
318 SFP_TEC_CUR_LOW_WARN
= 0x36,
319 SFP_CAL_RXPWR4
= 0x38,
320 SFP_CAL_RXPWR3
= 0x3c,
321 SFP_CAL_RXPWR2
= 0x40,
322 SFP_CAL_RXPWR1
= 0x44,
323 SFP_CAL_RXPWR0
= 0x48,
324 SFP_CAL_TXI_SLOPE
= 0x4c,
325 SFP_CAL_TXI_OFFSET
= 0x4e,
326 SFP_CAL_TXPWR_SLOPE
= 0x50,
327 SFP_CAL_TXPWR_OFFSET
= 0x52,
328 SFP_CAL_T_SLOPE
= 0x54,
329 SFP_CAL_T_OFFSET
= 0x56,
330 SFP_CAL_V_SLOPE
= 0x58,
331 SFP_CAL_V_OFFSET
= 0x5a,
339 SFP_LASER_TEMP
= 0x6a,
345 SFP_EXT_STATUS
= 0x76,
351 struct ethtool_eeprom
;
352 struct ethtool_modinfo
;
356 struct sfp_upstream_ops
{
357 int (*module_insert
)(void *, const struct sfp_eeprom_id
*id
);
358 void (*module_remove
)(void *);
359 void (*link_down
)(void *);
360 void (*link_up
)(void *);
361 int (*connect_phy
)(void *, struct phy_device
*);
362 void (*disconnect_phy
)(void *);
365 #if IS_ENABLED(CONFIG_SFP)
366 int sfp_parse_port(struct sfp_bus
*bus
, const struct sfp_eeprom_id
*id
,
367 unsigned long *support
);
368 phy_interface_t
sfp_parse_interface(struct sfp_bus
*bus
,
369 const struct sfp_eeprom_id
*id
);
370 void sfp_parse_support(struct sfp_bus
*bus
, const struct sfp_eeprom_id
*id
,
371 unsigned long *support
);
373 int sfp_get_module_info(struct sfp_bus
*bus
, struct ethtool_modinfo
*modinfo
);
374 int sfp_get_module_eeprom(struct sfp_bus
*bus
, struct ethtool_eeprom
*ee
,
376 void sfp_upstream_start(struct sfp_bus
*bus
);
377 void sfp_upstream_stop(struct sfp_bus
*bus
);
378 struct sfp_bus
*sfp_register_upstream(struct device_node
*np
,
379 struct net_device
*ndev
, void *upstream
,
380 const struct sfp_upstream_ops
*ops
);
381 void sfp_unregister_upstream(struct sfp_bus
*bus
);
383 static inline int sfp_parse_port(struct sfp_bus
*bus
,
384 const struct sfp_eeprom_id
*id
,
385 unsigned long *support
)
390 static inline phy_interface_t
sfp_parse_interface(struct sfp_bus
*bus
,
391 const struct sfp_eeprom_id
*id
)
393 return PHY_INTERFACE_MODE_NA
;
396 static inline void sfp_parse_support(struct sfp_bus
*bus
,
397 const struct sfp_eeprom_id
*id
,
398 unsigned long *support
)
402 static inline int sfp_get_module_info(struct sfp_bus
*bus
,
403 struct ethtool_modinfo
*modinfo
)
408 static inline int sfp_get_module_eeprom(struct sfp_bus
*bus
,
409 struct ethtool_eeprom
*ee
, u8
*data
)
414 static inline void sfp_upstream_start(struct sfp_bus
*bus
)
418 static inline void sfp_upstream_stop(struct sfp_bus
*bus
)
422 static inline struct sfp_bus
*sfp_register_upstream(struct device_node
*np
,
423 struct net_device
*ndev
, void *upstream
,
424 const struct sfp_upstream_ops
*ops
)
426 return (struct sfp_bus
*)-1;
429 static inline void sfp_unregister_upstream(struct sfp_bus
*bus
)