From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAD2AC433FE for ; Fri, 10 Dec 2021 19:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343560AbhLJTTZ (ORCPT ); Fri, 10 Dec 2021 14:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343558AbhLJTTY (ORCPT ); Fri, 10 Dec 2021 14:19:24 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BBE6C061746; Fri, 10 Dec 2021 11:15:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 65FB6CE2D2C; Fri, 10 Dec 2021 19:15:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B78CEC341C7; Fri, 10 Dec 2021 19:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639163745; bh=jg/fkuO5TQ/lbpYUZBIBkaH/d9H6ORUrfPsHC1ZV8wE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBMKSHzgJmStUabla13ezR150UAXUEUSOnlvDpfzYvFg/nusH5bgcZaq39MFrTJ2s rXt17PJ6C32S1ouBM0ESHabq6FnK3DWt7c76NdSvIVMcPpYZLkZGVC6m67xNgZqxq5 q7XnPZH6HKS58W0Sch9buRyS1TnVFKzoa2QOn+XqF5Y0OV9MNN1K9y5ajRLORHg4Ef nKkTsR/pAQuSzC2U2x/NIrDko6DJnd/c7pVoAo5soxtIiMgGcMw6b5nOCK6U8WEgBm eW2ASFXlb5EWvoHDTNZY9eG2BjRfKPLWm1xK/malDmQOHc7Qgw8XxE21RE16aSAXoR FuDJyalBvqUqQ== From: Lorenzo Bianconi To: bpf@vger.kernel.org, netdev@vger.kernel.org Cc: lorenzo.bianconi@redhat.com, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, shayagr@amazon.com, john.fastabend@gmail.com, dsahern@kernel.org, brouer@redhat.com, echaudro@redhat.com, jasowang@redhat.com, alexander.duyck@gmail.com, saeed@kernel.org, maciej.fijalkowski@intel.com, magnus.karlsson@intel.com, tirthendu.sarkar@intel.com, toke@redhat.com Subject: [PATCH v20 bpf-next 09/23] bpf: introduce BPF_F_XDP_MB flag in prog_flags loading the ebpf program Date: Fri, 10 Dec 2021 20:14:16 +0100 Message-Id: <5085e850bcaac0b2afaaf01f496a03070d617814.1639162845.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Introduce BPF_F_XDP_MB and the related field in bpf_prog_aux in order to notify the driver the loaded program support xdp multi-buffer. Acked-by: John Fastabend Signed-off-by: Lorenzo Bianconi --- include/linux/bpf.h | 1 + include/uapi/linux/bpf.h | 5 +++++ kernel/bpf/syscall.c | 4 +++- tools/include/uapi/linux/bpf.h | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 8bbf08fbab66..e516815e35f9 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -875,6 +875,7 @@ struct bpf_prog_aux { bool func_proto_unreliable; bool sleepable; bool tail_call_reachable; + bool xdp_mb; struct hlist_node tramp_hlist; /* BTF_KIND_FUNC_PROTO for valid attach_btf_id */ const struct btf_type *attach_func_proto; diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c26871263f1f..d5d3e7d9ec49 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -1111,6 +1111,11 @@ enum bpf_link_type { */ #define BPF_F_SLEEPABLE (1U << 4) +/* If BPF_F_XDP_MB is used in BPF_PROG_LOAD command, the loaded program + * fully support xdp multi-buffer + */ +#define BPF_F_XDP_MB (1U << 5) + /* When BPF ldimm64's insn[0].src_reg != 0 then this can have * the following extensions: * diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index b3ada4085f85..82626a95be99 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2202,7 +2202,8 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr) BPF_F_ANY_ALIGNMENT | BPF_F_TEST_STATE_FREQ | BPF_F_SLEEPABLE | - BPF_F_TEST_RND_HI32)) + BPF_F_TEST_RND_HI32 | + BPF_F_XDP_MB)) return -EINVAL; if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && @@ -2288,6 +2289,7 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr) prog->aux->dst_prog = dst_prog; prog->aux->offload_requested = !!attr->prog_ifindex; prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE; + prog->aux->xdp_mb = attr->prog_flags & BPF_F_XDP_MB; err = security_bpf_prog_alloc(prog->aux); if (err) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index c26871263f1f..d5d3e7d9ec49 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -1111,6 +1111,11 @@ enum bpf_link_type { */ #define BPF_F_SLEEPABLE (1U << 4) +/* If BPF_F_XDP_MB is used in BPF_PROG_LOAD command, the loaded program + * fully support xdp multi-buffer + */ +#define BPF_F_XDP_MB (1U << 5) + /* When BPF ldimm64's insn[0].src_reg != 0 then this can have * the following extensions: * -- 2.33.1