hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/samples/bpf/xdp_rxq_info_kern.c
....@@ -6,7 +6,7 @@
66 #include <uapi/linux/bpf.h>
77 #include <uapi/linux/if_ether.h>
88 #include <uapi/linux/in.h>
9
-#include "bpf_helpers.h"
9
+#include <bpf/bpf_helpers.h>
1010
1111 /* Config setup from with userspace
1212 *
....@@ -23,12 +23,13 @@
2323 READ_MEM = 0x1U,
2424 SWAP_MAC = 0x2U,
2525 };
26
-struct bpf_map_def SEC("maps") config_map = {
27
- .type = BPF_MAP_TYPE_ARRAY,
28
- .key_size = sizeof(int),
29
- .value_size = sizeof(struct config),
30
- .max_entries = 1,
31
-};
26
+
27
+struct {
28
+ __uint(type, BPF_MAP_TYPE_ARRAY);
29
+ __type(key, int);
30
+ __type(value, struct config);
31
+ __uint(max_entries, 1);
32
+} config_map SEC(".maps");
3233
3334 /* Common stats data record (shared with userspace) */
3435 struct datarec {
....@@ -36,22 +37,22 @@
3637 __u64 issue;
3738 };
3839
39
-struct bpf_map_def SEC("maps") stats_global_map = {
40
- .type = BPF_MAP_TYPE_PERCPU_ARRAY,
41
- .key_size = sizeof(u32),
42
- .value_size = sizeof(struct datarec),
43
- .max_entries = 1,
44
-};
40
+struct {
41
+ __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
42
+ __type(key, u32);
43
+ __type(value, struct datarec);
44
+ __uint(max_entries, 1);
45
+} stats_global_map SEC(".maps");
4546
4647 #define MAX_RXQs 64
4748
4849 /* Stats per rx_queue_index (per CPU) */
49
-struct bpf_map_def SEC("maps") rx_queue_index_map = {
50
- .type = BPF_MAP_TYPE_PERCPU_ARRAY,
51
- .key_size = sizeof(u32),
52
- .value_size = sizeof(struct datarec),
53
- .max_entries = MAX_RXQs + 1,
54
-};
50
+struct {
51
+ __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
52
+ __type(key, u32);
53
+ __type(value, struct datarec);
54
+ __uint(max_entries, MAX_RXQs + 1);
55
+} rx_queue_index_map SEC(".maps");
5556
5657 static __always_inline
5758 void swap_src_dst_mac(void *data)