diff mbox series

[RFC,net-next] net: mvneta: deny disabling autoneg for 802.3z modes

Message ID E1m2y9M-0005w4-3p@rmk-PC.armlinux.org.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [RFC,net-next] net: mvneta: deny disabling autoneg for 802.3z modes | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: linux@armlinux.org.uk
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/header_inline success Link

Commit Message

Russell King (Oracle) July 12, 2021, 3:47 p.m. UTC
The documentation for Armada 38x says:

  Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ...
  When <PortType> = 1 (1000BASE-X) this field must be set to 1.

We presently ignore whether userspace requests autonegotiation or not
through the ethtool ksettings interface. However, we have some network
interfaces that wish to do this. To offer a consistent API across
network interfaces, deny the ability to disable autonegotiation on
mvneta hardware when in 1000BASE-X and 2500BASE-X.

This means the only way to switch between 2500BASE-X and 1000BASE-X
on SFPs that support this will be:

 # ethtool -s ethX advertise 0x20000002000 # 1000BASE-X Pause
 # ethtool -s ethX advertise 0xa000        # 2500BASE-X Pause

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
net-next is currently closed, but I'd like to collect acks for this
patch. Thanks.

 drivers/net/ethernet/marvell/mvneta.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Marek Behún July 12, 2021, 9:27 p.m. UTC | #1
On Mon, 12 Jul 2021 16:47:16 +0100
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:

> The documentation for Armada 38x says:
> 
>   Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ...
>   When <PortType> = 1 (1000BASE-X) this field must be set to 1.
> 
> We presently ignore whether userspace requests autonegotiation or not
> through the ethtool ksettings interface. However, we have some network
> interfaces that wish to do this. To offer a consistent API across
> network interfaces, deny the ability to disable autonegotiation on
> mvneta hardware when in 1000BASE-X and 2500BASE-X.
> 
> This means the only way to switch between 2500BASE-X and 1000BASE-X
> on SFPs that support this will be:
> 
>  # ethtool -s ethX advertise 0x20000002000 # 1000BASE-X Pause
>  # ethtool -s ethX advertise 0xa000        # 2500BASE-X Pause
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> net-next is currently closed, but I'd like to collect acks for this
> patch. Thanks.
> 
>  drivers/net/ethernet/marvell/mvneta.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index 361bc4fbe20b..0a35d216b742 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -3832,12 +3832,20 @@ static void mvneta_validate(struct phylink_config *config,
>  	struct mvneta_port *pp = netdev_priv(ndev);
>  	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
>  
> -	/* We only support QSGMII, SGMII, 802.3z and RGMII modes */
> -	if (state->interface != PHY_INTERFACE_MODE_NA &&
> -	    state->interface != PHY_INTERFACE_MODE_QSGMII &&
> -	    state->interface != PHY_INTERFACE_MODE_SGMII &&
> -	    !phy_interface_mode_is_8023z(state->interface) &&
> -	    !phy_interface_mode_is_rgmii(state->interface)) {
> +	/* We only support QSGMII, SGMII, 802.3z and RGMII modes.
> +	 * When in 802.3z mode, we must have AN enabled:
> +	 * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ...
> +	 * When <PortType> = 1 (1000BASE-X) this field must be set to 1."
> +	 */
> +	if (phy_interface_mode_is_8023z(state->interface)) {
> +		if (!phylink_test(state->advertising, Autoneg)) {
> +			bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
> +			return;
> +		}
> +	} else if (state->interface != PHY_INTERFACE_MODE_NA &&
> +		   state->interface != PHY_INTERFACE_MODE_QSGMII &&
> +		   state->interface != PHY_INTERFACE_MODE_SGMII &&
> +		   !phy_interface_mode_is_rgmii(state->interface)) {
>  		bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
>  		return;
>  	}

Acked-by: Marek Behún <kabel@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 361bc4fbe20b..0a35d216b742 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3832,12 +3832,20 @@  static void mvneta_validate(struct phylink_config *config,
 	struct mvneta_port *pp = netdev_priv(ndev);
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
-	/* We only support QSGMII, SGMII, 802.3z and RGMII modes */
-	if (state->interface != PHY_INTERFACE_MODE_NA &&
-	    state->interface != PHY_INTERFACE_MODE_QSGMII &&
-	    state->interface != PHY_INTERFACE_MODE_SGMII &&
-	    !phy_interface_mode_is_8023z(state->interface) &&
-	    !phy_interface_mode_is_rgmii(state->interface)) {
+	/* We only support QSGMII, SGMII, 802.3z and RGMII modes.
+	 * When in 802.3z mode, we must have AN enabled:
+	 * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ...
+	 * When <PortType> = 1 (1000BASE-X) this field must be set to 1."
+	 */
+	if (phy_interface_mode_is_8023z(state->interface)) {
+		if (!phylink_test(state->advertising, Autoneg)) {
+			bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
+			return;
+		}
+	} else if (state->interface != PHY_INTERFACE_MODE_NA &&
+		   state->interface != PHY_INTERFACE_MODE_QSGMII &&
+		   state->interface != PHY_INTERFACE_MODE_SGMII &&
+		   !phy_interface_mode_is_rgmii(state->interface)) {
 		bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
 		return;
 	}