From patchwork Thu Sep 10 09:06:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Loftus, Ciara" X-Patchwork-Id: 77134 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29457A04B5; Thu, 10 Sep 2020 11:31:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0196C1BFA2; Thu, 10 Sep 2020 11:31:26 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E557B1DB8; Thu, 10 Sep 2020 11:31:23 +0200 (CEST) IronPort-SDR: C4vscvMmRb8/xtRw4SXnp58+Ty7N8IfNM9UriZ3z7apBdoNcpSJVWb91vC0LxsGdh9trzTX4Im MyPeKYA8Hj+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="222698849" X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="222698849" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 02:31:22 -0700 IronPort-SDR: RKNKpsJu9LjaTVYP5Xw9B2ZoBVQgnucxdztdx247vW65LS75HpK9nhHk7Al1XWS0+REt3tYboQ epTdgoZpdPcw== X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="286511955" Received: from silpixa00399839.ir.intel.com (HELO localhost.localdomain) ([10.237.222.142]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 02:31:21 -0700 From: Ciara Loftus To: dev@dpdk.org Cc: Ciara Loftus , stable@dpdk.org Date: Thu, 10 Sep 2020 09:06:47 +0000 Message-Id: <20200910090647.23789-1-ciara.loftus@intel.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/af_xdp: fix umem size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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");