patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Jiawen Wu <jiawenwu@trustnetic.com>
To: dev@dpdk.org
Cc: Jiawen Wu <jiawenwu@trustnetic.com>, stable@dpdk.org
Subject: [PATCH 4/9] net/txgbe: fix to set autoneg for 1G speed
Date: Wed, 14 Jun 2023 10:34:24 +0800	[thread overview]
Message-ID: <20230614023429.1002071-5-jiawenwu@trustnetic.com> (raw)
In-Reply-To: <20230614023429.1002071-1-jiawenwu@trustnetic.com>

Autoneg was always on for 1G speed, fix to set autoneg off.

Fixes: 01c3cf5c85a7 ("net/txgbe: add autoneg control read and write")
Fixes: e4c515a7bc7e ("net/txgbe: add multi-speed link setup")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/base/txgbe_hw.c   | 14 ++++++++++++++
 drivers/net/txgbe/base/txgbe_phy.c  |  4 +++-
 drivers/net/txgbe/base/txgbe_type.h |  1 +
 drivers/net/txgbe/txgbe_ethdev.c    |  2 ++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c
index 2952c408fd..d19fd0065d 100644
--- a/drivers/net/txgbe/base/txgbe_hw.c
+++ b/drivers/net/txgbe/base/txgbe_hw.c
@@ -2273,10 +2273,24 @@ s32 txgbe_setup_mac_link_multispeed_fiber(struct txgbe_hw *hw,
 	}
 
 	if (speed & TXGBE_LINK_SPEED_1GB_FULL) {
+		u32 curr_autoneg;
+
 		speedcnt++;
 		if (highest_link_speed == TXGBE_LINK_SPEED_UNKNOWN)
 			highest_link_speed = TXGBE_LINK_SPEED_1GB_FULL;
 
+		status = hw->mac.check_link(hw, &link_speed, &link_up, false);
+		if (status != 0)
+			return status;
+
+		/* If we already have link at this speed, just jump out */
+		if (link_speed == TXGBE_LINK_SPEED_1GB_FULL) {
+			curr_autoneg = rd32_epcs(hw, SR_MII_MMD_CTL);
+			if (link_up && (hw->autoneg ==
+					!!(curr_autoneg & SR_MII_MMD_CTL_AN_EN)))
+				goto out;
+		}
+
 		/* Set the module link speed */
 		switch (hw->phy.media_type) {
 		case txgbe_media_type_fiber:
diff --git a/drivers/net/txgbe/base/txgbe_phy.c b/drivers/net/txgbe/base/txgbe_phy.c
index 1eb45b068a..d87af656d5 100644
--- a/drivers/net/txgbe/base/txgbe_phy.c
+++ b/drivers/net/txgbe/base/txgbe_phy.c
@@ -1402,7 +1402,9 @@ txgbe_set_sgmii_an37_ability(struct txgbe_hw *hw)
 		wr32_epcs(hw, SR_MII_MMD_AN_CTL, 0x0105);
 	wr32_epcs(hw, SR_MII_MMD_DIGI_CTL, 0x0200);
 	value = rd32_epcs(hw, SR_MII_MMD_CTL);
-	value = (value & ~0x1200) | (0x1 << 12) | (0x1 << 9);
+	value = (value & ~0x1200) | (0x1 << 9);
+	if (hw->autoneg)
+		value |= SR_MII_MMD_CTL_AN_EN;
 	wr32_epcs(hw, SR_MII_MMD_CTL, value);
 }
 
diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h
index c3486b472f..75e839b7de 100644
--- a/drivers/net/txgbe/base/txgbe_type.h
+++ b/drivers/net/txgbe/base/txgbe_type.h
@@ -783,6 +783,7 @@ struct txgbe_hw {
 	bool allow_unsupported_sfp;
 	bool need_crosstalk_fix;
 	bool dev_start;
+	bool autoneg;
 	struct txgbe_devargs devarg;
 
 	uint64_t isb_dma;
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 36c74d353d..962667acdc 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -1821,6 +1821,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
 		speed = (TXGBE_LINK_SPEED_100M_FULL |
 			 TXGBE_LINK_SPEED_1GB_FULL |
 			 TXGBE_LINK_SPEED_10GB_FULL);
+		hw->autoneg = true;
 	} else {
 		if (*link_speeds & RTE_ETH_LINK_SPEED_10G)
 			speed |= TXGBE_LINK_SPEED_10GB_FULL;
@@ -1832,6 +1833,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
 			speed |= TXGBE_LINK_SPEED_1GB_FULL;
 		if (*link_speeds & RTE_ETH_LINK_SPEED_100M)
 			speed |= TXGBE_LINK_SPEED_100M_FULL;
+		hw->autoneg = false;
 	}
 
 	err = hw->mac.setup_link(hw, speed, link_up);
-- 
2.27.0


  parent reply	other threads:[~2023-06-14  2:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230614023429.1002071-1-jiawenwu@trustnetic.com>
2023-06-14  2:34 ` [PATCH 1/9] net/txgbe: fix Tx failure with fiber hotplug Jiawen Wu
2023-06-14  2:34 ` [PATCH 2/9] net/txgbe: fix interrupt enable mask Jiawen Wu
2023-06-14  2:34 ` [PATCH 3/9] net/txgbe: fix issues caused by MNG veto bit setting Jiawen Wu
2023-06-14  2:34 ` Jiawen Wu [this message]
2023-06-14  2:34 ` [PATCH 5/9] net/txgbe: fix device extended stats Jiawen Wu
2023-06-14  2:34 ` [PATCH 6/9] net/ngbe: " Jiawen Wu
2023-06-14  2:34 ` [PATCH 7/9] net/ngbe: fix issues caused by MNG veto bit setting Jiawen Wu
2023-06-14  2:34 ` [PATCH 8/9] net/ngbe: fix link status in no LSC mode Jiawen Wu
2023-06-14  2:34 ` [PATCH 9/9] net/ngbe: remove redundant codes Jiawen Wu

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=20230614023429.1002071-5-jiawenwu@trustnetic.com \
    --to=jiawenwu@trustnetic.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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).