From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 8C1935A52 for ; Tue, 21 Apr 2015 17:08:52 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 21 Apr 2015 08:07:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,616,1422950400"; d="scan'208";a="698610674" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga001.fm.intel.com with ESMTP; 21 Apr 2015 08:07:52 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.178]) by irsmsx110.ger.corp.intel.com ([169.254.15.83]) with mapi id 14.03.0224.002; Tue, 21 Apr 2015 16:07:51 +0100 From: "Ananyev, Konstantin" To: Olivier Matz , "dev@dpdk.org" Thread-Topic: [PATCH v5 04/12] mbuf: fix rte_pktmbuf_init when mbuf private size is not zero Thread-Index: AQHQfBla1GOsJ1eyb06CLiOS/Krp/51XkXag Date: Tue, 21 Apr 2015 15:07:50 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725821420981@irsmsx105.ger.corp.intel.com> References: <1429544496-22532-1-git-send-email-olivier.matz@6wind.com> <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> <1429610122-30943-5-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1429610122-30943-5-git-send-email-olivier.matz@6wind.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 15:08:53 -0000 > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Tuesday, April 21, 2015 10:55 AM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; zoltan.kiss@linaro.org; Richardson, Bruce; nhorm= an@tuxdriver.com; olivier.matz@6wind.com > Subject: [PATCH v5 04/12] mbuf: fix rte_pktmbuf_init when mbuf private si= ze is not zero >=20 > Allow the user to use the default rte_pktmbuf_init() function even > if the mbuf private size is not 0. >=20 > Signed-off-by: Olivier Matz > --- > lib/librte_mbuf/rte_mbuf.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) >=20 > 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 =3D _m; > - uint32_t buf_len =3D mp->elt_size - sizeof(struct rte_mbuf); > + uint32_t mbuf_size, buf_len; >=20 > - RTE_MBUF_ASSERT(mp->elt_size >=3D sizeof(struct rte_mbuf)); > + mbuf_size =3D sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); > + buf_len =3D rte_pktmbuf_data_room_size(mp); > + > + RTE_MBUF_ASSERT(mp->elt_size >=3D mbuf_size); > + RTE_MBUF_ASSERT(buf_len <=3D 0xffff); As a nit: s/0xfff/UINT16_MAX/. Konstantin >=20 > memset(m, 0, mp->elt_size); >=20 > /* start of buffer is just after mbuf structure */ > - m->buf_addr =3D (char *)m + sizeof(struct rte_mbuf); > - m->buf_physaddr =3D rte_mempool_virt2phy(mp, m) + > - sizeof(struct rte_mbuf); > + m->buf_addr =3D (char *)m + mbuf_size; > + m->buf_physaddr =3D rte_mempool_virt2phy(mp, m) + mbuf_size; > m->buf_len =3D (uint16_t)buf_len; >=20 > /* keep some headroom between start of buffer and data */ > -- > 2.1.4