* [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch
@ 2022-06-15 8:39 Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Ong Boon Leong
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
Thanks for v4 review feedback in [1] and [2]. I have changed the v5
implementation as follow.
v5 changes:
1/5 - No change from v4.
2/5 - No change from v4.
3/5 - [Fix] make xpcs_modify_changed() static and use
mdiodev_modify_changed() for cleaner code as suggested by
Russell King.
4/5 - [Fix] Use fwnode_get_phy_mode() as recommended by Andrew Lunn.
5/5 - [Fix] Make fwnode = of_fwnode_handle(priv->plat->phylink_node)
order after priv = netdev_priv(dev).
v4 changes:
1/5 - Squash v3:1/7 & 2/7 patches into v4:1/6 so that it passes build.
2/5 - [No change] same as v3:3/7
3/5 - [Fix] Fix issues identified by Russell in [1]
4/5 - [Fix] Drop v3:5/7 patch per input by Russell in [2] and make
dwmac-intel clear the ovr_an_inband flag if fixed-link
is used in ACPI _DSD.
5/5 - [No change] same as v3:7/7
For the steps to setup ACPI _DSD and checking, they are the same
as in [3]
Reference:
[1] https://patchwork.kernel.org/comment/24894239/
[2] https://patchwork.kernel.org/comment/24895330/
[3] https://patchwork.kernel.org/project/netdevbpf/cover/20220610033610.114084-1-boon.leong.ong@intel.com/
Thanks
Boon Leong
Ong Boon Leong (5):
net: make xpcs_do_config to accept advertising for pcs-xpcs and
sja1105
stmmac: intel: prepare to support 1000BASE-X phy interface setting
net: pcs: xpcs: add CL37 1000BASE-X AN support
stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support
net: stmmac: make mdio register skips PHY scanning for fixed-link
drivers/net/dsa/sja1105/sja1105_main.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 34 +++-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +-
.../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 ++
drivers/net/pcs/pcs-xpcs.c | 176 +++++++++++++++++-
drivers/net/pcs/pcs-xpcs.h | 1 -
include/linux/pcs/pcs-xpcs.h | 3 +-
7 files changed, 229 insertions(+), 13 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v5 1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
@ 2022-06-15 8:39 ` Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 2/5] stmmac: intel: prepare to support 1000BASE-X phy interface setting Ong Boon Leong
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
xpcs_config() has 'advertising' input that is required for C37 1000BASE-X
AN in later patch series. So, we prepare xpcs_do_config() for it.
For sja1105, xpcs_do_config() is used for xpcs configuration without
depending on advertising input, so set to NULL.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/dsa/sja1105/sja1105_main.c | 2 +-
drivers/net/pcs/pcs-xpcs.c | 6 +++---
include/linux/pcs/pcs-xpcs.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 72b6fc1932b..b253e27bcfb 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -2330,7 +2330,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
else
mode = MLO_AN_PHY;
- rc = xpcs_do_config(xpcs, priv->phy_mode[i], mode);
+ rc = xpcs_do_config(xpcs, priv->phy_mode[i], mode, NULL);
if (rc < 0)
goto out;
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 4cfd05c15ae..48d81c40aab 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -795,7 +795,7 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs)
}
int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
- unsigned int mode)
+ unsigned int mode, const unsigned long *advertising)
{
const struct xpcs_compat *compat;
int ret;
@@ -843,7 +843,7 @@ static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode,
{
struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);
- return xpcs_do_config(xpcs, interface, mode);
+ return xpcs_do_config(xpcs, interface, mode, advertising);
}
static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
@@ -864,7 +864,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
state->link = 0;
- return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND);
+ return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND, NULL);
}
if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state, compat)) {
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index 266eb26fb02..37eb97cc228 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -30,7 +30,7 @@ int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface);
void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed, int duplex);
int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
- unsigned int mode);
+ unsigned int mode, const unsigned long *advertising);
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);
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v5 2/5] stmmac: intel: prepare to support 1000BASE-X phy interface setting
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Ong Boon Leong
@ 2022-06-15 8:39 ` Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support Ong Boon Leong
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
Currently, intel_speed_mode_2500() redundantly fix-up phy_interface to
PHY_INTERFACE_MODE_SGMII if the underlying controller is in 1000Mbps
SGMII mode. The value of phy_interface has been initialized earlier.
This patch removes such redundancy to prepare for setting 1000BASE-X
mode for certain hardware platform configuration.
Also update the intel_mgbe_common_data() to include 1000BASE-X setup.
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 38fe77d1035..675dfb89b76 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -251,7 +251,6 @@ static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data)
priv->plat->mdio_bus_data->xpcs_an_inband = false;
} else {
priv->plat->max_speed = 1000;
- priv->plat->phy_interface = PHY_INTERFACE_MODE_SGMII;
priv->plat->mdio_bus_data->xpcs_an_inband = true;
}
}
@@ -562,7 +561,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
plat->vlan_fail_q = plat->rx_queues_to_use - 1;
/* Intel mgbe SGMII interface uses pcs-xcps */
- if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
+ plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
plat->mdio_bus_data->has_xpcs = true;
plat->mdio_bus_data->xpcs_an_inband = true;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 2/5] stmmac: intel: prepare to support 1000BASE-X phy interface setting Ong Boon Leong
@ 2022-06-15 8:39 ` Ong Boon Leong
2022-06-15 11:23 ` Russell King (Oracle)
2022-06-15 8:39 ` [PATCH net-next v5 4/5] stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support Ong Boon Leong
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
For CL37 1000BASE-X AN, DW xPCS does not support C22 method but offers
C45 vendor-specific MII MMD for programming.
We also add the ability to disable Autoneg (through ethtool for certain
network switch that supports 1000BASE-X (1000Mbps and Full-Duplex) but
not Autoneg capability.
v4: Fixes to comment from Russell King. Thanks!
https://patchwork.kernel.org/comment/24894239/
Make xpcs_modify_changed() as private, change to use
mdiodev_modify_changed() for cleaner code.
v3: Fixes to issues spotted by Russell King. Thanks!
https://patchwork.kernel.org/comment/24890210/
Use phylink_mii_c22_pcs_decode_state(), remove unnecessary
interrupt clearing and skip speed & duplex setting if AN
is enabled.
v2: Fixes to issues spotted by Russell King in v1. Thanks!
https://patchwork.kernel.org/comment/24826650/
Use phylink_mii_c22_pcs_encode_advertisement() and implement
C45 MII ADV handling since IP only support C45 access.
Tested-by: Emilio Riva <emilio.riva@ericsson.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/pcs/pcs-xpcs.c | 170 +++++++++++++++++++++++++++++++++++
drivers/net/pcs/pcs-xpcs.h | 1 -
include/linux/pcs/pcs-xpcs.h | 1 +
3 files changed, 171 insertions(+), 1 deletion(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 48d81c40aab..a5d520e34ea 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -77,6 +77,14 @@ static const int xpcs_sgmii_features[] = {
__ETHTOOL_LINK_MODE_MASK_NBITS,
};
+static const int xpcs_1000basex_features[] = {
+ ETHTOOL_LINK_MODE_Pause_BIT,
+ ETHTOOL_LINK_MODE_Asym_Pause_BIT,
+ ETHTOOL_LINK_MODE_Autoneg_BIT,
+ ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+};
+
static const int xpcs_2500basex_features[] = {
ETHTOOL_LINK_MODE_Pause_BIT,
ETHTOOL_LINK_MODE_Asym_Pause_BIT,
@@ -102,6 +110,10 @@ static const phy_interface_t xpcs_sgmii_interfaces[] = {
PHY_INTERFACE_MODE_SGMII,
};
+static const phy_interface_t xpcs_1000basex_interfaces[] = {
+ PHY_INTERFACE_MODE_1000BASEX,
+};
+
static const phy_interface_t xpcs_2500basex_interfaces[] = {
PHY_INTERFACE_MODE_2500BASEX,
PHY_INTERFACE_MODE_MAX,
@@ -112,6 +124,7 @@ enum {
DW_XPCS_10GKR,
DW_XPCS_XLGMII,
DW_XPCS_SGMII,
+ DW_XPCS_1000BASEX,
DW_XPCS_2500BASEX,
DW_XPCS_INTERFACE_MAX,
};
@@ -189,6 +202,14 @@ int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val)
return mdiobus_c45_write(bus, addr, dev, reg, val);
}
+static int xpcs_modify_changed(struct dw_xpcs *xpcs, int dev, u32 reg,
+ u16 mask, u16 set)
+{
+ u32 reg_addr = mdiobus_c45_addr(dev, reg);
+
+ return mdiodev_modify_changed(xpcs->mdiodev, reg_addr, mask, set);
+}
+
static int xpcs_read_vendor(struct dw_xpcs *xpcs, int dev, u32 reg)
{
return xpcs_read(xpcs, dev, DW_VENDOR | reg);
@@ -237,6 +258,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs,
break;
case DW_AN_C37_SGMII:
case DW_2500BASEX:
+ case DW_AN_C37_1000BASEX:
dev = MDIO_MMD_VEND2;
break;
default:
@@ -772,6 +794,68 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode)
return ret;
}
+static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs, unsigned int mode,
+ const unsigned long *advertising)
+{
+ phy_interface_t interface = PHY_INTERFACE_MODE_1000BASEX;
+ int ret, mdio_ctrl, adv;
+ bool changed = 0;
+
+ /* According to Chap 7.12, to set 1000BASE-X C37 AN, AN must
+ * be disabled first:-
+ * 1) VR_MII_MMD_CTRL Bit(12)[AN_ENABLE] = 0b
+ * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 00b (1000BASE-X C37)
+ */
+ mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL);
+ if (mdio_ctrl < 0)
+ return mdio_ctrl;
+
+ if (mdio_ctrl & AN_CL37_EN) {
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL,
+ mdio_ctrl & ~AN_CL37_EN);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL);
+ if (ret < 0)
+ return ret;
+
+ ret &= ~DW_VR_MII_PCS_MODE_MASK;
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, ret);
+ if (ret < 0)
+ return ret;
+
+ /* Check for advertising changes and update the C45 MII ADV
+ * register accordingly.
+ */
+ adv = phylink_mii_c22_pcs_encode_advertisement(interface,
+ advertising);
+ if (adv >= 0) {
+ ret = xpcs_modify_changed(xpcs, MDIO_MMD_VEND2,
+ MII_ADVERTISE, 0xffff, adv);
+ if (ret < 0)
+ return ret;
+
+ changed = ret;
+ }
+
+ /* Clear CL37 AN complete status */
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0);
+ if (ret < 0)
+ return ret;
+
+ if (phylink_autoneg_inband(mode) &&
+ linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)) {
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL,
+ mdio_ctrl | AN_CL37_EN);
+ if (ret < 0)
+ return ret;
+ }
+
+ return changed;
+}
+
static int xpcs_config_2500basex(struct dw_xpcs *xpcs)
{
int ret;
@@ -817,6 +901,12 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
if (ret)
return ret;
break;
+ case DW_AN_C37_1000BASEX:
+ ret = xpcs_config_aneg_c37_1000basex(xpcs, mode,
+ advertising);
+ if (ret)
+ return ret;
+ break;
case DW_2500BASEX:
ret = xpcs_config_2500basex(xpcs);
if (ret)
@@ -921,6 +1011,29 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
return 0;
}
+static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
+ struct phylink_link_state *state)
+{
+ int lpa, bmsr;
+
+ if (state->an_enabled) {
+ /* Reset link state */
+ state->link = false;
+
+ lpa = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_LPA);
+ if (lpa < 0 || lpa & LPA_RFAULT)
+ return lpa;
+
+ bmsr = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_BMSR);
+ if (bmsr < 0)
+ return bmsr;
+
+ phylink_mii_c22_pcs_decode_state(state, bmsr, lpa);
+ }
+
+ return 0;
+}
+
static void xpcs_get_state(struct phylink_pcs *pcs,
struct phylink_link_state *state)
{
@@ -948,6 +1061,13 @@ static void xpcs_get_state(struct phylink_pcs *pcs,
ERR_PTR(ret));
}
break;
+ case DW_AN_C37_1000BASEX:
+ ret = xpcs_get_state_c37_1000basex(xpcs, state);
+ if (ret) {
+ pr_err("xpcs_get_state_c37_1000basex returned %pe\n",
+ ERR_PTR(ret));
+ }
+ break;
default:
return;
}
@@ -983,6 +1103,35 @@ static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode,
pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret));
}
+static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, unsigned int mode,
+ int speed, int duplex)
+{
+ int val, ret;
+
+ if (phylink_autoneg_inband(mode))
+ return;
+
+ switch (speed) {
+ case SPEED_1000:
+ val = BMCR_SPEED1000;
+ break;
+ case SPEED_100:
+ case SPEED_10:
+ default:
+ pr_err("%s: speed = %d\n", __func__, speed);
+ return;
+ }
+
+ if (duplex == DUPLEX_FULL)
+ val |= BMCR_FULLDPLX;
+ else
+ pr_err("%s: half duplex not supported\n", __func__);
+
+ ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, val);
+ if (ret)
+ pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret));
+}
+
void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
phy_interface_t interface, int speed, int duplex)
{
@@ -992,9 +1141,23 @@ void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
return xpcs_config_usxgmii(xpcs, speed);
if (interface == PHY_INTERFACE_MODE_SGMII)
return xpcs_link_up_sgmii(xpcs, mode, speed, duplex);
+ if (interface == PHY_INTERFACE_MODE_1000BASEX)
+ return xpcs_link_up_1000basex(xpcs, mode, speed, duplex);
}
EXPORT_SYMBOL_GPL(xpcs_link_up);
+static void xpcs_an_restart(struct phylink_pcs *pcs)
+{
+ struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);
+ int ret;
+
+ ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1);
+ if (ret >= 0) {
+ ret |= BMCR_ANRESTART;
+ xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret);
+ }
+}
+
static u32 xpcs_get_id(struct dw_xpcs *xpcs)
{
int ret;
@@ -1060,6 +1223,12 @@ static const struct xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX] = {
.num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces),
.an_mode = DW_AN_C37_SGMII,
},
+ [DW_XPCS_1000BASEX] = {
+ .supported = xpcs_1000basex_features,
+ .interface = xpcs_1000basex_interfaces,
+ .num_interfaces = ARRAY_SIZE(xpcs_1000basex_interfaces),
+ .an_mode = DW_AN_C37_1000BASEX,
+ },
[DW_XPCS_2500BASEX] = {
.supported = xpcs_2500basex_features,
.interface = xpcs_2500basex_interfaces,
@@ -1115,6 +1284,7 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = {
.pcs_validate = xpcs_validate,
.pcs_config = xpcs_config,
.pcs_get_state = xpcs_get_state,
+ .pcs_an_restart = xpcs_an_restart,
.pcs_link_up = xpcs_link_up,
};
diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h
index 35651d32a22..770df50323a 100644
--- a/drivers/net/pcs/pcs-xpcs.h
+++ b/drivers/net/pcs/pcs-xpcs.h
@@ -109,7 +109,6 @@
int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg);
int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val);
-
int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs);
int nxp_sja1110_sgmii_pma_config(struct dw_xpcs *xpcs);
int nxp_sja1110_2500basex_pma_config(struct dw_xpcs *xpcs);
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index 37eb97cc228..d2da1e0b4a9 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -17,6 +17,7 @@
#define DW_AN_C73 1
#define DW_AN_C37_SGMII 2
#define DW_2500BASEX 3
+#define DW_AN_C37_1000BASEX 4
struct xpcs_id;
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v5 4/5] stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
` (2 preceding siblings ...)
2022-06-15 8:39 ` [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support Ong Boon Leong
@ 2022-06-15 8:39 ` Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 5/5] net: stmmac: make mdio register skips PHY scanning for fixed-link Ong Boon Leong
2022-06-17 10:10 ` [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
Currently, phy_interface for TSN controller instance is set based on its
PCI Device ID. For SGMII PHY interface, phy_interface default to
PHY_INTERFACE_MODE_SGMII. As C37 AN supports both SGMII and 1000BASE-X
mode, we add support for 'phy-mode' ACPI _DSD for port-specific
and customer platform specific customization.
v3: use fwnode_get_phy_mode() as suggested by Andrew Lunn in
https://patchwork.kernel.org/comment/24895330/
v2:
For platform that sets 'fixed-link' using ACPI _DSD, we will unset
xpcs_an_inband within stmmac. Thanks to Russell King for his comment in
https://patchwork.kernel.org/comment/24890222/
v1:
Thanks to Andrew Lunn's guidance in
https://patchwork.kernel.org/comment/24827101/
Tested-by: Emilio Riva <emilio.riva@ericsson.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 675dfb89b76..d0e82cb5ae0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -442,6 +442,7 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
static int intel_mgbe_common_data(struct pci_dev *pdev,
struct plat_stmmacenet_data *plat)
{
+ struct fwnode_handle *fwnode;
char clk_name[20];
int ret;
int i;
@@ -560,6 +561,24 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
/* Use the last Rx queue */
plat->vlan_fail_q = plat->rx_queues_to_use - 1;
+ /* For fixed-link setup, we allow phy-mode setting */
+ fwnode = dev_fwnode(&pdev->dev);
+ if (fwnode) {
+ int phy_mode;
+
+ /* "phy-mode" setting is optional. If it is set,
+ * we allow either sgmii or 1000base-x for now.
+ */
+ phy_mode = fwnode_get_phy_mode(fwnode);
+ if (phy_mode >= 0) {
+ if (phy_mode == PHY_INTERFACE_MODE_SGMII ||
+ phy_mode == PHY_INTERFACE_MODE_1000BASEX)
+ plat->phy_interface = phy_mode;
+ else
+ dev_warn(&pdev->dev, "Invalid phy-mode\n");
+ }
+ }
+
/* Intel mgbe SGMII interface uses pcs-xcps */
if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
@@ -567,6 +586,17 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
plat->mdio_bus_data->xpcs_an_inband = true;
}
+ /* For fixed-link setup, we clear xpcs_an_inband */
+ if (fwnode) {
+ struct fwnode_handle *fixed_node;
+
+ fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
+ if (fixed_node)
+ plat->mdio_bus_data->xpcs_an_inband = false;
+
+ fwnode_handle_put(fixed_node);
+ }
+
/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR;
plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR;
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v5 5/5] net: stmmac: make mdio register skips PHY scanning for fixed-link
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
` (3 preceding siblings ...)
2022-06-15 8:39 ` [PATCH net-next v5 4/5] stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support Ong Boon Leong
@ 2022-06-15 8:39 ` Ong Boon Leong
2022-06-17 10:10 ` [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: Ong Boon Leong @ 2022-06-15 8:39 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Russell King, Paolo Abeni, David S . Miller, Eric Dumazet,
Jakub Kicinski, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, Maxime Coquelin, Giuseppe Cavallaro
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Emilio Riva,
Ong Boon Leong
stmmac_mdio_register() lacks fixed-link consideration and only skip PHY
scanning if it has done DT style PHY discovery. So, for DT or ACPI _DSD
setting of fixed-link, the PHY scanning should not happen.
v2: fix incorrect order related to fwnode that is not caught in non-DT
platform.
Tested-by: Emilio Riva <emilio.riva@ericsson.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++++-----
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 ++++++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 73cae2938f6..50867e5d0d9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1142,18 +1142,20 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
static int stmmac_init_phy(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);
- struct device_node *node;
+ struct fwnode_handle *fwnode;
int ret;
- node = priv->plat->phylink_node;
+ fwnode = of_fwnode_handle(priv->plat->phylink_node);
+ if (!fwnode)
+ fwnode = dev_fwnode(priv->device);
- if (node)
- ret = phylink_of_phy_connect(priv->phylink, node, 0);
+ if (fwnode)
+ ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
/* Some DT bindings do not set-up the PHY handle. Let's try to
* manually parse it
*/
- if (!node || ret) {
+ if (!fwnode || ret) {
int addr = priv->plat->phy_addr;
struct phy_device *phydev;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 03d3d1f7aa4..5f177ea8072 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -434,9 +434,11 @@ int stmmac_mdio_register(struct net_device *ndev)
int err = 0;
struct mii_bus *new_bus;
struct stmmac_priv *priv = netdev_priv(ndev);
+ struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node);
struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
struct device_node *mdio_node = priv->plat->mdio_node;
struct device *dev = ndev->dev.parent;
+ struct fwnode_handle *fixed_node;
int addr, found, max_addr;
if (!mdio_bus_data)
@@ -490,6 +492,18 @@ int stmmac_mdio_register(struct net_device *ndev)
if (priv->plat->has_xgmac)
stmmac_xgmac2_mdio_read(new_bus, 0, MII_ADDR_C45);
+ /* If fixed-link is set, skip PHY scanning */
+ if (!fwnode)
+ fwnode = dev_fwnode(priv->device);
+
+ if (fwnode) {
+ fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
+ if (fixed_node) {
+ fwnode_handle_put(fixed_node);
+ goto bus_register_done;
+ }
+ }
+
if (priv->plat->phy_node || mdio_node)
goto bus_register_done;
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support
2022-06-15 8:39 ` [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support Ong Boon Leong
@ 2022-06-15 11:23 ` Russell King (Oracle)
0 siblings, 0 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2022-06-15 11:23 UTC (permalink / raw)
To: Ong Boon Leong
Cc: Alexandre Torgue, Jose Abreu, Andrew Lunn, Heiner Kallweit,
Paolo Abeni, David S . Miller, Eric Dumazet, Jakub Kicinski,
Vladimir Oltean, Vivien Didelot, Florian Fainelli,
Maxime Coquelin, Giuseppe Cavallaro, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, Emilio Riva
On Wed, Jun 15, 2022 at 04:39:06PM +0800, Ong Boon Leong wrote:
> For CL37 1000BASE-X AN, DW xPCS does not support C22 method but offers
> C45 vendor-specific MII MMD for programming.
>
> We also add the ability to disable Autoneg (through ethtool for certain
> network switch that supports 1000BASE-X (1000Mbps and Full-Duplex) but
> not Autoneg capability.
>
> v4: Fixes to comment from Russell King. Thanks!
> https://patchwork.kernel.org/comment/24894239/
> Make xpcs_modify_changed() as private, change to use
> mdiodev_modify_changed() for cleaner code.
>
> v3: Fixes to issues spotted by Russell King. Thanks!
> https://patchwork.kernel.org/comment/24890210/
> Use phylink_mii_c22_pcs_decode_state(), remove unnecessary
> interrupt clearing and skip speed & duplex setting if AN
> is enabled.
>
> v2: Fixes to issues spotted by Russell King in v1. Thanks!
> https://patchwork.kernel.org/comment/24826650/
> Use phylink_mii_c22_pcs_encode_advertisement() and implement
> C45 MII ADV handling since IP only support C45 access.
>
> Tested-by: Emilio Riva <emilio.riva@ericsson.com>
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
` (4 preceding siblings ...)
2022-06-15 8:39 ` [PATCH net-next v5 5/5] net: stmmac: make mdio register skips PHY scanning for fixed-link Ong Boon Leong
@ 2022-06-17 10:10 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-17 10:10 UTC (permalink / raw)
To: Ong Boon Leong
Cc: alexandre.torgue, Jose.Abreu, andrew, hkallweit1, linux, pabeni,
davem, edumazet, kuba, olteanv, vivien.didelot, f.fainelli,
mcoquelin.stm32, peppe.cavallaro, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, emilio.riva
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Wed, 15 Jun 2022 16:39:03 +0800 you wrote:
> Thanks for v4 review feedback in [1] and [2]. I have changed the v5
> implementation as follow.
>
> v5 changes:
> 1/5 - No change from v4.
> 2/5 - No change from v4.
> 3/5 - [Fix] make xpcs_modify_changed() static and use
> mdiodev_modify_changed() for cleaner code as suggested by
> Russell King.
> 4/5 - [Fix] Use fwnode_get_phy_mode() as recommended by Andrew Lunn.
> 5/5 - [Fix] Make fwnode = of_fwnode_handle(priv->plat->phylink_node)
> order after priv = netdev_priv(dev).
>
> [...]
Here is the summary with links:
- [net-next,v5,1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105
https://git.kernel.org/netdev/net-next/c/fa9c562f9735
- [net-next,v5,2/5] stmmac: intel: prepare to support 1000BASE-X phy interface setting
https://git.kernel.org/netdev/net-next/c/c82386310d95
- [net-next,v5,3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support
https://git.kernel.org/netdev/net-next/c/b47aec885bcd
- [net-next,v5,4/5] stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support
https://git.kernel.org/netdev/net-next/c/72edaf39fc65
- [net-next,v5,5/5] net: stmmac: make mdio register skips PHY scanning for fixed-link
https://git.kernel.org/netdev/net-next/c/ab21cf920928
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-06-17 10:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 8:39 [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 1/5] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 2/5] stmmac: intel: prepare to support 1000BASE-X phy interface setting Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 3/5] net: pcs: xpcs: add CL37 1000BASE-X AN support Ong Boon Leong
2022-06-15 11:23 ` Russell King (Oracle)
2022-06-15 8:39 ` [PATCH net-next v5 4/5] stmmac: intel: add phy-mode and fixed-link ACPI _DSD setting support Ong Boon Leong
2022-06-15 8:39 ` [PATCH net-next v5 5/5] net: stmmac: make mdio register skips PHY scanning for fixed-link Ong Boon Leong
2022-06-17 10:10 ` [PATCH net-next v5 0/5] pcs-xpcs, stmmac: add 1000BASE-X AN for network switch patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).