Commit e4e5aefc authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Daniel Borkmann

xsk: Change two variable names for increased clarity

Change two variables names so that it is clearer what they
represent. The first one is xsk_list that in fact only contains the
list of AF_XDP sockets with a Tx component. Change this to xsk_tx_list
for improved clarity. The second variable is size in the ring
structure. One might think that this is the size of the ring, but it
is in fact the size of the umem, copied into the ring structure to
improve performance. Rename this variable umem_size to avoid any
confusion.
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Link: https://lore.kernel.org/bpf/1588599232-24897-2-git-send-email-magnus.karlsson@intel.com
parent d26c0cc5
...@@ -62,8 +62,8 @@ struct xdp_umem { ...@@ -62,8 +62,8 @@ struct xdp_umem {
struct net_device *dev; struct net_device *dev;
struct xdp_umem_fq_reuse *fq_reuse; struct xdp_umem_fq_reuse *fq_reuse;
bool zc; bool zc;
spinlock_t xsk_list_lock; spinlock_t xsk_tx_list_lock;
struct list_head xsk_list; struct list_head xsk_tx_list;
}; };
/* Nodes are linked in the struct xdp_sock map_list field, and used to /* Nodes are linked in the struct xdp_sock map_list field, and used to
......
...@@ -30,9 +30,9 @@ void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs) ...@@ -30,9 +30,9 @@ void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
if (!xs->tx) if (!xs->tx)
return; return;
spin_lock_irqsave(&umem->xsk_list_lock, flags); spin_lock_irqsave(&umem->xsk_tx_list_lock, flags);
list_add_rcu(&xs->list, &umem->xsk_list); list_add_rcu(&xs->list, &umem->xsk_tx_list);
spin_unlock_irqrestore(&umem->xsk_list_lock, flags); spin_unlock_irqrestore(&umem->xsk_tx_list_lock, flags);
} }
void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs) void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
...@@ -42,9 +42,9 @@ void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs) ...@@ -42,9 +42,9 @@ void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs)
if (!xs->tx) if (!xs->tx)
return; return;
spin_lock_irqsave(&umem->xsk_list_lock, flags); spin_lock_irqsave(&umem->xsk_tx_list_lock, flags);
list_del_rcu(&xs->list); list_del_rcu(&xs->list);
spin_unlock_irqrestore(&umem->xsk_list_lock, flags); spin_unlock_irqrestore(&umem->xsk_tx_list_lock, flags);
} }
/* The umem is stored both in the _rx struct and the _tx struct as we do /* The umem is stored both in the _rx struct and the _tx struct as we do
...@@ -395,8 +395,8 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) ...@@ -395,8 +395,8 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
umem->pgs = NULL; umem->pgs = NULL;
umem->user = NULL; umem->user = NULL;
umem->flags = mr->flags; umem->flags = mr->flags;
INIT_LIST_HEAD(&umem->xsk_list); INIT_LIST_HEAD(&umem->xsk_tx_list);
spin_lock_init(&umem->xsk_list_lock); spin_lock_init(&umem->xsk_tx_list_lock);
refcount_set(&umem->users, 1); refcount_set(&umem->users, 1);
......
...@@ -75,7 +75,7 @@ void xsk_set_tx_need_wakeup(struct xdp_umem *umem) ...@@ -75,7 +75,7 @@ void xsk_set_tx_need_wakeup(struct xdp_umem *umem)
return; return;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(xs, &umem->xsk_list, list) { list_for_each_entry_rcu(xs, &umem->xsk_tx_list, list) {
xs->tx->ring->flags |= XDP_RING_NEED_WAKEUP; xs->tx->ring->flags |= XDP_RING_NEED_WAKEUP;
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -102,7 +102,7 @@ void xsk_clear_tx_need_wakeup(struct xdp_umem *umem) ...@@ -102,7 +102,7 @@ void xsk_clear_tx_need_wakeup(struct xdp_umem *umem)
return; return;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(xs, &umem->xsk_list, list) { list_for_each_entry_rcu(xs, &umem->xsk_tx_list, list) {
xs->tx->ring->flags &= ~XDP_RING_NEED_WAKEUP; xs->tx->ring->flags &= ~XDP_RING_NEED_WAKEUP;
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -305,7 +305,7 @@ void xsk_umem_consume_tx_done(struct xdp_umem *umem) ...@@ -305,7 +305,7 @@ void xsk_umem_consume_tx_done(struct xdp_umem *umem)
struct xdp_sock *xs; struct xdp_sock *xs;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(xs, &umem->xsk_list, list) { list_for_each_entry_rcu(xs, &umem->xsk_tx_list, list) {
__xskq_cons_release(xs->tx); __xskq_cons_release(xs->tx);
xs->sk.sk_write_space(&xs->sk); xs->sk.sk_write_space(&xs->sk);
} }
...@@ -318,7 +318,7 @@ bool xsk_umem_consume_tx(struct xdp_umem *umem, struct xdp_desc *desc) ...@@ -318,7 +318,7 @@ bool xsk_umem_consume_tx(struct xdp_umem *umem, struct xdp_desc *desc)
struct xdp_sock *xs; struct xdp_sock *xs;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(xs, &umem->xsk_list, list) { list_for_each_entry_rcu(xs, &umem->xsk_tx_list, list) {
if (!xskq_cons_peek_desc(xs->tx, desc, umem)) if (!xskq_cons_peek_desc(xs->tx, desc, umem))
continue; continue;
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "xsk_queue.h" #include "xsk_queue.h"
void xskq_set_umem(struct xsk_queue *q, u64 size, u64 chunk_mask) void xskq_set_umem(struct xsk_queue *q, u64 umem_size, u64 chunk_mask)
{ {
if (!q) if (!q)
return; return;
q->size = size; q->umem_size = umem_size;
q->chunk_mask = chunk_mask; q->chunk_mask = chunk_mask;
} }
......
...@@ -30,7 +30,7 @@ struct xdp_umem_ring { ...@@ -30,7 +30,7 @@ struct xdp_umem_ring {
struct xsk_queue { struct xsk_queue {
u64 chunk_mask; u64 chunk_mask;
u64 size; u64 umem_size;
u32 ring_mask; u32 ring_mask;
u32 nentries; u32 nentries;
u32 cached_prod; u32 cached_prod;
...@@ -123,7 +123,7 @@ static inline bool xskq_cons_is_valid_unaligned(struct xsk_queue *q, ...@@ -123,7 +123,7 @@ static inline bool xskq_cons_is_valid_unaligned(struct xsk_queue *q,
u64 base_addr = xsk_umem_extract_addr(addr); u64 base_addr = xsk_umem_extract_addr(addr);
addr = xsk_umem_add_offset_to_addr(addr); addr = xsk_umem_add_offset_to_addr(addr);
if (base_addr >= q->size || addr >= q->size || if (base_addr >= q->umem_size || addr >= q->umem_size ||
xskq_cons_crosses_non_contig_pg(umem, addr, length)) { xskq_cons_crosses_non_contig_pg(umem, addr, length)) {
q->invalid_descs++; q->invalid_descs++;
return false; return false;
...@@ -134,7 +134,7 @@ static inline bool xskq_cons_is_valid_unaligned(struct xsk_queue *q, ...@@ -134,7 +134,7 @@ static inline bool xskq_cons_is_valid_unaligned(struct xsk_queue *q,
static inline bool xskq_cons_is_valid_addr(struct xsk_queue *q, u64 addr) static inline bool xskq_cons_is_valid_addr(struct xsk_queue *q, u64 addr)
{ {
if (addr >= q->size) { if (addr >= q->umem_size) {
q->invalid_descs++; q->invalid_descs++;
return false; return false;
} }
...@@ -379,7 +379,7 @@ static inline u64 xskq_nb_invalid_descs(struct xsk_queue *q) ...@@ -379,7 +379,7 @@ static inline u64 xskq_nb_invalid_descs(struct xsk_queue *q)
return q ? q->invalid_descs : 0; return q ? q->invalid_descs : 0;
} }
void xskq_set_umem(struct xsk_queue *q, u64 size, u64 chunk_mask); void xskq_set_umem(struct xsk_queue *q, u64 umem_size, u64 chunk_mask);
struct xsk_queue *xskq_create(u32 nentries, bool umem_queue); struct xsk_queue *xskq_create(u32 nentries, bool umem_queue);
void xskq_destroy(struct xsk_queue *q_ops); void xskq_destroy(struct xsk_queue *q_ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment