Skip to content

Commit 9610a8d

Browse files
committed
Merge branch 'tsnep-xdp-socket-zero-copy-support'
Gerhard Engleder says: ==================== tsnep: XDP socket zero-copy support Implement XDP socket zero-copy support for tsnep driver. I tried to follow existing drivers like igc as far as possible. But one main difference is that tsnep does not need any reconfiguration for XDP BPF program setup. So I decided to keep this behavior no matter if a XSK pool is used or not. As a result, tsnep starts using the XSK pool even if no XDP BPF program is available. Another difference is that I tried to prevent potentially failing allocations during XSK pool setup. E.g. both memory models for page pool and XSK pool are registered all the time. Thus, XSK pool setup cannot end up with not working queues. Some prework is done to reduce the last two XSK commits to actual XSK changes. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 938f65a + cd275c2 commit 9610a8d

File tree

3 files changed

+822
-123
lines changed

3 files changed

+822
-123
lines changed

drivers/net/ethernet/engleder/tsnep.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define TSNEP "tsnep"
1919

2020
#define TSNEP_RING_SIZE 256
21+
#define TSNEP_RING_MASK (TSNEP_RING_SIZE - 1)
2122
#define TSNEP_RING_RX_REFILL 16
2223
#define TSNEP_RING_RX_REUSE (TSNEP_RING_SIZE - TSNEP_RING_SIZE / 4)
2324
#define TSNEP_RING_ENTRIES_PER_PAGE (PAGE_SIZE / TSNEP_DESC_SIZE)
@@ -69,6 +70,7 @@ struct tsnep_tx_entry {
6970
union {
7071
struct sk_buff *skb;
7172
struct xdp_frame *xdpf;
73+
bool zc;
7274
};
7375
size_t len;
7476
DEFINE_DMA_UNMAP_ADDR(dma);
@@ -87,6 +89,7 @@ struct tsnep_tx {
8789
int read;
8890
u32 owner_counter;
8991
int increment_owner_counter;
92+
struct xsk_buff_pool *xsk_pool;
9093

9194
u32 packets;
9295
u32 bytes;
@@ -100,7 +103,10 @@ struct tsnep_rx_entry {
100103

101104
u32 properties;
102105

103-
struct page *page;
106+
union {
107+
struct page *page;
108+
struct xdp_buff *xdp;
109+
};
104110
size_t len;
105111
dma_addr_t dma;
106112
};
@@ -120,6 +126,9 @@ struct tsnep_rx {
120126
u32 owner_counter;
121127
int increment_owner_counter;
122128
struct page_pool *page_pool;
129+
struct page **page_buffer;
130+
struct xsk_buff_pool *xsk_pool;
131+
struct xdp_buff **xdp_batch;
123132

124133
u32 packets;
125134
u32 bytes;
@@ -128,6 +137,7 @@ struct tsnep_rx {
128137
u32 alloc_failed;
129138

130139
struct xdp_rxq_info xdp_rxq;
140+
struct xdp_rxq_info xdp_rxq_zc;
131141
};
132142

133143
struct tsnep_queue {
@@ -213,6 +223,8 @@ int tsnep_rxnfc_del_rule(struct tsnep_adapter *adapter,
213223

214224
int tsnep_xdp_setup_prog(struct tsnep_adapter *adapter, struct bpf_prog *prog,
215225
struct netlink_ext_ack *extack);
226+
int tsnep_xdp_setup_pool(struct tsnep_adapter *adapter,
227+
struct xsk_buff_pool *pool, u16 queue_id);
216228

217229
#if IS_ENABLED(CONFIG_TSNEP_SELFTESTS)
218230
int tsnep_ethtool_get_test_count(void);
@@ -241,5 +253,7 @@ static inline void tsnep_ethtool_self_test(struct net_device *dev,
241253
void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time);
242254
int tsnep_set_irq_coalesce(struct tsnep_queue *queue, u32 usecs);
243255
u32 tsnep_get_irq_coalesce(struct tsnep_queue *queue);
256+
int tsnep_enable_xsk(struct tsnep_queue *queue, struct xsk_buff_pool *pool);
257+
void tsnep_disable_xsk(struct tsnep_queue *queue);
244258

245259
#endif /* _TSNEP_H */

0 commit comments

Comments
 (0)