Lines Matching refs:queue
24 int wg_packet_queue_init(struct crypt_queue *queue, work_func_t function, in wg_packet_queue_init() argument
29 memset(queue, 0, sizeof(*queue)); in wg_packet_queue_init()
30 ret = ptr_ring_init(&queue->ring, len, GFP_KERNEL); in wg_packet_queue_init()
33 queue->worker = wg_packet_percpu_multicore_worker_alloc(function, queue); in wg_packet_queue_init()
34 if (!queue->worker) { in wg_packet_queue_init()
35 ptr_ring_cleanup(&queue->ring, NULL); in wg_packet_queue_init()
41 void wg_packet_queue_free(struct crypt_queue *queue, bool purge) in wg_packet_queue_free() argument
43 free_percpu(queue->worker); in wg_packet_queue_free()
44 WARN_ON(!purge && !__ptr_ring_empty(&queue->ring)); in wg_packet_queue_free()
45 ptr_ring_cleanup(&queue->ring, purge ? (void(*)(void*))kfree_skb : NULL); in wg_packet_queue_free()
49 #define STUB(queue) ((struct sk_buff *)&queue->empty) argument
51 void wg_prev_queue_init(struct prev_queue *queue) in wg_prev_queue_init() argument
53 NEXT(STUB(queue)) = NULL; in wg_prev_queue_init()
54 queue->head = queue->tail = STUB(queue); in wg_prev_queue_init()
55 queue->peeked = NULL; in wg_prev_queue_init()
56 atomic_set(&queue->count, 0); in wg_prev_queue_init()
64 static void __wg_prev_queue_enqueue(struct prev_queue *queue, struct sk_buff *skb) in __wg_prev_queue_enqueue() argument
67 WRITE_ONCE(NEXT(xchg_release(&queue->head, skb)), skb); in __wg_prev_queue_enqueue()
70 bool wg_prev_queue_enqueue(struct prev_queue *queue, struct sk_buff *skb) in wg_prev_queue_enqueue() argument
72 if (!atomic_add_unless(&queue->count, 1, MAX_QUEUED_PACKETS)) in wg_prev_queue_enqueue()
74 __wg_prev_queue_enqueue(queue, skb); in wg_prev_queue_enqueue()
78 struct sk_buff *wg_prev_queue_dequeue(struct prev_queue *queue) in wg_prev_queue_dequeue() argument
80 struct sk_buff *tail = queue->tail, *next = smp_load_acquire(&NEXT(tail)); in wg_prev_queue_dequeue()
82 if (tail == STUB(queue)) { in wg_prev_queue_dequeue()
85 queue->tail = next; in wg_prev_queue_dequeue()
90 queue->tail = next; in wg_prev_queue_dequeue()
91 atomic_dec(&queue->count); in wg_prev_queue_dequeue()
94 if (tail != READ_ONCE(queue->head)) in wg_prev_queue_dequeue()
96 __wg_prev_queue_enqueue(queue, STUB(queue)); in wg_prev_queue_dequeue()
99 queue->tail = next; in wg_prev_queue_dequeue()
100 atomic_dec(&queue->count); in wg_prev_queue_dequeue()