1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2019 Mellanox Technologies. */ 3 4 #ifndef __MLX5_EN_XSK_RX_H__ 5 #define __MLX5_EN_XSK_RX_H__ 6 7 #include "en.h" 8 #include <net/xdp_sock_drv.h> 9 10 /* RX data path */ 11 12 struct sk_buff *mlx5e_xsk_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, 13 struct mlx5e_mpw_info *wi, 14 u16 cqe_bcnt, 15 u32 head_offset, 16 u32 page_idx); 17 struct sk_buff *mlx5e_xsk_skb_from_cqe_linear(struct mlx5e_rq *rq, 18 struct mlx5_cqe64 *cqe, 19 struct mlx5e_wqe_frag_info *wi, 20 u32 cqe_bcnt); 21 22 static inline int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq, 23 struct mlx5e_dma_info *dma_info) 24 { 25 dma_info->xsk = xsk_buff_alloc(rq->umem); 26 if (!dma_info->xsk) 27 return -ENOMEM; 28 29 /* Store the DMA address without headroom. In striding RQ case, we just 30 * provide pages for UMR, and headroom is counted at the setup stage 31 * when creating a WQE. In non-striding RQ case, headroom is accounted 32 * in mlx5e_alloc_rx_wqe. 33 */ 34 dma_info->addr = xsk_buff_xdp_get_frame_dma(dma_info->xsk); 35 36 return 0; 37 } 38 39 static inline bool mlx5e_xsk_update_rx_wakeup(struct mlx5e_rq *rq, bool alloc_err) 40 { 41 if (!xsk_umem_uses_need_wakeup(rq->umem)) 42 return alloc_err; 43 44 if (unlikely(alloc_err)) 45 xsk_set_rx_need_wakeup(rq->umem); 46 else 47 xsk_clear_rx_need_wakeup(rq->umem); 48 49 return false; 50 } 51 52 #endif /* __MLX5_EN_XSK_RX_H__ */ 53