From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by mail.toke.dk (Postfix) with ESMTPS id 88FFD9AFA9B for ; Thu, 27 Oct 2022 22:00:23 +0200 (CEST) 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=pIzQsnpS Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-36b7cfda276so23572827b3.1 for ; Thu, 27 Oct 2022 13:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=IJRg5lgl7kzO11/gALyLFHMHPMyjmqqtY1BF5RnPR14=; b=pIzQsnpSaVOO8sqt3SlIBbbbp5f8vt+5f4S6vG1zTlEcojcd7pFtgx9OtrR6wqKYtV u1JVcAjJhAibGxcLrpDTMDfv01VAJOia439UJ2cheASuIRUoU9ylX8KdY7WJ+8qtgK4F P6hbry+vEmgMIr+S+Xnf0kTyly656ScneE299J74XPrm2fnUJz/IjMv6rYfutp03nBRO jjwQ8mL7smDVBDwnkj2WuFIlZhZmWsdDC35QfGv7btqEWHRvnftWZgUO5PqRWP3xcKPA dVjd7Fdx6E8rFaXuM7VZlrE6FOs73jcVJ0xH8hc1+DwWlBt9Z5dL0WkPhjWnlsYROdQ7 IOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IJRg5lgl7kzO11/gALyLFHMHPMyjmqqtY1BF5RnPR14=; b=JsrOnKGXJGxDfj4SpP1oSlmYXf5pV3mCgsXw2B/MfR4sZZk7MDm0hD6XAdRAzrH3TC 4SOm20ndbQh1aBGjDGU83Fi56hCkGiVPvUWPoMu3jRzDNX/xEIjK7ijwLLqnqCKSFqnQ Bqr+uO06LTizh0k57RvMg02yIC3SG0uQ4YiVp1HH5JZMQBquh7MAnlyluLGWL0tbIU5T dO089ek9wWUZOiKlZ0y53yCrFUTqq9Ftw4kucchfPtjhoWXh+s8gFMAcg2HgDI1iMhCA Y+gnW09hiunan9UiwlUSBPDvQ3yKut9VoJaSgu3kwoo+sfJWBRjq1fIkpkh/EZvL8cHO hygA== X-Gm-Message-State: ACrzQf3Ga9tF0mUk2KMpx7ZoZ2lLdd38vaUaYg0BlXG3zFlWJF6fUqOX llzUm92b0VuNdOHxWngkNme4bdU= X-Google-Smtp-Source: AMsMyM6zYTuXcO6vunm67vhV12nr//6lfCXy+lo+BgbWwTf9fJWfDDLT6f4KPEgSZ+iSKGUJ2C/F2tQ= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a5b:390:0:b0:6b0:22:89fe with SMTP id k16-20020a5b0390000000b006b0002289femr0ybp.200.1666900821424; Thu, 27 Oct 2022 13:00:21 -0700 (PDT) Date: Thu, 27 Oct 2022 13:00:14 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221027200019.4106375-1-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: WTW3CDOZTSC7UVIT4D5DSQUC65N5DTM7 X-Message-ID-Hash: WTW3CDOZTSC7UVIT4D5DSQUC65N5DTM7 X-MailFrom: 3VeNaYwMKCagaLNOWWOTM.KWUfLX-PQVbafLX-XZWRMKb.VMb@flex--sdf.bounces.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: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, 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.5 Precedence: list Subject: [xdp-hints] [RFC bpf-next 0/5] xdp: hints via kfuncs List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is an RFC for the alternative approach suggested by Martin and Jakub. I've tried to CC most of the people from the original discussion, feel free to add more if you think I've missed somebody. Summary: - add new BPF_F_XDP_HAS_METADATA program flag and abuse attr->prog_ifindex to pass target device ifindex at load time - at load time, find appropriate ndo_unroll_kfunc and call it to unroll/inline kfuncs; kfuncs have the default "safe" implementation if unrolling is not supported by a particular device - rewrite xskxceiver test to use C bpf program and extend it to export rx_timestamp (plus add rx timestamp to veth driver) I've intentionally kept it small and hacky to see whether the approach is workable or not. Pros: - we avoid BTF complexity; the BPF programs themselves are now responsible for agreeing on the metadata layout with the AF_XDP consumer - the metadata is free if not used - the metadata should, in theory, be cheap if used; kfuncs should be unrolled to the same code as if the metadata was pre-populated and passed with a BTF id - it's not all or nothing; users can use small subset of metadata which is more efficient than the BTF id approach where all metadata has to be exposed for every frame (and selectively consumed by the users) Cons: - forwarding has to be handled explicitly; the BPF programs have to agree on the metadata layout (IOW, the forwarding program has to be aware of the final AF_XDP consumer metadata layout) - TX picture is not clear; but it's not clear with BTF ids as well; I think we've agreed that just reusing whatever we have at RX won't fly at TX; seems like TX XDP program might be the answer here? (with a set of another tx kfuncs to "expose" bpf/af_xdp metatata back into the kernel) Cc: Martin KaFai Lau Cc: Jakub Kicinski Cc: Willem de Bruijn Cc: Jesper Dangaard Brouer Cc: Anatoly Burakov Cc: Alexander Lobakin Cc: Magnus Karlsson Cc: Maryam Tahhan Cc: xdp-hints@xdp-project.net Cc: netdev@vger.kernel.org Stanislav Fomichev (5): bpf: Support inlined/unrolled kfuncs for xdp metadata veth: Support rx timestamp metadata for xdp libbpf: Pass prog_ifindex via bpf_object_open_opts selftests/bpf: Convert xskxceiver to use custom program selftests/bpf: Test rx_timestamp metadata in xskxceiver drivers/net/veth.c | 31 +++++ include/linux/bpf.h | 1 + include/linux/btf.h | 1 + include/linux/btf_ids.h | 4 + include/linux/netdevice.h | 3 + include/net/xdp.h | 22 ++++ include/uapi/linux/bpf.h | 5 + kernel/bpf/syscall.c | 28 ++++- kernel/bpf/verifier.c | 60 +++++++++ net/core/dev.c | 7 ++ net/core/xdp.c | 28 +++++ tools/include/uapi/linux/bpf.h | 5 + tools/lib/bpf/libbpf.c | 1 + tools/lib/bpf/libbpf.h | 6 +- tools/testing/selftests/bpf/Makefile | 1 + .../testing/selftests/bpf/progs/xskxceiver.c | 43 +++++++ tools/testing/selftests/bpf/xskxceiver.c | 119 +++++++++++++++--- tools/testing/selftests/bpf/xskxceiver.h | 5 +- 18 files changed, 348 insertions(+), 22 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/xskxceiver.c -- 2.38.1.273.g43a17bfeac-goog