patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/af_xdp: fix umem size
@ 2020-09-10  9:06 Ciara Loftus
  2020-09-18 17:29 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Ciara Loftus @ 2020-09-10  9:06 UTC (permalink / raw)
  To: dev; +Cc: Ciara Loftus, stable

The kernel expects the start address of the UMEM to be page size aligned.
Since the mempool is not guaranteed to have such alignment, we have been
aligning the address to the start of the page the mempool is on. However
when passing the 'size' of the UMEM during it's creation we did not take
this into account. This commit adds the amount by which the address was
aligned to the size of the UMEM.

Bugzilla ID: 532
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 | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 936d4a7d5f..22f2710e53 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -746,12 +746,17 @@ eth_link_update(struct rte_eth_dev *dev __rte_unused,
 }
 
 #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
-static inline uint64_t get_base_addr(struct rte_mempool *mp)
+static inline uint64_t get_base_addr(struct rte_mempool *mp, uint64_t *align)
 {
 	struct rte_mempool_memhdr *memhdr;
+	uint64_t memhdr_addr, aligned_addr;
 
 	memhdr = STAILQ_FIRST(&mp->mem_list);
-	return (uint64_t)memhdr->addr & ~(getpagesize() - 1);
+	memhdr_addr = (uint64_t)memhdr->addr;
+	aligned_addr = memhdr_addr & ~(getpagesize() - 1);
+	*align = memhdr_addr - aligned_addr;
+
+	return aligned_addr;
 }
 
 static struct
@@ -766,6 +771,7 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals __rte_unused,
 		.flags = XDP_UMEM_UNALIGNED_CHUNK_FLAG};
 	void *base_addr = NULL;
 	struct rte_mempool *mb_pool = rxq->mb_pool;
+	uint64_t umem_size, align = 0;
 
 	usr_config.frame_size = rte_mempool_calc_obj_size(mb_pool->elt_size,
 								mb_pool->flags,
@@ -782,12 +788,11 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals __rte_unused,
 	}
 
 	umem->mb_pool = mb_pool;
-	base_addr = (void *)get_base_addr(mb_pool);
+	base_addr = (void *)get_base_addr(mb_pool, &align);
+	umem_size = mb_pool->populated_size * usr_config.frame_size + align;
 
-	ret = xsk_umem__create(&umem->umem, base_addr,
-			       mb_pool->populated_size * usr_config.frame_size,
-			       &umem->fq, &umem->cq,
-			       &usr_config);
+	ret = xsk_umem__create(&umem->umem, base_addr, umem_size,
+			       &umem->fq, &umem->cq, &usr_config);
 
 	if (ret) {
 		AF_XDP_LOG(ERR, "Failed to create umem");
-- 
2.17.1


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

* Re: [dpdk-stable] [PATCH] net/af_xdp: fix umem size
  2020-09-10  9:06 [dpdk-stable] [PATCH] net/af_xdp: fix umem size Ciara Loftus
@ 2020-09-18 17:29 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2020-09-18 17:29 UTC (permalink / raw)
  To: Ciara Loftus, dev; +Cc: stable

On 9/10/2020 10:06 AM, Ciara Loftus wrote:
> The kernel expects the start address of the UMEM to be page size aligned.
> Since the mempool is not guaranteed to have such alignment, we have been
> aligning the address to the start of the page the mempool is on. However
> when passing the 'size' of the UMEM during it's creation we did not take
> this into account. This commit adds the amount by which the address was
> aligned to the size of the UMEM.
> 
> Bugzilla ID: 532
> Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

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


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

end of thread, other threads:[~2020-09-18 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10  9:06 [dpdk-stable] [PATCH] net/af_xdp: fix umem size Ciara Loftus
2020-09-18 17:29 ` Ferruh Yigit

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