From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by mail.toke.dk (Postfix) with ESMTPS id E938A9AFB0F for ; Thu, 27 Oct 2022 22:05:51 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=CX/54vza Received: by mail-ej1-x634.google.com with SMTP id 13so7845927ejn.3 for ; Thu, 27 Oct 2022 13:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/YD2QYJpySAIoPiLoDb5zCS/pnGBeAeTfq4t8+VFNY4=; b=CX/54vzaQ2uX5sLKJoCdzNh13Ky9s+epPtojrrcphlkJZ3VU1xNbZL8Up1Xk4+NzCs APn5kPCCOTwLJ/VDvvKt0bl8Ku7HCQOS4j/K/kWq0V/xDZ6hOzWMUnVWSn1QuzUX1uIW nZ3nTHseZRbxPOaAtIw5sdHLOeCUBGb5VVqZAmcj8zA0Tszz8XPTvT2BhEpOnqs16k+s QXgGs0wEK+47a8rl98sE1p9ZMglOnwp2bKhB2zpYYlR9BL9hK8YofwU6ab+bds0m+M3t oGGCYS0KICAabexHzICBGKyWCJ7g39QcNiPcu8GhJvezdn0tJJ95ldmZAJD3KsfxE+90 R5AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/YD2QYJpySAIoPiLoDb5zCS/pnGBeAeTfq4t8+VFNY4=; b=Xp1InnjrAictFVu7lCymaKcTUUrzTkPU10MbgIWfAS2HWESpGI6aeVERT8fgq4+HIJ nK0kR1D7R/KRA9a8Ko3zSBjKUA/mpTDmcPHLQdwWAng+UKN2nYG40ZbscMbRr5KIJAUQ BHrvcJr3vCBHXXNZqVZRuK/WRcI9FHgO6ON6W1L8k9PatLDtC5qlE9KwU3f5pXpD/h5b N/5qgJXETP4wQnnjqixn1IubGGWFXpBk7rec7w39u2BxUR/6l3pQ1o0Fbdu/zDsKSJdm yjctgRcqq2aNQ5NePpkyINajqSaQ5+dKt0kIwtExfGeeEGetOVfI3U/8vIWu4KzZvGaO 7P7Q== X-Gm-Message-State: ACrzQf2cYe7YjGM9nAJn1AEYoaFAErD9ADW9LyYZE7Sw3A51/YFUVBhw B+t9vlVGuvpaha+Aud6ZbO1SQvmvSJMLCQvVs7U= X-Google-Smtp-Source: AMsMyM6LqaomoQM1pYg81YdxKGY3vyTHwx1Ou1Ga7ygkvHfJg8B1QShrldJhL877qNSyWkHFTRmHzexD+GzuIU5kIdE= X-Received: by 2002:a17:906:99c5:b0:73d:70c5:1a4f with SMTP id s5-20020a17090699c500b0073d70c51a4fmr42209764ejn.302.1666901149421; Thu, 27 Oct 2022 13:05:49 -0700 (PDT) MIME-Version: 1.0 References: <20221027200019.4106375-1-sdf@google.com> <20221027200019.4106375-4-sdf@google.com> In-Reply-To: <20221027200019.4106375-4-sdf@google.com> From: Andrii Nakryiko Date: Thu, 27 Oct 2022 13:05:36 -0700 Message-ID: To: Stanislav Fomichev Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: KBNXHYUFQCZDRRQNNKLTPWVLTJNZLQSB X-Message-ID-Hash: KBNXHYUFQCZDRRQNNKLTPWVLTJNZLQSB X-MailFrom: andrii.nakryiko@gmail.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: bpf@vger.kernel.org, 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, 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] Re: [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: On Thu, Oct 27, 2022 at 1:00 PM Stanislav Fomichev wrote: > > 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; > + nope, don't do that, open_opts are for entire object, while this is per-program thing So bpf_program__set_ifindex() setter would be more appropriate > 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 >