mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 13:25:20 +02:00
Merge branch 'v5.15/standard/base' into v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g
This commit is contained in:
commit
6fe6c45eca
|
@ -77,6 +77,12 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
|
|||
return xp_alloc(pool);
|
||||
}
|
||||
|
||||
/* Returns as many entries as possible up to max. 0 <= N <= max. */
|
||||
static inline u32 xsk_buff_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
|
||||
{
|
||||
return xp_alloc_batch(pool, xdp, max);
|
||||
}
|
||||
|
||||
static inline bool xsk_buff_can_alloc(struct xsk_buff_pool *pool, u32 count)
|
||||
{
|
||||
return xp_can_alloc(pool, count);
|
||||
|
@ -89,6 +95,13 @@ static inline void xsk_buff_free(struct xdp_buff *xdp)
|
|||
xp_free(xskb);
|
||||
}
|
||||
|
||||
static inline void xsk_buff_set_size(struct xdp_buff *xdp, u32 size)
|
||||
{
|
||||
xdp->data = xdp->data_hard_start + XDP_PACKET_HEADROOM;
|
||||
xdp->data_meta = xdp->data;
|
||||
xdp->data_end = xdp->data + size;
|
||||
}
|
||||
|
||||
static inline dma_addr_t xsk_buff_raw_get_dma(struct xsk_buff_pool *pool,
|
||||
u64 addr)
|
||||
{
|
||||
|
@ -211,6 +224,11 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline u32 xsk_buff_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool xsk_buff_can_alloc(struct xsk_buff_pool *pool, u32 count)
|
||||
{
|
||||
return false;
|
||||
|
@ -220,6 +238,10 @@ static inline void xsk_buff_free(struct xdp_buff *xdp)
|
|||
{
|
||||
}
|
||||
|
||||
static inline void xsk_buff_set_size(struct xdp_buff *xdp, u32 size)
|
||||
{
|
||||
}
|
||||
|
||||
static inline dma_addr_t xsk_buff_raw_get_dma(struct xsk_buff_pool *pool,
|
||||
u64 addr)
|
||||
{
|
||||
|
|
|
@ -107,6 +107,7 @@ int xp_dma_map(struct xsk_buff_pool *pool, struct device *dev,
|
|||
unsigned long attrs, struct page **pages, u32 nr_pages);
|
||||
void xp_dma_unmap(struct xsk_buff_pool *pool, unsigned long attrs);
|
||||
struct xdp_buff *xp_alloc(struct xsk_buff_pool *pool);
|
||||
u32 xp_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max);
|
||||
bool xp_can_alloc(struct xsk_buff_pool *pool, u32 count);
|
||||
void *xp_raw_get_data(struct xsk_buff_pool *pool, u64 addr);
|
||||
dma_addr_t xp_raw_get_dma(struct xsk_buff_pool *pool, u64 addr);
|
||||
|
|
|
@ -524,6 +524,93 @@ struct xdp_buff *xp_alloc(struct xsk_buff_pool *pool)
|
|||
}
|
||||
EXPORT_SYMBOL(xp_alloc);
|
||||
|
||||
static u32 xp_alloc_new_from_fq(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
|
||||
{
|
||||
u32 i, cached_cons, nb_entries;
|
||||
|
||||
if (max > pool->free_heads_cnt)
|
||||
max = pool->free_heads_cnt;
|
||||
max = xskq_cons_nb_entries(pool->fq, max);
|
||||
|
||||
cached_cons = pool->fq->cached_cons;
|
||||
nb_entries = max;
|
||||
i = max;
|
||||
while (i--) {
|
||||
struct xdp_buff_xsk *xskb;
|
||||
u64 addr;
|
||||
bool ok;
|
||||
|
||||
__xskq_cons_read_addr_unchecked(pool->fq, cached_cons++, &addr);
|
||||
|
||||
ok = pool->unaligned ? xp_check_unaligned(pool, &addr) :
|
||||
xp_check_aligned(pool, &addr);
|
||||
if (unlikely(!ok)) {
|
||||
pool->fq->invalid_descs++;
|
||||
nb_entries--;
|
||||
continue;
|
||||
}
|
||||
|
||||
xskb = pool->free_heads[--pool->free_heads_cnt];
|
||||
*xdp = &xskb->xdp;
|
||||
xskb->orig_addr = addr;
|
||||
xskb->xdp.data_hard_start = pool->addrs + addr + pool->headroom;
|
||||
xskb->frame_dma = (pool->dma_pages[addr >> PAGE_SHIFT] &
|
||||
~XSK_NEXT_PG_CONTIG_MASK) + (addr & ~PAGE_MASK);
|
||||
xskb->dma = xskb->frame_dma + pool->headroom + XDP_PACKET_HEADROOM;
|
||||
xdp++;
|
||||
}
|
||||
|
||||
xskq_cons_release_n(pool->fq, max);
|
||||
return nb_entries;
|
||||
}
|
||||
|
||||
static u32 xp_alloc_reused(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 nb_entries)
|
||||
{
|
||||
struct xdp_buff_xsk *xskb;
|
||||
u32 i;
|
||||
|
||||
nb_entries = min_t(u32, nb_entries, pool->free_list_cnt);
|
||||
|
||||
i = nb_entries;
|
||||
while (i--) {
|
||||
xskb = list_first_entry(&pool->free_list, struct xdp_buff_xsk, free_list_node);
|
||||
list_del(&xskb->free_list_node);
|
||||
|
||||
*xdp = &xskb->xdp;
|
||||
xdp++;
|
||||
}
|
||||
pool->free_list_cnt -= nb_entries;
|
||||
|
||||
return nb_entries;
|
||||
}
|
||||
|
||||
u32 xp_alloc_batch(struct xsk_buff_pool *pool, struct xdp_buff **xdp, u32 max)
|
||||
{
|
||||
u32 nb_entries1 = 0, nb_entries2;
|
||||
|
||||
if (unlikely(pool->dma_need_sync)) {
|
||||
/* Slow path */
|
||||
*xdp = xp_alloc(pool);
|
||||
return !!*xdp;
|
||||
}
|
||||
|
||||
if (unlikely(pool->free_list_cnt)) {
|
||||
nb_entries1 = xp_alloc_reused(pool, xdp, max);
|
||||
if (nb_entries1 == max)
|
||||
return nb_entries1;
|
||||
|
||||
max -= nb_entries1;
|
||||
xdp += nb_entries1;
|
||||
}
|
||||
|
||||
nb_entries2 = xp_alloc_new_from_fq(pool, xdp, max);
|
||||
if (!nb_entries2)
|
||||
pool->fq->queue_empty_descs++;
|
||||
|
||||
return nb_entries1 + nb_entries2;
|
||||
}
|
||||
EXPORT_SYMBOL(xp_alloc_batch);
|
||||
|
||||
bool xp_can_alloc(struct xsk_buff_pool *pool, u32 count)
|
||||
{
|
||||
if (pool->free_list_cnt >= count)
|
||||
|
|
|
@ -111,14 +111,18 @@ struct xsk_queue {
|
|||
|
||||
/* Functions that read and validate content from consumer rings. */
|
||||
|
||||
static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
|
||||
static inline void __xskq_cons_read_addr_unchecked(struct xsk_queue *q, u32 cached_cons, u64 *addr)
|
||||
{
|
||||
struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring;
|
||||
|
||||
if (q->cached_cons != q->cached_prod) {
|
||||
u32 idx = q->cached_cons & q->ring_mask;
|
||||
u32 idx = cached_cons & q->ring_mask;
|
||||
|
||||
*addr = ring->desc[idx];
|
||||
}
|
||||
|
||||
static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
|
||||
{
|
||||
if (q->cached_cons != q->cached_prod) {
|
||||
__xskq_cons_read_addr_unchecked(q, q->cached_cons, addr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user