Lines Matching full:q
114 static inline void __xskq_cons_read_addr_unchecked(struct xsk_queue *q, u32 cached_cons, u64 *addr) in __xskq_cons_read_addr_unchecked() argument
116 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring; in __xskq_cons_read_addr_unchecked()
117 u32 idx = cached_cons & q->ring_mask; in __xskq_cons_read_addr_unchecked()
122 static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr) in xskq_cons_read_addr_unchecked() argument
124 if (q->cached_cons != q->cached_prod) { in xskq_cons_read_addr_unchecked()
125 __xskq_cons_read_addr_unchecked(q, q->cached_cons, addr); in xskq_cons_read_addr_unchecked()
179 static inline bool xskq_cons_is_valid_desc(struct xsk_queue *q, in xskq_cons_is_valid_desc() argument
184 q->invalid_descs++; in xskq_cons_is_valid_desc()
190 static inline bool xskq_cons_read_desc(struct xsk_queue *q, in xskq_cons_read_desc() argument
194 while (q->cached_cons != q->cached_prod) { in xskq_cons_read_desc()
195 struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring; in xskq_cons_read_desc()
196 u32 idx = q->cached_cons & q->ring_mask; in xskq_cons_read_desc()
199 if (xskq_cons_is_valid_desc(q, desc, pool)) in xskq_cons_read_desc()
202 q->cached_cons++; in xskq_cons_read_desc()
208 static inline void xskq_cons_release_n(struct xsk_queue *q, u32 cnt) in xskq_cons_release_n() argument
210 q->cached_cons += cnt; in xskq_cons_release_n()
213 static inline u32 xskq_cons_read_desc_batch(struct xsk_queue *q, struct xsk_buff_pool *pool, in xskq_cons_read_desc_batch() argument
216 u32 cached_cons = q->cached_cons, nb_entries = 0; in xskq_cons_read_desc_batch()
219 while (cached_cons != q->cached_prod && nb_entries < max) { in xskq_cons_read_desc_batch()
220 struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring; in xskq_cons_read_desc_batch()
221 u32 idx = cached_cons & q->ring_mask; in xskq_cons_read_desc_batch()
224 if (unlikely(!xskq_cons_is_valid_desc(q, &descs[nb_entries], pool))) { in xskq_cons_read_desc_batch()
235 xskq_cons_release_n(q, cached_cons - q->cached_cons); in xskq_cons_read_desc_batch()
241 static inline void __xskq_cons_release(struct xsk_queue *q) in __xskq_cons_release() argument
243 smp_store_release(&q->ring->consumer, q->cached_cons); /* D, matchees A */ in __xskq_cons_release()
246 static inline void __xskq_cons_peek(struct xsk_queue *q) in __xskq_cons_peek() argument
249 q->cached_prod = smp_load_acquire(&q->ring->producer); /* C, matches B */ in __xskq_cons_peek()
252 static inline void xskq_cons_get_entries(struct xsk_queue *q) in xskq_cons_get_entries() argument
254 __xskq_cons_release(q); in xskq_cons_get_entries()
255 __xskq_cons_peek(q); in xskq_cons_get_entries()
258 static inline u32 xskq_cons_nb_entries(struct xsk_queue *q, u32 max) in xskq_cons_nb_entries() argument
260 u32 entries = q->cached_prod - q->cached_cons; in xskq_cons_nb_entries()
265 __xskq_cons_peek(q); in xskq_cons_nb_entries()
266 entries = q->cached_prod - q->cached_cons; in xskq_cons_nb_entries()
271 static inline bool xskq_cons_has_entries(struct xsk_queue *q, u32 cnt) in xskq_cons_has_entries() argument
273 return xskq_cons_nb_entries(q, cnt) >= cnt; in xskq_cons_has_entries()
276 static inline bool xskq_cons_peek_addr_unchecked(struct xsk_queue *q, u64 *addr) in xskq_cons_peek_addr_unchecked() argument
278 if (q->cached_prod == q->cached_cons) in xskq_cons_peek_addr_unchecked()
279 xskq_cons_get_entries(q); in xskq_cons_peek_addr_unchecked()
280 return xskq_cons_read_addr_unchecked(q, addr); in xskq_cons_peek_addr_unchecked()
283 static inline bool xskq_cons_peek_desc(struct xsk_queue *q, in xskq_cons_peek_desc() argument
287 if (q->cached_prod == q->cached_cons) in xskq_cons_peek_desc()
288 xskq_cons_get_entries(q); in xskq_cons_peek_desc()
289 return xskq_cons_read_desc(q, desc, pool); in xskq_cons_peek_desc()
296 static inline void xskq_cons_release(struct xsk_queue *q) in xskq_cons_release() argument
298 q->cached_cons++; in xskq_cons_release()
301 static inline u32 xskq_cons_present_entries(struct xsk_queue *q) in xskq_cons_present_entries() argument
304 return READ_ONCE(q->ring->producer) - READ_ONCE(q->ring->consumer); in xskq_cons_present_entries()
309 static inline u32 xskq_prod_nb_free(struct xsk_queue *q, u32 max) in xskq_prod_nb_free() argument
311 u32 free_entries = q->nentries - (q->cached_prod - q->cached_cons); in xskq_prod_nb_free()
317 q->cached_cons = READ_ONCE(q->ring->consumer); in xskq_prod_nb_free()
318 free_entries = q->nentries - (q->cached_prod - q->cached_cons); in xskq_prod_nb_free()
323 static inline bool xskq_prod_is_full(struct xsk_queue *q) in xskq_prod_is_full() argument
325 return xskq_prod_nb_free(q, 1) ? false : true; in xskq_prod_is_full()
328 static inline void xskq_prod_cancel(struct xsk_queue *q) in xskq_prod_cancel() argument
330 q->cached_prod--; in xskq_prod_cancel()
333 static inline int xskq_prod_reserve(struct xsk_queue *q) in xskq_prod_reserve() argument
335 if (xskq_prod_is_full(q)) in xskq_prod_reserve()
339 q->cached_prod++; in xskq_prod_reserve()
343 static inline int xskq_prod_reserve_addr(struct xsk_queue *q, u64 addr) in xskq_prod_reserve_addr() argument
345 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring; in xskq_prod_reserve_addr()
347 if (xskq_prod_is_full(q)) in xskq_prod_reserve_addr()
351 ring->desc[q->cached_prod++ & q->ring_mask] = addr; in xskq_prod_reserve_addr()
355 static inline void xskq_prod_write_addr_batch(struct xsk_queue *q, struct xdp_desc *descs, in xskq_prod_write_addr_batch() argument
358 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring; in xskq_prod_write_addr_batch()
362 cached_prod = q->cached_prod; in xskq_prod_write_addr_batch()
364 ring->desc[cached_prod++ & q->ring_mask] = descs[i].addr; in xskq_prod_write_addr_batch()
365 q->cached_prod = cached_prod; in xskq_prod_write_addr_batch()
368 static inline int xskq_prod_reserve_desc(struct xsk_queue *q, in xskq_prod_reserve_desc() argument
371 struct xdp_rxtx_ring *ring = (struct xdp_rxtx_ring *)q->ring; in xskq_prod_reserve_desc()
374 if (xskq_prod_is_full(q)) in xskq_prod_reserve_desc()
378 idx = q->cached_prod++ & q->ring_mask; in xskq_prod_reserve_desc()
385 static inline void __xskq_prod_submit(struct xsk_queue *q, u32 idx) in __xskq_prod_submit() argument
387 smp_store_release(&q->ring->producer, idx); /* B, matches C */ in __xskq_prod_submit()
390 static inline void xskq_prod_submit(struct xsk_queue *q) in xskq_prod_submit() argument
392 __xskq_prod_submit(q, q->cached_prod); in xskq_prod_submit()
395 static inline void xskq_prod_submit_addr(struct xsk_queue *q, u64 addr) in xskq_prod_submit_addr() argument
397 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring; in xskq_prod_submit_addr()
398 u32 idx = q->ring->producer; in xskq_prod_submit_addr()
400 ring->desc[idx++ & q->ring_mask] = addr; in xskq_prod_submit_addr()
402 __xskq_prod_submit(q, idx); in xskq_prod_submit_addr()
405 static inline void xskq_prod_submit_n(struct xsk_queue *q, u32 nb_entries) in xskq_prod_submit_n() argument
407 __xskq_prod_submit(q, q->ring->producer + nb_entries); in xskq_prod_submit_n()
410 static inline bool xskq_prod_is_empty(struct xsk_queue *q) in xskq_prod_is_empty() argument
413 return READ_ONCE(q->ring->consumer) == READ_ONCE(q->ring->producer); in xskq_prod_is_empty()
418 static inline u64 xskq_nb_invalid_descs(struct xsk_queue *q) in xskq_nb_invalid_descs() argument
420 return q ? q->invalid_descs : 0; in xskq_nb_invalid_descs()
423 static inline u64 xskq_nb_queue_empty_descs(struct xsk_queue *q) in xskq_nb_queue_empty_descs() argument
425 return q ? q->queue_empty_descs : 0; in xskq_nb_queue_empty_descs()