From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, andrew@lunn.ch,
f.fainelli@gmail.com, vivien.didelot@gmail.com,
claudiu.manoil@nxp.com, alexandru.marginean@nxp.com,
ioana.ciornei@nxp.com
Subject: Re: [PATCH net-next 2/7] net: dsa: felix: support half-duplex link modes
Date: Thu, 25 Jun 2020 17:30:13 +0100 [thread overview]
Message-ID: <20200625163013.GG1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200625152331.3784018-3-olteanv@gmail.com>
On Thu, Jun 25, 2020 at 06:23:26PM +0300, Vladimir Oltean wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> Ping tested:
>
> [ 11.808455] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control rx/tx
> [ 11.816497] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
>
> [root@LS1028ARDB ~] # ethtool -s swp0 advertise 0x4
> [ 18.844591] mscc_felix 0000:00:00.5 swp0: Link is Down
> [ 22.048337] mscc_felix 0000:00:00.5 swp0: Link is Up - 100Mbps/Half - flow control off
>
> [root@LS1028ARDB ~] # ip addr add 192.168.1.1/24 dev swp0
>
> [root@LS1028ARDB ~] # ping 192.168.1.2
> PING 192.168.1.2 (192.168.1.2): 56 data bytes
> (...)
> ^C--- 192.168.1.2 ping statistics ---
> 3 packets transmitted, 3 packets received, 0% packet loss
> round-trip min/avg/max = 0.383/0.611/1.051 ms
>
> [root@LS1028ARDB ~] # ethtool -s swp0 advertise 0x10
> [ 355.637747] mscc_felix 0000:00:00.5 swp0: Link is Down
> [ 358.788034] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Half - flow control off
>
> [root@LS1028ARDB ~] # ping 192.168.1.2
> PING 192.168.1.2 (192.168.1.2): 56 data bytes
> (...)
> ^C
> --- 192.168.1.2 ping statistics ---
> 16 packets transmitted, 16 packets received, 0% packet loss
> round-trip min/avg/max = 0.301/0.384/1.138 ms
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Ping isn't really a good test of whether half duplex mode is operating
correctly. However, apart from that detail, and as this reflects the
functionality I implemented with the LX2160A version of this PCS:
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Repost of:
> https://patchwork.ozlabs.org/project/netdev/patch/20200624155926.3379373-1-olteanv@gmail.com/
> Changed:
> In the "forced link" scenario (not previously tested, just in-band), we
> need to configure half duplex through the IF_MODE register, not BMCR.
>
> drivers/net/dsa/ocelot/felix.c | 4 +++-
> drivers/net/dsa/ocelot/felix_vsc9959.c | 24 ++++++++++++++----------
> include/linux/fsl/enetc_mdio.h | 1 +
> 3 files changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index 25046777c993..25b340e0a6dd 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -194,13 +194,15 @@ static void felix_phylink_validate(struct dsa_switch *ds, int port,
> return;
> }
>
> - /* No half-duplex. */
> phylink_set_port_modes(mask);
> phylink_set(mask, Autoneg);
> phylink_set(mask, Pause);
> phylink_set(mask, Asym_Pause);
> + phylink_set(mask, 10baseT_Half);
> phylink_set(mask, 10baseT_Full);
> + phylink_set(mask, 100baseT_Half);
> phylink_set(mask, 100baseT_Full);
> + phylink_set(mask, 1000baseT_Half);
> phylink_set(mask, 1000baseT_Full);
>
> if (state->interface == PHY_INTERFACE_MODE_INTERNAL ||
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 3269c76b59ff..c1220b488f9c 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -817,12 +817,9 @@ static void vsc9959_pcs_init_sgmii(struct phy_device *pcs,
>
> phy_write(pcs, MII_BMCR, BMCR_ANRESTART | BMCR_ANENABLE);
> } else {
> + u16 if_mode = ENETC_PCS_IF_MODE_SGMII_EN;
> int speed;
>
> - if (state->duplex == DUPLEX_HALF) {
> - phydev_err(pcs, "Half duplex not supported\n");
> - return;
> - }
> switch (state->speed) {
> case SPEED_1000:
> speed = ENETC_PCS_SPEED_1000;
> @@ -841,10 +838,11 @@ static void vsc9959_pcs_init_sgmii(struct phy_device *pcs,
> return;
> }
>
> - phy_write(pcs, ENETC_PCS_IF_MODE,
> - ENETC_PCS_IF_MODE_SGMII_EN |
> - ENETC_PCS_IF_MODE_SGMII_SPEED(speed));
> + if_mode |= ENETC_PCS_IF_MODE_SGMII_SPEED(speed);
> + if (state->duplex == DUPLEX_HALF)
> + if_mode |= ENETC_PCS_IF_MODE_DUPLEX_HALF;
>
> + phy_write(pcs, ENETC_PCS_IF_MODE, if_mode);
> phy_write(pcs, MII_BMCR, BMCR_RESET);
> }
> }
> @@ -870,15 +868,18 @@ static void vsc9959_pcs_init_2500basex(struct phy_device *pcs,
> unsigned int link_an_mode,
> const struct phylink_link_state *state)
> {
> + u16 if_mode = ENETC_PCS_IF_MODE_SGMII_SPEED(ENETC_PCS_SPEED_2500) |
> + ENETC_PCS_IF_MODE_SGMII_EN;
> +
> if (link_an_mode == MLO_AN_INBAND) {
> phydev_err(pcs, "AN not supported on 3.125GHz SerDes lane\n");
> return;
> }
>
> - phy_write(pcs, ENETC_PCS_IF_MODE,
> - ENETC_PCS_IF_MODE_SGMII_EN |
> - ENETC_PCS_IF_MODE_SGMII_SPEED(ENETC_PCS_SPEED_2500));
> + if (state->duplex == DUPLEX_HALF)
> + if_mode |= ENETC_PCS_IF_MODE_DUPLEX_HALF;
>
> + phy_write(pcs, ENETC_PCS_IF_MODE, if_mode);
> phy_write(pcs, MII_BMCR, BMCR_RESET);
> }
>
> @@ -919,8 +920,11 @@ static void vsc9959_pcs_init(struct ocelot *ocelot, int port,
> linkmode_set_bit_array(phy_basic_ports_array,
> ARRAY_SIZE(phy_basic_ports_array),
> pcs->supported);
> + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, pcs->supported);
> linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, pcs->supported);
> + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, pcs->supported);
> linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, pcs->supported);
> + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, pcs->supported);
> linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, pcs->supported);
> if (pcs->interface == PHY_INTERFACE_MODE_2500BASEX ||
> pcs->interface == PHY_INTERFACE_MODE_USXGMII)
> diff --git a/include/linux/fsl/enetc_mdio.h b/include/linux/fsl/enetc_mdio.h
> index 4875dd38af7e..2d9203314865 100644
> --- a/include/linux/fsl/enetc_mdio.h
> +++ b/include/linux/fsl/enetc_mdio.h
> @@ -15,6 +15,7 @@
> #define ENETC_PCS_IF_MODE_SGMII_EN BIT(0)
> #define ENETC_PCS_IF_MODE_USE_SGMII_AN BIT(1)
> #define ENETC_PCS_IF_MODE_SGMII_SPEED(x) (((x) << 2) & GENMASK(3, 2))
> +#define ENETC_PCS_IF_MODE_DUPLEX_HALF BIT(3)
>
> /* Not a mistake, the SerDes PLL needs to be set at 3.125 GHz by Reset
> * Configuration Word (RCW, outside Linux control) for 2.5G SGMII mode. The PCS
> --
> 2.25.1
>
>
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2020-06-25 16:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 15:23 [PATCH net-next 0/7] PHYLINK integration improvements for Felix DSA driver Vladimir Oltean
2020-06-25 15:23 ` [PATCH net-next 1/7] net: dsa: felix: stop writing to read-only fields in MII_BMCR Vladimir Oltean
2020-06-25 16:28 ` Russell King - ARM Linux admin
2020-06-25 15:23 ` [PATCH net-next 2/7] net: dsa: felix: support half-duplex link modes Vladimir Oltean
2020-06-25 16:30 ` Russell King - ARM Linux admin [this message]
2020-06-25 15:23 ` [PATCH net-next 3/7] net: dsa: felix: unconditionally configure MAC speed to 1000Mbps Vladimir Oltean
2020-06-25 15:23 ` [PATCH net-next 4/7] net: dsa: felix: set proper pause frame timers based on link speed Vladimir Oltean
2020-06-25 16:37 ` Russell King - ARM Linux admin
2020-06-25 16:48 ` Vladimir Oltean
2020-06-25 16:58 ` Russell King - ARM Linux admin
2020-06-25 17:06 ` Vladimir Oltean
2020-06-25 17:53 ` Russell King - ARM Linux admin
2020-06-25 15:23 ` [PATCH net-next 5/7] net: dsa: felix: delete .phylink_mac_an_restart code Vladimir Oltean
2020-06-25 16:53 ` Russell King - ARM Linux admin
2020-06-26 8:53 ` Vladimir Oltean
2020-06-26 11:08 ` Russell King - ARM Linux admin
2020-06-26 11:19 ` Vladimir Oltean
2020-06-26 11:32 ` Russell King - ARM Linux admin
2020-06-25 15:23 ` [PATCH net-next 6/7] net: dsa: felix: disable in-band AN in MII_BMCR without reset Vladimir Oltean
2020-06-25 15:23 ` [PATCH net-next 7/7] net: dsa: felix: use resolved link config in mac_link_up() Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200625163013.GG1551@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandru.marginean@nxp.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).