bpf: add support for bpf_wq user type
[linux-2.6-block.git] / include / linux / bpf.h
index 5034c1b4ded7bfb3c9fe6fe209732e089ef99adf..c7dcfd395555a01d94902884f743d4300d0dd36b 100644 (file)
@@ -185,7 +185,7 @@ struct bpf_map_ops {
 
 enum {
        /* Support at most 10 fields in a BTF type */
-       BTF_FIELDS_MAX     = 10,
+       BTF_FIELDS_MAX     = 11,
 };
 
 enum btf_field_type {
@@ -202,6 +202,7 @@ enum btf_field_type {
        BPF_GRAPH_NODE = BPF_RB_NODE | BPF_LIST_NODE,
        BPF_GRAPH_ROOT = BPF_RB_ROOT | BPF_LIST_HEAD,
        BPF_REFCOUNT   = (1 << 9),
+       BPF_WORKQUEUE  = (1 << 10),
 };
 
 typedef void (*btf_dtor_kfunc_t)(void *);
@@ -238,6 +239,7 @@ struct btf_record {
        u32 field_mask;
        int spin_lock_off;
        int timer_off;
+       int wq_off;
        int refcount_off;
        struct btf_field fields[];
 };
@@ -312,6 +314,8 @@ static inline const char *btf_field_type_name(enum btf_field_type type)
                return "bpf_spin_lock";
        case BPF_TIMER:
                return "bpf_timer";
+       case BPF_WORKQUEUE:
+               return "bpf_wq";
        case BPF_KPTR_UNREF:
        case BPF_KPTR_REF:
                return "kptr";
@@ -340,6 +344,8 @@ static inline u32 btf_field_type_size(enum btf_field_type type)
                return sizeof(struct bpf_spin_lock);
        case BPF_TIMER:
                return sizeof(struct bpf_timer);
+       case BPF_WORKQUEUE:
+               return sizeof(struct bpf_wq);
        case BPF_KPTR_UNREF:
        case BPF_KPTR_REF:
        case BPF_KPTR_PERCPU:
@@ -367,6 +373,8 @@ static inline u32 btf_field_type_align(enum btf_field_type type)
                return __alignof__(struct bpf_spin_lock);
        case BPF_TIMER:
                return __alignof__(struct bpf_timer);
+       case BPF_WORKQUEUE:
+               return __alignof__(struct bpf_wq);
        case BPF_KPTR_UNREF:
        case BPF_KPTR_REF:
        case BPF_KPTR_PERCPU:
@@ -406,6 +414,7 @@ static inline void bpf_obj_init_field(const struct btf_field *field, void *addr)
                /* RB_ROOT_CACHED 0-inits, no need to do anything after memset */
        case BPF_SPIN_LOCK:
        case BPF_TIMER:
+       case BPF_WORKQUEUE:
        case BPF_KPTR_UNREF:
        case BPF_KPTR_REF:
        case BPF_KPTR_PERCPU: