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)
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 : : RTE_PTYPE_UNKNOWN
2251 : : };
2252 : :
2253 : : static const uint32_t ptypes_comms[] = {
2254 : : /* refers to ice_get_default_pkt_type() */
2255 : : RTE_PTYPE_L2_ETHER,
2256 : : RTE_PTYPE_L2_ETHER_TIMESYNC,
2257 : : RTE_PTYPE_L2_ETHER_LLDP,
2258 : : RTE_PTYPE_L2_ETHER_ARP,
2259 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2260 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2261 : : RTE_PTYPE_L4_FRAG,
2262 : : RTE_PTYPE_L4_ICMP,
2263 : : RTE_PTYPE_L4_NONFRAG,
2264 : : RTE_PTYPE_L4_SCTP,
2265 : : RTE_PTYPE_L4_TCP,
2266 : : RTE_PTYPE_L4_UDP,
2267 : : RTE_PTYPE_TUNNEL_GRENAT,
2268 : : RTE_PTYPE_TUNNEL_IP,
2269 : : RTE_PTYPE_INNER_L2_ETHER,
2270 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2271 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2272 : : RTE_PTYPE_INNER_L4_FRAG,
2273 : : RTE_PTYPE_INNER_L4_ICMP,
2274 : : RTE_PTYPE_INNER_L4_NONFRAG,
2275 : : RTE_PTYPE_INNER_L4_SCTP,
2276 : : RTE_PTYPE_INNER_L4_TCP,
2277 : : RTE_PTYPE_INNER_L4_UDP,
2278 : : RTE_PTYPE_TUNNEL_GTPC,
2279 : : RTE_PTYPE_TUNNEL_GTPU,
2280 : : RTE_PTYPE_L2_ETHER_PPPOE,
2281 : : RTE_PTYPE_UNKNOWN
2282 : : };
2283 : :
2284 [ # # ]: 0 : if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
2285 : : ptypes = ptypes_comms;
2286 : : else
2287 : : ptypes = ptypes_os;
2288 : :
2289 [ # # # # ]: 0 : if (dev->rx_pkt_burst == ice_recv_pkts ||
2290 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc ||
2291 : : dev->rx_pkt_burst == ice_recv_scattered_pkts)
2292 : : return ptypes;
2293 : :
2294 : : #ifdef RTE_ARCH_X86
2295 [ # # # # ]: 0 : if (dev->rx_pkt_burst == ice_recv_pkts_vec ||
2296 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_scattered_pkts_vec ||
2297 : : #ifdef CC_AVX512_SUPPORT
2298 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_pkts_vec_avx512 ||
2299 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_pkts_vec_avx512_offload ||
2300 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512 ||
2301 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload ||
2302 : : #endif
2303 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 ||
2304 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload ||
2305 [ # # ]: 0 : dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 ||
2306 : : dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload)
2307 : 0 : return ptypes;
2308 : : #endif
2309 : :
2310 : : return NULL;
2311 : : }
2312 : :
2313 : : int
2314 : 0 : ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
2315 : : {
2316 : : volatile union ice_rx_flex_desc *rxdp;
2317 : : struct ice_rx_queue *rxq = rx_queue;
2318 : : uint32_t desc;
2319 : :
2320 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
2321 : : return -EINVAL;
2322 : :
2323 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
2324 : : return RTE_ETH_RX_DESC_UNAVAIL;
2325 : :
2326 : 0 : desc = rxq->rx_tail + offset;
2327 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
2328 : 0 : desc -= rxq->nb_rx_desc;
2329 : :
2330 : 0 : rxdp = &rxq->rx_ring[desc];
2331 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
2332 : : (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
2333 : 0 : return RTE_ETH_RX_DESC_DONE;
2334 : :
2335 : : return RTE_ETH_RX_DESC_AVAIL;
2336 : : }
2337 : :
2338 : : int
2339 : 0 : ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
2340 : : {
2341 : : struct ice_tx_queue *txq = tx_queue;
2342 : : volatile uint64_t *status;
2343 : : uint64_t mask, expect;
2344 : : uint32_t desc;
2345 : :
2346 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
2347 : : return -EINVAL;
2348 : :
2349 : 0 : desc = txq->tx_tail + offset;
2350 : : /* go to next desc that has the RS bit */
2351 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
2352 : : txq->tx_rs_thresh;
2353 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
2354 : 0 : desc -= txq->nb_tx_desc;
2355 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
2356 : 0 : desc -= txq->nb_tx_desc;
2357 : : }
2358 : :
2359 : 0 : status = &txq->tx_ring[desc].cmd_type_offset_bsz;
2360 : : mask = rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M);
2361 : : expect = rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE <<
2362 : : ICE_TXD_QW1_DTYPE_S);
2363 [ # # ]: 0 : if ((*status & mask) == expect)
2364 : 0 : return RTE_ETH_TX_DESC_DONE;
2365 : :
2366 : : return RTE_ETH_TX_DESC_FULL;
2367 : : }
2368 : :
2369 : : void
2370 : 0 : ice_free_queues(struct rte_eth_dev *dev)
2371 : : {
2372 : : uint16_t i;
2373 : :
2374 : 0 : PMD_INIT_FUNC_TRACE();
2375 : :
2376 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2377 [ # # ]: 0 : if (!dev->data->rx_queues[i])
2378 : 0 : continue;
2379 : 0 : ice_rx_queue_release(dev->data->rx_queues[i]);
2380 : 0 : dev->data->rx_queues[i] = NULL;
2381 : : }
2382 : 0 : dev->data->nb_rx_queues = 0;
2383 : :
2384 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2385 [ # # ]: 0 : if (!dev->data->tx_queues[i])
2386 : 0 : continue;
2387 : 0 : ice_tx_queue_release(dev->data->tx_queues[i]);
2388 : 0 : dev->data->tx_queues[i] = NULL;
2389 : : }
2390 : 0 : dev->data->nb_tx_queues = 0;
2391 : 0 : }
2392 : :
2393 : : #define ICE_FDIR_NUM_TX_DESC ICE_MIN_RING_DESC
2394 : : #define ICE_FDIR_NUM_RX_DESC ICE_MIN_RING_DESC
2395 : :
2396 : : int
2397 : 0 : ice_fdir_setup_tx_resources(struct ice_pf *pf)
2398 : : {
2399 : : struct ice_tx_queue *txq;
2400 : : const struct rte_memzone *tz = NULL;
2401 : : uint32_t ring_size;
2402 : : struct rte_eth_dev *dev;
2403 : :
2404 [ # # ]: 0 : if (!pf) {
2405 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2406 : 0 : return -EINVAL;
2407 : : }
2408 : :
2409 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2410 : :
2411 : : /* Allocate the TX queue data structure. */
2412 : 0 : txq = rte_zmalloc_socket("ice fdir tx queue",
2413 : : sizeof(struct ice_tx_queue),
2414 : : RTE_CACHE_LINE_SIZE,
2415 : : SOCKET_ID_ANY);
2416 [ # # ]: 0 : if (!txq) {
2417 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2418 : : "tx queue structure.");
2419 : 0 : return -ENOMEM;
2420 : : }
2421 : :
2422 : : /* Allocate TX hardware ring descriptors. */
2423 : : ring_size = sizeof(struct ice_tx_desc) * ICE_FDIR_NUM_TX_DESC;
2424 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2425 : :
2426 : 0 : tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
2427 : : ICE_FDIR_QUEUE_ID, ring_size,
2428 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2429 [ # # ]: 0 : if (!tz) {
2430 : 0 : ice_tx_queue_release(txq);
2431 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
2432 : 0 : return -ENOMEM;
2433 : : }
2434 : :
2435 : 0 : txq->mz = tz;
2436 : 0 : txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
2437 : 0 : txq->queue_id = ICE_FDIR_QUEUE_ID;
2438 : 0 : txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2439 : 0 : txq->vsi = pf->fdir.fdir_vsi;
2440 : :
2441 : 0 : txq->tx_ring_dma = tz->iova;
2442 : 0 : txq->tx_ring = (struct ice_tx_desc *)tz->addr;
2443 : : /*
2444 : : * don't need to allocate software ring and reset for the fdir
2445 : : * program queue just set the queue has been configured.
2446 : : */
2447 : 0 : txq->q_set = true;
2448 : 0 : pf->fdir.txq = txq;
2449 : :
2450 : 0 : txq->tx_rel_mbufs = _ice_tx_queue_release_mbufs;
2451 : :
2452 : 0 : return ICE_SUCCESS;
2453 : : }
2454 : :
2455 : : int
2456 : 0 : ice_fdir_setup_rx_resources(struct ice_pf *pf)
2457 : : {
2458 : : struct ice_rx_queue *rxq;
2459 : : const struct rte_memzone *rz = NULL;
2460 : : uint32_t ring_size;
2461 : : struct rte_eth_dev *dev;
2462 : :
2463 [ # # ]: 0 : if (!pf) {
2464 : 0 : PMD_DRV_LOG(ERR, "PF is not available");
2465 : 0 : return -EINVAL;
2466 : : }
2467 : :
2468 : 0 : dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2469 : :
2470 : : /* Allocate the RX queue data structure. */
2471 : 0 : rxq = rte_zmalloc_socket("ice fdir rx queue",
2472 : : sizeof(struct ice_rx_queue),
2473 : : RTE_CACHE_LINE_SIZE,
2474 : : SOCKET_ID_ANY);
2475 [ # # ]: 0 : if (!rxq) {
2476 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2477 : : "rx queue structure.");
2478 : 0 : return -ENOMEM;
2479 : : }
2480 : :
2481 : : /* Allocate RX hardware ring descriptors. */
2482 : : ring_size = sizeof(union ice_32byte_rx_desc) * ICE_FDIR_NUM_RX_DESC;
2483 : : ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2484 : :
2485 : 0 : rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
2486 : : ICE_FDIR_QUEUE_ID, ring_size,
2487 : : ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2488 [ # # ]: 0 : if (!rz) {
2489 : 0 : ice_rx_queue_release(rxq);
2490 : 0 : PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
2491 : 0 : return -ENOMEM;
2492 : : }
2493 : :
2494 : 0 : rxq->mz = rz;
2495 : 0 : rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
2496 : 0 : rxq->queue_id = ICE_FDIR_QUEUE_ID;
2497 : 0 : rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2498 : 0 : rxq->vsi = pf->fdir.fdir_vsi;
2499 : :
2500 : 0 : rxq->rx_ring_dma = rz->iova;
2501 : 0 : memset(rz->addr, 0, ICE_FDIR_NUM_RX_DESC *
2502 : : sizeof(union ice_32byte_rx_desc));
2503 : 0 : rxq->rx_ring = (union ice_rx_flex_desc *)rz->addr;
2504 : :
2505 : : /*
2506 : : * Don't need to allocate software ring and reset for the fdir
2507 : : * rx queue, just set the queue has been configured.
2508 : : */
2509 : 0 : rxq->q_set = true;
2510 : 0 : pf->fdir.rxq = rxq;
2511 : :
2512 : 0 : rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
2513 : :
2514 : 0 : return ICE_SUCCESS;
2515 : : }
2516 : :
2517 : : uint16_t
2518 : 0 : ice_recv_pkts(void *rx_queue,
2519 : : struct rte_mbuf **rx_pkts,
2520 : : uint16_t nb_pkts)
2521 : : {
2522 : : struct ice_rx_queue *rxq = rx_queue;
2523 : 0 : volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
2524 : : volatile union ice_rx_flex_desc *rxdp;
2525 : : union ice_rx_flex_desc rxd;
2526 : 0 : struct ice_rx_entry *sw_ring = rxq->sw_ring;
2527 : : struct ice_rx_entry *rxe;
2528 : : struct rte_mbuf *nmb; /* new allocated mbuf */
2529 : : struct rte_mbuf *nmb_pay; /* new allocated payload mbuf */
2530 : : struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2531 : 0 : uint16_t rx_id = rxq->rx_tail;
2532 : : uint16_t nb_rx = 0;
2533 : : uint16_t nb_hold = 0;
2534 : : uint16_t rx_packet_len;
2535 : : uint16_t rx_header_len;
2536 : : uint16_t rx_stat_err0;
2537 : : uint64_t dma_addr;
2538 : : uint64_t pkt_flags;
2539 : 0 : uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
2540 : : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
2541 : : bool is_tsinit = false;
2542 : : uint64_t ts_ns;
2543 : : struct ice_vsi *vsi = rxq->vsi;
2544 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2545 : : struct ice_adapter *ad = rxq->vsi->adapter;
2546 : :
2547 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2548 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
2549 : :
2550 [ # # ]: 0 : if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
2551 : : is_tsinit = 1;
2552 : : }
2553 : : #endif
2554 : :
2555 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2556 : 0 : rxdp = &rx_ring[rx_id];
2557 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2558 : :
2559 : : /* Check the DD bit first */
2560 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2561 : : break;
2562 : :
2563 : : /* allocate header mbuf */
2564 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
2565 [ # # ]: 0 : if (unlikely(!nmb)) {
2566 : 0 : rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2567 : 0 : break;
2568 : : }
2569 : :
2570 : 0 : rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2571 : :
2572 : 0 : nb_hold++;
2573 : 0 : rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2574 : 0 : rx_id++;
2575 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
2576 : : rx_id = 0;
2577 : 0 : rxm = rxe->mbuf;
2578 [ # # ]: 0 : rxe->mbuf = nmb;
2579 : : dma_addr =
2580 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2581 : :
2582 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2583 : : /**
2584 : : * fill the read format of descriptor with physic address in
2585 : : * new allocated mbuf: nmb
2586 : : */
2587 : 0 : rxdp->read.hdr_addr = 0;
2588 : 0 : rxdp->read.pkt_addr = dma_addr;
2589 : : } else {
2590 : : /* allocate payload mbuf */
2591 : 0 : nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
2592 [ # # ]: 0 : if (unlikely(!nmb_pay)) {
2593 : 0 : rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2594 : 0 : break;
2595 : : }
2596 : :
2597 : 0 : nmb->next = nmb_pay;
2598 : 0 : nmb_pay->next = NULL;
2599 : :
2600 : : /**
2601 : : * fill the read format of descriptor with physic address in
2602 : : * new allocated mbuf: nmb
2603 : : */
2604 : 0 : rxdp->read.hdr_addr = dma_addr;
2605 : 0 : rxdp->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb_pay));
2606 : : }
2607 : :
2608 : : /* fill old mbuf with received descriptor: rxd */
2609 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2610 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
2611 [ # # ]: 0 : if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
2612 : 0 : rxm->nb_segs = 1;
2613 : 0 : rxm->next = NULL;
2614 : : /* calculate rx_packet_len of the received pkt */
2615 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2616 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2617 : 0 : rxm->data_len = rx_packet_len;
2618 : 0 : rxm->pkt_len = rx_packet_len;
2619 : : } else {
2620 : 0 : rxm->nb_segs = (uint16_t)(rxm->nb_segs + rxm->next->nb_segs);
2621 : 0 : rxm->next->next = NULL;
2622 : : /* calculate rx_packet_len of the received pkt */
2623 : 0 : rx_header_len = rte_le_to_cpu_16(rxd.wb.hdr_len_sph_flex_flags1) &
2624 : : ICE_RX_FLEX_DESC_HEADER_LEN_M;
2625 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2626 : 0 : ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2627 : 0 : rxm->data_len = rx_header_len;
2628 : 0 : rxm->pkt_len = rx_header_len + rx_packet_len;
2629 : 0 : rxm->next->data_len = rx_packet_len;
2630 : :
2631 : : #ifdef RTE_ETHDEV_DEBUG_RX
2632 : : rte_pktmbuf_dump(stdout, rxm, rte_pktmbuf_pkt_len(rxm));
2633 : : #endif
2634 : : }
2635 : :
2636 : 0 : rxm->port = rxq->port_id;
2637 : 0 : rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2638 [ # # ]: 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2639 : : ice_rxd_to_vlan_tci(rxm, &rxd);
2640 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
2641 : 0 : pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2642 : : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
2643 [ # # ]: 0 : if (ice_timestamp_dynflag > 0 &&
2644 [ # # ]: 0 : (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
2645 : 0 : rxq->time_high =
2646 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2647 [ # # ]: 0 : if (unlikely(is_tsinit)) {
2648 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
2649 : 0 : rxq->hw_time_low = (uint32_t)ts_ns;
2650 : 0 : rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
2651 : : is_tsinit = false;
2652 : : } else {
2653 [ # # ]: 0 : if (rxq->time_high < rxq->hw_time_low)
2654 : 0 : rxq->hw_time_high += 1;
2655 : 0 : ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
2656 : 0 : rxq->hw_time_low = rxq->time_high;
2657 : : }
2658 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2659 : 0 : (rte_get_timer_hz() / 1000);
2660 : 0 : *RTE_MBUF_DYNFIELD(rxm,
2661 : : (ice_timestamp_dynfield_offset),
2662 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2663 : 0 : pkt_flags |= ice_timestamp_dynflag;
2664 : : }
2665 : :
2666 [ # # # # ]: 0 : if (ad->ptp_ena && ((rxm->packet_type & RTE_PTYPE_L2_MASK) ==
2667 : : RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2668 : 0 : rxq->time_high =
2669 : 0 : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2670 : 0 : rxm->timesync = rxq->queue_id;
2671 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2672 : : }
2673 : : #endif
2674 : 0 : rxm->ol_flags |= pkt_flags;
2675 : : /* copy old mbuf to rx_pkts */
2676 : 0 : rx_pkts[nb_rx++] = rxm;
2677 : : }
2678 : :
2679 : 0 : rxq->rx_tail = rx_id;
2680 : : /**
2681 : : * If the number of free RX descriptors is greater than the RX free
2682 : : * threshold of the queue, advance the receive tail register of queue.
2683 : : * Update that register with the value of the last processed RX
2684 : : * descriptor minus 1.
2685 : : */
2686 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2687 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2688 [ # # ]: 0 : rx_id = (uint16_t)(rx_id == 0 ?
2689 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2690 : : /* write TAIL register */
2691 : 0 : ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2692 : : nb_hold = 0;
2693 : : }
2694 : 0 : rxq->nb_rx_hold = nb_hold;
2695 : :
2696 : : /* return received packet in the burst */
2697 : 0 : return nb_rx;
2698 : : }
2699 : :
2700 : : static inline void
2701 : 0 : ice_parse_tunneling_params(uint64_t ol_flags,
2702 : : union ice_tx_offload tx_offload,
2703 : : uint32_t *cd_tunneling)
2704 : : {
2705 : : /* EIPT: External (outer) IP header type */
2706 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
2707 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4;
2708 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)
2709 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4_NO_CSUM;
2710 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)
2711 : 0 : *cd_tunneling |= ICE_TX_CTX_EIPT_IPV6;
2712 : :
2713 : : /* EIPLEN: External (outer) IP header length, in DWords */
2714 : 0 : *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
2715 : : ICE_TXD_CTX_QW0_EIPLEN_S;
2716 : :
2717 : : /* L4TUNT: L4 Tunneling Type */
2718 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2719 : : case RTE_MBUF_F_TX_TUNNEL_IPIP:
2720 : : /* for non UDP / GRE tunneling, set to 00b */
2721 : : break;
2722 : 0 : case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2723 : : case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
2724 : : case RTE_MBUF_F_TX_TUNNEL_GTP:
2725 : : case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2726 : 0 : *cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
2727 : 0 : break;
2728 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2729 : 0 : *cd_tunneling |= ICE_TXD_CTX_GRE_TUNNELING;
2730 : 0 : break;
2731 : : default:
2732 : : PMD_TX_LOG(ERR, "Tunnel type not supported");
2733 : : return;
2734 : : }
2735 : :
2736 : : /* L4TUNLEN: L4 Tunneling Length, in Words
2737 : : *
2738 : : * We depend on app to set rte_mbuf.l2_len correctly.
2739 : : * For IP in GRE it should be set to the length of the GRE
2740 : : * header;
2741 : : * For MAC in GRE or MAC in UDP it should be set to the length
2742 : : * of the GRE or UDP headers plus the inner MAC up to including
2743 : : * its last Ethertype.
2744 : : * If MPLS labels exists, it should include them as well.
2745 : : */
2746 : 0 : *cd_tunneling |= (tx_offload.l2_len >> 1) <<
2747 : : ICE_TXD_CTX_QW0_NATLEN_S;
2748 : :
2749 : : /**
2750 : : * Calculate the tunneling UDP checksum.
2751 : : * Shall be set only if L4TUNT = 01b and EIPT is not zero
2752 : : */
2753 [ # # ]: 0 : if (!(*cd_tunneling & ICE_TX_CTX_EIPT_NONE) &&
2754 : 0 : (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) &&
2755 [ # # ]: 0 : (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2756 : 0 : *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M;
2757 : : }
2758 : :
2759 : : static inline void
2760 : 0 : ice_txd_enable_checksum(uint64_t ol_flags,
2761 : : uint32_t *td_cmd,
2762 : : uint32_t *td_offset,
2763 : : union ice_tx_offload tx_offload)
2764 : : {
2765 : : /* Set MACLEN */
2766 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK))
2767 : 0 : *td_offset |= (tx_offload.l2_len >> 1)
2768 : 0 : << ICE_TX_DESC_LEN_MACLEN_S;
2769 : :
2770 : : /* Enable L3 checksum offloads */
2771 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
2772 : 0 : *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4_CSUM;
2773 : 0 : *td_offset |= (tx_offload.l3_len >> 2) <<
2774 : : ICE_TX_DESC_LEN_IPLEN_S;
2775 [ # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
2776 : 0 : *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4;
2777 : 0 : *td_offset |= (tx_offload.l3_len >> 2) <<
2778 : : ICE_TX_DESC_LEN_IPLEN_S;
2779 [ # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
2780 : 0 : *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV6;
2781 : 0 : *td_offset |= (tx_offload.l3_len >> 2) <<
2782 : : ICE_TX_DESC_LEN_IPLEN_S;
2783 : : }
2784 : :
2785 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
2786 : 0 : *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
2787 : 0 : *td_offset |= (tx_offload.l4_len >> 2) <<
2788 : : ICE_TX_DESC_LEN_L4_LEN_S;
2789 : 0 : return;
2790 : : }
2791 : :
2792 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
2793 : 0 : *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP;
2794 : 0 : *td_offset |= (tx_offload.l4_len >> 2) <<
2795 : : ICE_TX_DESC_LEN_L4_LEN_S;
2796 : 0 : return;
2797 : : }
2798 : :
2799 : : /* Enable L4 checksum offloads */
2800 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
2801 : 0 : case RTE_MBUF_F_TX_TCP_CKSUM:
2802 : 0 : *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
2803 : 0 : *td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
2804 : : ICE_TX_DESC_LEN_L4_LEN_S;
2805 : 0 : break;
2806 : 0 : case RTE_MBUF_F_TX_SCTP_CKSUM:
2807 : 0 : *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_SCTP;
2808 : 0 : *td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
2809 : : ICE_TX_DESC_LEN_L4_LEN_S;
2810 : 0 : break;
2811 : 0 : case RTE_MBUF_F_TX_UDP_CKSUM:
2812 : 0 : *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP;
2813 : 0 : *td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
2814 : : ICE_TX_DESC_LEN_L4_LEN_S;
2815 : 0 : break;
2816 : : default:
2817 : : break;
2818 : : }
2819 : : }
2820 : :
2821 : : static inline int
2822 : 0 : ice_xmit_cleanup(struct ice_tx_queue *txq)
2823 : : {
2824 : 0 : struct ice_tx_entry *sw_ring = txq->sw_ring;
2825 : 0 : volatile struct ice_tx_desc *txd = txq->tx_ring;
2826 : 0 : uint16_t last_desc_cleaned = txq->last_desc_cleaned;
2827 : 0 : uint16_t nb_tx_desc = txq->nb_tx_desc;
2828 : : uint16_t desc_to_clean_to;
2829 : : uint16_t nb_tx_to_clean;
2830 : :
2831 : : /* Determine the last descriptor needing to be cleaned */
2832 : 0 : desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
2833 [ # # ]: 0 : if (desc_to_clean_to >= nb_tx_desc)
2834 : 0 : desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
2835 : :
2836 : : /* Check to make sure the last descriptor to clean is done */
2837 : 0 : desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
2838 [ # # ]: 0 : if (!(txd[desc_to_clean_to].cmd_type_offset_bsz &
2839 : : rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
2840 : : PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
2841 : : "(port=%d queue=%d) value=0x%"PRIx64"\n",
2842 : : desc_to_clean_to,
2843 : : txq->port_id, txq->queue_id,
2844 : : txd[desc_to_clean_to].cmd_type_offset_bsz);
2845 : : /* Failed to clean any descriptors */
2846 : : return -1;
2847 : : }
2848 : :
2849 : : /* Figure out how many descriptors will be cleaned */
2850 [ # # ]: 0 : if (last_desc_cleaned > desc_to_clean_to)
2851 : 0 : nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
2852 : : desc_to_clean_to);
2853 : : else
2854 : 0 : nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
2855 : : last_desc_cleaned);
2856 : :
2857 : : /* The last descriptor to clean is done, so that means all the
2858 : : * descriptors from the last descriptor that was cleaned
2859 : : * up to the last descriptor with the RS bit set
2860 : : * are done. Only reset the threshold descriptor.
2861 : : */
2862 : 0 : txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
2863 : :
2864 : : /* Update the txq to reflect the last descriptor that was cleaned */
2865 : 0 : txq->last_desc_cleaned = desc_to_clean_to;
2866 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
2867 : :
2868 : 0 : return 0;
2869 : : }
2870 : :
2871 : : /* Construct the tx flags */
2872 : : static inline uint64_t
2873 : : ice_build_ctob(uint32_t td_cmd,
2874 : : uint32_t td_offset,
2875 : : uint16_t size,
2876 : : uint32_t td_tag)
2877 : : {
2878 : 0 : return rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
2879 : : ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
2880 : : ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
2881 : : ((uint64_t)size << ICE_TXD_QW1_TX_BUF_SZ_S) |
2882 : : ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
2883 : : }
2884 : :
2885 : : /* Check if the context descriptor is needed for TX offloading */
2886 : : static inline uint16_t
2887 : : ice_calc_context_desc(uint64_t flags)
2888 : : {
2889 : : static uint64_t mask = RTE_MBUF_F_TX_TCP_SEG |
2890 : : RTE_MBUF_F_TX_UDP_SEG |
2891 : : RTE_MBUF_F_TX_QINQ |
2892 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM |
2893 : : RTE_MBUF_F_TX_TUNNEL_MASK |
2894 : : RTE_MBUF_F_TX_IEEE1588_TMST;
2895 : :
2896 : 0 : return (flags & mask) ? 1 : 0;
2897 : : }
2898 : :
2899 : : /* set ice TSO context descriptor */
2900 : : static inline uint64_t
2901 : : ice_set_tso_ctx(struct rte_mbuf *mbuf, union ice_tx_offload tx_offload)
2902 : : {
2903 : : uint64_t ctx_desc = 0;
2904 : : uint32_t cd_cmd, hdr_len, cd_tso_len;
2905 : :
2906 [ # # ]: 0 : if (!tx_offload.l4_len) {
2907 : : PMD_TX_LOG(DEBUG, "L4 length set to 0");
2908 : : return ctx_desc;
2909 : : }
2910 : :
2911 : 0 : hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
2912 : 0 : hdr_len += (mbuf->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
2913 [ # # ]: 0 : tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
2914 : :
2915 : : cd_cmd = ICE_TX_CTX_DESC_TSO;
2916 : 0 : cd_tso_len = mbuf->pkt_len - hdr_len;
2917 : 0 : ctx_desc |= ((uint64_t)cd_cmd << ICE_TXD_CTX_QW1_CMD_S) |
2918 : 0 : ((uint64_t)cd_tso_len << ICE_TXD_CTX_QW1_TSO_LEN_S) |
2919 : 0 : ((uint64_t)mbuf->tso_segsz << ICE_TXD_CTX_QW1_MSS_S);
2920 : :
2921 : 0 : return ctx_desc;
2922 : : }
2923 : :
2924 : : /* HW requires that TX buffer size ranges from 1B up to (16K-1)B. */
2925 : : #define ICE_MAX_DATA_PER_TXD \
2926 : : (ICE_TXD_QW1_TX_BUF_SZ_M >> ICE_TXD_QW1_TX_BUF_SZ_S)
2927 : : /* Calculate the number of TX descriptors needed for each pkt */
2928 : : static inline uint16_t
2929 : : ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
2930 : : {
2931 : : struct rte_mbuf *txd = tx_pkt;
2932 : : uint16_t count = 0;
2933 : :
2934 [ # # ]: 0 : while (txd != NULL) {
2935 : 0 : count += DIV_ROUND_UP(txd->data_len, ICE_MAX_DATA_PER_TXD);
2936 : 0 : txd = txd->next;
2937 : : }
2938 : :
2939 : : return count;
2940 : : }
2941 : :
2942 : : uint16_t
2943 : 0 : ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2944 : : {
2945 : : struct ice_tx_queue *txq;
2946 : : volatile struct ice_tx_desc *tx_ring;
2947 : : volatile struct ice_tx_desc *txd;
2948 : : struct ice_tx_entry *sw_ring;
2949 : : struct ice_tx_entry *txe, *txn;
2950 : : struct rte_mbuf *tx_pkt;
2951 : : struct rte_mbuf *m_seg;
2952 : : uint32_t cd_tunneling_params;
2953 : : uint16_t tx_id;
2954 : : uint16_t nb_tx;
2955 : : uint16_t nb_used;
2956 : : uint16_t nb_ctx;
2957 : 0 : uint32_t td_cmd = 0;
2958 : 0 : uint32_t td_offset = 0;
2959 : : uint32_t td_tag = 0;
2960 : : uint16_t tx_last;
2961 : : uint16_t slen;
2962 : : uint64_t buf_dma_addr;
2963 : : uint64_t ol_flags;
2964 : 0 : union ice_tx_offload tx_offload = {0};
2965 : :
2966 : : txq = tx_queue;
2967 : 0 : sw_ring = txq->sw_ring;
2968 : 0 : tx_ring = txq->tx_ring;
2969 : 0 : tx_id = txq->tx_tail;
2970 : 0 : txe = &sw_ring[tx_id];
2971 : :
2972 : : /* Check if the descriptor ring needs to be cleaned. */
2973 [ # # ]: 0 : if (txq->nb_tx_free < txq->tx_free_thresh)
2974 : 0 : (void)ice_xmit_cleanup(txq);
2975 : :
2976 [ # # ]: 0 : for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
2977 : 0 : tx_pkt = *tx_pkts++;
2978 : :
2979 : 0 : td_cmd = 0;
2980 : : td_tag = 0;
2981 : 0 : td_offset = 0;
2982 : 0 : ol_flags = tx_pkt->ol_flags;
2983 : 0 : tx_offload.l2_len = tx_pkt->l2_len;
2984 : 0 : tx_offload.l3_len = tx_pkt->l3_len;
2985 : 0 : tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
2986 : 0 : tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
2987 : 0 : tx_offload.l4_len = tx_pkt->l4_len;
2988 : 0 : tx_offload.tso_segsz = tx_pkt->tso_segsz;
2989 : : /* Calculate the number of context descriptors needed. */
2990 : : nb_ctx = ice_calc_context_desc(ol_flags);
2991 : :
2992 : : /* The number of descriptors that must be allocated for
2993 : : * a packet equals to the number of the segments of that
2994 : : * packet plus the number of context descriptor if needed.
2995 : : * Recalculate the needed tx descs when TSO enabled in case
2996 : : * the mbuf data size exceeds max data size that hw allows
2997 : : * per tx desc.
2998 : : */
2999 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
3000 : 0 : nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
3001 : : nb_ctx);
3002 : : else
3003 : 0 : nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
3004 : 0 : tx_last = (uint16_t)(tx_id + nb_used - 1);
3005 : :
3006 : : /* Circular ring */
3007 [ # # ]: 0 : if (tx_last >= txq->nb_tx_desc)
3008 : 0 : tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
3009 : :
3010 [ # # ]: 0 : if (nb_used > txq->nb_tx_free) {
3011 [ # # ]: 0 : if (ice_xmit_cleanup(txq) != 0) {
3012 [ # # ]: 0 : if (nb_tx == 0)
3013 : : return 0;
3014 : 0 : goto end_of_tx;
3015 : : }
3016 [ # # ]: 0 : if (unlikely(nb_used > txq->tx_rs_thresh)) {
3017 [ # # ]: 0 : while (nb_used > txq->nb_tx_free) {
3018 [ # # ]: 0 : if (ice_xmit_cleanup(txq) != 0) {
3019 [ # # ]: 0 : if (nb_tx == 0)
3020 : : return 0;
3021 : 0 : goto end_of_tx;
3022 : : }
3023 : : }
3024 : : }
3025 : : }
3026 : :
3027 : : /* Descriptor based VLAN insertion */
3028 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
3029 : 0 : td_cmd |= ICE_TX_DESC_CMD_IL2TAG1;
3030 : 0 : td_tag = tx_pkt->vlan_tci;
3031 : : }
3032 : :
3033 : : /* Fill in tunneling parameters if necessary */
3034 : 0 : cd_tunneling_params = 0;
3035 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3036 : 0 : td_offset |= (tx_offload.outer_l2_len >> 1)
3037 : 0 : << ICE_TX_DESC_LEN_MACLEN_S;
3038 : 0 : ice_parse_tunneling_params(ol_flags, tx_offload,
3039 : : &cd_tunneling_params);
3040 : : }
3041 : :
3042 : : /* Enable checksum offloading */
3043 [ # # ]: 0 : if (ol_flags & ICE_TX_CKSUM_OFFLOAD_MASK)
3044 : 0 : ice_txd_enable_checksum(ol_flags, &td_cmd,
3045 : : &td_offset, tx_offload);
3046 : :
3047 [ # # ]: 0 : if (nb_ctx) {
3048 : : /* Setup TX context descriptor if required */
3049 : 0 : volatile struct ice_tx_ctx_desc *ctx_txd =
3050 : : (volatile struct ice_tx_ctx_desc *)
3051 : 0 : &tx_ring[tx_id];
3052 : : uint16_t cd_l2tag2 = 0;
3053 : : uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
3054 : :
3055 : 0 : txn = &sw_ring[txe->next_id];
3056 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
3057 [ # # ]: 0 : if (txe->mbuf) {
3058 : : rte_pktmbuf_free_seg(txe->mbuf);
3059 : 0 : txe->mbuf = NULL;
3060 : : }
3061 : :
3062 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
3063 : 0 : cd_type_cmd_tso_mss |=
3064 : : ice_set_tso_ctx(tx_pkt, tx_offload);
3065 [ # # ]: 0 : else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
3066 : : cd_type_cmd_tso_mss |=
3067 : : ((uint64_t)ICE_TX_CTX_DESC_TSYN <<
3068 : : ICE_TXD_CTX_QW1_CMD_S);
3069 : :
3070 : 0 : ctx_txd->tunneling_params =
3071 : : rte_cpu_to_le_32(cd_tunneling_params);
3072 : :
3073 : : /* TX context descriptor based double VLAN insert */
3074 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_QINQ) {
3075 : 0 : cd_l2tag2 = tx_pkt->vlan_tci_outer;
3076 : 0 : cd_type_cmd_tso_mss |=
3077 : : ((uint64_t)ICE_TX_CTX_DESC_IL2TAG2 <<
3078 : : ICE_TXD_CTX_QW1_CMD_S);
3079 : : }
3080 : 0 : ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
3081 : 0 : ctx_txd->qw1 =
3082 : : rte_cpu_to_le_64(cd_type_cmd_tso_mss);
3083 : :
3084 : 0 : txe->last_id = tx_last;
3085 : 0 : tx_id = txe->next_id;
3086 : : txe = txn;
3087 : : }
3088 : : m_seg = tx_pkt;
3089 : :
3090 : : do {
3091 : 0 : txd = &tx_ring[tx_id];
3092 : 0 : txn = &sw_ring[txe->next_id];
3093 : :
3094 [ # # ]: 0 : if (txe->mbuf)
3095 : : rte_pktmbuf_free_seg(txe->mbuf);
3096 : 0 : txe->mbuf = m_seg;
3097 : :
3098 : : /* Setup TX Descriptor */
3099 : 0 : slen = m_seg->data_len;
3100 : : buf_dma_addr = rte_mbuf_data_iova(m_seg);
3101 : :
3102 [ # # ]: 0 : while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
3103 [ # # ]: 0 : unlikely(slen > ICE_MAX_DATA_PER_TXD)) {
3104 : 0 : txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
3105 : 0 : txd->cmd_type_offset_bsz =
3106 : 0 : rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
3107 : : ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
3108 : : ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
3109 : : ((uint64_t)ICE_MAX_DATA_PER_TXD <<
3110 : : ICE_TXD_QW1_TX_BUF_SZ_S) |
3111 : : ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
3112 : :
3113 : 0 : buf_dma_addr += ICE_MAX_DATA_PER_TXD;
3114 : 0 : slen -= ICE_MAX_DATA_PER_TXD;
3115 : :
3116 : 0 : txe->last_id = tx_last;
3117 : 0 : tx_id = txe->next_id;
3118 : : txe = txn;
3119 : 0 : txd = &tx_ring[tx_id];
3120 : 0 : txn = &sw_ring[txe->next_id];
3121 : : }
3122 : :
3123 : 0 : txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
3124 : 0 : txd->cmd_type_offset_bsz =
3125 : 0 : rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
3126 : : ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
3127 : : ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
3128 : : ((uint64_t)slen << ICE_TXD_QW1_TX_BUF_SZ_S) |
3129 : : ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
3130 : :
3131 : 0 : txe->last_id = tx_last;
3132 : 0 : tx_id = txe->next_id;
3133 : : txe = txn;
3134 : 0 : m_seg = m_seg->next;
3135 [ # # ]: 0 : } while (m_seg);
3136 : :
3137 : : /* fill the last descriptor with End of Packet (EOP) bit */
3138 : 0 : td_cmd |= ICE_TX_DESC_CMD_EOP;
3139 : 0 : txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
3140 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
3141 : :
3142 : : /* set RS bit on the last descriptor of one packet */
3143 [ # # ]: 0 : if (txq->nb_tx_used >= txq->tx_rs_thresh) {
3144 : : PMD_TX_LOG(DEBUG,
3145 : : "Setting RS bit on TXD id="
3146 : : "%4u (port=%d queue=%d)",
3147 : : tx_last, txq->port_id, txq->queue_id);
3148 : :
3149 : 0 : td_cmd |= ICE_TX_DESC_CMD_RS;
3150 : :
3151 : : /* Update txq RS bit counters */
3152 : 0 : txq->nb_tx_used = 0;
3153 : : }
3154 : 0 : txd->cmd_type_offset_bsz |=
3155 : 0 : rte_cpu_to_le_64(((uint64_t)td_cmd) <<
3156 : : ICE_TXD_QW1_CMD_S);
3157 : : }
3158 : 0 : end_of_tx:
3159 : : /* update Tail register */
3160 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, tx_id);
3161 : 0 : txq->tx_tail = tx_id;
3162 : :
3163 : 0 : return nb_tx;
3164 : : }
3165 : :
3166 : : static __rte_always_inline int
3167 : : ice_tx_free_bufs(struct ice_tx_queue *txq)
3168 : : {
3169 : : struct ice_tx_entry *txep;
3170 : : uint16_t i;
3171 : :
3172 [ # # # # ]: 0 : if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
3173 : : rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) !=
3174 : : rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
3175 : : return 0;
3176 : :
3177 : 0 : txep = &txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)];
3178 : :
3179 [ # # # # ]: 0 : for (i = 0; i < txq->tx_rs_thresh; i++)
3180 : 0 : rte_prefetch0((txep + i)->mbuf);
3181 : :
3182 [ # # # # ]: 0 : if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
3183 [ # # # # ]: 0 : for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
3184 [ # # # # ]: 0 : rte_mempool_put(txep->mbuf->pool, txep->mbuf);
3185 : 0 : txep->mbuf = NULL;
3186 : : }
3187 : : } else {
3188 [ # # # # ]: 0 : for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
3189 : 0 : rte_pktmbuf_free_seg(txep->mbuf);
3190 : 0 : txep->mbuf = NULL;
3191 : : }
3192 : : }
3193 : :
3194 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
3195 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
3196 [ # # # # ]: 0 : if (txq->tx_next_dd >= txq->nb_tx_desc)
3197 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
3198 : :
3199 : 0 : return txq->tx_rs_thresh;
3200 : : }
3201 : :
3202 : : static int
3203 : 0 : ice_tx_done_cleanup_full(struct ice_tx_queue *txq,
3204 : : uint32_t free_cnt)
3205 : : {
3206 : 0 : struct ice_tx_entry *swr_ring = txq->sw_ring;
3207 : : uint16_t i, tx_last, tx_id;
3208 : : uint16_t nb_tx_free_last;
3209 : : uint16_t nb_tx_to_clean;
3210 : : uint32_t pkt_cnt;
3211 : :
3212 : : /* Start free mbuf from the next of tx_tail */
3213 : 0 : tx_last = txq->tx_tail;
3214 : 0 : tx_id = swr_ring[tx_last].next_id;
3215 : :
3216 [ # # # # ]: 0 : if (txq->nb_tx_free == 0 && ice_xmit_cleanup(txq))
3217 : : return 0;
3218 : :
3219 : 0 : nb_tx_to_clean = txq->nb_tx_free;
3220 : : nb_tx_free_last = txq->nb_tx_free;
3221 [ # # ]: 0 : if (!free_cnt)
3222 : 0 : free_cnt = txq->nb_tx_desc;
3223 : :
3224 : : /* Loop through swr_ring to count the amount of
3225 : : * freeable mubfs and packets.
3226 : : */
3227 [ # # ]: 0 : for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
3228 : 0 : for (i = 0; i < nb_tx_to_clean &&
3229 [ # # # # ]: 0 : pkt_cnt < free_cnt &&
3230 : 0 : tx_id != tx_last; i++) {
3231 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
3232 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
3233 : 0 : swr_ring[tx_id].mbuf = NULL;
3234 : :
3235 : : /*
3236 : : * last segment in the packet,
3237 : : * increment packet count
3238 : : */
3239 : 0 : pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
3240 : : }
3241 : :
3242 : 0 : tx_id = swr_ring[tx_id].next_id;
3243 : : }
3244 : :
3245 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
3246 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
3247 : : break;
3248 : :
3249 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
3250 [ # # ]: 0 : if (ice_xmit_cleanup(txq))
3251 : : break;
3252 : :
3253 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
3254 : : nb_tx_free_last = txq->nb_tx_free;
3255 : : }
3256 : : }
3257 : :
3258 : 0 : return (int)pkt_cnt;
3259 : : }
3260 : :
3261 : : #ifdef RTE_ARCH_X86
3262 : : static int
3263 : : ice_tx_done_cleanup_vec(struct ice_tx_queue *txq __rte_unused,
3264 : : uint32_t free_cnt __rte_unused)
3265 : : {
3266 : : return -ENOTSUP;
3267 : : }
3268 : : #endif
3269 : :
3270 : : static int
3271 : 0 : ice_tx_done_cleanup_simple(struct ice_tx_queue *txq,
3272 : : uint32_t free_cnt)
3273 : : {
3274 : : int i, n, cnt;
3275 : :
3276 [ # # # # ]: 0 : if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
3277 : 0 : free_cnt = txq->nb_tx_desc;
3278 : :
3279 : 0 : cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
3280 : :
3281 [ # # ]: 0 : for (i = 0; i < cnt; i += n) {
3282 [ # # ]: 0 : if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
3283 : : break;
3284 : :
3285 : : n = ice_tx_free_bufs(txq);
3286 : :
3287 [ # # ]: 0 : if (n == 0)
3288 : : break;
3289 : : }
3290 : :
3291 : 0 : return i;
3292 : : }
3293 : :
3294 : : int
3295 : 0 : ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
3296 : : {
3297 : : struct ice_tx_queue *q = (struct ice_tx_queue *)txq;
3298 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[q->port_id];
3299 : 0 : struct ice_adapter *ad =
3300 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3301 : :
3302 : : #ifdef RTE_ARCH_X86
3303 [ # # ]: 0 : if (ad->tx_vec_allowed)
3304 : : return ice_tx_done_cleanup_vec(q, free_cnt);
3305 : : #endif
3306 [ # # ]: 0 : if (ad->tx_simple_allowed)
3307 : 0 : return ice_tx_done_cleanup_simple(q, free_cnt);
3308 : : else
3309 : 0 : return ice_tx_done_cleanup_full(q, free_cnt);
3310 : : }
3311 : :
3312 : : /* Populate 4 descriptors with data from 4 mbufs */
3313 : : static inline void
3314 : : tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
3315 : : {
3316 : : uint64_t dma_addr;
3317 : : uint32_t i;
3318 : :
3319 [ # # ]: 0 : for (i = 0; i < 4; i++, txdp++, pkts++) {
3320 : 0 : dma_addr = rte_mbuf_data_iova(*pkts);
3321 : 0 : txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
3322 : 0 : txdp->cmd_type_offset_bsz =
3323 : : ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
3324 : 0 : (*pkts)->data_len, 0);
3325 : : }
3326 : : }
3327 : :
3328 : : /* Populate 1 descriptor with data from 1 mbuf */
3329 : : static inline void
3330 : : tx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
3331 : : {
3332 : : uint64_t dma_addr;
3333 : :
3334 : : dma_addr = rte_mbuf_data_iova(*pkts);
3335 : 0 : txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
3336 : 0 : txdp->cmd_type_offset_bsz =
3337 : : ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
3338 : 0 : (*pkts)->data_len, 0);
3339 : : }
3340 : :
3341 : : static inline void
3342 : 0 : ice_tx_fill_hw_ring(struct ice_tx_queue *txq, struct rte_mbuf **pkts,
3343 : : uint16_t nb_pkts)
3344 : : {
3345 : 0 : volatile struct ice_tx_desc *txdp = &txq->tx_ring[txq->tx_tail];
3346 : 0 : struct ice_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
3347 : : const int N_PER_LOOP = 4;
3348 : : const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
3349 : : int mainpart, leftover;
3350 : : int i, j;
3351 : :
3352 : : /**
3353 : : * Process most of the packets in chunks of N pkts. Any
3354 : : * leftover packets will get processed one at a time.
3355 : : */
3356 : 0 : mainpart = nb_pkts & ((uint32_t)~N_PER_LOOP_MASK);
3357 : 0 : leftover = nb_pkts & ((uint32_t)N_PER_LOOP_MASK);
3358 [ # # ]: 0 : for (i = 0; i < mainpart; i += N_PER_LOOP) {
3359 : : /* Copy N mbuf pointers to the S/W ring */
3360 [ # # ]: 0 : for (j = 0; j < N_PER_LOOP; ++j)
3361 : 0 : (txep + i + j)->mbuf = *(pkts + i + j);
3362 : 0 : tx4(txdp + i, pkts + i);
3363 : : }
3364 : :
3365 [ # # ]: 0 : if (unlikely(leftover > 0)) {
3366 [ # # ]: 0 : for (i = 0; i < leftover; ++i) {
3367 : 0 : (txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
3368 : 0 : tx1(txdp + mainpart + i, pkts + mainpart + i);
3369 : : }
3370 : : }
3371 : 0 : }
3372 : :
3373 : : static inline uint16_t
3374 : 0 : tx_xmit_pkts(struct ice_tx_queue *txq,
3375 : : struct rte_mbuf **tx_pkts,
3376 : : uint16_t nb_pkts)
3377 : : {
3378 : 0 : volatile struct ice_tx_desc *txr = txq->tx_ring;
3379 : : uint16_t n = 0;
3380 : :
3381 : : /**
3382 : : * Begin scanning the H/W ring for done descriptors when the number
3383 : : * of available descriptors drops below tx_free_thresh. For each done
3384 : : * descriptor, free the associated buffer.
3385 : : */
3386 [ # # ]: 0 : if (txq->nb_tx_free < txq->tx_free_thresh)
3387 : : ice_tx_free_bufs(txq);
3388 : :
3389 : : /* Use available descriptor only */
3390 : 0 : nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
3391 [ # # ]: 0 : if (unlikely(!nb_pkts))
3392 : : return 0;
3393 : :
3394 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
3395 [ # # ]: 0 : if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
3396 : 0 : n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
3397 : 0 : ice_tx_fill_hw_ring(txq, tx_pkts, n);
3398 : 0 : txr[txq->tx_next_rs].cmd_type_offset_bsz |=
3399 : : rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
3400 : : ICE_TXD_QW1_CMD_S);
3401 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
3402 : 0 : txq->tx_tail = 0;
3403 : : }
3404 : :
3405 : : /* Fill hardware descriptor ring with mbuf data */
3406 : 0 : ice_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
3407 : 0 : txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
3408 : :
3409 : : /* Determine if RS bit needs to be set */
3410 [ # # ]: 0 : if (txq->tx_tail > txq->tx_next_rs) {
3411 : 0 : txr[txq->tx_next_rs].cmd_type_offset_bsz |=
3412 : : rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
3413 : : ICE_TXD_QW1_CMD_S);
3414 : 0 : txq->tx_next_rs =
3415 : 0 : (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
3416 [ # # ]: 0 : if (txq->tx_next_rs >= txq->nb_tx_desc)
3417 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
3418 : : }
3419 : :
3420 [ # # ]: 0 : if (txq->tx_tail >= txq->nb_tx_desc)
3421 : 0 : txq->tx_tail = 0;
3422 : :
3423 : : /* Update the tx tail register */
3424 : 0 : ICE_PCI_REG_WC_WRITE(txq->qtx_tail, txq->tx_tail);
3425 : :
3426 : : return nb_pkts;
3427 : : }
3428 : :
3429 : : static uint16_t
3430 : 0 : ice_xmit_pkts_simple(void *tx_queue,
3431 : : struct rte_mbuf **tx_pkts,
3432 : : uint16_t nb_pkts)
3433 : : {
3434 : : uint16_t nb_tx = 0;
3435 : :
3436 [ # # ]: 0 : if (likely(nb_pkts <= ICE_TX_MAX_BURST))
3437 : 0 : return tx_xmit_pkts((struct ice_tx_queue *)tx_queue,
3438 : : tx_pkts, nb_pkts);
3439 : :
3440 [ # # ]: 0 : while (nb_pkts) {
3441 : 0 : uint16_t ret, num = (uint16_t)RTE_MIN(nb_pkts,
3442 : : ICE_TX_MAX_BURST);
3443 : :
3444 : 0 : ret = tx_xmit_pkts((struct ice_tx_queue *)tx_queue,
3445 : 0 : &tx_pkts[nb_tx], num);
3446 : 0 : nb_tx = (uint16_t)(nb_tx + ret);
3447 : 0 : nb_pkts = (uint16_t)(nb_pkts - ret);
3448 [ # # ]: 0 : if (ret < num)
3449 : : break;
3450 : : }
3451 : :
3452 : : return nb_tx;
3453 : : }
3454 : :
3455 : : void __rte_cold
3456 : 0 : ice_set_rx_function(struct rte_eth_dev *dev)
3457 : : {
3458 : 0 : PMD_INIT_FUNC_TRACE();
3459 : 0 : struct ice_adapter *ad =
3460 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3461 : : #ifdef RTE_ARCH_X86
3462 : : struct ice_rx_queue *rxq;
3463 : : int i;
3464 : : int rx_check_ret = -1;
3465 : :
3466 [ # # ]: 0 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3467 : 0 : ad->rx_use_avx512 = false;
3468 : 0 : ad->rx_use_avx2 = false;
3469 : 0 : rx_check_ret = ice_rx_vec_dev_check(dev);
3470 [ # # ]: 0 : if (ad->ptp_ena)
3471 : : rx_check_ret = -1;
3472 : 0 : ad->rx_vec_offload_support =
3473 : 0 : (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH);
3474 [ # # # # : 0 : if (rx_check_ret >= 0 && ad->rx_bulk_alloc_allowed &&
# # ]
3475 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
3476 : 0 : ad->rx_vec_allowed = true;
3477 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3478 : 0 : rxq = dev->data->rx_queues[i];
3479 [ # # # # ]: 0 : if (rxq && ice_rxq_vec_setup(rxq)) {
3480 : 0 : ad->rx_vec_allowed = false;
3481 : 0 : break;
3482 : : }
3483 : : }
3484 : :
3485 [ # # # # ]: 0 : if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
3486 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
3487 : 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
3488 : : #ifdef CC_AVX512_SUPPORT
3489 : 0 : ad->rx_use_avx512 = true;
3490 : : #else
3491 : : PMD_DRV_LOG(NOTICE,
3492 : : "AVX512 is not supported in build env");
3493 : : #endif
3494 [ # # # # ]: 0 : if (!ad->rx_use_avx512 &&
3495 [ # # ]: 0 : (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
3496 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
3497 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
3498 : 0 : ad->rx_use_avx2 = true;
3499 : :
3500 : : } else {
3501 : 0 : ad->rx_vec_allowed = false;
3502 : : }
3503 : : }
3504 : :
3505 [ # # ]: 0 : if (ad->rx_vec_allowed) {
3506 [ # # ]: 0 : if (dev->data->scattered_rx) {
3507 [ # # ]: 0 : if (ad->rx_use_avx512) {
3508 : : #ifdef CC_AVX512_SUPPORT
3509 [ # # ]: 0 : if (ad->rx_vec_offload_support) {
3510 : 0 : PMD_DRV_LOG(NOTICE,
3511 : : "Using AVX512 OFFLOAD Vector Scattered Rx (port %d).",
3512 : : dev->data->port_id);
3513 : 0 : dev->rx_pkt_burst =
3514 : : ice_recv_scattered_pkts_vec_avx512_offload;
3515 : : } else {
3516 : 0 : PMD_DRV_LOG(NOTICE,
3517 : : "Using AVX512 Vector Scattered Rx (port %d).",
3518 : : dev->data->port_id);
3519 : 0 : dev->rx_pkt_burst =
3520 : : ice_recv_scattered_pkts_vec_avx512;
3521 : : }
3522 : : #endif
3523 [ # # ]: 0 : } else if (ad->rx_use_avx2) {
3524 [ # # ]: 0 : if (ad->rx_vec_offload_support) {
3525 : 0 : PMD_DRV_LOG(NOTICE,
3526 : : "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).",
3527 : : dev->data->port_id);
3528 : 0 : dev->rx_pkt_burst =
3529 : : ice_recv_scattered_pkts_vec_avx2_offload;
3530 : : } else {
3531 : 0 : PMD_DRV_LOG(NOTICE,
3532 : : "Using AVX2 Vector Scattered Rx (port %d).",
3533 : : dev->data->port_id);
3534 : 0 : dev->rx_pkt_burst =
3535 : : ice_recv_scattered_pkts_vec_avx2;
3536 : : }
3537 : : } else {
3538 : 0 : PMD_DRV_LOG(DEBUG,
3539 : : "Using Vector Scattered Rx (port %d).",
3540 : : dev->data->port_id);
3541 : 0 : dev->rx_pkt_burst = ice_recv_scattered_pkts_vec;
3542 : : }
3543 : : } else {
3544 [ # # ]: 0 : if (ad->rx_use_avx512) {
3545 : : #ifdef CC_AVX512_SUPPORT
3546 [ # # ]: 0 : if (ad->rx_vec_offload_support) {
3547 : 0 : PMD_DRV_LOG(NOTICE,
3548 : : "Using AVX512 OFFLOAD Vector Rx (port %d).",
3549 : : dev->data->port_id);
3550 : 0 : dev->rx_pkt_burst =
3551 : : ice_recv_pkts_vec_avx512_offload;
3552 : : } else {
3553 : 0 : PMD_DRV_LOG(NOTICE,
3554 : : "Using AVX512 Vector Rx (port %d).",
3555 : : dev->data->port_id);
3556 : 0 : dev->rx_pkt_burst =
3557 : : ice_recv_pkts_vec_avx512;
3558 : : }
3559 : : #endif
3560 [ # # ]: 0 : } else if (ad->rx_use_avx2) {
3561 [ # # ]: 0 : if (ad->rx_vec_offload_support) {
3562 : 0 : PMD_DRV_LOG(NOTICE,
3563 : : "Using AVX2 OFFLOAD Vector Rx (port %d).",
3564 : : dev->data->port_id);
3565 : 0 : dev->rx_pkt_burst =
3566 : : ice_recv_pkts_vec_avx2_offload;
3567 : : } else {
3568 : 0 : PMD_DRV_LOG(NOTICE,
3569 : : "Using AVX2 Vector Rx (port %d).",
3570 : : dev->data->port_id);
3571 : 0 : dev->rx_pkt_burst =
3572 : : ice_recv_pkts_vec_avx2;
3573 : : }
3574 : : } else {
3575 : 0 : PMD_DRV_LOG(DEBUG,
3576 : : "Using Vector Rx (port %d).",
3577 : : dev->data->port_id);
3578 : 0 : dev->rx_pkt_burst = ice_recv_pkts_vec;
3579 : : }
3580 : : }
3581 : 0 : return;
3582 : : }
3583 : :
3584 : : #endif
3585 : :
3586 [ # # ]: 0 : if (dev->data->scattered_rx) {
3587 : : /* Set the non-LRO scattered function */
3588 : 0 : PMD_INIT_LOG(DEBUG,
3589 : : "Using a Scattered function on port %d.",
3590 : : dev->data->port_id);
3591 : 0 : dev->rx_pkt_burst = ice_recv_scattered_pkts;
3592 [ # # ]: 0 : } else if (ad->rx_bulk_alloc_allowed) {
3593 : 0 : PMD_INIT_LOG(DEBUG,
3594 : : "Rx Burst Bulk Alloc Preconditions are "
3595 : : "satisfied. Rx Burst Bulk Alloc function "
3596 : : "will be used on port %d.",
3597 : : dev->data->port_id);
3598 : 0 : dev->rx_pkt_burst = ice_recv_pkts_bulk_alloc;
3599 : : } else {
3600 : 0 : PMD_INIT_LOG(DEBUG,
3601 : : "Rx Burst Bulk Alloc Preconditions are not "
3602 : : "satisfied, Normal Rx will be used on port %d.",
3603 : : dev->data->port_id);
3604 : 0 : dev->rx_pkt_burst = ice_recv_pkts;
3605 : : }
3606 : : }
3607 : :
3608 : : static const struct {
3609 : : eth_rx_burst_t pkt_burst;
3610 : : const char *info;
3611 : : } ice_rx_burst_infos[] = {
3612 : : { ice_recv_scattered_pkts, "Scalar Scattered" },
3613 : : { ice_recv_pkts_bulk_alloc, "Scalar Bulk Alloc" },
3614 : : { ice_recv_pkts, "Scalar" },
3615 : : #ifdef RTE_ARCH_X86
3616 : : #ifdef CC_AVX512_SUPPORT
3617 : : { ice_recv_scattered_pkts_vec_avx512, "Vector AVX512 Scattered" },
3618 : : { ice_recv_scattered_pkts_vec_avx512_offload, "Offload Vector AVX512 Scattered" },
3619 : : { ice_recv_pkts_vec_avx512, "Vector AVX512" },
3620 : : { ice_recv_pkts_vec_avx512_offload, "Offload Vector AVX512" },
3621 : : #endif
3622 : : { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" },
3623 : : { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" },
3624 : : { ice_recv_pkts_vec_avx2, "Vector AVX2" },
3625 : : { ice_recv_pkts_vec_avx2_offload, "Offload Vector AVX2" },
3626 : : { ice_recv_scattered_pkts_vec, "Vector SSE Scattered" },
3627 : : { ice_recv_pkts_vec, "Vector SSE" },
3628 : : #endif
3629 : : };
3630 : :
3631 : : int
3632 : 0 : ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3633 : : struct rte_eth_burst_mode *mode)
3634 : : {
3635 : 0 : eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
3636 : : int ret = -EINVAL;
3637 : : unsigned int i;
3638 : :
3639 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_rx_burst_infos); ++i) {
3640 [ # # ]: 0 : if (pkt_burst == ice_rx_burst_infos[i].pkt_burst) {
3641 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3642 : 0 : ice_rx_burst_infos[i].info);
3643 : : ret = 0;
3644 : 0 : break;
3645 : : }
3646 : : }
3647 : :
3648 : 0 : return ret;
3649 : : }
3650 : :
3651 : : void __rte_cold
3652 : 0 : ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
3653 : : {
3654 : 0 : struct ice_adapter *ad =
3655 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3656 : :
3657 : : /* Use a simple Tx queue if possible (only fast free is allowed) */
3658 : 0 : ad->tx_simple_allowed =
3659 : 0 : (txq->offloads ==
3660 [ # # ]: 0 : (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
3661 [ # # ]: 0 : txq->tx_rs_thresh >= ICE_TX_MAX_BURST);
3662 : :
3663 [ # # ]: 0 : if (ad->tx_simple_allowed)
3664 : 0 : PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
3665 : : txq->queue_id);
3666 : : else
3667 : 0 : PMD_INIT_LOG(DEBUG,
3668 : : "Simple Tx can NOT be enabled on Tx queue %u.",
3669 : : txq->queue_id);
3670 : 0 : }
3671 : :
3672 : : /*********************************************************************
3673 : : *
3674 : : * TX prep functions
3675 : : *
3676 : : **********************************************************************/
3677 : : /* The default values of TSO MSS */
3678 : : #define ICE_MIN_TSO_MSS 64
3679 : : #define ICE_MAX_TSO_MSS 9728
3680 : : #define ICE_MAX_TSO_FRAME_SIZE 262144
3681 : :
3682 : : /*Check for empty mbuf*/
3683 : : static inline uint16_t
3684 : : ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
3685 : : {
3686 : : struct rte_mbuf *txd = tx_pkt;
3687 : :
3688 [ # # ]: 0 : while (txd != NULL) {
3689 [ # # ]: 0 : if (txd->data_len == 0)
3690 : : return -1;
3691 : 0 : txd = txd->next;
3692 : : }
3693 : :
3694 : : return 0;
3695 : : }
3696 : :
3697 : : uint16_t
3698 : 0 : ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
3699 : : uint16_t nb_pkts)
3700 : : {
3701 : : int i, ret;
3702 : : uint64_t ol_flags;
3703 : : struct rte_mbuf *m;
3704 : :
3705 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3706 : 0 : m = tx_pkts[i];
3707 : 0 : ol_flags = m->ol_flags;
3708 : :
3709 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
3710 : : /**
3711 : : * No TSO case: nb->segs, pkt_len to not exceed
3712 : : * the limites.
3713 : : */
3714 [ # # ]: 0 : (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
3715 [ # # ]: 0 : m->pkt_len > ICE_FRAME_SIZE_MAX)) {
3716 : 0 : rte_errno = EINVAL;
3717 : 0 : return i;
3718 [ # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
3719 : : /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
3720 : : * the limits.
3721 : : */
3722 [ # # ]: 0 : (m->tso_segsz < ICE_MIN_TSO_MSS ||
3723 : 0 : m->tso_segsz > ICE_MAX_TSO_MSS ||
3724 : 0 : m->nb_segs >
3725 [ # # ]: 0 : ((struct ice_tx_queue *)tx_queue)->nb_tx_desc ||
3726 [ # # ]: 0 : m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
3727 : : /**
3728 : : * MSS outside the range are considered malicious
3729 : : */
3730 : 0 : rte_errno = EINVAL;
3731 : 0 : return i;
3732 : : }
3733 : :
3734 [ # # ]: 0 : if (m->pkt_len < ICE_TX_MIN_PKT_LEN) {
3735 : 0 : rte_errno = EINVAL;
3736 : 0 : return i;
3737 : : }
3738 : :
3739 : : #ifdef RTE_ETHDEV_DEBUG_TX
3740 : : ret = rte_validate_tx_offload(m);
3741 : : if (ret != 0) {
3742 : : rte_errno = -ret;
3743 : : return i;
3744 : : }
3745 : : #endif
3746 : : ret = rte_net_intel_cksum_prepare(m);
3747 [ # # ]: 0 : if (ret != 0) {
3748 : 0 : rte_errno = -ret;
3749 : 0 : return i;
3750 : : }
3751 : :
3752 [ # # ]: 0 : if (ice_check_empty_mbuf(m) != 0) {
3753 : 0 : rte_errno = EINVAL;
3754 : 0 : return i;
3755 : : }
3756 : : }
3757 : 0 : return i;
3758 : : }
3759 : :
3760 : : void __rte_cold
3761 : 0 : ice_set_tx_function(struct rte_eth_dev *dev)
3762 : : {
3763 : 0 : struct ice_adapter *ad =
3764 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3765 : : #ifdef RTE_ARCH_X86
3766 : : struct ice_tx_queue *txq;
3767 : : int i;
3768 : : int tx_check_ret = -1;
3769 : :
3770 [ # # ]: 0 : if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3771 : 0 : ad->tx_use_avx2 = false;
3772 : 0 : ad->tx_use_avx512 = false;
3773 : 0 : tx_check_ret = ice_tx_vec_dev_check(dev);
3774 [ # # # # ]: 0 : if (tx_check_ret >= 0 &&
3775 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
3776 : 0 : ad->tx_vec_allowed = true;
3777 : :
3778 [ # # # # ]: 0 : if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
3779 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
3780 : 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
3781 : : #ifdef CC_AVX512_SUPPORT
3782 : 0 : ad->tx_use_avx512 = true;
3783 : : #else
3784 : : PMD_DRV_LOG(NOTICE,
3785 : : "AVX512 is not supported in build env");
3786 : : #endif
3787 [ # # # # ]: 0 : if (!ad->tx_use_avx512 &&
3788 [ # # ]: 0 : (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
3789 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
3790 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
3791 : 0 : ad->tx_use_avx2 = true;
3792 : :
3793 [ # # # # : 0 : if (!ad->tx_use_avx2 && !ad->tx_use_avx512 &&
# # ]
3794 : : tx_check_ret == ICE_VECTOR_OFFLOAD_PATH)
3795 : 0 : ad->tx_vec_allowed = false;
3796 : :
3797 [ # # ]: 0 : if (ad->tx_vec_allowed) {
3798 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3799 : 0 : txq = dev->data->tx_queues[i];
3800 [ # # # # ]: 0 : if (txq && ice_txq_vec_setup(txq)) {
3801 : 0 : ad->tx_vec_allowed = false;
3802 : 0 : break;
3803 : : }
3804 : : }
3805 : : }
3806 : : } else {
3807 : 0 : ad->tx_vec_allowed = false;
3808 : : }
3809 : : }
3810 : :
3811 [ # # ]: 0 : if (ad->tx_vec_allowed) {
3812 : 0 : dev->tx_pkt_prepare = NULL;
3813 [ # # ]: 0 : if (ad->tx_use_avx512) {
3814 : : #ifdef CC_AVX512_SUPPORT
3815 [ # # ]: 0 : if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3816 : 0 : PMD_DRV_LOG(NOTICE,
3817 : : "Using AVX512 OFFLOAD Vector Tx (port %d).",
3818 : : dev->data->port_id);
3819 : 0 : dev->tx_pkt_burst =
3820 : : ice_xmit_pkts_vec_avx512_offload;
3821 : 0 : dev->tx_pkt_prepare = ice_prep_pkts;
3822 : : } else {
3823 : 0 : PMD_DRV_LOG(NOTICE,
3824 : : "Using AVX512 Vector Tx (port %d).",
3825 : : dev->data->port_id);
3826 : 0 : dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512;
3827 : : }
3828 : : #endif
3829 : : } else {
3830 [ # # ]: 0 : if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3831 : 0 : PMD_DRV_LOG(NOTICE,
3832 : : "Using AVX2 OFFLOAD Vector Tx (port %d).",
3833 : : dev->data->port_id);
3834 : 0 : dev->tx_pkt_burst =
3835 : : ice_xmit_pkts_vec_avx2_offload;
3836 : 0 : dev->tx_pkt_prepare = ice_prep_pkts;
3837 : : } else {
3838 [ # # ]: 0 : PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).",
3839 : : ad->tx_use_avx2 ? "avx2 " : "",
3840 : : dev->data->port_id);
3841 : 0 : dev->tx_pkt_burst = ad->tx_use_avx2 ?
3842 [ # # ]: 0 : ice_xmit_pkts_vec_avx2 :
3843 : : ice_xmit_pkts_vec;
3844 : : }
3845 : : }
3846 : :
3847 : 0 : return;
3848 : : }
3849 : : #endif
3850 : :
3851 [ # # ]: 0 : if (ad->tx_simple_allowed) {
3852 : 0 : PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
3853 : 0 : dev->tx_pkt_burst = ice_xmit_pkts_simple;
3854 : 0 : dev->tx_pkt_prepare = NULL;
3855 : : } else {
3856 : 0 : PMD_INIT_LOG(DEBUG, "Normal tx finally be used.");
3857 : 0 : dev->tx_pkt_burst = ice_xmit_pkts;
3858 : 0 : dev->tx_pkt_prepare = ice_prep_pkts;
3859 : : }
3860 : : }
3861 : :
3862 : : static const struct {
3863 : : eth_tx_burst_t pkt_burst;
3864 : : const char *info;
3865 : : } ice_tx_burst_infos[] = {
3866 : : { ice_xmit_pkts_simple, "Scalar Simple" },
3867 : : { ice_xmit_pkts, "Scalar" },
3868 : : #ifdef RTE_ARCH_X86
3869 : : #ifdef CC_AVX512_SUPPORT
3870 : : { ice_xmit_pkts_vec_avx512, "Vector AVX512" },
3871 : : { ice_xmit_pkts_vec_avx512_offload, "Offload Vector AVX512" },
3872 : : #endif
3873 : : { ice_xmit_pkts_vec_avx2, "Vector AVX2" },
3874 : : { ice_xmit_pkts_vec_avx2_offload, "Offload Vector AVX2" },
3875 : : { ice_xmit_pkts_vec, "Vector SSE" },
3876 : : #endif
3877 : : };
3878 : :
3879 : : int
3880 : 0 : ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3881 : : struct rte_eth_burst_mode *mode)
3882 : : {
3883 : 0 : eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
3884 : : int ret = -EINVAL;
3885 : : unsigned int i;
3886 : :
3887 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_tx_burst_infos); ++i) {
3888 [ # # ]: 0 : if (pkt_burst == ice_tx_burst_infos[i].pkt_burst) {
3889 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3890 : 0 : ice_tx_burst_infos[i].info);
3891 : : ret = 0;
3892 : 0 : break;
3893 : : }
3894 : : }
3895 : :
3896 : 0 : return ret;
3897 : : }
3898 : :
3899 : : /* For each value it means, datasheet of hardware can tell more details
3900 : : *
3901 : : * @note: fix ice_dev_supported_ptypes_get() if any change here.
3902 : : */
3903 : : static inline uint32_t
3904 : : ice_get_default_pkt_type(uint16_t ptype)
3905 : : {
3906 : : static const uint32_t type_table[ICE_MAX_PKT_TYPE]
3907 : : __rte_cache_aligned = {
3908 : : /* L2 types */
3909 : : /* [0] reserved */
3910 : : [1] = RTE_PTYPE_L2_ETHER,
3911 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
3912 : : /* [3] - [5] reserved */
3913 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
3914 : : /* [7] - [10] reserved */
3915 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
3916 : : /* [12] - [21] reserved */
3917 : :
3918 : : /* Non tunneled IPv4 */
3919 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3920 : : RTE_PTYPE_L4_FRAG,
3921 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3922 : : RTE_PTYPE_L4_NONFRAG,
3923 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3924 : : RTE_PTYPE_L4_UDP,
3925 : : /* [25] reserved */
3926 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3927 : : RTE_PTYPE_L4_TCP,
3928 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3929 : : RTE_PTYPE_L4_SCTP,
3930 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3931 : : RTE_PTYPE_L4_ICMP,
3932 : :
3933 : : /* IPv4 --> IPv4 */
3934 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3935 : : RTE_PTYPE_TUNNEL_IP |
3936 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3937 : : RTE_PTYPE_INNER_L4_FRAG,
3938 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3939 : : RTE_PTYPE_TUNNEL_IP |
3940 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3941 : : RTE_PTYPE_INNER_L4_NONFRAG,
3942 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3943 : : RTE_PTYPE_TUNNEL_IP |
3944 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3945 : : RTE_PTYPE_INNER_L4_UDP,
3946 : : /* [32] reserved */
3947 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3948 : : RTE_PTYPE_TUNNEL_IP |
3949 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3950 : : RTE_PTYPE_INNER_L4_TCP,
3951 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3952 : : RTE_PTYPE_TUNNEL_IP |
3953 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3954 : : RTE_PTYPE_INNER_L4_SCTP,
3955 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3956 : : RTE_PTYPE_TUNNEL_IP |
3957 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3958 : : RTE_PTYPE_INNER_L4_ICMP,
3959 : :
3960 : : /* IPv4 --> IPv6 */
3961 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3962 : : RTE_PTYPE_TUNNEL_IP |
3963 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3964 : : RTE_PTYPE_INNER_L4_FRAG,
3965 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3966 : : RTE_PTYPE_TUNNEL_IP |
3967 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3968 : : RTE_PTYPE_INNER_L4_NONFRAG,
3969 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3970 : : RTE_PTYPE_TUNNEL_IP |
3971 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3972 : : RTE_PTYPE_INNER_L4_UDP,
3973 : : /* [39] reserved */
3974 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3975 : : RTE_PTYPE_TUNNEL_IP |
3976 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3977 : : RTE_PTYPE_INNER_L4_TCP,
3978 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3979 : : RTE_PTYPE_TUNNEL_IP |
3980 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3981 : : RTE_PTYPE_INNER_L4_SCTP,
3982 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3983 : : RTE_PTYPE_TUNNEL_IP |
3984 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3985 : : RTE_PTYPE_INNER_L4_ICMP,
3986 : :
3987 : : /* IPv4 --> GRE/Teredo/VXLAN */
3988 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3989 : : RTE_PTYPE_TUNNEL_GRENAT,
3990 : :
3991 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
3992 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3993 : : RTE_PTYPE_TUNNEL_GRENAT |
3994 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3995 : : RTE_PTYPE_INNER_L4_FRAG,
3996 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3997 : : RTE_PTYPE_TUNNEL_GRENAT |
3998 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3999 : : RTE_PTYPE_INNER_L4_NONFRAG,
4000 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4001 : : RTE_PTYPE_TUNNEL_GRENAT |
4002 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4003 : : RTE_PTYPE_INNER_L4_UDP,
4004 : : /* [47] reserved */
4005 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4006 : : RTE_PTYPE_TUNNEL_GRENAT |
4007 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4008 : : RTE_PTYPE_INNER_L4_TCP,
4009 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4010 : : RTE_PTYPE_TUNNEL_GRENAT |
4011 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4012 : : RTE_PTYPE_INNER_L4_SCTP,
4013 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4014 : : RTE_PTYPE_TUNNEL_GRENAT |
4015 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4016 : : RTE_PTYPE_INNER_L4_ICMP,
4017 : :
4018 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
4019 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4020 : : RTE_PTYPE_TUNNEL_GRENAT |
4021 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4022 : : RTE_PTYPE_INNER_L4_FRAG,
4023 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4024 : : RTE_PTYPE_TUNNEL_GRENAT |
4025 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4026 : : RTE_PTYPE_INNER_L4_NONFRAG,
4027 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4028 : : RTE_PTYPE_TUNNEL_GRENAT |
4029 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4030 : : RTE_PTYPE_INNER_L4_UDP,
4031 : : /* [54] reserved */
4032 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4033 : : RTE_PTYPE_TUNNEL_GRENAT |
4034 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4035 : : RTE_PTYPE_INNER_L4_TCP,
4036 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4037 : : RTE_PTYPE_TUNNEL_GRENAT |
4038 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4039 : : RTE_PTYPE_INNER_L4_SCTP,
4040 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4041 : : RTE_PTYPE_TUNNEL_GRENAT |
4042 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4043 : : RTE_PTYPE_INNER_L4_ICMP,
4044 : :
4045 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
4046 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4047 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4048 : :
4049 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4050 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4051 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4052 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4053 : : RTE_PTYPE_INNER_L4_FRAG,
4054 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4055 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4056 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4057 : : RTE_PTYPE_INNER_L4_NONFRAG,
4058 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4059 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4060 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4061 : : RTE_PTYPE_INNER_L4_UDP,
4062 : : /* [62] reserved */
4063 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4064 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4065 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4066 : : RTE_PTYPE_INNER_L4_TCP,
4067 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4068 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4069 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4070 : : RTE_PTYPE_INNER_L4_SCTP,
4071 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4072 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4073 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4074 : : RTE_PTYPE_INNER_L4_ICMP,
4075 : :
4076 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4077 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4078 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4079 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4080 : : RTE_PTYPE_INNER_L4_FRAG,
4081 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4082 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4083 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4084 : : RTE_PTYPE_INNER_L4_NONFRAG,
4085 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4086 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4087 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4088 : : RTE_PTYPE_INNER_L4_UDP,
4089 : : /* [69] reserved */
4090 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4091 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4092 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4093 : : RTE_PTYPE_INNER_L4_TCP,
4094 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4095 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4096 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4097 : : RTE_PTYPE_INNER_L4_SCTP,
4098 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4099 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4100 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4101 : : RTE_PTYPE_INNER_L4_ICMP,
4102 : : /* [73] - [87] reserved */
4103 : :
4104 : : /* Non tunneled IPv6 */
4105 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4106 : : RTE_PTYPE_L4_FRAG,
4107 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4108 : : RTE_PTYPE_L4_NONFRAG,
4109 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4110 : : RTE_PTYPE_L4_UDP,
4111 : : /* [91] reserved */
4112 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4113 : : RTE_PTYPE_L4_TCP,
4114 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4115 : : RTE_PTYPE_L4_SCTP,
4116 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4117 : : RTE_PTYPE_L4_ICMP,
4118 : :
4119 : : /* IPv6 --> IPv4 */
4120 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4121 : : RTE_PTYPE_TUNNEL_IP |
4122 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4123 : : RTE_PTYPE_INNER_L4_FRAG,
4124 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4125 : : RTE_PTYPE_TUNNEL_IP |
4126 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4127 : : RTE_PTYPE_INNER_L4_NONFRAG,
4128 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4129 : : RTE_PTYPE_TUNNEL_IP |
4130 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4131 : : RTE_PTYPE_INNER_L4_UDP,
4132 : : /* [98] reserved */
4133 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4134 : : RTE_PTYPE_TUNNEL_IP |
4135 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4136 : : RTE_PTYPE_INNER_L4_TCP,
4137 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4138 : : RTE_PTYPE_TUNNEL_IP |
4139 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4140 : : RTE_PTYPE_INNER_L4_SCTP,
4141 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4142 : : RTE_PTYPE_TUNNEL_IP |
4143 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4144 : : RTE_PTYPE_INNER_L4_ICMP,
4145 : :
4146 : : /* IPv6 --> IPv6 */
4147 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4148 : : RTE_PTYPE_TUNNEL_IP |
4149 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4150 : : RTE_PTYPE_INNER_L4_FRAG,
4151 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4152 : : RTE_PTYPE_TUNNEL_IP |
4153 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4154 : : RTE_PTYPE_INNER_L4_NONFRAG,
4155 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4156 : : RTE_PTYPE_TUNNEL_IP |
4157 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4158 : : RTE_PTYPE_INNER_L4_UDP,
4159 : : /* [105] reserved */
4160 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4161 : : RTE_PTYPE_TUNNEL_IP |
4162 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4163 : : RTE_PTYPE_INNER_L4_TCP,
4164 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4165 : : RTE_PTYPE_TUNNEL_IP |
4166 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4167 : : RTE_PTYPE_INNER_L4_SCTP,
4168 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4169 : : RTE_PTYPE_TUNNEL_IP |
4170 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4171 : : RTE_PTYPE_INNER_L4_ICMP,
4172 : :
4173 : : /* IPv6 --> GRE/Teredo/VXLAN */
4174 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4175 : : RTE_PTYPE_TUNNEL_GRENAT,
4176 : :
4177 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4178 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4179 : : RTE_PTYPE_TUNNEL_GRENAT |
4180 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4181 : : RTE_PTYPE_INNER_L4_FRAG,
4182 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4183 : : RTE_PTYPE_TUNNEL_GRENAT |
4184 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4185 : : RTE_PTYPE_INNER_L4_NONFRAG,
4186 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4187 : : RTE_PTYPE_TUNNEL_GRENAT |
4188 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4189 : : RTE_PTYPE_INNER_L4_UDP,
4190 : : /* [113] reserved */
4191 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4192 : : RTE_PTYPE_TUNNEL_GRENAT |
4193 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4194 : : RTE_PTYPE_INNER_L4_TCP,
4195 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4196 : : RTE_PTYPE_TUNNEL_GRENAT |
4197 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4198 : : RTE_PTYPE_INNER_L4_SCTP,
4199 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4200 : : RTE_PTYPE_TUNNEL_GRENAT |
4201 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4202 : : RTE_PTYPE_INNER_L4_ICMP,
4203 : :
4204 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4205 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4206 : : RTE_PTYPE_TUNNEL_GRENAT |
4207 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4208 : : RTE_PTYPE_INNER_L4_FRAG,
4209 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4210 : : RTE_PTYPE_TUNNEL_GRENAT |
4211 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4212 : : RTE_PTYPE_INNER_L4_NONFRAG,
4213 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4214 : : RTE_PTYPE_TUNNEL_GRENAT |
4215 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4216 : : RTE_PTYPE_INNER_L4_UDP,
4217 : : /* [120] reserved */
4218 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4219 : : RTE_PTYPE_TUNNEL_GRENAT |
4220 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4221 : : RTE_PTYPE_INNER_L4_TCP,
4222 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4223 : : RTE_PTYPE_TUNNEL_GRENAT |
4224 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4225 : : RTE_PTYPE_INNER_L4_SCTP,
4226 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4227 : : RTE_PTYPE_TUNNEL_GRENAT |
4228 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4229 : : RTE_PTYPE_INNER_L4_ICMP,
4230 : :
4231 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4232 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4233 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4234 : :
4235 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4236 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4237 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4238 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4239 : : RTE_PTYPE_INNER_L4_FRAG,
4240 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4241 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4242 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4243 : : RTE_PTYPE_INNER_L4_NONFRAG,
4244 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4245 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4246 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4247 : : RTE_PTYPE_INNER_L4_UDP,
4248 : : /* [128] reserved */
4249 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4250 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4251 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4252 : : RTE_PTYPE_INNER_L4_TCP,
4253 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4254 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4255 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4256 : : RTE_PTYPE_INNER_L4_SCTP,
4257 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4258 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4259 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4260 : : RTE_PTYPE_INNER_L4_ICMP,
4261 : :
4262 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4263 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4264 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4265 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4266 : : RTE_PTYPE_INNER_L4_FRAG,
4267 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4268 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4269 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4270 : : RTE_PTYPE_INNER_L4_NONFRAG,
4271 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4272 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4273 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4274 : : RTE_PTYPE_INNER_L4_UDP,
4275 : : /* [135] reserved */
4276 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4277 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4278 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4279 : : RTE_PTYPE_INNER_L4_TCP,
4280 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4281 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4282 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4283 : : RTE_PTYPE_INNER_L4_SCTP,
4284 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4285 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4286 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4287 : : RTE_PTYPE_INNER_L4_ICMP,
4288 : : /* [139] - [299] reserved */
4289 : :
4290 : : /* PPPoE */
4291 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4292 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4293 : :
4294 : : /* PPPoE --> IPv4 */
4295 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4296 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4297 : : RTE_PTYPE_L4_FRAG,
4298 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4299 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4300 : : RTE_PTYPE_L4_NONFRAG,
4301 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4302 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4303 : : RTE_PTYPE_L4_UDP,
4304 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4305 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4306 : : RTE_PTYPE_L4_TCP,
4307 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4308 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4309 : : RTE_PTYPE_L4_SCTP,
4310 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4311 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4312 : : RTE_PTYPE_L4_ICMP,
4313 : :
4314 : : /* PPPoE --> IPv6 */
4315 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4316 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4317 : : RTE_PTYPE_L4_FRAG,
4318 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4319 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4320 : : RTE_PTYPE_L4_NONFRAG,
4321 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4322 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4323 : : RTE_PTYPE_L4_UDP,
4324 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4325 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4326 : : RTE_PTYPE_L4_TCP,
4327 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4328 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4329 : : RTE_PTYPE_L4_SCTP,
4330 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4331 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4332 : : RTE_PTYPE_L4_ICMP,
4333 : : /* [314] - [324] reserved */
4334 : :
4335 : : /* IPv4/IPv6 --> GTPC/GTPU */
4336 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4337 : : RTE_PTYPE_TUNNEL_GTPC,
4338 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4339 : : RTE_PTYPE_TUNNEL_GTPC,
4340 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4341 : : RTE_PTYPE_TUNNEL_GTPC,
4342 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4343 : : RTE_PTYPE_TUNNEL_GTPC,
4344 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4345 : : RTE_PTYPE_TUNNEL_GTPU,
4346 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4347 : : RTE_PTYPE_TUNNEL_GTPU,
4348 : :
4349 : : /* IPv4 --> GTPU --> IPv4 */
4350 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4351 : : RTE_PTYPE_TUNNEL_GTPU |
4352 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4353 : : RTE_PTYPE_INNER_L4_FRAG,
4354 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4355 : : RTE_PTYPE_TUNNEL_GTPU |
4356 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4357 : : RTE_PTYPE_INNER_L4_NONFRAG,
4358 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4359 : : RTE_PTYPE_TUNNEL_GTPU |
4360 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4361 : : RTE_PTYPE_INNER_L4_UDP,
4362 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4363 : : RTE_PTYPE_TUNNEL_GTPU |
4364 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4365 : : RTE_PTYPE_INNER_L4_TCP,
4366 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4367 : : RTE_PTYPE_TUNNEL_GTPU |
4368 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4369 : : RTE_PTYPE_INNER_L4_ICMP,
4370 : :
4371 : : /* IPv6 --> GTPU --> IPv4 */
4372 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4373 : : RTE_PTYPE_TUNNEL_GTPU |
4374 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4375 : : RTE_PTYPE_INNER_L4_FRAG,
4376 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4377 : : RTE_PTYPE_TUNNEL_GTPU |
4378 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4379 : : RTE_PTYPE_INNER_L4_NONFRAG,
4380 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4381 : : RTE_PTYPE_TUNNEL_GTPU |
4382 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4383 : : RTE_PTYPE_INNER_L4_UDP,
4384 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4385 : : RTE_PTYPE_TUNNEL_GTPU |
4386 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4387 : : RTE_PTYPE_INNER_L4_TCP,
4388 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4389 : : RTE_PTYPE_TUNNEL_GTPU |
4390 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4391 : : RTE_PTYPE_INNER_L4_ICMP,
4392 : :
4393 : : /* IPv4 --> GTPU --> IPv6 */
4394 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4395 : : RTE_PTYPE_TUNNEL_GTPU |
4396 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4397 : : RTE_PTYPE_INNER_L4_FRAG,
4398 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4399 : : RTE_PTYPE_TUNNEL_GTPU |
4400 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4401 : : RTE_PTYPE_INNER_L4_NONFRAG,
4402 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4403 : : RTE_PTYPE_TUNNEL_GTPU |
4404 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4405 : : RTE_PTYPE_INNER_L4_UDP,
4406 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4407 : : RTE_PTYPE_TUNNEL_GTPU |
4408 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4409 : : RTE_PTYPE_INNER_L4_TCP,
4410 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4411 : : RTE_PTYPE_TUNNEL_GTPU |
4412 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4413 : : RTE_PTYPE_INNER_L4_ICMP,
4414 : :
4415 : : /* IPv6 --> GTPU --> IPv6 */
4416 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4417 : : RTE_PTYPE_TUNNEL_GTPU |
4418 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4419 : : RTE_PTYPE_INNER_L4_FRAG,
4420 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4421 : : RTE_PTYPE_TUNNEL_GTPU |
4422 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4423 : : RTE_PTYPE_INNER_L4_NONFRAG,
4424 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4425 : : RTE_PTYPE_TUNNEL_GTPU |
4426 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4427 : : RTE_PTYPE_INNER_L4_UDP,
4428 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4429 : : RTE_PTYPE_TUNNEL_GTPU |
4430 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4431 : : RTE_PTYPE_INNER_L4_TCP,
4432 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4433 : : RTE_PTYPE_TUNNEL_GTPU |
4434 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4435 : : RTE_PTYPE_INNER_L4_ICMP,
4436 : :
4437 : : /* IPv4 --> UDP ECPRI */
4438 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4439 : : RTE_PTYPE_L4_UDP,
4440 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4441 : : RTE_PTYPE_L4_UDP,
4442 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4443 : : RTE_PTYPE_L4_UDP,
4444 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4445 : : RTE_PTYPE_L4_UDP,
4446 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4447 : : RTE_PTYPE_L4_UDP,
4448 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4449 : : RTE_PTYPE_L4_UDP,
4450 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4451 : : RTE_PTYPE_L4_UDP,
4452 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4453 : : RTE_PTYPE_L4_UDP,
4454 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4455 : : RTE_PTYPE_L4_UDP,
4456 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4457 : : RTE_PTYPE_L4_UDP,
4458 : :
4459 : : /* IPV6 --> UDP ECPRI */
4460 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4461 : : RTE_PTYPE_L4_UDP,
4462 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4463 : : RTE_PTYPE_L4_UDP,
4464 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4465 : : RTE_PTYPE_L4_UDP,
4466 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4467 : : RTE_PTYPE_L4_UDP,
4468 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4469 : : RTE_PTYPE_L4_UDP,
4470 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4471 : : RTE_PTYPE_L4_UDP,
4472 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4473 : : RTE_PTYPE_L4_UDP,
4474 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4475 : : RTE_PTYPE_L4_UDP,
4476 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4477 : : RTE_PTYPE_L4_UDP,
4478 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4479 : : RTE_PTYPE_L4_UDP,
4480 : : /* All others reserved */
4481 : : };
4482 : :
4483 : 0 : return type_table[ptype];
4484 : : }
4485 : :
4486 : : void __rte_cold
4487 : 0 : ice_set_default_ptype_table(struct rte_eth_dev *dev)
4488 : : {
4489 : 0 : struct ice_adapter *ad =
4490 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4491 : : int i;
4492 : :
4493 [ # # ]: 0 : for (i = 0; i < ICE_MAX_PKT_TYPE; i++)
4494 : 0 : ad->ptype_tbl[i] = ice_get_default_pkt_type(i);
4495 : 0 : }
4496 : :
4497 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S 1
4498 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M \
4499 : : (0x3UL << ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S)
4500 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD 0
4501 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL 0x1
4502 : :
4503 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S 4
4504 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M \
4505 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S)
4506 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S 5
4507 : : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M \
4508 : : (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S)
4509 : :
4510 : : /*
4511 : : * check the programming status descriptor in rx queue.
4512 : : * done after Programming Flow Director is programmed on
4513 : : * tx queue
4514 : : */
4515 : : static inline int
4516 : 0 : ice_check_fdir_programming_status(struct ice_rx_queue *rxq)
4517 : : {
4518 : : volatile union ice_32byte_rx_desc *rxdp;
4519 : : uint64_t qword1;
4520 : : uint32_t rx_status;
4521 : : uint32_t error;
4522 : : uint32_t id;
4523 : : int ret = -EAGAIN;
4524 : :
4525 : 0 : rxdp = (volatile union ice_32byte_rx_desc *)
4526 : 0 : (&rxq->rx_ring[rxq->rx_tail]);
4527 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
4528 : : rx_status = (qword1 & ICE_RXD_QW1_STATUS_M)
4529 : 0 : >> ICE_RXD_QW1_STATUS_S;
4530 : :
4531 [ # # ]: 0 : if (rx_status & (1 << ICE_RX_DESC_STATUS_DD_S)) {
4532 : : ret = 0;
4533 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M) >>
4534 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S;
4535 : 0 : id = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M) >>
4536 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S;
4537 [ # # ]: 0 : if (error) {
4538 [ # # ]: 0 : if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD)
4539 : 0 : PMD_DRV_LOG(ERR, "Failed to add FDIR rule.");
4540 [ # # ]: 0 : else if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL)
4541 : 0 : PMD_DRV_LOG(ERR, "Failed to remove FDIR rule.");
4542 : : ret = -EINVAL;
4543 : 0 : goto err;
4544 : : }
4545 : 0 : error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M) >>
4546 : : ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S;
4547 [ # # ]: 0 : if (error) {
4548 : 0 : PMD_DRV_LOG(ERR, "Failed to create FDIR profile.");
4549 : : ret = -EINVAL;
4550 : : }
4551 : 0 : err:
4552 : 0 : rxdp->wb.qword1.status_error_len = 0;
4553 : 0 : rxq->rx_tail++;
4554 [ # # ]: 0 : if (unlikely(rxq->rx_tail == rxq->nb_rx_desc))
4555 : 0 : rxq->rx_tail = 0;
4556 [ # # ]: 0 : if (rxq->rx_tail == 0)
4557 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
4558 : : else
4559 : 0 : ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_tail - 1);
4560 : : }
4561 : :
4562 : 0 : return ret;
4563 : : }
4564 : :
4565 : : #define ICE_FDIR_MAX_WAIT_US 10000
4566 : :
4567 : : int
4568 : 0 : ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
4569 : : {
4570 : 0 : struct ice_tx_queue *txq = pf->fdir.txq;
4571 : 0 : struct ice_rx_queue *rxq = pf->fdir.rxq;
4572 : : volatile struct ice_fltr_desc *fdirdp;
4573 : : volatile struct ice_tx_desc *txdp;
4574 : : uint32_t td_cmd;
4575 : : uint16_t i;
4576 : :
4577 : 0 : fdirdp = (volatile struct ice_fltr_desc *)
4578 : 0 : (&txq->tx_ring[txq->tx_tail]);
4579 : 0 : fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
4580 : 0 : fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
4581 : :
4582 : 0 : txdp = &txq->tx_ring[txq->tx_tail + 1];
4583 : 0 : txdp->buf_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
4584 : : td_cmd = ICE_TX_DESC_CMD_EOP |
4585 : : ICE_TX_DESC_CMD_RS |
4586 : : ICE_TX_DESC_CMD_DUMMY;
4587 : :
4588 : 0 : txdp->cmd_type_offset_bsz =
4589 : : ice_build_ctob(td_cmd, 0, ICE_FDIR_PKT_LEN, 0);
4590 : :
4591 : 0 : txq->tx_tail += 2;
4592 [ # # ]: 0 : if (txq->tx_tail >= txq->nb_tx_desc)
4593 : 0 : txq->tx_tail = 0;
4594 : : /* Update the tx tail register */
4595 : 0 : ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
4596 [ # # ]: 0 : for (i = 0; i < ICE_FDIR_MAX_WAIT_US; i++) {
4597 [ # # ]: 0 : if ((txdp->cmd_type_offset_bsz &
4598 : : rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) ==
4599 : : rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
4600 : : break;
4601 : 0 : rte_delay_us(1);
4602 : : }
4603 [ # # ]: 0 : if (i >= ICE_FDIR_MAX_WAIT_US) {
4604 : 0 : PMD_DRV_LOG(ERR,
4605 : : "Failed to program FDIR filter: time out to get DD on tx queue.");
4606 : 0 : return -ETIMEDOUT;
4607 : : }
4608 : :
4609 [ # # ]: 0 : for (; i < ICE_FDIR_MAX_WAIT_US; i++) {
4610 : : int ret;
4611 : :
4612 : 0 : ret = ice_check_fdir_programming_status(rxq);
4613 [ # # ]: 0 : if (ret == -EAGAIN)
4614 : 0 : rte_delay_us(1);
4615 : : else
4616 : 0 : return ret;
4617 : : }
4618 : :
4619 : 0 : PMD_DRV_LOG(ERR,
4620 : : "Failed to program FDIR filter: programming status reported.");
4621 : 0 : return -ETIMEDOUT;
4622 : :
4623 : :
4624 : : }
|