On Wed, 2021-04-14 at 16:25 -0700, Jakub Kicinski wrote:
> On Wed, 14 Apr 2021 23:14:04 +0000 Joseph, Jithu wrote:
> > > > +static struct sk_buff *igc_construct_skb_zc(struct igc_ring
> > > > *ring,
> > > > +                                           struct xdp_buff
> > > > *xdp)
> > > > +{
> > > > +       unsigned int metasize = xdp->data - xdp->data_meta;
> > > > +       unsigned int datasize = xdp->data_end - xdp->data;
> > > > +       struct sk_buff *skb;
> > > > +
> > > > +       skb = __napi_alloc_skb(&ring->q_vector->napi,
> > > > +                              xdp->data_end - xdp-
> > > > >data_hard_start,
> > > > +                              GFP_ATOMIC | __GFP_NOWARN);
> > > > +       if (unlikely(!skb))
> > > > +               return NULL;
> > > > +
> > > > +       skb_reserve(skb, xdp->data - xdp->data_hard_start);
> > > > +       memcpy(__skb_put(skb, datasize), xdp->data, datasize);
> > > > +       if (metasize)
> > > > +               skb_metadata_set(skb, metasize);  
> > > 
> > > But you haven't actually copied the matadata into the skb,
> > > the metadata is before xdp->data, right?  
> > 
> > Today the igc driver doesn’t add any metadata (except for hw time
> > stamps explained later) . So for most part, xdp->data and xdp-
> > > data_meta point to the same address . That could be why in this  
> > initial implementation we are not copying  the metadata into skb
> > (as
> > the driver doesn’t add any).  
> 
> I don't think the timestamp is supposed to be part of the metadata.
> We're talking about BPF metadata here (added by the XDP prog).
> 
> > If the XDP program adds some metadata before xdp->data (and  xdp-
> > > data_meta reflects this), that is NOT copied into the SKB as
> > > you  
> > mentioned .   Is the expectation that meta_data (if any added by
> > the
> > bpf program) , should also be copied to the skb  in this XDP_PASS
> > flow
> > ? If so I can revise this patch to do that. 
> 
> Yes, I believe so.
> 
> > If h/w time-stamp is added by the NIC, then metasize will be non
> > zero
> > (as  xdp->data is advanced by the driver ) .  h/w ts  is still
> > copied
> > into "skb_hwtstamps(skb)->hwtstamp" by  the caller of this function
> > igc_dispatch_skb_zc()  . Do you still want it to be copied into
> > __skb_put(skb, ) area too ? 
> 
> If TS is prepended to the frame it should be saved (e.g. on the
> stack)
> before XDP program is called and gets the chance to overwrite it. The
> metadata length when XDP program is called should be 0.

When you say metadata length should be 0 above, Do you mean that when
bpf_prog_run_xdp(prog, xdp) is invoked, xdp->data and xdp->data_meta
should point to the same address ?

Reply via email to