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