aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r--include/linux/bpf.h20
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;
22struct bpf_prog; 22struct bpf_prog;
23struct bpf_map; 23struct bpf_map;
24struct sock; 24struct sock;
25struct seq_file;
26struct 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 */
27struct bpf_map_ops { 29struct 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
48struct bpf_map { 54struct 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
112static 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
103extern const struct bpf_map_ops bpf_map_offload_ops; 117extern const struct bpf_map_ops bpf_map_offload_ops;
104 118
105/* function argument constraints */ 119/* function argument constraints */