From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [RFC bpf-next 2/6] net: xdp: RX meta data infrastructure Date: Mon, 2 Jul 2018 10:01:58 +0200 Message-ID: <1fc9e26e-35b9-b14c-eac2-c240649e1417@iogearbox.net> References: <20180627024615.17856-1-saeedm@mellanox.com> <20180627024615.17856-3-saeedm@mellanox.com> <20180627161517.31f1f7af@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "alexander.h.duyck@intel.com" , "peter.waskiewicz.jr@intel.com" , Rony Efraim , Tariq Toukan , "neerav.parikh@intel.com" , Opher Reviv , "alexei.starovoitov@gmail.com" , "pjwaskiewicz@gmail.com" , "netdev@vger.kernel.org" , "ttoukan.linux@gmail.com" , john.fastabend@gmail.com To: Saeed Mahameed , "saeedm@dev.mellanox.co.il" , "brouer@redhat.com" Return-path: Received: from www62.your-server.de ([213.133.104.62]:59961 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933554AbeGBICG (ORCPT ); Mon, 2 Jul 2018 04:02:06 -0400 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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 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