[v2] net/af_xdp: fix zero copy Tx queue drain

Message ID 8a03128cb9edeeaa747f74aca60d6a8b9f5c4f8e.1629885944.git.baruch@tkos.co.il (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/af_xdp: fix zero copy Tx queue drain |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing fail Testing issues

Commit Message

Baruch Siach Aug. 25, 2021, 10:05 a.m. UTC
  Call xsk_ring_prod__submit() before kick_tx() so that the kernel
consumer sees the updated state of Tx ring. Otherwise, Tx packets are
stuck in the ring until the next call to af_xdp_tx_zc().

Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
Cc: stable@dpdk.org

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
--
v2:

  Don't call xsk_ring_prod__submit() when kick_tx() is only used to
  drain the completion queue (Ciara Loftus)
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Loftus, Ciara Aug. 25, 2021, 10:48 a.m. UTC | #1
> 
> Call xsk_ring_prod__submit() before kick_tx() so that the kernel
> consumer sees the updated state of Tx ring. Otherwise, Tx packets are
> stuck in the ring until the next call to af_xdp_tx_zc().
> 
> Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Thanks for respinning. I tested it out and it looks good to me.

Acked-by: Ciara Loftus <ciara.loftus@intel.com>

> --
> v2:
> 
>   Don't call xsk_ring_prod__submit() when kick_tx() is only used to
>   drain the completion queue (Ciara Loftus)
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 74ffa4511284..9bea0a895a3e 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -527,7 +527,6 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs,
> uint16_t nb_pkts)
> 
>  			if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx)) {
>  				rte_pktmbuf_free(local_mbuf);
> -				kick_tx(txq, cq);
>  				goto out;
>  			}
> 
> @@ -551,10 +550,9 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs,
> uint16_t nb_pkts)
>  		tx_bytes += mbuf->pkt_len;
>  	}
> 
> -	kick_tx(txq, cq);
> -
>  out:
>  	xsk_ring_prod__submit(&txq->tx, count);
> +	kick_tx(txq, cq);
> 
>  	txq->stats.tx_pkts += count;
>  	txq->stats.tx_bytes += tx_bytes;
> --
> 2.32.0
  
Ferruh Yigit Sept. 7, 2021, 3:56 p.m. UTC | #2
On 8/25/2021 11:48 AM, Loftus, Ciara wrote:
>>
>> Call xsk_ring_prod__submit() before kick_tx() so that the kernel
>> consumer sees the updated state of Tx ring. Otherwise, Tx packets are
>> stuck in the ring until the next call to af_xdp_tx_zc().
>>
>> Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> 
> Thanks for respinning. I tested it out and it looks good to me.
> 
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 74ffa4511284..9bea0a895a3e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -527,7 +527,6 @@  af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 			if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx)) {
 				rte_pktmbuf_free(local_mbuf);
-				kick_tx(txq, cq);
 				goto out;
 			}
 
@@ -551,10 +550,9 @@  af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		tx_bytes += mbuf->pkt_len;
 	}
 
-	kick_tx(txq, cq);
-
 out:
 	xsk_ring_prod__submit(&txq->tx, count);
+	kick_tx(txq, cq);
 
 	txq->stats.tx_pkts += count;
 	txq->stats.tx_bytes += tx_bytes;