patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3
@ 2023-11-08  2:19 Chaoyong He
  2023-11-23 10:47 ` Kevin Traynor
  0 siblings, 1 reply; 3+ messages in thread
From: Chaoyong He @ 2023-11-08  2:19 UTC (permalink / raw)
  To: stable; +Cc: oss-drivers, Chaoyong He

[ upstream commit e97738919c2315e07c2e98b6a9cc3912c335364a ]

In the Tx descriptor free logic of nfd3, the former logic might force
cast a negative number into a very big unsigned number, and which will
cause potential problem in the xmit loop.

The xmit loop will continue in the place where it should break, and will
overwrite the Tx descriptor which is not free to use by the PMD.

Fixes: 74a640dac864 ("net/nfp: avoid modulo operations for handling ring wrapping")

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_rxtx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 639c1c925b..4fa608d417 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -796,10 +796,14 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 static inline
 uint32_t nfp_free_tx_desc(struct nfp_net_txq *txq)
 {
+	uint32_t free_desc;
+
 	if (txq->wr_p >= txq->rd_p)
-		return txq->tx_count - (txq->wr_p - txq->rd_p) - 8;
+		free_desc = txq->tx_count - (txq->wr_p - txq->rd_p);
 	else
-		return txq->rd_p - txq->wr_p - 8;
+		free_desc = txq->rd_p - txq->wr_p - 8;
+
+	return (free_desc > 8) ? (free_desc - 8) : 0;
 }
 
 /*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3
  2023-11-08  2:19 [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3 Chaoyong He
@ 2023-11-23 10:47 ` Kevin Traynor
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Traynor @ 2023-11-23 10:47 UTC (permalink / raw)
  To: Chaoyong He, stable; +Cc: oss-drivers

On 08/11/2023 02:19, Chaoyong He wrote:
> [ upstream commit e97738919c2315e07c2e98b6a9cc3912c335364a ]
> 
> In the Tx descriptor free logic of nfd3, the former logic might force
> cast a negative number into a very big unsigned number, and which will
> cause potential problem in the xmit loop.
> 
> The xmit loop will continue in the place where it should break, and will
> overwrite the Tx descriptor which is not free to use by the PMD.
> 
> Fixes: 74a640dac864 ("net/nfp: avoid modulo operations for handling ring wrapping")
> 
> Signed-off-by: Chaoyong He<chaoyong.he@corigine.com>
> ---
>   drivers/net/nfp/nfp_rxtx.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)

Applied to 21.11 branch. Thanks for backporting.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3
  2023-07-25  6:51 [PATCH 21.11] net/nfp: fix offloading flows Chaoyong He
@ 2023-07-25  6:51 ` Chaoyong He
  0 siblings, 0 replies; 3+ messages in thread
From: Chaoyong He @ 2023-07-25  6:51 UTC (permalink / raw)
  To: stable; +Cc: oss-drivers, niklas.soderlund, Chaoyong He

[upstream commit e97738919c2315e07c2e98b6a9cc3912c335364a ]

In the Tx descriptor free logic of nfd3, the former logic might force
cast a negative number into a very big unsigned number, and which will
cause potential problem in the xmit loop.

The xmit loop will continue in the place where it should break, and will
overwrite the Tx descriptor which is not free to use by the PMD.

Fixes: 74a640dac864 ("net/nfp: avoid modulo operations for handling ring wrapping")
Cc: stable@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_rxtx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 639c1c925b..3a20e33217 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -796,10 +796,14 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 static inline
 uint32_t nfp_free_tx_desc(struct nfp_net_txq *txq)
 {
+	uint32_t free_desc;
+
 	if (txq->wr_p >= txq->rd_p)
-		return txq->tx_count - (txq->wr_p - txq->rd_p) - 8;
+		free_desc = txq->tx_count - (txq->wr_p - txq->rd_p);
 	else
-		return txq->rd_p - txq->wr_p - 8;
+		free_desc = txq->rd_p - txq->wr_p;
+
+	return (free_desc > 8) ? (free_desc - 8) : 0;
 }
 
 /*
-- 
2.39.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-23 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08  2:19 [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3 Chaoyong He
2023-11-23 10:47 ` Kevin Traynor
  -- strict thread matches above, loose matches on Subject: below --
2023-07-25  6:51 [PATCH 21.11] net/nfp: fix offloading flows Chaoyong He
2023-07-25  6:51 ` [PATCH 21.11] net/nfp: fix Tx descriptor free logic of NFD3 Chaoyong He

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).