From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by mail.toke.dk (Postfix) with ESMTPS id 2C06E9C453E for ; Mon, 21 Nov 2022 19:25:56 +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=YbJPFsOK Received: by mail-pf1-x449.google.com with SMTP id t10-20020aa7946a000000b0057193a6891eso7867763pfq.0 for ; Mon, 21 Nov 2022 10:25:56 -0800 (PST) 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=neyclIYmG2MJG0dCgBX3z1WFmjD9qCZi8nD0qNfRZRU=; b=YbJPFsOK1XLIQ5fT/xSiHlNBomXbIsycXsSxoWDiNeEgRNXmMvMjF9knrQ77sUE9s9 k08aLCK0GAenX9iZv9vu3+6Dzj/1CnGh2sJd+vRqbTG10RgtdpWUHjj+4PNLlZ1+ycRc n9Kt+xuryiKGNWWYo+fK9/KPpFaBKRvo/uNVuGytj68vT7fIxSn/sicXHKTH3if3PO/t wZ7NsaFYzzJ5kSPjRdjewIPDReexUHIqR/qxfHVvXJHWzQHgpHIfsDAtb2uqQP2UIjo+ s9NAZmGTMVMCsWInsr01nknMm2S4i3z7PWwXWTMB6ed74iBAL7qbDHAYXWVWo7YUxE5x zTlw== 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=neyclIYmG2MJG0dCgBX3z1WFmjD9qCZi8nD0qNfRZRU=; b=JzC2EFofs3TvIs4TC0SSktHZzMdpauYDQWziZYVp02a6qtcEKI5R55XFzNVflfvwE9 Vz2kEBpOQIn56lSBC+I/EPwloKH3BGVBPPLP/0Omty7QrneL0UOxstBcLYlEcINNKwDY 6knI/c0MMhdI0PlYbg9K8H+fAOUIYfh3wiMJIxixZJNEf1FDWj+IWcJShZDuHTCw/yqI F5rbqzCtftmykYU06HHZxelbKFilgH7v1YHwxvtXs4aQ9eNrjNGBgnDanW73snbPxzc2 jUwkz8kAoL3Mv/HdSJxAER1rhMaXWaOXqSVrHmn5r82/SeoujpgCWozsvRBKIRDzAd6b pGew== X-Gm-Message-State: ANoB5plVLqZPXPOA0T5SET9o4SEXZ2aL0eBpw/2/434hPIxC73KAN9lq LWcbexGY+w0U9UfkAn3NyQg8MaM= X-Google-Smtp-Source: AA0mqf42La1ts4Pi84zycQoiDeWxQo7HER3f6PUKjfK6gBRvLd0L4veQzAa8AuF2uk9BG+d3UIeZFOQ= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:eac2:b0:186:b91b:17ec with SMTP id p2-20020a170902eac200b00186b91b17ecmr12951852pld.10.1669055154167; Mon, 21 Nov 2022 10:25:54 -0800 (PST) Date: Mon, 21 Nov 2022 10:25:44 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221121182552.2152891-1-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: EXBHP355WZGWNROPU7PCDF7LT6CHBN3X X-Message-ID-Hash: EXBHP355WZGWNROPU7PCDF7LT6CHBN3X X-MailFrom: 3ssJ7YwMKCUk3oqrzzrwp.nzx8o0-sty438o0-02zupn4.yp4@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, 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.7 Precedence: list Subject: [xdp-hints] [PATCH bpf-next v2 0/8] 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: Please see the first patch in the series for the overall design and use-cases. Changes since v1: - Drop xdp->skb metadata path (Jakub) No consensus yet on exposing xdp_skb_metadata in UAPI. Exploring whether everyone would be ok with kfunc to access that part.. Will follow up separately. - Drop kfunc unrolling (Alexei) Starting with simple code to resolve per-device ndo kfuncs. We can always go back to unrolling and keep the same kfuncs interface in the future. - Add rx hash metadata (Toke) Not adding the rest (csum/hash_type/etc), I'd like us to agree on the framework. - use dev_get_by_index and add proper refcnt (Toke) Changes since last RFC: - drop ice/bnxt example implementation (Alexander) -ENOHARDWARE to test - fix/test mlx4 implementation Confirmed that I get reasonable looking timestamp. The last patch in the series is the small xsk program that can be used to dump incoming metadata. - bpf_push64/bpf_pop64 (Alexei) x86_64+arm64(untested)+disassembler - struct xdp_to_skb_metadata -> struct xdp_skb_metadata (Toke) s/xdp_to_skb/xdp_skb/ - Documentation/bpf/xdp-rx-metadata.rst Documents functionality, assumptions and limitations. - bpf_xdp_metadata_export_to_skb returns true/false (Martin) Plus xdp_md->skb_metadata field to access it. - BPF_F_XDP_HAS_METADATA flag (Toke/Martin) Drop magic, use the flag instead. - drop __randomize_layout Not sure it's possible to sanely expose it via UAPI. Because every .o potentially gets its own randomized layout, test_progs refuses to link. - remove __net_timestamp in veth driver (John/Jesper) Instead, calling ktime_get from the kfunc; enough for the selftests. Future work on RX side: - Support more devices besides veth and mlx4 - Support more metadata besides RX timestamp. - Convert skb_metadata_set() callers to xdp_convert_skb_metadata() which handles extra xdp_skb_metadata Prior art (to record pros/cons for different approaches): - Stable UAPI approach: https://lore.kernel.org/bpf/20220628194812.1453059-1-alexandr.lobakin@intel.com/ - Metadata+BTF_ID appoach: https://lore.kernel.org/bpf/166256538687.1434226.15760041133601409770.stgit@firesoul/ - v1: https://lore.kernel.org/bpf/20221115030210.3159213-1-sdf@google.com/T/#t - kfuncs v2 RFC: https://lore.kernel.org/bpf/20221027200019.4106375-1-sdf@google.com/ - kfuncs v1 RFC: https://lore.kernel.org/bpf/20221104032532.1615099-1-sdf@google.com/ Cc: John Fastabend Cc: David Ahern 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 (8): bpf: Document XDP RX metadata bpf: XDP metadata RX kfuncs veth: Introduce veth_xdp_buff wrapper for xdp_buff veth: Support RX XDP metadata selftests/bpf: Verify xdp_metadata xdp->af_xdp path mlx4: Introduce mlx4_xdp_buff wrapper for xdp_buff mxl4: Support RX XDP metadata selftests/bpf: Simple program to dump XDP RX metadata Documentation/bpf/xdp-rx-metadata.rst | 90 ++++ .../net/ethernet/mellanox/mlx4/en_netdev.c | 10 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 78 +++- drivers/net/veth.c | 88 ++-- include/linux/bpf.h | 1 + include/linux/mlx4/device.h | 7 + include/linux/netdevice.h | 5 + include/net/xdp.h | 20 + include/uapi/linux/bpf.h | 5 + kernel/bpf/core.c | 1 + kernel/bpf/syscall.c | 17 +- kernel/bpf/verifier.c | 33 ++ net/core/dev.c | 5 + net/core/xdp.c | 52 +++ tools/include/uapi/linux/bpf.h | 5 + tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 8 +- .../selftests/bpf/prog_tests/xdp_metadata.c | 365 ++++++++++++++++ .../selftests/bpf/progs/xdp_hw_metadata.c | 93 ++++ .../selftests/bpf/progs/xdp_metadata.c | 57 +++ tools/testing/selftests/bpf/xdp_hw_metadata.c | 405 ++++++++++++++++++ tools/testing/selftests/bpf/xdp_metadata.h | 7 + 22 files changed, 1311 insertions(+), 42 deletions(-) create mode 100644 Documentation/bpf/xdp-rx-metadata.rst create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_metadata.c create mode 100644 tools/testing/selftests/bpf/progs/xdp_hw_metadata.c create mode 100644 tools/testing/selftests/bpf/progs/xdp_metadata.c create mode 100644 tools/testing/selftests/bpf/xdp_hw_metadata.c create mode 100644 tools/testing/selftests/bpf/xdp_metadata.h -- 2.38.1.584.g0f3c55d4c2-goog