Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _ICE_RXTX_H_
6 : : #define _ICE_RXTX_H_
7 : :
8 : : #include "../common/rx.h"
9 : : #include "../common/tx.h"
10 : : #include "ice_ethdev.h"
11 : :
12 : : #define FIELD_GET(_mask, _reg) \
13 : : (__extension__ ({ \
14 : : typeof(_mask) _x = (_mask); \
15 : : (typeof(_x))(((_reg) & (_x)) >> rte_bsf32(_x)); \
16 : : }))
17 : : #define FIELD_PREP(_mask, _val) \
18 : : (__extension__ ({ \
19 : : typeof(_mask) _x = (_mask); \
20 : : ((typeof(_x))(_val) << rte_bsf32(_x)) & (_x); \
21 : : }))
22 : :
23 : : #define ICE_ALIGN_RING_DESC 32
24 : : #define ICE_MIN_RING_DESC 64
25 : : #define ICE_MAX_RING_DESC (8192 - 32)
26 : : #define ICE_MAX_RING_DESC_E830 8096
27 : : #define ICE_MAX_NUM_DESC_BY_MAC(hw) ((hw)->phy_model == \
28 : : ICE_PHY_E830 ? \
29 : : ICE_MAX_RING_DESC_E830 : \
30 : : ICE_MAX_RING_DESC)
31 : : #define ICE_DMA_MEM_ALIGN 4096
32 : : #define ICE_RING_BASE_ALIGN 128
33 : :
34 : : #define ICE_TXTIME_TX_DESC_IDX_M RTE_GENMASK32(12, 0)
35 : : #define ICE_TXTIME_STAMP_M RTE_GENMASK32(31, 13)
36 : : #define ICE_REQ_DESC_MULTIPLE 32
37 : :
38 : : #define ICE_RX_MAX_BURST CI_RX_MAX_BURST
39 : : #define ICE_TX_MAX_BURST 32
40 : :
41 : : /* Maximal number of segments to split. */
42 : : #define ICE_RX_MAX_NSEG CI_RX_MAX_NSEG
43 : :
44 : : #define ICE_CHK_Q_ENA_COUNT 100
45 : : #define ICE_CHK_Q_ENA_INTERVAL_US 100
46 : :
47 : : #define ICE_SUPPORT_CHAIN_NUM 5
48 : :
49 : : #define ICE_VPMD_RX_BURST CI_VPMD_RX_BURST
50 : : #define ICE_VPMD_TX_BURST 32
51 : : #define ICE_VPMD_RXQ_REARM_THRESH CI_VPMD_RX_REARM_THRESH
52 : : #define ICE_TX_MAX_FREE_BUF_SZ 64
53 : : #define ICE_VPMD_DESCS_PER_LOOP CI_VPMD_DESCS_PER_LOOP
54 : : #define ICE_VPMD_DESCS_PER_LOOP_WIDE CI_VPMD_DESCS_PER_LOOP_WIDE
55 : :
56 : : #define ICE_FDIR_PKT_LEN 512
57 : :
58 : : #define ICE_RXDID_COMMS_OVS 22
59 : :
60 : : #define ICE_TX_MIN_PKT_LEN 17
61 : :
62 : : #define ICE_TX_OFFLOAD_MASK ( \
63 : : RTE_MBUF_F_TX_OUTER_IPV6 | \
64 : : RTE_MBUF_F_TX_OUTER_IPV4 | \
65 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
66 : : RTE_MBUF_F_TX_VLAN | \
67 : : RTE_MBUF_F_TX_IPV6 | \
68 : : RTE_MBUF_F_TX_IPV4 | \
69 : : RTE_MBUF_F_TX_IP_CKSUM | \
70 : : RTE_MBUF_F_TX_L4_MASK | \
71 : : RTE_MBUF_F_TX_IEEE1588_TMST | \
72 : : RTE_MBUF_F_TX_TCP_SEG | \
73 : : RTE_MBUF_F_TX_QINQ | \
74 : : RTE_MBUF_F_TX_TUNNEL_MASK | \
75 : : RTE_MBUF_F_TX_UDP_SEG | \
76 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
77 : :
78 : : #define ICE_TX_OFFLOAD_NOTSUP_MASK \
79 : : (RTE_MBUF_F_TX_OFFLOAD_MASK ^ ICE_TX_OFFLOAD_MASK)
80 : :
81 : : /* basic scalar path */
82 : : #define ICE_RX_SCALAR_OFFLOADS ( \
83 : : RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
84 : : RTE_ETH_RX_OFFLOAD_KEEP_CRC | \
85 : : RTE_ETH_RX_OFFLOAD_SCATTER | \
86 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
87 : : RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
88 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
89 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \
90 : : RTE_ETH_RX_OFFLOAD_QINQ_STRIP | \
91 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | \
92 : : RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
93 : : RTE_ETH_RX_OFFLOAD_RSS_HASH | \
94 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP | \
95 : : RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
96 : : /* basic vector paths */
97 : : #define ICE_RX_VECTOR_OFFLOADS ( \
98 : : RTE_ETH_RX_OFFLOAD_KEEP_CRC | \
99 : : RTE_ETH_RX_OFFLOAD_SCATTER | \
100 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM)
101 : : /* vector offload paths */
102 : : #define ICE_RX_VECTOR_OFFLOAD_OFFLOADS ( \
103 : : ICE_RX_VECTOR_OFFLOADS | \
104 : : RTE_ETH_RX_OFFLOAD_CHECKSUM | \
105 : : RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
106 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER |\
107 : : RTE_ETH_RX_OFFLOAD_RSS_HASH)
108 : :
109 : : /* basic scalar path */
110 : : #define ICE_TX_SCALAR_OFFLOADS ( \
111 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \
112 : : RTE_ETH_TX_OFFLOAD_TCP_TSO | \
113 : : RTE_ETH_TX_OFFLOAD_UDP_TSO | \
114 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
115 : : RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | \
116 : : RTE_ETH_TX_OFFLOAD_QINQ_INSERT | \
117 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
118 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \
119 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
120 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | \
121 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | \
122 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM | \
123 : : RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | \
124 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | \
125 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | \
126 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | \
127 : : RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)
128 : : /* basic vector path */
129 : : #define ICE_TX_VECTOR_OFFLOADS RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE
130 : : /* vector offload paths */
131 : : #define ICE_TX_VECTOR_OFFLOAD_OFFLOADS ( \
132 : : ICE_TX_VECTOR_OFFLOADS | \
133 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \
134 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
135 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \
136 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
137 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)
138 : :
139 : : /* Max header size can be 2K - 64 bytes */
140 : : #define ICE_RX_HDR_BUF_SIZE (2048 - 64)
141 : :
142 : : /* Max data buffer size must be 16K - 128 bytes */
143 : : #define ICE_RX_MAX_DATA_BUF_SIZE (16 * 1024 - 128)
144 : :
145 : : #define ICE_HEADER_SPLIT_ENA BIT(0)
146 : :
147 : : #define ICE_TX_MTU_SEG_MAX 8
148 : :
149 : : typedef void (*ice_rxd_to_pkt_fields_t)(struct ci_rx_queue *rxq,
150 : : struct rte_mbuf *mb,
151 : : volatile union ci_rx_flex_desc *rxdp);
152 : :
153 : : enum ice_rx_dtype {
154 : : ICE_RX_DTYPE_NO_SPLIT = 0,
155 : : ICE_RX_DTYPE_HEADER_SPLIT = 1,
156 : : ICE_RX_DTYPE_SPLIT_ALWAYS = 2,
157 : : };
158 : :
159 : : /**
160 : : * Structure associated with Tx Time based queue
161 : : */
162 : : struct ice_txtime {
163 : : volatile struct ice_ts_desc *ice_ts_ring; /* Tx time ring virtual address */
164 : : uint16_t nb_ts_desc; /* number of Tx Time descriptors */
165 : : uint16_t ts_tail; /* current value of tail register */
166 : : int ts_offset; /* dynamic mbuf Tx timestamp field offset */
167 : : uint64_t ts_flag; /* dynamic mbuf Tx timestamp flag */
168 : : const struct rte_memzone *ts_mz;
169 : : };
170 : :
171 : : /* Rx Flex Descriptor for Comms Package Profile
172 : : * RxDID Profile ID 22 (swap Hash and FlowID)
173 : : * Flex-field 0: Flow ID lower 16-bits
174 : : * Flex-field 1: Flow ID upper 16-bits
175 : : * Flex-field 2: RSS hash lower 16-bits
176 : : * Flex-field 3: RSS hash upper 16-bits
177 : : * Flex-field 4: AUX0
178 : : * Flex-field 5: AUX1
179 : : */
180 : : struct ice_32b_rx_flex_desc_comms_ovs {
181 : : /* Qword 0 */
182 : : u8 rxdid;
183 : : u8 mir_id_umb_cast;
184 : : __le16 ptype_flexi_flags0;
185 : : __le16 pkt_len;
186 : : __le16 hdr_len_sph_flex_flags1;
187 : :
188 : : /* Qword 1 */
189 : : __le16 status_error0;
190 : : __le16 l2tag1;
191 : : __le32 flow_id;
192 : :
193 : : /* Qword 2 */
194 : : __le16 status_error1;
195 : : u8 flexi_flags2;
196 : : u8 ts_low;
197 : : __le16 l2tag2_1st;
198 : : __le16 l2tag2_2nd;
199 : :
200 : : /* Qword 3 */
201 : : __le32 rss_hash;
202 : : union {
203 : : struct {
204 : : __le16 aux0;
205 : : __le16 aux1;
206 : : } flex;
207 : : __le32 ts_high;
208 : : } flex_ts;
209 : : };
210 : :
211 : : int ice_rx_queue_setup(struct rte_eth_dev *dev,
212 : : uint16_t queue_idx,
213 : : uint16_t nb_desc,
214 : : unsigned int socket_id,
215 : : const struct rte_eth_rxconf *rx_conf,
216 : : struct rte_mempool *mp);
217 : : int ice_tx_queue_setup(struct rte_eth_dev *dev,
218 : : uint16_t queue_idx,
219 : : uint16_t nb_desc,
220 : : unsigned int socket_id,
221 : : const struct rte_eth_txconf *tx_conf);
222 : : int ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
223 : : int ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
224 : : int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
225 : : int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
226 : : int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
227 : : int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
228 : : int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
229 : : int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
230 : : void ice_rx_queue_release(void *rxq);
231 : : void ice_tx_queue_release(void *txq);
232 : : void ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
233 : : void ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
234 : : void ice_free_queues(struct rte_eth_dev *dev);
235 : : int ice_fdir_setup_tx_resources(struct ice_pf *pf);
236 : : int ice_fdir_setup_rx_resources(struct ice_pf *pf);
237 : : uint16_t ice_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
238 : : uint16_t nb_pkts);
239 : : uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
240 : : uint16_t nb_pkts);
241 : : void ice_set_rx_function(struct rte_eth_dev *dev);
242 : : uint16_t ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
243 : : uint16_t nb_pkts);
244 : : void ice_set_tx_function_flag(struct rte_eth_dev *dev,
245 : : struct ci_tx_queue *txq);
246 : : void ice_set_tx_function(struct rte_eth_dev *dev);
247 : : int ice_rx_queue_count(void *rx_queue);
248 : : void ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
249 : : struct rte_eth_rxq_info *qinfo);
250 : : void ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
251 : : struct rte_eth_txq_info *qinfo);
252 : : int ice_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
253 : : struct rte_eth_burst_mode *mode);
254 : : int ice_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
255 : : struct rte_eth_burst_mode *mode);
256 : : int ice_rx_descriptor_status(void *rx_queue, uint16_t offset);
257 : : int ice_tx_descriptor_status(void *tx_queue, uint16_t offset);
258 : : void ice_set_default_ptype_table(struct rte_eth_dev *dev);
259 : : const uint32_t *ice_dev_supported_ptypes_get(struct rte_eth_dev *dev,
260 : : size_t *no_of_elements);
261 : : void ice_select_rxd_to_pkt_fields_handler(struct ci_rx_queue *rxq,
262 : : uint32_t rxdid);
263 : :
264 : : int ice_rx_vec_dev_check(struct rte_eth_dev *dev);
265 : : int ice_tx_vec_dev_check(struct rte_eth_dev *dev);
266 : : int ice_rxq_vec_setup(struct ci_rx_queue *rxq);
267 : : uint16_t ice_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
268 : : uint16_t nb_pkts);
269 : : uint16_t ice_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts,
270 : : uint16_t nb_pkts);
271 : : uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue,
272 : : struct rte_mbuf **rx_pkts,
273 : : uint16_t nb_pkts);
274 : : uint16_t ice_recv_scattered_pkts_vec_avx2_offload(void *rx_queue,
275 : : struct rte_mbuf **rx_pkts,
276 : : uint16_t nb_pkts);
277 : : uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
278 : : uint16_t nb_pkts);
279 : : uint16_t ice_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
280 : : uint16_t nb_pkts);
281 : : uint16_t ice_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
282 : : uint16_t nb_pkts);
283 : : uint16_t ice_recv_pkts_vec_avx512_offload(void *rx_queue,
284 : : struct rte_mbuf **rx_pkts,
285 : : uint16_t nb_pkts);
286 : : uint16_t ice_recv_scattered_pkts_vec_avx512(void *rx_queue,
287 : : struct rte_mbuf **rx_pkts,
288 : : uint16_t nb_pkts);
289 : : uint16_t ice_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
290 : : struct rte_mbuf **rx_pkts,
291 : : uint16_t nb_pkts);
292 : : uint16_t ice_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
293 : : uint16_t nb_pkts);
294 : : uint16_t ice_xmit_pkts_vec_avx512_offload(void *tx_queue,
295 : : struct rte_mbuf **tx_pkts,
296 : : uint16_t nb_pkts);
297 : : int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
298 : : int ice_tx_done_cleanup(void *txq, uint32_t free_cnt);
299 : : int ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
300 : : enum rte_vect_max_simd ice_get_max_simd_bitwidth(void);
301 : :
302 : : #define FDIR_PARSING_ENABLE_PER_QUEUE(ad, on) do { \
303 : : int i; \
304 : : for (i = 0; i < (ad)->pf.dev_data->nb_rx_queues; i++) { \
305 : : struct ci_rx_queue *rxq = (ad)->pf.dev_data->rx_queues[i]; \
306 : : if (!rxq) \
307 : : continue; \
308 : : rxq->fdir_enabled = on; \
309 : : } \
310 : : PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
311 : : } while (0)
312 : :
313 : : /* Enable/disable flow director parsing from Rx descriptor in data path. */
314 : : static inline
315 : 0 : void ice_fdir_rx_parsing_enable(struct ice_adapter *ad, bool on)
316 : : {
317 [ # # ]: 0 : if (on) {
318 : : /* Enable flow director parsing from Rx descriptor */
319 [ # # # # ]: 0 : FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
320 : 0 : ad->fdir_ref_cnt++;
321 : : } else {
322 [ # # ]: 0 : if (ad->fdir_ref_cnt >= 1) {
323 : 0 : ad->fdir_ref_cnt--;
324 : :
325 [ # # ]: 0 : if (ad->fdir_ref_cnt == 0)
326 [ # # # # ]: 0 : FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
327 : : }
328 : : }
329 : 0 : }
330 : :
331 : : #define ICE_TIMESYNC_REG_WRAP_GUARD_BAND 10000
332 : :
333 : : /* Helper function to convert a 32b nanoseconds timestamp to 64b. */
334 : : static inline
335 : 0 : uint64_t ice_tstamp_convert_32b_64b(struct ice_hw *hw, struct ice_adapter *ad,
336 : : uint32_t flag, uint32_t in_timestamp)
337 : : {
338 : 0 : uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
339 : : const uint64_t mask = 0xFFFFFFFF;
340 : : uint32_t hi, lo, lo2, delta;
341 : : uint64_t ns;
342 : :
343 [ # # ]: 0 : if (flag) {
344 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
345 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
346 : :
347 : : /*
348 : : * On typical system, the delta between lo and lo2 is ~1000ns,
349 : : * so 10000 seems a large-enough but not overly-big guard band.
350 : : */
351 [ # # ]: 0 : if (lo > (UINT32_MAX - ICE_TIMESYNC_REG_WRAP_GUARD_BAND))
352 : 0 : lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
353 : : else
354 : : lo2 = lo;
355 : :
356 [ # # ]: 0 : if (lo2 < lo) {
357 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
358 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
359 : : }
360 : :
361 : 0 : ad->time_hw = ((uint64_t)hi << 32) | lo;
362 : : }
363 : :
364 : 0 : delta = (in_timestamp - (uint32_t)(ad->time_hw & mask));
365 [ # # ]: 0 : if (delta > (mask / 2)) {
366 : 0 : delta = ((uint32_t)(ad->time_hw & mask) - in_timestamp);
367 : 0 : ns = ad->time_hw - delta;
368 : : } else {
369 : 0 : ns = ad->time_hw + delta;
370 : : }
371 : :
372 : 0 : return ns;
373 : : }
374 : :
375 : : #endif /* _ICE_RXTX_H_ */
|