net: pcs: add supported_interfaces bitmap for PCS
Subsystems (10)
Russell King (Oracle)
maintainercover net: pcs: add supported_interfaces bitmap for PCS
Hi,
This series adds supported_interfaces for PCS, which gives MAC code a way to determine the interface modes that the PCS supports without having to implement functions such as xpcs_get_interfaces(), or workarounds such as in
https://lore.kernel.org/r/[email protected]
Patch 1 adds the new bitmask to struct phylink_pcs, and code within phylink to validate that the PCS returned by the MAC driver supports the interface mode - but only if this bitmask is non-empty.
Patch 2 through 4 fills in the interface modes for XPCS, Mediatek LynxI and Lynx PCS.
Patch 5 adds support to stmmac to make use of this bitmask when filling in phylink_config.supported_interfaces, eliminating the call to xpcs_get_interfaces.
As xpcs_get_interfaces() is now unused outside of pcs-xpcs.c, patch 6 makes this function static and removes it from the header file.
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++-- drivers/net/pcs/pcs-lynx.c | 13 +++++++++++++ drivers/net/pcs/pcs-mtk-lynxi.c | 4 ++++ drivers/net/pcs/pcs-xpcs.c | 5 +++-- drivers/net/phy/phylink.c | 11 +++++++++++ include/linux/pcs/pcs-xpcs.h | 1 - include/linux/phylink.h | 3 +++ 7 files changed, 43 insertions(+), 5 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/6 net: phylink: add support for PCS supported_interfaces bitmap
Add support for the PCS to specify which interfaces it supports, which can be used by MAC drivers to build the main supported_interfaces bitmap. Phylink also validates that the PCS returned by the MAC driver supports the interface that the MAC was asked for.
An empty supported_interfaces bitmap from the PCS indicates that it does not provide this information, and we handle that appropriately.
--- drivers/net/phy/phylink.c | 11 +++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 14 insertions(+)
drivers/net/phy/phylink.c +11 -0
@@ -691,6 +691,17 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,return -EINVAL ; } +/* Ensure that this PCS supports the interface which the MAC +* returned it for. It is an error for the MAC to return a PCS +* that does not support the interface mode. +*/ +if (!phy_interface_empty (pcs->supported_interfaces) && + !test_bit (state->interface, pcs->supported_interfaces)) { +phylink_err (pl,"MAC returned PCS which does not support %s\n" , +phy_modes (state->interface)); +return -EINVAL ; + } +/* Validate the link parameters with the PCS */ if (pcs->ops->pcs_validate) { ret = pcs->ops->pcs_validate (pcs, supported, state);
include/linux/phylink.h +3 -0
@@ -393,6 +393,8 @@ struct phylink_pcs_ops;/** * struct phylink_pcs - PHYLINK PCS instance +* @supported_interfaces: describing which PHY_INTERFACE_MODE_xxx +* are supported by this PCS. * @ops: a pointer to the &struct phylink_pcs_ops structure * @phylink: pointer to &struct phylink_config * @neg_mode: provide PCS neg mode via "mode" argument
@@ -409,6 +411,7 @@ struct phylink_pcs_ops;* the PCS driver. */ struct phylink_pcs { +DECLARE_PHY_INTERFACE_MASK (supported_interfaces);const struct phylink_pcs_ops *ops;struct phylink *phylink;bool neg_mode;
Signature · 1 line
2.30.2
PATCH 2/6 net: pcs: xpcs: fill in PCS supported_interfaces
In reply to Russell King (Oracle)Fill in the new PCS supported_interfaces member with the interfaces that XPCS supports.
--- drivers/net/pcs/pcs-xpcs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/pcs/pcs-xpcs.c +2 -0
@@ -1446,6 +1446,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev)if (ret) goto out_clear_clks; +xpcs_get_interfaces (xpcs, xpcs->pcs.supported_interfaces); +if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) xpcs->pcs.poll = false;else
Signature · 1 line
2.30.2
PATCH 3/6 net: pcs: mtk-lynxi: fill in PCS supported_interfaces
In reply to Russell King (Oracle)Fill in the new PCS supported_interfaces member with the interfaces that the Mediatek LynxI supports.
--- drivers/net/pcs/pcs-mtk-lynxi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/pcs/pcs-mtk-lynxi.c +4 -0
@@ -306,6 +306,10 @@ struct phylink_pcs *mtk_pcs_lynxi_create(struct device *dev, mpcs->pcs.poll = true; mpcs->interface =PHY_INTERFACE_MODE_NA ; +__set_bit (PHY_INTERFACE_MODE_SGMII , mpcs->pcs.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , mpcs->pcs.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_2500BASEX , mpcs->pcs.supported_interfaces); +return &mpcs->pcs; }EXPORT_SYMBOL (mtk_pcs_lynxi_create);
Signature · 1 line
2.30.2
PATCH 4/6 net: pcs: lynx: fill in PCS supported_interfaces
In reply to Russell King (Oracle)Fill in the new PCS supported_interfaces member with the interfaces that Lynx supports.
--- drivers/net/pcs/pcs-lynx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/net/pcs/pcs-lynx.c +13 -0
@@ -334,9 +334,19 @@ static const struct phylink_pcs_ops lynx_pcs_phylink_ops = { .pcs_link_up = lynx_pcs_link_up, }; +static const phy_interface_t lynx_interfaces[] = { +PHY_INTERFACE_MODE_SGMII , +PHY_INTERFACE_MODE_QSGMII , +PHY_INTERFACE_MODE_1000BASEX , +PHY_INTERFACE_MODE_2500BASEX , +PHY_INTERFACE_MODE_10GBASER , +PHY_INTERFACE_MODE_USXGMII , +}; +static struct phylink_pcs *lynx_pcs_create (struct mdio_device *mdio) {struct lynx_pcs *lynx; +int i; lynx =kzalloc (sizeof (*lynx),GFP_KERNEL );if (!lynx)
@@ -348,6 +358,9 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) lynx->pcs.neg_mode = true; lynx->pcs.poll = true; +for (i =0 ; i <ARRAY_SIZE (lynx_interfaces); i++) +__set_bit (lynx_interfaces[i], lynx->pcs.supported_interfaces); +return lynx_to_phylink_pcs (lynx); }
Signature · 1 line
2.30.2
PATCH 5/6 net: stmmac: use PCS supported_interfaces
In reply to Russell King (Oracle)Use the PCS' supported_interfaces member to build the MAC level supported_interfaces bitmap.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -2
@@ -1203,6 +1203,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)struct stmmac_mdio_bus_data *mdio_bus_data;int mode = priv->plat->phy_interface;struct fwnode_handle *fwnode; +struct phylink_pcs *pcs;struct phylink *phylink; priv->phylink_config.dev = &priv->dev->dev;
@@ -1224,8 +1225,14 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)/* If we have an xpcs, it defines which PHY interfaces are supported. */ if (priv->hw->xpcs) -xpcs_get_interfaces (priv->hw->xpcs, - priv->phylink_config.supported_interfaces); + pcs =xpcs_to_phylink_pcs (priv->hw->xpcs); +else + pcs = priv->hw->phylink_pcs; + +if (pcs) +phy_interface_or (priv->phylink_config.supported_interfaces, + priv->phylink_config.supported_interfaces, + pcs->supported_interfaces); fwnode = priv->plat->port_node;if (!fwnode)
Signature · 1 line
2.30.2
PATCH 6/6 net: pcs: xpcs: make xpcs_get_interfaces() static
In reply to Russell King (Oracle)xpcs_get_interfaces() should no longer be used outside of the XPCS code, so make it static.
--- drivers/net/pcs/pcs-xpcs.c | 3 +-- include/linux/pcs/pcs-xpcs.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/net/pcs/pcs-xpcs.c +1 -2
@@ -594,14 +594,13 @@ static unsigned int xpcs_inband_caps(struct phylink_pcs *pcs, } } -void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces) +static void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces) {const struct dw_xpcs_compat *compat;for (compat = xpcs->desc->compat; compat->supported; compat++)__set_bit (compat->interface, interfaces); } -EXPORT_SYMBOL_GPL (xpcs_get_interfaces);int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable) {
include/linux/pcs/pcs-xpcs.h +0 -1
@@ -50,7 +50,6 @@ struct dw_xpcs;struct phylink_pcs *xpcs_to_phylink_pcs (struct dw_xpcs *xpcs);int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface); -void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces);int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable);struct dw_xpcs *xpcs_create_mdiodev (struct mii_bus *bus,int addr);
Signature · 1 line
2.30.2
Re: [PATCH net-next 3/6] net: pcs: mtk-lynxi: fill in PCS supported_interfaces
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Fill in the new PCS
supported_interfacesmember with the interfaces that the Mediatek LynxI supports.Signed-off-by Russell King (Oracle) <[email protected]>
Quoted 19 lines
---
drivers/net/pcs/pcs-mtk-lynxi.c| 4 ++++1 file changed, 4 insertions(+)drivers/net/pcs/pcs-mtk-lynxi.c +4
-0@@ -306,6 +306,10 @@ struct phylink_pcs *mtk_pcs_lynxi_create(struct device *dev, mpcs->pcs.poll = true; mpcs->interface =PHY_INTERFACE_MODE_NA ; +__set_bit (PHY_INTERFACE_MODE_SGMII , mpcs->pcs.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_1000BASEX , mpcs->pcs.supported_interfaces); +__set_bit (PHY_INTERFACE_MODE_2500BASEX , mpcs->pcs.supported_interfaces); +return &mpcs->pcs; }EXPORT_SYMBOL (mtk_pcs_lynxi_create);
Re: [PATCH net-next 3/6] net: pcs: mtk-lynxi: fill in PCS supported_interfaces
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Fill in the new PCS
supported_interfacesmember with the interfaces that the Mediatek LynxI supports.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 6/6] net: pcs: xpcs: make xpcs_get_interfaces() static
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
xpcs_get_interfaces()should no longer be used outside of the XPCS code, so make it static.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 3 Jan 2025 11:16:06 +0000 you wrote:
Hi,
This series adds
supported_interfacesfor PCS, which gives MAC code a way to determine the interface modes that the PCS supports without having to implement functions such asxpcs_get_interfaces(), or workarounds such as in[...]
Here is the summary with links:
- [net-next,1/6] net: phylink: add support for PCS supported_interfaces bitmap
https://git.kernel.org/netdev/net-next/c/fbb9a9d263a6 - [net-next,2/6] net: pcs: xpcs: fill in PCS supported_interfaces https://git.kernel.org/netdev/net-next/c/906909fabb81 - [net-next,3/6] net: pcs: mtk-lynxi: fill in PCS supported_interfaces https://git.kernel.org/netdev/net-next/c/b87d4ee16bb4 - [net-next,4/6] net: pcs: lynx: fill in PCS supported_interfaces https://git.kernel.org/netdev/net-next/c/b0f88c1b9a53 - [net-next,5/6] net: stmmac: use PCS supported_interfaces https://git.kernel.org/netdev/net-next/c/d13cefbb108e - [net-next,6/6] net: pcs: xpcs: make xpcs_get_interfaces() static https://git.kernel.org/netdev/net-next/c/2410719cdd49
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html