xref: /linux/drivers/net/ethernet/intel/ice/ice_xsk.h (revision 06b9cce42634a50f2840777a66553b02320db5ef)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Intel Corporation. */
3 
4 #ifndef _ICE_XSK_H_
5 #define _ICE_XSK_H_
6 #include "ice_txrx.h"
7 #include "ice.h"
8 
9 #define PKTS_PER_BATCH 8
10 
11 #ifdef __clang__
12 #define loop_unrolled_for _Pragma("clang loop unroll_count(8)") for
13 #elif __GNUC__ >= 4
14 #define loop_unrolled_for _Pragma("GCC unroll 8") for
15 #else
16 #define loop_unrolled_for for
17 #endif
18 
19 struct ice_vsi;
20 
21 #ifdef CONFIG_XDP_SOCKETS
22 int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool,
23 		       u16 qid);
24 int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget);
25 int ice_xsk_wakeup(struct net_device *netdev, u32 queue_id, u32 flags);
26 bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count);
27 bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi);
28 void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring);
29 void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring);
30 bool ice_xmit_zc(struct ice_tx_ring *xdp_ring, u32 budget, int napi_budget);
31 #else
32 static inline bool
33 ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_ring,
34 	    u32 __always_unused budget,
35 	    int __always_unused napi_budget)
36 {
37 	return false;
38 }
39 
40 static inline int
41 ice_xsk_pool_setup(struct ice_vsi __always_unused *vsi,
42 		   struct xsk_buff_pool __always_unused *pool,
43 		   u16 __always_unused qid)
44 {
45 	return -EOPNOTSUPP;
46 }
47 
48 static inline int
49 ice_clean_rx_irq_zc(struct ice_rx_ring __always_unused *rx_ring,
50 		    int __always_unused budget)
51 {
52 	return 0;
53 }
54 
55 static inline bool
56 ice_alloc_rx_bufs_zc(struct ice_rx_ring __always_unused *rx_ring,
57 		     u16 __always_unused count)
58 {
59 	return false;
60 }
61 
62 static inline bool ice_xsk_any_rx_ring_ena(struct ice_vsi __always_unused *vsi)
63 {
64 	return false;
65 }
66 
67 static inline int
68 ice_xsk_wakeup(struct net_device __always_unused *netdev,
69 	       u32 __always_unused queue_id, u32 __always_unused flags)
70 {
71 	return -EOPNOTSUPP;
72 }
73 
74 static inline void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring) { }
75 static inline void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring) { }
76 #endif /* CONFIG_XDP_SOCKETS */
77 #endif /* !_ICE_XSK_H_ */
78