From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by mail.toke.dk (Postfix) with ESMTPS id 8C0ECA17D77 for ; Fri, 7 Jul 2023 21:30:13 +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=20221208 header.b=xruGGNlM Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-26314c2bdb8so2793645a91.1 for ; Fri, 07 Jul 2023 12:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688758212; x=1691350212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1MKED6r0fOSDG2OitoAAOgEtvC/DPkEhJBtkp+m4JxY=; b=xruGGNlMKaVcqxRIP0wIULlOAxnVjAZI1dldXXdPF4RQYpP+OtG/qxFIq+hfCLkgx9 f3rNt1m3aqdWctECAanKbXLh/gxXD3PBXHh/Ki8XZrUaf9oEQiab8yBP2cB+QBy+NbcX 1ZodPiFfIjJF4LfWnch92WxDZcQlAs/cJSYCiRHv8viZLc8bnHX0eK0j5nOf8TnjtQR5 gAFmrCgWL89X3C5Oj5t5V8FjeinImPCxlKVfFUXmCXzaWLC/D0c2SbjgF6EvOXix9EGV Rr17sSwVPKuXHFVgqGLnRfj+FjGhLuPrm9aaWgS2aPPprsiGWO5Lpfshf6S6d1ybkU5i XJTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688758212; x=1691350212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1MKED6r0fOSDG2OitoAAOgEtvC/DPkEhJBtkp+m4JxY=; b=GxrJJ6fCtXMravoBSsg/vIOt7/ee/Hgb4Df8u4MHWoX/AosHuY8Yhpe8k5uSHHM6Ki Wz0MICK37LWpJNCWSWau40WZ59MaYyGRSuqeb1YGihtTmlfFiCrhdf+/DmoE1JC5nty6 HGUuX0bXiVK++f+G1O9/YwD93Jx8XYkeUYB6M17QHHsSlyVqtfZKiuorgJyucY4j9Noq /Sd0RYi6ppHrl5PyJwCrjov1xLAR/HOR7dKzx3klkh2RC4nZ/n6Kx20gskYyzcT+FlOR eoDQhXskeXzWPeSAeXUtJ8TakxZ8npTzvQVs+Hl8P42xj4/VkjL0+6JjjIYU/whKNni2 F/1w== X-Gm-Message-State: ABy/qLaYaUxdJuqcom3OsXgyo62ol8kUzTvzpDeNqIN7yvmApSeKXk9J 5rTgcWI0CW3xW8mRkCB/dA6JbO8= X-Google-Smtp-Source: APBJJlGIZBvJPkKFv/Q5I+xIa3tblE8GIDGj+rcewIcapBo9qV5OybfQAFp23jqwnP4fXgxyIaOajVk= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:90a:f481:b0:263:4dca:ae63 with SMTP id bx1-20020a17090af48100b002634dcaae63mr4830732pjb.6.1688758211652; Fri, 07 Jul 2023 12:30:11 -0700 (PDT) Date: Fri, 7 Jul 2023 12:29:54 -0700 In-Reply-To: <20230707193006.1309662-1-sdf@google.com> Mime-Version: 1.0 References: <20230707193006.1309662-1-sdf@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230707193006.1309662-3-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: UKULOG4IOLQJR6MYTDEANFHKAMBXHYQO X-Message-ID-Hash: UKULOG4IOLQJR6MYTDEANFHKAMBXHYQO X-MailFrom: 3w2eoZAMKCWAQBDEMMEJC.AMKVBN-FGLRQVBN-NPMHCAR.LCR@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, kuba@kernel.org, toke@kernel.org, willemb@google.com, dsahern@kernel.org, magnus.karlsson@intel.com, bjorn@kernel.org, maciej.fijalkowski@intel.com, hawk@kernel.org, netdev@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [RFC bpf-next v3 02/14] bpf: Make it easier to add new metadata kfunc List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: No functional changes. Instead of having hand-crafted code in bpf_dev_bound_resolve_kfunc, move kfunc <> xmo handler relationship into XDP_METADATA_KFUNC_xxx. This way, any time new kfunc is added, we don't have to touch bpf_dev_bound_resolve_kfunc. Signed-off-by: Stanislav Fomichev --- include/net/offload.h | 8 +++++--- kernel/bpf/offload.c | 13 +++++++------ net/core/xdp.c | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/net/offload.h b/include/net/offload.h index 264a35881473..de0fac38a95b 100644 --- a/include/net/offload.h +++ b/include/net/offload.h @@ -6,12 +6,14 @@ #define XDP_METADATA_KFUNC_xxx \ NETDEV_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_TIMESTAMP, \ - bpf_xdp_metadata_rx_timestamp) \ + bpf_xdp_metadata_rx_timestamp, \ + xmo_rx_timestamp) \ NETDEV_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_HASH, \ - bpf_xdp_metadata_rx_hash) + bpf_xdp_metadata_rx_hash, \ + xmo_rx_hash) enum { -#define NETDEV_METADATA_KFUNC(name, _) name, +#define NETDEV_METADATA_KFUNC(name, _, __) name, XDP_METADATA_KFUNC_xxx #undef NETDEV_METADATA_KFUNC MAX_NETDEV_METADATA_KFUNC, diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index 235d81f7e0ed..cec63c76dce5 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -844,10 +844,11 @@ void *bpf_dev_bound_resolve_kfunc(struct bpf_prog *prog, u32 func_id) if (!ops) goto out; - if (func_id == bpf_dev_bound_kfunc_id(XDP_METADATA_KFUNC_RX_TIMESTAMP)) - p = ops->xmo_rx_timestamp; - else if (func_id == bpf_dev_bound_kfunc_id(XDP_METADATA_KFUNC_RX_HASH)) - p = ops->xmo_rx_hash; +#define NETDEV_METADATA_KFUNC(name, _, xmo) \ + if (func_id == bpf_dev_bound_kfunc_id(name)) p = ops->xmo; + XDP_METADATA_KFUNC_xxx +#undef NETDEV_METADATA_KFUNC + out: up_read(&bpf_devs_lock); @@ -855,13 +856,13 @@ void *bpf_dev_bound_resolve_kfunc(struct bpf_prog *prog, u32 func_id) } BTF_SET_START(dev_bound_kfunc_ids) -#define NETDEV_METADATA_KFUNC(name, str) BTF_ID(func, str) +#define NETDEV_METADATA_KFUNC(name, str, _) BTF_ID(func, str) XDP_METADATA_KFUNC_xxx #undef NETDEV_METADATA_KFUNC BTF_SET_END(dev_bound_kfunc_ids) BTF_ID_LIST(dev_bound_kfunc_ids_unsorted) -#define NETDEV_METADATA_KFUNC(name, str) BTF_ID(func, str) +#define NETDEV_METADATA_KFUNC(name, str, _) BTF_ID(func, str) XDP_METADATA_KFUNC_xxx #undef NETDEV_METADATA_KFUNC diff --git a/net/core/xdp.c b/net/core/xdp.c index 819767697370..c4be4367f2dd 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -741,7 +741,7 @@ __bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash, __diag_pop(); BTF_SET8_START(xdp_metadata_kfunc_ids) -#define NETDEV_METADATA_KFUNC(_, name) BTF_ID_FLAGS(func, name, 0) +#define NETDEV_METADATA_KFUNC(_, name, __) BTF_ID_FLAGS(func, name, 0) XDP_METADATA_KFUNC_xxx #undef NETDEV_METADATA_KFUNC BTF_SET8_END(xdp_metadata_kfunc_ids) -- 2.41.0.255.g8b1d071c50-goog