Please explain what you're trying to do in detail. There should be no need to 
ever do something like that.

Vlib_buffer_t's are embedded in private headroom space, tangent to the packet 
DMA target [which starts at (struct mbuf *)mb->data_off].

Here's how we create the mempools:

  rmp = rte_pktmbuf_pool_create ((char *) pool_name,   /* pool name */
                      num_mbufs,     /* number of mbufs */
                      512, /* cache size */
                      VLIB_BUFFER_HDR_SIZE,     /* priv size */
                      VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE,     /* 
dataroom size */
                      socket_id);    /* cpu socket */

As Chris wrote, b0->data is an array, not a pointer:

  u8 data[0]; /**< Packet data. Hardware DMA here */

Thanks... Dave

From: vpp-dev-boun...@lists.fd.io [mailto:vpp-dev-boun...@lists.fd.io] On 
Behalf Of Luke, Chris
Sent: Tuesday, February 28, 2017 7:15 AM
To: Li, Rujun <rujun...@intel.com>; vpp-dev@lists.fd.io
Subject: Re: [vpp-dev] wrong when i want to change vlib_buffer_t->data to my 
pointer

Look at the definition of 'data' in the .h or in the docs: 
https://docs.fd.io/vpp/17.04/dd/d10/structvlib__buffer__t.html

It's not a pointer, ergo you cannot do this. That is not how the buffer 
mechanism works.

Chris.

From: vpp-dev-boun...@lists.fd.io<mailto:vpp-dev-boun...@lists.fd.io> 
[mailto:vpp-dev-boun...@lists.fd.io] On Behalf Of Li, Rujun
Sent: Tuesday, February 28, 2017 3:44
To: vpp-dev@lists.fd.io<mailto:vpp-dev@lists.fd.io>
Subject: [vpp-dev] wrong when i want to change vlib_buffer_t->data to my pointer

Hi ,all

Now I am working on VPP and I met a problem. I have a pointer pointing to 
packets receive from my changed DPDK and now I want to change 
vlib_buffer_t->data to my pointer to avoid memory copy, but the errors were 
reported that the vlib_buffer_t->data cannot be used as left value. My code 
looks like:

Uint8_t * pktbuf;
//do assignment to pktbuf
Vlib_buffer_t * b = vlib_get_buffer(vm, tm->rx_buffers[i_rx]);
b->data = pktbuf;

and the error is : error: lvalue required as left operand of assignment
is there is something wrong with my code or vlib_buffer_t is projected from 
assignment?


Best Wishes,
Rujun, Li

_______________________________________________
vpp-dev mailing list
vpp-dev@lists.fd.io
https://lists.fd.io/mailman/listinfo/vpp-dev

Reply via email to