summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-09-20 03:19:47 +0300
committerJakub Kicinski <kuba@kernel.org>2025-09-20 03:19:47 +0300
commit0c2a4d304cea450d9f99e2092a731150a67ecc6b (patch)
tree9a207a8332693122582ef1fe4fa9acf845f63ef1 /include
parent6a46e4faa8fd848acec81bd6149a44c3b9b17de6 (diff)
parent6b0ed6a3a89cd2d04980e15a44c645bebb077418 (diff)
downloadlinux-0c2a4d304cea450d9f99e2092a731150a67ecc6b.tar.xz
Merge branch 'net-stmmac-remove-mac_interface'
Russell King says: ==================== net: stmmac: remove mac_interface The dwmac core supports a range of interfaces, but when it comes to SerDes interfaces, the core itself does not include the SerDes block. Consequently, it has to provide an interface suitable to interface such a block to, and uses TBI for this. The driver also uses "PCS" for RGMII, even though the dwmac PCS block is not present for this interface type - it was a convenice for the code structure as RGMII includes inband signalling of the PHY state, much like Cisco SGMII does at a high level. As such, the code refers to RGMII and SGMII modes for the PCS, and there used to be STMMAC_PCS_TBI and STMMAC_PCS_RTBI constants as well but these were never set, although they were used in the code. The selection of the PCS mode was from mac_interface. Thus, it seems that the original intention was for mac_interface to describe the interface mode used within the dwmac core, and phy_interface to describe the external world-accessible interface (e.g. which would connect to a PHY or SFP cage.) It appears that many glue drivers misinterpret these. A good exmple is socfpga. This supports SGMII and 1000BASE-X, but does not include the dwmac PCS, relying on the Lynx PCS instead. However, it makes use of mac_interface to configure the dwmac core to its GMII/MII mode. So, when operating in either of these modes, the dwmac is configured for GMII mode to communicate with the Lynx PCS which then provides the SGMII or 1000BASE-X interface mode to the external world. Given that phy_interface is the external world interface, and mac_interface is the dwmac core interface, selecting the interface mode based on mac_interface being 1000BASEX makes no sense. Moreover, mac_interface is initialised by the stmmac core code. If the "mac-mode" property is set in DT, this will be used. Otherwise, it will reflect the "phy-mode" property - meaning that it defaults to phy_interface. As no in-kernel DT makes reference to a "mac-mode" property, we can assume that for all in-kernel platforms, these two interface variables are the same. The exception are those platform glues which I reviwed and suggested they use phy_interface, setting mac_interface to PHY_INTERFACE_MODE_NA. The conclusion to all of this is that mac_interface serves no useful purpose, and causes confusion as the platform glue code doesn't seem to know which one should be used. Thus, let's get rid of mac_interface, which makes all this code more understandable. It also helps to untangle some of the questions such as: - should this be using the interface passed from phylink - should we set the range of phylink supported interfaces to be more than one - when we get phylink PCS support for the dwmac PCS, should we be selecting it based on mac_interface or phy_interface, and how should we populate the PCS' supported_interface bitmap. Having converted socfpga to use phy_interface, this turns out to feel like "the right way" to do this - convert the external world "phy_interface" to whatever phy_intf_sel value that the dwmac core needs to achieve the connection to whatever hardware blocks are integrated inside the SoC to achieve the requested external world interface. As an illustration why - consider that in the case of socfpga, it _could_ have been implemented such that the dwmac PCS was used for SGMII, and the Lynx PCS for 1000BASE-X, or vice versa. Only the platform glue would know which it is. I will also note that several cores provide their currently configured interface mode via the ACTPHYIF field of Hardware Feature 0, and thus can be read back in the platform-independent parts of the driver to decide whether the internal PCS or the RGMII (or actually SMII) "PCS" should be used. This is hot-off-the-press, and has only been build tested. As I have none of these platforms, this series has not been run-tested, so please test on your hardware. ==================== Link: https://patch.msgid.link/aMrPpc8oRxqGtVPJ@shell.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/stmmac.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index e284f04964bf..fa1318bac06c 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -190,18 +190,27 @@ struct plat_stmmacenet_data {
int bus_id;
int phy_addr;
/* MAC ----- optional PCS ----- SerDes ----- optional PHY ----- Media
- * ^ ^
- * mac_interface phy_interface
+ * ^
+ * phy_interface
*
- * mac_interface is the MAC-side interface, which may be the same
- * as phy_interface if there is no intervening PCS. If there is a
- * PCS, then mac_interface describes the interface mode between the
- * MAC and PCS, and phy_interface describes the interface mode
- * between the PCS and PHY.
- */
- phy_interface_t mac_interface;
- /* phy_interface is the PHY-side interface - the interface used by
- * an attached PHY.
+ * The Synopsys dwmac core only covers the MAC and an optional
+ * integrated PCS. Where the integrated PCS is used with a SerDes,
+ * e.g. for 1000base-X or Cisco SGMII, the connection between the
+ * PCS and SerDes will be TBI.
+ *
+ * Where the Synopsys dwmac core has been instantiated with multiple
+ * interface modes, these are selected via core-external configuration
+ * which is sampled when the dwmac core is reset. How this is done is
+ * platform glue specific, but this defines the interface used from
+ * the Synopsys dwmac core to the rest of the SoC.
+ *
+ * Where PCS other than the optional integrated Synopsys dwmac PCS
+ * is used, this counts as "the rest of the SoC" in the above
+ * paragraph.
+ *
+ * phy_interface is the PHY-side interface - the interface used by
+ * an attached PHY or SFP etc. This is equivalent to the interface
+ * that phylink uses.
*/
phy_interface_t phy_interface;
struct stmmac_mdio_bus_data *mdio_bus_data;