]> Git Repo - linux.git/blob - include/linux/sfp.h
Merge tag 'sched_ext-for-6.14-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / include / linux / sfp.h
1 #ifndef LINUX_SFP_H
2 #define LINUX_SFP_H
3
4 #include <linux/phy.h>
5
6 struct sfp_eeprom_base {
7         u8 phys_id;
8         u8 phys_ext_id;
9         u8 connector;
10 #if defined __BIG_ENDIAN_BITFIELD
11         u8 e10g_base_er:1;
12         u8 e10g_base_lrm:1;
13         u8 e10g_base_lr:1;
14         u8 e10g_base_sr:1;
15         u8 if_1x_sx:1;
16         u8 if_1x_lx:1;
17         u8 if_1x_copper_active:1;
18         u8 if_1x_copper_passive:1;
19
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;
28
29         u8 unallocated_5_7:1;
30         u8 sonet_oc12_smf_long_reach:1;
31         u8 sonet_oc12_smf_intermediate_reach:1;
32         u8 sonet_oc12_short_reach:1;
33         u8 unallocated_5_3:1;
34         u8 sonet_oc3_smf_long_reach:1;
35         u8 sonet_oc3_smf_intermediate_reach:1;
36         u8 sonet_oc3_short_reach:1;
37
38         u8 e_base_px:1;
39         u8 e_base_bx10:1;
40         u8 e100_base_fx:1;
41         u8 e100_base_lx:1;
42         u8 e1000_base_t:1;
43         u8 e1000_base_cx:1;
44         u8 e1000_base_lx:1;
45         u8 e1000_base_sx:1;
46
47         u8 fc_ll_v:1;
48         u8 fc_ll_s:1;
49         u8 fc_ll_i:1;
50         u8 fc_ll_l:1;
51         u8 fc_ll_m:1;
52         u8 fc_tech_sa:1;
53         u8 fc_tech_lc:1;
54         u8 fc_tech_electrical_inter_enclosure:1;
55
56         u8 fc_tech_electrical_intra_enclosure:1;
57         u8 fc_tech_sn:1;
58         u8 fc_tech_sl:1;
59         u8 fc_tech_ll:1;
60         u8 sfp_ct_active:1;
61         u8 sfp_ct_passive:1;
62         u8 unallocated_8_1:1;
63         u8 unallocated_8_0:1;
64
65         u8 fc_media_tw:1;
66         u8 fc_media_tp:1;
67         u8 fc_media_mi:1;
68         u8 fc_media_tv:1;
69         u8 fc_media_m6:1;
70         u8 fc_media_m5:1;
71         u8 unallocated_9_1:1;
72         u8 fc_media_sm:1;
73
74         u8 fc_speed_1200:1;
75         u8 fc_speed_800:1;
76         u8 fc_speed_1600:1;
77         u8 fc_speed_400:1;
78         u8 fc_speed_3200:1;
79         u8 fc_speed_200:1;
80         u8 unallocated_10_1:1;
81         u8 fc_speed_100:1;
82 #elif defined __LITTLE_ENDIAN_BITFIELD
83         u8 if_1x_copper_passive:1;
84         u8 if_1x_copper_active:1;
85         u8 if_1x_lx:1;
86         u8 if_1x_sx:1;
87         u8 e10g_base_sr:1;
88         u8 e10g_base_lr:1;
89         u8 e10g_base_lrm:1;
90         u8 e10g_base_er:1;
91
92         u8 sonet_oc3_short_reach:1;
93         u8 sonet_oc3_smf_intermediate_reach:1;
94         u8 sonet_oc3_smf_long_reach:1;
95         u8 unallocated_5_3:1;
96         u8 sonet_oc12_short_reach:1;
97         u8 sonet_oc12_smf_intermediate_reach:1;
98         u8 sonet_oc12_smf_long_reach:1;
99         u8 unallocated_5_7:1;
100
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;
109
110         u8 e1000_base_sx:1;
111         u8 e1000_base_lx:1;
112         u8 e1000_base_cx:1;
113         u8 e1000_base_t:1;
114         u8 e100_base_lx:1;
115         u8 e100_base_fx:1;
116         u8 e_base_bx10:1;
117         u8 e_base_px:1;
118
119         u8 fc_tech_electrical_inter_enclosure:1;
120         u8 fc_tech_lc:1;
121         u8 fc_tech_sa:1;
122         u8 fc_ll_m:1;
123         u8 fc_ll_l:1;
124         u8 fc_ll_i:1;
125         u8 fc_ll_s:1;
126         u8 fc_ll_v:1;
127
128         u8 unallocated_8_0:1;
129         u8 unallocated_8_1:1;
130         u8 sfp_ct_passive:1;
131         u8 sfp_ct_active:1;
132         u8 fc_tech_ll:1;
133         u8 fc_tech_sl:1;
134         u8 fc_tech_sn:1;
135         u8 fc_tech_electrical_intra_enclosure:1;
136
137         u8 fc_media_sm:1;
138         u8 unallocated_9_1:1;
139         u8 fc_media_m5:1;
140         u8 fc_media_m6:1;
141         u8 fc_media_tv:1;
142         u8 fc_media_mi:1;
143         u8 fc_media_tp:1;
144         u8 fc_media_tw:1;
145
146         u8 fc_speed_100:1;
147         u8 unallocated_10_1:1;
148         u8 fc_speed_200:1;
149         u8 fc_speed_3200:1;
150         u8 fc_speed_400:1;
151         u8 fc_speed_1600:1;
152         u8 fc_speed_800:1;
153         u8 fc_speed_1200:1;
154 #else
155 #error Unknown Endian
156 #endif
157         u8 encoding;
158         u8 br_nominal;
159         u8 rate_id;
160         u8 link_len[6];
161         char vendor_name[16];
162         u8 extended_cc;
163         char vendor_oui[3];
164         char vendor_pn[16];
165         char vendor_rev[4];
166         union {
167                 __be16 optical_wavelength;
168                 __be16 cable_compliance;
169                 struct {
170 #if defined __BIG_ENDIAN_BITFIELD
171                         u8 reserved60_2:6;
172                         u8 fc_pi_4_app_h:1;
173                         u8 sff8431_app_e:1;
174                         u8 reserved61:8;
175 #elif defined __LITTLE_ENDIAN_BITFIELD
176                         u8 sff8431_app_e:1;
177                         u8 fc_pi_4_app_h:1;
178                         u8 reserved60_2:6;
179                         u8 reserved61:8;
180 #else
181 #error Unknown Endian
182 #endif
183                 } __packed passive;
184                 struct {
185 #if defined __BIG_ENDIAN_BITFIELD
186                         u8 reserved60_4:4;
187                         u8 fc_pi_4_lim:1;
188                         u8 sff8431_lim:1;
189                         u8 fc_pi_4_app_h:1;
190                         u8 sff8431_app_e:1;
191                         u8 reserved61:8;
192 #elif defined __LITTLE_ENDIAN_BITFIELD
193                         u8 sff8431_app_e:1;
194                         u8 fc_pi_4_app_h:1;
195                         u8 sff8431_lim:1;
196                         u8 fc_pi_4_lim:1;
197                         u8 reserved60_4:4;
198                         u8 reserved61:8;
199 #else
200 #error Unknown Endian
201 #endif
202                 } __packed active;
203         } __packed;
204         u8 reserved62;
205         u8 cc_base;
206 } __packed;
207
208 struct sfp_eeprom_ext {
209         __be16 options;
210         u8 br_max;
211         u8 br_min;
212         char vendor_sn[16];
213         char datecode[8];
214         u8 diagmon;
215         u8 enhopts;
216         u8 sff8472_compliance;
217         u8 cc_ext;
218 } __packed;
219
220 /**
221  * struct sfp_eeprom_id - raw SFP module identification information
222  * @base: base SFP module identification structure
223  * @ext: extended SFP module identification structure
224  *
225  * See the SFF-8472 specification and related documents for the definition
226  * of these structure members. This can be obtained from
227  * https://www.snia.org/technology-communities/sff/specifications
228  */
229 struct sfp_eeprom_id {
230         struct sfp_eeprom_base base;
231         struct sfp_eeprom_ext ext;
232 } __packed;
233
234 struct sfp_diag {
235         __be16 temp_high_alarm;
236         __be16 temp_low_alarm;
237         __be16 temp_high_warn;
238         __be16 temp_low_warn;
239         __be16 volt_high_alarm;
240         __be16 volt_low_alarm;
241         __be16 volt_high_warn;
242         __be16 volt_low_warn;
243         __be16 bias_high_alarm;
244         __be16 bias_low_alarm;
245         __be16 bias_high_warn;
246         __be16 bias_low_warn;
247         __be16 txpwr_high_alarm;
248         __be16 txpwr_low_alarm;
249         __be16 txpwr_high_warn;
250         __be16 txpwr_low_warn;
251         __be16 rxpwr_high_alarm;
252         __be16 rxpwr_low_alarm;
253         __be16 rxpwr_high_warn;
254         __be16 rxpwr_low_warn;
255         __be16 laser_temp_high_alarm;
256         __be16 laser_temp_low_alarm;
257         __be16 laser_temp_high_warn;
258         __be16 laser_temp_low_warn;
259         __be16 tec_cur_high_alarm;
260         __be16 tec_cur_low_alarm;
261         __be16 tec_cur_high_warn;
262         __be16 tec_cur_low_warn;
263         __be32 cal_rxpwr4;
264         __be32 cal_rxpwr3;
265         __be32 cal_rxpwr2;
266         __be32 cal_rxpwr1;
267         __be32 cal_rxpwr0;
268         __be16 cal_txi_slope;
269         __be16 cal_txi_offset;
270         __be16 cal_txpwr_slope;
271         __be16 cal_txpwr_offset;
272         __be16 cal_t_slope;
273         __be16 cal_t_offset;
274         __be16 cal_v_slope;
275         __be16 cal_v_offset;
276 } __packed;
277
278 /* SFF8024 defined constants */
279 enum {
280         SFF8024_ID_UNK                  = 0x00,
281         SFF8024_ID_SFF_8472             = 0x02,
282         SFF8024_ID_SFP                  = 0x03,
283         SFF8024_ID_DWDM_SFP             = 0x0b,
284         SFF8024_ID_QSFP_8438            = 0x0c,
285         SFF8024_ID_QSFP_8436_8636       = 0x0d,
286         SFF8024_ID_QSFP28_8636          = 0x11,
287         SFF8024_ID_QSFP_DD              = 0x18,
288         SFF8024_ID_OSFP                 = 0x19,
289         SFF8024_ID_DSFP                 = 0x1B,
290         SFF8024_ID_QSFP_PLUS_CMIS       = 0x1E,
291         SFF8024_ID_SFP_DD_CMIS          = 0x1F,
292         SFF8024_ID_SFP_PLUS_CMIS        = 0x20,
293
294         SFF8024_ENCODING_UNSPEC         = 0x00,
295         SFF8024_ENCODING_8B10B          = 0x01,
296         SFF8024_ENCODING_4B5B           = 0x02,
297         SFF8024_ENCODING_NRZ            = 0x03,
298         SFF8024_ENCODING_8472_MANCHESTER= 0x04,
299         SFF8024_ENCODING_8472_SONET     = 0x05,
300         SFF8024_ENCODING_8472_64B66B    = 0x06,
301         SFF8024_ENCODING_8436_MANCHESTER= 0x06,
302         SFF8024_ENCODING_8436_SONET     = 0x04,
303         SFF8024_ENCODING_8436_64B66B    = 0x05,
304         SFF8024_ENCODING_256B257B       = 0x07,
305         SFF8024_ENCODING_PAM4           = 0x08,
306
307         SFF8024_CONNECTOR_UNSPEC        = 0x00,
308         /* codes 01-05 not supportable on SFP, but some modules have single SC */
309         SFF8024_CONNECTOR_SC            = 0x01,
310         SFF8024_CONNECTOR_FIBERJACK     = 0x06,
311         SFF8024_CONNECTOR_LC            = 0x07,
312         SFF8024_CONNECTOR_MT_RJ         = 0x08,
313         SFF8024_CONNECTOR_MU            = 0x09,
314         SFF8024_CONNECTOR_SG            = 0x0a,
315         SFF8024_CONNECTOR_OPTICAL_PIGTAIL= 0x0b,
316         SFF8024_CONNECTOR_MPO_1X12      = 0x0c,
317         SFF8024_CONNECTOR_MPO_2X16      = 0x0d,
318         SFF8024_CONNECTOR_HSSDC_II      = 0x20,
319         SFF8024_CONNECTOR_COPPER_PIGTAIL= 0x21,
320         SFF8024_CONNECTOR_RJ45          = 0x22,
321         SFF8024_CONNECTOR_NOSEPARATE    = 0x23,
322         SFF8024_CONNECTOR_MXC_2X16      = 0x24,
323
324         SFF8024_ECC_UNSPEC              = 0x00,
325         SFF8024_ECC_100G_25GAUI_C2M_AOC = 0x01,
326         SFF8024_ECC_100GBASE_SR4_25GBASE_SR = 0x02,
327         SFF8024_ECC_100GBASE_LR4_25GBASE_LR = 0x03,
328         SFF8024_ECC_100GBASE_ER4_25GBASE_ER = 0x04,
329         SFF8024_ECC_100GBASE_SR10       = 0x05,
330         SFF8024_ECC_100GBASE_CR4        = 0x0b,
331         SFF8024_ECC_25GBASE_CR_S        = 0x0c,
332         SFF8024_ECC_25GBASE_CR_N        = 0x0d,
333         SFF8024_ECC_10GBASE_T_SFI       = 0x16,
334         SFF8024_ECC_10GBASE_T_SR        = 0x1c,
335         SFF8024_ECC_5GBASE_T            = 0x1d,
336         SFF8024_ECC_2_5GBASE_T          = 0x1e,
337 };
338
339 /* SFP EEPROM registers */
340 enum {
341         SFP_PHYS_ID                     = 0,
342
343         SFP_PHYS_EXT_ID                 = 1,
344         SFP_PHYS_EXT_ID_SFP             = 0x04,
345
346         SFP_CONNECTOR                   = 2,
347         SFP_COMPLIANCE                  = 3,
348         SFP_ENCODING                    = 11,
349         SFP_BR_NOMINAL                  = 12,
350         SFP_RATE_ID                     = 13,
351         SFF_RID_8079                    = 0x01,
352         SFF_RID_8431_RX_ONLY            = 0x02,
353         SFF_RID_8431_TX_ONLY            = 0x04,
354         SFF_RID_8431                    = 0x06,
355         SFF_RID_10G8G                   = 0x0e,
356
357         SFP_LINK_LEN_SM_KM              = 14,
358         SFP_LINK_LEN_SM_100M            = 15,
359         SFP_LINK_LEN_50UM_OM2_10M       = 16,
360         SFP_LINK_LEN_62_5UM_OM1_10M     = 17,
361         SFP_LINK_LEN_COPPER_1M          = 18,
362         SFP_LINK_LEN_50UM_OM4_10M       = 18,
363         SFP_LINK_LEN_50UM_OM3_10M       = 19,
364         SFP_VENDOR_NAME                 = 20,
365         SFP_VENDOR_OUI                  = 37,
366         SFP_VENDOR_PN                   = 40,
367         SFP_VENDOR_REV                  = 56,
368         SFP_OPTICAL_WAVELENGTH_MSB      = 60,
369         SFP_OPTICAL_WAVELENGTH_LSB      = 61,
370         SFP_CABLE_SPEC                  = 60,
371         SFP_CC_BASE                     = 63,
372
373         SFP_OPTIONS                     = 64,   /* 2 bytes, MSB, LSB */
374         SFP_OPTIONS_HIGH_POWER_LEVEL    = BIT(13),
375         SFP_OPTIONS_PAGING_A2           = BIT(12),
376         SFP_OPTIONS_RETIMER             = BIT(11),
377         SFP_OPTIONS_COOLED_XCVR         = BIT(10),
378         SFP_OPTIONS_POWER_DECL          = BIT(9),
379         SFP_OPTIONS_RX_LINEAR_OUT       = BIT(8),
380         SFP_OPTIONS_RX_DECISION_THRESH  = BIT(7),
381         SFP_OPTIONS_TUNABLE_TX          = BIT(6),
382         SFP_OPTIONS_RATE_SELECT         = BIT(5),
383         SFP_OPTIONS_TX_DISABLE          = BIT(4),
384         SFP_OPTIONS_TX_FAULT            = BIT(3),
385         SFP_OPTIONS_LOS_INVERTED        = BIT(2),
386         SFP_OPTIONS_LOS_NORMAL          = BIT(1),
387
388         SFP_BR_MAX                      = 66,
389         SFP_BR_MIN                      = 67,
390         SFP_VENDOR_SN                   = 68,
391         SFP_DATECODE                    = 84,
392
393         SFP_DIAGMON                     = 92,
394         SFP_DIAGMON_DDM                 = BIT(6),
395         SFP_DIAGMON_INT_CAL             = BIT(5),
396         SFP_DIAGMON_EXT_CAL             = BIT(4),
397         SFP_DIAGMON_RXPWR_AVG           = BIT(3),
398         SFP_DIAGMON_ADDRMODE            = BIT(2),
399
400         SFP_ENHOPTS                     = 93,
401         SFP_ENHOPTS_ALARMWARN           = BIT(7),
402         SFP_ENHOPTS_SOFT_TX_DISABLE     = BIT(6),
403         SFP_ENHOPTS_SOFT_TX_FAULT       = BIT(5),
404         SFP_ENHOPTS_SOFT_RX_LOS         = BIT(4),
405         SFP_ENHOPTS_SOFT_RATE_SELECT    = BIT(3),
406         SFP_ENHOPTS_APP_SELECT_SFF8079  = BIT(2),
407         SFP_ENHOPTS_SOFT_RATE_SFF8431   = BIT(1),
408
409         SFP_SFF8472_COMPLIANCE          = 94,
410         SFP_SFF8472_COMPLIANCE_NONE     = 0x00,
411         SFP_SFF8472_COMPLIANCE_REV9_3   = 0x01,
412         SFP_SFF8472_COMPLIANCE_REV9_5   = 0x02,
413         SFP_SFF8472_COMPLIANCE_REV10_2  = 0x03,
414         SFP_SFF8472_COMPLIANCE_REV10_4  = 0x04,
415         SFP_SFF8472_COMPLIANCE_REV11_0  = 0x05,
416         SFP_SFF8472_COMPLIANCE_REV11_3  = 0x06,
417         SFP_SFF8472_COMPLIANCE_REV11_4  = 0x07,
418         SFP_SFF8472_COMPLIANCE_REV12_0  = 0x08,
419
420         SFP_CC_EXT                      = 95,
421 };
422
423 /* SFP Diagnostics */
424 enum {
425         /* Alarm and warnings stored MSB at lower address then LSB */
426         SFP_TEMP_HIGH_ALARM             = 0,
427         SFP_TEMP_LOW_ALARM              = 2,
428         SFP_TEMP_HIGH_WARN              = 4,
429         SFP_TEMP_LOW_WARN               = 6,
430         SFP_VOLT_HIGH_ALARM             = 8,
431         SFP_VOLT_LOW_ALARM              = 10,
432         SFP_VOLT_HIGH_WARN              = 12,
433         SFP_VOLT_LOW_WARN               = 14,
434         SFP_BIAS_HIGH_ALARM             = 16,
435         SFP_BIAS_LOW_ALARM              = 18,
436         SFP_BIAS_HIGH_WARN              = 20,
437         SFP_BIAS_LOW_WARN               = 22,
438         SFP_TXPWR_HIGH_ALARM            = 24,
439         SFP_TXPWR_LOW_ALARM             = 26,
440         SFP_TXPWR_HIGH_WARN             = 28,
441         SFP_TXPWR_LOW_WARN              = 30,
442         SFP_RXPWR_HIGH_ALARM            = 32,
443         SFP_RXPWR_LOW_ALARM             = 34,
444         SFP_RXPWR_HIGH_WARN             = 36,
445         SFP_RXPWR_LOW_WARN              = 38,
446         SFP_LASER_TEMP_HIGH_ALARM       = 40,
447         SFP_LASER_TEMP_LOW_ALARM        = 42,
448         SFP_LASER_TEMP_HIGH_WARN        = 44,
449         SFP_LASER_TEMP_LOW_WARN         = 46,
450         SFP_TEC_CUR_HIGH_ALARM          = 48,
451         SFP_TEC_CUR_LOW_ALARM           = 50,
452         SFP_TEC_CUR_HIGH_WARN           = 52,
453         SFP_TEC_CUR_LOW_WARN            = 54,
454         SFP_CAL_RXPWR4                  = 56,
455         SFP_CAL_RXPWR3                  = 60,
456         SFP_CAL_RXPWR2                  = 64,
457         SFP_CAL_RXPWR1                  = 68,
458         SFP_CAL_RXPWR0                  = 72,
459         SFP_CAL_TXI_SLOPE               = 76,
460         SFP_CAL_TXI_OFFSET              = 78,
461         SFP_CAL_TXPWR_SLOPE             = 80,
462         SFP_CAL_TXPWR_OFFSET            = 82,
463         SFP_CAL_T_SLOPE                 = 84,
464         SFP_CAL_T_OFFSET                = 86,
465         SFP_CAL_V_SLOPE                 = 88,
466         SFP_CAL_V_OFFSET                = 90,
467         SFP_CHKSUM                      = 95,
468
469         SFP_TEMP                        = 96,
470         SFP_VCC                         = 98,
471         SFP_TX_BIAS                     = 100,
472         SFP_TX_POWER                    = 102,
473         SFP_RX_POWER                    = 104,
474         SFP_LASER_TEMP                  = 106,
475         SFP_TEC_CUR                     = 108,
476
477         SFP_STATUS                      = 110,
478         SFP_STATUS_TX_DISABLE           = BIT(7),
479         SFP_STATUS_TX_DISABLE_FORCE     = BIT(6),
480         SFP_STATUS_RS0_SELECT           = BIT(3),
481         SFP_STATUS_TX_FAULT             = BIT(2),
482         SFP_STATUS_RX_LOS               = BIT(1),
483         SFP_ALARM0                      = 112,
484         SFP_ALARM0_TEMP_HIGH            = BIT(7),
485         SFP_ALARM0_TEMP_LOW             = BIT(6),
486         SFP_ALARM0_VCC_HIGH             = BIT(5),
487         SFP_ALARM0_VCC_LOW              = BIT(4),
488         SFP_ALARM0_TX_BIAS_HIGH         = BIT(3),
489         SFP_ALARM0_TX_BIAS_LOW          = BIT(2),
490         SFP_ALARM0_TXPWR_HIGH           = BIT(1),
491         SFP_ALARM0_TXPWR_LOW            = BIT(0),
492
493         SFP_ALARM1                      = 113,
494         SFP_ALARM1_RXPWR_HIGH           = BIT(7),
495         SFP_ALARM1_RXPWR_LOW            = BIT(6),
496
497         SFP_WARN0                       = 116,
498         SFP_WARN0_TEMP_HIGH             = BIT(7),
499         SFP_WARN0_TEMP_LOW              = BIT(6),
500         SFP_WARN0_VCC_HIGH              = BIT(5),
501         SFP_WARN0_VCC_LOW               = BIT(4),
502         SFP_WARN0_TX_BIAS_HIGH          = BIT(3),
503         SFP_WARN0_TX_BIAS_LOW           = BIT(2),
504         SFP_WARN0_TXPWR_HIGH            = BIT(1),
505         SFP_WARN0_TXPWR_LOW             = BIT(0),
506
507         SFP_WARN1                       = 117,
508         SFP_WARN1_RXPWR_HIGH            = BIT(7),
509         SFP_WARN1_RXPWR_LOW             = BIT(6),
510
511         SFP_EXT_STATUS                  = 118,
512         SFP_EXT_STATUS_RS1_SELECT       = BIT(3),
513         SFP_EXT_STATUS_PWRLVL_SELECT    = BIT(0),
514
515         SFP_VSL                         = 120,
516         SFP_PAGE                        = 127,
517 };
518
519 struct fwnode_handle;
520 struct ethtool_eeprom;
521 struct ethtool_modinfo;
522 struct sfp_bus;
523
524 /**
525  * struct sfp_upstream_ops - upstream operations structure
526  * @attach: called when the sfp socket driver is bound to the upstream
527  *   (mandatory).
528  * @detach: called when the sfp socket driver is unbound from the upstream
529  *   (mandatory).
530  * @module_insert: called after a module has been detected to determine
531  *   whether the module is supported for the upstream device.
532  * @module_remove: called after the module has been removed.
533  * @module_start: called after the PHY probe step
534  * @module_stop: called before the PHY is removed
535  * @link_down: called when the link is non-operational for whatever
536  *   reason.
537  * @link_up: called when the link is operational.
538  * @connect_phy: called when an I2C accessible PHY has been detected
539  *   on the module.
540  * @disconnect_phy: called when a module with an I2C accessible PHY has
541  *   been removed.
542  */
543 struct sfp_upstream_ops {
544         void (*attach)(void *priv, struct sfp_bus *bus);
545         void (*detach)(void *priv, struct sfp_bus *bus);
546         int (*module_insert)(void *priv, const struct sfp_eeprom_id *id);
547         void (*module_remove)(void *priv);
548         int (*module_start)(void *priv);
549         void (*module_stop)(void *priv);
550         void (*link_down)(void *priv);
551         void (*link_up)(void *priv);
552         int (*connect_phy)(void *priv, struct phy_device *);
553         void (*disconnect_phy)(void *priv, struct phy_device *);
554 };
555
556 #if IS_ENABLED(CONFIG_SFP)
557 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
558                    unsigned long *support);
559 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id);
560 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
561                        unsigned long *support, unsigned long *interfaces);
562 phy_interface_t sfp_select_interface(struct sfp_bus *bus,
563                                      const unsigned long *link_modes);
564
565 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
566 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
567                           u8 *data);
568 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
569                                   const struct ethtool_module_eeprom *page,
570                                   struct netlink_ext_ack *extack);
571 void sfp_upstream_start(struct sfp_bus *bus);
572 void sfp_upstream_stop(struct sfp_bus *bus);
573 void sfp_upstream_set_signal_rate(struct sfp_bus *bus, unsigned int rate_kbd);
574 void sfp_bus_put(struct sfp_bus *bus);
575 struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode);
576 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
577                          const struct sfp_upstream_ops *ops);
578 void sfp_bus_del_upstream(struct sfp_bus *bus);
579 const char *sfp_get_name(struct sfp_bus *bus);
580 #else
581 static inline int sfp_parse_port(struct sfp_bus *bus,
582                                  const struct sfp_eeprom_id *id,
583                                  unsigned long *support)
584 {
585         return PORT_OTHER;
586 }
587
588 static inline bool sfp_may_have_phy(struct sfp_bus *bus,
589                                     const struct sfp_eeprom_id *id)
590 {
591         return false;
592 }
593
594 static inline void sfp_parse_support(struct sfp_bus *bus,
595                                      const struct sfp_eeprom_id *id,
596                                      unsigned long *support,
597                                      unsigned long *interfaces)
598 {
599 }
600
601 static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus,
602                                                 const unsigned long *link_modes)
603 {
604         return PHY_INTERFACE_MODE_NA;
605 }
606
607 static inline int sfp_get_module_info(struct sfp_bus *bus,
608                                       struct ethtool_modinfo *modinfo)
609 {
610         return -EOPNOTSUPP;
611 }
612
613 static inline int sfp_get_module_eeprom(struct sfp_bus *bus,
614                                         struct ethtool_eeprom *ee, u8 *data)
615 {
616         return -EOPNOTSUPP;
617 }
618
619 static inline int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
620                                                 const struct ethtool_module_eeprom *page,
621                                                 struct netlink_ext_ack *extack)
622 {
623         return -EOPNOTSUPP;
624 }
625
626 static inline void sfp_upstream_start(struct sfp_bus *bus)
627 {
628 }
629
630 static inline void sfp_upstream_stop(struct sfp_bus *bus)
631 {
632 }
633
634 static inline void sfp_upstream_set_signal_rate(struct sfp_bus *bus,
635                                                 unsigned int rate_kbd)
636 {
637 }
638
639 static inline void sfp_bus_put(struct sfp_bus *bus)
640 {
641 }
642
643 static inline struct sfp_bus *
644 sfp_bus_find_fwnode(const struct fwnode_handle *fwnode)
645 {
646         return NULL;
647 }
648
649 static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
650                                        const struct sfp_upstream_ops *ops)
651 {
652         return 0;
653 }
654
655 static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
656 {
657 }
658
659 static inline const char *sfp_get_name(struct sfp_bus *bus)
660 {
661         return NULL;
662 }
663 #endif
664
665 #endif
This page took 0.067344 seconds and 4 git commands to generate.