net: axienet: Properly handle PCS/PMA PHY for 1000BaseX mode
PATCH v2 1/1 net: axienet: Properly handle PCS/PMA PHY for 1000BaseX mode
Update the axienet driver to properly support the Xilinx PCS/PMA PHY component which is used for 1000BaseX and SGMII modes, including properly configuring the auto-negotiation mode of the PHY and reading the negotiated state from the PHY.
---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++----- 2 files changed, 73 insertions(+), 26 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +3 -0
@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +70 -26
130 lines not on this page · raw message
Signature · 1 line
2.18.4
Thanks for the patch.
Quoted 58 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Monday, October 26, 2020 11:26 PM
To: Radhey Shyam Pandey <[email protected]>; [email protected]; [email protected]
Cc: Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; Robert Hancock <[email protected]>
Subject: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for 1000BaseX modeUpdate the axienet driver to properly support the Xilinx PCS/PMA PHY component which is used for 1000BaseX and SGMII modes, including properly configuring the auto-negotiation mode of the PHY and reading the negotiated state from the PHY.
Signed-off-by Robert Hancock <[email protected]>---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++----- 2 files changed, 73 insertions(+), 26 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +3
-0@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-4@@ -1517,10 +1517,29 @@ static void axienet_validate(structphylink_config *config,phylink_set (mask ,Asym_Pause );phylink_set (mask, Pause); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Full); + +switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX :
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct · line 1534
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +10
-0+case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;
100BaseT and 10BaseT can be set in PHY_INTERFACE_MODE_MII if we allow fallthrough here.
Quoted 45 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+ phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +break ; +case PHY_INTERFACE_MODE_MII : + phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +default : +break ; + } bitmap_and(supported, supported, mask,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +7
-20__ETHTOOL_LINK_MODE_MASK_NBITS);@@ -1533,38 +1552,46 @@ static void axienet_mac_pcs_get_state(struct phylink_config *config, {struct net_device *ndev =to_net_dev (config->dev);struct axienet_local *lp =netdev_priv (ndev); -u32 emmc_reg, fcc_reg; - - state->interface = lp->phy_mode; - emmc_reg =axienet_ior (lp,XAE_EMMC_OFFSET ); -if (emmc_reg &XAE_EMMC_LINKSPD_1000 ) - state->speed =SPEED_1000 ; -else if (emmc_reg &XAE_EMMC_LINKSPD_100 ) - state->speed =SPEED_100 ; -else - state->speed =SPEED_10 ; - - state->pause =0 ; - fcc_reg =axienet_ior (lp,XAE_FCC_OFFSET ); -if (fcc_reg &XAE_FCC_FCTX_MASK ) - state->pause |=MLO_PAUSE_TX ; -if (fcc_reg &XAE_FCC_FCRX_MASK ) - state->pause |=MLO_PAUSE_RX ; - - state->an_complete =0 ; - state->duplex =1 ; +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +phylink_mii_c22_pcs_get_state (lp->pcs_phy, state); +break ; +default : +break ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_mac_pcs_get_state(struct · line 1572
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-1+ } }static void axienet_mac_an_restart (struct phylink_config *config) { -/* Unsupported, do nothing */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); + +phylink_mii_c22_pcs_an_restart (lp->pcs_phy);
Is this phylink.._an_restart only called for 1000BaseX/SGMII?
Quoted 29 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +18
-1}static void axienet_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) { -/* nothing meaningful to do */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); +int ret; + +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : + ret =phylink_mii_c22_pcs_config (lp->pcs_phy, mode, + state->interface, + state->advertising); +if (ret <0 ) +netdev_warn (ndev,"Failed to configure PCS: %d\n" , + ret); +break ; + +default : +break ; + } }static void axienet_mac_link_down(struct
phylink_config*config,
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device · line 2029
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -1999,6 +2026,20 @@ static int axienet_probe(struct platform_device *pdev)dev_warn (&pdev->dev,"error registering MDIO bus: %d\n" , ret); }
Minor nit - There is already a check for phy_node at L1882. Maybe we can refactor and use it.
if (!lp->phy_node) {
if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII || BASEX)
//error handing
} else {
//existing code
}drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 2038
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +10
-0+if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || + lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { +if (!lp->phy_node) { + dev_err(&pdev->dev, "phy-handle required for 1000BaseX/SGMII\n"); + ret = -EINVAL; + goto free_netdev; + } + lp->pcs_phy =of_mdio_find_device (lp->phy_node); +if (!lp->pcs_phy) { + ret = -EPROBE_DEFER ;
Are we assuming the error is always EPROBE_DEFER?
Quoted 20 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+ goto free_netdev; + } + lp->phylink_config.pcs_poll = true; + }drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0lp->phylink_config.dev = &ndev->dev; lp->phylink_config.type =PHYLINK_NETDEV ;@@ -2036,6 +2077,9 @@ static int axienet_remove(struct platform_device *pdev)if (lp->phylink)phylink_destroy (lp->phylink); +if (lp->pcs_phy) +put_device (&lp->pcs_phy->dev); +axienet_mdio_teardown (lp);
clk_disable_unprepare(lp->clk);
--
2.18.4
Quoted 8 lines · Radhey Shyam Pandey
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8
-0+switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID :
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct phylink_config *config, · line 1533
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-0+case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;100BaseT and 10BaseT can be set in
PHY_INTERFACE_MODE_MIIif we allow fallthrough here.
The above is actually correct (at the moment) since we don't yet support rate adapting 1G PHYs.
Quoted 5 lines
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || + lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { +if (!lp->phy_node) { + dev_err(&pdev->dev, "phy-handle required for1000BaseX/SGMII\n");
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 2038
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ ret = -EINVAL ; + goto free_netdev; + } + lp->pcs_phy =of_mdio_find_device (lp->phy_node); +if (!lp->pcs_phy) { + ret = -EPROBE_DEFER ;Are we assuming the error is always
EPROBE_DEFER?
of_mdio_find_device() returning NULL when the argument is non-NULL just means it wasn't found - which isn't an "error".
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 69 lines · Radhey Shyam Pandey
Thanks for the patch.
Quoted 67 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Monday, October 26, 2020 11:26 PM
To: Radhey Shyam Pandey <[email protected]>; [email protected]; [email protected]
Cc: Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; Robert Hancock <[email protected]>
Subject: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for
1000BaseX modeUpdate the axienet driver to properly support the Xilinx PCS/PMA PHY
component which is used for 1000BaseX and SGMII modes, including properly configuring the auto-negotiation mode of the PHY and reading
the negotiated state from the PHY.Signed-off-by Robert Hancock <[email protected]>---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++- ---- 2 files changed, 73 insertions(+), 26 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +3
-0@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-4@@ -1517,10 +1517,29 @@ static void axienet_validate(structphylink_config *config,phylink_set (mask ,Asym_Pause );phylink_set (mask, Pause); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Full); + +switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID :
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct phylink_config *config, · line 1533
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-0+case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;100BaseT and 10BaseT can be set in
PHY_INTERFACE_MODE_MIIif we allow fallthrough here.
Not quite sure what you are saying here?
Quoted 49 lines
Quoted 49 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+ phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +break ; +case PHY_INTERFACE_MODE_MII : + phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +default : +break ; + } bitmap_and(supported, supported, mask,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0__ETHTOOL_LINK_MODE_MASK_NBITS);@@ -1533,38 +1552,46 @@ static voidaxienet_mac_pcs_get_state(struct
phylink_config*config,
{drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8
-20struct net_device *ndev =to_net_dev (config->dev);struct axienet_local *lp =netdev_priv (ndev); -u32 emmc_reg, fcc_reg; - - state->interface = lp->phy_mode; - emmc_reg =axienet_ior (lp,XAE_EMMC_OFFSET ); -if (emmc_reg &XAE_EMMC_LINKSPD_1000 ) - state->speed =SPEED_1000 ; -else if (emmc_reg &XAE_EMMC_LINKSPD_100 ) - state->speed =SPEED_100 ; -else - state->speed =SPEED_10 ; - - state->pause =0 ; - fcc_reg =axienet_ior (lp,XAE_FCC_OFFSET ); -if (fcc_reg &XAE_FCC_FCTX_MASK ) - state->pause |=MLO_PAUSE_TX ; -if (fcc_reg &XAE_FCC_FCRX_MASK ) - state->pause |=MLO_PAUSE_RX ; - - state->an_complete =0 ; - state->duplex =1 ; +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +phylink_mii_c22_pcs_get_state (lp->pcs_phy, state); +break ; +default : +break ; + } }
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_mac_pcs_get_state(struct phylink_config *config, · line 1571
Quoted 7 lines
static void
axienet_mac_an_restart(struct phylink_config *config){drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-1-/* Unsupported, do nothing */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); + +phylink_mii_c22_pcs_an_restart (lp->pcs_phy);Is this phylink.._an_restart only called for 1000BaseX/SGMII?
Yes, this is only called in phylink_mac_pcs_an_restart and only if phy_interface_mode_is_8023z returns true (only for 1000BaseX or 2500BaseX).
Quoted 29 lines
Quoted 29 lines
}
static void axienet_mac_config(struct
phylink_config*config,
unsigned int
mode,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12
-1const struct phylink_link_state *state) { -/* nothing meaningful to do */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); +int ret; + +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : + ret =phylink_mii_c22_pcs_config (lp->pcs_phy, mode, + state->interface, + state->advertising); +if (ret <0 ) + netdev_warn(ndev, "Failed to configure PCS:%d\n",
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ ret); +break ; + +default : +break ; + } }
Quoted 11 lines
Quoted 8 lines
static void axienet_mac_link_down(struct
phylink_config*config,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -1999,6 +2026,20 @@ static int axienet_probe(struct
platform_device
*pdev)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0dev_warn(&pdev->dev, "error registering MDIO bus: %d\n",ret);
}Minor nit - There is already a check for
phy_nodeat L1882. Maybe we can refactor and use it.
Possible, but then we need to duplicate the check for 1000BaseX/SGMII again before looking for pcs_phy - doesn't seem like a clear win.
Quoted 7 lines
if (!lp->phy_node) {
if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII || BASEX)
//error handing
} else {
//existing code
}Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 2038
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || + lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { +if (!lp->phy_node) { + dev_err(&pdev->dev, "phy-handle required for1000BaseX/SGMII\n");
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ ret = -EINVAL ; + goto free_netdev; + } + lp->pcs_phy =of_mdio_find_device (lp->phy_node); +if (!lp->pcs_phy) { + ret = -EPROBE_DEFER ;Are we assuming the error is always
EPROBE_DEFER?
As Russell mentioned, I believe the device not being found is the only error possible here.
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+ goto free_netdev; + } + lp->phylink_config.pcs_poll = true; + } lp->phylink_config.dev = &ndev->dev; lp->phylink_config.type =PHYLINK_NETDEV ;@@ -2036,6 +2077,9 @@ static int axienet_remove(struct
platform_device
*pdev)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-1if (lp->phylink)phylink_destroy (lp->phylink); +if (lp->pcs_phy) +put_device (&lp->pcs_phy->dev); +axienet_mdio_teardown (lp);clk_disable_unprepare (lp->clk); --2.18.4
Quoted 90 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Tuesday, October 27, 2020 1:15 AM
To: Radhey Shyam Pandey <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for 1000BaseX modeQuoted 6 lines · Radhey Shyam Pandey
Thanks for the patch.
Quoted 4 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Monday, October 26, 2020 11:26 PM
To: Radhey Shyam Pandey <[email protected]>;Quoted 63 lines
Quoted 63 lines
[email protected]
Cc: Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; Robert Hancock <[email protected]>
Subject: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for
1000BaseX modeUpdate the axienet driver to properly support the Xilinx PCS/PMA PHY
component which is used for 1000BaseX and SGMII modes, including properly configuring the auto-negotiation mode of the PHY and reading
the negotiated state from the PHY.Signed-off-by Robert Hancock <[email protected]>---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++- ---- 2 files changed, 73 insertions(+), 26 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +3
-0@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-4@@ -1517,10 +1517,29 @@ static void axienet_validate(structphylink_config *config,phylink_set (mask ,Asym_Pause );phylink_set (mask, Pause); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Full); + +switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID :Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct phylink_config *config, · line 1533
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-0+case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;100BaseT and 10BaseT can be set in
PHY_INTERFACE_MODE_MIIif we allow fallthrough here.
Quoted 1 line
Not quite sure what you are saying here?
I was saying to allow switch case fall through.
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ phylink_set(mask, 1000baseX_Full);
+ phylink_set(mask, 1000baseT_Full);
+ if (state->interface == PHY_INTERFACE_MODE_1000BASEX)
+ break;
+ case PHY_INTERFACE_MODE_MII:
+ phylink_set(mask, 100baseT_Full);
+ phylink_set(mask, 10baseT_Full);
Quoted 60 lines
Quoted 50 lines
Quoted 50 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+ phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +break ; +case PHY_INTERFACE_MODE_MII : + phylink_set(mask, 100baseT_Full); + phylink_set(mask, 10baseT_Full); +default : +break ; + } bitmap_and(supported, supported, mask,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0__ETHTOOL_LINK_MODE_MASK_NBITS);@@ -1533,38 +1552,46 @@ static voidaxienet_mac_pcs_get_state(struct
phylink_config*config,
{drivers/net/ethernet/xilinx/xilinx_axienet_main.c +8
-20struct net_device *ndev =to_net_dev (config->dev);struct axienet_local *lp =netdev_priv (ndev); -u32 emmc_reg, fcc_reg; - - state->interface = lp->phy_mode; - emmc_reg =axienet_ior (lp,XAE_EMMC_OFFSET ); -if (emmc_reg &XAE_EMMC_LINKSPD_1000 ) - state->speed =SPEED_1000 ; -else if (emmc_reg &XAE_EMMC_LINKSPD_100 ) - state->speed =SPEED_100 ; -else - state->speed =SPEED_10 ; - - state->pause =0 ; - fcc_reg =axienet_ior (lp,XAE_FCC_OFFSET ); -if (fcc_reg &XAE_FCC_FCTX_MASK ) - state->pause |=MLO_PAUSE_TX ; -if (fcc_reg &XAE_FCC_FCRX_MASK ) - state->pause |=MLO_PAUSE_RX ; - - state->an_complete =0 ; - state->duplex =1 ; +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +phylink_mii_c22_pcs_get_state (lp->pcs_phy, state); +break ; +default : +break ; + } }Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_mac_pcs_get_state(struct phylink_config *config, · line 1571
Quoted 7 lines
static void
axienet_mac_an_restart(struct phylink_config *config){drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-1-/* Unsupported, do nothing */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); + +phylink_mii_c22_pcs_an_restart (lp->pcs_phy);Is this phylink.._an_restart only called for 1000BaseX/SGMII?
Quoted 3 lines
Yes, this is only called in
phylink_mac_pcs_an_restartand only ifphy_interface_mode_is_8023zreturns true (only for 1000BaseX or 2500BaseX).
Ok. Thanks.
Quoted 42 lines
Quoted 30 lines
Quoted 30 lines
}
static void axienet_mac_config(struct
phylink_config*config,
unsigned int
mode,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12
-1const struct phylink_link_state *state) { -/* nothing meaningful to do */ +struct net_device *ndev =to_net_dev (config->dev); +struct axienet_local *lp =netdev_priv (ndev); +int ret; + +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : + ret =phylink_mii_c22_pcs_config (lp->pcs_phy, mode, + state->interface, + state->advertising); +if (ret <0 ) + netdev_warn(ndev, "Failed to configure PCS:%d\n",
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ ret); +break ; + +default : +break ; + } }Quoted 11 lines
Quoted 8 lines
static void axienet_mac_link_down(struct
phylink_config*config,drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -1999,6 +2026,20 @@ static int axienet_probe(struct
platform_device
*pdev)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0dev_warn(&pdev->dev, "error registering MDIO bus: %d\n",ret);
}Minor nit - There is already a check for
phy_nodeat L1882. Maybe we can refactor and use it.
Quoted 2 lines
Possible, but then we need to duplicate the check for 1000BaseX/SGMII again before looking for
pcs_phy- doesn't seem like a clear win.
Seems fine then.
Quoted 46 lines
Quoted 8 lines
if (!lp->phy_node) { if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII || BASEX) //error handing } else { //existing code }Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 2038
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || + lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { +if (!lp->phy_node) { + dev_err(&pdev->dev, "phy-handle required for1000BaseX/SGMII\n");
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ ret = -EINVAL ; + goto free_netdev; + } + lp->pcs_phy =of_mdio_find_device (lp->phy_node); +if (!lp->pcs_phy) { + ret = -EPROBE_DEFER ;Are we assuming the error is always
EPROBE_DEFER?As Russell mentioned, I believe the device not being found is the only error possible here.
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0+ goto free_netdev; + } + lp->phylink_config.pcs_poll = true; + } lp->phylink_config.dev = &ndev->dev; lp->phylink_config.type =PHYLINK_NETDEV ;@@ -2036,6 +2077,9 @@ static int axienet_remove(struct
platform_device
*pdev)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-1if (lp->phylink)phylink_destroy (lp->phylink); +if (lp->pcs_phy) +put_device (&lp->pcs_phy->dev); +axienet_mdio_teardown (lp);clk_disable_unprepare (lp->clk); --2.18.4
Quoted 96 lines · Radhey Shyam Pandey
Quoted 96 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Tuesday, October 27, 2020 1:15 AM
To: Radhey Shyam Pandey <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY
for 1000BaseX modeQuoted 6 lines · Radhey Shyam Pandey
Thanks for the patch.
Quoted 4 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Monday, October 26, 2020 11:26 PM
To: Radhey Shyam Pandey <[email protected]>;Quoted 76 lines
Quoted 63 lines
[email protected]
Cc: Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; Robert Hancock <[email protected]>
Subject: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA
PHY for
1000BaseX modeUpdate the axienet driver to properly support the Xilinx PCS/PMA
PHY
component which is used for 1000BaseX and SGMII modes, including
properly configuring the auto-negotiation mode of the PHY and reading
the negotiated state from the PHY.Signed-off-by Robert Hancock <[email protected]>---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++- ---- 2 files changed, 73 insertions(+), 26 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +3
-0@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-4@@ -1517,10 +1517,29 @@ static void axienet_validate(structphylink_config *config,phylink_set (mask ,Asym_Pause );phylink_set (mask, Pause); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Full); + +switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_SGMII :drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct · line 1535
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;100BaseT and 10BaseT can be set in
PHY_INTERFACE_MODE_MIIif we allow fallthrough here.
Quoted 3 lines
Quoted 1 line
Not quite sure what you are saying here?
I was saying to allow switch case fall through.
Ah, I see. Yes, that would work to save a couple duplicate lines - just not sure if using the switch fall-through is preferable. Any thoughts from people on what's preferred?
Signature · 3 lines
Robert Hancock Senior Hardware Designer, Advanced Technologies www.calian.com
Quoted 101 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Tuesday, October 27, 2020 8:38 PM
To: Radhey Shyam Pandey <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for 1000BaseX modeQuoted 4 lines · Radhey Shyam Pandey
Quoted 4 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Tuesday, October 27, 2020 1:15 AM
To: Radhey Shyam Pandey <[email protected]>;Quoted 85 lines
Quoted 85 lines
[email protected]
Cc: [email protected]; Michal Simek <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for 1000BaseX modeQuoted 6 lines · Radhey Shyam Pandey
Thanks for the patch.
Quoted 4 lines
-----Original Message-----
From: Robert Hancock <[email protected]>
Sent: Monday, October 26, 2020 11:26 PM
To: Radhey Shyam Pandey <[email protected]>;Quoted 70 lines
Quoted 57 lines
[email protected]
Cc: Michal Simek <[email protected]>; [email protected]; [email protected]; [email protected]; Robert Hancock <[email protected]>
Subject: [PATCH net-next v2] net: axienet: Properly handle PCS/PMA PHY for 1000BaseX modeUpdate the axienet driver to properly support the Xilinx PCS/PMA PHY component which is used for 1000BaseX and SGMII modes, including properly configuring the auto-negotiation mode of the PHY and reading the negotiated state from the PHY.
Signed-off-by Robert Hancock <[email protected]>---
Resubmit of v2 tagged for net-next.
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 96 ++++++++++++++- ---- 2 files changed, 73 insertions(+), 26 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet.h +3
-0@@ -419,6 +419,9 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; +/* Reference to PCS/PMA PHY if used */ +struct mdio_device *pcs_phy; +/* Clock for AXI bus */ struct clk *clk;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-4@@ -1517,10 +1517,29 @@ static void axienet_validate(structphylink_config *config,phylink_set (mask ,Asym_Pause );phylink_set (mask, Pause); - phylink_set(mask, 1000baseX_Full); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Full); + +switch (state->interface) { +case PHY_INTERFACE_MODE_NA : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_SGMII :drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_validate(struct · line 1535
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+case PHY_INTERFACE_MODE_GMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_RGMII_ID : +case PHY_INTERFACE_MODE_RGMII_RXID : +case PHY_INTERFACE_MODE_RGMII_TXID : + phylink_set(mask, 1000baseX_Full); + phylink_set(mask, 1000baseT_Full); +if (state->interface ==PHY_INTERFACE_MODE_1000BASEX ) +break ;100BaseT and 10BaseT can be set in
PHY_INTERFACE_MODE_MIIif we allow fallthrough here.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Not quite sure what you are saying here?
I was saying to allow switch case fall through.
Ah, I see. Yes, that would work to save a couple duplicate lines - just not sure if using the switch fall-through is preferable. Any thoughts from people on
Right. Just to add - we are already using switch fall-through. So reusing it might be ok.
+ case PHY_INTERFACE_MODE_NA:
+ case PHY_INTERFACE_MODE_1000BASEX:
+ case PHY_INTERFACE_MODE_SGMII:
Quoted 5 lines
what's preferred?
--
Robert Hancock
Senior Hardware Designer, Advanced Technologies www.calian.com