Skip to content

Commit 37a8997

Browse files
vladimirolteandavem330
authored andcommitted
net: phylink: reimplement population of pl->supported for in-band
phylink_parse_mode() populates all possible supported link modes for a given phy_interface_t, for the case where a phylib phy may be absent and we can't retrieve the supported link modes from that. Russell points out that since the introduction of the generic validation helpers phylink_get_capabilities() and phylink_caps_to_linkmodes(), we can rewrite this procedure to populate the pl->supported mask, so that instead of spelling out the link modes, we derive an intermediary mac_capabilities bit field, and we convert that to the equivalent link modes. Suggested-by: Russell King (Oracle) <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 358105a commit 37a8997

File tree

1 file changed

+5
-66
lines changed

1 file changed

+5
-66
lines changed

drivers/net/phy/phylink.c

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ static int phylink_parse_mode(struct phylink *pl,
883883
{
884884
struct fwnode_handle *dn;
885885
const char *managed;
886+
unsigned long caps;
886887

887888
dn = fwnode_get_named_child_node(fwnode, "fixed-link");
888889
if (dn || fwnode_property_present(fwnode, "fixed-link"))
@@ -915,80 +916,18 @@ static int phylink_parse_mode(struct phylink *pl,
915916
case PHY_INTERFACE_MODE_RGMII_RXID:
916917
case PHY_INTERFACE_MODE_RGMII_TXID:
917918
case PHY_INTERFACE_MODE_RTBI:
918-
phylink_set(pl->supported, 10baseT_Half);
919-
phylink_set(pl->supported, 10baseT_Full);
920-
phylink_set(pl->supported, 100baseT_Half);
921-
phylink_set(pl->supported, 100baseT_Full);
922-
phylink_set(pl->supported, 1000baseT_Half);
923-
phylink_set(pl->supported, 1000baseT_Full);
924-
break;
925-
926919
case PHY_INTERFACE_MODE_1000BASEX:
927-
phylink_set(pl->supported, 1000baseX_Full);
928-
break;
929-
930920
case PHY_INTERFACE_MODE_2500BASEX:
931-
phylink_set(pl->supported, 2500baseX_Full);
932-
break;
933-
934921
case PHY_INTERFACE_MODE_5GBASER:
935-
phylink_set(pl->supported, 5000baseT_Full);
936-
break;
937-
938922
case PHY_INTERFACE_MODE_25GBASER:
939-
phylink_set(pl->supported, 25000baseCR_Full);
940-
phylink_set(pl->supported, 25000baseKR_Full);
941-
phylink_set(pl->supported, 25000baseSR_Full);
942-
fallthrough;
943923
case PHY_INTERFACE_MODE_USXGMII:
944924
case PHY_INTERFACE_MODE_10GKR:
945925
case PHY_INTERFACE_MODE_10GBASER:
946-
phylink_set(pl->supported, 10baseT_Half);
947-
phylink_set(pl->supported, 10baseT_Full);
948-
phylink_set(pl->supported, 100baseT_Half);
949-
phylink_set(pl->supported, 100baseT_Full);
950-
phylink_set(pl->supported, 1000baseT_Half);
951-
phylink_set(pl->supported, 1000baseT_Full);
952-
phylink_set(pl->supported, 1000baseX_Full);
953-
phylink_set(pl->supported, 1000baseKX_Full);
954-
phylink_set(pl->supported, 2500baseT_Full);
955-
phylink_set(pl->supported, 2500baseX_Full);
956-
phylink_set(pl->supported, 5000baseT_Full);
957-
phylink_set(pl->supported, 10000baseT_Full);
958-
phylink_set(pl->supported, 10000baseKR_Full);
959-
phylink_set(pl->supported, 10000baseKX4_Full);
960-
phylink_set(pl->supported, 10000baseCR_Full);
961-
phylink_set(pl->supported, 10000baseSR_Full);
962-
phylink_set(pl->supported, 10000baseLR_Full);
963-
phylink_set(pl->supported, 10000baseLRM_Full);
964-
phylink_set(pl->supported, 10000baseER_Full);
965-
break;
966-
967926
case PHY_INTERFACE_MODE_XLGMII:
968-
phylink_set(pl->supported, 25000baseCR_Full);
969-
phylink_set(pl->supported, 25000baseKR_Full);
970-
phylink_set(pl->supported, 25000baseSR_Full);
971-
phylink_set(pl->supported, 40000baseKR4_Full);
972-
phylink_set(pl->supported, 40000baseCR4_Full);
973-
phylink_set(pl->supported, 40000baseSR4_Full);
974-
phylink_set(pl->supported, 40000baseLR4_Full);
975-
phylink_set(pl->supported, 50000baseCR2_Full);
976-
phylink_set(pl->supported, 50000baseKR2_Full);
977-
phylink_set(pl->supported, 50000baseSR2_Full);
978-
phylink_set(pl->supported, 50000baseKR_Full);
979-
phylink_set(pl->supported, 50000baseSR_Full);
980-
phylink_set(pl->supported, 50000baseCR_Full);
981-
phylink_set(pl->supported, 50000baseLR_ER_FR_Full);
982-
phylink_set(pl->supported, 50000baseDR_Full);
983-
phylink_set(pl->supported, 100000baseKR4_Full);
984-
phylink_set(pl->supported, 100000baseSR4_Full);
985-
phylink_set(pl->supported, 100000baseCR4_Full);
986-
phylink_set(pl->supported, 100000baseLR4_ER4_Full);
987-
phylink_set(pl->supported, 100000baseKR2_Full);
988-
phylink_set(pl->supported, 100000baseSR2_Full);
989-
phylink_set(pl->supported, 100000baseCR2_Full);
990-
phylink_set(pl->supported, 100000baseLR2_ER2_FR2_Full);
991-
phylink_set(pl->supported, 100000baseDR2_Full);
927+
caps = ~(MAC_SYM_PAUSE | MAC_ASYM_PAUSE);
928+
caps = phylink_get_capabilities(pl->link_config.interface, caps,
929+
RATE_MATCH_NONE);
930+
phylink_caps_to_linkmodes(pl->supported, caps);
992931
break;
993932

994933
default:

0 commit comments

Comments
 (0)