Skip to content

Commit 734f06d

Browse files
vladimirolteandavem330
authored andcommitted
net: dpaa: fman_memac: accept phy-interface-type = "10gbase-r" in the device tree
Since commit 5d93cfc ("net: dpaa: Convert to phylink"), we support the "10gbase-r" phy-mode through a driver-based conversion of "xgmii", but we still don't actually support it when the device tree specifies "10gbase-r" proper. This is because boards such as LS1046A-RDB do not define pcs-handle-names (for whatever reason) in the ethernet@f0000 device tree node, and the code enters through this code path: err = of_property_match_string(mac_node, "pcs-handle-names", "xfi"); // code takes neither branch and falls through if (err >= 0) { (...) } else if (err != -EINVAL && err != -ENODATA) { goto _return_fm_mac_free; } (...) /* For compatibility, if pcs-handle-names is missing, we assume this * phy is the first one in pcsphy-handle */ err = of_property_match_string(mac_node, "pcs-handle-names", "sgmii"); if (err == -EINVAL || err == -ENODATA) pcs = memac_pcs_create(mac_node, 0); // code takes this branch else if (err < 0) goto _return_fm_mac_free; else pcs = memac_pcs_create(mac_node, err); // A default PCS is created and saved in "pcs" // This determination fails and mistakenly saves the default PCS // memac->sgmii_pcs instead of memac->xfi_pcs, because at this // stage, mac_dev->phy_if == PHY_INTERFACE_MODE_10GBASER. if (err && mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII) memac->xfi_pcs = pcs; else memac->sgmii_pcs = pcs; In other words, in the absence of pcs-handle-names, the default xfi_pcs assignment logic only works when in the device tree we have PHY_INTERFACE_MODE_XGMII. By reversing the order between the fallback xfi_pcs assignment and the "xgmii" overwrite with "10gbase-r", we are able to support both values in the device tree, with identical behavior. Currently, it is impossible to make the s/xgmii/10gbase-r/ device tree conversion, because it would break forward compatibility (new device tree with old kernel). The only way to modify existing device trees to phy-interface-mode = "10gbase-r" is to fix stable kernels to accept this value and handle it properly. One reason why the conversion is desirable is because with pre-phylink kernels, the Aquantia PHY driver used to warn about the improper use of PHY_INTERFACE_MODE_XGMII [1]. It is best to have a single (latest) device tree that works with all supported stable kernel versions. Note that the blamed commit does not constitute a regression per se. Older stable kernels like 6.1 still do not work with "10gbase-r", but for a different reason. That is a battle for another time. [1] https://lore.kernel.org/netdev/20240214-ls1046-dts-use-10gbase-r-v1-1-8c2d68547393@concurrent-rt.com/ Fixes: 5d93cfc ("net: dpaa: Convert to phylink") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Sean Anderson <[email protected]> Acked-by: Madalin Bucur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3773d65 commit 734f06d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/net/ethernet/freescale/fman/fman_memac.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,14 @@ int memac_initialization(struct mac_device *mac_dev,
10731073
unsigned long capabilities;
10741074
unsigned long *supported;
10751075

1076+
/* The internal connection to the serdes is XGMII, but this isn't
1077+
* really correct for the phy mode (which is the external connection).
1078+
* However, this is how all older device trees say that they want
1079+
* 10GBASE-R (aka XFI), so just convert it for them.
1080+
*/
1081+
if (mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII)
1082+
mac_dev->phy_if = PHY_INTERFACE_MODE_10GBASER;
1083+
10761084
mac_dev->phylink_ops = &memac_mac_ops;
10771085
mac_dev->set_promisc = memac_set_promiscuous;
10781086
mac_dev->change_addr = memac_modify_mac_address;
@@ -1139,7 +1147,7 @@ int memac_initialization(struct mac_device *mac_dev,
11391147
* (and therefore that xfi_pcs cannot be set). If we are defaulting to
11401148
* XGMII, assume this is for XFI. Otherwise, assume it is for SGMII.
11411149
*/
1142-
if (err && mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII)
1150+
if (err && mac_dev->phy_if == PHY_INTERFACE_MODE_10GBASER)
11431151
memac->xfi_pcs = pcs;
11441152
else
11451153
memac->sgmii_pcs = pcs;
@@ -1153,14 +1161,6 @@ int memac_initialization(struct mac_device *mac_dev,
11531161
goto _return_fm_mac_free;
11541162
}
11551163

1156-
/* The internal connection to the serdes is XGMII, but this isn't
1157-
* really correct for the phy mode (which is the external connection).
1158-
* However, this is how all older device trees say that they want
1159-
* 10GBASE-R (aka XFI), so just convert it for them.
1160-
*/
1161-
if (mac_dev->phy_if == PHY_INTERFACE_MODE_XGMII)
1162-
mac_dev->phy_if = PHY_INTERFACE_MODE_10GBASER;
1163-
11641164
/* TODO: The following interface modes are supported by (some) hardware
11651165
* but not by this driver:
11661166
* - 1000BASE-KX

0 commit comments

Comments
 (0)