sfp.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. #ifndef LINUX_SFP_H
  2. #define LINUX_SFP_H
  3. #include <linux/phy.h>
  4. struct sfp_eeprom_base {
  5. u8 phys_id;
  6. u8 phys_ext_id;
  7. u8 connector;
  8. #if defined __BIG_ENDIAN_BITFIELD
  9. u8 e10g_base_er:1;
  10. u8 e10g_base_lrm:1;
  11. u8 e10g_base_lr:1;
  12. u8 e10g_base_sr:1;
  13. u8 if_1x_sx:1;
  14. u8 if_1x_lx:1;
  15. u8 if_1x_copper_active:1;
  16. u8 if_1x_copper_passive:1;
  17. u8 escon_mmf_1310_led:1;
  18. u8 escon_smf_1310_laser:1;
  19. u8 sonet_oc192_short_reach:1;
  20. u8 sonet_reach_bit1:1;
  21. u8 sonet_reach_bit2:1;
  22. u8 sonet_oc48_long_reach:1;
  23. u8 sonet_oc48_intermediate_reach:1;
  24. u8 sonet_oc48_short_reach:1;
  25. u8 unallocated_5_7:1;
  26. u8 sonet_oc12_smf_long_reach:1;
  27. u8 sonet_oc12_smf_intermediate_reach:1;
  28. u8 sonet_oc12_short_reach:1;
  29. u8 unallocated_5_3:1;
  30. u8 sonet_oc3_smf_long_reach:1;
  31. u8 sonet_oc3_smf_intermediate_reach:1;
  32. u8 sonet_oc3_short_reach:1;
  33. u8 e_base_px:1;
  34. u8 e_base_bx10:1;
  35. u8 e100_base_fx:1;
  36. u8 e100_base_lx:1;
  37. u8 e1000_base_t:1;
  38. u8 e1000_base_cx:1;
  39. u8 e1000_base_lx:1;
  40. u8 e1000_base_sx:1;
  41. u8 fc_ll_v:1;
  42. u8 fc_ll_s:1;
  43. u8 fc_ll_i:1;
  44. u8 fc_ll_l:1;
  45. u8 fc_ll_m:1;
  46. u8 fc_tech_sa:1;
  47. u8 fc_tech_lc:1;
  48. u8 fc_tech_electrical_inter_enclosure:1;
  49. u8 fc_tech_electrical_intra_enclosure:1;
  50. u8 fc_tech_sn:1;
  51. u8 fc_tech_sl:1;
  52. u8 fc_tech_ll:1;
  53. u8 sfp_ct_active:1;
  54. u8 sfp_ct_passive:1;
  55. u8 unallocated_8_1:1;
  56. u8 unallocated_8_0:1;
  57. u8 fc_media_tw:1;
  58. u8 fc_media_tp:1;
  59. u8 fc_media_mi:1;
  60. u8 fc_media_tv:1;
  61. u8 fc_media_m6:1;
  62. u8 fc_media_m5:1;
  63. u8 unallocated_9_1:1;
  64. u8 fc_media_sm:1;
  65. u8 fc_speed_1200:1;
  66. u8 fc_speed_800:1;
  67. u8 fc_speed_1600:1;
  68. u8 fc_speed_400:1;
  69. u8 fc_speed_3200:1;
  70. u8 fc_speed_200:1;
  71. u8 unallocated_10_1:1;
  72. u8 fc_speed_100:1;
  73. #elif defined __LITTLE_ENDIAN_BITFIELD
  74. u8 if_1x_copper_passive:1;
  75. u8 if_1x_copper_active:1;
  76. u8 if_1x_lx:1;
  77. u8 if_1x_sx:1;
  78. u8 e10g_base_sr:1;
  79. u8 e10g_base_lr:1;
  80. u8 e10g_base_lrm:1;
  81. u8 e10g_base_er:1;
  82. u8 sonet_oc3_short_reach:1;
  83. u8 sonet_oc3_smf_intermediate_reach:1;
  84. u8 sonet_oc3_smf_long_reach:1;
  85. u8 unallocated_5_3:1;
  86. u8 sonet_oc12_short_reach:1;
  87. u8 sonet_oc12_smf_intermediate_reach:1;
  88. u8 sonet_oc12_smf_long_reach:1;
  89. u8 unallocated_5_7:1;
  90. u8 sonet_oc48_short_reach:1;
  91. u8 sonet_oc48_intermediate_reach:1;
  92. u8 sonet_oc48_long_reach:1;
  93. u8 sonet_reach_bit2:1;
  94. u8 sonet_reach_bit1:1;
  95. u8 sonet_oc192_short_reach:1;
  96. u8 escon_smf_1310_laser:1;
  97. u8 escon_mmf_1310_led:1;
  98. u8 e1000_base_sx:1;
  99. u8 e1000_base_lx:1;
  100. u8 e1000_base_cx:1;
  101. u8 e1000_base_t:1;
  102. u8 e100_base_lx:1;
  103. u8 e100_base_fx:1;
  104. u8 e_base_bx10:1;
  105. u8 e_base_px:1;
  106. u8 fc_tech_electrical_inter_enclosure:1;
  107. u8 fc_tech_lc:1;
  108. u8 fc_tech_sa:1;
  109. u8 fc_ll_m:1;
  110. u8 fc_ll_l:1;
  111. u8 fc_ll_i:1;
  112. u8 fc_ll_s:1;
  113. u8 fc_ll_v:1;
  114. u8 unallocated_8_0:1;
  115. u8 unallocated_8_1:1;
  116. u8 sfp_ct_passive:1;
  117. u8 sfp_ct_active:1;
  118. u8 fc_tech_ll:1;
  119. u8 fc_tech_sl:1;
  120. u8 fc_tech_sn:1;
  121. u8 fc_tech_electrical_intra_enclosure:1;
  122. u8 fc_media_sm:1;
  123. u8 unallocated_9_1:1;
  124. u8 fc_media_m5:1;
  125. u8 fc_media_m6:1;
  126. u8 fc_media_tv:1;
  127. u8 fc_media_mi:1;
  128. u8 fc_media_tp:1;
  129. u8 fc_media_tw:1;
  130. u8 fc_speed_100:1;
  131. u8 unallocated_10_1:1;
  132. u8 fc_speed_200:1;
  133. u8 fc_speed_3200:1;
  134. u8 fc_speed_400:1;
  135. u8 fc_speed_1600:1;
  136. u8 fc_speed_800:1;
  137. u8 fc_speed_1200:1;
  138. #else
  139. #error Unknown Endian
  140. #endif
  141. u8 encoding;
  142. u8 br_nominal;
  143. u8 rate_id;
  144. u8 link_len[6];
  145. char vendor_name[16];
  146. u8 extended_cc;
  147. char vendor_oui[3];
  148. char vendor_pn[16];
  149. char vendor_rev[4];
  150. union {
  151. __be16 optical_wavelength;
  152. __be16 cable_compliance;
  153. struct {
  154. #if defined __BIG_ENDIAN_BITFIELD
  155. u8 reserved60_2:6;
  156. u8 fc_pi_4_app_h:1;
  157. u8 sff8431_app_e:1;
  158. u8 reserved61:8;
  159. #elif defined __LITTLE_ENDIAN_BITFIELD
  160. u8 sff8431_app_e:1;
  161. u8 fc_pi_4_app_h:1;
  162. u8 reserved60_2:6;
  163. u8 reserved61:8;
  164. #else
  165. #error Unknown Endian
  166. #endif
  167. } __packed passive;
  168. struct {
  169. #if defined __BIG_ENDIAN_BITFIELD
  170. u8 reserved60_4:4;
  171. u8 fc_pi_4_lim:1;
  172. u8 sff8431_lim:1;
  173. u8 fc_pi_4_app_h:1;
  174. u8 sff8431_app_e:1;
  175. u8 reserved61:8;
  176. #elif defined __LITTLE_ENDIAN_BITFIELD
  177. u8 sff8431_app_e:1;
  178. u8 fc_pi_4_app_h:1;
  179. u8 sff8431_lim:1;
  180. u8 fc_pi_4_lim:1;
  181. u8 reserved60_4:4;
  182. u8 reserved61:8;
  183. #else
  184. #error Unknown Endian
  185. #endif
  186. } __packed active;
  187. } __packed;
  188. u8 reserved62;
  189. u8 cc_base;
  190. } __packed;
  191. struct sfp_eeprom_ext {
  192. __be16 options;
  193. u8 br_max;
  194. u8 br_min;
  195. char vendor_sn[16];
  196. char datecode[8];
  197. u8 diagmon;
  198. u8 enhopts;
  199. u8 sff8472_compliance;
  200. u8 cc_ext;
  201. } __packed;
  202. /**
  203. * struct sfp_eeprom_id - raw SFP module identification information
  204. * @base: base SFP module identification structure
  205. * @ext: extended SFP module identification structure
  206. *
  207. * See the SFF-8472 specification and related documents for the definition
  208. * of these structure members. This can be obtained from
  209. * ftp://ftp.seagate.com/sff
  210. */
  211. struct sfp_eeprom_id {
  212. struct sfp_eeprom_base base;
  213. struct sfp_eeprom_ext ext;
  214. } __packed;
  215. struct sfp_diag {
  216. __be16 temp_high_alarm;
  217. __be16 temp_low_alarm;
  218. __be16 temp_high_warn;
  219. __be16 temp_low_warn;
  220. __be16 volt_high_alarm;
  221. __be16 volt_low_alarm;
  222. __be16 volt_high_warn;
  223. __be16 volt_low_warn;
  224. __be16 bias_high_alarm;
  225. __be16 bias_low_alarm;
  226. __be16 bias_high_warn;
  227. __be16 bias_low_warn;
  228. __be16 txpwr_high_alarm;
  229. __be16 txpwr_low_alarm;
  230. __be16 txpwr_high_warn;
  231. __be16 txpwr_low_warn;
  232. __be16 rxpwr_high_alarm;
  233. __be16 rxpwr_low_alarm;
  234. __be16 rxpwr_high_warn;
  235. __be16 rxpwr_low_warn;
  236. __be16 laser_temp_high_alarm;
  237. __be16 laser_temp_low_alarm;
  238. __be16 laser_temp_high_warn;
  239. __be16 laser_temp_low_warn;
  240. __be16 tec_cur_high_alarm;
  241. __be16 tec_cur_low_alarm;
  242. __be16 tec_cur_high_warn;
  243. __be16 tec_cur_low_warn;
  244. __be32 cal_rxpwr4;
  245. __be32 cal_rxpwr3;
  246. __be32 cal_rxpwr2;
  247. __be32 cal_rxpwr1;
  248. __be32 cal_rxpwr0;
  249. __be16 cal_txi_slope;
  250. __be16 cal_txi_offset;
  251. __be16 cal_txpwr_slope;
  252. __be16 cal_txpwr_offset;
  253. __be16 cal_t_slope;
  254. __be16 cal_t_offset;
  255. __be16 cal_v_slope;
  256. __be16 cal_v_offset;
  257. } __packed;
  258. /* SFP EEPROM registers */
  259. enum {
  260. SFP_PHYS_ID = 0x00,
  261. SFP_PHYS_EXT_ID = 0x01,
  262. SFP_CONNECTOR = 0x02,
  263. SFP_COMPLIANCE = 0x03,
  264. SFP_ENCODING = 0x0b,
  265. SFP_BR_NOMINAL = 0x0c,
  266. SFP_RATE_ID = 0x0d,
  267. SFP_LINK_LEN_SM_KM = 0x0e,
  268. SFP_LINK_LEN_SM_100M = 0x0f,
  269. SFP_LINK_LEN_50UM_OM2_10M = 0x10,
  270. SFP_LINK_LEN_62_5UM_OM1_10M = 0x11,
  271. SFP_LINK_LEN_COPPER_1M = 0x12,
  272. SFP_LINK_LEN_50UM_OM4_10M = 0x12,
  273. SFP_LINK_LEN_50UM_OM3_10M = 0x13,
  274. SFP_VENDOR_NAME = 0x14,
  275. SFP_VENDOR_OUI = 0x25,
  276. SFP_VENDOR_PN = 0x28,
  277. SFP_VENDOR_REV = 0x38,
  278. SFP_OPTICAL_WAVELENGTH_MSB = 0x3c,
  279. SFP_OPTICAL_WAVELENGTH_LSB = 0x3d,
  280. SFP_CABLE_SPEC = 0x3c,
  281. SFP_CC_BASE = 0x3f,
  282. SFP_OPTIONS = 0x40, /* 2 bytes, MSB, LSB */
  283. SFP_BR_MAX = 0x42,
  284. SFP_BR_MIN = 0x43,
  285. SFP_VENDOR_SN = 0x44,
  286. SFP_DATECODE = 0x54,
  287. SFP_DIAGMON = 0x5c,
  288. SFP_ENHOPTS = 0x5d,
  289. SFP_SFF8472_COMPLIANCE = 0x5e,
  290. SFP_CC_EXT = 0x5f,
  291. SFP_PHYS_ID_SFF = 0x02,
  292. SFP_PHYS_ID_SFP = 0x03,
  293. SFP_PHYS_EXT_ID_SFP = 0x04,
  294. SFP_CONNECTOR_UNSPEC = 0x00,
  295. /* codes 01-05 not supportable on SFP, but some modules have single SC */
  296. SFP_CONNECTOR_SC = 0x01,
  297. SFP_CONNECTOR_FIBERJACK = 0x06,
  298. SFP_CONNECTOR_LC = 0x07,
  299. SFP_CONNECTOR_MT_RJ = 0x08,
  300. SFP_CONNECTOR_MU = 0x09,
  301. SFP_CONNECTOR_SG = 0x0a,
  302. SFP_CONNECTOR_OPTICAL_PIGTAIL = 0x0b,
  303. SFP_CONNECTOR_MPO_1X12 = 0x0c,
  304. SFP_CONNECTOR_MPO_2X16 = 0x0d,
  305. SFP_CONNECTOR_HSSDC_II = 0x20,
  306. SFP_CONNECTOR_COPPER_PIGTAIL = 0x21,
  307. SFP_CONNECTOR_RJ45 = 0x22,
  308. SFP_CONNECTOR_NOSEPARATE = 0x23,
  309. SFP_CONNECTOR_MXC_2X16 = 0x24,
  310. SFP_ENCODING_UNSPEC = 0x00,
  311. SFP_ENCODING_8B10B = 0x01,
  312. SFP_ENCODING_4B5B = 0x02,
  313. SFP_ENCODING_NRZ = 0x03,
  314. SFP_ENCODING_8472_MANCHESTER = 0x04,
  315. SFP_ENCODING_8472_SONET = 0x05,
  316. SFP_ENCODING_8472_64B66B = 0x06,
  317. SFP_ENCODING_256B257B = 0x07,
  318. SFP_ENCODING_PAM4 = 0x08,
  319. SFP_OPTIONS_HIGH_POWER_LEVEL = BIT(13),
  320. SFP_OPTIONS_PAGING_A2 = BIT(12),
  321. SFP_OPTIONS_RETIMER = BIT(11),
  322. SFP_OPTIONS_COOLED_XCVR = BIT(10),
  323. SFP_OPTIONS_POWER_DECL = BIT(9),
  324. SFP_OPTIONS_RX_LINEAR_OUT = BIT(8),
  325. SFP_OPTIONS_RX_DECISION_THRESH = BIT(7),
  326. SFP_OPTIONS_TUNABLE_TX = BIT(6),
  327. SFP_OPTIONS_RATE_SELECT = BIT(5),
  328. SFP_OPTIONS_TX_DISABLE = BIT(4),
  329. SFP_OPTIONS_TX_FAULT = BIT(3),
  330. SFP_OPTIONS_LOS_INVERTED = BIT(2),
  331. SFP_OPTIONS_LOS_NORMAL = BIT(1),
  332. SFP_DIAGMON_DDM = BIT(6),
  333. SFP_DIAGMON_INT_CAL = BIT(5),
  334. SFP_DIAGMON_EXT_CAL = BIT(4),
  335. SFP_DIAGMON_RXPWR_AVG = BIT(3),
  336. SFP_DIAGMON_ADDRMODE = BIT(2),
  337. SFP_ENHOPTS_ALARMWARN = BIT(7),
  338. SFP_ENHOPTS_SOFT_TX_DISABLE = BIT(6),
  339. SFP_ENHOPTS_SOFT_TX_FAULT = BIT(5),
  340. SFP_ENHOPTS_SOFT_RX_LOS = BIT(4),
  341. SFP_ENHOPTS_SOFT_RATE_SELECT = BIT(3),
  342. SFP_ENHOPTS_APP_SELECT_SFF8079 = BIT(2),
  343. SFP_ENHOPTS_SOFT_RATE_SFF8431 = BIT(1),
  344. SFP_SFF8472_COMPLIANCE_NONE = 0x00,
  345. SFP_SFF8472_COMPLIANCE_REV9_3 = 0x01,
  346. SFP_SFF8472_COMPLIANCE_REV9_5 = 0x02,
  347. SFP_SFF8472_COMPLIANCE_REV10_2 = 0x03,
  348. SFP_SFF8472_COMPLIANCE_REV10_4 = 0x04,
  349. SFP_SFF8472_COMPLIANCE_REV11_0 = 0x05,
  350. SFP_SFF8472_COMPLIANCE_REV11_3 = 0x06,
  351. SFP_SFF8472_COMPLIANCE_REV11_4 = 0x07,
  352. SFP_SFF8472_COMPLIANCE_REV12_0 = 0x08,
  353. };
  354. /* SFP Diagnostics */
  355. enum {
  356. /* Alarm and warnings stored MSB at lower address then LSB */
  357. SFP_TEMP_HIGH_ALARM = 0x00,
  358. SFP_TEMP_LOW_ALARM = 0x02,
  359. SFP_TEMP_HIGH_WARN = 0x04,
  360. SFP_TEMP_LOW_WARN = 0x06,
  361. SFP_VOLT_HIGH_ALARM = 0x08,
  362. SFP_VOLT_LOW_ALARM = 0x0a,
  363. SFP_VOLT_HIGH_WARN = 0x0c,
  364. SFP_VOLT_LOW_WARN = 0x0e,
  365. SFP_BIAS_HIGH_ALARM = 0x10,
  366. SFP_BIAS_LOW_ALARM = 0x12,
  367. SFP_BIAS_HIGH_WARN = 0x14,
  368. SFP_BIAS_LOW_WARN = 0x16,
  369. SFP_TXPWR_HIGH_ALARM = 0x18,
  370. SFP_TXPWR_LOW_ALARM = 0x1a,
  371. SFP_TXPWR_HIGH_WARN = 0x1c,
  372. SFP_TXPWR_LOW_WARN = 0x1e,
  373. SFP_RXPWR_HIGH_ALARM = 0x20,
  374. SFP_RXPWR_LOW_ALARM = 0x22,
  375. SFP_RXPWR_HIGH_WARN = 0x24,
  376. SFP_RXPWR_LOW_WARN = 0x26,
  377. SFP_LASER_TEMP_HIGH_ALARM = 0x28,
  378. SFP_LASER_TEMP_LOW_ALARM = 0x2a,
  379. SFP_LASER_TEMP_HIGH_WARN = 0x2c,
  380. SFP_LASER_TEMP_LOW_WARN = 0x2e,
  381. SFP_TEC_CUR_HIGH_ALARM = 0x30,
  382. SFP_TEC_CUR_LOW_ALARM = 0x32,
  383. SFP_TEC_CUR_HIGH_WARN = 0x34,
  384. SFP_TEC_CUR_LOW_WARN = 0x36,
  385. SFP_CAL_RXPWR4 = 0x38,
  386. SFP_CAL_RXPWR3 = 0x3c,
  387. SFP_CAL_RXPWR2 = 0x40,
  388. SFP_CAL_RXPWR1 = 0x44,
  389. SFP_CAL_RXPWR0 = 0x48,
  390. SFP_CAL_TXI_SLOPE = 0x4c,
  391. SFP_CAL_TXI_OFFSET = 0x4e,
  392. SFP_CAL_TXPWR_SLOPE = 0x50,
  393. SFP_CAL_TXPWR_OFFSET = 0x52,
  394. SFP_CAL_T_SLOPE = 0x54,
  395. SFP_CAL_T_OFFSET = 0x56,
  396. SFP_CAL_V_SLOPE = 0x58,
  397. SFP_CAL_V_OFFSET = 0x5a,
  398. SFP_CHKSUM = 0x5f,
  399. SFP_TEMP = 0x60,
  400. SFP_VCC = 0x62,
  401. SFP_TX_BIAS = 0x64,
  402. SFP_TX_POWER = 0x66,
  403. SFP_RX_POWER = 0x68,
  404. SFP_LASER_TEMP = 0x6a,
  405. SFP_TEC_CUR = 0x6c,
  406. SFP_STATUS = 0x6e,
  407. SFP_ALARM0 = 0x70,
  408. SFP_ALARM0_TEMP_HIGH = BIT(7),
  409. SFP_ALARM0_TEMP_LOW = BIT(6),
  410. SFP_ALARM0_VCC_HIGH = BIT(5),
  411. SFP_ALARM0_VCC_LOW = BIT(4),
  412. SFP_ALARM0_TX_BIAS_HIGH = BIT(3),
  413. SFP_ALARM0_TX_BIAS_LOW = BIT(2),
  414. SFP_ALARM0_TXPWR_HIGH = BIT(1),
  415. SFP_ALARM0_TXPWR_LOW = BIT(0),
  416. SFP_ALARM1 = 0x71,
  417. SFP_ALARM1_RXPWR_HIGH = BIT(7),
  418. SFP_ALARM1_RXPWR_LOW = BIT(6),
  419. SFP_WARN0 = 0x74,
  420. SFP_WARN0_TEMP_HIGH = BIT(7),
  421. SFP_WARN0_TEMP_LOW = BIT(6),
  422. SFP_WARN0_VCC_HIGH = BIT(5),
  423. SFP_WARN0_VCC_LOW = BIT(4),
  424. SFP_WARN0_TX_BIAS_HIGH = BIT(3),
  425. SFP_WARN0_TX_BIAS_LOW = BIT(2),
  426. SFP_WARN0_TXPWR_HIGH = BIT(1),
  427. SFP_WARN0_TXPWR_LOW = BIT(0),
  428. SFP_WARN1 = 0x75,
  429. SFP_WARN1_RXPWR_HIGH = BIT(7),
  430. SFP_WARN1_RXPWR_LOW = BIT(6),
  431. SFP_EXT_STATUS = 0x76,
  432. SFP_VSL = 0x78,
  433. SFP_PAGE = 0x7f,
  434. };
  435. struct fwnode_handle;
  436. struct ethtool_eeprom;
  437. struct ethtool_modinfo;
  438. struct net_device;
  439. struct sfp_bus;
  440. /**
  441. * struct sfp_upstream_ops - upstream operations structure
  442. * @module_insert: called after a module has been detected to determine
  443. * whether the module is supported for the upstream device.
  444. * @module_remove: called after the module has been removed.
  445. * @link_down: called when the link is non-operational for whatever
  446. * reason.
  447. * @link_up: called when the link is operational.
  448. * @connect_phy: called when an I2C accessible PHY has been detected
  449. * on the module.
  450. * @disconnect_phy: called when a module with an I2C accessible PHY has
  451. * been removed.
  452. */
  453. struct sfp_upstream_ops {
  454. int (*module_insert)(void *priv, const struct sfp_eeprom_id *id);
  455. void (*module_remove)(void *priv);
  456. void (*link_down)(void *priv);
  457. void (*link_up)(void *priv);
  458. int (*connect_phy)(void *priv, struct phy_device *);
  459. void (*disconnect_phy)(void *priv);
  460. };
  461. #if IS_ENABLED(CONFIG_SFP)
  462. int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
  463. unsigned long *support);
  464. void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
  465. unsigned long *support);
  466. phy_interface_t sfp_select_interface(struct sfp_bus *bus,
  467. const struct sfp_eeprom_id *id,
  468. unsigned long *link_modes);
  469. int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo);
  470. int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
  471. u8 *data);
  472. void sfp_upstream_start(struct sfp_bus *bus);
  473. void sfp_upstream_stop(struct sfp_bus *bus);
  474. struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
  475. struct net_device *ndev, void *upstream,
  476. const struct sfp_upstream_ops *ops);
  477. void sfp_unregister_upstream(struct sfp_bus *bus);
  478. #else
  479. static inline int sfp_parse_port(struct sfp_bus *bus,
  480. const struct sfp_eeprom_id *id,
  481. unsigned long *support)
  482. {
  483. return PORT_OTHER;
  484. }
  485. static inline void sfp_parse_support(struct sfp_bus *bus,
  486. const struct sfp_eeprom_id *id,
  487. unsigned long *support)
  488. {
  489. }
  490. static inline phy_interface_t sfp_select_interface(struct sfp_bus *bus,
  491. const struct sfp_eeprom_id *id,
  492. unsigned long *link_modes)
  493. {
  494. return PHY_INTERFACE_MODE_NA;
  495. }
  496. static inline int sfp_get_module_info(struct sfp_bus *bus,
  497. struct ethtool_modinfo *modinfo)
  498. {
  499. return -EOPNOTSUPP;
  500. }
  501. static inline int sfp_get_module_eeprom(struct sfp_bus *bus,
  502. struct ethtool_eeprom *ee, u8 *data)
  503. {
  504. return -EOPNOTSUPP;
  505. }
  506. static inline void sfp_upstream_start(struct sfp_bus *bus)
  507. {
  508. }
  509. static inline void sfp_upstream_stop(struct sfp_bus *bus)
  510. {
  511. }
  512. static inline struct sfp_bus *sfp_register_upstream(
  513. struct fwnode_handle *fwnode,
  514. struct net_device *ndev, void *upstream,
  515. const struct sfp_upstream_ops *ops)
  516. {
  517. return (struct sfp_bus *)-1;
  518. }
  519. static inline void sfp_unregister_upstream(struct sfp_bus *bus)
  520. {
  521. }
  522. #endif
  523. #endif