Skip to content

Commit 3fc2333

Browse files
Gerhard Englederkuba-moo
authored andcommitted
tsnep: Add XDP socket zero-copy RX support
Add support for XSK zero-copy to RX path. The setup of the XSK pool can be done at runtime. If the netdev is running, then the queue must be disabled and enabled during reconfiguration. This can be done easily with functions introduced in previous commits. A more important property is that, if the netdev is running, then the setup of the XSK pool shall not stop the netdev in case of errors. A broken netdev after a failed XSK pool setup is bad behavior. Therefore, the allocation and setup of resources during XSK pool setup is done only before any queue is disabled. Additionally, freeing and later allocation of resources is eliminated in some cases. Page pool entries are kept for later use. Two memory models are registered in parallel. As a result, the XSK pool setup cannot fail during queue reconfiguration. In contrast to other drivers, XSK pool setup and XDP BPF program setup are separate actions. XSK pool setup can be done without any XDP BPF program. The XDP BPF program can be added, removed or changed without any reconfiguration of the XSK pool. Test results with A53 1.2GHz: xdpsock rxdrop copy mode, 64 byte frames: pps pkts 1.00 rx 856,054 10,625,775 Two CPUs with both 100% utilization. xdpsock rxdrop zero-copy mode, 64 byte frames: pps pkts 1.00 rx 889,388 4,615,284 Two CPUs with 100% and 20% utilization. Packet rate increases and CPU utilization is reduced. 100% CPU load seems to the base load. This load is consumed by ksoftirqd just for dropping the generated packets without xdpsock running. Using batch API reduced CPU utilization slightly, but measurements are not stable enough to provide meaningful numbers. Signed-off-by: Gerhard Engleder <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c2d6469 commit 3fc2333

File tree

3 files changed

+556
-14
lines changed

3 files changed

+556
-14
lines changed

drivers/net/ethernet/engleder/tsnep.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ struct tsnep_rx_entry {
101101

102102
u32 properties;
103103

104-
struct page *page;
104+
union {
105+
struct page *page;
106+
struct xdp_buff *xdp;
107+
};
105108
size_t len;
106109
dma_addr_t dma;
107110
};
@@ -121,6 +124,9 @@ struct tsnep_rx {
121124
u32 owner_counter;
122125
int increment_owner_counter;
123126
struct page_pool *page_pool;
127+
struct page **page_buffer;
128+
struct xsk_buff_pool *xsk_pool;
129+
struct xdp_buff **xdp_batch;
124130

125131
u32 packets;
126132
u32 bytes;
@@ -129,6 +135,7 @@ struct tsnep_rx {
129135
u32 alloc_failed;
130136

131137
struct xdp_rxq_info xdp_rxq;
138+
struct xdp_rxq_info xdp_rxq_zc;
132139
};
133140

134141
struct tsnep_queue {
@@ -214,6 +221,8 @@ int tsnep_rxnfc_del_rule(struct tsnep_adapter *adapter,
214221

215222
int tsnep_xdp_setup_prog(struct tsnep_adapter *adapter, struct bpf_prog *prog,
216223
struct netlink_ext_ack *extack);
224+
int tsnep_xdp_setup_pool(struct tsnep_adapter *adapter,
225+
struct xsk_buff_pool *pool, u16 queue_id);
217226

218227
#if IS_ENABLED(CONFIG_TSNEP_SELFTESTS)
219228
int tsnep_ethtool_get_test_count(void);
@@ -242,5 +251,7 @@ static inline void tsnep_ethtool_self_test(struct net_device *dev,
242251
void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time);
243252
int tsnep_set_irq_coalesce(struct tsnep_queue *queue, u32 usecs);
244253
u32 tsnep_get_irq_coalesce(struct tsnep_queue *queue);
254+
int tsnep_enable_xsk(struct tsnep_queue *queue, struct xsk_buff_pool *pool);
255+
void tsnep_disable_xsk(struct tsnep_queue *queue);
245256

246257
#endif /* _TSNEP_H */

0 commit comments

Comments
 (0)