From: vmukunda <vmukunda@marvell.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Sunil Goutham <sgoutham@marvell.com>,
Ratheesh Kannoth <rkannoth@marvell.com>,
Geetha sowjanya <gakula@marvell.com>,
"Subbaraya Sundeep" <sbhatta@marvell.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
"Naveen Mamindlapalli" <naveenm@marvell.com>,
vmukunda <vmukunda@marvell.com>
Subject: [PATCH] octeontx2-af: fix TX hang after link mode change under traffic
Date: Thu, 29 Oct 2026 07:46:35 +0000 [thread overview]
Message-ID: <20261029074635.4139111-1-vmukunda@marvell.com> (raw)
From: Naveen Mamindlapalli <naveenm@marvell.com>
During a CGX/RPM link mode change while traffic is running, the link
state is disabled and the TX link credits go negative. Once the link is
active again the credits are not restored, which leads to a TX hang.
Set TL1 SW_XOFF before the link mode change and poll until the TX link
credits return to their original value. Clear TL1 SW_XOFF after the
change, including when it fails, so that a failed request does not leave
the link stopped. A timeout in the credit poll is only reported with a
warning, and the link mode change still proceeds.
Fixes: 62945033ea22 ("octeontx2-af: poll for tx link credits before link mode change")
Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
Signed-off-by: vmukunda <vmukunda@marvell.com>
---
.../net/ethernet/marvell/octeontx2/af/rvu.h | 2 +
.../ethernet/marvell/octeontx2/af/rvu_cgx.c | 5 ++
.../ethernet/marvell/octeontx2/af/rvu_nix.c | 50 +++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 094227404ef9..7fc10d17bde9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -1048,6 +1048,8 @@ int rvu_nix_mcast_get_mce_index(struct rvu *rvu, u16 pcifunc,
u32 mcast_grp_idx);
int rvu_nix_mcast_update_mcam_entry(struct rvu *rvu, u16 pcifunc,
u32 mcast_grp_idx, u16 mcam_index);
+int rvu_nix_tl1_xoff_wait_for_link_credits(struct rvu *rvu, u16 pcifunc);
+int rvu_nix_tl1_xoff_clear(struct rvu *rvu, u16 pcifunc);
void rvu_nix_flr_free_bpids(struct rvu *rvu, u16 pcifunc);
int rvu_alloc_cint_qint_mem(struct rvu *rvu, struct rvu_pfvf *pfvf,
int blkaddr, int nixlf);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index 87d21889dc49..a66abea6e676 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -1235,8 +1235,13 @@ int rvu_mbox_handler_cgx_set_link_mode(struct rvu *rvu,
else
linkmodes = &rvu->fwdata->cgx_fw_data[cgx_idx][lmac];
+ rvu_nix_tl1_xoff_wait_for_link_credits(rvu, req->hdr.pcifunc);
+
rsp->status = cgx_set_link_mode(cgxd, req->args, linkmodes,
cgx_idx, lmac);
+
+ rvu_nix_tl1_xoff_clear(rvu, req->hdr.pcifunc);
+
return 0;
}
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 68cf730a8372..ec51a3911da6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -6749,3 +6749,53 @@ void rvu_block_bcast_xon(struct rvu *rvu, int blkaddr)
cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(0));
rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(0), cfg);
}
+
+int rvu_nix_tl1_xoff_wait_for_link_credits(struct rvu *rvu, u16 pcifunc)
+{
+ int link, blkaddr, count = 1000;
+ u64 tx_credits, regval;
+ struct nix_hw *nix_hw;
+
+ blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
+ if (blkaddr < 0)
+ return NIX_AF_ERR_AF_LF_INVALID;
+
+ nix_hw = get_nix_hw(rvu->hw, blkaddr);
+ if (!nix_hw)
+ return NIX_AF_ERR_INVALID_NIXBLK;
+
+ /* set TL1 sw_xoff */
+ link = nix_get_tx_link(rvu, pcifunc);
+ rvu_write64(rvu, blkaddr, NIX_AF_TL1X_SW_XOFF(link), 1);
+
+ /* wait for link credits to return */
+ tx_credits = nix_hw->tx_credits[link];
+ while (1) {
+ regval = rvu_read64(rvu, blkaddr,
+ NIX_AF_TX_LINKX_NORM_CREDIT(link));
+ if (((regval >> 12) & 0xFFFFF) == tx_credits)
+ break;
+ count--;
+ if (!count) {
+ dev_info(rvu->dev, "TX link(%d) credit poll timeout, expected=%lld credits=%lld\n",
+ link, tx_credits, ((regval >> 12) & 0xFFFFF));
+ return -ETIMEDOUT;
+ }
+ cpu_relax();
+ udelay(1);
+ }
+ return 0;
+}
+
+int rvu_nix_tl1_xoff_clear(struct rvu *rvu, u16 pcifunc)
+{
+ int blkaddr;
+
+ blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
+ if (blkaddr < 0)
+ return NIX_AF_ERR_AF_LF_INVALID;
+
+ nix_clear_tx_xoff(rvu, blkaddr, NIX_TXSCH_LVL_TL1,
+ nix_get_tx_link(rvu, pcifunc));
+ return 0;
+}
--
2.25.1
next reply other threads:[~2026-10-29 7:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 7:46 vmukunda [this message]
2026-10-29 7:50 ` [PATCH] octeontx2-af: fix TX hang after link mode change under traffic netdev-bot+sinfo
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=20261029074635.4139111-1-vmukunda@marvell.com \
--to=vmukunda@marvell.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gakula@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naveenm@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.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