xref: /openbmc/linux/drivers/net/ethernet/netronome/nfp/nfp_net_xsk.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
16402528bSNiklas Söderlund /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
26402528bSNiklas Söderlund /* Copyright (C) 2018 Netronome Systems, Inc */
36402528bSNiklas Söderlund /* Copyright (C) 2021 Corigine, Inc */
46402528bSNiklas Söderlund 
56402528bSNiklas Söderlund #ifndef _NFP_XSK_H_
66402528bSNiklas Söderlund #define _NFP_XSK_H_
76402528bSNiklas Söderlund 
86402528bSNiklas Söderlund #include <net/xdp_sock_drv.h>
96402528bSNiklas Söderlund 
106402528bSNiklas Söderlund #define NFP_NET_XSK_TX_BATCH 16		/* XSK TX transmission batch size. */
116402528bSNiklas Söderlund 
nfp_net_has_xsk_pool_slow(struct nfp_net_dp * dp,unsigned int qid)126402528bSNiklas Söderlund static inline bool nfp_net_has_xsk_pool_slow(struct nfp_net_dp *dp,
136402528bSNiklas Söderlund 					     unsigned int qid)
146402528bSNiklas Söderlund {
156402528bSNiklas Söderlund 	return dp->xdp_prog && dp->xsk_pools[qid];
166402528bSNiklas Söderlund }
176402528bSNiklas Söderlund 
nfp_net_rx_space(struct nfp_net_rx_ring * rx_ring)18*62d03330SJakub Kicinski static inline int nfp_net_rx_space(struct nfp_net_rx_ring *rx_ring)
19*62d03330SJakub Kicinski {
20*62d03330SJakub Kicinski 	return rx_ring->cnt - rx_ring->wr_p + rx_ring->rd_p - 1;
21*62d03330SJakub Kicinski }
22*62d03330SJakub Kicinski 
nfp_net_tx_space(struct nfp_net_tx_ring * tx_ring)23*62d03330SJakub Kicinski static inline int nfp_net_tx_space(struct nfp_net_tx_ring *tx_ring)
24*62d03330SJakub Kicinski {
25*62d03330SJakub Kicinski 	return tx_ring->cnt - tx_ring->wr_p + tx_ring->rd_p - 1;
26*62d03330SJakub Kicinski }
27*62d03330SJakub Kicinski 
28*62d03330SJakub Kicinski void nfp_net_xsk_rx_unstash(struct nfp_net_xsk_rx_buf *rxbuf);
29*62d03330SJakub Kicinski void nfp_net_xsk_rx_free(struct nfp_net_xsk_rx_buf *rxbuf);
30*62d03330SJakub Kicinski void nfp_net_xsk_rx_drop(struct nfp_net_r_vector *r_vec,
31*62d03330SJakub Kicinski 			 struct nfp_net_xsk_rx_buf *xrxbuf);
326402528bSNiklas Söderlund int nfp_net_xsk_setup_pool(struct net_device *netdev, struct xsk_buff_pool *pool,
336402528bSNiklas Söderlund 			   u16 queue_id);
346402528bSNiklas Söderlund 
356402528bSNiklas Söderlund void nfp_net_xsk_rx_bufs_free(struct nfp_net_rx_ring *rx_ring);
366402528bSNiklas Söderlund 
376402528bSNiklas Söderlund void nfp_net_xsk_rx_ring_fill_freelist(struct nfp_net_rx_ring *rx_ring);
386402528bSNiklas Söderlund 
396402528bSNiklas Söderlund int nfp_net_xsk_wakeup(struct net_device *netdev, u32 queue_id, u32 flags);
406402528bSNiklas Söderlund 
416402528bSNiklas Söderlund #endif /* _NFP_XSK_H_ */
42