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