From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by dpdk.org (Postfix) with ESMTP id 0FD27C314 for ; Tue, 21 Apr 2015 11:55:50 +0200 (CEST) Received: by wizk4 with SMTP id k4so132504873wiz.1 for ; Tue, 21 Apr 2015 02:55:50 -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=q27S16ZqjaV1eJG+0C/JYG36YAE7bT7Fdg3Ve0J3iok=; b=ZMCKzIZEW2UOYIzTMuazxJhB65Nafmajhse8uzBWxQUPkns3MDYe90ohtJjj3dX6d+ epmxCtbUCMhGImM3uO8C4nQ12/at2xaEMcItmsMjDP4DWdWuyRj8trEGgmIgbAFF8IAV GNrMn0iiFeco7qVV4BK0bl6XsHjeGQ2b7ido3fEQNIS/9cumaPiLhMc6EUU5KTrkUJFS EfwLtzBAHkJVi7w++JK3NCPcvaVHLXdIYx67Wxws/ny2l9P18mB0kchp9XG5wSewimcI A0pScjMS1StuDDHQOYxhrNl6gAB/fSA1DTbs1wnqV8FM4Xthx6BRXhh4N0T9Af6Alv2+ uhLA== X-Gm-Message-State: ALoCoQknVwP2zGSs4qRLKxd1xQaCIFz91oIVjcZZ7yXKPpB/djKqIIholzGpZ21+huriYWs0ZTDW X-Received: by 10.181.11.137 with SMTP id ei9mr4135594wid.48.1429610149920; Tue, 21 Apr 2015 02:55:49 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id i6sm1855867wjf.29.2015.04.21.02.55.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Apr 2015 02:55:48 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Tue, 21 Apr 2015 11:55:15 +0200 Message-Id: <1429610122-30943-6-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> References: <1429544496-22532-1-git-send-email-olivier.matz@6wind.com> <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v5 05/12] 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: Tue, 21 Apr 2015 09:55:50 -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 --- 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