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