1159d2131STariq Toukan /*
2159d2131STariq Toukan  * Copyright (c) 2018, Mellanox Technologies. All rights reserved.
3159d2131STariq Toukan  *
4159d2131STariq Toukan  * This software is available to you under a choice of one of two
5159d2131STariq Toukan  * licenses.  You may choose to be licensed under the terms of the GNU
6159d2131STariq Toukan  * General Public License (GPL) Version 2, available from the file
7159d2131STariq Toukan  * COPYING in the main directory of this source tree, or the
8159d2131STariq Toukan  * OpenIB.org BSD license below:
9159d2131STariq Toukan  *
10159d2131STariq Toukan  *     Redistribution and use in source and binary forms, with or
11159d2131STariq Toukan  *     without modification, are permitted provided that the following
12159d2131STariq Toukan  *     conditions are met:
13159d2131STariq Toukan  *
14159d2131STariq Toukan  *      - Redistributions of source code must retain the above
15159d2131STariq Toukan  *        copyright notice, this list of conditions and the following
16159d2131STariq Toukan  *        disclaimer.
17159d2131STariq Toukan  *
18159d2131STariq Toukan  *      - Redistributions in binary form must reproduce the above
19159d2131STariq Toukan  *        copyright notice, this list of conditions and the following
20159d2131STariq Toukan  *        disclaimer in the documentation and/or other materials
21159d2131STariq Toukan  *        provided with the distribution.
22159d2131STariq Toukan  *
23159d2131STariq Toukan  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24159d2131STariq Toukan  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25159d2131STariq Toukan  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26159d2131STariq Toukan  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27159d2131STariq Toukan  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28159d2131STariq Toukan  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29159d2131STariq Toukan  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30159d2131STariq Toukan  * SOFTWARE.
31159d2131STariq Toukan  */
32159d2131STariq Toukan #ifndef __MLX5_EN_XDP_H__
33159d2131STariq Toukan #define __MLX5_EN_XDP_H__
34159d2131STariq Toukan 
35159d2131STariq Toukan #include "en.h"
36159d2131STariq Toukan 
37159d2131STariq Toukan #define MLX5E_XDP_MAX_MTU ((int)(PAGE_SIZE - \
38159d2131STariq Toukan 				 MLX5_SKB_FRAG_SZ(XDP_PACKET_HEADROOM)))
39159d2131STariq Toukan #define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
40159d2131STariq Toukan #define MLX5E_XDP_TX_DS_COUNT \
41159d2131STariq Toukan 	((sizeof(struct mlx5e_tx_wqe) / MLX5_SEND_WQE_DS) + 1 /* SG DS */)
42159d2131STariq Toukan 
43159d2131STariq Toukan bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
44159d2131STariq Toukan 		      void *va, u16 *rx_headroom, u32 *len);
45feb2ff9dSTariq Toukan bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq);
46feb2ff9dSTariq Toukan void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq);
474fb2f516STariq Toukan void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);
48c94e4f11STariq Toukan bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi);
4958b99ee3STariq Toukan int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
5058b99ee3STariq Toukan 		   u32 flags);
51159d2131STariq Toukan 
52159d2131STariq Toukan static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq)
53159d2131STariq Toukan {
54b8180392STariq Toukan 	if (sq->doorbell_cseg) {
55b8180392STariq Toukan 		mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, sq->doorbell_cseg);
56b8180392STariq Toukan 		sq->doorbell_cseg = NULL;
57b8180392STariq Toukan 	}
58159d2131STariq Toukan }
59159d2131STariq Toukan 
60159d2131STariq Toukan #endif
61