Merge remote-tracking branch 'iommu/next'
[deliverable/linux.git] / include / linux / bpf.h
index 0de4de6dd43e09aae40a72500b0e5a2fb9e89c1e..9a904f63f8c1faa945914fb09aedecfc004ac295 100644 (file)
 #include <linux/workqueue.h>
 #include <linux/file.h>
 #include <linux/percpu.h>
+#include <linux/err.h>
 
+struct perf_event;
 struct bpf_map;
 
 /* map is generic key/value storage optionally accesible by eBPF programs */
 struct bpf_map_ops {
        /* funcs callable from userspace (via syscall) */
        struct bpf_map *(*map_alloc)(union bpf_attr *attr);
-       void (*map_free)(struct bpf_map *);
+       void (*map_release)(struct bpf_map *map, struct file *map_file);
+       void (*map_free)(struct bpf_map *map);
        int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key);
 
        /* funcs callable from userspace and from eBPF programs */
@@ -27,8 +30,9 @@ struct bpf_map_ops {
        int (*map_delete_elem)(struct bpf_map *map, void *key);
 
        /* funcs called by prog_array and perf_event_array map */
-       void *(*map_fd_get_ptr) (struct bpf_map *map, int fd);
-       void (*map_fd_put_ptr) (void *ptr);
+       void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
+                               int fd);
+       void (*map_fd_put_ptr)(void *ptr);
 };
 
 struct bpf_map {
@@ -189,15 +193,28 @@ struct bpf_array {
                void __percpu *pptrs[0] __aligned(8);
        };
 };
+
 #define MAX_TAIL_CALL_CNT 32
 
+struct bpf_event_entry {
+       struct perf_event *event;
+       struct file *perf_file;
+       struct file *map_file;
+       struct rcu_head rcu;
+};
+
 u64 bpf_tail_call(u64 ctx, u64 r2, u64 index, u64 r4, u64 r5);
 u64 bpf_get_stackid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
-void bpf_fd_array_map_clear(struct bpf_map *map);
+
 bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp);
 
 const struct bpf_func_proto *bpf_get_trace_printk_proto(void);
-const struct bpf_func_proto *bpf_get_event_output_proto(void);
+
+typedef unsigned long (*bpf_ctx_copy_t)(void *dst, const void *src,
+                                       unsigned long off, unsigned long len);
+
+u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
+                    void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy);
 
 #ifdef CONFIG_BPF_SYSCALL
 DECLARE_PER_CPU(int, bpf_prog_active);
@@ -206,9 +223,10 @@ void bpf_register_prog_type(struct bpf_prog_type_list *tl);
 void bpf_register_map_type(struct bpf_map_type_list *tl);
 
 struct bpf_prog *bpf_prog_get(u32 ufd);
+struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type);
+struct bpf_prog *bpf_prog_add(struct bpf_prog *prog, int i);
 struct bpf_prog *bpf_prog_inc(struct bpf_prog *prog);
 void bpf_prog_put(struct bpf_prog *prog);
-void bpf_prog_put_rcu(struct bpf_prog *prog);
 
 struct bpf_map *bpf_map_get_with_uref(u32 ufd);
 struct bpf_map *__bpf_map_get(struct fd f);
@@ -231,8 +249,13 @@ int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value,
                           u64 flags);
 int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
                            u64 flags);
+
 int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value);
 
+int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
+                                void *key, void *value, u64 map_flags);
+void bpf_fd_array_map_clear(struct bpf_map *map);
+
 /* memcpy that is used with 8-byte aligned pointers, power-of-8 size and
  * forced to use 'long' read/writes to try to atomically copy long counters.
  * Best-effort only.  No barriers here, since it _will_ race with concurrent
@@ -261,12 +284,22 @@ static inline struct bpf_prog *bpf_prog_get(u32 ufd)
        return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline void bpf_prog_put(struct bpf_prog *prog)
+static inline struct bpf_prog *bpf_prog_get_type(u32 ufd,
+                                                enum bpf_prog_type type)
 {
+       return ERR_PTR(-EOPNOTSUPP);
+}
+static inline struct bpf_prog *bpf_prog_add(struct bpf_prog *prog, int i)
+{
+       return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline void bpf_prog_put_rcu(struct bpf_prog *prog)
+static inline void bpf_prog_put(struct bpf_prog *prog)
+{
+}
+static inline struct bpf_prog *bpf_prog_inc(struct bpf_prog *prog)
 {
+       return ERR_PTR(-EOPNOTSUPP);
 }
 #endif /* CONFIG_BPF_SYSCALL */
 
This page took 0.0268929999999999 seconds and 5 git commands to generate.