diff options
Diffstat (limited to 'include/linux/sfp.h')
-rw-r--r-- | include/linux/sfp.h | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/include/linux/sfp.h b/include/linux/sfp.h index 4a906f560817..e724d5a3dd80 100644 --- a/include/linux/sfp.h +++ b/include/linux/sfp.h | |||
@@ -3,7 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/phy.h> | 4 | #include <linux/phy.h> |
5 | 5 | ||
6 | struct __packed sfp_eeprom_base { | 6 | struct sfp_eeprom_base { |
7 | u8 phys_id; | 7 | u8 phys_id; |
8 | u8 phys_ext_id; | 8 | u8 phys_ext_id; |
9 | u8 connector; | 9 | u8 connector; |
@@ -165,13 +165,47 @@ struct __packed sfp_eeprom_base { | |||
165 | char vendor_rev[4]; | 165 | char vendor_rev[4]; |
166 | union { | 166 | union { |
167 | __be16 optical_wavelength; | 167 | __be16 optical_wavelength; |
168 | u8 cable_spec; | 168 | __be16 cable_compliance; |
169 | }; | 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; | ||
170 | u8 reserved62; | 204 | u8 reserved62; |
171 | u8 cc_base; | 205 | u8 cc_base; |
172 | }; | 206 | } __packed; |
173 | 207 | ||
174 | struct __packed sfp_eeprom_ext { | 208 | struct sfp_eeprom_ext { |
175 | __be16 options; | 209 | __be16 options; |
176 | u8 br_max; | 210 | u8 br_max; |
177 | u8 br_min; | 211 | u8 br_min; |
@@ -181,12 +215,21 @@ struct __packed sfp_eeprom_ext { | |||
181 | u8 enhopts; | 215 | u8 enhopts; |
182 | u8 sff8472_compliance; | 216 | u8 sff8472_compliance; |
183 | u8 cc_ext; | 217 | u8 cc_ext; |
184 | }; | 218 | } __packed; |
185 | 219 | ||
186 | struct __packed sfp_eeprom_id { | 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 | * ftp://ftp.seagate.com/sff | ||
228 | */ | ||
229 | struct sfp_eeprom_id { | ||
187 | struct sfp_eeprom_base base; | 230 | struct sfp_eeprom_base base; |
188 | struct sfp_eeprom_ext ext; | 231 | struct sfp_eeprom_ext ext; |
189 | }; | 232 | } __packed; |
190 | 233 | ||
191 | /* SFP EEPROM registers */ | 234 | /* SFP EEPROM registers */ |
192 | enum { | 235 | enum { |
@@ -222,6 +265,7 @@ enum { | |||
222 | SFP_SFF8472_COMPLIANCE = 0x5e, | 265 | SFP_SFF8472_COMPLIANCE = 0x5e, |
223 | SFP_CC_EXT = 0x5f, | 266 | SFP_CC_EXT = 0x5f, |
224 | 267 | ||
268 | SFP_PHYS_ID_SFF = 0x02, | ||
225 | SFP_PHYS_ID_SFP = 0x03, | 269 | SFP_PHYS_ID_SFP = 0x03, |
226 | SFP_PHYS_EXT_ID_SFP = 0x04, | 270 | SFP_PHYS_EXT_ID_SFP = 0x04, |
227 | SFP_CONNECTOR_UNSPEC = 0x00, | 271 | SFP_CONNECTOR_UNSPEC = 0x00, |
@@ -347,19 +391,32 @@ enum { | |||
347 | SFP_PAGE = 0x7f, | 391 | SFP_PAGE = 0x7f, |
348 | }; | 392 | }; |
349 | 393 | ||
350 | struct device_node; | 394 | struct fwnode_handle; |
351 | struct ethtool_eeprom; | 395 | struct ethtool_eeprom; |
352 | struct ethtool_modinfo; | 396 | struct ethtool_modinfo; |
353 | struct net_device; | 397 | struct net_device; |
354 | struct sfp_bus; | 398 | struct sfp_bus; |
355 | 399 | ||
400 | /** | ||
401 | * struct sfp_upstream_ops - upstream operations structure | ||
402 | * @module_insert: called after a module has been detected to determine | ||
403 | * whether the module is supported for the upstream device. | ||
404 | * @module_remove: called after the module has been removed. | ||
405 | * @link_down: called when the link is non-operational for whatever | ||
406 | * reason. | ||
407 | * @link_up: called when the link is operational. | ||
408 | * @connect_phy: called when an I2C accessible PHY has been detected | ||
409 | * on the module. | ||
410 | * @disconnect_phy: called when a module with an I2C accessible PHY has | ||
411 | * been removed. | ||
412 | */ | ||
356 | struct sfp_upstream_ops { | 413 | struct sfp_upstream_ops { |
357 | int (*module_insert)(void *, const struct sfp_eeprom_id *id); | 414 | int (*module_insert)(void *priv, const struct sfp_eeprom_id *id); |
358 | void (*module_remove)(void *); | 415 | void (*module_remove)(void *priv); |
359 | void (*link_down)(void *); | 416 | void (*link_down)(void *priv); |
360 | void (*link_up)(void *); | 417 | void (*link_up)(void *priv); |
361 | int (*connect_phy)(void *, struct phy_device *); | 418 | int (*connect_phy)(void *priv, struct phy_device *); |
362 | void (*disconnect_phy)(void *); | 419 | void (*disconnect_phy)(void *priv); |
363 | }; | 420 | }; |
364 | 421 | ||
365 | #if IS_ENABLED(CONFIG_SFP) | 422 | #if IS_ENABLED(CONFIG_SFP) |
@@ -375,7 +432,7 @@ int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee, | |||
375 | u8 *data); | 432 | u8 *data); |
376 | void sfp_upstream_start(struct sfp_bus *bus); | 433 | void sfp_upstream_start(struct sfp_bus *bus); |
377 | void sfp_upstream_stop(struct sfp_bus *bus); | 434 | void sfp_upstream_stop(struct sfp_bus *bus); |
378 | struct sfp_bus *sfp_register_upstream(struct device_node *np, | 435 | struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode, |
379 | struct net_device *ndev, void *upstream, | 436 | struct net_device *ndev, void *upstream, |
380 | const struct sfp_upstream_ops *ops); | 437 | const struct sfp_upstream_ops *ops); |
381 | void sfp_unregister_upstream(struct sfp_bus *bus); | 438 | void sfp_unregister_upstream(struct sfp_bus *bus); |
@@ -419,7 +476,8 @@ static inline void sfp_upstream_stop(struct sfp_bus *bus) | |||
419 | { | 476 | { |
420 | } | 477 | } |
421 | 478 | ||
422 | static inline struct sfp_bus *sfp_register_upstream(struct device_node *np, | 479 | static inline struct sfp_bus *sfp_register_upstream( |
480 | struct fwnode_handle *fwnode, | ||
423 | struct net_device *ndev, void *upstream, | 481 | struct net_device *ndev, void *upstream, |
424 | const struct sfp_upstream_ops *ops) | 482 | const struct sfp_upstream_ops *ops) |
425 | { | 483 | { |