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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-phy_port-sfp-modules-representation-and-phy_port-listing'

Maxime Chevallier says:

====================
net: phy_port: SFP modules representation and phy_port listing (part)
====================

Applying just the initial cleanup + fixes from the series.

Link: https://patch.msgid.link/20260205092317.755906-1-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+22 -14
+3
drivers/net/phy/phy_device.c
··· 3499 3499 3500 3500 port->parent_type = PHY_PORT_PHY; 3501 3501 port->phy = phydev; 3502 + 3503 + linkmode_copy(port->supported, phydev->supported); 3504 + 3502 3505 err = phy_add_port(phydev, port); 3503 3506 if (err) { 3504 3507 phy_port_destroy(port);
+19 -14
drivers/net/phy/phy_port.c
··· 53 53 enum ethtool_link_medium medium; 54 54 struct phy_port *port; 55 55 const char *med_str; 56 - u32 pairs = 0, mediums = 0; 56 + u32 pairs = 0; 57 57 int ret; 58 58 59 59 ret = fwnode_property_read_string(fwnode, "media", &med_str); ··· 85 85 return ERR_PTR(-EINVAL); 86 86 } 87 87 88 - mediums |= BIT(medium); 89 - 90 - if (!mediums) 91 - return ERR_PTR(-EINVAL); 92 - 93 88 port = phy_port_alloc(); 94 89 if (!port) 95 90 return ERR_PTR(-ENOMEM); 96 91 97 92 port->pairs = pairs; 98 - port->mediums = mediums; 93 + port->mediums = BIT(medium); 99 94 100 95 return port; 101 96 } ··· 108 113 */ 109 114 void phy_port_update_supported(struct phy_port *port) 110 115 { 111 - __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0 }; 116 + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = {0}; 112 117 unsigned long mode; 113 118 int i; 114 - 115 - for_each_set_bit(i, &port->mediums, __ETHTOOL_LINK_MEDIUM_LAST) { 116 - linkmode_zero(supported); 117 - phy_caps_medium_get_supported(supported, i, port->pairs); 118 - linkmode_or(port->supported, port->supported, supported); 119 - } 120 119 121 120 /* If there's no pairs specified, we grab the default number of 122 121 * pairs as the max of the default pairs for each linkmode ··· 120 131 __ETHTOOL_LINK_MODE_MASK_NBITS) 121 132 port->pairs = max_t(int, port->pairs, 122 133 ethtool_linkmode_n_pairs(mode)); 134 + 135 + for_each_set_bit(i, &port->mediums, __ETHTOOL_LINK_MEDIUM_LAST) { 136 + __ETHTOOL_DECLARE_LINK_MODE_MASK(med_supported) = {0}; 137 + 138 + phy_caps_medium_get_supported(med_supported, i, port->pairs); 139 + linkmode_or(supported, supported, med_supported); 140 + } 141 + 142 + /* If port->supported is already populated, filter it out with the 143 + * medium/pair support. Otherwise, let's just use this medium-based 144 + * support as the port's supported list. 145 + */ 146 + if (linkmode_empty(port->supported)) 147 + linkmode_copy(port->supported, supported); 148 + else 149 + linkmode_and(port->supported, supported, port->supported); 123 150 124 151 /* Serdes ports supported through SFP may not have any medium set, 125 152 * as they will output PHY_INTERFACE_MODE_XXX modes. In that case, derive