xref: /dpdk/drivers/net/intel/ice/ice_rxtx.h (revision c038157a2e4416338bb5c7171ae7d611c454045d)
1c1d14583SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2c1d14583SBruce Richardson  * Copyright(c) 2018 Intel Corporation
3c1d14583SBruce Richardson  */
4c1d14583SBruce Richardson 
5c1d14583SBruce Richardson #ifndef _ICE_RXTX_H_
6c1d14583SBruce Richardson #define _ICE_RXTX_H_
7c1d14583SBruce Richardson 
85cc9919fSBruce Richardson #include "../common/tx.h"
9c1d14583SBruce Richardson #include "ice_ethdev.h"
10c1d14583SBruce Richardson 
11c1d14583SBruce Richardson #define ICE_ALIGN_RING_DESC  32
12c1d14583SBruce Richardson #define ICE_MIN_RING_DESC    64
13c1d14583SBruce Richardson #define ICE_MAX_RING_DESC    (8192 - 32)
14c1d14583SBruce Richardson #define ICE_DMA_MEM_ALIGN    4096
15c1d14583SBruce Richardson #define ICE_RING_BASE_ALIGN  128
16c1d14583SBruce Richardson 
17c1d14583SBruce Richardson #define ICE_RX_MAX_BURST 32
18c1d14583SBruce Richardson #define ICE_TX_MAX_BURST 32
19c1d14583SBruce Richardson 
20c1d14583SBruce Richardson /* Maximal number of segments to split. */
21c1d14583SBruce Richardson #define ICE_RX_MAX_NSEG 2
22c1d14583SBruce Richardson 
23c1d14583SBruce Richardson #define ICE_CHK_Q_ENA_COUNT        100
24c1d14583SBruce Richardson #define ICE_CHK_Q_ENA_INTERVAL_US  100
25c1d14583SBruce Richardson 
26c1d14583SBruce Richardson #ifdef RTE_LIBRTE_ICE_16BYTE_RX_DESC
27c1d14583SBruce Richardson #define ice_rx_flex_desc ice_16b_rx_flex_desc
28c1d14583SBruce Richardson #else
29c1d14583SBruce Richardson #define ice_rx_flex_desc ice_32b_rx_flex_desc
30c1d14583SBruce Richardson #endif
31c1d14583SBruce Richardson 
32c1d14583SBruce Richardson #define ICE_SUPPORT_CHAIN_NUM 5
33c1d14583SBruce Richardson 
34c1d14583SBruce Richardson #define ICE_TD_CMD                      ICE_TX_DESC_CMD_EOP
35c1d14583SBruce Richardson 
36c1d14583SBruce Richardson #define ICE_VPMD_RX_BURST           32
37c1d14583SBruce Richardson #define ICE_VPMD_TX_BURST           32
38c1d14583SBruce Richardson #define ICE_RXQ_REARM_THRESH        64
39c1d14583SBruce Richardson #define ICE_MAX_RX_BURST            ICE_RXQ_REARM_THRESH
40c1d14583SBruce Richardson #define ICE_TX_MAX_FREE_BUF_SZ      64
41c1d14583SBruce Richardson #define ICE_DESCS_PER_LOOP          4
42c1d14583SBruce Richardson 
43c1d14583SBruce Richardson #define ICE_FDIR_PKT_LEN	512
44c1d14583SBruce Richardson 
45c1d14583SBruce Richardson #define ICE_RXDID_COMMS_OVS	22
46c1d14583SBruce Richardson 
47c1d14583SBruce Richardson #define ICE_TX_MIN_PKT_LEN 17
48c1d14583SBruce Richardson 
49c1d14583SBruce Richardson #define ICE_TX_OFFLOAD_MASK (    \
50c1d14583SBruce Richardson 		RTE_MBUF_F_TX_OUTER_IPV6 |	 \
51c1d14583SBruce Richardson 		RTE_MBUF_F_TX_OUTER_IPV4 |	 \
52c1d14583SBruce Richardson 		RTE_MBUF_F_TX_OUTER_IP_CKSUM |  \
53c1d14583SBruce Richardson 		RTE_MBUF_F_TX_VLAN |        \
54c1d14583SBruce Richardson 		RTE_MBUF_F_TX_IPV6 |		 \
55c1d14583SBruce Richardson 		RTE_MBUF_F_TX_IPV4 |		 \
56c1d14583SBruce Richardson 		RTE_MBUF_F_TX_IP_CKSUM |        \
57c1d14583SBruce Richardson 		RTE_MBUF_F_TX_L4_MASK |         \
58c1d14583SBruce Richardson 		RTE_MBUF_F_TX_IEEE1588_TMST |	 \
59c1d14583SBruce Richardson 		RTE_MBUF_F_TX_TCP_SEG |         \
60c1d14583SBruce Richardson 		RTE_MBUF_F_TX_QINQ |        \
61c1d14583SBruce Richardson 		RTE_MBUF_F_TX_TUNNEL_MASK |	 \
62c1d14583SBruce Richardson 		RTE_MBUF_F_TX_UDP_SEG |	 \
63c1d14583SBruce Richardson 		RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
64c1d14583SBruce Richardson 
65c1d14583SBruce Richardson #define ICE_TX_OFFLOAD_NOTSUP_MASK \
66c1d14583SBruce Richardson 		(RTE_MBUF_F_TX_OFFLOAD_MASK ^ ICE_TX_OFFLOAD_MASK)
67c1d14583SBruce Richardson 
68c1d14583SBruce Richardson extern uint64_t ice_timestamp_dynflag;
69c1d14583SBruce Richardson extern int ice_timestamp_dynfield_offset;
70c1d14583SBruce Richardson 
71c1d14583SBruce Richardson /* Max header size can be 2K - 64 bytes */
72c1d14583SBruce Richardson #define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
73c1d14583SBruce Richardson 
74c1d14583SBruce Richardson /* Max data buffer size must be 16K - 128 bytes */
75c1d14583SBruce Richardson #define ICE_RX_MAX_DATA_BUF_SIZE	(16 * 1024 - 128)
76c1d14583SBruce Richardson 
77c1d14583SBruce Richardson #define ICE_HEADER_SPLIT_ENA   BIT(0)
78c1d14583SBruce Richardson 
79c1d14583SBruce Richardson #define ICE_TX_MTU_SEG_MAX	8
80c1d14583SBruce Richardson 
81c1d14583SBruce Richardson typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
82c1d14583SBruce Richardson typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
83c1d14583SBruce Richardson 					struct rte_mbuf *mb,
84c1d14583SBruce Richardson 					volatile union ice_rx_flex_desc *rxdp);
85c1d14583SBruce Richardson 
86c1d14583SBruce Richardson struct ice_rx_entry {
87c1d14583SBruce Richardson 	struct rte_mbuf *mbuf;
88c1d14583SBruce Richardson };
89c1d14583SBruce Richardson 
90c1d14583SBruce Richardson enum ice_rx_dtype {
91c1d14583SBruce Richardson 	ICE_RX_DTYPE_NO_SPLIT       = 0,
92c1d14583SBruce Richardson 	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
93c1d14583SBruce Richardson 	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
94c1d14583SBruce Richardson };
95c1d14583SBruce Richardson 
96c1d14583SBruce Richardson struct ice_rx_queue {
97c1d14583SBruce Richardson 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
98c1d14583SBruce Richardson 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
99c1d14583SBruce Richardson 	rte_iova_t rx_ring_dma; /* RX ring DMA address */
100c1d14583SBruce Richardson 	struct ice_rx_entry *sw_ring; /* address of RX soft ring */
101c1d14583SBruce Richardson 	uint16_t nb_rx_desc; /* number of RX descriptors */
102c1d14583SBruce Richardson 	uint16_t rx_free_thresh; /* max free RX desc to hold */
103c1d14583SBruce Richardson 	uint16_t rx_tail; /* current value of tail */
104c1d14583SBruce Richardson 	uint16_t nb_rx_hold; /* number of held free RX desc */
105c1d14583SBruce Richardson 	struct rte_mbuf *pkt_first_seg; /**< first segment of current packet */
106c1d14583SBruce Richardson 	struct rte_mbuf *pkt_last_seg; /**< last segment of current packet */
107c1d14583SBruce Richardson 	uint16_t rx_nb_avail; /**< number of staged packets ready */
108c1d14583SBruce Richardson 	uint16_t rx_next_avail; /**< index of next staged packets */
109c1d14583SBruce Richardson 	uint16_t rx_free_trigger; /**< triggers rx buffer allocation */
110c1d14583SBruce Richardson 	struct rte_mbuf fake_mbuf; /**< dummy mbuf */
111c1d14583SBruce Richardson 	struct rte_mbuf *rx_stage[ICE_RX_MAX_BURST * 2];
112c1d14583SBruce Richardson 
113c1d14583SBruce Richardson 	uint16_t rxrearm_nb;	/**< number of remaining to be re-armed */
114c1d14583SBruce Richardson 	uint16_t rxrearm_start;	/**< the idx we start the re-arming from */
115c1d14583SBruce Richardson 	uint64_t mbuf_initializer; /**< value to init mbufs */
116c1d14583SBruce Richardson 
117c1d14583SBruce Richardson 	uint16_t port_id; /* device port ID */
118c1d14583SBruce Richardson 	uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */
119c1d14583SBruce Richardson 	uint8_t fdir_enabled; /* 0 if FDIR disabled, 1 when enabled */
120c1d14583SBruce Richardson 	uint16_t queue_id; /* RX queue index */
121c1d14583SBruce Richardson 	uint16_t reg_idx; /* RX queue register index */
122c1d14583SBruce Richardson 	uint8_t drop_en; /* if not 0, set register bit */
123c1d14583SBruce Richardson 	volatile uint8_t *qrx_tail; /* register address of tail */
124c1d14583SBruce Richardson 	struct ice_vsi *vsi; /* the VSI this queue belongs to */
125c1d14583SBruce Richardson 	uint16_t rx_buf_len; /* The packet buffer size */
126c1d14583SBruce Richardson 	uint16_t rx_hdr_len; /* The header buffer size */
127c1d14583SBruce Richardson 	uint16_t max_pkt_len; /* Maximum packet length */
128c1d14583SBruce Richardson 	bool q_set; /* indicate if rx queue has been configured */
129c1d14583SBruce Richardson 	bool rx_deferred_start; /* don't start this queue in dev start */
130c1d14583SBruce Richardson 	uint8_t proto_xtr; /* Protocol extraction from flexible descriptor */
131c1d14583SBruce Richardson 	int xtr_field_offs; /*Protocol extraction matedata offset*/
132c1d14583SBruce Richardson 	uint64_t xtr_ol_flag; /* Protocol extraction offload flag */
133c1d14583SBruce Richardson 	uint32_t rxdid; /* Receive Flex Descriptor profile ID */
134c1d14583SBruce Richardson 	ice_rx_release_mbufs_t rx_rel_mbufs;
135c1d14583SBruce Richardson 	uint64_t offloads;
136c1d14583SBruce Richardson 	uint32_t time_high;
137c1d14583SBruce Richardson 	uint32_t hw_register_set;
138c1d14583SBruce Richardson 	const struct rte_memzone *mz;
139c1d14583SBruce Richardson 	uint32_t hw_time_high; /* high 32 bits of timestamp */
140c1d14583SBruce Richardson 	uint32_t hw_time_low; /* low 32 bits of timestamp */
141c1d14583SBruce Richardson 	uint64_t hw_time_update; /* SW time of HW record updating */
142c1d14583SBruce Richardson 	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
143c1d14583SBruce Richardson 	uint32_t rxseg_nb;
144c1d14583SBruce Richardson 	bool ts_enable; /* if rxq timestamp is enabled */
145c1d14583SBruce Richardson };
146c1d14583SBruce Richardson 
147c1d14583SBruce Richardson /* Offload features */
148c1d14583SBruce Richardson union ice_tx_offload {
149c1d14583SBruce Richardson 	uint64_t data;
150c1d14583SBruce Richardson 	struct {
151c1d14583SBruce Richardson 		uint64_t l2_len:7; /* L2 (MAC) Header Length. */
152c1d14583SBruce Richardson 		uint64_t l3_len:9; /* L3 (IP) Header Length. */
153c1d14583SBruce Richardson 		uint64_t l4_len:8; /* L4 Header Length. */
154c1d14583SBruce Richardson 		uint64_t tso_segsz:16; /* TCP TSO segment size */
155c1d14583SBruce Richardson 		uint64_t outer_l2_len:8; /* outer L2 Header Length */
156c1d14583SBruce Richardson 		uint64_t outer_l3_len:16; /* outer L3 Header Length */
157c1d14583SBruce Richardson 	};
158c1d14583SBruce Richardson };
159c1d14583SBruce Richardson 
160c1d14583SBruce Richardson /* Rx Flex Descriptor for Comms Package Profile
161c1d14583SBruce Richardson  * RxDID Profile ID 22 (swap Hash and FlowID)
162c1d14583SBruce Richardson  * Flex-field 0: Flow ID lower 16-bits
163c1d14583SBruce Richardson  * Flex-field 1: Flow ID upper 16-bits
164c1d14583SBruce Richardson  * Flex-field 2: RSS hash lower 16-bits
165c1d14583SBruce Richardson  * Flex-field 3: RSS hash upper 16-bits
166c1d14583SBruce Richardson  * Flex-field 4: AUX0
167c1d14583SBruce Richardson  * Flex-field 5: AUX1
168c1d14583SBruce Richardson  */
169c1d14583SBruce Richardson struct ice_32b_rx_flex_desc_comms_ovs {
170c1d14583SBruce Richardson 	/* Qword 0 */
171c1d14583SBruce Richardson 	u8 rxdid;
172c1d14583SBruce Richardson 	u8 mir_id_umb_cast;
173c1d14583SBruce Richardson 	__le16 ptype_flexi_flags0;
174c1d14583SBruce Richardson 	__le16 pkt_len;
175c1d14583SBruce Richardson 	__le16 hdr_len_sph_flex_flags1;
176c1d14583SBruce Richardson 
177c1d14583SBruce Richardson 	/* Qword 1 */
178c1d14583SBruce Richardson 	__le16 status_error0;
179c1d14583SBruce Richardson 	__le16 l2tag1;
180c1d14583SBruce Richardson 	__le32 flow_id;
181c1d14583SBruce Richardson 
182c1d14583SBruce Richardson 	/* Qword 2 */
183c1d14583SBruce Richardson 	__le16 status_error1;
184c1d14583SBruce Richardson 	u8 flexi_flags2;
185c1d14583SBruce Richardson 	u8 ts_low;
186c1d14583SBruce Richardson 	__le16 l2tag2_1st;
187c1d14583SBruce Richardson 	__le16 l2tag2_2nd;
188c1d14583SBruce Richardson 
189c1d14583SBruce Richardson 	/* Qword 3 */
190c1d14583SBruce Richardson 	__le32 rss_hash;
191c1d14583SBruce Richardson 	union {
192c1d14583SBruce Richardson 		struct {
193c1d14583SBruce Richardson 			__le16 aux0;
194c1d14583SBruce Richardson 			__le16 aux1;
195c1d14583SBruce Richardson 		} flex;
196c1d14583SBruce Richardson 		__le32 ts_high;
197c1d14583SBruce Richardson 	} flex_ts;
198c1d14583SBruce Richardson };
199c1d14583SBruce Richardson 
200c1d14583SBruce Richardson int ice_rx_queue_setup(struct rte_eth_dev *dev,
201c1d14583SBruce Richardson 		       uint16_t queue_idx,
202c1d14583SBruce Richardson 		       uint16_t nb_desc,
203c1d14583SBruce Richardson 		       unsigned int socket_id,
204c1d14583SBruce Richardson 		       const struct rte_eth_rxconf *rx_conf,
205c1d14583SBruce Richardson 		       struct rte_mempool *mp);
206c1d14583SBruce Richardson int ice_tx_queue_setup(struct rte_eth_dev *dev,
207c1d14583SBruce Richardson 		       uint16_t queue_idx,
208c1d14583SBruce Richardson 		       uint16_t nb_desc,
209c1d14583SBruce Richardson 		       unsigned int socket_id,
210c1d14583SBruce Richardson 		       const struct rte_eth_txconf *tx_conf);
211c1d14583SBruce Richardson int ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
212c1d14583SBruce Richardson int ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
213c1d14583SBruce Richardson int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
214c1d14583SBruce Richardson int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
215c1d14583SBruce Richardson int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
216c1d14583SBruce Richardson int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
217c1d14583SBruce Richardson int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
218c1d14583SBruce Richardson int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
219c1d14583SBruce Richardson void ice_rx_queue_release(void *rxq);
220c1d14583SBruce Richardson void ice_tx_queue_release(void *txq);
221c1d14583SBruce Richardson void ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
222c1d14583SBruce Richardson void ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
223c1d14583SBruce Richardson void ice_free_queues(struct rte_eth_dev *dev);
224c1d14583SBruce Richardson int ice_fdir_setup_tx_resources(struct ice_pf *pf);
225c1d14583SBruce Richardson int ice_fdir_setup_rx_resources(struct ice_pf *pf);
226c1d14583SBruce Richardson uint16_t ice_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
227c1d14583SBruce Richardson 		       uint16_t nb_pkts);
228c1d14583SBruce Richardson uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
229c1d14583SBruce Richardson 		       uint16_t nb_pkts);
230c1d14583SBruce Richardson void ice_set_rx_function(struct rte_eth_dev *dev);
231c1d14583SBruce Richardson uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
232c1d14583SBruce Richardson 		       uint16_t nb_pkts);
233c1d14583SBruce Richardson void ice_set_tx_function_flag(struct rte_eth_dev *dev,
234*c038157aSBruce Richardson 			      struct ci_tx_queue *txq);
235c1d14583SBruce Richardson void ice_set_tx_function(struct rte_eth_dev *dev);
236c1d14583SBruce Richardson uint32_t ice_rx_queue_count(void *rx_queue);
237c1d14583SBruce Richardson void ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
238c1d14583SBruce Richardson 		      struct rte_eth_rxq_info *qinfo);
239c1d14583SBruce Richardson void ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
240c1d14583SBruce Richardson 		      struct rte_eth_txq_info *qinfo);
241c1d14583SBruce Richardson int ice_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
242c1d14583SBruce Richardson 			  struct rte_eth_burst_mode *mode);
243c1d14583SBruce Richardson int ice_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
244c1d14583SBruce Richardson 			  struct rte_eth_burst_mode *mode);
245c1d14583SBruce Richardson int ice_rx_descriptor_status(void *rx_queue, uint16_t offset);
246c1d14583SBruce Richardson int ice_tx_descriptor_status(void *tx_queue, uint16_t offset);
247c1d14583SBruce Richardson void ice_set_default_ptype_table(struct rte_eth_dev *dev);
248c1d14583SBruce Richardson const uint32_t *ice_dev_supported_ptypes_get(struct rte_eth_dev *dev,
249c1d14583SBruce Richardson 					     size_t *no_of_elements);
250c1d14583SBruce Richardson void ice_select_rxd_to_pkt_fields_handler(struct ice_rx_queue *rxq,
251c1d14583SBruce Richardson 					  uint32_t rxdid);
252c1d14583SBruce Richardson 
253c1d14583SBruce Richardson int ice_rx_vec_dev_check(struct rte_eth_dev *dev);
254c1d14583SBruce Richardson int ice_tx_vec_dev_check(struct rte_eth_dev *dev);
255c1d14583SBruce Richardson int ice_rxq_vec_setup(struct ice_rx_queue *rxq);
256*c038157aSBruce Richardson int ice_txq_vec_setup(struct ci_tx_queue *txq);
257c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
258c1d14583SBruce Richardson 			   uint16_t nb_pkts);
259c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
260c1d14583SBruce Richardson 				     uint16_t nb_pkts);
261c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
262c1d14583SBruce Richardson 			   uint16_t nb_pkts);
263c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
264c1d14583SBruce Richardson 				uint16_t nb_pkts);
265c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts,
266c1d14583SBruce Richardson 					uint16_t nb_pkts);
267c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue,
268c1d14583SBruce Richardson 					  struct rte_mbuf **rx_pkts,
269c1d14583SBruce Richardson 					  uint16_t nb_pkts);
270c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue,
271c1d14583SBruce Richardson 						  struct rte_mbuf **rx_pkts,
272c1d14583SBruce Richardson 						  uint16_t nb_pkts);
273c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
274c1d14583SBruce Richardson 				uint16_t nb_pkts);
275c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
276c1d14583SBruce Richardson 					uint16_t nb_pkts);
277c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
278c1d14583SBruce Richardson 				  uint16_t nb_pkts);
279c1d14583SBruce Richardson uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue,
280c1d14583SBruce Richardson 					  struct rte_mbuf **rx_pkts,
281c1d14583SBruce Richardson 					  uint16_t nb_pkts);
282c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx512(void *rx_queue,
283c1d14583SBruce Richardson 					    struct rte_mbuf **rx_pkts,
284c1d14583SBruce Richardson 					    uint16_t nb_pkts);
285c1d14583SBruce Richardson uint16_t ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
286c1d14583SBruce Richardson 						    struct rte_mbuf **rx_pkts,
287c1d14583SBruce Richardson 						    uint16_t nb_pkts);
288c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
289c1d14583SBruce Richardson 				  uint16_t nb_pkts);
290c1d14583SBruce Richardson uint16_t ice_xmit_pkts_vec_avx512_offload(void *tx_queue,
291c1d14583SBruce Richardson 					  struct rte_mbuf **tx_pkts,
292c1d14583SBruce Richardson 					  uint16_t nb_pkts);
293c1d14583SBruce Richardson int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
294c1d14583SBruce Richardson int ice_tx_done_cleanup(void *txq, uint32_t free_cnt);
295c1d14583SBruce Richardson int ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
296c1d14583SBruce Richardson 
297c1d14583SBruce Richardson #define FDIR_PARSING_ENABLE_PER_QUEUE(ad, on) do { \
298c1d14583SBruce Richardson 	int i; \
299c1d14583SBruce Richardson 	for (i = 0; i < (ad)->pf.dev_data->nb_rx_queues; i++) { \
300c1d14583SBruce Richardson 		struct ice_rx_queue *rxq = (ad)->pf.dev_data->rx_queues[i]; \
301c1d14583SBruce Richardson 		if (!rxq) \
302c1d14583SBruce Richardson 			continue; \
303c1d14583SBruce Richardson 		rxq->fdir_enabled = on; \
304c1d14583SBruce Richardson 	} \
305c1d14583SBruce Richardson 	PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
306c1d14583SBruce Richardson } while (0)
307c1d14583SBruce Richardson 
308c1d14583SBruce Richardson /* Enable/disable flow director parsing from Rx descriptor in data path. */
309c1d14583SBruce Richardson static inline
310c1d14583SBruce Richardson void ice_fdir_rx_parsing_enable(struct ice_adapter *ad, bool on)
311c1d14583SBruce Richardson {
312c1d14583SBruce Richardson 	if (on) {
313c1d14583SBruce Richardson 		/* Enable flow director parsing from Rx descriptor */
314c1d14583SBruce Richardson 		FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
315c1d14583SBruce Richardson 		ad->fdir_ref_cnt++;
316c1d14583SBruce Richardson 	} else {
317c1d14583SBruce Richardson 		if (ad->fdir_ref_cnt >= 1) {
318c1d14583SBruce Richardson 			ad->fdir_ref_cnt--;
319c1d14583SBruce Richardson 
320c1d14583SBruce Richardson 			if (ad->fdir_ref_cnt == 0)
321c1d14583SBruce Richardson 				FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
322c1d14583SBruce Richardson 		}
323c1d14583SBruce Richardson 	}
324c1d14583SBruce Richardson }
325c1d14583SBruce Richardson 
326c1d14583SBruce Richardson #define ICE_TIMESYNC_REG_WRAP_GUARD_BAND  10000
327c1d14583SBruce Richardson 
328c1d14583SBruce Richardson /* Helper function to convert a 32b nanoseconds timestamp to 64b. */
329c1d14583SBruce Richardson static inline
330c1d14583SBruce Richardson uint64_t ice_tstamp_convert_32b_64b(struct ice_hw *hw, struct ice_adapter *ad,
331c1d14583SBruce Richardson 				    uint32_t flag, uint32_t in_timestamp)
332c1d14583SBruce Richardson {
333c1d14583SBruce Richardson 	uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
334c1d14583SBruce Richardson 	const uint64_t mask = 0xFFFFFFFF;
335c1d14583SBruce Richardson 	uint32_t hi, lo, lo2, delta;
336c1d14583SBruce Richardson 	uint64_t ns;
337c1d14583SBruce Richardson 
338c1d14583SBruce Richardson 	if (flag) {
339c1d14583SBruce Richardson 		lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
340c1d14583SBruce Richardson 		hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
341c1d14583SBruce Richardson 
342c1d14583SBruce Richardson 		/*
343c1d14583SBruce Richardson 		 * On typical system, the delta between lo and lo2 is ~1000ns,
344c1d14583SBruce Richardson 		 * so 10000 seems a large-enough but not overly-big guard band.
345c1d14583SBruce Richardson 		 */
346c1d14583SBruce Richardson 		if (lo > (UINT32_MAX - ICE_TIMESYNC_REG_WRAP_GUARD_BAND))
347c1d14583SBruce Richardson 			lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
348c1d14583SBruce Richardson 		else
349c1d14583SBruce Richardson 			lo2 = lo;
350c1d14583SBruce Richardson 
351c1d14583SBruce Richardson 		if (lo2 < lo) {
352c1d14583SBruce Richardson 			lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
353c1d14583SBruce Richardson 			hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
354c1d14583SBruce Richardson 		}
355c1d14583SBruce Richardson 
356c1d14583SBruce Richardson 		ad->time_hw = ((uint64_t)hi << 32) | lo;
357c1d14583SBruce Richardson 	}
358c1d14583SBruce Richardson 
359c1d14583SBruce Richardson 	delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
360c1d14583SBruce Richardson 	if (delta > (mask / 2)) {
361c1d14583SBruce Richardson 		delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
362c1d14583SBruce Richardson 		ns = ad->time_hw - delta;
363c1d14583SBruce Richardson 	} else {
364c1d14583SBruce Richardson 		ns = ad->time_hw + delta;
365c1d14583SBruce Richardson 	}
366c1d14583SBruce Richardson 
367c1d14583SBruce Richardson 	return ns;
368c1d14583SBruce Richardson }
369c1d14583SBruce Richardson 
370c1d14583SBruce Richardson #endif /* _ICE_RXTX_H_ */
371