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