From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 1236EC300 for ; Tue, 21 Apr 2015 11:55:49 +0200 (CEST) Received: by wgso17 with SMTP id o17so207800178wgs.1 for ; Tue, 21 Apr 2015 02:55: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=LvpzTp47HSI1t+o2lJ4tP1vjCeMeaV+SLTO/PrBL5ok=; b=Tuj3oDxDkXOgdzrqZrSIgg/2+vipXmEYKAD+xjgec4QavGrDsnsLFD7/6+nEMqD/9B 18P4+b6XeYUOBeob+yWaOUb9NTbsvDL5P8QXW6YbaBIHJ24ixgDHbSKICRNAS5ppjTwR +8vQyobkVEHl+XxawWowc5CeAXYcEv57mOPlIFHWGeBsriKlSuEpt2A/IRpEP1i381jq C+NLvBSXgr1zeUe9Lody7E2wkIzV8WY+UVeuCZJHVR+j85yZd2mDDbnOoi8E1RnpqMTy qI2C+NiNfW83yUkY8u7njbDE4tf3rnjNg5nBHPrcycN4oySkO/EjGRRhpp+YYTZL8/We CQZg== X-Gm-Message-State: ALoCoQnNIfn/H2QVHk4iEG1rk8bqHwwBIcXAHbnTAL1WIwy+9YZyfdZkG2qwTAwtr17G6nh3rMCO X-Received: by 10.194.77.230 with SMTP id v6mr40158716wjw.25.1429610148431; Tue, 21 Apr 2015 02:55:48 -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.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Apr 2015 02:55:47 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Tue, 21 Apr 2015 11:55:14 +0200 Message-Id: <1429610122-30943-5-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 04/12] 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: Tue, 21 Apr 2015 09:55:49 -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 --- 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..d7f0380 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 <= 0xffff); 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