Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #include <ethdev_driver.h>
6 : : #include <rte_net.h>
7 : : #include <rte_vect.h>
8 : : #include <rte_bitops.h>
9 : :
10 : : #include "ice_rxtx.h"
11 : : #include "ice_rxtx_vec_common.h"
12 : :
13 : : #ifdef RTE_ARCH_X86
14 : : #include "../common/rx_vec_x86.h"
15 : : #endif
16 : :
17 : : /**
18 : : * The mbuf dynamic field pointer for protocol extraction metadata.
19 : : */
20 : : #define ICE_DYNF_PROTO_XTR_METADATA(m, n) \
21 : : RTE_MBUF_DYNFIELD((m), (n), uint32_t *)
22 : :
23 : : static int
24 : 0 : ice_monitor_callback(const uint64_t value,
25 : : const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
26 : : {
27 : : const uint64_t m = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
28 : : /*
29 : : * we expect the DD bit to be set to 1 if this descriptor was already
30 : : * written to.
31 : : */
32 [ # # ]: 0 : return (value & m) == m ? -1 : 0;
33 : : }
34 : :
35 : : int
36 : 0 : ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
37 : : {
38 : : volatile union ci_rx_flex_desc *rxdp;
39 : : struct ci_rx_queue *rxq = rx_queue;
40 : : uint16_t desc;
41 : :
42 : 0 : desc = rxq->rx_tail;
43 : 0 : rxdp = &rxq->rx_flex_ring[desc];
44 : : /* watch for changes in status bit */
45 : 0 : pmc->addr = &rxdp->wb.status_error0;
46 : :
47 : : /* comparison callback */
48 : 0 : pmc->fn = ice_monitor_callback;
49 : :
50 : : /* register is 16-bit */
51 : 0 : pmc->size = sizeof(uint16_t);
52 : :
53 : 0 : return 0;
54 : : }
55 : :
56 : :
57 : : static inline uint8_t
58 : : ice_proto_xtr_type_to_rxdid(uint8_t xtr_type)
59 : : {
60 : : static uint8_t rxdid_map[] = {
61 : : [PROTO_XTR_NONE] = ICE_RXDID_COMMS_OVS,
62 : : [PROTO_XTR_VLAN] = ICE_RXDID_COMMS_AUX_VLAN,
63 : : [PROTO_XTR_IPV4] = ICE_RXDID_COMMS_AUX_IPV4,
64 : : [PROTO_XTR_IPV6] = ICE_RXDID_COMMS_AUX_IPV6,
65 : : [PROTO_XTR_IPV6_FLOW] = ICE_RXDID_COMMS_AUX_IPV6_FLOW,
66 : : [PROTO_XTR_TCP] = ICE_RXDID_COMMS_AUX_TCP,
67 : : [PROTO_XTR_IP_OFFSET] = ICE_RXDID_COMMS_AUX_IP_OFFSET,
68 : : };
69 : :
70 : : return xtr_type < RTE_DIM(rxdid_map) ?
71 : 0 : rxdid_map[xtr_type] : ICE_RXDID_COMMS_OVS;
72 : : }
73 : :
74 : : static inline void
75 : 0 : ice_rxd_to_pkt_fields_by_comms_generic(__rte_unused struct ci_rx_queue *rxq,
76 : : struct rte_mbuf *mb,
77 : : volatile union ci_rx_flex_desc *rxdp)
78 : : {
79 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
80 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
81 : 0 : uint16_t stat_err = rte_le_to_cpu_16(desc->status_error0);
82 : :
83 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
84 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
85 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
86 : : }
87 : :
88 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
89 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
90 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
91 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
92 : : }
93 : : #endif
94 : 0 : }
95 : :
96 : : static inline void
97 : 0 : ice_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct ci_rx_queue *rxq,
98 : : struct rte_mbuf *mb,
99 : : volatile union ci_rx_flex_desc *rxdp)
100 : : {
101 : : volatile struct ice_32b_rx_flex_desc_comms_ovs *desc =
102 : : (volatile struct ice_32b_rx_flex_desc_comms_ovs *)rxdp;
103 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
104 : : uint16_t stat_err;
105 : : #endif
106 : :
107 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
108 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
109 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
110 : : }
111 : :
112 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
113 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
114 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
115 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
116 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
117 : : }
118 : : #endif
119 : 0 : }
120 : :
121 : : static inline void
122 : 0 : ice_rxd_to_pkt_fields_by_comms_aux_v1(struct ci_rx_queue *rxq,
123 : : struct rte_mbuf *mb,
124 : : volatile union ci_rx_flex_desc *rxdp)
125 : : {
126 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
127 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
128 : : uint16_t stat_err;
129 : :
130 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
131 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
132 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
133 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
134 : : }
135 : :
136 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
137 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
138 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
139 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
140 : : }
141 : :
142 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
143 : : uint32_t metadata = 0;
144 : :
145 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error1);
146 : :
147 [ # # ]: 0 : if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
148 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
149 : :
150 [ # # ]: 0 : if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
151 : 0 : metadata |=
152 : 0 : rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
153 : :
154 [ # # ]: 0 : if (metadata) {
155 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
156 : :
157 : 0 : *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
158 : : }
159 : : }
160 : : #else
161 : : RTE_SET_USED(rxq);
162 : : #endif
163 : 0 : }
164 : :
165 : : static inline void
166 : 0 : ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ci_rx_queue *rxq,
167 : : struct rte_mbuf *mb,
168 : : volatile union ci_rx_flex_desc *rxdp)
169 : : {
170 : : volatile struct ice_32b_rx_flex_desc_comms *desc =
171 : : (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
172 : : uint16_t stat_err;
173 : :
174 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
175 [ # # ]: 0 : if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
176 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
177 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
178 : : }
179 : :
180 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
181 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
182 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
183 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
184 : : }
185 : :
186 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
187 : : uint32_t metadata = 0;
188 : :
189 [ # # ]: 0 : if (desc->flex_ts.flex.aux0 != 0xFFFF)
190 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
191 [ # # ]: 0 : else if (desc->flex_ts.flex.aux1 != 0xFFFF)
192 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
193 : :
194 [ # # ]: 0 : if (metadata) {
195 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
196 : :
197 : 0 : *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
198 : : }
199 : : }
200 : : #else
201 : : RTE_SET_USED(rxq);
202 : : #endif
203 : 0 : }
204 : :
205 : : static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = {
206 : : [ICE_RXDID_COMMS_AUX_VLAN] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
207 : : [ICE_RXDID_COMMS_AUX_IPV4] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
208 : : [ICE_RXDID_COMMS_AUX_IPV6] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
209 : : [ICE_RXDID_COMMS_AUX_IPV6_FLOW] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
210 : : [ICE_RXDID_COMMS_AUX_TCP] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
211 : : [ICE_RXDID_COMMS_AUX_IP_OFFSET] = ice_rxd_to_pkt_fields_by_comms_aux_v2,
212 : : [ICE_RXDID_COMMS_GENERIC] = ice_rxd_to_pkt_fields_by_comms_generic,
213 : : [ICE_RXDID_COMMS_OVS] = ice_rxd_to_pkt_fields_by_comms_ovs,
214 : : };
215 : :
216 : : void
217 : 0 : ice_select_rxd_to_pkt_fields_handler(struct ci_rx_queue *rxq, uint32_t rxdid)
218 : : {
219 : 0 : rxq->rxdid = rxdid;
220 : :
221 [ # # ]: 0 : switch (rxdid) {
222 : : case ICE_RXDID_COMMS_AUX_VLAN:
223 : : case ICE_RXDID_COMMS_AUX_IPV4:
224 : : case ICE_RXDID_COMMS_AUX_IPV6:
225 : : case ICE_RXDID_COMMS_AUX_IPV6_FLOW:
226 : : case ICE_RXDID_COMMS_AUX_TCP:
227 : : case ICE_RXDID_COMMS_AUX_IP_OFFSET:
228 : : break;
229 : : case ICE_RXDID_COMMS_GENERIC:
230 : : /* fallthrough */
231 : : case ICE_RXDID_COMMS_OVS:
232 : : break;
233 : :
234 : 0 : default:
235 : : /* update this according to the RXDID for PROTO_XTR_NONE */
236 : 0 : rxq->rxdid = ICE_RXDID_COMMS_OVS;
237 : 0 : break;
238 : : }
239 : :
240 [ # # ]: 0 : if (rxq->xtr_field_offs == -1)
241 : 0 : rxq->xtr_ol_flag = 0;
242 : 0 : }
243 : :
244 : : static int
245 : 0 : ice_program_hw_rx_queue(struct ci_rx_queue *rxq)
246 : : {
247 : 0 : struct ice_vsi *vsi = rxq->ice_vsi;
248 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
249 : : struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
250 : 0 : struct rte_eth_dev_data *dev_data = rxq->ice_vsi->adapter->pf.dev_data;
251 : : struct ice_rlan_ctx rx_ctx;
252 : : uint16_t buf_size;
253 : : uint32_t rxdid = ICE_RXDID_COMMS_OVS;
254 : : uint32_t regval;
255 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
256 : 0 : uint32_t frame_size = dev_data->mtu + ICE_ETH_OVERHEAD;
257 : : int err;
258 : :
259 : : /* Set buffer size as the head split is disabled. */
260 [ # # ]: 0 : buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
261 : : RTE_PKTMBUF_HEADROOM);
262 : 0 : rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << ICE_RLAN_CTX_DBUF_S));
263 : 0 : rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, ICE_RX_MAX_DATA_BUF_SIZE);
264 : 0 : rxq->max_pkt_len =
265 : 0 : RTE_MIN((uint32_t)ICE_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
266 : : frame_size);
267 : :
268 [ # # ]: 0 : if (rxq->max_pkt_len <= RTE_ETHER_MIN_LEN ||
269 : : rxq->max_pkt_len > ICE_FRAME_SIZE_MAX) {
270 : 0 : PMD_DRV_LOG(ERR, "maximum packet length must "
271 : : "be larger than %u and smaller than %u",
272 : : (uint32_t)RTE_ETHER_MIN_LEN,
273 : : (uint32_t)ICE_FRAME_SIZE_MAX);
274 : 0 : return -EINVAL;
275 : : }
276 : :
277 [ # # # # ]: 0 : if (rxq->ts_flag == 0 && (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
278 : : /* Register mbuf field and flag for Rx timestamp */
279 : 0 : err = rte_mbuf_dyn_rx_timestamp_register(
280 : : &rxq->ts_offset,
281 : : &rxq->ts_flag);
282 [ # # ]: 0 : if (err) {
283 : 0 : PMD_DRV_LOG(ERR,
284 : : "Cannot register mbuf field/flag for timestamp");
285 : 0 : return -EINVAL;
286 : : }
287 : : }
288 : :
289 : : memset(&rx_ctx, 0, sizeof(rx_ctx));
290 : :
291 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
292 : : uint32_t proto_hdr;
293 : 0 : proto_hdr = rxq->rxseg[0].proto_hdr;
294 : :
295 [ # # ]: 0 : if (proto_hdr == RTE_PTYPE_UNKNOWN) {
296 : 0 : PMD_DRV_LOG(ERR, "Buffer split protocol must be configured");
297 : 0 : return -EINVAL;
298 : : }
299 : :
300 [ # # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L4_MASK) {
301 : 0 : case RTE_PTYPE_L4_TCP:
302 : : case RTE_PTYPE_L4_UDP:
303 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
304 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
305 : 0 : goto set_hsplit_finish;
306 : 0 : case RTE_PTYPE_L4_SCTP:
307 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
308 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
309 : 0 : goto set_hsplit_finish;
310 : : }
311 : :
312 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L3_MASK) {
313 : 0 : case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
314 : : case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
315 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
316 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
317 : 0 : goto set_hsplit_finish;
318 : : }
319 : :
320 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_L2_MASK) {
321 : 0 : case RTE_PTYPE_L2_ETHER:
322 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
323 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
324 : 0 : rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_L2;
325 : 0 : goto set_hsplit_finish;
326 : : }
327 : :
328 [ # # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
329 : 0 : case RTE_PTYPE_INNER_L4_TCP:
330 : : case RTE_PTYPE_INNER_L4_UDP:
331 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
332 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
333 : 0 : goto set_hsplit_finish;
334 : 0 : case RTE_PTYPE_INNER_L4_SCTP:
335 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
336 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
337 : 0 : goto set_hsplit_finish;
338 : : }
339 : :
340 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
341 : 0 : case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
342 : : case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
343 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
344 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
345 : 0 : goto set_hsplit_finish;
346 : : }
347 : :
348 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
349 : 0 : case RTE_PTYPE_INNER_L2_ETHER:
350 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
351 : 0 : rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
352 : 0 : goto set_hsplit_finish;
353 : : }
354 : :
355 [ # # ]: 0 : switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
356 : 0 : case RTE_PTYPE_TUNNEL_GRENAT:
357 : 0 : rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
358 : 0 : rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_ALWAYS;
359 : 0 : goto set_hsplit_finish;
360 : : }
361 : :
362 : 0 : PMD_DRV_LOG(ERR, "Buffer split protocol is not supported");
363 : 0 : return -EINVAL;
364 : :
365 : 0 : set_hsplit_finish:
366 : 0 : rxq->rx_hdr_len = ICE_RX_HDR_BUF_SIZE;
367 : : } else {
368 : 0 : rxq->rx_hdr_len = 0;
369 : : rx_ctx.dtype = 0; /* No Protocol Based Buffer Split mode */
370 : : }
371 : :
372 : 0 : rx_ctx.base = rxq->rx_ring_phys_addr / ICE_QUEUE_BASE_ADDR_UNIT;
373 : 0 : rx_ctx.qlen = rxq->nb_rx_desc;
374 : 0 : rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
375 : 0 : rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
376 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
377 : 0 : rx_ctx.dsize = 1; /* 32B descriptors */
378 : : #endif
379 : 0 : rx_ctx.rxmax = rxq->max_pkt_len;
380 : : /* TPH: Transaction Layer Packet (TLP) processing hints */
381 : 0 : rx_ctx.tphrdesc_ena = 1;
382 : 0 : rx_ctx.tphwdesc_ena = 1;
383 : 0 : rx_ctx.tphdata_ena = 1;
384 : 0 : rx_ctx.tphhead_ena = 1;
385 : : /* Low Receive Queue Threshold defined in 64 descriptors units.
386 : : * When the number of free descriptors goes below the lrxqthresh,
387 : : * an immediate interrupt is triggered.
388 : : */
389 : 0 : rx_ctx.lrxqthresh = 2;
390 : : /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
391 : 0 : rx_ctx.l2tsel = 1;
392 : : rx_ctx.showiv = 0;
393 : 0 : rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
394 : :
395 [ # # ]: 0 : rxdid = ice_proto_xtr_type_to_rxdid(rxq->proto_xtr);
396 : :
397 : 0 : PMD_DRV_LOG(DEBUG, "Port (%u) - Rx queue (%u) is set with RXDID : %u",
398 : : rxq->port_id, rxq->queue_id, rxdid);
399 : :
400 [ # # ]: 0 : if (!(pf->supported_rxdid & RTE_BIT64(rxdid))) {
401 : 0 : PMD_DRV_LOG(ERR, "currently package doesn't support RXDID (%u)",
402 : : rxdid);
403 : 0 : return -EINVAL;
404 : : }
405 : :
406 : 0 : rxq->rxdid = rxdid;
407 : :
408 : : /* Enable Flexible Descriptors in the queue context which
409 : : * allows this driver to select a specific receive descriptor format
410 : : */
411 : 0 : regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
412 : : QRXFLXP_CNTXT_RXDID_IDX_M;
413 : :
414 : : /* increasing context priority to pick up profile ID;
415 : : * default is 0x01; setting to 0x03 to ensure profile
416 : : * is programming if prev context is of same priority
417 : : */
418 : 0 : regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
419 : : QRXFLXP_CNTXT_RXDID_PRIO_M;
420 : :
421 [ # # # # ]: 0 : if (ad->ptp_ena || rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
422 : 0 : regval |= QRXFLXP_CNTXT_TS_M;
423 : :
424 : 0 : ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
425 : :
426 : 0 : err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
427 [ # # ]: 0 : if (err) {
428 : 0 : PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
429 : : rxq->queue_id);
430 : 0 : return -EINVAL;
431 : : }
432 : 0 : err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
433 [ # # ]: 0 : if (err) {
434 : 0 : PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
435 : : rxq->queue_id);
436 : 0 : return -EINVAL;
437 : : }
438 : :
439 : : /* Check if scattered RX needs to be used. */
440 [ # # ]: 0 : if (frame_size > buf_size)
441 : 0 : dev_data->scattered_rx = 1;
442 : :
443 : 0 : rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
444 : :
445 : : /* Init the Rx tail register*/
446 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
447 : :
448 : 0 : return 0;
449 : : }
450 : :
451 : : /* Allocate mbufs for all descriptors in rx queue */
452 : : static int
453 : 0 : ice_alloc_rx_queue_mbufs(struct ci_rx_queue *rxq)
454 : : {
455 : 0 : struct ci_rx_entry *rxe = rxq->sw_ring;
456 : : uint64_t dma_addr;
457 : : uint16_t i;
458 : :
459 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
460 : : volatile union ci_rx_flex_desc *rxd;
461 : 0 : rxd = &rxq->rx_flex_ring[i];
462 : 0 : struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mp);
463 : :
464 [ # # ]: 0 : if (unlikely(!mbuf)) {
465 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
466 : 0 : return -ENOMEM;
467 : : }
468 : :
469 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
470 : 0 : mbuf->nb_segs = 1;
471 [ # # ]: 0 : mbuf->port = rxq->port_id;
472 : :
473 : : dma_addr =
474 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
475 : :
476 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
477 : : rte_mbuf_refcnt_set(mbuf, 1);
478 : 0 : mbuf->next = NULL;
479 : 0 : rxd->read.hdr_addr = 0;
480 : 0 : rxd->read.pkt_addr = dma_addr;
481 : : } else {
482 : : struct rte_mbuf *mbuf_pay;
483 : 0 : mbuf_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
484 [ # # ]: 0 : if (unlikely(!mbuf_pay)) {
485 : 0 : rte_pktmbuf_free(mbuf);
486 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate payload mbuf for RX");
487 : 0 : return -ENOMEM;
488 : : }
489 : :
490 : 0 : mbuf_pay->next = NULL;
491 : 0 : mbuf_pay->data_off = RTE_PKTMBUF_HEADROOM;
492 : 0 : mbuf_pay->nb_segs = 1;
493 : 0 : mbuf_pay->port = rxq->port_id;
494 : 0 : mbuf->next = mbuf_pay;
495 : :
496 : 0 : rxd->read.hdr_addr = dma_addr;
497 : : /* The LS bit should be set to zero regardless of
498 : : * buffer split enablement.
499 : : */
500 : 0 : rxd->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf_pay));
501 : : }
502 : :
503 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
504 : 0 : rxd->read.rsvd1 = 0;
505 : 0 : rxd->read.rsvd2 = 0;
506 : : #endif
507 : 0 : rxe[i].mbuf = mbuf;
508 : : }
509 : :
510 : : return 0;
511 : : }
512 : :
513 : : /* Free all mbufs for descriptors in rx queue */
514 : : static void
515 : 0 : _ice_rx_queue_release_mbufs(struct ci_rx_queue *rxq)
516 : : {
517 : : uint16_t i;
518 : :
519 [ # # # # ]: 0 : if (!rxq || !rxq->sw_ring) {
520 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
521 : 0 : return;
522 : : }
523 : :
524 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
525 [ # # ]: 0 : if (rxq->sw_ring[i].mbuf) {
526 : 0 : rte_pktmbuf_free(rxq->sw_ring[i].mbuf);
527 : 0 : rxq->sw_ring[i].mbuf = NULL;
528 : : }
529 : : }
530 [ # # ]: 0 : if (rxq->rx_nb_avail == 0)
531 : : return;
532 [ # # ]: 0 : for (i = 0; i < rxq->rx_nb_avail; i++)
533 : 0 : rte_pktmbuf_free(rxq->rx_stage[rxq->rx_next_avail + i]);
534 : :
535 : 0 : rxq->rx_nb_avail = 0;
536 : : }
537 : :
538 : : /* turn on or off rx queue
539 : : * @q_idx: queue index in pf scope
540 : : * @on: turn on or off the queue
541 : : */
542 : : static int
543 : 0 : ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
544 : : {
545 : : uint32_t reg;
546 : : uint16_t j;
547 : :
548 : : /* QRX_CTRL = QRX_ENA */
549 : 0 : reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
550 : :
551 [ # # ]: 0 : if (on) {
552 [ # # ]: 0 : if (reg & QRX_CTRL_QENA_STAT_M)
553 : : return 0; /* Already on, skip */
554 : 0 : reg |= QRX_CTRL_QENA_REQ_M;
555 : : } else {
556 [ # # ]: 0 : if (!(reg & QRX_CTRL_QENA_STAT_M))
557 : : return 0; /* Already off, skip */
558 : 0 : reg &= ~QRX_CTRL_QENA_REQ_M;
559 : : }
560 : :
561 : : /* Write the register */
562 : 0 : ICE_WRITE_REG(hw, QRX_CTRL(q_idx), reg);
563 : : /* Check the result. It is said that QENA_STAT
564 : : * follows the QENA_REQ not more than 10 use.
565 : : * TODO: need to change the wait counter later
566 : : */
567 [ # # ]: 0 : for (j = 0; j < ICE_CHK_Q_ENA_COUNT; j++) {
568 : 0 : rte_delay_us(ICE_CHK_Q_ENA_INTERVAL_US);
569 : 0 : reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
570 [ # # ]: 0 : if (on) {
571 [ # # ]: 0 : if ((reg & QRX_CTRL_QENA_REQ_M) &&
572 : : (reg & QRX_CTRL_QENA_STAT_M))
573 : : break;
574 : : } else {
575 [ # # ]: 0 : if (!(reg & QRX_CTRL_QENA_REQ_M) &&
576 : : !(reg & QRX_CTRL_QENA_STAT_M))
577 : : break;
578 : : }
579 : : }
580 : :
581 : : /* Check if it is timeout */
582 [ # # ]: 0 : if (j >= ICE_CHK_Q_ENA_COUNT) {
583 [ # # ]: 0 : PMD_DRV_LOG(ERR, "Failed to %s rx queue[%u]",
584 : : (on ? "enable" : "disable"), q_idx);
585 : 0 : return -ETIMEDOUT;
586 : : }
587 : :
588 : : return 0;
589 : : }
590 : :
591 : : static inline int
592 : 0 : ice_check_rx_burst_bulk_alloc_preconditions(struct ci_rx_queue *rxq)
593 : : {
594 : : int ret = 0;
595 : :
596 [ # # ]: 0 : if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
597 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
598 : : "rxq->rx_free_thresh=%d, "
599 : : "ICE_RX_MAX_BURST=%d",
600 : : rxq->rx_free_thresh, ICE_RX_MAX_BURST);
601 : : ret = -EINVAL;
602 [ # # ]: 0 : } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
603 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
604 : : "rxq->rx_free_thresh=%d, "
605 : : "rxq->nb_rx_desc=%d",
606 : : rxq->rx_free_thresh, rxq->nb_rx_desc);
607 : : ret = -EINVAL;
608 [ # # ]: 0 : } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
609 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
610 : : "rxq->nb_rx_desc=%d, "
611 : : "rxq->rx_free_thresh=%d",
612 : : rxq->nb_rx_desc, rxq->rx_free_thresh);
613 : : ret = -EINVAL;
614 : : }
615 : :
616 : 0 : return ret;
617 : : }
618 : :
619 : : /* reset fields in ci_rx_queue back to default */
620 : : static void
621 : 0 : ice_reset_rx_queue(struct ci_rx_queue *rxq)
622 : : {
623 : : unsigned int i;
624 : : uint16_t len;
625 : :
626 [ # # ]: 0 : if (!rxq) {
627 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
628 : 0 : return;
629 : : }
630 : :
631 : 0 : len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
632 : :
633 [ # # ]: 0 : for (i = 0; i < len * sizeof(union ci_rx_flex_desc); i++)
634 : 0 : ((volatile char *)rxq->rx_flex_ring)[i] = 0;
635 : :
636 : 0 : memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
637 [ # # ]: 0 : for (i = 0; i < ICE_RX_MAX_BURST; ++i)
638 : 0 : rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
639 : :
640 : 0 : rxq->rx_nb_avail = 0;
641 : 0 : rxq->rx_next_avail = 0;
642 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
643 : :
644 : 0 : rxq->rx_tail = 0;
645 : 0 : rxq->nb_rx_hold = 0;
646 : 0 : rxq->pkt_first_seg = NULL;
647 : 0 : rxq->pkt_last_seg = NULL;
648 : :
649 : 0 : rxq->rxrearm_start = 0;
650 : 0 : rxq->rxrearm_nb = 0;
651 : : }
652 : :
653 : : int
654 : 0 : ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
655 : : {
656 : : struct ci_rx_queue *rxq;
657 : : int err;
658 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
659 : :
660 : 0 : PMD_INIT_FUNC_TRACE();
661 : :
662 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues) {
663 : 0 : PMD_DRV_LOG(ERR, "RX queue %u is out of range %u",
664 : : rx_queue_id, dev->data->nb_rx_queues);
665 : 0 : return -EINVAL;
666 : : }
667 : :
668 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
669 [ # # # # ]: 0 : if (!rxq || !rxq->q_set) {
670 : 0 : PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
671 : : rx_queue_id);
672 : 0 : return -EINVAL;
673 : : }
674 : :
675 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
676 : : RTE_ETH_QUEUE_STATE_STARTED)
677 : : return 0;
678 : :
679 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
680 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
681 : 0 : err = ice_program_hw_rx_queue(rxq);
682 [ # # ]: 0 : if (err) {
683 : 0 : PMD_DRV_LOG(ERR, "fail to program RX queue %u",
684 : : rx_queue_id);
685 : 0 : return -EIO;
686 : : }
687 : :
688 : 0 : err = ice_alloc_rx_queue_mbufs(rxq);
689 [ # # ]: 0 : if (err) {
690 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
691 : 0 : return -ENOMEM;
692 : : }
693 : :
694 : : /* Init the RX tail register. */
695 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
696 : :
697 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
698 [ # # ]: 0 : if (err) {
699 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
700 : : rx_queue_id);
701 : :
702 : 0 : rxq->rx_rel_mbufs(rxq);
703 : 0 : ice_reset_rx_queue(rxq);
704 : 0 : return -EINVAL;
705 : : }
706 : :
707 : 0 : dev->data->rx_queue_state[rx_queue_id] =
708 : : RTE_ETH_QUEUE_STATE_STARTED;
709 : :
710 : 0 : return 0;
711 : : }
712 : :
713 : : int
714 : 0 : ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
715 : : {
716 : : struct ci_rx_queue *rxq;
717 : : int err;
718 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
719 : :
720 [ # # ]: 0 : if (rx_queue_id < dev->data->nb_rx_queues) {
721 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
722 : :
723 [ # # ]: 0 : if (dev->data->rx_queue_state[rx_queue_id] ==
724 : : RTE_ETH_QUEUE_STATE_STOPPED)
725 : : return 0;
726 : :
727 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
728 [ # # ]: 0 : if (err) {
729 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
730 : : rx_queue_id);
731 : 0 : return -EINVAL;
732 : : }
733 : 0 : rxq->rx_rel_mbufs(rxq);
734 : 0 : ice_reset_rx_queue(rxq);
735 : 0 : dev->data->rx_queue_state[rx_queue_id] =
736 : : RTE_ETH_QUEUE_STATE_STOPPED;
737 : : }
738 : :
739 : : return 0;
740 : : }
741 : :
742 : : /**
743 : : * ice_setup_txtime_ctx - setup a struct ice_txtime_ctx instance
744 : : * @txq: The queue on which tstamp ring to configure
745 : : * @txtime_ctx: Pointer to the Tx time queue context structure to be initialized
746 : : * @txtime_ena: Tx time enable flag, set to true if Tx time should be enabled
747 : : */
748 : : static int
749 : 0 : ice_setup_txtime_ctx(struct ci_tx_queue *txq,
750 : : struct ice_txtime_ctx *txtime_ctx, bool txtime_ena)
751 : : {
752 : 0 : struct ice_vsi *vsi = txq->ice_vsi;
753 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
754 : :
755 : 0 : txtime_ctx->base = txq->tsq->ts_mz->iova >> ICE_TX_CMPLTNQ_CTX_BASE_S;
756 : :
757 : : /* Tx time Queue Length */
758 : 0 : txtime_ctx->qlen = txq->tsq->nb_ts_desc;
759 : :
760 [ # # ]: 0 : if (txtime_ena)
761 : 0 : txtime_ctx->txtime_ena_q = 1;
762 : :
763 : : /* PF number */
764 : 0 : txtime_ctx->pf_num = hw->pf_id;
765 : :
766 [ # # ]: 0 : switch (vsi->type) {
767 : 0 : case ICE_VSI_PF:
768 : 0 : txtime_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
769 : : break;
770 : 0 : default:
771 : 0 : PMD_DRV_LOG(ERR, "Unable to set VMVF type for VSI type %d", vsi->type);
772 : 0 : return -EINVAL;
773 : : }
774 : :
775 : : /* make sure the context is associated with the right VSI */
776 : 0 : txtime_ctx->src_vsi = vsi->vsi_id;
777 : :
778 : 0 : txtime_ctx->ts_res = ICE_TXTIME_CTX_RESOLUTION_128NS;
779 : 0 : txtime_ctx->drbell_mode_32 = ICE_TXTIME_CTX_DRBELL_MODE_32;
780 : 0 : txtime_ctx->ts_fetch_prof_id = ICE_TXTIME_CTX_FETCH_PROF_ID_0;
781 : :
782 : 0 : return 0;
783 : : }
784 : :
785 : : int
786 : 0 : ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
787 : : {
788 : : struct ci_tx_queue *txq;
789 : : int err;
790 : : struct ice_vsi *vsi;
791 : : struct ice_hw *hw;
792 : : struct ice_pf *pf;
793 : : struct ice_aqc_add_tx_qgrp *txq_elem;
794 : : struct ice_tlan_ctx tx_ctx;
795 : : int buf_len;
796 : 0 : struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
797 : : u16 q_base, q_range, cgd_idx = 0;
798 : :
799 : 0 : PMD_INIT_FUNC_TRACE();
800 : :
801 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues) {
802 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
803 : : tx_queue_id, dev->data->nb_tx_queues);
804 : 0 : return -EINVAL;
805 : : }
806 : :
807 : 0 : txq = dev->data->tx_queues[tx_queue_id];
808 [ # # # # ]: 0 : if (!txq || !txq->q_set) {
809 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available or setup",
810 : : tx_queue_id);
811 : 0 : return -EINVAL;
812 : : }
813 : :
814 [ # # ]: 0 : if (dev->data->tx_queue_state[tx_queue_id] ==
815 : : RTE_ETH_QUEUE_STATE_STARTED)
816 : : return 0;
817 : :
818 : : buf_len = ice_struct_size(txq_elem, txqs, 1);
819 : 0 : txq_elem = ice_malloc(hw, buf_len);
820 [ # # ]: 0 : if (!txq_elem)
821 : : return -ENOMEM;
822 : :
823 : 0 : vsi = txq->ice_vsi;
824 : 0 : hw = ICE_VSI_TO_HW(vsi);
825 [ # # ]: 0 : pf = ICE_VSI_TO_PF(vsi);
826 : :
827 : : memset(&tx_ctx, 0, sizeof(tx_ctx));
828 : 0 : txq_elem->num_txqs = 1;
829 : 0 : txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
830 : :
831 : 0 : tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
832 : 0 : tx_ctx.qlen = txq->nb_tx_desc;
833 : 0 : tx_ctx.pf_num = hw->pf_id;
834 : 0 : tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
835 : 0 : tx_ctx.src_vsi = vsi->vsi_id;
836 : 0 : tx_ctx.port_num = hw->port_info->lport;
837 : 0 : tx_ctx.tso_ena = 1; /* tso enable */
838 : 0 : tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
839 : 0 : tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
840 : 0 : tx_ctx.tsyn_ena = 1;
841 : :
842 [ # # ]: 0 : if (!pf->tm_conf.committed) {
843 : : /* Mirror RXQ<->CGD association to TXQ<->CGD */
844 [ # # ]: 0 : for (int i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
845 : 0 : q_base = rte_le_to_cpu_16(vsi->info.tc_mapping[i]) &
846 : : ICE_AQ_VSI_TC_Q_OFFSET_M;
847 : 0 : q_range = 1 << ((rte_le_to_cpu_16(vsi->info.tc_mapping[i]) &
848 : 0 : ICE_AQ_VSI_TC_Q_NUM_M) >> ICE_AQ_VSI_TC_Q_NUM_S);
849 : :
850 [ # # # # ]: 0 : if (q_base <= tx_queue_id && tx_queue_id < q_base + q_range)
851 : : break;
852 : :
853 : 0 : cgd_idx++;
854 : : }
855 [ # # ]: 0 : if (cgd_idx >= ICE_MAX_TRAFFIC_CLASS) {
856 : 0 : PMD_DRV_LOG(ERR, "Bad queue mapping configuration");
857 : 0 : ice_free(hw, txq_elem);
858 : 0 : return -EINVAL;
859 : : }
860 [ # # ]: 0 : } else if (pf->dcb_num_tcs > 1) {
861 : : /* TM only manages the TC0 scheduler subtree. */
862 : 0 : PMD_DRV_LOG(ERR, "TM hierarchy is not supported together with multi-TC DCB");
863 : 0 : ice_free(hw, txq_elem);
864 : 0 : return -EINVAL;
865 : : }
866 : :
867 : 0 : tx_ctx.cgd_num = cgd_idx;
868 : :
869 : 0 : ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
870 : : ice_tlan_ctx_info);
871 : :
872 : : /* Fix me, we assume TC always 0 here */
873 : 0 : err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
874 : : txq_elem, buf_len, NULL);
875 [ # # ]: 0 : if (err) {
876 : 0 : PMD_DRV_LOG(ERR, "Failed to add lan txq");
877 : 0 : ice_free(hw, txq_elem);
878 : 0 : return -EIO;
879 : : }
880 : : /* store the schedule node id */
881 : 0 : txq->q_teid = txq_elem->txqs[0].q_teid;
882 : :
883 : : /* move the queue to correct position in hierarchy, if explicit hierarchy configured */
884 [ # # ]: 0 : if (pf->tm_conf.committed)
885 [ # # ]: 0 : if (ice_tm_setup_txq_node(pf, hw, tx_queue_id, txq->q_teid) != 0) {
886 : 0 : PMD_DRV_LOG(ERR, "Failed to set up txq traffic management node");
887 : 0 : ice_free(hw, txq_elem);
888 : 0 : return -EIO;
889 : : }
890 : :
891 : : /* record what kind of descriptor cleanup we need on teardown */
892 : 0 : txq->use_vec_entry = ad->tx_vec_allowed || ad->tx_simple_allowed;
893 : 0 : txq->use_ctx = ad->use_ctx;
894 : :
895 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
896 : : struct ice_aqc_set_txtime_qgrp *ts_elem;
897 : 0 : struct ice_txtime_ctx txtime_ctx = { 0 };
898 : : u8 ts_buf_len = ice_struct_size(ts_elem, txtimeqs, 1);
899 : :
900 : 0 : ts_elem = ice_malloc(hw, ts_buf_len);
901 [ # # ]: 0 : if (!ts_elem) {
902 : 0 : ice_free(hw, txq_elem);
903 : 0 : return -ENOMEM;
904 : : }
905 : 0 : ice_setup_txtime_ctx(txq, &txtime_ctx, true);
906 : 0 : ice_set_ctx(hw, (u8 *)&txtime_ctx,
907 : 0 : ts_elem->txtimeqs[0].txtime_ctx,
908 : : ice_txtime_ctx_info);
909 : :
910 : 0 : txq->qtx_tail = hw->hw_addr + E830_GLQTX_TXTIME_DBELL_LSB(txq->reg_idx);
911 : :
912 : : /* Init the Tx time tail register*/
913 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
914 : :
915 : 0 : err = ice_aq_set_txtimeq(hw, txq->reg_idx, 1, ts_elem, ts_buf_len, NULL);
916 : 0 : ice_free(hw, ts_elem);
917 [ # # ]: 0 : if (err) {
918 : 0 : PMD_DRV_LOG(ERR, "Failed to set Tx Time queue context, error: %d", err);
919 : 0 : ice_free(hw, txq_elem);
920 : 0 : return err;
921 : : }
922 : : } else {
923 : 0 : txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
924 : :
925 : : /* Init the Tx tail register*/
926 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
927 : : }
928 : :
929 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
930 : :
931 : 0 : ice_free(hw, txq_elem);
932 : 0 : return 0;
933 : : }
934 : :
935 : : static int
936 : 0 : ice_fdir_program_hw_rx_queue(struct ci_rx_queue *rxq)
937 : : {
938 : 0 : struct ice_vsi *vsi = rxq->ice_vsi;
939 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
940 : : uint32_t rxdid = ICE_RXDID_LEGACY_1;
941 : : struct ice_rlan_ctx rx_ctx;
942 : : uint32_t regval;
943 : : int err;
944 : :
945 : 0 : rxq->rx_hdr_len = 0;
946 : 0 : rxq->rx_buf_len = 1024;
947 : :
948 : : memset(&rx_ctx, 0, sizeof(rx_ctx));
949 : :
950 : 0 : rx_ctx.base = rxq->rx_ring_phys_addr / ICE_QUEUE_BASE_ADDR_UNIT;
951 : 0 : rx_ctx.qlen = rxq->nb_rx_desc;
952 : 0 : rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
953 : : rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
954 : : rx_ctx.dtype = 0; /* No Buffer Split mode */
955 : 0 : rx_ctx.dsize = 1; /* 32B descriptors */
956 : 0 : rx_ctx.rxmax = ICE_ETH_MAX_LEN;
957 : : /* TPH: Transaction Layer Packet (TLP) processing hints */
958 : 0 : rx_ctx.tphrdesc_ena = 1;
959 : 0 : rx_ctx.tphwdesc_ena = 1;
960 : 0 : rx_ctx.tphdata_ena = 1;
961 : 0 : rx_ctx.tphhead_ena = 1;
962 : : /* Low Receive Queue Threshold defined in 64 descriptors units.
963 : : * When the number of free descriptors goes below the lrxqthresh,
964 : : * an immediate interrupt is triggered.
965 : : */
966 : 0 : rx_ctx.lrxqthresh = 2;
967 : : /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
968 : 0 : rx_ctx.l2tsel = 1;
969 : : rx_ctx.showiv = 0;
970 : 0 : rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
971 : :
972 : : /* Enable Flexible Descriptors in the queue context which
973 : : * allows this driver to select a specific receive descriptor format
974 : : */
975 : : regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
976 : : QRXFLXP_CNTXT_RXDID_IDX_M;
977 : :
978 : : /* increasing context priority to pick up profile ID;
979 : : * default is 0x01; setting to 0x03 to ensure profile
980 : : * is programming if prev context is of same priority
981 : : */
982 : : regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
983 : : QRXFLXP_CNTXT_RXDID_PRIO_M;
984 : :
985 : 0 : ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
986 : :
987 : 0 : err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
988 [ # # ]: 0 : if (err) {
989 : 0 : PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
990 : : rxq->queue_id);
991 : 0 : return -EINVAL;
992 : : }
993 : 0 : err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
994 [ # # ]: 0 : if (err) {
995 : 0 : PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
996 : : rxq->queue_id);
997 : 0 : return -EINVAL;
998 : : }
999 : :
1000 : 0 : rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
1001 : :
1002 : : /* Init the Rx tail register*/
1003 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
1004 : :
1005 : 0 : return 0;
1006 : : }
1007 : :
1008 : : int
1009 : 0 : ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1010 : : {
1011 : : struct ci_rx_queue *rxq;
1012 : : int err;
1013 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1014 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1015 : :
1016 : 0 : PMD_INIT_FUNC_TRACE();
1017 : :
1018 : 0 : rxq = pf->fdir.rxq;
1019 [ # # # # ]: 0 : if (!rxq || !rxq->q_set) {
1020 : 0 : PMD_DRV_LOG(ERR, "FDIR RX queue %u not available or setup",
1021 : : rx_queue_id);
1022 : 0 : return -EINVAL;
1023 : : }
1024 : :
1025 : 0 : err = ice_fdir_program_hw_rx_queue(rxq);
1026 [ # # ]: 0 : if (err) {
1027 : 0 : PMD_DRV_LOG(ERR, "fail to program FDIR RX queue %u",
1028 : : rx_queue_id);
1029 : 0 : return -EIO;
1030 : : }
1031 : :
1032 : : /* Init the RX tail register. */
1033 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
1034 : :
1035 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
1036 [ # # ]: 0 : if (err) {
1037 : 0 : PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u on",
1038 : : rx_queue_id);
1039 : :
1040 : 0 : ice_reset_rx_queue(rxq);
1041 : 0 : return -EINVAL;
1042 : : }
1043 : :
1044 : : return 0;
1045 : : }
1046 : :
1047 : : int
1048 : 0 : ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1049 : : {
1050 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1051 : : struct ci_tx_queue *txq;
1052 : : int err;
1053 : : struct ice_vsi *vsi;
1054 : : struct ice_hw *hw;
1055 : : struct ice_aqc_add_tx_qgrp *txq_elem;
1056 : : struct ice_tlan_ctx tx_ctx;
1057 : : int buf_len;
1058 : :
1059 : 0 : PMD_INIT_FUNC_TRACE();
1060 : :
1061 : 0 : txq = pf->fdir.txq;
1062 [ # # # # ]: 0 : if (!txq || !txq->q_set) {
1063 : 0 : PMD_DRV_LOG(ERR, "FDIR TX queue %u is not available or setup",
1064 : : tx_queue_id);
1065 : 0 : return -EINVAL;
1066 : : }
1067 : :
1068 : : buf_len = ice_struct_size(txq_elem, txqs, 1);
1069 : 0 : txq_elem = ice_malloc(hw, buf_len);
1070 [ # # ]: 0 : if (!txq_elem)
1071 : : return -ENOMEM;
1072 : :
1073 : 0 : vsi = txq->ice_vsi;
1074 : 0 : hw = ICE_VSI_TO_HW(vsi);
1075 : :
1076 : : memset(&tx_ctx, 0, sizeof(tx_ctx));
1077 : 0 : txq_elem->num_txqs = 1;
1078 : 0 : txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
1079 : :
1080 : 0 : tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
1081 : 0 : tx_ctx.qlen = txq->nb_tx_desc;
1082 : 0 : tx_ctx.pf_num = hw->pf_id;
1083 : 0 : tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
1084 : 0 : tx_ctx.src_vsi = vsi->vsi_id;
1085 : 0 : tx_ctx.port_num = hw->port_info->lport;
1086 : 0 : tx_ctx.tso_ena = 1; /* tso enable */
1087 : 0 : tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
1088 : 0 : tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
1089 : :
1090 : 0 : ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
1091 : : ice_tlan_ctx_info);
1092 : :
1093 : 0 : txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
1094 : :
1095 : : /* Init the Tx tail register*/
1096 : : ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
1097 : :
1098 : : /* Fix me, we assume TC always 0 here */
1099 : 0 : err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
1100 : : txq_elem, buf_len, NULL);
1101 [ # # ]: 0 : if (err) {
1102 : 0 : PMD_DRV_LOG(ERR, "Failed to add FDIR txq");
1103 : 0 : ice_free(hw, txq_elem);
1104 : 0 : return -EIO;
1105 : : }
1106 : : /* store the schedule node id */
1107 : 0 : txq->q_teid = txq_elem->txqs[0].q_teid;
1108 : :
1109 : 0 : ice_free(hw, txq_elem);
1110 : 0 : return 0;
1111 : : }
1112 : :
1113 : : static void
1114 : 0 : ice_reset_tx_queue(struct ci_tx_queue *txq)
1115 : : {
1116 : : struct ci_tx_entry *txe;
1117 : : uint16_t i, prev, size;
1118 : :
1119 [ # # ]: 0 : if (!txq) {
1120 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
1121 : 0 : return;
1122 : : }
1123 : :
1124 : 0 : txe = txq->sw_ring;
1125 : 0 : size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
1126 [ # # ]: 0 : for (i = 0; i < size; i++)
1127 : 0 : ((volatile char *)txq->ci_tx_ring)[i] = 0;
1128 : :
1129 : 0 : prev = (uint16_t)(txq->nb_tx_desc - 1);
1130 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
1131 : 0 : volatile struct ci_tx_desc *txd = &txq->ci_tx_ring[i];
1132 : :
1133 : 0 : txd->cmd_type_offset_bsz =
1134 : : rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
1135 : 0 : txe[i].mbuf = NULL;
1136 : 0 : txe[prev].next_id = i;
1137 : : prev = i;
1138 : : }
1139 : :
1140 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
1141 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
1142 : :
1143 : 0 : txq->tx_tail = 0;
1144 : :
1145 : 0 : txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
1146 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
1147 : :
1148 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
1149 [ # # ]: 0 : for (i = 0; i < txq->tsq->nb_ts_desc; i++) {
1150 : 0 : volatile struct ice_ts_desc *tsd = &txq->tsq->ice_ts_ring[i];
1151 : 0 : tsd->tx_desc_idx_tstamp = 0;
1152 : : }
1153 : :
1154 : 0 : txq->tsq->ts_tail = 0;
1155 : : }
1156 : : }
1157 : :
1158 : : int
1159 : 0 : ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1160 : : {
1161 : : struct ci_tx_queue *txq;
1162 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1163 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1164 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1165 : : uint16_t q_ids[1];
1166 : : uint32_t q_teids[1];
1167 : 0 : uint16_t q_handle = tx_queue_id;
1168 : : int status;
1169 : :
1170 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues) {
1171 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
1172 : : tx_queue_id, dev->data->nb_tx_queues);
1173 : 0 : return -EINVAL;
1174 : : }
1175 : :
1176 : 0 : txq = dev->data->tx_queues[tx_queue_id];
1177 [ # # ]: 0 : if (!txq) {
1178 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available",
1179 : : tx_queue_id);
1180 : 0 : return -EINVAL;
1181 : : }
1182 : :
1183 [ # # ]: 0 : if (dev->data->tx_queue_state[tx_queue_id] ==
1184 : : RTE_ETH_QUEUE_STATE_STOPPED)
1185 : : return 0;
1186 : :
1187 : 0 : q_ids[0] = txq->reg_idx;
1188 : 0 : q_teids[0] = txq->q_teid;
1189 : :
1190 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
1191 : : struct ice_aqc_ena_dis_txtime_qgrp txtime_pg;
1192 : :
1193 : 0 : status = ice_aq_ena_dis_txtimeq(hw, q_ids[0], 1, 0, &txtime_pg, NULL);
1194 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1195 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Tx time queue");
1196 : 0 : return -EINVAL;
1197 : : }
1198 : : }
1199 : :
1200 : : /* Fix me, we assume TC always 0 here */
1201 : 0 : status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
1202 : : q_ids, q_teids, ICE_NO_RESET, 0, NULL);
1203 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1204 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
1205 : 0 : return -EINVAL;
1206 : : }
1207 : :
1208 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1209 : 0 : ice_reset_tx_queue(txq);
1210 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
1211 : :
1212 : 0 : return 0;
1213 : : }
1214 : :
1215 : : int
1216 : 0 : ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1217 : : {
1218 : : struct ci_rx_queue *rxq;
1219 : : int err;
1220 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1221 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1222 : :
1223 : 0 : rxq = pf->fdir.rxq;
1224 : :
1225 : 0 : err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
1226 [ # # ]: 0 : if (err) {
1227 : 0 : PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u off",
1228 : : rx_queue_id);
1229 : 0 : return -EINVAL;
1230 : : }
1231 : 0 : rxq->rx_rel_mbufs(rxq);
1232 : :
1233 : 0 : return 0;
1234 : : }
1235 : :
1236 : : int
1237 : 0 : ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1238 : : {
1239 : : struct ci_tx_queue *txq;
1240 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1241 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1242 : : struct ice_vsi *vsi = pf->main_vsi;
1243 : : uint16_t q_ids[1];
1244 : : uint32_t q_teids[1];
1245 : 0 : uint16_t q_handle = tx_queue_id;
1246 : : int status;
1247 : :
1248 : 0 : txq = pf->fdir.txq;
1249 [ # # ]: 0 : if (!txq) {
1250 : 0 : PMD_DRV_LOG(ERR, "TX queue %u is not available",
1251 : : tx_queue_id);
1252 : 0 : return -EINVAL;
1253 : : }
1254 [ # # ]: 0 : if (txq->qtx_tail == NULL) {
1255 : 0 : PMD_DRV_LOG(INFO, "TX queue %u not started", tx_queue_id);
1256 : 0 : return 0;
1257 : : }
1258 : 0 : vsi = txq->ice_vsi;
1259 : :
1260 : 0 : q_ids[0] = txq->reg_idx;
1261 : 0 : q_teids[0] = txq->q_teid;
1262 : :
1263 : : /* Fix me, we assume TC always 0 here */
1264 : 0 : status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
1265 : : q_ids, q_teids, ICE_NO_RESET, 0, NULL);
1266 [ # # ]: 0 : if (status != ICE_SUCCESS) {
1267 : 0 : PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
1268 : 0 : return -EINVAL;
1269 : : }
1270 : :
1271 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1272 : 0 : txq->qtx_tail = NULL;
1273 : :
1274 : 0 : return 0;
1275 : : }
1276 : :
1277 : : int
1278 : 0 : ice_rx_queue_setup(struct rte_eth_dev *dev,
1279 : : uint16_t queue_idx,
1280 : : uint16_t nb_desc,
1281 : : unsigned int socket_id,
1282 : : const struct rte_eth_rxconf *rx_conf,
1283 : : struct rte_mempool *mp)
1284 : : {
1285 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1286 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1287 : : struct ice_adapter *ad =
1288 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1289 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1290 : : struct ci_rx_queue *rxq;
1291 : : const struct rte_memzone *rz;
1292 : : uint32_t ring_size, tlen;
1293 : : uint16_t len;
1294 : : int use_def_burst_func = 1;
1295 : : uint64_t offloads;
1296 : 0 : uint16_t n_seg = rx_conf->rx_nseg;
1297 : : uint16_t i;
1298 : :
1299 [ # # ]: 0 : if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1300 [ # # ]: 0 : nb_desc > ICE_MAX_RING_DESC ||
1301 : : nb_desc < ICE_MIN_RING_DESC) {
1302 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
1303 : : "invalid", nb_desc);
1304 : 0 : return -EINVAL;
1305 : : }
1306 : :
1307 : : /* Check that ring size is > 2 * rx_free_thresh */
1308 [ # # ]: 0 : if (nb_desc <= 2 * rx_conf->rx_free_thresh) {
1309 : 0 : PMD_INIT_LOG(ERR, "rx ring size (%u) must be > 2 * rx_free_thresh (%u)",
1310 : : nb_desc, rx_conf->rx_free_thresh);
1311 [ # # ]: 0 : if (nb_desc == ICE_MIN_RING_DESC)
1312 : 0 : PMD_INIT_LOG(ERR, "To use the minimum ring size (%u), reduce rx_free_thresh to a lower value (recommended %u)",
1313 : : ICE_MIN_RING_DESC, ICE_MIN_RING_DESC / 4);
1314 : 0 : return -EINVAL;
1315 : : }
1316 : :
1317 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
1318 : :
1319 [ # # ]: 0 : if (mp)
1320 : : n_seg = 1;
1321 : :
1322 [ # # # # ]: 0 : if (n_seg > 1 && !(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
1323 : 0 : PMD_INIT_LOG(ERR, "port %u queue index %u split offload not configured",
1324 : : dev->data->port_id, queue_idx);
1325 : 0 : return -EINVAL;
1326 : : }
1327 : :
1328 : : /* Free memory if needed */
1329 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx]) {
1330 : 0 : ice_rx_queue_release(dev->data->rx_queues[queue_idx]);
1331 : 0 : dev->data->rx_queues[queue_idx] = NULL;
1332 : : }
1333 : :
1334 : : /* Allocate the rx queue data structure */
1335 : 0 : rxq = rte_zmalloc_socket(NULL,
1336 : : sizeof(struct ci_rx_queue),
1337 : : RTE_CACHE_LINE_SIZE,
1338 : : socket_id);
1339 : :
1340 [ # # ]: 0 : if (!rxq) {
1341 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1342 : : "rx queue data structure");
1343 : 0 : return -ENOMEM;
1344 : : }
1345 : :
1346 : 0 : rxq->rxseg_nb = n_seg;
1347 [ # # ]: 0 : if (n_seg > 1) {
1348 [ # # ]: 0 : for (i = 0; i < n_seg; i++)
1349 : 0 : memcpy(&rxq->rxseg[i], &rx_conf->rx_seg[i].split,
1350 : : sizeof(struct rte_eth_rxseg_split));
1351 : :
1352 : 0 : rxq->mp = rxq->rxseg[0].mp;
1353 : : } else {
1354 : 0 : rxq->mp = mp;
1355 : : }
1356 : :
1357 : 0 : rxq->nb_rx_desc = nb_desc;
1358 : 0 : rxq->rx_free_thresh = rx_conf->rx_free_thresh;
1359 : 0 : rxq->queue_id = queue_idx;
1360 : 0 : rxq->offloads = offloads;
1361 : :
1362 : 0 : rxq->reg_idx = vsi->base_queue + queue_idx;
1363 : 0 : rxq->port_id = dev->data->port_id;
1364 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
1365 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
1366 : : else
1367 : 0 : rxq->crc_len = 0;
1368 : :
1369 : 0 : rxq->drop_en = rx_conf->rx_drop_en;
1370 : 0 : rxq->ice_vsi = vsi;
1371 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
1372 : 0 : rxq->proto_xtr = pf->proto_xtr != NULL ?
1373 [ # # ]: 0 : pf->proto_xtr[queue_idx] : PROTO_XTR_NONE;
1374 [ # # ]: 0 : if (rxq->proto_xtr != PROTO_XTR_NONE &&
1375 [ # # ]: 0 : ad->devargs.xtr_flag_offs[rxq->proto_xtr] != 0xff)
1376 : 0 : rxq->xtr_ol_flag = 1ULL << ad->devargs.xtr_flag_offs[rxq->proto_xtr];
1377 : 0 : rxq->xtr_field_offs = ad->devargs.xtr_field_offs;
1378 : :
1379 : : /* Allocate the maximum number of RX ring hardware descriptor. */
1380 : : len = ICE_MAX_NUM_DESC_BY_MAC(hw);
1381 : :
1382 : : /**
1383 : : * Allocating a little more memory because vectorized/bulk_alloc Rx
1384 : : * functions doesn't check boundaries each time.
1385 : : */
1386 : : len += ICE_RX_MAX_BURST;
1387 : :
1388 : : /* Allocate the maximum number of RX ring hardware descriptor. */
1389 : : ring_size = sizeof(union ci_rx_flex_desc) * len;
1390 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1391 : 0 : rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
1392 : : ring_size, ICE_RING_BASE_ALIGN,
1393 : : socket_id);
1394 [ # # ]: 0 : if (!rz) {
1395 : 0 : ice_rx_queue_release(rxq);
1396 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
1397 : 0 : return -ENOMEM;
1398 : : }
1399 : :
1400 : 0 : rxq->mz = rz;
1401 : : /* Zero all the descriptors in the ring. */
1402 [ # # ]: 0 : memset(rz->addr, 0, ring_size);
1403 : :
1404 : 0 : rxq->rx_ring_phys_addr = rz->iova;
1405 : 0 : rxq->rx_flex_ring = rz->addr;
1406 : :
1407 : : /* always reserve more for bulk alloc */
1408 : 0 : len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
1409 : :
1410 : : /* allocate extra entries for SW split buffer */
1411 : 0 : tlen = ((rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) != 0) ?
1412 [ # # ]: 0 : rxq->rx_free_thresh : 0;
1413 : 0 : tlen += len;
1414 : :
1415 : : /* Allocate the software ring. */
1416 : 0 : rxq->sw_ring = rte_zmalloc_socket(NULL,
1417 : : sizeof(struct ci_rx_entry) * tlen,
1418 : : RTE_CACHE_LINE_SIZE,
1419 : : socket_id);
1420 [ # # ]: 0 : if (!rxq->sw_ring) {
1421 : 0 : ice_rx_queue_release(rxq);
1422 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
1423 : 0 : return -ENOMEM;
1424 : : }
1425 : :
1426 [ # # ]: 0 : rxq->sw_split_buf = (tlen == len) ? NULL : rxq->sw_ring + len;
1427 : :
1428 : 0 : ice_reset_rx_queue(rxq);
1429 : 0 : rxq->q_set = true;
1430 : 0 : dev->data->rx_queues[queue_idx] = rxq;
1431 : 0 : rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
1432 : :
1433 : 0 : use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
1434 : :
1435 [ # # ]: 0 : if (!use_def_burst_func) {
1436 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1437 : : "satisfied. Rx Burst Bulk Alloc function will be "
1438 : : "used on port=%d, queue=%d.",
1439 : : rxq->port_id, rxq->queue_id);
1440 : : } else {
1441 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1442 : : "not satisfied, Scattered Rx is requested. "
1443 : : "on port=%d, queue=%d.",
1444 : : rxq->port_id, rxq->queue_id);
1445 : 0 : ad->rx_bulk_alloc_allowed = false;
1446 : : }
1447 : :
1448 : : return 0;
1449 : : }
1450 : :
1451 : : void
1452 : 0 : ice_rx_queue_release(void *rxq)
1453 : : {
1454 : : struct ci_rx_queue *q = (struct ci_rx_queue *)rxq;
1455 : :
1456 [ # # ]: 0 : if (!q) {
1457 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
1458 : 0 : return;
1459 : : }
1460 : :
1461 [ # # ]: 0 : if (q->rx_rel_mbufs != NULL)
1462 : 0 : q->rx_rel_mbufs(q);
1463 : 0 : rte_free(q->sw_ring);
1464 : 0 : rte_memzone_free(q->mz);
1465 : 0 : rte_free(q);
1466 : : }
1467 : :
1468 : : /**
1469 : : * ice_calc_ts_ring_count - Calculate the number of timestamp descriptors
1470 : : * @hw: pointer to the hardware structure
1471 : : * @tx_desc_count: number of Tx descriptors in the ring
1472 : : *
1473 : : * Return: the number of timestamp descriptors
1474 : : */
1475 : : static uint16_t
1476 : : ice_calc_ts_ring_count(struct ice_hw *hw, u16 tx_desc_count)
1477 : : {
1478 : : u16 prof = ICE_TXTIME_CTX_FETCH_PROF_ID_0;
1479 : : u16 max_fetch_desc = 0;
1480 : : u16 fetch;
1481 : : u32 reg;
1482 : : u16 i;
1483 : :
1484 [ # # ]: 0 : for (i = 0; i < ICE_TXTIME_FETCH_PROFILE_CNT; i++) {
1485 : 0 : reg = rd32(hw, E830_GLTXTIME_FETCH_PROFILE(prof, 0));
1486 : 0 : fetch = FIELD_GET(E830_GLTXTIME_FETCH_PROFILE_FETCH_TS_DESC_M, reg);
1487 : 0 : max_fetch_desc = max(fetch, max_fetch_desc);
1488 : : }
1489 : :
1490 [ # # ]: 0 : if (!max_fetch_desc)
1491 : : max_fetch_desc = ICE_TXTIME_FETCH_TS_DESC_DFLT;
1492 : :
1493 : 0 : max_fetch_desc = RTE_ALIGN(max_fetch_desc, ICE_REQ_DESC_MULTIPLE);
1494 : :
1495 : 0 : return tx_desc_count + max_fetch_desc;
1496 : : }
1497 : :
1498 : : int
1499 : 0 : ice_tx_queue_setup(struct rte_eth_dev *dev,
1500 : : uint16_t queue_idx,
1501 : : uint16_t nb_desc,
1502 : : unsigned int socket_id,
1503 : : const struct rte_eth_txconf *tx_conf)
1504 : : {
1505 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1506 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1507 : 0 : struct ice_vsi *vsi = pf->main_vsi;
1508 : : struct ci_tx_queue *txq;
1509 : : const struct rte_memzone *tz;
1510 : : uint32_t ring_size;
1511 : : uint16_t tx_rs_thresh, tx_free_thresh;
1512 : : uint64_t offloads;
1513 : :
1514 : 0 : offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
1515 : :
1516 [ # # ]: 0 : if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1517 [ # # ]: 0 : nb_desc > ICE_MAX_RING_DESC ||
1518 : : nb_desc < ICE_MIN_RING_DESC) {
1519 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
1520 : : "invalid", nb_desc);
1521 : 0 : return -EINVAL;
1522 : : }
1523 : :
1524 : : /**
1525 : : * The following two parameters control the setting of the RS bit on
1526 : : * transmit descriptors. TX descriptors will have their RS bit set
1527 : : * after txq->tx_rs_thresh descriptors have been used. The TX
1528 : : * descriptor ring will be cleaned after txq->tx_free_thresh
1529 : : * descriptors are used or if the number of descriptors required to
1530 : : * transmit a packet is greater than the number of free TX descriptors.
1531 : : *
1532 : : * The following constraints must be satisfied:
1533 : : * - tx_rs_thresh must be greater than 0.
1534 : : * - tx_rs_thresh must be less than the size of the ring minus 2.
1535 : : * - tx_rs_thresh must be less than or equal to tx_free_thresh.
1536 : : * - tx_rs_thresh must be a divisor of the ring size.
1537 : : * - tx_free_thresh must be greater than 0.
1538 : : * - tx_free_thresh must be less than the size of the ring minus 3.
1539 : : * - tx_free_thresh + tx_rs_thresh must not exceed nb_desc.
1540 : : *
1541 : : * One descriptor in the TX ring is used as a sentinel to avoid a H/W
1542 : : * race condition, hence the maximum threshold constraints. When set
1543 : : * to zero use default values.
1544 : : */
1545 [ # # ]: 0 : tx_free_thresh = (uint16_t)(tx_conf->tx_free_thresh ?
1546 : : tx_conf->tx_free_thresh :
1547 : : ICE_DEFAULT_TX_FREE_THRESH);
1548 : : /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */
1549 : 0 : tx_rs_thresh =
1550 [ # # ]: 0 : (ICE_DEFAULT_TX_RSBIT_THRESH + tx_free_thresh > nb_desc) ?
1551 : : nb_desc - tx_free_thresh : ICE_DEFAULT_TX_RSBIT_THRESH;
1552 [ # # ]: 0 : if (tx_conf->tx_rs_thresh)
1553 : : tx_rs_thresh = tx_conf->tx_rs_thresh;
1554 [ # # ]: 0 : if (tx_rs_thresh + tx_free_thresh > nb_desc) {
1555 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh + tx_free_thresh must not "
1556 : : "exceed nb_desc. (tx_rs_thresh=%u "
1557 : : "tx_free_thresh=%u nb_desc=%u port = %d queue=%d)",
1558 : : (unsigned int)tx_rs_thresh,
1559 : : (unsigned int)tx_free_thresh,
1560 : : (unsigned int)nb_desc,
1561 : : (int)dev->data->port_id,
1562 : : (int)queue_idx);
1563 : 0 : return -EINVAL;
1564 : : }
1565 [ # # ]: 0 : if (tx_rs_thresh >= (nb_desc - 2)) {
1566 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1567 : : "number of TX descriptors minus 2. "
1568 : : "(tx_rs_thresh=%u port=%d queue=%d)",
1569 : : (unsigned int)tx_rs_thresh,
1570 : : (int)dev->data->port_id,
1571 : : (int)queue_idx);
1572 : 0 : return -EINVAL;
1573 : : }
1574 [ # # ]: 0 : if (tx_free_thresh >= (nb_desc - 3)) {
1575 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1576 : : "tx_free_thresh must be less than the "
1577 : : "number of TX descriptors minus 3. "
1578 : : "(tx_free_thresh=%u port=%d queue=%d)",
1579 : : (unsigned int)tx_free_thresh,
1580 : : (int)dev->data->port_id,
1581 : : (int)queue_idx);
1582 : 0 : return -EINVAL;
1583 : : }
1584 [ # # ]: 0 : if (tx_rs_thresh > tx_free_thresh) {
1585 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or "
1586 : : "equal to tx_free_thresh. (tx_free_thresh=%u"
1587 : : " tx_rs_thresh=%u port=%d queue=%d)",
1588 : : (unsigned int)tx_free_thresh,
1589 : : (unsigned int)tx_rs_thresh,
1590 : : (int)dev->data->port_id,
1591 : : (int)queue_idx);
1592 : 0 : return -EINVAL;
1593 : : }
1594 [ # # ]: 0 : if ((nb_desc % tx_rs_thresh) != 0) {
1595 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
1596 : : "number of TX descriptors. (tx_rs_thresh=%u"
1597 : : " port=%d queue=%d)",
1598 : : (unsigned int)tx_rs_thresh,
1599 : : (int)dev->data->port_id,
1600 : : (int)queue_idx);
1601 : 0 : return -EINVAL;
1602 : : }
1603 [ # # ]: 0 : if (!rte_is_power_of_2(tx_rs_thresh)) {
1604 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u port=%d queue=%d)",
1605 : : (unsigned int)tx_rs_thresh,
1606 : : (int)dev->data->port_id,
1607 : : (int)queue_idx);
1608 : 0 : return -EINVAL;
1609 : : }
1610 [ # # # # ]: 0 : if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
1611 : 0 : PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
1612 : : "tx_rs_thresh is greater than 1. "
1613 : : "(tx_rs_thresh=%u port=%d queue=%d)",
1614 : : (unsigned int)tx_rs_thresh,
1615 : : (int)dev->data->port_id,
1616 : : (int)queue_idx);
1617 : 0 : return -EINVAL;
1618 : : }
1619 : :
1620 : : /* Free memory if needed. */
1621 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx]) {
1622 : 0 : ice_tx_queue_release(dev->data->tx_queues[queue_idx]);
1623 : 0 : dev->data->tx_queues[queue_idx] = NULL;
1624 : : }
1625 : :
1626 : : /* Allocate the TX queue data structure. */
1627 : 0 : txq = rte_zmalloc_socket(NULL,
1628 : : sizeof(struct ci_tx_queue),
1629 : : RTE_CACHE_LINE_SIZE,
1630 : : socket_id);
1631 [ # # ]: 0 : if (!txq) {
1632 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1633 : : "tx queue structure");
1634 : 0 : return -ENOMEM;
1635 : : }
1636 : :
1637 : : /* Allocate TX hardware ring descriptors. */
1638 : : ring_size = sizeof(struct ci_tx_desc) * ICE_MAX_NUM_DESC_BY_MAC(hw);
1639 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1640 : 0 : tz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
1641 : : ring_size, ICE_RING_BASE_ALIGN,
1642 : : socket_id);
1643 [ # # ]: 0 : if (!tz) {
1644 : 0 : ice_tx_queue_release(txq);
1645 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
1646 : 0 : return -ENOMEM;
1647 : : }
1648 : :
1649 : 0 : txq->mz = tz;
1650 : 0 : txq->nb_tx_desc = nb_desc;
1651 [ # # ]: 0 : txq->tx_rs_thresh = tx_rs_thresh;
1652 : 0 : txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
1653 : 0 : txq->tx_free_thresh = tx_free_thresh;
1654 : 0 : txq->queue_id = queue_idx;
1655 : :
1656 : 0 : txq->reg_idx = vsi->base_queue + queue_idx;
1657 : 0 : txq->port_id = dev->data->port_id;
1658 : 0 : txq->fast_free_mp = offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ?
1659 [ # # ]: 0 : (void *)UINTPTR_MAX : NULL;
1660 : 0 : txq->offloads = offloads;
1661 : 0 : txq->ice_vsi = vsi;
1662 : 0 : txq->tx_deferred_start = tx_conf->tx_deferred_start;
1663 : :
1664 : 0 : txq->tx_ring_dma = tz->iova;
1665 : 0 : txq->ci_tx_ring = tz->addr;
1666 : :
1667 : : /* Allocate software ring */
1668 : 0 : txq->sw_ring =
1669 : 0 : rte_zmalloc_socket(NULL,
1670 : : sizeof(struct ci_tx_entry) * nb_desc,
1671 : : RTE_CACHE_LINE_SIZE,
1672 : : socket_id);
1673 [ # # ]: 0 : if (!txq->sw_ring) {
1674 : 0 : ice_tx_queue_release(txq);
1675 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
1676 : 0 : return -ENOMEM;
1677 : : }
1678 : :
1679 : : /* Allocate RS last_id tracking array */
1680 : 0 : uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
1681 : 0 : txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
1682 : : RTE_CACHE_LINE_SIZE, socket_id);
1683 [ # # ]: 0 : if (txq->rs_last_id == NULL) {
1684 : 0 : ice_tx_queue_release(txq);
1685 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
1686 : 0 : return -ENOMEM;
1687 : : }
1688 : :
1689 [ # # # # ]: 0 : if (vsi->type == ICE_VSI_PF && (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)) {
1690 [ # # ]: 0 : if (hw->phy_model != ICE_PHY_E830) {
1691 : 0 : ice_tx_queue_release(txq);
1692 : 0 : PMD_INIT_LOG(ERR, "Tx Time Queue is not supported on this device");
1693 : 0 : return -EINVAL;
1694 : : }
1695 : :
1696 : 0 : txq->tsq = rte_zmalloc_socket(NULL, sizeof(struct ice_txtime),
1697 : : RTE_CACHE_LINE_SIZE, socket_id);
1698 [ # # ]: 0 : if (!txq->tsq) {
1699 : 0 : ice_tx_queue_release(txq);
1700 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for tx time queue structure");
1701 : 0 : return -ENOMEM;
1702 : : }
1703 : :
1704 : : int ret =
1705 : 0 : rte_mbuf_dyn_tx_timestamp_register(&txq->tsq->ts_offset,
1706 : : &txq->tsq->ts_flag);
1707 [ # # ]: 0 : if (ret) {
1708 : 0 : ice_tx_queue_release(txq);
1709 : 0 : PMD_INIT_LOG(ERR, "Cannot register Tx mbuf field/flag for timestamp");
1710 : 0 : return -EINVAL;
1711 : : }
1712 : :
1713 : 0 : txq->tsq->nb_ts_desc = ice_calc_ts_ring_count(ICE_VSI_TO_HW(vsi), txq->nb_tx_desc);
1714 : 0 : ring_size = sizeof(struct ice_ts_desc) * txq->tsq->nb_ts_desc;
1715 : 0 : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1716 : 0 : const struct rte_memzone *ts_z = rte_eth_dma_zone_reserve(dev, "ice_tstamp_ring",
1717 : : queue_idx, ring_size, ICE_RING_BASE_ALIGN, socket_id);
1718 [ # # ]: 0 : if (!ts_z) {
1719 : 0 : ice_tx_queue_release(txq);
1720 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX timestamp");
1721 : 0 : return -ENOMEM;
1722 : : }
1723 : 0 : txq->tsq->ts_mz = ts_z;
1724 : 0 : txq->tsq->ice_ts_ring = ts_z->addr;
1725 : : } else {
1726 : 0 : txq->tsq = NULL;
1727 : : }
1728 : :
1729 : 0 : ice_reset_tx_queue(txq);
1730 : 0 : txq->q_set = true;
1731 : 0 : dev->data->tx_queues[queue_idx] = txq;
1732 : 0 : ice_set_tx_function_flag(dev, txq);
1733 : :
1734 : 0 : return 0;
1735 : : }
1736 : :
1737 : : void
1738 : 0 : ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1739 : : {
1740 : 0 : ice_rx_queue_release(dev->data->rx_queues[qid]);
1741 : 0 : }
1742 : :
1743 : : void
1744 : 0 : ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1745 : : {
1746 : 0 : ice_tx_queue_release(dev->data->tx_queues[qid]);
1747 : 0 : }
1748 : :
1749 : : void
1750 : 0 : ice_tx_queue_release(void *txq)
1751 : : {
1752 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
1753 : :
1754 [ # # ]: 0 : if (!q) {
1755 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to TX queue is NULL");
1756 : 0 : return;
1757 : : }
1758 : :
1759 : 0 : ci_txq_release_all_mbufs(q, q->use_ctx);
1760 : 0 : rte_free(q->sw_ring);
1761 : 0 : rte_free(q->rs_last_id);
1762 [ # # ]: 0 : if (q->tsq) {
1763 : 0 : rte_memzone_free(q->tsq->ts_mz);
1764 : 0 : rte_free(q->tsq);
1765 : : }
1766 : 0 : rte_memzone_free(q->mz);
1767 : 0 : rte_free(q);
1768 : : }
1769 : :
1770 : : void
1771 : 0 : ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1772 : : struct rte_eth_rxq_info *qinfo)
1773 : : {
1774 : : struct ci_rx_queue *rxq;
1775 : :
1776 : 0 : rxq = dev->data->rx_queues[queue_id];
1777 : :
1778 : 0 : qinfo->mp = rxq->mp;
1779 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
1780 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
1781 : :
1782 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
1783 : 0 : qinfo->conf.rx_drop_en = rxq->drop_en;
1784 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
1785 : 0 : }
1786 : :
1787 : : void
1788 : 0 : ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1789 : : struct rte_eth_txq_info *qinfo)
1790 : : {
1791 : : struct ci_tx_queue *txq;
1792 : :
1793 : 0 : txq = dev->data->tx_queues[queue_id];
1794 : :
1795 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
1796 : :
1797 : 0 : qinfo->conf.tx_thresh.pthresh = ICE_DEFAULT_TX_PTHRESH;
1798 : 0 : qinfo->conf.tx_thresh.hthresh = ICE_DEFAULT_TX_HTHRESH;
1799 : 0 : qinfo->conf.tx_thresh.wthresh = ICE_DEFAULT_TX_WTHRESH;
1800 : :
1801 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
1802 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
1803 : 0 : qinfo->conf.offloads = txq->offloads;
1804 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
1805 : 0 : }
1806 : :
1807 : : int
1808 : 0 : ice_rx_queue_count(void *rx_queue)
1809 : : {
1810 : : #define ICE_RXQ_SCAN_INTERVAL 4
1811 : : volatile union ci_rx_flex_desc *rxdp;
1812 : : struct ci_rx_queue *rxq;
1813 : : uint16_t desc = 0;
1814 : :
1815 : : rxq = rx_queue;
1816 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
1817 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
1818 [ # # ]: 0 : rte_le_to_cpu_16(rxdp->wb.status_error0) &
1819 : : (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)) {
1820 : : /**
1821 : : * Check the DD bit of a rx descriptor of each 4 in a group,
1822 : : * to avoid checking too frequently and downgrading performance
1823 : : * too much.
1824 : : */
1825 : 0 : desc += ICE_RXQ_SCAN_INTERVAL;
1826 : 0 : rxdp += ICE_RXQ_SCAN_INTERVAL;
1827 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
1828 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail + desc - rxq->nb_rx_desc];
1829 : : }
1830 : :
1831 : 0 : return desc;
1832 : : }
1833 : :
1834 : : #define ICE_RX_FLEX_ERR0_BITS \
1835 : : ((1 << ICE_RX_FLEX_DESC_STATUS0_HBO_S) | \
1836 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1837 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1838 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1839 : : (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1840 : : (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
1841 : :
1842 : : /* Rx L3/L4 checksum */
1843 : : static inline uint64_t
1844 : 0 : ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
1845 : : {
1846 : : uint64_t flags = 0;
1847 : :
1848 : : /* check if HW has decoded the packet and checksum */
1849 [ # # ]: 0 : if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S))))
1850 : : return 0;
1851 : :
1852 [ # # ]: 0 : if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
1853 : : flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1854 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD |
1855 : : RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
1856 : : return flags;
1857 : : }
1858 : :
1859 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
1860 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
1861 : : else
1862 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
1863 : :
1864 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
1865 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
1866 : : else
1867 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
1868 : :
1869 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
1870 : 0 : flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
1871 : :
1872 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
1873 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
1874 : : else
1875 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
1876 : :
1877 : : return flags;
1878 : : }
1879 : :
1880 : : static inline void
1881 : 0 : ice_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ci_rx_flex_desc *rxdp)
1882 : : {
1883 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
1884 : : (1 << ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
1885 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1886 : 0 : mb->vlan_tci =
1887 : 0 : rte_le_to_cpu_16(rxdp->wb.l2tag1);
1888 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
1889 : : rte_le_to_cpu_16(rxdp->wb.l2tag1));
1890 : : } else {
1891 : 0 : mb->vlan_tci = 0;
1892 : : }
1893 : :
1894 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1895 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
1896 : : (1 << ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
1897 [ # # ]: 0 : if ((mb->ol_flags & RTE_MBUF_F_RX_VLAN_STRIPPED) == 0) {
1898 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1899 : : } else {
1900 : : /* if two tags, move Tag1 to outer tag field */
1901 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED | RTE_MBUF_F_RX_QINQ;
1902 : 0 : mb->vlan_tci_outer = mb->vlan_tci;
1903 : : }
1904 : 0 : mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
1905 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
1906 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
1907 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
1908 : : } else {
1909 : 0 : mb->vlan_tci_outer = 0;
1910 : : }
1911 : : #endif
1912 : : PMD_RX_LOG(DEBUG, "Mbuf vlan_tci: %u, vlan_tci_outer: %u",
1913 : : mb->vlan_tci, mb->vlan_tci_outer);
1914 : 0 : }
1915 : :
1916 : : #define ICE_LOOK_AHEAD 8
1917 : : #if (ICE_LOOK_AHEAD != 8)
1918 : : #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
1919 : : #endif
1920 : :
1921 : : #define ICE_PTP_TS_VALID 0x1
1922 : :
1923 : : static inline int
1924 : 0 : ice_rx_scan_hw_ring(struct ci_rx_queue *rxq)
1925 : : {
1926 : : volatile union ci_rx_flex_desc *rxdp;
1927 : : struct ci_rx_entry *rxep;
1928 : : struct rte_mbuf *mb;
1929 : : uint16_t stat_err0;
1930 : : uint16_t pkt_len, hdr_len;
1931 : : int32_t s[ICE_LOOK_AHEAD], nb_dd;
1932 : : int32_t i, j, nb_rx = 0;
1933 : : uint64_t pkt_flags = 0;
1934 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
1935 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1936 : : bool is_tsinit = false;
1937 : : uint64_t ts_ns;
1938 : : struct ice_vsi *vsi = rxq->ice_vsi;
1939 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1940 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
1941 : : #endif
1942 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
1943 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
1944 : :
1945 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1946 : :
1947 : : /* Make sure there is at least 1 packet to receive */
1948 [ # # ]: 0 : if (!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
1949 : : return 0;
1950 : :
1951 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
1952 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1953 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1954 : :
1955 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
1956 : : is_tsinit = 1;
1957 : : }
1958 : : #endif
1959 : :
1960 : : /**
1961 : : * Scan LOOK_AHEAD descriptors at a time to determine which
1962 : : * descriptors reference packets that are ready to be received.
1963 : : */
1964 [ # # ]: 0 : for (i = 0; i < ICE_RX_MAX_BURST; i += ICE_LOOK_AHEAD,
1965 : 0 : rxdp += ICE_LOOK_AHEAD, rxep += ICE_LOOK_AHEAD) {
1966 : : /* Read desc statuses backwards to avoid race condition */
1967 [ # # ]: 0 : for (j = ICE_LOOK_AHEAD - 1; j >= 0; j--)
1968 : 0 : s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1969 : :
1970 : : rte_atomic_thread_fence(rte_memory_order_acquire);
1971 : :
1972 : : /* Compute how many status bits were set */
1973 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < ICE_LOOK_AHEAD; j++)
1974 : 0 : nb_dd += s[j] & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
1975 : :
1976 : 0 : nb_rx += nb_dd;
1977 : :
1978 : : /* Translate descriptor info to mbuf parameters */
1979 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
1980 : 0 : mb = rxep[j].mbuf;
1981 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1982 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1983 : : mb->data_len = pkt_len;
1984 : 0 : mb->pkt_len = pkt_len;
1985 : :
1986 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
1987 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1988 : : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1989 : 0 : mb->data_len = pkt_len;
1990 : 0 : mb->pkt_len = pkt_len;
1991 : : } else {
1992 : 0 : mb->nb_segs = (uint16_t)(mb->nb_segs + mb->next->nb_segs);
1993 : 0 : mb->next->next = NULL;
1994 : 0 : hdr_len = rte_le_to_cpu_16(rxdp[j].wb.hdr_len_sph_flex_flags1) &
1995 : : ICE_RX_FLEX_DESC_HEADER_LEN_M;
1996 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1997 : : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1998 : 0 : mb->data_len = hdr_len;
1999 : 0 : mb->pkt_len = hdr_len + pkt_len;
2000 : 0 : mb->next->data_len = pkt_len;
2001 : : #ifdef RTE_ETHDEV_DEBUG_RX
2002 : : rte_pktmbuf_dump(stdout, mb, rte_pktmbuf_pkt_len(mb));
2003 : : #endif
2004 : : }
2005 : :
2006 : 0 : mb->ol_flags = 0;
2007 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
2008 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(stat_err0);
2009 : 0 : mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2010 : 0 : rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
2011 : 0 : ice_rxd_to_vlan_tci(mb, &rxdp[j]);
2012 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);
2013 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2014 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2015 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2016 : 0 : rxq->time_high =
2017 : 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
2018 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2019 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1,
2020 : : rxq->time_high);
2021 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2022 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2023 : : is_tsinit = false;
2024 : : } else {
2025 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2026 : 0 : rxq->hw_time_high += 1;
2027 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2028 : 0 : rxq->hw_time_low = rxq->time_high;
2029 : : }
2030 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2031 : 0 : (rte_get_timer_hz() / 1000);
2032 : 0 : *RTE_MBUF_DYNFIELD(mb,
2033 : : rxq->ts_offset,
2034 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2035 : 0 : pkt_flags |= rxq->ts_flag;
2036 : : }
2037 : :
2038 [ # # # # ]: 0 : if (ad->ptp_ena && ((mb->packet_type &
2039 : : RTE_PTYPE_L2_MASK) == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2040 : 0 : rxq->time_high =
2041 : 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
2042 : 0 : mb->timesync = rxq->queue_id;
2043 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2044 [ # # ]: 0 : if (rxdp[j].wb.time_stamp_low &
2045 : : ICE_PTP_TS_VALID)
2046 : 0 : pkt_flags |=
2047 : : RTE_MBUF_F_RX_IEEE1588_TMST;
2048 : : }
2049 : : #endif
2050 : 0 : mb->ol_flags |= pkt_flags;
2051 : : }
2052 : :
2053 [ # # ]: 0 : for (j = 0; j < ICE_LOOK_AHEAD; j++)
2054 : 0 : rxq->rx_stage[i + j] = rxep[j].mbuf;
2055 : :
2056 [ # # ]: 0 : if (nb_dd != ICE_LOOK_AHEAD)
2057 : : break;
2058 : : }
2059 : :
2060 : : /* Clear software ring entries */
2061 [ # # ]: 0 : for (i = 0; i < nb_rx; i++)
2062 : 0 : rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
2063 : :
2064 : : PMD_RX_LOG(DEBUG, "ice_rx_scan_hw_ring: "
2065 : : "port_id=%u, queue_id=%u, nb_rx=%d",
2066 : : rxq->port_id, rxq->queue_id, nb_rx);
2067 : :
2068 : : return nb_rx;
2069 : : }
2070 : :
2071 : : static inline uint16_t
2072 : : ice_rx_fill_from_stage(struct ci_rx_queue *rxq,
2073 : : struct rte_mbuf **rx_pkts,
2074 : : uint16_t nb_pkts)
2075 : : {
2076 : : uint16_t i;
2077 : 0 : struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
2078 : :
2079 : 0 : nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
2080 : :
2081 [ # # # # ]: 0 : for (i = 0; i < nb_pkts; i++)
2082 : 0 : rx_pkts[i] = stage[i];
2083 : :
2084 : 0 : rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
2085 : 0 : rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
2086 : :
2087 : : return nb_pkts;
2088 : : }
2089 : :
2090 : : static inline int
2091 : 0 : ice_rx_alloc_bufs(struct ci_rx_queue *rxq)
2092 : : {
2093 : : volatile union ci_rx_flex_desc *rxdp;
2094 : : struct ci_rx_entry *rxep;
2095 : : struct rte_mbuf *mb;
2096 : : uint16_t alloc_idx, i;
2097 : : uint64_t dma_addr;
2098 : : int diag, diag_pay;
2099 : : uint64_t pay_addr;
2100 : :
2101 : : /* Allocate buffers in bulk */
2102 : 0 : alloc_idx = (uint16_t)(rxq->rx_free_trigger -
2103 : 0 : (rxq->rx_free_thresh - 1));
2104 : 0 : rxep = &rxq->sw_ring[alloc_idx];
2105 [ # # ]: 0 : diag = rte_mbuf_raw_alloc_bulk(rxq->mp, (void *)rxep,
2106 : : rxq->rx_free_thresh);
2107 [ # # ]: 0 : if (unlikely(diag != 0)) {
2108 : : PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
2109 : : return -ENOMEM;
2110 : : }
2111 : :
2112 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
2113 : 0 : diag_pay = rte_mbuf_raw_alloc_bulk(rxq->rxseg[1].mp,
2114 [ # # ]: 0 : (void *)rxq->sw_split_buf, rxq->rx_free_thresh);
2115 [ # # ]: 0 : if (unlikely(diag_pay != 0)) {
2116 : 0 : rte_mbuf_raw_free_bulk(rxq->mp, (void *)rxep,
2117 [ # # ]: 0 : rxq->rx_free_thresh);
2118 : : PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk");
2119 : 0 : return -ENOMEM;
2120 : : }
2121 : : }
2122 : :
2123 : 0 : rxdp = &rxq->rx_flex_ring[alloc_idx];
2124 [ # # ]: 0 : for (i = 0; i < rxq->rx_free_thresh; i++) {
2125 [ # # ]: 0 : if (likely(i < (rxq->rx_free_thresh - 1)))
2126 : : /* Prefetch next mbuf */
2127 : 0 : rte_prefetch0(rxep[i + 1].mbuf);
2128 : :
2129 [ # # ]: 0 : mb = rxep[i].mbuf;
2130 : : rte_mbuf_refcnt_set(mb, 1);
2131 : 0 : mb->data_off = RTE_PKTMBUF_HEADROOM;
2132 : 0 : mb->nb_segs = 1;
2133 [ # # ]: 0 : mb->port = rxq->port_id;
2134 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
2135 : :
2136 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2137 : 0 : mb->next = NULL;
2138 : 0 : rxdp[i].read.hdr_addr = 0;
2139 : 0 : rxdp[i].read.pkt_addr = dma_addr;
2140 : : } else {
2141 : 0 : mb->next = rxq->sw_split_buf[i].mbuf;
2142 : : pay_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb->next));
2143 : 0 : rxdp[i].read.hdr_addr = dma_addr;
2144 : 0 : rxdp[i].read.pkt_addr = pay_addr;
2145 : : }
2146 : : }
2147 : :
2148 : : /* Update Rx tail register */
2149 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
2150 : :
2151 : 0 : rxq->rx_free_trigger =
2152 : 0 : (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
2153 [ # # ]: 0 : if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
2154 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
2155 : :
2156 : : return 0;
2157 : : }
2158 : :
2159 : : static inline uint16_t
2160 : 0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2161 : : {
2162 : : struct ci_rx_queue *rxq = (struct ci_rx_queue *)rx_queue;
2163 : : uint16_t nb_rx = 0;
2164 : :
2165 [ # # ]: 0 : if (!nb_pkts)
2166 : : return 0;
2167 : :
2168 [ # # ]: 0 : if (rxq->rx_nb_avail)
2169 : 0 : return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2170 : :
2171 : 0 : nb_rx = (uint16_t)ice_rx_scan_hw_ring(rxq);
2172 : 0 : rxq->rx_next_avail = 0;
2173 : 0 : rxq->rx_nb_avail = nb_rx;
2174 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
2175 : :
2176 [ # # ]: 0 : if (rxq->rx_tail > rxq->rx_free_trigger) {
2177 [ # # ]: 0 : if (ice_rx_alloc_bufs(rxq) != 0) {
2178 : : uint16_t i, j;
2179 : :
2180 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed +=
2181 : 0 : rxq->rx_free_thresh;
2182 : : PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
2183 : : "port_id=%u, queue_id=%u",
2184 : : rxq->port_id, rxq->queue_id);
2185 : 0 : rxq->rx_nb_avail = 0;
2186 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
2187 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
2188 : 0 : rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
2189 : :
2190 : : return 0;
2191 : : }
2192 : : }
2193 : :
2194 [ # # ]: 0 : if (rxq->rx_tail >= rxq->nb_rx_desc)
2195 : 0 : rxq->rx_tail = 0;
2196 : :
2197 [ # # ]: 0 : if (rxq->rx_nb_avail)
2198 : 0 : return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2199 : :
2200 : : return 0;
2201 : : }
2202 : :
2203 : : static uint16_t
2204 : 0 : ice_recv_pkts_bulk_alloc(void *rx_queue,
2205 : : struct rte_mbuf **rx_pkts,
2206 : : uint16_t nb_pkts)
2207 : : {
2208 : : uint16_t nb_rx = 0;
2209 : : uint16_t n;
2210 : : uint16_t count;
2211 : :
2212 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
2213 : : return nb_rx;
2214 : :
2215 [ # # ]: 0 : if (likely(nb_pkts <= ICE_RX_MAX_BURST))
2216 : 0 : return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
2217 : :
2218 [ # # ]: 0 : while (nb_pkts) {
2219 : 0 : n = RTE_MIN(nb_pkts, ICE_RX_MAX_BURST);
2220 : 0 : count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
2221 : 0 : nb_rx = (uint16_t)(nb_rx + count);
2222 : 0 : nb_pkts = (uint16_t)(nb_pkts - count);
2223 [ # # ]: 0 : if (count < n)
2224 : : break;
2225 : : }
2226 : :
2227 : : return nb_rx;
2228 : : }
2229 : :
2230 : : static uint16_t
2231 : 0 : ice_recv_scattered_pkts(void *rx_queue,
2232 : : struct rte_mbuf **rx_pkts,
2233 : : uint16_t nb_pkts)
2234 : : {
2235 : : struct ci_rx_queue *rxq = rx_queue;
2236 : 0 : volatile union ci_rx_flex_desc *rx_ring = rxq->rx_flex_ring;
2237 : : volatile union ci_rx_flex_desc *rxdp;
2238 : : union ci_rx_flex_desc rxd;
2239 : 0 : struct ci_rx_entry *sw_ring = rxq->sw_ring;
2240 : : struct ci_rx_entry *rxe;
2241 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
2242 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
2243 : : struct rte_mbuf *nmb; /* new allocated mbuf */
2244 : : struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2245 : 0 : uint16_t rx_id = rxq->rx_tail;
2246 : : uint16_t nb_rx = 0;
2247 : : uint16_t nb_hold = 0;
2248 : : uint16_t rx_packet_len;
2249 : : uint16_t rx_stat_err0;
2250 : : uint64_t dma_addr;
2251 : : uint64_t pkt_flags;
2252 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
2253 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2254 : : bool is_tsinit = false;
2255 : : uint64_t ts_ns;
2256 : : struct ice_vsi *vsi = rxq->ice_vsi;
2257 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2258 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
2259 : :
2260 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2261 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
2262 : :
2263 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
2264 : : is_tsinit = true;
2265 : : }
2266 : : #endif
2267 : :
2268 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2269 : 0 : rxdp = &rx_ring[rx_id];
2270 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2271 : :
2272 : : /* Check the DD bit first */
2273 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2274 : : break;
2275 : :
2276 : : /* allocate mbuf */
2277 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
2278 [ # # ]: 0 : if (unlikely(!nmb)) {
2279 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2280 : 0 : break;
2281 : : }
2282 : 0 : rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2283 : :
2284 : 0 : nb_hold++;
2285 : 0 : rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2286 : 0 : rx_id++;
2287 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
2288 : : rx_id = 0;
2289 : :
2290 : : /* Prefetch next mbuf */
2291 : 0 : rte_prefetch0(sw_ring[rx_id].mbuf);
2292 : :
2293 : : /**
2294 : : * When next RX descriptor is on a cache line boundary,
2295 : : * prefetch the next 4 RX descriptors and next 8 pointers
2296 : : * to mbufs.
2297 : : */
2298 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
2299 : 0 : rte_prefetch0(&rx_ring[rx_id]);
2300 : : rte_prefetch0(&sw_ring[rx_id]);
2301 : : }
2302 : :
2303 : 0 : rxm = rxe->mbuf;
2304 [ # # ]: 0 : rxe->mbuf = nmb;
2305 : : dma_addr =
2306 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2307 : :
2308 : : /* Set data buffer address and data length of the mbuf */
2309 : 0 : rxdp->read.hdr_addr = 0;
2310 : 0 : rxdp->read.pkt_addr = dma_addr;
2311 : 0 : rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
2312 : : ICE_RX_FLX_DESC_PKT_LEN_M;
2313 : 0 : rxm->data_len = rx_packet_len;
2314 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2315 : :
2316 : : /**
2317 : : * If this is the first buffer of the received packet, set the
2318 : : * pointer to the first mbuf of the packet and initialize its
2319 : : * context. Otherwise, update the total length and the number
2320 : : * of segments of the current scattered packet, and update the
2321 : : * pointer to the last mbuf of the current packet.
2322 : : */
2323 [ # # ]: 0 : if (!first_seg) {
2324 : : first_seg = rxm;
2325 : 0 : first_seg->nb_segs = 1;
2326 : 0 : first_seg->pkt_len = rx_packet_len;
2327 : : } else {
2328 : 0 : first_seg->pkt_len =
2329 : 0 : (uint16_t)(first_seg->pkt_len +
2330 : : rx_packet_len);
2331 : 0 : first_seg->nb_segs++;
2332 : 0 : last_seg->next = rxm;
2333 : : }
2334 : :
2335 : : /**
2336 : : * If this is not the last buffer of the received packet,
2337 : : * update the pointer to the last mbuf of the current scattered
2338 : : * packet and continue to parse the RX ring.
2339 : : */
2340 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_EOF_S))) {
2341 : : last_seg = rxm;
2342 : 0 : continue;
2343 : : }
2344 : :
2345 : : /**
2346 : : * This is the last buffer of the received packet. If the CRC
2347 : : * is not stripped by the hardware:
2348 : : * - Subtract the CRC length from the total packet length.
2349 : : * - If the last buffer only contains the whole CRC or a part
2350 : : * of it, free the mbuf associated to the last buffer. If part
2351 : : * of the CRC is also contained in the previous mbuf, subtract
2352 : : * the length of that CRC part from the data length of the
2353 : : * previous mbuf.
2354 : : */
2355 : 0 : rxm->next = NULL;
2356 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
2357 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
2358 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
2359 : : rte_pktmbuf_free_seg(rxm);
2360 : 0 : first_seg->nb_segs--;
2361 : 0 : last_seg->data_len =
2362 : 0 : (uint16_t)(last_seg->data_len -
2363 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
2364 : 0 : last_seg->next = NULL;
2365 : : } else
2366 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
2367 : : RTE_ETHER_CRC_LEN);
2368 [ # # ]: 0 : } else if (rx_packet_len == 0) {
2369 : : rte_pktmbuf_free_seg(rxm);
2370 : 0 : first_seg->nb_segs--;
2371 : 0 : last_seg->next = NULL;
2372 : : }
2373 : :
2374 : 0 : first_seg->port = rxq->port_id;
2375 : 0 : first_seg->ol_flags = 0;
2376 : 0 : first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2377 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2378 : 0 : ice_rxd_to_vlan_tci(first_seg, &rxd);
2379 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd);
2380 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2381 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2382 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2383 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2384 : 0 : rxq->time_high =
2385 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2386 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2387 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
2388 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2389 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2390 : : is_tsinit = false;
2391 : : } else {
2392 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2393 : 0 : rxq->hw_time_high += 1;
2394 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2395 : 0 : rxq->hw_time_low = rxq->time_high;
2396 : : }
2397 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2398 : 0 : (rte_get_timer_hz() / 1000);
2399 : 0 : *RTE_MBUF_DYNFIELD(first_seg,
2400 : : (rxq->ts_offset),
2401 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2402 : 0 : pkt_flags |= rxq->ts_flag;
2403 : : }
2404 : :
2405 [ # # # # ]: 0 : if (ad->ptp_ena && ((first_seg->packet_type & RTE_PTYPE_L2_MASK)
2406 : : == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2407 : 0 : rxq->time_high =
2408 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2409 : 0 : first_seg->timesync = rxq->queue_id;
2410 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2411 : : }
2412 : : #endif
2413 : 0 : first_seg->ol_flags |= pkt_flags;
2414 : : /* Prefetch data of first segment, if configured to do so. */
2415 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
2416 : : first_seg->data_off));
2417 : 0 : rx_pkts[nb_rx++] = first_seg;
2418 : : first_seg = NULL;
2419 : : }
2420 : :
2421 : : /* Record index of the next RX descriptor to probe. */
2422 : 0 : rxq->rx_tail = rx_id;
2423 : 0 : rxq->pkt_first_seg = first_seg;
2424 : 0 : rxq->pkt_last_seg = last_seg;
2425 : :
2426 : : /**
2427 : : * If the number of free RX descriptors is greater than the RX free
2428 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
2429 : : * register. Update the RDT with the value of the last processed RX
2430 : : * descriptor minus 1, to guarantee that the RDT register is never
2431 : : * equal to the RDH register, which creates a "full" ring situation
2432 : : * from the hardware point of view.
2433 : : */
2434 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2435 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2436 [ # # ]: 0 : rx_id = (uint16_t)(rx_id == 0 ?
2437 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2438 : : /* write TAIL register */
2439 : 0 : ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2440 : : nb_hold = 0;
2441 : : }
2442 : 0 : rxq->nb_rx_hold = nb_hold;
2443 : :
2444 : : /* return received packet in the burst */
2445 : 0 : return nb_rx;
2446 : : }
2447 : :
2448 : : const uint32_t *
2449 : 0 : ice_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
2450 : : {
2451 : 0 : struct ice_adapter *ad =
2452 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2453 : : const uint32_t *ptypes;
2454 : :
2455 : : static const uint32_t ptypes_os[] = {
2456 : : /* refers to ice_get_default_pkt_type() */
2457 : : RTE_PTYPE_L2_ETHER,
2458 : : RTE_PTYPE_L2_ETHER_TIMESYNC,
2459 : : RTE_PTYPE_L2_ETHER_LLDP,
2460 : : RTE_PTYPE_L2_ETHER_ARP,
2461 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2462 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2463 : : RTE_PTYPE_L4_FRAG,
2464 : : RTE_PTYPE_L4_ICMP,
2465 : : RTE_PTYPE_L4_NONFRAG,
2466 : : RTE_PTYPE_L4_SCTP,
2467 : : RTE_PTYPE_L4_TCP,
2468 : : RTE_PTYPE_L4_UDP,
2469 : : RTE_PTYPE_TUNNEL_GRENAT,
2470 : : RTE_PTYPE_TUNNEL_IP,
2471 : : RTE_PTYPE_INNER_L2_ETHER,
2472 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2473 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2474 : : RTE_PTYPE_INNER_L4_FRAG,
2475 : : RTE_PTYPE_INNER_L4_ICMP,
2476 : : RTE_PTYPE_INNER_L4_NONFRAG,
2477 : : RTE_PTYPE_INNER_L4_SCTP,
2478 : : RTE_PTYPE_INNER_L4_TCP,
2479 : : RTE_PTYPE_INNER_L4_UDP,
2480 : : };
2481 : :
2482 : : static const uint32_t ptypes_comms[] = {
2483 : : /* refers to ice_get_default_pkt_type() */
2484 : : RTE_PTYPE_L2_ETHER,
2485 : : RTE_PTYPE_L2_ETHER_TIMESYNC,
2486 : : RTE_PTYPE_L2_ETHER_LLDP,
2487 : : RTE_PTYPE_L2_ETHER_ARP,
2488 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2489 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2490 : : RTE_PTYPE_L4_FRAG,
2491 : : RTE_PTYPE_L4_ICMP,
2492 : : RTE_PTYPE_L4_NONFRAG,
2493 : : RTE_PTYPE_L4_SCTP,
2494 : : RTE_PTYPE_L4_TCP,
2495 : : RTE_PTYPE_L4_UDP,
2496 : : RTE_PTYPE_TUNNEL_GRENAT,
2497 : : RTE_PTYPE_TUNNEL_IP,
2498 : : RTE_PTYPE_INNER_L2_ETHER,
2499 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2500 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2501 : : RTE_PTYPE_INNER_L4_FRAG,
2502 : : RTE_PTYPE_INNER_L4_ICMP,
2503 : : RTE_PTYPE_INNER_L4_NONFRAG,
2504 : : RTE_PTYPE_INNER_L4_SCTP,
2505 : : RTE_PTYPE_INNER_L4_TCP,
2506 : : RTE_PTYPE_INNER_L4_UDP,
2507 : : RTE_PTYPE_TUNNEL_GTPC,
2508 : : RTE_PTYPE_TUNNEL_GTPU,
2509 : : RTE_PTYPE_L2_ETHER_PPPOE,
2510 : : };
2511 : :
2512 [ # # ]: 0 : if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS) {
2513 : 0 : *no_of_elements = RTE_DIM(ptypes_comms);
2514 : : ptypes = ptypes_comms;
2515 : : } else {
2516 : 0 : *no_of_elements = RTE_DIM(ptypes_os);
2517 : : ptypes = ptypes_os;
2518 : : }
2519 : :
2520 [ # # ]: 0 : if (ad->rx_func_type == ICE_RX_DEFAULT ||
2521 [ # # ]: 0 : ad->rx_func_type == ICE_RX_BULK_ALLOC ||
2522 [ # # ]: 0 : ad->rx_func_type == ICE_RX_SCATTERED ||
2523 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2 ||
2524 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_OFFLOAD ||
2525 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_SCATTERED ||
2526 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX2_SCATTERED_OFFLOAD ||
2527 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512 ||
2528 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512_SCATTERED ||
2529 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512_OFFLOAD ||
2530 [ # # ]: 0 : ad->rx_func_type == ICE_RX_AVX512_SCATTERED_OFFLOAD ||
2531 [ # # ]: 0 : ad->rx_func_type == ICE_RX_NEON ||
2532 : : ad->rx_func_type == ICE_RX_NEON_SCATTERED)
2533 : 0 : return ptypes;
2534 : :
2535 : : return NULL;
2536 : : }
2537 : :
2538 : : int
2539 : 0 : ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
2540 : : {
2541 : : volatile union ci_rx_flex_desc *rxdp;
2542 : : struct ci_rx_queue *rxq = rx_queue;
2543 : : uint32_t desc;
2544 : :
2545 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
2546 : : return -EINVAL;
2547 : :
2548 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
2549 : : return RTE_ETH_RX_DESC_UNAVAIL;
2550 : :
2551 : 0 : desc = rxq->rx_tail + offset;
2552 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
2553 : 0 : desc -= rxq->nb_rx_desc;
2554 : :
2555 : 0 : rxdp = &rxq->rx_flex_ring[desc];
2556 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
2557 : : (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
2558 : 0 : return RTE_ETH_RX_DESC_DONE;
2559 : :
2560 : : return RTE_ETH_RX_DESC_AVAIL;
2561 : : }
2562 : :
2563 : : int
2564 : 0 : ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
2565 : : {
2566 : : struct ci_tx_queue *txq = tx_queue;
2567 : : volatile uint64_t *status;
2568 : : uint64_t mask, expect;
2569 : : uint32_t desc;
2570 : :
2571 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
2572 : : return -EINVAL;
2573 : :
2574 : 0 : desc = txq->tx_tail + offset;
2575 : : /* go to next desc that has the RS bit */
2576 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
2577 : : txq->tx_rs_thresh;
2578 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
2579 : 0 : desc -= txq->nb_tx_desc;
2580 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
2581 : 0 : desc -= txq->nb_tx_desc;
2582 : : }
2583 : :
2584 : 0 : status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
2585 : : mask = rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M);
2586 : : expect = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE << CI_TXD_QW1_DTYPE_S);
2587 [ # # ]: 0 : if ((*status & mask) == expect)
2588 : 0 : return RTE_ETH_TX_DESC_DONE;
2589 : :
2590 : : return RTE_ETH_TX_DESC_FULL;
2591 : : }
2592 : :
2593 : : void
2594 : 0 : ice_free_queues(struct rte_eth_dev *dev)
2595 : : {
2596 : : uint16_t i;
2597 : :
2598 : 0 : PMD_INIT_FUNC_TRACE();
2599 : :
2600 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2601 [ # # ]: 0 : if (!dev->data->rx_queues[i])
2602 : 0 : continue;
2603 : 0 : ice_rx_queue_release(dev->data->rx_queues[i]);
2604 : 0 : dev->data->rx_queues[i] = NULL;
2605 : : }
2606 : 0 : dev->data->nb_rx_queues = 0;
2607 : :
2608 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2609 [ # # ]: 0 : if (!dev->data->tx_queues[i])
2610 : 0 : continue;
2611 : 0 : ice_tx_queue_release(dev->data->tx_queues[i]);
2612 : 0 : dev->data->tx_queues[i] = NULL;
2613 : : }
2614 : 0 : dev->data->nb_tx_queues = 0;
2615 : 0 : }
2616 : :
2617 : : #define ICE_FDIR_NUM_TX_DESC ICE_MIN_RING_DESC
2618 : : #define ICE_FDIR_NUM_RX_DESC ICE_MIN_RING_DESC
2619 : :
2620 : : int
2621 : 0 : ice_fdir_setup_tx_resources(struct ice_pf *pf)
2622 : : {
2623 : : struct ci_tx_queue *txq;
2624 : : const struct rte_memzone *tz = NULL;
2625 : : uint32_t ring_size;
2626 : : struct rte_eth_dev *dev;
2627 : :
2628 [ # # ]: 0 : if (!pf) {
2629 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2630 : 0 : return -EINVAL;
2631 : : }
2632 : :
2633 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2634 : :
2635 : : /* Allocate the TX queue data structure. */
2636 : 0 : txq = rte_zmalloc_socket("ice fdir tx queue",
2637 : : sizeof(struct ci_tx_queue),
2638 : : RTE_CACHE_LINE_SIZE,
2639 : : SOCKET_ID_ANY);
2640 [ # # ]: 0 : if (!txq) {
2641 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2642 : : "tx queue structure.");
2643 : 0 : return -ENOMEM;
2644 : : }
2645 : :
2646 : : /* Allocate TX hardware ring descriptors. */
2647 : : ring_size = sizeof(struct ci_tx_desc) * ICE_FDIR_NUM_TX_DESC;
2648 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2649 : :
2650 : 0 : tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
2651 : : ICE_FDIR_QUEUE_ID, ring_size,
2652 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2653 [ # # ]: 0 : if (!tz) {
2654 : 0 : ice_tx_queue_release(txq);
2655 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
2656 : 0 : return -ENOMEM;
2657 : : }
2658 : :
2659 : 0 : txq->mz = tz;
2660 : 0 : txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
2661 : 0 : txq->queue_id = ICE_FDIR_QUEUE_ID;
2662 : 0 : txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2663 : 0 : txq->ice_vsi = pf->fdir.fdir_vsi;
2664 : :
2665 : 0 : txq->tx_ring_dma = tz->iova;
2666 : 0 : txq->ci_tx_ring = (struct ci_tx_desc *)tz->addr;
2667 : : /*
2668 : : * don't need to allocate software ring and reset for the fdir
2669 : : * program queue just set the queue has been configured.
2670 : : */
2671 : 0 : txq->q_set = true;
2672 : 0 : pf->fdir.txq = txq;
2673 : :
2674 : :
2675 : 0 : return ICE_SUCCESS;
2676 : : }
2677 : :
2678 : : int
2679 : 0 : ice_fdir_setup_rx_resources(struct ice_pf *pf)
2680 : : {
2681 : : struct ci_rx_queue *rxq;
2682 : : const struct rte_memzone *rz = NULL;
2683 : : uint32_t ring_size;
2684 : : struct rte_eth_dev *dev;
2685 : :
2686 [ # # ]: 0 : if (!pf) {
2687 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2688 : 0 : return -EINVAL;
2689 : : }
2690 : :
2691 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2692 : :
2693 : : /* Allocate the RX queue data structure. */
2694 : 0 : rxq = rte_zmalloc_socket("ice fdir rx queue",
2695 : : sizeof(struct ci_rx_queue),
2696 : : RTE_CACHE_LINE_SIZE,
2697 : : SOCKET_ID_ANY);
2698 [ # # ]: 0 : if (!rxq) {
2699 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2700 : : "rx queue structure.");
2701 : 0 : return -ENOMEM;
2702 : : }
2703 : :
2704 : : /* Allocate RX hardware ring descriptors. */
2705 : : ring_size = sizeof(union ci_rx_flex_desc) * ICE_FDIR_NUM_RX_DESC;
2706 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2707 : :
2708 : 0 : rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
2709 : : ICE_FDIR_QUEUE_ID, ring_size,
2710 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2711 [ # # ]: 0 : if (!rz) {
2712 : 0 : ice_rx_queue_release(rxq);
2713 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
2714 : 0 : return -ENOMEM;
2715 : : }
2716 : :
2717 : 0 : rxq->mz = rz;
2718 : 0 : rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
2719 : 0 : rxq->queue_id = ICE_FDIR_QUEUE_ID;
2720 : 0 : rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2721 : 0 : rxq->ice_vsi = pf->fdir.fdir_vsi;
2722 : :
2723 : 0 : rxq->rx_ring_phys_addr = rz->iova;
2724 : 0 : memset(rz->addr, 0, ICE_FDIR_NUM_RX_DESC *
2725 : : sizeof(union ci_rx_flex_desc));
2726 : 0 : rxq->rx_flex_ring = (union ci_rx_flex_desc *)rz->addr;
2727 : :
2728 : : /*
2729 : : * Don't need to allocate software ring and reset for the fdir
2730 : : * rx queue, just set the queue has been configured.
2731 : : */
2732 : 0 : rxq->q_set = true;
2733 : 0 : pf->fdir.rxq = rxq;
2734 : :
2735 : 0 : rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
2736 : :
2737 : 0 : return ICE_SUCCESS;
2738 : : }
2739 : :
2740 : : uint16_t
2741 : 0 : ice_recv_pkts(void *rx_queue,
2742 : : struct rte_mbuf **rx_pkts,
2743 : : uint16_t nb_pkts)
2744 : : {
2745 : : struct ci_rx_queue *rxq = rx_queue;
2746 : 0 : volatile union ci_rx_flex_desc *rx_ring = rxq->rx_flex_ring;
2747 : : volatile union ci_rx_flex_desc *rxdp;
2748 : : union ci_rx_flex_desc rxd;
2749 : 0 : struct ci_rx_entry *sw_ring = rxq->sw_ring;
2750 : : struct ci_rx_entry *rxe;
2751 : : struct rte_mbuf *nmb; /* new allocated mbuf */
2752 : : struct rte_mbuf *nmb_pay; /* new allocated payload mbuf */
2753 : : struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2754 : 0 : uint16_t rx_id = rxq->rx_tail;
2755 : : uint16_t nb_rx = 0;
2756 : : uint16_t nb_hold = 0;
2757 : : uint16_t rx_packet_len;
2758 : : uint16_t rx_header_len;
2759 : : uint16_t rx_stat_err0;
2760 : : uint64_t dma_addr;
2761 : : uint64_t pkt_flags;
2762 : 0 : uint32_t *ptype_tbl = rxq->ice_vsi->adapter->ptype_tbl;
2763 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2764 : : bool is_tsinit = false;
2765 : : uint64_t ts_ns;
2766 : : struct ice_vsi *vsi = rxq->ice_vsi;
2767 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2768 : : struct ice_adapter *ad = rxq->ice_vsi->adapter;
2769 : :
2770 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2771 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
2772 : :
2773 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
2774 : : is_tsinit = 1;
2775 : : }
2776 : : #endif
2777 : :
2778 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2779 : 0 : rxdp = &rx_ring[rx_id];
2780 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2781 : :
2782 : : /* Check the DD bit first */
2783 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2784 : : break;
2785 : :
2786 : : /* allocate header mbuf */
2787 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
2788 [ # # ]: 0 : if (unlikely(!nmb)) {
2789 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2790 : 0 : break;
2791 : : }
2792 : :
2793 : 0 : rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2794 : :
2795 : 0 : nb_hold++;
2796 : 0 : rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2797 : 0 : rx_id++;
2798 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
2799 : : rx_id = 0;
2800 : 0 : rxm = rxe->mbuf;
2801 [ # # ]: 0 : rxe->mbuf = nmb;
2802 : : dma_addr =
2803 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2804 : :
2805 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2806 : : /**
2807 : : * fill the read format of descriptor with physic address in
2808 : : * new allocated mbuf: nmb
2809 : : */
2810 : 0 : rxdp->read.hdr_addr = 0;
2811 : 0 : rxdp->read.pkt_addr = dma_addr;
2812 : : } else {
2813 : : /* allocate payload mbuf */
2814 : 0 : nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
2815 [ # # ]: 0 : if (unlikely(!nmb_pay)) {
2816 : 0 : rxq->ice_vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2817 : 0 : rxe->mbuf = NULL;
2818 : : nb_hold--;
2819 [ # # ]: 0 : if (unlikely(rx_id == 0))
2820 : 0 : rx_id = rxq->nb_rx_desc;
2821 : :
2822 : 0 : rx_id--;
2823 : 0 : rte_pktmbuf_free(nmb);
2824 : 0 : break;
2825 : : }
2826 : :
2827 : 0 : nmb->next = nmb_pay;
2828 : 0 : nmb_pay->next = NULL;
2829 : :
2830 : : /**
2831 : : * fill the read format of descriptor with physic address in
2832 : : * new allocated mbuf: nmb
2833 : : */
2834 : 0 : rxdp->read.hdr_addr = dma_addr;
2835 : 0 : rxdp->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb_pay));
2836 : : }
2837 : :
2838 : : /* fill old mbuf with received descriptor: rxd */
2839 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2840 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
2841 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2842 : 0 : rxm->nb_segs = 1;
2843 : 0 : rxm->next = NULL;
2844 : : /* calculate rx_packet_len of the received pkt */
2845 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2846 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2847 : 0 : rxm->data_len = rx_packet_len;
2848 : 0 : rxm->pkt_len = rx_packet_len;
2849 : : } else {
2850 : 0 : rxm->nb_segs = (uint16_t)(rxm->nb_segs + rxm->next->nb_segs);
2851 : 0 : rxm->next->next = NULL;
2852 : : /* calculate rx_packet_len of the received pkt */
2853 : 0 : rx_header_len = rte_le_to_cpu_16(rxd.wb.hdr_len_sph_flex_flags1) &
2854 : : ICE_RX_FLEX_DESC_HEADER_LEN_M;
2855 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2856 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2857 : 0 : rxm->data_len = rx_header_len;
2858 : 0 : rxm->pkt_len = rx_header_len + rx_packet_len;
2859 : 0 : rxm->next->data_len = rx_packet_len;
2860 : :
2861 : : #ifdef RTE_ETHDEV_DEBUG_RX
2862 : : rte_pktmbuf_dump(stdout, rxm, rte_pktmbuf_pkt_len(rxm));
2863 : : #endif
2864 : : }
2865 : :
2866 : 0 : rxm->port = rxq->port_id;
2867 : 0 : rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2868 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2869 : 0 : ice_rxd_to_vlan_tci(rxm, &rxd);
2870 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
2871 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2872 : : #ifndef RTE_NET_INTEL_USE_16BYTE_DESC
2873 [ # # ]: 0 : if (rxq->ts_flag > 0 &&
2874 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2875 : 0 : rxq->time_high =
2876 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2877 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2878 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
2879 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2880 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2881 : : is_tsinit = false;
2882 : : } else {
2883 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2884 : 0 : rxq->hw_time_high += 1;
2885 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2886 : 0 : rxq->hw_time_low = rxq->time_high;
2887 : : }
2888 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2889 : 0 : (rte_get_timer_hz() / 1000);
2890 : 0 : *RTE_MBUF_DYNFIELD(rxm,
2891 : : (rxq->ts_offset),
2892 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2893 : 0 : pkt_flags |= rxq->ts_flag;
2894 : : }
2895 : :
2896 [ # # # # ]: 0 : if (ad->ptp_ena && ((rxm->packet_type & RTE_PTYPE_L2_MASK) ==
2897 : : RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2898 : 0 : rxq->time_high =
2899 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2900 : 0 : rxm->timesync = rxq->queue_id;
2901 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2902 : : }
2903 : : #endif
2904 : 0 : rxm->ol_flags |= pkt_flags;
2905 : : /* copy old mbuf to rx_pkts */
2906 : 0 : rx_pkts[nb_rx++] = rxm;
2907 : : }
2908 : :
2909 : 0 : rxq->rx_tail = rx_id;
2910 : : /**
2911 : : * If the number of free RX descriptors is greater than the RX free
2912 : : * threshold of the queue, advance the receive tail register of queue.
2913 : : * Update that register with the value of the last processed RX
2914 : : * descriptor minus 1.
2915 : : */
2916 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2917 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2918 [ # # ]: 0 : rx_id = (uint16_t)(rx_id == 0 ?
2919 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2920 : : /* write TAIL register */
2921 : 0 : ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2922 : : nb_hold = 0;
2923 : : }
2924 : 0 : rxq->nb_rx_hold = nb_hold;
2925 : :
2926 : : /* return received packet in the burst */
2927 : 0 : return nb_rx;
2928 : : }
2929 : :
2930 : : static inline void
2931 : 0 : ice_parse_tunneling_params(uint64_t ol_flags,
2932 : : union ci_tx_offload tx_offload,
2933 : : uint32_t *cd_tunneling)
2934 : : {
2935 : : /* EIPT: External (outer) IP header type */
2936 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
2937 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4;
2938 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)
2939 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4_NO_CSUM;
2940 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)
2941 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV6;
2942 : :
2943 : : /* EIPLEN: External (outer) IP header length, in DWords */
2944 : 0 : *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
2945 : : ICE_TXD_CTX_QW0_EIPLEN_S;
2946 : :
2947 : : /* L4TUNT: L4 Tunneling Type */
2948 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2949 : : case RTE_MBUF_F_TX_TUNNEL_IPIP:
2950 : : /* for non UDP / GRE tunneling, set to 00b */
2951 : : break;
2952 : 0 : case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2953 : : case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
2954 : : case RTE_MBUF_F_TX_TUNNEL_GTP:
2955 : : case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2956 : 0 : *cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
2957 : 0 : break;
2958 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2959 : 0 : *cd_tunneling |= ICE_TXD_CTX_GRE_TUNNELING;
2960 : 0 : break;
2961 : : default:
2962 : : PMD_TX_LOG(ERR, "Tunnel type not supported");
2963 : : return;
2964 : : }
2965 : :
2966 : : /* L4TUNLEN: L4 Tunneling Length, in Words
2967 : : *
2968 : : * We depend on app to set rte_mbuf.l2_len correctly.
2969 : : * For IP in GRE it should be set to the length of the GRE
2970 : : * header;
2971 : : * For MAC in GRE or MAC in UDP it should be set to the length
2972 : : * of the GRE or UDP headers plus the inner MAC up to including
2973 : : * its last Ethertype.
2974 : : * If MPLS labels exists, it should include them as well.
2975 : : */
2976 : 0 : *cd_tunneling |= (tx_offload.l2_len >> 1) <<
2977 : : ICE_TXD_CTX_QW0_NATLEN_S;
2978 : :
2979 : : /**
2980 : : * Calculate the tunneling UDP checksum.
2981 : : * Shall be set only if L4TUNT = 01b and EIPT is not zero
2982 : : */
2983 [ # # # # ]: 0 : if ((*cd_tunneling & ICE_TXD_CTX_QW0_EIPT_M) &&
2984 : 0 : (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) &&
2985 [ # # ]: 0 : (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2986 : 0 : *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M;
2987 : : }
2988 : :
2989 : : /* Construct the tx flags */
2990 : : static inline uint64_t
2991 : : ice_build_ctob(uint32_t td_cmd,
2992 : : uint32_t td_offset,
2993 : : uint16_t size,
2994 : : uint32_t td_tag)
2995 : : {
2996 : : return rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DATA |
2997 : : ((uint64_t)td_cmd << CI_TXD_QW1_CMD_S) |
2998 : : ((uint64_t)td_offset << CI_TXD_QW1_OFFSET_S) |
2999 : : ((uint64_t)size << CI_TXD_QW1_TX_BUF_SZ_S) |
3000 : : ((uint64_t)td_tag << CI_TXD_QW1_L2TAG1_S));
3001 : : }
3002 : :
3003 : : /* Check if the context descriptor is needed for TX offloading */
3004 : : static inline uint16_t
3005 : 0 : ice_calc_context_desc(uint64_t flags)
3006 : : {
3007 : : static uint64_t mask = RTE_MBUF_F_TX_TCP_SEG |
3008 : : RTE_MBUF_F_TX_UDP_SEG |
3009 : : RTE_MBUF_F_TX_QINQ |
3010 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM |
3011 : : RTE_MBUF_F_TX_TUNNEL_MASK |
3012 : : RTE_MBUF_F_TX_IEEE1588_TMST;
3013 : :
3014 : 0 : return (flags & mask) ? 1 : 0;
3015 : : }
3016 : :
3017 : : /* set ice TSO context descriptor */
3018 : : static inline uint64_t
3019 : 0 : ice_set_tso_ctx(uint64_t ol_flags, const struct rte_mbuf *mbuf, union ci_tx_offload tx_offload)
3020 : : {
3021 : : uint64_t ctx_desc = 0;
3022 : : uint32_t cd_cmd, hdr_len, cd_tso_len;
3023 : :
3024 [ # # ]: 0 : if (!tx_offload.l4_len) {
3025 : : PMD_TX_LOG(DEBUG, "L4 length set to 0");
3026 : : return ctx_desc;
3027 : : }
3028 : :
3029 : 0 : hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
3030 : 0 : hdr_len += (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
3031 [ # # ]: 0 : tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
3032 : :
3033 : : cd_cmd = CI_TX_CTX_DESC_TSO;
3034 : 0 : cd_tso_len = mbuf->pkt_len - hdr_len;
3035 : 0 : ctx_desc |= ((uint64_t)cd_cmd << CI_TXD_QW1_CMD_S) |
3036 : 0 : ((uint64_t)cd_tso_len << ICE_TXD_CTX_QW1_TSO_LEN_S) |
3037 : 0 : ((uint64_t)mbuf->tso_segsz << ICE_TXD_CTX_QW1_MSS_S);
3038 : :
3039 : 0 : return ctx_desc;
3040 : : }
3041 : :
3042 : : /* compute a context descriptor if one is necessary based on the ol_flags
3043 : : *
3044 : : * Returns 0 if no descriptor is necessary.
3045 : : * Returns 1 if one is necessary and the contents of the descriptor are returned
3046 : : * in the values pointed to by qw0 and qw1.
3047 : : */
3048 : : static __rte_always_inline uint16_t
3049 : 0 : get_context_desc(uint64_t ol_flags, const struct rte_mbuf *tx_pkt,
3050 : : const union ci_tx_offload *tx_offload, const struct ci_tx_queue *txq,
3051 : : uint64_t *qw0, uint64_t *qw1)
3052 : : {
3053 : : uint16_t cd_l2tag2 = 0;
3054 : : uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
3055 : 0 : uint32_t cd_tunneling_params = 0;
3056 : 0 : uint64_t ptp_tx_index = txq->ice_vsi->adapter->ptp_tx_index;
3057 : :
3058 [ # # ]: 0 : if (ice_calc_context_desc(ol_flags) == 0)
3059 : : return 0;
3060 : :
3061 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
3062 : 0 : ice_parse_tunneling_params(ol_flags, *tx_offload, &cd_tunneling_params);
3063 : :
3064 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
3065 : 0 : cd_type_cmd_tso_mss |= ice_set_tso_ctx(ol_flags, tx_pkt, *tx_offload);
3066 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
3067 : 0 : cd_type_cmd_tso_mss |=
3068 : : ((uint64_t)CI_TX_CTX_DESC_TSYN << CI_TXD_QW1_CMD_S) |
3069 : 0 : ((ptp_tx_index << ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);
3070 : :
3071 : :
3072 : : /* TX context descriptor based double VLAN insert */
3073 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_QINQ) {
3074 : 0 : cd_l2tag2 = tx_pkt->vlan_tci_outer;
3075 : 0 : cd_type_cmd_tso_mss |= ((uint64_t)CI_TX_CTX_DESC_IL2TAG2 << CI_TXD_QW1_CMD_S);
3076 : : }
3077 : :
3078 : 0 : *qw0 = rte_cpu_to_le_32(cd_tunneling_params) |
3079 : 0 : ((uint64_t)rte_cpu_to_le_16(cd_l2tag2) << 32);
3080 : 0 : *qw1 = rte_cpu_to_le_64(cd_type_cmd_tso_mss);
3081 : :
3082 : 0 : return 1;
3083 : : }
3084 : :
3085 : : static uint16_t
3086 : 0 : ice_get_ts_tail(struct ci_tx_queue *txq)
3087 : : {
3088 : 0 : return txq->tsq->ts_tail;
3089 : : }
3090 : :
3091 : : static uint16_t
3092 : 0 : ice_write_ts_desc(struct ci_tx_queue *txq,
3093 : : struct rte_mbuf *tx_pkt,
3094 : : uint16_t tx_id,
3095 : : uint16_t ts_id)
3096 : : {
3097 : 0 : uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, txq->tsq->ts_offset, uint64_t *);
3098 : 0 : uint32_t tstamp = (uint32_t)(txtime % NS_PER_S) >> ICE_TXTIME_CTX_RESOLUTION_128NS;
3099 [ # # ]: 0 : const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
3100 : 0 : __le32 ts_desc = rte_cpu_to_le_32(FIELD_PREP(ICE_TXTIME_TX_DESC_IDX_M, desc_tx_id) |
3101 : : FIELD_PREP(ICE_TXTIME_STAMP_M, tstamp));
3102 : :
3103 : 0 : txq->tsq->ice_ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
3104 : 0 : ts_id++;
3105 : :
3106 : : /* To prevent an MDD, when wrapping the tstamp
3107 : : * ring create additional TS descriptors equal
3108 : : * to the number of the fetch TS descriptors
3109 : : * value. HW will merge the TS descriptors with
3110 : : * the same timestamp value into a single
3111 : : * descriptor.
3112 : : */
3113 [ # # ]: 0 : if (ts_id == txq->tsq->nb_ts_desc) {
3114 : 0 : uint16_t fetch = txq->tsq->nb_ts_desc - txq->nb_tx_desc;
3115 : : ts_id = 0;
3116 [ # # ]: 0 : for (; ts_id < fetch; ts_id++)
3117 : 0 : txq->tsq->ice_ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
3118 : : }
3119 : 0 : return ts_id;
3120 : : }
3121 : :
3122 : : static void
3123 : 0 : ice_write_ts_tail(struct ci_tx_queue *txq, uint16_t ts_tail)
3124 : : {
3125 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, ts_tail);
3126 : 0 : txq->tsq->ts_tail = ts_tail;
3127 : 0 : }
3128 : :
3129 : : uint16_t
3130 : 0 : ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
3131 : : {
3132 : 0 : const struct ci_timestamp_queue_fns ts_fns = {
3133 : : .get_ts_tail = ice_get_ts_tail,
3134 : : .write_ts_desc = ice_write_ts_desc,
3135 : : .write_ts_tail = ice_write_ts_tail,
3136 : : };
3137 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
3138 : :
3139 [ # # # # ]: 0 : if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
3140 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_TAG_IN_DATA_DESC, CI_TAG_IN_CTX_DESC,
3141 : : get_context_desc, NULL, &ts_fns);
3142 : :
3143 : : /* QinQ always places the outer tag in the ctx desc, inner in the data desc. */
3144 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_TAG_IN_DATA_DESC, CI_TAG_IN_CTX_DESC,
3145 : : get_context_desc, NULL, NULL);
3146 : : }
3147 : :
3148 : : static int
3149 : 0 : ice_tx_done_cleanup_full(struct ci_tx_queue *txq,
3150 : : uint32_t free_cnt)
3151 : : {
3152 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
3153 : : uint16_t i, tx_last, tx_id;
3154 : : uint16_t nb_tx_free_last;
3155 : : uint16_t nb_tx_to_clean;
3156 : : uint32_t pkt_cnt;
3157 : :
3158 : : /* Start free mbuf from the next of tx_tail */
3159 : 0 : tx_last = txq->tx_tail;
3160 : 0 : tx_id = swr_ring[tx_last].next_id;
3161 : :
3162 [ # # ]: 0 : if (txq->nb_tx_free == 0 && ci_tx_xmit_cleanup(txq))
3163 : : return 0;
3164 : :
3165 : 0 : nb_tx_to_clean = txq->nb_tx_free;
3166 : : nb_tx_free_last = txq->nb_tx_free;
3167 [ # # ]: 0 : if (!free_cnt)
3168 : 0 : free_cnt = txq->nb_tx_desc;
3169 : :
3170 : : /* Loop through swr_ring to count the amount of
3171 : : * freeable mubfs and packets.
3172 : : */
3173 [ # # ]: 0 : for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
3174 : 0 : for (i = 0; i < nb_tx_to_clean &&
3175 [ # # # # ]: 0 : pkt_cnt < free_cnt &&
3176 : 0 : tx_id != tx_last; i++) {
3177 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
3178 : : /*
3179 : : * last segment in the packet,
3180 : : * increment packet count
3181 : : */
3182 [ # # ]: 0 : pkt_cnt += swr_ring[tx_id].mbuf->next == NULL ? 1 : 0;
3183 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
3184 : 0 : swr_ring[tx_id].mbuf = NULL;
3185 : :
3186 : : }
3187 : :
3188 : 0 : tx_id = swr_ring[tx_id].next_id;
3189 : : }
3190 : :
3191 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
3192 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
3193 : : break;
3194 : :
3195 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
3196 : : if (ci_tx_xmit_cleanup(txq))
3197 : : break;
3198 : :
3199 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
3200 : : nb_tx_free_last = txq->nb_tx_free;
3201 : : }
3202 : : }
3203 : :
3204 : 0 : return (int)pkt_cnt;
3205 : : }
3206 : :
3207 : : #ifdef RTE_ARCH_X86
3208 : : static int
3209 : : ice_tx_done_cleanup_vec(struct ci_tx_queue *txq __rte_unused,
3210 : : uint32_t free_cnt __rte_unused)
3211 : : {
3212 : : return -ENOTSUP;
3213 : : }
3214 : :
3215 : : enum rte_vect_max_simd
3216 : 0 : ice_get_max_simd_bitwidth(void)
3217 : : {
3218 : 0 : return ci_get_x86_max_simd_bitwidth();
3219 : : }
3220 : : #endif
3221 : :
3222 : : static int
3223 : 0 : ice_tx_done_cleanup_simple(struct ci_tx_queue *txq,
3224 : : uint32_t free_cnt)
3225 : : {
3226 : : int i, n, cnt;
3227 : :
3228 [ # # # # ]: 0 : if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
3229 : 0 : free_cnt = txq->nb_tx_desc;
3230 : :
3231 : 0 : cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
3232 : :
3233 [ # # ]: 0 : for (i = 0; i < cnt; i += n) {
3234 [ # # ]: 0 : if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
3235 : : break;
3236 : :
3237 : : n = ci_tx_free_bufs_simple(txq);
3238 : :
3239 [ # # ]: 0 : if (n == 0)
3240 : : break;
3241 : : }
3242 : :
3243 : 0 : return i;
3244 : : }
3245 : :
3246 : : int
3247 : 0 : ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
3248 : : {
3249 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
3250 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[q->port_id];
3251 : 0 : struct ice_adapter *ad =
3252 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3253 : :
3254 : : #ifdef RTE_ARCH_X86
3255 [ # # ]: 0 : if (ad->tx_vec_allowed)
3256 : : return ice_tx_done_cleanup_vec(q, free_cnt);
3257 : : #endif
3258 [ # # ]: 0 : if (ad->tx_simple_allowed)
3259 : 0 : return ice_tx_done_cleanup_simple(q, free_cnt);
3260 : : else
3261 : 0 : return ice_tx_done_cleanup_full(q, free_cnt);
3262 : : }
3263 : :
3264 : : static uint16_t
3265 : 0 : ice_xmit_pkts_simple(void *tx_queue,
3266 : : struct rte_mbuf **tx_pkts,
3267 : : uint16_t nb_pkts)
3268 : : {
3269 [ # # ]: 0 : return ci_xmit_pkts_simple(tx_queue, tx_pkts, nb_pkts);
3270 : : }
3271 : :
3272 : : static const struct ci_rx_path_info ice_rx_path_infos[] = {
3273 : : [ICE_RX_DEFAULT] = {
3274 : : .pkt_burst = ice_recv_pkts,
3275 : : .info = "Scalar",
3276 : : .features = {
3277 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS
3278 : : }
3279 : : },
3280 : : [ICE_RX_SCATTERED] = {
3281 : : .pkt_burst = ice_recv_scattered_pkts,
3282 : : .info = "Scalar Scattered",
3283 : : .features = {
3284 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS,
3285 : : .scattered = true
3286 : : }
3287 : : },
3288 : : [ICE_RX_BULK_ALLOC] = {
3289 : : .pkt_burst = ice_recv_pkts_bulk_alloc,
3290 : : .info = "Scalar Bulk Alloc",
3291 : : .features = {
3292 : : .rx_offloads = ICE_RX_SCALAR_OFFLOADS,
3293 : : .bulk_alloc = true
3294 : : }
3295 : : },
3296 : : #ifdef RTE_ARCH_X86
3297 : : [ICE_RX_AVX2] = {
3298 : : .pkt_burst = ice_recv_pkts_vec_avx2,
3299 : : .info = "Vector AVX2",
3300 : : .features = {
3301 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3302 : : .simd_width = RTE_VECT_SIMD_256,
3303 : : .bulk_alloc = true
3304 : : }
3305 : : },
3306 : : [ICE_RX_AVX2_SCATTERED] = {
3307 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx2,
3308 : : .info = "Vector AVX2 Scattered",
3309 : : .features = {
3310 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3311 : : .simd_width = RTE_VECT_SIMD_256,
3312 : : .scattered = true,
3313 : : .bulk_alloc = true
3314 : : }
3315 : : },
3316 : : [ICE_RX_AVX2_OFFLOAD] = {
3317 : : .pkt_burst = ice_recv_pkts_vec_avx2_offload,
3318 : : .info = "Offload Vector AVX2",
3319 : : .features = {
3320 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3321 : : .simd_width = RTE_VECT_SIMD_256,
3322 : : .bulk_alloc = true
3323 : : }
3324 : : },
3325 : : [ICE_RX_AVX2_SCATTERED_OFFLOAD] = {
3326 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx2_offload,
3327 : : .info = "Offload Vector AVX2 Scattered",
3328 : : .features = {
3329 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3330 : : .simd_width = RTE_VECT_SIMD_256,
3331 : : .scattered = true,
3332 : : .bulk_alloc = true
3333 : : }
3334 : : },
3335 : : #ifdef CC_AVX512_SUPPORT
3336 : : [ICE_RX_AVX512] = {
3337 : : .pkt_burst = ice_recv_pkts_vec_avx512,
3338 : : .info = "Vector AVX512",
3339 : : .features = {
3340 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3341 : : .simd_width = RTE_VECT_SIMD_512,
3342 : : .bulk_alloc = true
3343 : : }
3344 : : },
3345 : : [ICE_RX_AVX512_SCATTERED] = {
3346 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx512,
3347 : : .info = "Vector AVX512 Scattered",
3348 : : .features = {
3349 : : .rx_offloads = ICE_RX_VECTOR_OFFLOADS,
3350 : : .simd_width = RTE_VECT_SIMD_512,
3351 : : .scattered = true,
3352 : : .bulk_alloc = true
3353 : : }
3354 : : },
3355 : : [ICE_RX_AVX512_OFFLOAD] = {
3356 : : .pkt_burst = ice_recv_pkts_vec_avx512_offload,
3357 : : .info = "Offload Vector AVX512",
3358 : : .features = {
3359 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3360 : : .simd_width = RTE_VECT_SIMD_512,
3361 : : .bulk_alloc = true
3362 : : }
3363 : : },
3364 : : [ICE_RX_AVX512_SCATTERED_OFFLOAD] = {
3365 : : .pkt_burst = ice_recv_scattered_pkts_vec_avx512_offload,
3366 : : .info = "Offload Vector AVX512 Scattered",
3367 : : .features = {
3368 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3369 : : .simd_width = RTE_VECT_SIMD_512,
3370 : : .scattered = true,
3371 : : .bulk_alloc = true
3372 : : }
3373 : : },
3374 : : #endif
3375 : : #elif defined(RTE_ARCH_ARM64)
3376 : : [ICE_RX_NEON] = {
3377 : : .pkt_burst = ice_recv_pkts_vec,
3378 : : .info = "Vector Neon",
3379 : : .features = {
3380 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3381 : : .simd_width = RTE_VECT_SIMD_128,
3382 : : .bulk_alloc = true
3383 : : }
3384 : : },
3385 : : [ICE_RX_NEON_SCATTERED] = {
3386 : : .pkt_burst = ice_recv_scattered_pkts_vec,
3387 : : .info = "Vector Neon Scattered",
3388 : : .features = {
3389 : : .rx_offloads = ICE_RX_VECTOR_OFFLOAD_OFFLOADS,
3390 : : .simd_width = RTE_VECT_SIMD_128,
3391 : : .scattered = true,
3392 : : .bulk_alloc = true
3393 : : }
3394 : : },
3395 : : #endif
3396 : : };
3397 : :
3398 : : void __rte_cold
3399 : 0 : ice_set_rx_function(struct rte_eth_dev *dev)
3400 : : {
3401 : 0 : PMD_INIT_FUNC_TRACE();
3402 : 0 : struct ice_adapter *ad =
3403 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3404 : : enum rte_vect_max_simd rx_simd_width = RTE_VECT_SIMD_DISABLED;
3405 : 0 : struct ci_rx_path_features req_features = {
3406 : 0 : .rx_offloads = dev->data->dev_conf.rxmode.offloads,
3407 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3408 : : };
3409 : :
3410 : : /* If the device has started the function has already been selected. */
3411 [ # # ]: 0 : if (dev->data->dev_started)
3412 : 0 : goto out;
3413 : :
3414 : : #ifdef RTE_ARCH_X86
3415 [ # # # # ]: 0 : if (ad->ptp_ena || !ad->rx_bulk_alloc_allowed) {
3416 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3417 : : } else {
3418 : 0 : rx_simd_width = ice_get_max_simd_bitwidth();
3419 [ # # ]: 0 : if (rx_simd_width >= RTE_VECT_SIMD_256)
3420 [ # # ]: 0 : if (ice_rx_vec_dev_check(dev) == -1)
3421 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3422 : : }
3423 : : #elif defined(RTE_ARCH_ARM64)
3424 : : if (ad->ptp_ena || !ad->rx_bulk_alloc_allowed) {
3425 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3426 : : } else {
3427 : : rx_simd_width = ice_get_max_simd_bitwidth();
3428 : : if (rx_simd_width >= RTE_VECT_SIMD_128)
3429 : : if (ice_rx_vec_dev_check(dev) == -1)
3430 : : rx_simd_width = RTE_VECT_SIMD_DISABLED;
3431 : : }
3432 : : #endif
3433 : :
3434 : 0 : req_features.simd_width = rx_simd_width;
3435 [ # # ]: 0 : if (dev->data->scattered_rx)
3436 : 0 : req_features.scattered = true;
3437 [ # # ]: 0 : if (ad->rx_bulk_alloc_allowed)
3438 : 0 : req_features.bulk_alloc = true;
3439 : :
3440 : 0 : ad->rx_func_type = ci_rx_path_select(&req_features,
3441 : : &ice_rx_path_infos[0],
3442 : : RTE_DIM(ice_rx_path_infos),
3443 : : ICE_RX_DEFAULT);
3444 : : #ifdef RTE_ARCH_X86
3445 : : int i;
3446 : :
3447 [ # # ]: 0 : if (ice_rx_path_infos[ad->rx_func_type].features.simd_width >= RTE_VECT_SIMD_256)
3448 : : /* Vector function selected. Prepare the rxq accordingly. */
3449 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++)
3450 [ # # ]: 0 : if (dev->data->rx_queues[i])
3451 : 0 : ice_rxq_vec_setup(dev->data->rx_queues[i]);
3452 : : #elif defined(RTE_ARCH_ARM64)
3453 : : int i;
3454 : :
3455 : : if (ice_rx_path_infos[ad->rx_func_type].features.simd_width >= RTE_VECT_SIMD_128)
3456 : : /* Vector function selected. Prepare the rxq accordingly. */
3457 : : for (i = 0; i < dev->data->nb_rx_queues; i++)
3458 : : if (dev->data->rx_queues[i])
3459 : : ice_rxq_vec_setup(dev->data->rx_queues[i]);
3460 : : #endif
3461 : :
3462 : 0 : out:
3463 : 0 : dev->rx_pkt_burst = ice_rx_path_infos[ad->rx_func_type].pkt_burst;
3464 : 0 : PMD_DRV_LOG(DEBUG, "Using %s (port %d).",
3465 : : ice_rx_path_infos[ad->rx_func_type].info, dev->data->port_id);
3466 : 0 : }
3467 : :
3468 : : int
3469 : 0 : ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3470 : : struct rte_eth_burst_mode *mode)
3471 : : {
3472 : 0 : eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
3473 : : int ret = -EINVAL;
3474 : : unsigned int i;
3475 : :
3476 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_rx_path_infos); ++i) {
3477 [ # # ]: 0 : if (pkt_burst == ice_rx_path_infos[i].pkt_burst) {
3478 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3479 : 0 : ice_rx_path_infos[i].info);
3480 : : ret = 0;
3481 : 0 : break;
3482 : : }
3483 : : }
3484 : :
3485 : 0 : return ret;
3486 : : }
3487 : :
3488 : : void __rte_cold
3489 : 0 : ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ci_tx_queue *txq)
3490 : : {
3491 : 0 : struct ice_adapter *ad =
3492 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3493 : :
3494 : : /* Use a simple Tx queue if possible (only fast free is allowed) */
3495 : 0 : ad->tx_simple_allowed =
3496 : 0 : (txq->offloads ==
3497 [ # # ]: 0 : (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
3498 [ # # ]: 0 : txq->tx_rs_thresh >= ICE_TX_MAX_BURST);
3499 : :
3500 [ # # ]: 0 : if (ad->tx_simple_allowed)
3501 : 0 : PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
3502 : : txq->queue_id);
3503 : : else
3504 : 0 : PMD_INIT_LOG(DEBUG,
3505 : : "Simple Tx can NOT be enabled on Tx queue %u.",
3506 : : txq->queue_id);
3507 : 0 : }
3508 : :
3509 : : /*********************************************************************
3510 : : *
3511 : : * TX prep functions
3512 : : *
3513 : : **********************************************************************/
3514 : : /* The default values of TSO MSS */
3515 : : #define ICE_MIN_TSO_MSS 64
3516 : : #define ICE_MAX_TSO_MSS 9728
3517 : : #define ICE_MAX_TSO_FRAME_SIZE 262144
3518 : :
3519 : : /*Check for empty mbuf*/
3520 : : static inline uint16_t
3521 : : ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
3522 : : {
3523 : : struct rte_mbuf *txd = tx_pkt;
3524 : :
3525 [ # # ]: 0 : while (txd != NULL) {
3526 [ # # ]: 0 : if (txd->data_len == 0)
3527 : : return -1;
3528 : 0 : txd = txd->next;
3529 : : }
3530 : :
3531 : : return 0;
3532 : : }
3533 : :
3534 : : static const struct ci_tx_path_info ice_tx_path_infos[] = {
3535 : : [ICE_TX_DEFAULT] = {
3536 : : .pkt_burst = ice_xmit_pkts,
3537 : : .info = "Scalar",
3538 : : .features = {
3539 : : .tx_offloads = ICE_TX_SCALAR_OFFLOADS
3540 : : },
3541 : : .pkt_prep = ice_prep_pkts,
3542 : : .supports_ctx = true
3543 : : },
3544 : : [ICE_TX_SIMPLE] = {
3545 : : .pkt_burst = ice_xmit_pkts_simple,
3546 : : .info = "Scalar Simple",
3547 : : .features = {
3548 : : .tx_offloads = ICE_TX_SCALAR_OFFLOADS,
3549 : : .simple_tx = true
3550 : : },
3551 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3552 : : },
3553 : : #ifdef RTE_ARCH_X86
3554 : : [ICE_TX_AVX2] = {
3555 : : .pkt_burst = ice_xmit_pkts_vec_avx2,
3556 : : .info = "Vector AVX2",
3557 : : .features = {
3558 : : .tx_offloads = CI_TX_VECTOR_OFFLOADS,
3559 : : .simd_width = RTE_VECT_SIMD_256
3560 : : },
3561 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3562 : : },
3563 : : [ICE_TX_AVX2_OFFLOAD] = {
3564 : : .pkt_burst = ice_xmit_pkts_vec_avx2_offload,
3565 : : .info = "Offload Vector AVX2",
3566 : : .features = {
3567 : : .tx_offloads = CI_TX_VEC_OFFLOAD_PATH_OFFLOADS,
3568 : : .simd_width = RTE_VECT_SIMD_256
3569 : : },
3570 : : .pkt_prep = ice_prep_pkts
3571 : : },
3572 : : [ICE_TX_AVX2_CTX_OFFLOAD] = {
3573 : : .pkt_burst = ice_xmit_pkts_vec_avx2_ctx_offload,
3574 : : .info = "Offload Vector AVX2 Ctx",
3575 : : .features = {
3576 : : .tx_offloads = CI_TX_VEC_CTX_OFFLOAD_PATH_OFFLOADS,
3577 : : .simd_width = RTE_VECT_SIMD_256
3578 : : },
3579 : : .pkt_prep = ice_prep_pkts,
3580 : : .supports_ctx = true
3581 : : },
3582 : : #ifdef CC_AVX512_SUPPORT
3583 : : [ICE_TX_AVX512] = {
3584 : : .pkt_burst = ice_xmit_pkts_vec_avx512,
3585 : : .info = "Vector AVX512",
3586 : : .features = {
3587 : : .tx_offloads = CI_TX_VECTOR_OFFLOADS,
3588 : : .simd_width = RTE_VECT_SIMD_512
3589 : : },
3590 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3591 : : },
3592 : : [ICE_TX_AVX512_OFFLOAD] = {
3593 : : .pkt_burst = ice_xmit_pkts_vec_avx512_offload,
3594 : : .info = "Offload Vector AVX512",
3595 : : .features = {
3596 : : .tx_offloads = CI_TX_VEC_OFFLOAD_PATH_OFFLOADS,
3597 : : .simd_width = RTE_VECT_SIMD_512
3598 : : },
3599 : : .pkt_prep = ice_prep_pkts
3600 : : },
3601 : : [ICE_TX_AVX512_CTX_OFFLOAD] = {
3602 : : .pkt_burst = ice_xmit_pkts_vec_avx512_ctx_offload,
3603 : : .info = "Offload Vector AVX512 Ctx",
3604 : : .features = {
3605 : : .tx_offloads = CI_TX_VEC_CTX_OFFLOAD_PATH_OFFLOADS,
3606 : : .simd_width = RTE_VECT_SIMD_512
3607 : : },
3608 : : .pkt_prep = ice_prep_pkts,
3609 : : .supports_ctx = true
3610 : : },
3611 : : #endif
3612 : : #elif defined(RTE_ARCH_ARM64)
3613 : : [ICE_TX_NEON] = {
3614 : : .pkt_burst = ice_xmit_pkts_vec,
3615 : : .info = "Vector Neon",
3616 : : .features = {
3617 : : .tx_offloads = CI_TX_VECTOR_OFFLOADS,
3618 : : .simd_width = RTE_VECT_SIMD_128
3619 : : },
3620 : : .pkt_prep = rte_eth_tx_pkt_prepare_dummy
3621 : : },
3622 : : #endif
3623 : : };
3624 : :
3625 : : /* Tx mbuf check */
3626 : : static uint16_t
3627 : 0 : ice_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
3628 : : {
3629 : : struct ci_tx_queue *txq = tx_queue;
3630 : : uint16_t idx;
3631 : : struct rte_mbuf *mb;
3632 : : bool pkt_error = false;
3633 : : uint16_t good_pkts = nb_pkts;
3634 : 0 : const char *reason = NULL;
3635 : 0 : struct ice_adapter *adapter = txq->ice_vsi->adapter;
3636 : : uint64_t ol_flags;
3637 : 0 : enum ice_tx_func_type tx_func_type = adapter->tx_func_type;
3638 : :
3639 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
3640 : 0 : mb = tx_pkts[idx];
3641 : 0 : ol_flags = mb->ol_flags;
3642 : :
3643 [ # # # # ]: 0 : if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_MBUF) &&
3644 : 0 : (rte_mbuf_check(mb, 1, &reason) != 0)) {
3645 : : PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
3646 : : pkt_error = true;
3647 : : break;
3648 : : }
3649 : :
3650 [ # # ]: 0 : if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SIZE) &&
3651 [ # # # # ]: 0 : (mb->data_len > mb->pkt_len ||
3652 [ # # ]: 0 : mb->data_len < ICE_TX_MIN_PKT_LEN ||
3653 : : mb->data_len > ICE_FRAME_SIZE_MAX)) {
3654 : : PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %d)",
3655 : : mb->data_len, ICE_TX_MIN_PKT_LEN, ICE_FRAME_SIZE_MAX);
3656 : : pkt_error = true;
3657 : : break;
3658 : : }
3659 : :
3660 [ # # ]: 0 : if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SEGMENT) {
3661 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
3662 : : /**
3663 : : * No TSO case: nb->segs, pkt_len to not exceed
3664 : : * the limites.
3665 : : */
3666 [ # # ]: 0 : if (mb->nb_segs > ICE_TX_MTU_SEG_MAX) {
3667 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
3668 : : mb->nb_segs, ICE_TX_MTU_SEG_MAX);
3669 : : pkt_error = true;
3670 : : break;
3671 : : }
3672 [ # # ]: 0 : if (mb->pkt_len > ICE_FRAME_SIZE_MAX) {
3673 : : PMD_TX_LOG(ERR, "INVALID mbuf: pkt_len (%d) exceeds HW limit, maximum allowed value is %d",
3674 : : mb->nb_segs, ICE_FRAME_SIZE_MAX);
3675 : : pkt_error = true;
3676 : : break;
3677 : : }
3678 : : } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
3679 : : /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
3680 : : * the limits.
3681 : : */
3682 [ # # ]: 0 : if (mb->tso_segsz < ICE_MIN_TSO_MSS ||
3683 : : mb->tso_segsz > ICE_MAX_TSO_MSS) {
3684 : : /**
3685 : : * MSS outside the range are considered malicious
3686 : : */
3687 : : PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
3688 : : mb->tso_segsz, ICE_MIN_TSO_MSS, ICE_MAX_TSO_MSS);
3689 : : pkt_error = true;
3690 : : break;
3691 : : }
3692 [ # # ]: 0 : if (mb->nb_segs > ((struct ci_tx_queue *)tx_queue)->nb_tx_desc) {
3693 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
3694 : : pkt_error = true;
3695 : : break;
3696 : : }
3697 : : }
3698 : : }
3699 : :
3700 [ # # ]: 0 : if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_OFFLOAD) {
3701 [ # # ]: 0 : if (ol_flags & ICE_TX_OFFLOAD_NOTSUP_MASK) {
3702 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
3703 : : pkt_error = true;
3704 : : break;
3705 : : }
3706 : :
3707 [ # # ]: 0 : if (rte_validate_tx_offload(mb) != 0) {
3708 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
3709 : : pkt_error = true;
3710 : : break;
3711 : : }
3712 : : }
3713 : : }
3714 : :
3715 [ # # ]: 0 : if (pkt_error) {
3716 : 0 : txq->mbuf_errors++;
3717 : : good_pkts = idx;
3718 [ # # ]: 0 : if (good_pkts == 0)
3719 : : return 0;
3720 : : }
3721 : :
3722 : 0 : return ice_tx_path_infos[tx_func_type].pkt_burst(tx_queue, tx_pkts, good_pkts);
3723 : : }
3724 : :
3725 : : uint16_t
3726 : 0 : ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
3727 : : uint16_t nb_pkts)
3728 : : {
3729 : : int i, ret;
3730 : : uint64_t ol_flags;
3731 : : struct rte_mbuf *m;
3732 : :
3733 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3734 : 0 : m = tx_pkts[i];
3735 : 0 : ol_flags = m->ol_flags;
3736 : :
3737 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
3738 : : /**
3739 : : * No TSO case: nb->segs, pkt_len to not exceed
3740 : : * the limites.
3741 : : */
3742 [ # # ]: 0 : (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
3743 [ # # ]: 0 : m->pkt_len > ICE_FRAME_SIZE_MAX)) {
3744 : 0 : rte_errno = EINVAL;
3745 : 0 : return i;
3746 [ # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
3747 : : /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
3748 : : * the limits.
3749 : : */
3750 [ # # ]: 0 : (m->tso_segsz < ICE_MIN_TSO_MSS ||
3751 : 0 : m->tso_segsz > ICE_MAX_TSO_MSS ||
3752 : 0 : m->nb_segs >
3753 [ # # ]: 0 : ((struct ci_tx_queue *)tx_queue)->nb_tx_desc ||
3754 [ # # ]: 0 : m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
3755 : : /**
3756 : : * MSS outside the range are considered malicious
3757 : : */
3758 : 0 : rte_errno = EINVAL;
3759 : 0 : return i;
3760 : : }
3761 : :
3762 [ # # ]: 0 : if (m->pkt_len < ICE_TX_MIN_PKT_LEN) {
3763 : 0 : rte_errno = EINVAL;
3764 : 0 : return i;
3765 : : }
3766 : :
3767 : : #ifdef RTE_ETHDEV_DEBUG_TX
3768 : : ret = rte_validate_tx_offload(m);
3769 : : if (ret != 0) {
3770 : : rte_errno = -ret;
3771 : : return i;
3772 : : }
3773 : : #endif
3774 : : ret = rte_net_intel_cksum_prepare(m);
3775 [ # # ]: 0 : if (ret != 0) {
3776 : 0 : rte_errno = -ret;
3777 : 0 : return i;
3778 : : }
3779 : :
3780 [ # # ]: 0 : if (ice_check_empty_mbuf(m) != 0) {
3781 : 0 : rte_errno = EINVAL;
3782 : 0 : return i;
3783 : : }
3784 : : }
3785 : 0 : return i;
3786 : : }
3787 : :
3788 : : void __rte_cold
3789 : 0 : ice_set_tx_function(struct rte_eth_dev *dev)
3790 : : {
3791 : 0 : struct ice_adapter *ad =
3792 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3793 : 0 : int mbuf_check = ad->devargs.mbuf_check;
3794 : 0 : struct ci_tx_path_features req_features = {
3795 : 0 : .tx_offloads = dev->data->dev_conf.txmode.offloads,
3796 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3797 : : };
3798 : :
3799 : : /* If the device has started the function has already been selected. */
3800 [ # # ]: 0 : if (dev->data->dev_started)
3801 : 0 : goto out;
3802 : :
3803 : 0 : req_features.simple_tx = ad->tx_simple_allowed;
3804 : :
3805 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3806 [ # # ]: 0 : if (ice_tx_vec_dev_check(dev) != -1)
3807 : 0 : req_features.simd_width = ice_get_max_simd_bitwidth();
3808 : : #endif
3809 : :
3810 : 0 : ad->tx_func_type = ci_tx_path_select(&req_features,
3811 : : &ice_tx_path_infos[0],
3812 : : RTE_DIM(ice_tx_path_infos),
3813 : : ICE_TX_DEFAULT,
3814 : : false);
3815 : :
3816 : 0 : out:
3817 : : #if defined(RTE_ARCH_X86)
3818 : 0 : ad->tx_vec_allowed =
3819 : 0 : (ice_tx_path_infos[ad->tx_func_type].features.simd_width >= RTE_VECT_SIMD_256);
3820 : : #elif defined(RTE_ARCH_ARM64)
3821 : : ad->tx_vec_allowed =
3822 : : (ice_tx_path_infos[ad->tx_func_type].features.simd_width >= RTE_VECT_SIMD_128);
3823 : : #endif
3824 : 0 : ad->use_ctx = ice_tx_path_infos[ad->tx_func_type].supports_ctx;
3825 : :
3826 [ # # ]: 0 : dev->tx_pkt_burst = mbuf_check ? ice_xmit_pkts_check :
3827 : : ice_tx_path_infos[ad->tx_func_type].pkt_burst;
3828 : 0 : dev->tx_pkt_prepare = ice_tx_path_infos[ad->tx_func_type].pkt_prep;
3829 : 0 : PMD_DRV_LOG(DEBUG, "Using %s (port %d).",
3830 : : ice_tx_path_infos[ad->tx_func_type].info, dev->data->port_id);
3831 : 0 : }
3832 : :
3833 : : int
3834 : 0 : ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3835 : : struct rte_eth_burst_mode *mode)
3836 : : {
3837 : 0 : eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
3838 : : int ret = -EINVAL;
3839 : : unsigned int i;
3840 : :
3841 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_tx_path_infos); ++i) {
3842 [ # # ]: 0 : if (pkt_burst == ice_tx_path_infos[i].pkt_burst) {
3843 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3844 : 0 : ice_tx_path_infos[i].info);
3845 : : ret = 0;
3846 : 0 : break;
3847 : : }
3848 : : }
3849 : :
3850 : 0 : return ret;
3851 : : }
3852 : :
3853 : : /* For each value it means, datasheet of hardware can tell more details
3854 : : *
3855 : : * @note: fix ice_dev_supported_ptypes_get() if any change here.
3856 : : */
3857 : : static inline uint32_t
3858 : : ice_get_default_pkt_type(uint16_t ptype)
3859 : : {
3860 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t type_table[ICE_MAX_PKT_TYPE] = {
3861 : : /* L2 types */
3862 : : /* [0] reserved */
3863 : : [1] = RTE_PTYPE_L2_ETHER,
3864 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
3865 : : /* [3] - [5] reserved */
3866 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
3867 : : /* [7] - [10] reserved */
3868 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
3869 : : /* [12] - [21] reserved */
3870 : :
3871 : : /* Non tunneled IPv4 */
3872 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3873 : : RTE_PTYPE_L4_FRAG,
3874 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3875 : : RTE_PTYPE_L4_NONFRAG,
3876 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3877 : : RTE_PTYPE_L4_UDP,
3878 : : /* [25] reserved */
3879 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3880 : : RTE_PTYPE_L4_TCP,
3881 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3882 : : RTE_PTYPE_L4_SCTP,
3883 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3884 : : RTE_PTYPE_L4_ICMP,
3885 : :
3886 : : /* IPv4 --> IPv4 */
3887 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3888 : : RTE_PTYPE_TUNNEL_IP |
3889 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3890 : : RTE_PTYPE_INNER_L4_FRAG,
3891 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3892 : : RTE_PTYPE_TUNNEL_IP |
3893 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3894 : : RTE_PTYPE_INNER_L4_NONFRAG,
3895 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3896 : : RTE_PTYPE_TUNNEL_IP |
3897 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3898 : : RTE_PTYPE_INNER_L4_UDP,
3899 : : /* [32] reserved */
3900 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3901 : : RTE_PTYPE_TUNNEL_IP |
3902 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3903 : : RTE_PTYPE_INNER_L4_TCP,
3904 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3905 : : RTE_PTYPE_TUNNEL_IP |
3906 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3907 : : RTE_PTYPE_INNER_L4_SCTP,
3908 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3909 : : RTE_PTYPE_TUNNEL_IP |
3910 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3911 : : RTE_PTYPE_INNER_L4_ICMP,
3912 : :
3913 : : /* IPv4 --> IPv6 */
3914 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3915 : : RTE_PTYPE_TUNNEL_IP |
3916 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3917 : : RTE_PTYPE_INNER_L4_FRAG,
3918 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3919 : : RTE_PTYPE_TUNNEL_IP |
3920 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3921 : : RTE_PTYPE_INNER_L4_NONFRAG,
3922 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3923 : : RTE_PTYPE_TUNNEL_IP |
3924 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3925 : : RTE_PTYPE_INNER_L4_UDP,
3926 : : /* [39] reserved */
3927 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3928 : : RTE_PTYPE_TUNNEL_IP |
3929 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3930 : : RTE_PTYPE_INNER_L4_TCP,
3931 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3932 : : RTE_PTYPE_TUNNEL_IP |
3933 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3934 : : RTE_PTYPE_INNER_L4_SCTP,
3935 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3936 : : RTE_PTYPE_TUNNEL_IP |
3937 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3938 : : RTE_PTYPE_INNER_L4_ICMP,
3939 : :
3940 : : /* IPv4 --> GRE/Teredo/VXLAN */
3941 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3942 : : RTE_PTYPE_TUNNEL_GRENAT,
3943 : :
3944 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
3945 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3946 : : RTE_PTYPE_TUNNEL_GRENAT |
3947 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3948 : : RTE_PTYPE_INNER_L4_FRAG,
3949 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3950 : : RTE_PTYPE_TUNNEL_GRENAT |
3951 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3952 : : RTE_PTYPE_INNER_L4_NONFRAG,
3953 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3954 : : RTE_PTYPE_TUNNEL_GRENAT |
3955 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3956 : : RTE_PTYPE_INNER_L4_UDP,
3957 : : /* [47] reserved */
3958 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3959 : : RTE_PTYPE_TUNNEL_GRENAT |
3960 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3961 : : RTE_PTYPE_INNER_L4_TCP,
3962 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3963 : : RTE_PTYPE_TUNNEL_GRENAT |
3964 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3965 : : RTE_PTYPE_INNER_L4_SCTP,
3966 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3967 : : RTE_PTYPE_TUNNEL_GRENAT |
3968 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3969 : : RTE_PTYPE_INNER_L4_ICMP,
3970 : :
3971 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
3972 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3973 : : RTE_PTYPE_TUNNEL_GRENAT |
3974 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3975 : : RTE_PTYPE_INNER_L4_FRAG,
3976 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3977 : : RTE_PTYPE_TUNNEL_GRENAT |
3978 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3979 : : RTE_PTYPE_INNER_L4_NONFRAG,
3980 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3981 : : RTE_PTYPE_TUNNEL_GRENAT |
3982 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3983 : : RTE_PTYPE_INNER_L4_UDP,
3984 : : /* [54] reserved */
3985 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3986 : : RTE_PTYPE_TUNNEL_GRENAT |
3987 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3988 : : RTE_PTYPE_INNER_L4_TCP,
3989 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3990 : : RTE_PTYPE_TUNNEL_GRENAT |
3991 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3992 : : RTE_PTYPE_INNER_L4_SCTP,
3993 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3994 : : RTE_PTYPE_TUNNEL_GRENAT |
3995 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3996 : : RTE_PTYPE_INNER_L4_ICMP,
3997 : :
3998 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
3999 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4000 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4001 : :
4002 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4003 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4004 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4005 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4006 : : RTE_PTYPE_INNER_L4_FRAG,
4007 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4008 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4009 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4010 : : RTE_PTYPE_INNER_L4_NONFRAG,
4011 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4012 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4013 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4014 : : RTE_PTYPE_INNER_L4_UDP,
4015 : : /* [62] reserved */
4016 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4017 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4018 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4019 : : RTE_PTYPE_INNER_L4_TCP,
4020 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4021 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4022 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4023 : : RTE_PTYPE_INNER_L4_SCTP,
4024 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4025 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4026 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4027 : : RTE_PTYPE_INNER_L4_ICMP,
4028 : :
4029 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4030 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4031 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4032 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4033 : : RTE_PTYPE_INNER_L4_FRAG,
4034 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4035 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4036 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4037 : : RTE_PTYPE_INNER_L4_NONFRAG,
4038 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4039 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4040 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4041 : : RTE_PTYPE_INNER_L4_UDP,
4042 : : /* [69] reserved */
4043 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4044 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4045 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4046 : : RTE_PTYPE_INNER_L4_TCP,
4047 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4048 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4049 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4050 : : RTE_PTYPE_INNER_L4_SCTP,
4051 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4052 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4053 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4054 : : RTE_PTYPE_INNER_L4_ICMP,
4055 : : /* [73] - [87] reserved */
4056 : :
4057 : : /* Non tunneled IPv6 */
4058 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4059 : : RTE_PTYPE_L4_FRAG,
4060 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4061 : : RTE_PTYPE_L4_NONFRAG,
4062 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4063 : : RTE_PTYPE_L4_UDP,
4064 : : /* [91] reserved */
4065 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4066 : : RTE_PTYPE_L4_TCP,
4067 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4068 : : RTE_PTYPE_L4_SCTP,
4069 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4070 : : RTE_PTYPE_L4_ICMP,
4071 : :
4072 : : /* IPv6 --> IPv4 */
4073 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4074 : : RTE_PTYPE_TUNNEL_IP |
4075 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4076 : : RTE_PTYPE_INNER_L4_FRAG,
4077 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4078 : : RTE_PTYPE_TUNNEL_IP |
4079 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4080 : : RTE_PTYPE_INNER_L4_NONFRAG,
4081 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4082 : : RTE_PTYPE_TUNNEL_IP |
4083 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4084 : : RTE_PTYPE_INNER_L4_UDP,
4085 : : /* [98] reserved */
4086 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4087 : : RTE_PTYPE_TUNNEL_IP |
4088 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4089 : : RTE_PTYPE_INNER_L4_TCP,
4090 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4091 : : RTE_PTYPE_TUNNEL_IP |
4092 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4093 : : RTE_PTYPE_INNER_L4_SCTP,
4094 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4095 : : RTE_PTYPE_TUNNEL_IP |
4096 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4097 : : RTE_PTYPE_INNER_L4_ICMP,
4098 : :
4099 : : /* IPv6 --> IPv6 */
4100 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4101 : : RTE_PTYPE_TUNNEL_IP |
4102 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4103 : : RTE_PTYPE_INNER_L4_FRAG,
4104 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4105 : : RTE_PTYPE_TUNNEL_IP |
4106 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4107 : : RTE_PTYPE_INNER_L4_NONFRAG,
4108 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4109 : : RTE_PTYPE_TUNNEL_IP |
4110 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4111 : : RTE_PTYPE_INNER_L4_UDP,
4112 : : /* [105] reserved */
4113 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4114 : : RTE_PTYPE_TUNNEL_IP |
4115 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4116 : : RTE_PTYPE_INNER_L4_TCP,
4117 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4118 : : RTE_PTYPE_TUNNEL_IP |
4119 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4120 : : RTE_PTYPE_INNER_L4_SCTP,
4121 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4122 : : RTE_PTYPE_TUNNEL_IP |
4123 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4124 : : RTE_PTYPE_INNER_L4_ICMP,
4125 : :
4126 : : /* IPv6 --> GRE/Teredo/VXLAN */
4127 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4128 : : RTE_PTYPE_TUNNEL_GRENAT,
4129 : :
4130 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4131 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4132 : : RTE_PTYPE_TUNNEL_GRENAT |
4133 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4134 : : RTE_PTYPE_INNER_L4_FRAG,
4135 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4136 : : RTE_PTYPE_TUNNEL_GRENAT |
4137 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4138 : : RTE_PTYPE_INNER_L4_NONFRAG,
4139 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4140 : : RTE_PTYPE_TUNNEL_GRENAT |
4141 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4142 : : RTE_PTYPE_INNER_L4_UDP,
4143 : : /* [113] reserved */
4144 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4145 : : RTE_PTYPE_TUNNEL_GRENAT |
4146 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4147 : : RTE_PTYPE_INNER_L4_TCP,
4148 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4149 : : RTE_PTYPE_TUNNEL_GRENAT |
4150 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4151 : : RTE_PTYPE_INNER_L4_SCTP,
4152 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4153 : : RTE_PTYPE_TUNNEL_GRENAT |
4154 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4155 : : RTE_PTYPE_INNER_L4_ICMP,
4156 : :
4157 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4158 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4159 : : RTE_PTYPE_TUNNEL_GRENAT |
4160 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4161 : : RTE_PTYPE_INNER_L4_FRAG,
4162 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4163 : : RTE_PTYPE_TUNNEL_GRENAT |
4164 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4165 : : RTE_PTYPE_INNER_L4_NONFRAG,
4166 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4167 : : RTE_PTYPE_TUNNEL_GRENAT |
4168 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4169 : : RTE_PTYPE_INNER_L4_UDP,
4170 : : /* [120] reserved */
4171 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4172 : : RTE_PTYPE_TUNNEL_GRENAT |
4173 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4174 : : RTE_PTYPE_INNER_L4_TCP,
4175 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4176 : : RTE_PTYPE_TUNNEL_GRENAT |
4177 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4178 : : RTE_PTYPE_INNER_L4_SCTP,
4179 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4180 : : RTE_PTYPE_TUNNEL_GRENAT |
4181 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4182 : : RTE_PTYPE_INNER_L4_ICMP,
4183 : :
4184 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4185 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4186 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4187 : :
4188 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4189 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4190 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4191 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4192 : : RTE_PTYPE_INNER_L4_FRAG,
4193 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4194 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4195 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4196 : : RTE_PTYPE_INNER_L4_NONFRAG,
4197 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4198 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4199 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4200 : : RTE_PTYPE_INNER_L4_UDP,
4201 : : /* [128] reserved */
4202 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4203 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4204 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4205 : : RTE_PTYPE_INNER_L4_TCP,
4206 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4207 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4208 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4209 : : RTE_PTYPE_INNER_L4_SCTP,
4210 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4211 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4212 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4213 : : RTE_PTYPE_INNER_L4_ICMP,
4214 : :
4215 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4216 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4217 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4218 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4219 : : RTE_PTYPE_INNER_L4_FRAG,
4220 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4221 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4222 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4223 : : RTE_PTYPE_INNER_L4_NONFRAG,
4224 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4225 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4226 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4227 : : RTE_PTYPE_INNER_L4_UDP,
4228 : : /* [135] reserved */
4229 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4230 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4231 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4232 : : RTE_PTYPE_INNER_L4_TCP,
4233 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4234 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4235 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4236 : : RTE_PTYPE_INNER_L4_SCTP,
4237 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4238 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4239 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4240 : : RTE_PTYPE_INNER_L4_ICMP,
4241 : : /* [139] - [299] reserved */
4242 : :
4243 : : /* PPPoE */
4244 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4245 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4246 : :
4247 : : /* PPPoE --> IPv4 */
4248 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4249 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4250 : : RTE_PTYPE_L4_FRAG,
4251 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4252 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4253 : : RTE_PTYPE_L4_NONFRAG,
4254 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4255 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4256 : : RTE_PTYPE_L4_UDP,
4257 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4258 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4259 : : RTE_PTYPE_L4_TCP,
4260 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4261 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4262 : : RTE_PTYPE_L4_SCTP,
4263 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4264 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4265 : : RTE_PTYPE_L4_ICMP,
4266 : :
4267 : : /* PPPoE --> IPv6 */
4268 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4269 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4270 : : RTE_PTYPE_L4_FRAG,
4271 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4272 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4273 : : RTE_PTYPE_L4_NONFRAG,
4274 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4275 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4276 : : RTE_PTYPE_L4_UDP,
4277 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4278 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4279 : : RTE_PTYPE_L4_TCP,
4280 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4281 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4282 : : RTE_PTYPE_L4_SCTP,
4283 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4284 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4285 : : RTE_PTYPE_L4_ICMP,
4286 : : /* [314] - [324] reserved */
4287 : :
4288 : : /* IPv4/IPv6 --> GTPC/GTPU */
4289 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4290 : : RTE_PTYPE_TUNNEL_GTPC,
4291 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4292 : : RTE_PTYPE_TUNNEL_GTPC,
4293 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4294 : : RTE_PTYPE_TUNNEL_GTPC,
4295 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4296 : : RTE_PTYPE_TUNNEL_GTPC,
4297 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4298 : : RTE_PTYPE_TUNNEL_GTPU,
4299 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4300 : : RTE_PTYPE_TUNNEL_GTPU,
4301 : :
4302 : : /* IPv4 --> GTPU --> IPv4 */
4303 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4304 : : RTE_PTYPE_TUNNEL_GTPU |
4305 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4306 : : RTE_PTYPE_INNER_L4_FRAG,
4307 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4308 : : RTE_PTYPE_TUNNEL_GTPU |
4309 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4310 : : RTE_PTYPE_INNER_L4_NONFRAG,
4311 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4312 : : RTE_PTYPE_TUNNEL_GTPU |
4313 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4314 : : RTE_PTYPE_INNER_L4_UDP,
4315 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4316 : : RTE_PTYPE_TUNNEL_GTPU |
4317 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4318 : : RTE_PTYPE_INNER_L4_TCP,
4319 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4320 : : RTE_PTYPE_TUNNEL_GTPU |
4321 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4322 : : RTE_PTYPE_INNER_L4_ICMP,
4323 : :
4324 : : /* IPv6 --> GTPU --> IPv4 */
4325 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4326 : : RTE_PTYPE_TUNNEL_GTPU |
4327 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4328 : : RTE_PTYPE_INNER_L4_FRAG,
4329 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4330 : : RTE_PTYPE_TUNNEL_GTPU |
4331 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4332 : : RTE_PTYPE_INNER_L4_NONFRAG,
4333 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4334 : : RTE_PTYPE_TUNNEL_GTPU |
4335 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4336 : : RTE_PTYPE_INNER_L4_UDP,
4337 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4338 : : RTE_PTYPE_TUNNEL_GTPU |
4339 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4340 : : RTE_PTYPE_INNER_L4_TCP,
4341 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4342 : : RTE_PTYPE_TUNNEL_GTPU |
4343 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4344 : : RTE_PTYPE_INNER_L4_ICMP,
4345 : :
4346 : : /* IPv4 --> GTPU --> IPv6 */
4347 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4348 : : RTE_PTYPE_TUNNEL_GTPU |
4349 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4350 : : RTE_PTYPE_INNER_L4_FRAG,
4351 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4352 : : RTE_PTYPE_TUNNEL_GTPU |
4353 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4354 : : RTE_PTYPE_INNER_L4_NONFRAG,
4355 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4356 : : RTE_PTYPE_TUNNEL_GTPU |
4357 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4358 : : RTE_PTYPE_INNER_L4_UDP,
4359 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4360 : : RTE_PTYPE_TUNNEL_GTPU |
4361 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4362 : : RTE_PTYPE_INNER_L4_TCP,
4363 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4364 : : RTE_PTYPE_TUNNEL_GTPU |
4365 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4366 : : RTE_PTYPE_INNER_L4_ICMP,
4367 : :
4368 : : /* IPv6 --> GTPU --> IPv6 */
4369 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4370 : : RTE_PTYPE_TUNNEL_GTPU |
4371 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4372 : : RTE_PTYPE_INNER_L4_FRAG,
4373 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4374 : : RTE_PTYPE_TUNNEL_GTPU |
4375 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4376 : : RTE_PTYPE_INNER_L4_NONFRAG,
4377 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4378 : : RTE_PTYPE_TUNNEL_GTPU |
4379 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4380 : : RTE_PTYPE_INNER_L4_UDP,
4381 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4382 : : RTE_PTYPE_TUNNEL_GTPU |
4383 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4384 : : RTE_PTYPE_INNER_L4_TCP,
4385 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4386 : : RTE_PTYPE_TUNNEL_GTPU |
4387 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4388 : : RTE_PTYPE_INNER_L4_ICMP,
4389 : :
4390 : : /* IPv4 --> UDP ECPRI */
4391 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4392 : : RTE_PTYPE_L4_UDP,
4393 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4394 : : RTE_PTYPE_L4_UDP,
4395 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4396 : : RTE_PTYPE_L4_UDP,
4397 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4398 : : RTE_PTYPE_L4_UDP,
4399 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4400 : : RTE_PTYPE_L4_UDP,
4401 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4402 : : RTE_PTYPE_L4_UDP,
4403 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4404 : : RTE_PTYPE_L4_UDP,
4405 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4406 : : RTE_PTYPE_L4_UDP,
4407 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4408 : : RTE_PTYPE_L4_UDP,
4409 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4410 : : RTE_PTYPE_L4_UDP,
4411 : :
4412 : : /* IPV6 --> UDP ECPRI */
4413 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4414 : : RTE_PTYPE_L4_UDP,
4415 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4416 : : RTE_PTYPE_L4_UDP,
4417 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4418 : : RTE_PTYPE_L4_UDP,
4419 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4420 : : RTE_PTYPE_L4_UDP,
4421 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4422 : : RTE_PTYPE_L4_UDP,
4423 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4424 : : RTE_PTYPE_L4_UDP,
4425 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4426 : : RTE_PTYPE_L4_UDP,
4427 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4428 : : RTE_PTYPE_L4_UDP,
4429 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4430 : : RTE_PTYPE_L4_UDP,
4431 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4432 : : RTE_PTYPE_L4_UDP,
4433 : : /* All others reserved */
4434 : : };
4435 : :
4436 : 0 : return type_table[ptype];
4437 : : }
4438 : :
4439 : : void __rte_cold
4440 : 0 : ice_set_default_ptype_table(struct rte_eth_dev *dev)
4441 : : {
4442 : 0 : struct ice_adapter *ad =
4443 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4444 : : int i;
4445 : :
4446 [ # # ]: 0 : for (i = 0; i < ICE_MAX_PKT_TYPE; i++)
4447 : 0 : ad->ptype_tbl[i] = ice_get_default_pkt_type(i);
4448 : 0 : }
4449 : :
4450 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S 1
4451 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M \
4452 : : (0x3UL << ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S)
4453 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD 0
4454 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL 0x1
4455 : :
4456 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S 4
4457 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M \
4458 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S)
4459 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S 5
4460 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M \
4461 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S)
4462 : :
4463 : : /*
4464 : : * check the programming status descriptor in rx queue.
4465 : : * done after Programming Flow Director is programmed on
4466 : : * tx queue
4467 : : */
4468 : : static inline int
4469 : 0 : ice_check_fdir_programming_status(struct ci_rx_queue *rxq)
4470 : : {
4471 : : volatile union ci_rx_flex_desc *rxdp;
4472 : : uint16_t qword1;
4473 : : uint16_t rx_status;
4474 : : uint16_t error;
4475 : : uint16_t id;
4476 : : int ret = -EAGAIN;
4477 : :
4478 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
4479 : 0 : qword1 = rte_le_to_cpu_16(rxdp->wb.status_error0);
4480 : : rx_status = (qword1 & ICE_RXD_QW1_STATUS_M)
4481 : : >> ICE_RXD_QW1_STATUS_S;
4482 : :
4483 [ # # ]: 0 : if (rx_status & (1 << ICE_RX_DESC_STATUS_DD_S)) {
4484 : : ret = 0;
4485 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M) >>
4486 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S;
4487 : 0 : id = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M) >>
4488 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S;
4489 [ # # ]: 0 : if (error) {
4490 [ # # ]: 0 : if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD)
4491 : 0 : PMD_DRV_LOG(ERR, "Failed to add FDIR rule.");
4492 [ # # ]: 0 : else if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL)
4493 : 0 : PMD_DRV_LOG(ERR, "Failed to remove FDIR rule.");
4494 : : ret = -EINVAL;
4495 : 0 : goto err;
4496 : : }
4497 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M) >>
4498 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S;
4499 [ # # ]: 0 : if (error) {
4500 : 0 : PMD_DRV_LOG(ERR, "Failed to create FDIR profile.");
4501 : : ret = -EINVAL;
4502 : : }
4503 : 0 : err:
4504 : 0 : rxdp->wb.status_error0 = 0;
4505 : 0 : rxq->rx_tail++;
4506 [ # # ]: 0 : if (unlikely(rxq->rx_tail == rxq->nb_rx_desc))
4507 : 0 : rxq->rx_tail = 0;
4508 [ # # ]: 0 : if (rxq->rx_tail == 0)
4509 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
4510 : : else
4511 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_tail - 1);
4512 : : }
4513 : :
4514 : 0 : return ret;
4515 : : }
4516 : :
4517 : : #define ICE_FDIR_MAX_WAIT_US 10000
4518 : :
4519 : : int
4520 : 0 : ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
4521 : : {
4522 : 0 : struct ci_tx_queue *txq = pf->fdir.txq;
4523 : 0 : struct ci_rx_queue *rxq = pf->fdir.rxq;
4524 : : volatile struct ice_fltr_desc *fdirdp;
4525 : : volatile struct ci_tx_desc *txdp;
4526 : : uint32_t td_cmd;
4527 : : uint16_t i;
4528 : :
4529 : 0 : fdirdp = (volatile struct ice_fltr_desc *)
4530 : 0 : (&txq->ci_tx_ring[txq->tx_tail]);
4531 : 0 : fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
4532 : 0 : fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
4533 : :
4534 : 0 : txdp = &txq->ci_tx_ring[txq->tx_tail + 1];
4535 : 0 : txdp->buffer_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
4536 : : td_cmd = CI_TX_DESC_CMD_EOP |
4537 : : CI_TX_DESC_CMD_RS |
4538 : : CI_TX_DESC_CMD_DUMMY;
4539 : :
4540 : 0 : txdp->cmd_type_offset_bsz =
4541 : : ice_build_ctob(td_cmd, 0, ICE_FDIR_PKT_LEN, 0);
4542 : :
4543 : 0 : txq->tx_tail += 2;
4544 [ # # ]: 0 : if (txq->tx_tail >= txq->nb_tx_desc)
4545 : 0 : txq->tx_tail = 0;
4546 : : /* Update the tx tail register */
4547 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
4548 [ # # ]: 0 : for (i = 0; i < ICE_FDIR_MAX_WAIT_US; i++) {
4549 [ # # ]: 0 : if ((txdp->cmd_type_offset_bsz & rte_cpu_to_le_64(CI_TXD_QW1_DTYPE_M)) ==
4550 : : rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE))
4551 : : break;
4552 : 0 : rte_delay_us(1);
4553 : : }
4554 [ # # ]: 0 : if (i >= ICE_FDIR_MAX_WAIT_US) {
4555 : 0 : PMD_DRV_LOG(ERR,
4556 : : "Failed to program FDIR filter: time out to get DD on tx queue.");
4557 : 0 : return -ETIMEDOUT;
4558 : : }
4559 : :
4560 [ # # ]: 0 : for (; i < ICE_FDIR_MAX_WAIT_US; i++) {
4561 : : int ret;
4562 : :
4563 : 0 : ret = ice_check_fdir_programming_status(rxq);
4564 [ # # ]: 0 : if (ret == -EAGAIN)
4565 : 0 : rte_delay_us(1);
4566 : : else
4567 : 0 : return ret;
4568 : : }
4569 : :
4570 : 0 : PMD_DRV_LOG(ERR,
4571 : : "Failed to program FDIR filter: programming status reported.");
4572 : 0 : return -ETIMEDOUT;
4573 : :
4574 : :
4575 : : }
|