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