From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by mail.toke.dk (Postfix) with ESMTPS id 276289AFAAC for ; Thu, 27 Oct 2022 22:00:28 +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=hjkhJabF Received: by mail-yb1-xb4a.google.com with SMTP id o2-20020a5b0502000000b006cade5e7c07so2510737ybp.10 for ; Thu, 27 Oct 2022 13:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RP55M8cA5M2RXo8rOon2JD5KhcZkcbkmc4ixPrmMem4=; b=hjkhJabFkn0xjp3ooIiT6qUbyMYEDUSI2QuChlBbDXQQ5HNfNN8+I+bFe8j2cBJgoZ oRPArOxcW/M864tAkzcPY671i8RDYxN32TcbY0cIcLB2IwIWfm6AVePXM2FVjeCo0b2R Bx4Eqgyb9+H6iWLZjDlytBat4d6JouHpsFYU3tmCifz24e6LWempBi7DjILFIksvBAt1 omEbPEMyso4TjhRN6ebWSGvztHkBG22SVWdgcyWjYlPZhUKir1TIeop1Iduzc2g3Lz+g s+cQkgUSf4zaL0tQ6quMUjRUaiqlq0sr3IkqoAEnSu6XW6aIbWEUJ1Ys/3cTE8RapL1T L9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=RP55M8cA5M2RXo8rOon2JD5KhcZkcbkmc4ixPrmMem4=; b=MLQHuE4eTSE6N8Mmnoc3Xlx6I9cu7i/78UPMGvVqlMyCtQhf9nI9j/3RdepetvBwkz 8cBGmZgI+v53hKO9qnZNHjwTL6ttIKv8AECzdb+4MJ2XKJ2NqY79q89LxDEN+WLSpttB 1CtkyBWWUmQhO5KSJKWY+gqZgo78FsWeh1VxZ5bhL4QJ/AX0d+QH23NSwvXK6Ct1mKS1 FzEJtIgKnP7u6rK8hms6mcbaHmDZVzT0/evChdmWjdTfGO0MoDbPea7jGWHKQpUWGlNr zIRJII8+YKpvqs1ig/LwQhTOMy1BeTnc8rmy7To+BMB1BuiVmmb2XpQCXb+MszmL6Oh9 GifQ== X-Gm-Message-State: ACrzQf0Ug85vAOcv6J6S5OnrV7y3T08S4/aUsuZbkzIgsV+kVoRh2D94 SA+agkGPgRYWD8d24rE7toEDvIw= X-Google-Smtp-Source: AMsMyM77QeyllYbofvOa5Xukf+6LO5LkGydr8MQ+Mrn0YajmX3NrsZDFSyNNTfTCbD+ZFdb3Hxi/bY0= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a05:6902:10a:b0:6af:b884:840e with SMTP id o10-20020a056902010a00b006afb884840emr46744379ybh.330.1666900827359; Thu, 27 Oct 2022 13:00:27 -0700 (PDT) Date: Thu, 27 Oct 2022 13:00:17 -0700 In-Reply-To: <20221027200019.4106375-1-sdf@google.com> Mime-Version: 1.0 References: <20221027200019.4106375-1-sdf@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221027200019.4106375-4-sdf@google.com> From: Stanislav Fomichev To: bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 5TWQIU3MN3GG4JIX442PBCFESA6QZXMV X-Message-ID-Hash: 5TWQIU3MN3GG4JIX442PBCFESA6QZXMV X-MailFrom: 3W-NaYwMKCa4gRTUccUZS.QcalRd-VWbhglRd-dfcXSQh.bSh@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 3/5] libbpf: Pass prog_ifindex via bpf_object_open_opts List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allow passing prog_ifindex to BPF_PROG_LOAD. This patch is not XDP metadata specific but it's here because we (ab)use prog_ifindex as "target metadata" device during loading. We can figure out proper UAPI story if we decide to go forward with the kfunc approach. 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 Signed-off-by: Stanislav Fomichev --- tools/lib/bpf/libbpf.c | 1 + tools/lib/bpf/libbpf.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 5d7819edf074..61bc37006fe4 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -7190,6 +7190,7 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object prog->type = prog->sec_def->prog_type; prog->expected_attach_type = prog->sec_def->expected_attach_type; + prog->prog_ifindex = opts->prog_ifindex; /* sec_def can have custom callback which should be called * after bpf_program is initialized to adjust its properties diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index eee883f007f9..4a40b7623099 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -170,9 +170,13 @@ struct bpf_object_open_opts { */ __u32 kernel_log_level; + /* Optional ifindex of netdev for offload purposes. + */ + int prog_ifindex; + size_t :0; }; -#define bpf_object_open_opts__last_field kernel_log_level +#define bpf_object_open_opts__last_field prog_ifindex LIBBPF_API struct bpf_object *bpf_object__open(const char *path); -- 2.38.1.273.g43a17bfeac-goog