diff mbox series

[RFCv7,net-next,09/36] test_bpf: replace const features initialization with NETDEV_FEATURE_SET

Message ID 20220810030624.34711-10-shenjian15@huawei.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: extend the type of netdev_features_t to bitmap | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count fail Series longer than 15 patches (and no cover letter)
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 114 this patch: 114
netdev/cc_maintainers fail 12 maintainers not CCed: john.fastabend@gmail.com song@kernel.org sdf@google.com ast@kernel.org martin.lau@linux.dev daniel@iogearbox.net andrii@kernel.org kpsingh@kernel.org jolsa@kernel.org bpf@vger.kernel.org haoluo@google.com yhs@fb.com
netdev/build_clang fail Errors and warnings before: 15 this patch: 15
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 115 this patch: 115
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 79 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shenjian (K) Aug. 10, 2022, 3:05 a.m. UTC
The test_bpf uses netdev_features in global structure
initialization. Changed the its netdev_features_t memeber
to netdev_features_t *, and make it refer to a netdev_features_t
global variables.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 lib/test_bpf.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 5820704165a6..5ba5e9064903 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -13,6 +13,7 @@ 
 #include <linux/bpf.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/netdev_features_helper.h>
 #include <linux/if_vlan.h>
 #include <linux/random.h>
 #include <linux/highmem.h>
@@ -14718,27 +14719,48 @@  static __init struct sk_buff *build_test_skb_linear_no_head_frag(void)
 struct skb_segment_test {
 	const char *descr;
 	struct sk_buff *(*build_skb)(void);
-	netdev_features_t features;
+	const netdev_features_t *features;
 };
 
+static DECLARE_NETDEV_FEATURE_SET(gso_frags_feature_set,
+				  NETIF_F_SG_BIT,
+				  NETIF_F_GSO_PARTIAL_BIT,
+				  NETIF_F_IP_CSUM_BIT,
+				  NETIF_F_IPV6_CSUM_BIT,
+				  NETIF_F_RXCSUM_BIT);
+static DECLARE_NETDEV_FEATURE_SET(gso_linear_feature_set,
+				  NETIF_F_SG_BIT,
+				  NETIF_F_FRAGLIST_BIT,
+				  NETIF_F_HW_VLAN_CTAG_TX_BIT,
+				  NETIF_F_GSO_BIT,
+				  NETIF_F_LLTX_BIT,
+				  NETIF_F_GRO_BIT,
+				  NETIF_F_IPV6_CSUM_BIT,
+				  NETIF_F_RXCSUM_BIT,
+				  NETIF_F_HW_VLAN_STAG_TX_BIT);
+static netdev_features_t gso_frags_features __ro_after_init;
+static netdev_features_t gso_linear_feature_features __ro_after_init;
+
 static struct skb_segment_test skb_segment_tests[] __initconst = {
 	{
 		.descr = "gso_with_rx_frags",
 		.build_skb = build_test_skb,
-		.features = NETIF_F_SG | NETIF_F_GSO_PARTIAL | NETIF_F_IP_CSUM |
-			    NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM
+		.features = &gso_frags_features
 	},
 	{
 		.descr = "gso_linear_no_head_frag",
 		.build_skb = build_test_skb_linear_no_head_frag,
-		.features = NETIF_F_SG | NETIF_F_FRAGLIST |
-			    NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_GSO |
-			    NETIF_F_LLTX | NETIF_F_GRO |
-			    NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
-			    NETIF_F_HW_VLAN_STAG_TX
+		.features = &gso_linear_feature_features
 	}
 };
 
+static void __init test_skb_features_init(void)
+{
+	netdev_features_set_array(&gso_frags_feature_set, &gso_frags_features);
+	netdev_features_set_array(&gso_linear_feature_set,
+				  &gso_linear_feature_features);
+}
+
 static __init int test_skb_segment_single(const struct skb_segment_test *test)
 {
 	struct sk_buff *skb, *segs;
@@ -14750,7 +14772,7 @@  static __init int test_skb_segment_single(const struct skb_segment_test *test)
 		goto done;
 	}
 
-	segs = skb_segment(skb, test->features);
+	segs = skb_segment(skb, *test->features);
 	if (!IS_ERR(segs)) {
 		kfree_skb_list(segs);
 		ret = 0;
@@ -14764,6 +14786,8 @@  static __init int test_skb_segment(void)
 {
 	int i, err_cnt = 0, pass_cnt = 0;
 
+	test_skb_features_init();
+
 	for (i = 0; i < ARRAY_SIZE(skb_segment_tests); i++) {
 		const struct skb_segment_test *test = &skb_segment_tests[i];