DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ye Xiaolong <xiaolong.ye@intel.com>
To: Ciara Loftus <ciara.loftus@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3 2/3] net/af_xdp: use correct fill queue addresses
Date: Thu, 13 Feb 2020 11:09:17 +0800	[thread overview]
Message-ID: <20200213030917.GP80720@intel.com> (raw)
In-Reply-To: <20200210114009.49590-3-ciara.loftus@intel.com>

On 02/10, Ciara Loftus wrote:
>The fill queue addresses should start at the beginning of the mempool
>object instead of the beginning of the mbuf. This is because the umem
>frame headroom includes the mp hdrobj size. Starting at this point
>ensures AF_XDP doesn't write past the available room in the frame, in
>the case of larger packets which are close to the size of the mbuf.
>
>Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
>Cc: stable@dpdk.org
>
>Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
>---
> drivers/net/af_xdp/rte_eth_af_xdp.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
>index 8b189119c..1e98cd44f 100644
>--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
>+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
>@@ -172,7 +172,8 @@ reserve_fill_queue_zc(struct xsk_umem_info *umem, uint16_t reserve_size,
> 		uint64_t addr;
> 
> 		fq_addr = xsk_ring_prod__fill_addr(fq, idx++);
>-		addr = (uint64_t)bufs[i] - (uint64_t)umem->buffer;
>+		addr = (uint64_t)bufs[i] - (uint64_t)umem->buffer -
>+				umem->mb_pool->header_size;
> 		*fq_addr = addr;
> 	}
> 
>@@ -271,8 +272,11 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
> 		addr = xsk_umem__extract_addr(addr);
> 
> 		bufs[i] = (struct rte_mbuf *)
>-				xsk_umem__get_data(umem->buffer, addr);
>-		bufs[i]->data_off = offset - sizeof(struct rte_mbuf);
>+				xsk_umem__get_data(umem->buffer, addr +
>+					umem->mb_pool->header_size);
>+		bufs[i]->data_off = offset - sizeof(struct rte_mbuf) -
>+			rte_pktmbuf_priv_size(umem->mb_pool) -
>+			umem->mb_pool->header_size;
> 
> 		rte_pktmbuf_pkt_len(bufs[i]) = len;
> 		rte_pktmbuf_data_len(bufs[i]) = len;
>@@ -385,7 +389,8 @@ pull_umem_cq(struct xsk_umem_info *umem, int size)
> #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
> 		addr = xsk_umem__extract_addr(addr);
> 		rte_pktmbuf_free((struct rte_mbuf *)
>-					xsk_umem__get_data(umem->buffer, addr));
>+					xsk_umem__get_data(umem->buffer,
>+					addr + umem->mb_pool->header_size));
> #else
> 		rte_ring_enqueue(umem->buf_ring, (void *)addr);
> #endif
>@@ -443,9 +448,11 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
> 			}
> 			desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
> 			desc->len = mbuf->pkt_len;
>-			addr = (uint64_t)mbuf - (uint64_t)umem->buffer;
>+			addr = (uint64_t)mbuf - (uint64_t)umem->buffer -
>+					umem->mb_pool->header_size;
> 			offset = rte_pktmbuf_mtod(mbuf, uint64_t) -
>-					(uint64_t)mbuf;
>+					(uint64_t)mbuf +
>+					umem->mb_pool->header_size;
> 			offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
> 			desc->addr = addr | offset;
> 			count++;
>@@ -466,9 +473,11 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
> 			desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
> 			desc->len = mbuf->pkt_len;
> 
>-			addr = (uint64_t)local_mbuf - (uint64_t)umem->buffer;
>+			addr = (uint64_t)local_mbuf - (uint64_t)umem->buffer -
>+					umem->mb_pool->header_size;
> 			offset = rte_pktmbuf_mtod(local_mbuf, uint64_t) -
>-					(uint64_t)local_mbuf;
>+					(uint64_t)local_mbuf +
>+					umem->mb_pool->header_size;
> 			pkt = xsk_umem__get_data(umem->buffer, addr + offset);
> 			offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
> 			desc->addr = addr | offset;
>-- 
>2.17.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

  reply	other threads:[~2020-02-13  3:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 11:40 [dpdk-dev] [PATCH v3 0/3] AF_XDP PMD Fixes Ciara Loftus
2020-02-10 11:40 ` [dpdk-dev] [PATCH v3 1/3] net/af_xdp: fix umem frame size & headroom calculations Ciara Loftus
2020-02-13  2:45   ` Ye Xiaolong
2020-02-10 11:40 ` [dpdk-dev] [PATCH v3 2/3] net/af_xdp: use correct fill queue addresses Ciara Loftus
2020-02-13  3:09   ` Ye Xiaolong [this message]
2020-02-10 11:40 ` [dpdk-dev] [PATCH v3 3/3] net/af_xdp: fix maximum MTU value Ciara Loftus
2020-02-13  3:05   ` Ye Xiaolong
2020-02-13  8:43     ` Loftus, Ciara

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=20200213030917.GP80720@intel.com \
    --to=xiaolong.ye@intel.com \
    --cc=ciara.loftus@intel.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).