| .. | .. |
|---|
| 6 | 6 | #include <uapi/linux/bpf.h> |
|---|
| 7 | 7 | #include <uapi/linux/if_ether.h> |
|---|
| 8 | 8 | #include <uapi/linux/in.h> |
|---|
| 9 | | -#include "bpf_helpers.h" |
|---|
| 9 | +#include <bpf/bpf_helpers.h> |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | /* Config setup from with userspace |
|---|
| 12 | 12 | * |
|---|
| .. | .. |
|---|
| 23 | 23 | READ_MEM = 0x1U, |
|---|
| 24 | 24 | SWAP_MAC = 0x2U, |
|---|
| 25 | 25 | }; |
|---|
| 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"); |
|---|
| 32 | 33 | |
|---|
| 33 | 34 | /* Common stats data record (shared with userspace) */ |
|---|
| 34 | 35 | struct datarec { |
|---|
| .. | .. |
|---|
| 36 | 37 | __u64 issue; |
|---|
| 37 | 38 | }; |
|---|
| 38 | 39 | |
|---|
| 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"); |
|---|
| 45 | 46 | |
|---|
| 46 | 47 | #define MAX_RXQs 64 |
|---|
| 47 | 48 | |
|---|
| 48 | 49 | /* 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"); |
|---|
| 55 | 56 | |
|---|
| 56 | 57 | static __always_inline |
|---|
| 57 | 58 | void swap_src_dst_mac(void *data) |
|---|