mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
xsk: Add API to check for available entries in FQ
Add a function that checks whether the Fill Ring has the specified amount of descriptors available. It will be useful for mlx5e that wants to check in advance, whether it can allocate a bulk of RX descriptors, to get the best performance. Signed-off-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Acked-by: Björn Töpel <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
This commit is contained in:
parent
e18953240d
commit
d57d76428a
3 changed files with 41 additions and 0 deletions
|
|
@ -37,6 +37,12 @@ bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs)
|
|||
READ_ONCE(xs->umem->fq);
|
||||
}
|
||||
|
||||
bool xsk_umem_has_addrs(struct xdp_umem *umem, u32 cnt)
|
||||
{
|
||||
return xskq_has_addrs(umem->fq, cnt);
|
||||
}
|
||||
EXPORT_SYMBOL(xsk_umem_has_addrs);
|
||||
|
||||
u64 *xsk_umem_peek_addr(struct xdp_umem *umem, u64 *addr)
|
||||
{
|
||||
return xskq_peek_addr(umem->fq, addr);
|
||||
|
|
|
|||
|
|
@ -117,6 +117,20 @@ static inline u32 xskq_nb_free(struct xsk_queue *q, u32 producer, u32 dcnt)
|
|||
return q->nentries - (producer - q->cons_tail);
|
||||
}
|
||||
|
||||
static inline bool xskq_has_addrs(struct xsk_queue *q, u32 cnt)
|
||||
{
|
||||
u32 entries = q->prod_tail - q->cons_tail;
|
||||
|
||||
if (entries >= cnt)
|
||||
return true;
|
||||
|
||||
/* Refresh the local pointer. */
|
||||
q->prod_tail = READ_ONCE(q->ring->producer);
|
||||
entries = q->prod_tail - q->cons_tail;
|
||||
|
||||
return entries >= cnt;
|
||||
}
|
||||
|
||||
/* UMEM queue */
|
||||
|
||||
static inline bool xskq_is_valid_addr(struct xsk_queue *q, u64 addr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue