From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by mail.toke.dk (Postfix) with ESMTPS id 5E70B9C223E for ; Tue, 15 Nov 2022 04:02:14 +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=Y1uFrunl Received: by mail-pj1-x104a.google.com with SMTP id k9-20020a17090a39c900b0021671e97a25so6791747pjf.1 for ; Mon, 14 Nov 2022 19:02:14 -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=jmoFjVUpIScIBXVlBGccTMF8ONCdDUS7UktVwh7iZmE=; b=Y1uFrunl6UnS9d2RPWNj2avXr22GuFyGPTISJ3LB3jEji0/Cc1h+fSpKSRPrl2HPOB WWyG+g6K4HVRRONXPZGgAkDmyEExMuVEXINiwO5WTqLT2NrZ2Ai7HjtpSIjtLyhMf27F J3OUh4vSWzB9iKzGRMpmqd/FD5vLmsgahGKlAapwK6RIRpbwra6Xv73VH/asKTPl44Ql GgLnQ9AvzpA06xQ5hewxqhJqXiR/RtS9Z5EwLvnfnkDxutNW+8FeTh/sZeyJoFoED7jV jDgDZp5IVlao/qyQgFM1JAxBHrGrFvMIfVK+DPFzLTCRpHaX8abEt/eImkwnN4AO4tFD M2aA== 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=jmoFjVUpIScIBXVlBGccTMF8ONCdDUS7UktVwh7iZmE=; b=5yffn3yfVWqyas6ekD/e1lZdK0vIbNSDVahFNMgdUWAQYzRa57rEbEOyHcmaXRf2Da RS4+ZbA63KqFju2Dq353czzUMzsoiT0K1PSn3jcideSvvI90j9mDhh2PP7T4DizqsKrf Nt9C7E5awNADbiYe2I91cXbQ4Y5O4NUKMuqzWFBiT3bm+p1PqwtBefET1TJehAamiuUt jB/KbmMTkbUb2NtVnRyEDV8NIYJbBBjbqENtQLTA35GGizb+C+e4M/XAPk2knQXq8BoQ ksKhWo4wMp10Qm0WWfqh4e2/v43madASrv+g/t2FAixilczDO4nVQRxCS25b5zb786xX mlfg== X-Gm-Message-State: ANoB5pnkIpCa26UFArWCaYMulNcNL70ming+Ib8OgHI49Dc7x/EwHCl6 cAzXlUeN+fXcLBjk26koCwMeSdQ= X-Google-Smtp-Source: AA0mqf7VU5XHuRqXRyQfM/PJ2eyCTEP96FM8RRPAA+2ZO/Hi8ZzOLB2rh5A/wMibAztCTehRhBbSDwo= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:aa7:8891:0:b0:562:9a93:7c91 with SMTP id z17-20020aa78891000000b005629a937c91mr16485801pfe.21.1668481332141; Mon, 14 Nov 2022 19:02:12 -0800 (PST) Date: Mon, 14 Nov 2022 19:01:59 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221115030210.3159213-1-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: EB5IGPWXXUBH6TYOXAN3PA74VJSSL6SI X-Message-ID-Hash: EB5IGPWXXUBH6TYOXAN3PA74VJSSL6SI X-MailFrom: 3NAFzYwMKCSUTEGHPPHMF.DPNYEQ-IJOUTYEQ-QSPKFDU.OFU@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.6 Precedence: list Subject: [xdp-hints] [PATCH bpf-next 00/11] 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 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/ - 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 (11): bpf: Document XDP RX metadata bpf: Introduce bpf_patch bpf: Support inlined/unrolled kfuncs for xdp metadata bpf: Implement hidden BPF_PUSH64 and BPF_POP64 instructions veth: Support rx timestamp metadata for xdp xdp: Carry over xdp metadata into skb context selftests/bpf: Verify xdp_metadata xdp->af_xdp path selftests/bpf: Verify xdp_metadata xdp->skb path mlx4: Introduce mlx4_xdp_buff wrapper for xdp_buff mxl4: Support rx timestamp metadata for xdp selftests/bpf: Simple program to dump XDP RX metadata Documentation/bpf/kfuncs.rst | 8 + Documentation/bpf/xdp-rx-metadata.rst | 109 +++++ arch/arm64/net/bpf_jit_comp.c | 8 + arch/x86/net/bpf_jit_comp.c | 8 + .../net/ethernet/mellanox/mlx4/en_netdev.c | 2 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 68 ++- drivers/net/veth.c | 22 +- include/linux/bpf.h | 1 + include/linux/bpf_patch.h | 29 ++ include/linux/btf.h | 1 + include/linux/btf_ids.h | 4 + include/linux/filter.h | 23 + include/linux/mlx4/device.h | 7 + include/linux/netdevice.h | 5 + include/linux/skbuff.h | 4 + include/net/xdp.h | 41 ++ include/uapi/linux/bpf.h | 12 + kernel/bpf/Makefile | 2 +- kernel/bpf/bpf_patch.c | 77 +++ kernel/bpf/disasm.c | 6 + kernel/bpf/syscall.c | 28 +- kernel/bpf/verifier.c | 80 ++++ net/core/dev.c | 7 + net/core/filter.c | 40 ++ net/core/skbuff.c | 20 + net/core/xdp.c | 184 +++++++- tools/include/uapi/linux/bpf.h | 12 + tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/DENYLIST.s390x | 1 + tools/testing/selftests/bpf/Makefile | 8 +- .../selftests/bpf/prog_tests/xdp_metadata.c | 440 ++++++++++++++++++ .../selftests/bpf/progs/xdp_hw_metadata.c | 99 ++++ .../selftests/bpf/progs/xdp_metadata.c | 114 +++++ tools/testing/selftests/bpf/xdp_hw_metadata.c | 404 ++++++++++++++++ tools/testing/selftests/bpf/xdp_hw_metadata.h | 6 + 35 files changed, 1856 insertions(+), 25 deletions(-) create mode 100644 Documentation/bpf/xdp-rx-metadata.rst create mode 100644 include/linux/bpf_patch.h create mode 100644 kernel/bpf/bpf_patch.c 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_hw_metadata.h -- 2.38.1.431.g37b22c650d-goog