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