From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by mail.toke.dk (Postfix) with ESMTPS id ACCC29B8705 for ; Thu, 10 Nov 2022 02:35:25 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WND2qg3N Received: by mail-pl1-x62f.google.com with SMTP id y4so315649plb.2 for ; Wed, 09 Nov 2022 17:35:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=aBWVLQ8bpcmSVCI9/eRrlYiKEKS4ChABCKWm3hWCQDg=; b=WND2qg3NkTaTsQ8lEHsgRLDmkmUZAVv/AC3413t0qb54lb6POtCdQmiu87lwHHAedW OGmK6OdBNEjdbvchZPQk/9OIgHw7H0UcvOqg0AiexDghWa/Dk4564O7zHvZFRGRatE40 BirfxSzbykucGYQ9dyjIRvH6d5H17C5rvOi82Z9j9DRZZgNGMOuq0I4HpwfLoCTbXZeH DDRDvDOp1G305SDGXvS3cu6wx1mkS/UmwbE3qXI6uq971LXVAruuEHNeNtu2EAYtQSS9 hgj2qJ8a6BqOqiXMoyBCSLdSCcB/6ijxhk1rP2zEhesiQAf9x+m43I0KwTMC8B6cx7Ya HPeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aBWVLQ8bpcmSVCI9/eRrlYiKEKS4ChABCKWm3hWCQDg=; b=aOXaoBkn1H51mBVX4jkwYEdna+rZCZaDX0fz10H4B/WfS/q1D9mFCUAe0AirGQ1k2+ gdiFwMR/dK8YAK8FJEjishOYqcoO2yCNGsUwChukYwFKMSux7i0+FvFiF4W8zWe1OIwd aHXPJK8Zy/KBpIg4ymg3cBB2BrDGNWMLHAoLFuC5/n9ahjsvOHhrwcHBYY0WNDBJWdMm T1C59EulXeD7a2QyrYEXD+hbdJe0AYdGQFrR23I314Puk2IejHPFYB3yyctKkE+Mt8cp jBkSnGeaORN7w0v3NNvE9hJ/QdhaNFU9ZZLnFuJqTk2SnNHmIvMYKhr5BZZ+75W/Yp9x 93Lw== X-Gm-Message-State: ANoB5pkV54UmO3dy+KrUshuLvhTLFPJ3u7YfJ7jcprtWUCFfBHHIrWd/ jPKDvGKsVEszgftuTJjPm1w= X-Google-Smtp-Source: AA0mqf6TRCn3ocObYvdfwHgBkIrFKVPceTIVdjm2HuYhQENpPOLxnlmnM7o0hD7CU6SJ1vEi32ewDQ== X-Received: by 2002:a17:90a:fd0c:b0:217:cd6b:466 with SMTP id cv12-20020a17090afd0c00b00217cd6b0466mr19237426pjb.4.1668044123216; Wed, 09 Nov 2022 17:35:23 -0800 (PST) Received: from localhost ([98.97.44.95]) by smtp.gmail.com with ESMTPSA id o24-20020aa79798000000b0056a7486da77sm9143255pfp.13.2022.11.09.17.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 17:35:22 -0800 (PST) Date: Wed, 09 Nov 2022 17:35:21 -0800 From: John Fastabend To: Stanislav Fomichev , John Fastabend Message-ID: <636c555942433_13ef3820861@john.notmuch> In-Reply-To: References: <20221104032532.1615099-1-sdf@google.com> <20221104032532.1615099-5-sdf@google.com> <636c4514917fa_13c168208d0@john.notmuch> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Message-ID-Hash: O62JIYGREAGTAQTPFQXEL5PERGF6WNWE X-Message-ID-Hash: O62JIYGREAGTAQTPFQXEL5PERGF6WNWE X-MailFrom: john.fastabend@gmail.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: Stanislav Fomichev wrote: > 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. I can't think of a use for it though so its just extra cycles. There is a helper to read the ktime. > Any way I can make it configurable? Is there some ethtool "enable tx > timestamping" option I can reuse? There is a -T option for timestamping in ethtool. There are also the socket controls for it. So you could spin up a socket and use it. But that is a bit broken as well I think it would be better if the timestamp came from the receiving physical nic? I have some mlx nics here and a k8s cluster with lots of veth devices so I could think a bit more. I'm just not sure why I would want the veth to timestamp things off hand? > > > > skb = veth_xdp_rcv_skb(rq, skb, bq, stats); > > > if (skb) { > > > if (skb_shared(skb) || skb_unclone(skb, GFP_ATOMIC))