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 
8 #define PKTS_PER_BATCH 8
9 
10 #ifdef __clang__
11 #define loop_unrolled_for _Pragma("clang loop unroll_count(8)") for
12 #elif __GNUC__ >= 8
13 #define loop_unrolled_for _Pragma("GCC unroll 8") for
14 #else
15 #define loop_unrolled_for for
16 #endif
17 
18 struct ice_vsi;
19 
20 #ifdef CONFIG_XDP_SOCKETS
21 int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool,
22 		       u16 qid);
23 int ice_clean_rx_irq_zc(struct ice_rx_ring *rx_ring, int budget);
24 int ice_xsk_wakeup(struct net_device *netdev, u32 queue_id, u32 flags);
25 bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count);
26 bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi);
27 void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring);
28 void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring);
29 bool ice_xmit_zc(struct ice_tx_ring *xdp_ring, u32 budget, int napi_budget);
30 #else
31 static inline bool
32 ice_xmit_zc(struct ice_tx_ring __always_unused *xdp_ring,
33 	    u32 __always_unused budget,
34 	    int __always_unused napi_budget)
35 {
36 	return false;
37 }
38 
39 static inline int
40 ice_xsk_pool_setup(struct ice_vsi __always_unused *vsi,
41 		   struct xsk_buff_pool __always_unused *pool,
42 		   u16 __always_unused qid)
43 {
44 	return -EOPNOTSUPP;
45 }
46 
47 static inline int
48 ice_clean_rx_irq_zc(struct ice_rx_ring __always_unused *rx_ring,
49 		    int __always_unused budget)
50 {
51 	return 0;
52 }
53 
54 static inline bool
55 ice_alloc_rx_bufs_zc(struct ice_rx_ring __always_unused *rx_ring,
56 		     u16 __always_unused count)
57 {
58 	return false;
59 }
60 
61 static inline bool ice_xsk_any_rx_ring_ena(struct ice_vsi __always_unused *vsi)
62 {
63 	return false;
64 }
65 
66 static inline int
67 ice_xsk_wakeup(struct net_device __always_unused *netdev,
68 	       u32 __always_unused queue_id, u32 __always_unused flags)
69 {
70 	return -EOPNOTSUPP;
71 }
72 
73 static inline void ice_xsk_clean_rx_ring(struct ice_rx_ring *rx_ring) { }
74 static inline void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring) { }
75 #endif /* CONFIG_XDP_SOCKETS */
76 #endif /* !_ICE_XSK_H_ */
77