From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by mail.toke.dk (Postfix) with ESMTPS id 5CA4B9B835D for ; Thu, 10 Nov 2022 02:02:13 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=MNdu2pMd Received: by mail-io1-xd29.google.com with SMTP id n191so180225iod.13 for ; Wed, 09 Nov 2022 17:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1CUpF8sPjSKa1qNYh255GV9ZgKn7MltcaT4JcHEFhGY=; b=MNdu2pMdm9Q/07uvCc/zUIAyVQxalRVb7Hlr94A0mceH+Li1TWOT/WBQNzhUBXY6CY s+KNuB9k1qAkQC6XzPqX2+NXByTm72czY3m2UbOt9yqRBmFCYC5Y1hbEMWbg+ZvttHZT jIPsSRcstPdI8PT0q1NSd4oK1ACUzG93mJ+qSVvSKpX37nonJE3EY7MIExhw9FqKDc+d +aXbpxtqVnpnDmQRN5W1wEMjDjJn69ttp35I1tTjcLo9G0lLmdgOhE0lXC7TJfu5HAK/ AnDWp5DJzP76Y0pSK0ABJX1VU4Ie2IzW1n1PZkLJlmNRow+mKg1xjpDwV03HfnOrcTBp oy1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1CUpF8sPjSKa1qNYh255GV9ZgKn7MltcaT4JcHEFhGY=; b=Eb+OpZCId6SCuL959g6YqwDP+oJXa4DhNBXCufH2PgO5dAosCmXmOHGmtQ8b5YBaAE VfzfqM/GpDH33wNtspnH86anz4aa5aTlusGCUbNCD5/PsxvA+SF8ExMPRg9NgmFeM1nX m4igkxH8Tdh3kGCNPae5xC6lG3wIE+PmNlPCYWy8HrrmbZib9DxK1t0F1a8KSQD/JKTZ Cgs7ZWhTXq6wo+4lXFTB+pADckb6h+xHuoS9WsTXNxVuMHo1my6QAPLOr++1VXFZyDjx ToMO/mqjHXM+0lI6qvPU40jMUmP+AUkQ8FbFx/8ymrtizp0q2lZ9bJRgxQ089+nYYkQY RjxA== X-Gm-Message-State: ANoB5pkPFxi2Io41ixAr2rXxwajELiZ6cZyBRAKTZeGmdFGNlRTvzIpa pOJXHdbGPjTfku2LZ37LNoZMXO8J1/ZcKTmZRR/I/A== X-Google-Smtp-Source: AA0mqf5iU++nhS9XQpgQ+bbgvvR9S0yg/vQEYa81M7IXz1j3U6aRC34YmQ61ZR1XSRw9bTVDQWqMV96gLsvOhOr1jVw= X-Received: by 2002:a02:ca49:0:b0:375:c385:d846 with SMTP id i9-20020a02ca49000000b00375c385d846mr1901422jal.84.1668042131419; Wed, 09 Nov 2022 17:02:11 -0800 (PST) MIME-Version: 1.0 References: <20221104032532.1615099-1-sdf@google.com> <20221104032532.1615099-5-sdf@google.com> <636c4514917fa_13c168208d0@john.notmuch> In-Reply-To: <636c4514917fa_13c168208d0@john.notmuch> From: Stanislav Fomichev Date: Wed, 9 Nov 2022 17:02:00 -0800 Message-ID: To: John Fastabend Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 3DZMG655IXFODUHYTV72GBUKULEZ35YB X-Message-ID-Hash: 3DZMG655IXFODUHYTV72GBUKULEZ35YB X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.6 Precedence: list Subject: [xdp-hints] Re: [RFC bpf-next v2 04/14] veth: Support rx timestamp metadata for xdp List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, Nov 9, 2022 at 4:26 PM John Fastabend wrote: > > Stanislav Fomichev wrote: > > xskxceiver conveniently setups up veth pairs so it seems logical > > to use veth as an example for some of the metadata handling. > > > > We timestamp skb right when we "receive" it, store its > > pointer in new veth_xdp_buff wrapper and generate BPF bytecode to > > reach it from the BPF program. > > > > This largely follows the idea of "store some queue context in > > the xdp_buff/xdp_frame so the metadata can be reached out > > from the BPF program". > > > > [...] > > > orig_data = xdp->data; > > orig_data_end = xdp->data_end; > > + vxbuf.skb = skb; > > > > act = bpf_prog_run_xdp(xdp_prog, xdp); > > > > @@ -942,6 +946,7 @@ static int veth_xdp_rcv(struct veth_rq *rq, int budget, > > struct sk_buff *skb = ptr; > > > > stats->xdp_bytes += skb->len; > > + __net_timestamp(skb); > > Just getting to reviewing in depth a bit more. But we hit veth with lots of > packets in some configurations I don't think we want to add a __net_timestamp > here when vast majority of use cases will have no need for timestamp on veth > device. I didn't do a benchmark but its not free. > > If there is a real use case for timestamping on veth we could do it through > a XDP program directly? Basically fallback for devices without hw timestamps. > Anyways I need the helper to support hardware without time stamping. > > Not sure if this was just part of the RFC to explore BPF programs or not. Initially I've done it mostly so I can have selftests on top of veth driver, but I'd still prefer to keep it to have working tests. Any way I can make it configurable? Is there some ethtool "enable tx timestamping" option I can reuse? > > skb = veth_xdp_rcv_skb(rq, skb, bq, stats); > > if (skb) { > > if (skb_shared(skb) || skb_unclone(skb, GFP_ATOMIC))