Skip to content

Commit d248861

Browse files
fengidrikernel-patches-bot
authored andcommitted
xsk: set tx/rx the min entries
We expect tx entries to be greater than twice the number of packets that the network card can send at a time, so that when the remaining number of the tx queue is less than half of the queue, it can be guaranteed that there are recycled items in the cq that can be used. At the same time, rx will not cause packet loss because it cannot receive the packets uploaded by the network card at one time. Of course, the 1024 here is only an estimated value, and the number of packets sent by each network card at a time may be different. Signed-off-by: Xuan Zhuo <[email protected]>
1 parent d3fac98 commit d248861

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

include/uapi/linux/if_xdp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct xdp_mmap_offsets {
6464
#define XDP_STATISTICS 7
6565
#define XDP_OPTIONS 8
6666

67+
#define XDP_RXTX_RING_MIN_ENTRIES 1024
68+
6769
struct xdp_umem_reg {
6870
__u64 addr; /* Start of packet data area */
6971
__u64 len; /* Length of packet data area */

net/xdp/xsk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ static int xsk_setsockopt(struct socket *sock, int level, int optname,
888888
return -EINVAL;
889889
if (copy_from_sockptr(&entries, optval, sizeof(entries)))
890890
return -EFAULT;
891+
if (entries < XDP_RXTX_RING_MIN_ENTRIES)
892+
return -EINVAL;
891893

892894
mutex_lock(&xs->mutex);
893895
if (xs->state != XSK_READY) {

0 commit comments

Comments
 (0)