From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by dpdk.org (Postfix) with ESMTP id 8D3CCC36A for ; Wed, 22 Apr 2015 11:57:48 +0200 (CEST) Received: by wiun10 with SMTP id n10so50865753wiu.1 for ; Wed, 22 Apr 2015 02:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ecnecZqGWH/d2KMAFNasex2HFMcQDoRR1Dkc+0mEyYA=; b=Hjw4do7QI/Hs4lA8UW4M2Wu+MzMTvd1W18zcDhe21SUk5WFd/ekrxEdiIg+zIswxSj AcYFU8tgNTWk2lO6Q9nNT5QO08xy3NlxnsqUj065NzNsM7ZvHVTWxgwCSp43+zBniADf sEBNFVAHQgPWt/B9w8PoTbJgm1hBYHeiJDMTlEF1EkLVH+iIDOG8S+FsQIniLRWOwzcE NXJOLiFRC9VyMCjdmupwmu8ImwtYyXNmhbpqlMw3zpbiqeaBPJcEprrSD/zEeW2C4IDX wRMN9OSRzvx/369cEQ0ka7z9owX2d8AF3J4rgE6oMpUI+c17m+pZ8VACITgUX4rYORkr g3SQ== X-Gm-Message-State: ALoCoQkI4ra8Yg7UVaMg1/FzeW9BzjwPbhhUq/OsGV3UOq/bH4FfOr31TCoAMBH9rnWmfRP0zeVN X-Received: by 10.180.84.67 with SMTP id w3mr4523617wiy.68.1429696668472; Wed, 22 Apr 2015 02:57:48 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id yr1sm6570006wjc.37.2015.04.22.02.57.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Apr 2015 02:57:47 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Wed, 22 Apr 2015 11:57:22 +0200 Message-Id: <1429696650-9043-6-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429696650-9043-1-git-send-email-olivier.matz@6wind.com> References: <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> <1429696650-9043-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v6 05/13] testpmd: use standard functions to initialize mbufs and mbuf pool X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2015 09:57:49 -0000 The rte_pktmbuf_pool_init() and rte_pktmbuf_init() functions now support to have a non-hardcoded buffer length. We can remove the specific functions used in testpmd and replace them by the standard ones. Signed-off-by: Olivier Matz Acked-by: Neil Horman --- app/test-pmd/testpmd.c | 74 +++++--------------------------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 10e4347..1f2445e 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -393,83 +393,23 @@ set_def_fwd_config(void) /* * Configuration initialisation done once at init time. */ -struct mbuf_ctor_arg { - uint16_t seg_buf_offset; /**< offset of data in data segment of mbuf. */ - uint16_t seg_buf_size; /**< size of data segment in mbuf. */ -}; - -struct mbuf_pool_ctor_arg { - uint16_t seg_buf_size; /**< size of data segment in mbuf. */ -}; - -static void -testpmd_mbuf_ctor(struct rte_mempool *mp, - void *opaque_arg, - void *raw_mbuf, - __attribute__((unused)) unsigned i) -{ - struct mbuf_ctor_arg *mb_ctor_arg; - struct rte_mbuf *mb; - - mb_ctor_arg = (struct mbuf_ctor_arg *) opaque_arg; - mb = (struct rte_mbuf *) raw_mbuf; - - mb->pool = mp; - mb->buf_addr = (void *) ((char *)mb + mb_ctor_arg->seg_buf_offset); - mb->buf_physaddr = (uint64_t) (rte_mempool_virt2phy(mp, mb) + - mb_ctor_arg->seg_buf_offset); - mb->buf_len = mb_ctor_arg->seg_buf_size; - mb->ol_flags = 0; - mb->data_off = RTE_PKTMBUF_HEADROOM; - mb->nb_segs = 1; - mb->tx_offload = 0; - mb->vlan_tci = 0; - mb->hash.rss = 0; -} - -static void -testpmd_mbuf_pool_ctor(struct rte_mempool *mp, - void *opaque_arg) -{ - struct mbuf_pool_ctor_arg *mbp_ctor_arg; - struct rte_pktmbuf_pool_private *mbp_priv; - - if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) { - printf("%s(%s) private_data_size %d < %d\n", - __func__, mp->name, (int) mp->private_data_size, - (int) sizeof(struct rte_pktmbuf_pool_private)); - return; - } - mbp_ctor_arg = (struct mbuf_pool_ctor_arg *) opaque_arg; - mbp_priv = rte_mempool_get_priv(mp); - mbp_priv->mbuf_data_room_size = mbp_ctor_arg->seg_buf_size; - mbp_priv->mbuf_priv_size = 0; -} - static void mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, unsigned int socket_id) { char pool_name[RTE_MEMPOOL_NAMESIZE]; struct rte_mempool *rte_mp; - struct mbuf_pool_ctor_arg mbp_ctor_arg; - struct mbuf_ctor_arg mb_ctor_arg; uint32_t mb_size; - mbp_ctor_arg.seg_buf_size = (uint16_t) (RTE_PKTMBUF_HEADROOM + - mbuf_seg_size); - mb_ctor_arg.seg_buf_offset = - (uint16_t) RTE_CACHE_LINE_ROUNDUP(sizeof(struct rte_mbuf)); - mb_ctor_arg.seg_buf_size = mbp_ctor_arg.seg_buf_size; - mb_size = mb_ctor_arg.seg_buf_offset + mb_ctor_arg.seg_buf_size; + mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size; mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name)); #ifdef RTE_LIBRTE_PMD_XENVIRT rte_mp = rte_mempool_gntalloc_create(pool_name, nb_mbuf, mb_size, (unsigned) mb_mempool_cache, sizeof(struct rte_pktmbuf_pool_private), - testpmd_mbuf_pool_ctor, &mbp_ctor_arg, - testpmd_mbuf_ctor, &mb_ctor_arg, + rte_pktmbuf_pool_init, NULL, + rte_pktmbuf_init, NULL, socket_id, 0); @@ -479,15 +419,15 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, rte_mp = mempool_anon_create(pool_name, nb_mbuf, mb_size, (unsigned) mb_mempool_cache, sizeof(struct rte_pktmbuf_pool_private), - testpmd_mbuf_pool_ctor, &mbp_ctor_arg, - testpmd_mbuf_ctor, &mb_ctor_arg, + rte_pktmbuf_pool_init, NULL, + rte_pktmbuf_init, NULL, socket_id, 0); else rte_mp = rte_mempool_create(pool_name, nb_mbuf, mb_size, (unsigned) mb_mempool_cache, sizeof(struct rte_pktmbuf_pool_private), - testpmd_mbuf_pool_ctor, &mbp_ctor_arg, - testpmd_mbuf_ctor, &mb_ctor_arg, + rte_pktmbuf_pool_init, NULL, + rte_pktmbuf_init, NULL, socket_id, 0); #endif -- 2.1.4