On 06/27/2018 07:55 PM, Saeed Mahameed wrote:
> On Wed, 2018-06-27 at 16:15 +0200, Jesper Dangaard Brouer wrote:
>> On Tue, 26 Jun 2018 19:46:11 -0700
>> Saeed Mahameed <sae...@dev.mellanox.co.il> wrote:
>>
>>> diff --git a/include/net/xdp.h b/include/net/xdp.h
>>> index 2deea7166a34..afe302613ae1 100644
>>> --- a/include/net/xdp.h
>>> +++ b/include/net/xdp.h
>>> @@ -138,6 +138,12 @@ xdp_set_data_meta_invalid(struct xdp_buff
>>> *xdp)
>>>     xdp->data_meta = xdp->data + 1;
>>>  }
>>>  
>>> +static __always_inline void
>>> +xdp_reset_data_meta(struct xdp_buff *xdp)
>>> +{
>>> +   xdp->data_meta = xdp->data_hard_start;
>>> +}
>>
>> This is WRONG ... it should be:
>>
>>  xdp->data_meta = xdp->data;
> 
> maybe the name of the function is not suitable for the use case.
> i need to set xdp->data_meta = xdp->data in the driver to start storing
> meta data.

The xdp_set_data_meta_invalid() is a straight forward way for XDP drivers
to tell they do not support xdp->data_meta, since setting xdp->data + 1 will
fail the checks for direct (meta) packet access in the BPF code and at the
same time bpf_xdp_adjust_meta() will know to bail out with error when program
attempts to make headroom for meta data that driver cannot handle later on.

So later setting 'xdp->data_meta = xdp->data' to enable it is as setting any
other of the initializers in xdp_buff, and done so today in the i40e, ixgbe,
ixgbevf and nfp drivers. (Theoretically it wouldn't have to be exactly set to
xdp->data, but anything <= xdp->data works, if the driver would prepend info
from hw in front of it that program can then use or later override.)

Thanks,
Daniel

Reply via email to