• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2018 Netronome Systems, Inc */
3 /* Copyright (C) 2021 Corigine, Inc */
4 
5 #ifndef _NFP_XSK_H_
6 #define _NFP_XSK_H_
7 
8 #include <net/xdp_sock_drv.h>
9 
10 #define NFP_NET_XSK_TX_BATCH 16		/* XSK TX transmission batch size. */
11 
nfp_net_has_xsk_pool_slow(struct nfp_net_dp * dp,unsigned int qid)12 static inline bool nfp_net_has_xsk_pool_slow(struct nfp_net_dp *dp,
13 					     unsigned int qid)
14 {
15 	return dp->xdp_prog && dp->xsk_pools[qid];
16 }
17 
nfp_net_rx_space(struct nfp_net_rx_ring * rx_ring)18 static inline int nfp_net_rx_space(struct nfp_net_rx_ring *rx_ring)
19 {
20 	return rx_ring->cnt - rx_ring->wr_p + rx_ring->rd_p - 1;
21 }
22 
nfp_net_tx_space(struct nfp_net_tx_ring * tx_ring)23 static inline int nfp_net_tx_space(struct nfp_net_tx_ring *tx_ring)
24 {
25 	return tx_ring->cnt - tx_ring->wr_p + tx_ring->rd_p - 1;
26 }
27 
28 void nfp_net_xsk_rx_unstash(struct nfp_net_xsk_rx_buf *rxbuf);
29 void nfp_net_xsk_rx_free(struct nfp_net_xsk_rx_buf *rxbuf);
30 void nfp_net_xsk_rx_drop(struct nfp_net_r_vector *r_vec,
31 			 struct nfp_net_xsk_rx_buf *xrxbuf);
32 int nfp_net_xsk_setup_pool(struct net_device *netdev, struct xsk_buff_pool *pool,
33 			   u16 queue_id);
34 
35 void nfp_net_xsk_rx_bufs_free(struct nfp_net_rx_ring *rx_ring);
36 
37 void nfp_net_xsk_rx_ring_fill_freelist(struct nfp_net_rx_ring *rx_ring);
38 
39 int nfp_net_xsk_wakeup(struct net_device *netdev, u32 queue_id, u32 flags);
40 
41 #endif /* _NFP_XSK_H_ */
42