Back to home page

OSCL-LXR

 
 

    


0001 #ifndef LINUX_SFP_H
0002 #define LINUX_SFP_H
0003 
0004 #include <linux/phy.h>
0005 
0006 struct sfp_eeprom_base {
0007     u8 phys_id;
0008     u8 phys_ext_id;
0009     u8 connector;
0010 #if defined __BIG_ENDIAN_BITFIELD
0011     u8 e10g_base_er:1;
0012     u8 e10g_base_lrm:1;
0013     u8 e10g_base_lr:1;
0014     u8 e10g_base_sr:1;
0015     u8 if_1x_sx:1;
0016     u8 if_1x_lx:1;
0017     u8 if_1x_copper_active:1;
0018     u8 if_1x_copper_passive:1;
0019 
0020     u8 escon_mmf_1310_led:1;
0021     u8 escon_smf_1310_laser:1;
0022     u8 sonet_oc192_short_reach:1;
0023     u8 sonet_reach_bit1:1;
0024     u8 sonet_reach_bit2:1;
0025     u8 sonet_oc48_long_reach:1;
0026     u8 sonet_oc48_intermediate_reach:1;
0027     u8 sonet_oc48_short_reach:1;
0028 
0029     u8 unallocated_5_7:1;
0030     u8 sonet_oc12_smf_long_reach:1;
0031     u8 sonet_oc12_smf_intermediate_reach:1;
0032     u8 sonet_oc12_short_reach:1;
0033     u8 unallocated_5_3:1;
0034     u8 sonet_oc3_smf_long_reach:1;
0035     u8 sonet_oc3_smf_intermediate_reach:1;
0036     u8 sonet_oc3_short_reach:1;
0037 
0038     u8 e_base_px:1;
0039     u8 e_base_bx10:1;
0040     u8 e100_base_fx:1;
0041     u8 e100_base_lx:1;
0042     u8 e1000_base_t:1;
0043     u8 e1000_base_cx:1;
0044     u8 e1000_base_lx:1;
0045     u8 e1000_base_sx:1;
0046 
0047     u8 fc_ll_v:1;
0048     u8 fc_ll_s:1;
0049     u8 fc_ll_i:1;
0050     u8 fc_ll_l:1;
0051     u8 fc_ll_m:1;
0052     u8 fc_tech_sa:1;
0053     u8 fc_tech_lc:1;
0054     u8 fc_tech_electrical_inter_enclosure:1;
0055 
0056     u8 fc_tech_electrical_intra_enclosure:1;
0057     u8 fc_tech_sn:1;
0058     u8 fc_tech_sl:1;
0059     u8 fc_tech_ll:1;
0060     u8 sfp_ct_active:1;
0061     u8 sfp_ct_passive:1;
0062     u8 unallocated_8_1:1;
0063     u8 unallocated_8_0:1;
0064 
0065     u8 fc_media_tw:1;
0066     u8 fc_media_tp:1;
0067     u8 fc_media_mi:1;
0068     u8 fc_media_tv:1;
0069     u8 fc_media_m6:1;
0070     u8 fc_media_m5:1;
0071     u8 unallocated_9_1:1;
0072     u8 fc_media_sm:1;
0073 
0074     u8 fc_speed_1200:1;
0075     u8 fc_speed_800:1;
0076     u8 fc_speed_1600:1;
0077     u8 fc_speed_400:1;
0078     u8 fc_speed_3200:1;
0079     u8 fc_speed_200:1;
0080     u8 unallocated_10_1:1;
0081     u8 fc_speed_100:1;
0082 #elif defined __LITTLE_ENDIAN_BITFIELD
0083     u8 if_1x_copper_passive:1;
0084     u8 if_1x_copper_active:1;
0085     u8 if_1x_lx:1;
0086     u8 if_1x_sx:1;
0087     u8 e10g_base_sr:1;
0088     u8 e10g_base_lr:1;
0089     u8 e10g_base_lrm:1;
0090     u8 e10g_base_er:1;
0091 
0092     u8 sonet_oc3_short_reach:1;
0093     u8 sonet_oc3_smf_intermediate_reach:1;
0094     u8 sonet_oc3_smf_long_reach:1;
0095     u8 unallocated_5_3:1;
0096     u8 sonet_oc12_short_reach:1;
0097     u8 sonet_oc12_smf_intermediate_reach:1;
0098     u8 sonet_oc12_smf_long_reach:1;
0099     u8 unallocated_5_7:1;
0100 
0101     u8 sonet_oc48_short_reach:1;
0102     u8 sonet_oc48_intermediate_reach:1;
0103     u8 sonet_oc48_long_reach:1;
0104     u8 sonet_reach_bit2:1;
0105     u8 sonet_reach_bit1:1;
0106     u8 sonet_oc192_short_reach:1;
0107     u8 escon_smf_1310_laser:1;
0108     u8 escon_mmf_1310_led:1;
0109 
0110     u8 e1000_base_sx:1;
0111     u8 e1000_base_lx:1;
0112     u8 e1000_base_cx:1;
0113     u8 e1000_base_t:1;
0114     u8 e100_base_lx:1;
0115     u8 e100_base_fx:1;
0116     u8 e_base_bx10:1;
0117     u8 e_base_px:1;
0118 
0119     u8 fc_tech_electrical_inter_enclosure:1;
0120     u8 fc_tech_lc:1;
0121     u8 fc_tech_sa:1;
0122     u8 fc_ll_m:1;
0123     u8 fc_ll_l:1;
0124     u8 fc_ll_i:1;
0125     u8 fc_ll_s:1;
0126     u8 fc_ll_v:1;
0127 
0128     u8 unallocated_8_0:1;
0129     u8 unallocated_8_1:1;
0130     u8 sfp_ct_passive:1;
0131     u8 sfp_ct_active:1;
0132     u8 fc_tech_ll:1;
0133     u8 fc_tech_sl:1;
0134     u8 fc_tech_sn:1;
0135     u8 fc_tech_electrical_intra_enclosure:1;
0136 
0137     u8 fc_media_sm:1;
0138     u8 unallocated_9_1:1;
0139     u8 fc_media_m5:1;
0140     u8 fc_media_m6:1;
0141     u8 fc_media_tv:1;
0142     u8 fc_media_mi:1;
0143     u8 fc_media_tp:1;
0144     u8 fc_media_tw:1;
0145 
0146     u8 fc_speed_100:1;
0147     u8 unallocated_10_1:1;
0148     u8 fc_speed_200:1;
0149     u8 fc_speed_3200:1;
0150     u8 fc_speed_400:1;
0151     u8 fc_speed_1600:1;
0152     u8 fc_speed_800:1;
0153     u8 fc_speed_1200:1;
0154 #else
0155 #error Unknown Endian
0156 #endif
0157     u8 encoding;
0158     u8 br_nominal;
0159     u8 rate_id;
0160     u8 link_len[6];
0161     char vendor_name[16];
0162     u8 extended_cc;
0163     char vendor_oui[3];
0164     char vendor_pn[16];
0165     char vendor_rev[4];
0166     union {
0167         __be16 optical_wavelength;
0168         __be16 cable_compliance;
0169         struct {
0170 #if defined __BIG_ENDIAN_BITFIELD
0171             u8 reserved60_2:6;
0172             u8 fc_pi_4_app_h:1;
0173             u8 sff8431_app_e:1;
0174             u8 reserved61:8;
0175 #elif defined __LITTLE_ENDIAN_BITFIELD
0176             u8 sff8431_app_e:1;
0177             u8 fc_pi_4_app_h:1;
0178             u8 reserved60_2:6;
0179             u8 reserved61:8;
0180 #else
0181 #error Unknown Endian
0182 #endif
0183         } __packed passive;
0184         struct {
0185 #if defined __BIG_ENDIAN_BITFIELD
0186             u8 reserved60_4:4;
0187             u8 fc_pi_4_lim:1;
0188             u8 sff8431_lim:1;
0189             u8 fc_pi_4_app_h:1;
0190             u8 sff8431_app_e:1;
0191             u8 reserved61:8;
0192 #elif defined __LITTLE_ENDIAN_BITFIELD
0193             u8 sff8431_app_e:1;
0194             u8 fc_pi_4_app_h:1;
0195             u8 sff8431_lim:1;
0196             u8 fc_pi_4_lim:1;
0197             u8 reserved60_4:4;
0198             u8 reserved61:8;
0199 #else
0200 #error Unknown Endian
0201 #endif
0202         } __packed active;
0203     } __packed;
0204     u8 reserved62;
0205     u8 cc_base;
0206 } __packed;
0207 
0208 struct sfp_eeprom_ext {
0209     __be16 options;
0210     u8 br_max;
0211     u8 br_min;
0212     char vendor_sn[16];
0213     char datecode[8];
0214     u8 diagmon;
0215     u8 enhopts;
0216     u8 sff8472_compliance;
0217     u8 cc_ext;
0218 } __packed;
0219 
0220 /**
0221  * struct sfp_eeprom_id - raw SFP module identification information
0222  * @base: base SFP module identification structure
0223  * @ext: extended SFP module identification structure
0224  *
0225  * See the SFF-8472 specification and related documents for the definition
0226  * of these structure members. This can be obtained from
0227  * https://www.snia.org/technology-communities/sff/specifications
0228  */
0229 struct sfp_eeprom_id {
0230     struct sfp_eeprom_base base;
0231     struct sfp_eeprom_ext ext;
0232 } __packed;
0233 
0234 struct sfp_diag {
0235     __be16 temp_high_alarm;
0236     __be16 temp_low_alarm;
0237     __be16 temp_high_warn;
0238     __be16 temp_low_warn;
0239     __be16 volt_high_alarm;
0240     __be16 volt_low_alarm;
0241     __be16 volt_high_warn;
0242     __be16 volt_low_warn;
0243     __be16 bias_high_alarm;
0244     __be16 bias_low_alarm;
0245     __be16 bias_high_warn;
0246     __be16 bias_low_warn;
0247     __be16 txpwr_high_alarm;
0248     __be16 txpwr_low_alarm;
0249     __be16 txpwr_high_warn;
0250     __be16 txpwr_low_warn;
0251     __be16 rxpwr_high_alarm;
0252     __be16 rxpwr_low_alarm;
0253     __be16 rxpwr_high_warn;
0254     __be16 rxpwr_low_warn;
0255     __be16 laser_temp_high_alarm;
0256     __be16 laser_temp_low_alarm;
0257     __be16 laser_temp_high_warn;
0258     __be16 laser_temp_low_warn;
0259     __be16 tec_cur_high_alarm;
0260     __be16 tec_cur_low_alarm;
0261     __be16 tec_cur_high_warn;
0262     __be16 tec_cur_low_warn;
0263     __be32 cal_rxpwr4;
0264     __be32 cal_rxpwr3;
0265     __be32 cal_rxpwr2;
0266     __be32 cal_rxpwr1;
0267     __be32 cal_rxpwr0;
0268     __be16 cal_txi_slope;
0269     __be16 cal_txi_offset;
0270     __be16 cal_txpwr_slope;
0271     __be16 cal_txpwr_offset;
0272     __be16 cal_t_slope;
0273     __be16 cal_t_offset;
0274     __be16 cal_v_slope;
0275     __be16 cal_v_offset;
0276 } __packed;
0277 
0278 /* SFF8024 defined constants */
0279 enum {
0280     SFF8024_ID_UNK          = 0x00,
0281     SFF8024_ID_SFF_8472     = 0x02,
0282     SFF8024_ID_SFP          = 0x03,
0283     SFF8024_ID_DWDM_SFP     = 0x0b,
0284     SFF8024_ID_QSFP_8438        = 0x0c,
0285     SFF8024_ID_QSFP_8436_8636   = 0x0d,
0286     SFF8024_ID_QSFP28_8636      = 0x11,
0287 
0288     SFF8024_ENCODING_UNSPEC     = 0x00,
0289     SFF8024_ENCODING_8B10B      = 0x01,
0290     SFF8024_ENCODING_4B5B       = 0x02,
0291     SFF8024_ENCODING_NRZ        = 0x03,
0292     SFF8024_ENCODING_8472_MANCHESTER= 0x04,
0293     SFF8024_ENCODING_8472_SONET = 0x05,
0294     SFF8024_ENCODING_8472_64B66B    = 0x06,
0295     SFF8024_ENCODING_8436_MANCHESTER= 0x06,
0296     SFF8024_ENCODING_8436_SONET = 0x04,
0297     SFF8024_ENCODING_8436_64B66B    = 0x05,
0298     SFF8024_ENCODING_256B257B   = 0x07,
0299     SFF8024_ENCODING_PAM4       = 0x08,
0300 
0301     SFF8024_CONNECTOR_UNSPEC    = 0x00,
0302     /* codes 01-05 not supportable on SFP, but some modules have single SC */
0303     SFF8024_CONNECTOR_SC        = 0x01,
0304     SFF8024_CONNECTOR_FIBERJACK = 0x06,
0305     SFF8024_CONNECTOR_LC        = 0x07,
0306     SFF8024_CONNECTOR_MT_RJ     = 0x08,
0307     SFF8024_CONNECTOR_MU        = 0x09,
0308     SFF8024_CONNECTOR_SG        = 0x0a,
0309     SFF8024_CONNECTOR_OPTICAL_PIGTAIL= 0x0b,
0310     SFF8024_CONNECTOR_MPO_1X12  = 0x0c,
0311     SFF8024_CONNECTOR_MPO_2X16  = 0x0d,
0312     SFF8024_CONNECTOR_HSSDC_II  = 0x20,
0313     SFF8024_CONNECTOR_COPPER_PIGTAIL= 0x21,
0314     SFF8024_CONNECTOR_RJ45      = 0x22,
0315     SFF8024_CONNECTOR_NOSEPARATE    = 0x23,
0316     SFF8024_CONNECTOR_MXC_2X16  = 0x24,
0317 
0318     SFF8024_ECC_UNSPEC      = 0x00,
0319     SFF8024_ECC_100G_25GAUI_C2M_AOC = 0x01,
0320     SFF8024_ECC_100GBASE_SR4_25GBASE_SR = 0x02,
0321     SFF8024_ECC_100GBASE_LR4_25GBASE_LR = 0x03,
0322     SFF8024_ECC_100GBASE_ER4_25GBASE_ER = 0x04,
0323     SFF8024_ECC_100GBASE_SR10   = 0x05,
0324     SFF8024_ECC_100GBASE_CR4    = 0x0b,
0325     SFF8024_ECC_25GBASE_CR_S    = 0x0c,
0326     SFF8024_ECC_25GBASE_CR_N    = 0x0d,
0327     SFF8024_ECC_10GBASE_T_SFI   = 0x16,
0328     SFF8024_ECC_10GBASE_T_SR    = 0x1c,
0329     SFF8024_ECC_5GBASE_T        = 0x1d,
0330     SFF8024_ECC_2_5GBASE_T      = 0x1e,
0331 };
0332 
0333 /* SFP EEPROM registers */
0334 enum {
0335     SFP_PHYS_ID         = 0x00,
0336     SFP_PHYS_EXT_ID         = 0x01,
0337     SFP_CONNECTOR           = 0x02,
0338     SFP_COMPLIANCE          = 0x03,
0339     SFP_ENCODING            = 0x0b,
0340     SFP_BR_NOMINAL          = 0x0c,
0341     SFP_RATE_ID         = 0x0d,
0342     SFP_LINK_LEN_SM_KM      = 0x0e,
0343     SFP_LINK_LEN_SM_100M        = 0x0f,
0344     SFP_LINK_LEN_50UM_OM2_10M   = 0x10,
0345     SFP_LINK_LEN_62_5UM_OM1_10M = 0x11,
0346     SFP_LINK_LEN_COPPER_1M      = 0x12,
0347     SFP_LINK_LEN_50UM_OM4_10M   = 0x12,
0348     SFP_LINK_LEN_50UM_OM3_10M   = 0x13,
0349     SFP_VENDOR_NAME         = 0x14,
0350     SFP_VENDOR_OUI          = 0x25,
0351     SFP_VENDOR_PN           = 0x28,
0352     SFP_VENDOR_REV          = 0x38,
0353     SFP_OPTICAL_WAVELENGTH_MSB  = 0x3c,
0354     SFP_OPTICAL_WAVELENGTH_LSB  = 0x3d,
0355     SFP_CABLE_SPEC          = 0x3c,
0356     SFP_CC_BASE         = 0x3f,
0357     SFP_OPTIONS         = 0x40, /* 2 bytes, MSB, LSB */
0358     SFP_BR_MAX          = 0x42,
0359     SFP_BR_MIN          = 0x43,
0360     SFP_VENDOR_SN           = 0x44,
0361     SFP_DATECODE            = 0x54,
0362     SFP_DIAGMON         = 0x5c,
0363     SFP_ENHOPTS         = 0x5d,
0364     SFP_SFF8472_COMPLIANCE      = 0x5e,
0365     SFP_CC_EXT          = 0x5f,
0366 
0367     SFP_PHYS_EXT_ID_SFP     = 0x04,
0368     SFP_OPTIONS_HIGH_POWER_LEVEL    = BIT(13),
0369     SFP_OPTIONS_PAGING_A2       = BIT(12),
0370     SFP_OPTIONS_RETIMER     = BIT(11),
0371     SFP_OPTIONS_COOLED_XCVR     = BIT(10),
0372     SFP_OPTIONS_POWER_DECL      = BIT(9),
0373     SFP_OPTIONS_RX_LINEAR_OUT   = BIT(8),
0374     SFP_OPTIONS_RX_DECISION_THRESH  = BIT(7),
0375     SFP_OPTIONS_TUNABLE_TX      = BIT(6),
0376     SFP_OPTIONS_RATE_SELECT     = BIT(5),
0377     SFP_OPTIONS_TX_DISABLE      = BIT(4),
0378     SFP_OPTIONS_TX_FAULT        = BIT(3),
0379     SFP_OPTIONS_LOS_INVERTED    = BIT(2),
0380     SFP_OPTIONS_LOS_NORMAL      = BIT(1),
0381     SFP_DIAGMON_DDM         = BIT(6),
0382     SFP_DIAGMON_INT_CAL     = BIT(5),
0383     SFP_DIAGMON_EXT_CAL     = BIT(4),
0384     SFP_DIAGMON_RXPWR_AVG       = BIT(3),
0385     SFP_DIAGMON_ADDRMODE        = BIT(2),
0386     SFP_ENHOPTS_ALARMWARN       = BIT(7),
0387     SFP_ENHOPTS_SOFT_TX_DISABLE = BIT(6),
0388     SFP_ENHOPTS_SOFT_TX_FAULT   = BIT(5),
0389     SFP_ENHOPTS_SOFT_RX_LOS     = BIT(4),
0390     SFP_ENHOPTS_SOFT_RATE_SELECT    = BIT(3),
0391     SFP_ENHOPTS_APP_SELECT_SFF8079  = BIT(2),
0392     SFP_ENHOPTS_SOFT_RATE_SFF8431   = BIT(1),
0393     SFP_SFF8472_COMPLIANCE_NONE = 0x00,
0394     SFP_SFF8472_COMPLIANCE_REV9_3   = 0x01,
0395     SFP_SFF8472_COMPLIANCE_REV9_5   = 0x02,
0396     SFP_SFF8472_COMPLIANCE_REV10_2  = 0x03,
0397     SFP_SFF8472_COMPLIANCE_REV10_4  = 0x04,
0398     SFP_SFF8472_COMPLIANCE_REV11_0  = 0x05,
0399     SFP_SFF8472_COMPLIANCE_REV11_3  = 0x06,
0400     SFP_SFF8472_COMPLIANCE_REV11_4  = 0x07,
0401     SFP_SFF8472_COMPLIANCE_REV12_0  = 0x08,
0402 };
0403 
0404 /* SFP Diagnostics */
0405 enum {
0406     /* Alarm and warnings stored MSB at lower address then LSB */
0407     SFP_TEMP_HIGH_ALARM     = 0x00,
0408     SFP_TEMP_LOW_ALARM      = 0x02,
0409     SFP_TEMP_HIGH_WARN      = 0x04,
0410     SFP_TEMP_LOW_WARN       = 0x06,
0411     SFP_VOLT_HIGH_ALARM     = 0x08,
0412     SFP_VOLT_LOW_ALARM      = 0x0a,
0413     SFP_VOLT_HIGH_WARN      = 0x0c,
0414     SFP_VOLT_LOW_WARN       = 0x0e,
0415     SFP_BIAS_HIGH_ALARM     = 0x10,
0416     SFP_BIAS_LOW_ALARM      = 0x12,
0417     SFP_BIAS_HIGH_WARN      = 0x14,
0418     SFP_BIAS_LOW_WARN       = 0x16,
0419     SFP_TXPWR_HIGH_ALARM        = 0x18,
0420     SFP_TXPWR_LOW_ALARM     = 0x1a,
0421     SFP_TXPWR_HIGH_WARN     = 0x1c,
0422     SFP_TXPWR_LOW_WARN      = 0x1e,
0423     SFP_RXPWR_HIGH_ALARM        = 0x20,
0424     SFP_RXPWR_LOW_ALARM     = 0x22,
0425     SFP_RXPWR_HIGH_WARN     = 0x24,
0426     SFP_RXPWR_LOW_WARN      = 0x26,
0427     SFP_LASER_TEMP_HIGH_ALARM   = 0x28,
0428     SFP_LASER_TEMP_LOW_ALARM    = 0x2a,
0429     SFP_LASER_TEMP_HIGH_WARN    = 0x2c,
0430     SFP_LASER_TEMP_LOW_WARN     = 0x2e,
0431     SFP_TEC_CUR_HIGH_ALARM      = 0x30,
0432     SFP_TEC_CUR_LOW_ALARM       = 0x32,
0433     SFP_TEC_CUR_HIGH_WARN       = 0x34,
0434     SFP_TEC_CUR_LOW_WARN        = 0x36,
0435     SFP_CAL_RXPWR4          = 0x38,
0436     SFP_CAL_RXPWR3          = 0x3c,
0437     SFP_CAL_RXPWR2          = 0x40,
0438     SFP_CAL_RXPWR1          = 0x44,
0439     SFP_CAL_RXPWR0          = 0x48,
0440     SFP_CAL_TXI_SLOPE       = 0x4c,
0441     SFP_CAL_TXI_OFFSET      = 0x4e,
0442     SFP_CAL_TXPWR_SLOPE     = 0x50,
0443     SFP_CAL_TXPWR_OFFSET        = 0x52,
0444     SFP_CAL_T_SLOPE         = 0x54,
0445     SFP_CAL_T_OFFSET        = 0x56,
0446     SFP_CAL_V_SLOPE         = 0x58,
0447     SFP_CAL_V_OFFSET        = 0x5a,
0448     SFP_CHKSUM          = 0x5f,
0449 
0450     SFP_TEMP            = 0x60,
0451     SFP_VCC             = 0x62,
0452     SFP_TX_BIAS         = 0x64,
0453     SFP_TX_POWER            = 0x66,
0454     SFP_RX_POWER            = 0x68,
0455     SFP_LASER_TEMP          = 0x6a,
0456     SFP_TEC_CUR         = 0x6c,
0457 
0458     SFP_STATUS          = 0x6e,
0459     SFP_STATUS_TX_DISABLE       = BIT(7),
0460     SFP_STATUS_TX_DISABLE_FORCE = BIT(6),
0461     SFP_STATUS_TX_FAULT     = BIT(2),
0462     SFP_STATUS_RX_LOS       = BIT(1),
0463     SFP_ALARM0          = 0x70,
0464     SFP_ALARM0_TEMP_HIGH        = BIT(7),
0465     SFP_ALARM0_TEMP_LOW     = BIT(6),
0466     SFP_ALARM0_VCC_HIGH     = BIT(5),
0467     SFP_ALARM0_VCC_LOW      = BIT(4),
0468     SFP_ALARM0_TX_BIAS_HIGH     = BIT(3),
0469     SFP_ALARM0_TX_BIAS_LOW      = BIT(2),
0470     SFP_ALARM0_TXPWR_HIGH       = BIT(1),
0471     SFP_ALARM0_TXPWR_LOW        = BIT(0),
0472 
0473     SFP_ALARM1          = 0x71,
0474     SFP_ALARM1_RXPWR_HIGH       = BIT(7),
0475     SFP_ALARM1_RXPWR_LOW        = BIT(6),
0476 
0477     SFP_WARN0           = 0x74,
0478     SFP_WARN0_TEMP_HIGH     = BIT(7),
0479     SFP_WARN0_TEMP_LOW      = BIT(6),
0480     SFP_WARN0_VCC_HIGH      = BIT(5),
0481     SFP_WARN0_VCC_LOW       = BIT(4),
0482     SFP_WARN0_TX_BIAS_HIGH      = BIT(3),
0483     SFP_WARN0_TX_BIAS_LOW       = BIT(2),
0484     SFP_WARN0_TXPWR_HIGH        = BIT(1),
0485     SFP_WARN0_TXPWR_LOW     = BIT(0),
0486 
0487     SFP_WARN1           = 0x75,
0488     SFP_WARN1_RXPWR_HIGH        = BIT(7),
0489     SFP_WARN1_RXPWR_LOW     = BIT(6),
0490 
0491     SFP_EXT_STATUS          = 0x76,
0492     SFP_VSL             = 0x78,
0493     SFP_PAGE            = 0x7f,
0494 };
0495 
0496 struct fwnode_handle;
0497 struct ethtool_eeprom;
0498 struct ethtool_modinfo;
0499 struct sfp_bus;
0500 
0501 /**
0502  * struct sfp_upstream_ops - upstream operations structure
0503  * @attach: called when the sfp socket driver is bound to the upstream
0504  *   (mandatory).
0505  * @detach: called when the sfp socket driver is unbound from the upstream
0506  *   (mandatory).
0507  * @module_insert: called after a module has been detected to determine
0508  *   whether the module is supported for the upstream device.
0509  * @module_remove: called after the module has been removed.
0510  * @module_start: called after the PHY probe step
0511  * @module_stop: called before the PHY is removed
0512  * @link_down: called when the link is non-operational for whatever
0513  *   reason.
0514  * @link_up: called when the link is operational.
0515  * @connect_phy: called when an I2C accessible PHY has been detected
0516  *   on the module.
0517  * @disconnect_phy: called when a module with an I2C accessible PHY has
0518  *   been removed.
0519  */
0520 struct sfp_upstream_ops {
0521     void (*attach)(void *priv, struct sfp_bus *bus);
0522     void (*detach)(void *priv, struct sfp_bus *bus);
0523     int (*module_insert)(void *priv, const struct sfp_eeprom_id *id);
0524     void (*module_remove)(void *priv);
0525     int (*module_start)(void *priv);
0526     void (*module_stop)(void *priv);
0527     void (*link_down)(void *priv);
0528     void (*link_up)(void *priv);
0529     int (*connect_phy)(void *priv, struct phy_device *);
0530     void (*disconnect_phy)(void *priv);
0531 };
0532 
0533 #if IS_ENABLED(CONFIG_SFP)
0534 int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
0535            unsigned long *support);
0536 bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id);
0537 void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
0538                unsigned long *support);
0539 phy_interface_t sfp_select_interface(struct sfp_bus *bus,
0540                      unsigned long *link_modes);
0541 
0542 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
0543 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
0544               u8 *data);
0545 int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
0546                   const struct ethtool_module_eeprom *page,
0547                   struct netlink_ext_ack *extack);
0548 void sfp_upstream_start(struct sfp_bus *bus);
0549 void sfp_upstream_stop(struct sfp_bus *bus);
0550 void sfp_bus_put(struct sfp_bus *bus);
0551 struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode);
0552 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
0553              const struct sfp_upstream_ops *ops);
0554 void sfp_bus_del_upstream(struct sfp_bus *bus);
0555 #else
0556 static inline int sfp_parse_port(struct sfp_bus *bus,
0557                  const struct sfp_eeprom_id *id,
0558                  unsigned long *support)
0559 {
0560     return PORT_OTHER;
0561 }
0562 
0563 static inline bool sfp_may_have_phy(struct sfp_bus *bus,
0564                     const struct sfp_eeprom_id *id)
0565 {
0566     return false;
0567 }
0568 
0569 static inline void sfp_parse_support(struct sfp_bus *bus,
0570                      const struct sfp_eeprom_id *id,
0571                      unsigned long *support)
0572 {
0573 }
0574 
0575 static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus,
0576                            unsigned long *link_modes)
0577 {
0578     return PHY_INTERFACE_MODE_NA;
0579 }
0580 
0581 static inline int sfp_get_module_info(struct sfp_bus *bus,
0582                       struct ethtool_modinfo *modinfo)
0583 {
0584     return -EOPNOTSUPP;
0585 }
0586 
0587 static inline int sfp_get_module_eeprom(struct sfp_bus *bus,
0588                     struct ethtool_eeprom *ee, u8 *data)
0589 {
0590     return -EOPNOTSUPP;
0591 }
0592 
0593 static inline int sfp_get_module_eeprom_by_page(struct sfp_bus *bus,
0594                         const struct ethtool_module_eeprom *page,
0595                         struct netlink_ext_ack *extack)
0596 {
0597     return -EOPNOTSUPP;
0598 }
0599 
0600 static inline void sfp_upstream_start(struct sfp_bus *bus)
0601 {
0602 }
0603 
0604 static inline void sfp_upstream_stop(struct sfp_bus *bus)
0605 {
0606 }
0607 
0608 static inline void sfp_bus_put(struct sfp_bus *bus)
0609 {
0610 }
0611 
0612 static inline struct sfp_bus *sfp_bus_find_fwnode(struct fwnode_handle *fwnode)
0613 {
0614     return NULL;
0615 }
0616 
0617 static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
0618                        const struct sfp_upstream_ops *ops)
0619 {
0620     return 0;
0621 }
0622 
0623 static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
0624 {
0625 }
0626 #endif
0627 
0628 #endif