From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id A1E1E9AD8 for ; Wed, 22 Apr 2015 11:57:47 +0200 (CEST) Received: by widdi4 with SMTP id di4so170927434wid.0 for ; Wed, 22 Apr 2015 02:57:47 -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=6BjDlId/41xkhtzm7WqiEHjDelOOLQfJoRHb07Nqems=; b=XEJYJkCWM251BuGMsHbn0ry7mtCKkQmjW7XQq22ngEsAYB9F2hT0Qt0WkSumPxLBHQ yFoDOss//KuBzWLDMYbLTnPuny6mq4qONlsoUCwHeFW6p9g3jSCiVdRgnDUbYmv5+2df 2yK16Im5Z6mtR1EFx2BoVIkOOmtbW0zxre4WOtOZ7uLlid2XtLWWGke+tl6VRYiqbl9h XwFuZunWQUrwP/KDPpzpTKIMCU2QBwq4cauw9r2b9vT1ouDkr8UVIslEJpB0DDlG8hlb mvx1yubVTadNYIz2xF78l1+hVpTUbA+iP4X7+sS72uEozCuFJj5IkPZsfdwtU4xnO3xn lmeg== X-Gm-Message-State: ALoCoQluM0+K8Gkmpzt7+Qrf1+pebLW0OHxzxT1R5cgKbvE/Wt0gmJyuPtRzAxIx/2+is9wVQPZz X-Received: by 10.180.76.231 with SMTP id n7mr4330042wiw.44.1429696667519; Wed, 22 Apr 2015 02:57:47 -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.46 (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:21 +0200 Message-Id: <1429696650-9043-5-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 04/13] mbuf: fix rte_pktmbuf_init when mbuf private size is not zero 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:47 -0000 Allow the user to use the default rte_pktmbuf_init() function even if the mbuf private size is not 0. Signed-off-by: Olivier Matz Acked-by: Neil Horman --- lib/librte_mbuf/rte_mbuf.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 231cfb8..d1f2a6f 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -119,16 +119,19 @@ rte_pktmbuf_init(struct rte_mempool *mp, __attribute__((unused)) unsigned i) { struct rte_mbuf *m = _m; - uint32_t buf_len = mp->elt_size - sizeof(struct rte_mbuf); + uint32_t mbuf_size, buf_len; - RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf)); + mbuf_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); + buf_len = rte_pktmbuf_data_room_size(mp); + + RTE_MBUF_ASSERT(mp->elt_size >= mbuf_size); + RTE_MBUF_ASSERT(buf_len <= UINT16_MAX); memset(m, 0, mp->elt_size); /* start of buffer is just after mbuf structure */ - m->buf_addr = (char *)m + sizeof(struct rte_mbuf); - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + - sizeof(struct rte_mbuf); + m->buf_addr = (char *)m + mbuf_size; + m->buf_physaddr = rte_mempool_virt2phy(mp, m) + mbuf_size; m->buf_len = (uint16_t)buf_len; /* keep some headroom between start of buffer and data */ -- 2.1.4