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