Lines Matching refs:qs

31 static bool queue_stack_map_is_empty(struct bpf_queue_stack *qs)  in queue_stack_map_is_empty()  argument
33 return qs->head == qs->tail; in queue_stack_map_is_empty()
36 static bool queue_stack_map_is_full(struct bpf_queue_stack *qs) in queue_stack_map_is_full() argument
38 u32 head = qs->head + 1; in queue_stack_map_is_full()
40 if (unlikely(head >= qs->size)) in queue_stack_map_is_full()
43 return head == qs->tail; in queue_stack_map_is_full()
71 struct bpf_queue_stack *qs; in queue_stack_map_alloc() local
75 queue_size = sizeof(*qs) + size * attr->value_size; in queue_stack_map_alloc()
77 qs = bpf_map_area_alloc(queue_size, numa_node); in queue_stack_map_alloc()
78 if (!qs) in queue_stack_map_alloc()
81 bpf_map_init_from_attr(&qs->map, attr); in queue_stack_map_alloc()
83 qs->size = size; in queue_stack_map_alloc()
85 raw_spin_lock_init(&qs->lock); in queue_stack_map_alloc()
87 return &qs->map; in queue_stack_map_alloc()
93 struct bpf_queue_stack *qs = bpf_queue_stack(map); in queue_stack_map_free() local
95 bpf_map_area_free(qs); in queue_stack_map_free()
100 struct bpf_queue_stack *qs = bpf_queue_stack(map); in __queue_map_get() local
105 raw_spin_lock_irqsave(&qs->lock, flags); in __queue_map_get()
107 if (queue_stack_map_is_empty(qs)) { in __queue_map_get()
108 memset(value, 0, qs->map.value_size); in __queue_map_get()
113 ptr = &qs->elements[qs->tail * qs->map.value_size]; in __queue_map_get()
114 memcpy(value, ptr, qs->map.value_size); in __queue_map_get()
117 if (unlikely(++qs->tail >= qs->size)) in __queue_map_get()
118 qs->tail = 0; in __queue_map_get()
122 raw_spin_unlock_irqrestore(&qs->lock, flags); in __queue_map_get()
129 struct bpf_queue_stack *qs = bpf_queue_stack(map); in __stack_map_get() local
135 raw_spin_lock_irqsave(&qs->lock, flags); in __stack_map_get()
137 if (queue_stack_map_is_empty(qs)) { in __stack_map_get()
138 memset(value, 0, qs->map.value_size); in __stack_map_get()
143 index = qs->head - 1; in __stack_map_get()
144 if (unlikely(index >= qs->size)) in __stack_map_get()
145 index = qs->size - 1; in __stack_map_get()
147 ptr = &qs->elements[index * qs->map.value_size]; in __stack_map_get()
148 memcpy(value, ptr, qs->map.value_size); in __stack_map_get()
151 qs->head = index; in __stack_map_get()
154 raw_spin_unlock_irqrestore(&qs->lock, flags); in __stack_map_get()
186 struct bpf_queue_stack *qs = bpf_queue_stack(map); in queue_stack_map_push_elem() local
200 raw_spin_lock_irqsave(&qs->lock, irq_flags); in queue_stack_map_push_elem()
202 if (queue_stack_map_is_full(qs)) { in queue_stack_map_push_elem()
208 if (unlikely(++qs->tail >= qs->size)) in queue_stack_map_push_elem()
209 qs->tail = 0; in queue_stack_map_push_elem()
212 dst = &qs->elements[qs->head * qs->map.value_size]; in queue_stack_map_push_elem()
213 memcpy(dst, value, qs->map.value_size); in queue_stack_map_push_elem()
215 if (unlikely(++qs->head >= qs->size)) in queue_stack_map_push_elem()
216 qs->head = 0; in queue_stack_map_push_elem()
219 raw_spin_unlock_irqrestore(&qs->lock, irq_flags); in queue_stack_map_push_elem()