diff options
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r-- | include/linux/bpf.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 95a7abd0ee92..ee5275e7d4df 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h | |||
@@ -22,6 +22,8 @@ struct perf_event; | |||
22 | struct bpf_prog; | 22 | struct bpf_prog; |
23 | struct bpf_map; | 23 | struct bpf_map; |
24 | struct sock; | 24 | struct sock; |
25 | struct seq_file; | ||
26 | struct btf; | ||
25 | 27 | ||
26 | /* map is generic key/value storage optionally accesible by eBPF programs */ | 28 | /* map is generic key/value storage optionally accesible by eBPF programs */ |
27 | struct bpf_map_ops { | 29 | struct bpf_map_ops { |
@@ -43,10 +45,14 @@ struct bpf_map_ops { | |||
43 | void (*map_fd_put_ptr)(void *ptr); | 45 | void (*map_fd_put_ptr)(void *ptr); |
44 | u32 (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf); | 46 | u32 (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf); |
45 | u32 (*map_fd_sys_lookup_elem)(void *ptr); | 47 | u32 (*map_fd_sys_lookup_elem)(void *ptr); |
48 | void (*map_seq_show_elem)(struct bpf_map *map, void *key, | ||
49 | struct seq_file *m); | ||
50 | int (*map_check_btf)(const struct bpf_map *map, const struct btf *btf, | ||
51 | u32 key_type_id, u32 value_type_id); | ||
46 | }; | 52 | }; |
47 | 53 | ||
48 | struct bpf_map { | 54 | struct bpf_map { |
49 | /* 1st cacheline with read-mostly members of which some | 55 | /* The first two cachelines with read-mostly members of which some |
50 | * are also accessed in fast-path (e.g. ops, max_entries). | 56 | * are also accessed in fast-path (e.g. ops, max_entries). |
51 | */ | 57 | */ |
52 | const struct bpf_map_ops *ops ____cacheline_aligned; | 58 | const struct bpf_map_ops *ops ____cacheline_aligned; |
@@ -62,10 +68,13 @@ struct bpf_map { | |||
62 | u32 pages; | 68 | u32 pages; |
63 | u32 id; | 69 | u32 id; |
64 | int numa_node; | 70 | int numa_node; |
71 | u32 btf_key_id; | ||
72 | u32 btf_value_id; | ||
73 | struct btf *btf; | ||
65 | bool unpriv_array; | 74 | bool unpriv_array; |
66 | /* 7 bytes hole */ | 75 | /* 55 bytes hole */ |
67 | 76 | ||
68 | /* 2nd cacheline with misc members to avoid false sharing | 77 | /* The 3rd and 4th cacheline with misc members to avoid false sharing |
69 | * particularly with refcounting. | 78 | * particularly with refcounting. |
70 | */ | 79 | */ |
71 | struct user_struct *user ____cacheline_aligned; | 80 | struct user_struct *user ____cacheline_aligned; |
@@ -100,6 +109,11 @@ static inline struct bpf_offloaded_map *map_to_offmap(struct bpf_map *map) | |||
100 | return container_of(map, struct bpf_offloaded_map, map); | 109 | return container_of(map, struct bpf_offloaded_map, map); |
101 | } | 110 | } |
102 | 111 | ||
112 | static inline bool bpf_map_support_seq_show(const struct bpf_map *map) | ||
113 | { | ||
114 | return map->ops->map_seq_show_elem && map->ops->map_check_btf; | ||
115 | } | ||
116 | |||
103 | extern const struct bpf_map_ops bpf_map_offload_ops; | 117 | extern const struct bpf_map_ops bpf_map_offload_ops; |
104 | 118 | ||
105 | /* function argument constraints */ | 119 | /* function argument constraints */ |