Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sfp: convert sfp quirks to modify struct sfp_module_support

In order to provide extensible module support properties, arrange for
the SFP quirks to modify any member of the sfp_module_support struct,
rather than just the ethtool link modes and interfaces.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1uydVe-000000061WK-3KwI@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
a7dc35a9 ddae6127

+28 -30
+2 -3
drivers/net/phy/sfp-bus.c
··· 373 373 sfp_module_parse_port(bus, id); 374 374 sfp_module_parse_may_have_phy(bus, id); 375 375 376 - if (quirk && quirk->modes) 377 - quirk->modes(id, bus->caps.link_modes, 378 - bus->caps.interfaces); 376 + if (quirk && quirk->support) 377 + quirk->support(id, &bus->caps); 379 378 } 380 379 381 380 /**
+24 -25
drivers/net/phy/sfp.c
··· 440 440 } 441 441 442 442 static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, 443 - unsigned long *modes, 444 - unsigned long *interfaces) 443 + struct sfp_module_caps *caps) 445 444 { 446 - linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, modes); 447 - __set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces); 445 + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, 446 + caps->link_modes); 447 + __set_bit(PHY_INTERFACE_MODE_2500BASEX, caps->interfaces); 448 448 } 449 449 450 450 static void sfp_quirk_disable_autoneg(const struct sfp_eeprom_id *id, 451 - unsigned long *modes, 452 - unsigned long *interfaces) 451 + struct sfp_module_caps *caps) 453 452 { 454 - linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, modes); 453 + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, caps->link_modes); 455 454 } 456 455 457 456 static void sfp_quirk_oem_2_5g(const struct sfp_eeprom_id *id, 458 - unsigned long *modes, 459 - unsigned long *interfaces) 457 + struct sfp_module_caps *caps) 460 458 { 461 459 /* Copper 2.5G SFP */ 462 - linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, modes); 463 - __set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces); 464 - sfp_quirk_disable_autoneg(id, modes, interfaces); 460 + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, 461 + caps->link_modes); 462 + __set_bit(PHY_INTERFACE_MODE_2500BASEX, caps->interfaces); 463 + sfp_quirk_disable_autoneg(id, caps); 465 464 } 466 465 467 466 static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id, 468 - unsigned long *modes, 469 - unsigned long *interfaces) 467 + struct sfp_module_caps *caps) 470 468 { 471 469 /* Ubiquiti U-Fiber Instant module claims that support all transceiver 472 470 * types including 10G Ethernet which is not truth. So clear all claimed 473 471 * modes and set only one mode which module supports: 1000baseX_Full. 474 472 */ 475 - linkmode_zero(modes); 476 - linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes); 473 + linkmode_zero(caps->link_modes); 474 + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, 475 + caps->link_modes); 477 476 } 478 477 479 - #define SFP_QUIRK(_v, _p, _m, _f) \ 480 - { .vendor = _v, .part = _p, .modes = _m, .fixup = _f, } 481 - #define SFP_QUIRK_M(_v, _p, _m) SFP_QUIRK(_v, _p, _m, NULL) 478 + #define SFP_QUIRK(_v, _p, _s, _f) \ 479 + { .vendor = _v, .part = _p, .support = _s, .fixup = _f, } 480 + #define SFP_QUIRK_S(_v, _p, _s) SFP_QUIRK(_v, _p, _s, NULL) 482 481 #define SFP_QUIRK_F(_v, _p, _f) SFP_QUIRK(_v, _p, NULL, _f) 483 482 484 483 static const struct sfp_quirk sfp_quirks[] = { ··· 513 514 514 515 // HG MXPD-483II-F 2.5G supports 2500Base-X, but incorrectly reports 515 516 // 2600MBd in their EERPOM 516 - SFP_QUIRK_M("HG GENUINE", "MXPD-483II", sfp_quirk_2500basex), 517 + SFP_QUIRK_S("HG GENUINE", "MXPD-483II", sfp_quirk_2500basex), 517 518 518 519 // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in 519 520 // their EEPROM ··· 522 523 523 524 // Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report 524 525 // 2500MBd NRZ in their EEPROM 525 - SFP_QUIRK_M("Lantech", "8330-262D-E", sfp_quirk_2500basex), 526 + SFP_QUIRK_S("Lantech", "8330-262D-E", sfp_quirk_2500basex), 526 527 527 - SFP_QUIRK_M("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant), 528 + SFP_QUIRK_S("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant), 528 529 529 530 // Walsun HXSX-ATR[CI]-1 don't identify as copper, and use the 530 531 // Rollball protocol to talk to the PHY. ··· 537 538 SFP_QUIRK_F("OEM", "SFP-GE-T", sfp_fixup_ignore_tx_fault), 538 539 539 540 SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc), 540 - SFP_QUIRK_M("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g), 541 - SFP_QUIRK_M("OEM", "SFP-2.5G-BX10-D", sfp_quirk_2500basex), 542 - SFP_QUIRK_M("OEM", "SFP-2.5G-BX10-U", sfp_quirk_2500basex), 541 + SFP_QUIRK_S("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g), 542 + SFP_QUIRK_S("OEM", "SFP-2.5G-BX10-D", sfp_quirk_2500basex), 543 + SFP_QUIRK_S("OEM", "SFP-2.5G-BX10-U", sfp_quirk_2500basex), 543 544 SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc), 544 545 SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc), 545 546 SFP_QUIRK_F("Turris", "RTSFP-2.5G", sfp_fixup_rollball),
+2 -2
drivers/net/phy/sfp.h
··· 9 9 struct sfp_quirk { 10 10 const char *vendor; 11 11 const char *part; 12 - void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes, 13 - unsigned long *interfaces); 12 + void (*support)(const struct sfp_eeprom_id *id, 13 + struct sfp_module_caps *caps); 14 14 void (*fixup)(struct sfp *sfp); 15 15 }; 16 16