[dpdk-dev] [PATCH v5 04/12] mbuf: fix rte_pktmbuf_init when mbuf private size is not zero

Ananyev, Konstantin konstantin.ananyev at intel.com
Tue Apr 21 17:07:50 CEST 2015



> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz at 6wind.com]
> Sent: Tuesday, April 21, 2015 10:55 AM
> To: dev at dpdk.org
> Cc: Ananyev, Konstantin; zoltan.kiss at linaro.org; Richardson, Bruce; nhorman at tuxdriver.com; olivier.matz at 6wind.com
> Subject: [PATCH v5 04/12] mbuf: fix rte_pktmbuf_init when mbuf private size is not zero
> 
> 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 <olivier.matz at 6wind.com>
> ---
>  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);

As a nit: s/0xfff/UINT16_MAX/.
Konstantin

> 
>  	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



More information about the dev mailing list