Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <sys/queue.h>
7 : :
8 : : #include <stdio.h>
9 : : #include <stdlib.h>
10 : : #include <string.h>
11 : : #include <errno.h>
12 : : #include <stdint.h>
13 : : #include <stdarg.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : :
17 : : #include <rte_byteorder.h>
18 : : #include <rte_common.h>
19 : : #include <rte_cycles.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_interrupts.h>
23 : : #include <rte_pci.h>
24 : : #include <rte_memory.h>
25 : : #include <rte_memzone.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_mempool.h>
32 : : #include <rte_malloc.h>
33 : : #include <rte_mbuf.h>
34 : : #include <rte_ether.h>
35 : : #include <ethdev_driver.h>
36 : : #include <rte_security_driver.h>
37 : : #include <rte_prefetch.h>
38 : : #include <rte_udp.h>
39 : : #include <rte_tcp.h>
40 : : #include <rte_sctp.h>
41 : : #include <rte_string_fns.h>
42 : : #include <rte_errno.h>
43 : : #include <rte_ip.h>
44 : : #include <rte_net.h>
45 : : #include <rte_vect.h>
46 : :
47 : : #include "ixgbe_logs.h"
48 : : #include "base/ixgbe_api.h"
49 : : #include "base/ixgbe_vf.h"
50 : : #include "ixgbe_ethdev.h"
51 : : #include "base/ixgbe_dcb.h"
52 : : #include "base/ixgbe_common.h"
53 : : #include "ixgbe_rxtx.h"
54 : :
55 : : #ifdef RTE_LIBRTE_IEEE1588
56 : : #define IXGBE_TX_IEEE1588_TMST RTE_MBUF_F_TX_IEEE1588_TMST
57 : : #else
58 : : #define IXGBE_TX_IEEE1588_TMST 0
59 : : #endif
60 : : /* Bit Mask to indicate what bits required for building TX context */
61 : : #define IXGBE_TX_OFFLOAD_MASK (RTE_MBUF_F_TX_OUTER_IPV6 | \
62 : : RTE_MBUF_F_TX_OUTER_IPV4 | \
63 : : RTE_MBUF_F_TX_IPV6 | \
64 : : RTE_MBUF_F_TX_IPV4 | \
65 : : RTE_MBUF_F_TX_VLAN | \
66 : : RTE_MBUF_F_TX_IP_CKSUM | \
67 : : RTE_MBUF_F_TX_L4_MASK | \
68 : : RTE_MBUF_F_TX_TCP_SEG | \
69 : : RTE_MBUF_F_TX_MACSEC | \
70 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
71 : : RTE_MBUF_F_TX_SEC_OFFLOAD | \
72 : : IXGBE_TX_IEEE1588_TMST)
73 : :
74 : : #define IXGBE_TX_OFFLOAD_NOTSUP_MASK \
75 : : (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IXGBE_TX_OFFLOAD_MASK)
76 : :
77 : : #if 1
78 : : #define RTE_PMD_USE_PREFETCH
79 : : #endif
80 : :
81 : : #ifdef RTE_PMD_USE_PREFETCH
82 : : /*
83 : : * Prefetch a cache line into all cache levels.
84 : : */
85 : : #define rte_ixgbe_prefetch(p) rte_prefetch0(p)
86 : : #else
87 : : #define rte_ixgbe_prefetch(p) do {} while (0)
88 : : #endif
89 : :
90 : : /* forward-declare some functions */
91 : : static int ixgbe_is_vf(struct rte_eth_dev *dev);
92 : : static int ixgbe_write_default_ctx_desc(struct ci_tx_queue *txq, struct rte_mempool *mp, bool vec);
93 : :
94 : : /*********************************************************************
95 : : *
96 : : * TX functions
97 : : *
98 : : **********************************************************************/
99 : :
100 : : /*
101 : : * Check for descriptors with their DD bit set and free mbufs.
102 : : * Return the total number of buffers freed.
103 : : */
104 : : static __rte_always_inline int
105 : : ixgbe_tx_free_bufs(struct ci_tx_queue *txq)
106 : : {
107 : : struct ci_tx_entry *txep;
108 : : uint32_t status;
109 : : int i, nb_free = 0;
110 : : struct rte_mbuf *m, *free[RTE_IXGBE_TX_MAX_FREE_BUF_SZ];
111 : :
112 : : /* check DD bit on threshold descriptor */
113 : 0 : status = txq->ixgbe_tx_ring[txq->tx_next_dd].wb.status;
114 [ # # # # ]: 0 : if (!(status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD)))
115 : : return 0;
116 : :
117 : : /*
118 : : * first buffer to free from S/W ring is at index
119 : : * tx_next_dd - (tx_rs_thresh-1)
120 : : */
121 : 0 : txep = &(txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)]);
122 : :
123 [ # # # # ]: 0 : for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
124 : : /* free buffers one at a time */
125 : 0 : m = rte_pktmbuf_prefree_seg(txep->mbuf);
126 : 0 : txep->mbuf = NULL;
127 : :
128 [ # # # # ]: 0 : if (unlikely(m == NULL))
129 : 0 : continue;
130 : :
131 [ # # # # : 0 : if (nb_free >= RTE_IXGBE_TX_MAX_FREE_BUF_SZ ||
# # # # ]
132 [ # # # # ]: 0 : (nb_free > 0 && m->pool != free[0]->pool)) {
133 [ # # # # ]: 0 : rte_mempool_put_bulk(free[0]->pool,
134 : : (void **)free, nb_free);
135 : : nb_free = 0;
136 : : }
137 : :
138 : 0 : free[nb_free++] = m;
139 : : }
140 : :
141 [ # # # # ]: 0 : if (nb_free > 0)
142 [ # # # # ]: 0 : rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free);
143 : :
144 : : /* buffers were freed, update counters */
145 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
146 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
147 [ # # # # ]: 0 : if (txq->tx_next_dd >= txq->nb_tx_desc)
148 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
149 : :
150 : 0 : return txq->tx_rs_thresh;
151 : : }
152 : :
153 : : /* Populate 4 descriptors with data from 4 mbufs */
154 : : static inline void
155 : : tx4(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts,
156 : : const uint32_t olinfo_flags)
157 : : {
158 : : uint64_t buf_dma_addr;
159 : : uint32_t pkt_len;
160 : : int i;
161 : :
162 [ # # ]: 0 : for (i = 0; i < 4; ++i, ++txdp, ++pkts) {
163 : 0 : buf_dma_addr = rte_mbuf_data_iova(*pkts);
164 : 0 : pkt_len = (*pkts)->data_len;
165 : :
166 : : /* write data to descriptor */
167 : 0 : txdp->read.buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
168 : :
169 : 0 : txdp->read.cmd_type_len =
170 : 0 : rte_cpu_to_le_32((uint32_t)DCMD_DTYP_FLAGS | pkt_len);
171 : :
172 : 0 : txdp->read.olinfo_status =
173 : 0 : rte_cpu_to_le_32(pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT) |
174 : : olinfo_flags;
175 : :
176 : 0 : rte_prefetch0(&(*pkts)->pool);
177 : : }
178 : : }
179 : :
180 : : /* Populate 1 descriptor with data from 1 mbuf */
181 : : static inline void
182 : : tx1(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts,
183 : : const uint32_t olinfo_flags)
184 : : {
185 : : uint64_t buf_dma_addr;
186 : : uint32_t pkt_len;
187 : :
188 : : buf_dma_addr = rte_mbuf_data_iova(*pkts);
189 : 0 : pkt_len = (*pkts)->data_len;
190 : :
191 : : /* write data to descriptor */
192 : 0 : txdp->read.buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
193 : 0 : txdp->read.cmd_type_len =
194 : 0 : rte_cpu_to_le_32((uint32_t)DCMD_DTYP_FLAGS | pkt_len);
195 : 0 : txdp->read.olinfo_status =
196 : 0 : rte_cpu_to_le_32(pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT) |
197 : : olinfo_flags;
198 : 0 : rte_prefetch0(&(*pkts)->pool);
199 : : }
200 : :
201 : : /*
202 : : * Fill H/W descriptor ring with mbuf data.
203 : : * Copy mbuf pointers to the S/W ring.
204 : : */
205 : : static inline void
206 : 0 : ixgbe_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
207 : : uint16_t nb_pkts)
208 : : {
209 : 0 : volatile union ixgbe_adv_tx_desc *txdp = &txq->ixgbe_tx_ring[txq->tx_tail];
210 : 0 : struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
211 : : const int N_PER_LOOP = 4;
212 : : const int N_PER_LOOP_MASK = N_PER_LOOP-1;
213 : : /* for VF queues, need to set CC bit. context idx is always 0. */
214 [ # # ]: 0 : const uint32_t olinfo_flags = txq->is_vf ? rte_cpu_to_le_32(IXGBE_ADVTXD_CC) : 0;
215 : : int mainpart, leftover;
216 : : int i, j;
217 : :
218 : : /*
219 : : * Process most of the packets in chunks of N pkts. Any
220 : : * leftover packets will get processed one at a time.
221 : : */
222 : 0 : mainpart = (nb_pkts & ((uint32_t) ~N_PER_LOOP_MASK));
223 : 0 : leftover = (nb_pkts & ((uint32_t) N_PER_LOOP_MASK));
224 [ # # ]: 0 : for (i = 0; i < mainpart; i += N_PER_LOOP) {
225 : : /* Copy N mbuf pointers to the S/W ring */
226 [ # # ]: 0 : for (j = 0; j < N_PER_LOOP; ++j) {
227 : 0 : (txep + i + j)->mbuf = *(pkts + i + j);
228 : : }
229 : 0 : tx4(txdp + i, pkts + i, olinfo_flags);
230 : : }
231 : :
232 [ # # ]: 0 : if (unlikely(leftover > 0)) {
233 [ # # ]: 0 : for (i = 0; i < leftover; ++i) {
234 : 0 : (txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
235 : 0 : tx1(txdp + mainpart + i, pkts + mainpart + i, olinfo_flags);
236 : : }
237 : : }
238 : 0 : }
239 : :
240 : : static inline uint16_t
241 : 0 : tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
242 : : uint16_t nb_pkts)
243 : : {
244 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
245 : 0 : volatile union ixgbe_adv_tx_desc *tx_r = txq->ixgbe_tx_ring;
246 : : uint16_t n = 0;
247 : :
248 : : /*
249 : : * Begin scanning the H/W ring for done descriptors when the
250 : : * number of available descriptors drops below tx_free_thresh. For
251 : : * each done descriptor, free the associated buffer.
252 : : */
253 [ # # ]: 0 : if (txq->nb_tx_free < txq->tx_free_thresh)
254 : : ixgbe_tx_free_bufs(txq);
255 : :
256 : : /* Only use descriptors that are available */
257 : 0 : nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
258 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
259 : : return 0;
260 : :
261 : : /* Use exactly nb_pkts descriptors */
262 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
263 : :
264 : : /*
265 : : * At this point, we know there are enough descriptors in the
266 : : * ring to transmit all the packets. This assumes that each
267 : : * mbuf contains a single segment, and that no new offloads
268 : : * are expected, which would require a new context descriptor.
269 : : */
270 : :
271 : : /*
272 : : * See if we're going to wrap-around. If so, handle the top
273 : : * of the descriptor ring first, then do the bottom. If not,
274 : : * the processing looks just like the "bottom" part anyway...
275 : : */
276 [ # # ]: 0 : if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
277 : 0 : n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
278 : 0 : ixgbe_tx_fill_hw_ring(txq, tx_pkts, n);
279 : :
280 : : /*
281 : : * We know that the last descriptor in the ring will need to
282 : : * have its RS bit set because tx_rs_thresh has to be
283 : : * a divisor of the ring size
284 : : */
285 : 0 : tx_r[txq->tx_next_rs].read.cmd_type_len |=
286 : : rte_cpu_to_le_32(IXGBE_ADVTXD_DCMD_RS);
287 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
288 : :
289 : 0 : txq->tx_tail = 0;
290 : : }
291 : :
292 : : /* Fill H/W descriptor ring with mbuf data */
293 : 0 : ixgbe_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
294 : 0 : txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
295 : :
296 : : /*
297 : : * Determine if RS bit should be set
298 : : * This is what we actually want:
299 : : * if ((txq->tx_tail - 1) >= txq->tx_next_rs)
300 : : * but instead of subtracting 1 and doing >=, we can just do
301 : : * greater than without subtracting.
302 : : */
303 [ # # ]: 0 : if (txq->tx_tail > txq->tx_next_rs) {
304 : 0 : tx_r[txq->tx_next_rs].read.cmd_type_len |=
305 : : rte_cpu_to_le_32(IXGBE_ADVTXD_DCMD_RS);
306 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_next_rs +
307 : 0 : txq->tx_rs_thresh);
308 [ # # ]: 0 : if (txq->tx_next_rs >= txq->nb_tx_desc)
309 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
310 : : }
311 : :
312 : : /*
313 : : * Check for wrap-around. This would only happen if we used
314 : : * up to the last descriptor in the ring, no more, no less.
315 : : */
316 [ # # ]: 0 : if (txq->tx_tail >= txq->nb_tx_desc)
317 : 0 : txq->tx_tail = 0;
318 : :
319 : : /* update tail pointer */
320 : : rte_wmb();
321 [ # # ]: 0 : IXGBE_PCI_REG_WC_WRITE_RELAXED(txq->qtx_tail, txq->tx_tail);
322 : :
323 : : return nb_pkts;
324 : : }
325 : :
326 : : uint16_t
327 : 0 : ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
328 : : uint16_t nb_pkts)
329 : : {
330 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
331 : : uint16_t nb_tx;
332 : :
333 : : /* we might check first packet's mempool */
334 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
335 : : return nb_pkts;
336 : :
337 : : /* check if we need to initialize default context descriptor */
338 [ # # # # ]: 0 : if (unlikely(!txq->vf_ctx_initialized) &&
339 : 0 : ixgbe_write_default_ctx_desc(txq, tx_pkts[0]->pool, false))
340 : : return 0;
341 : :
342 : : /* Try to transmit at least chunks of TX_MAX_BURST pkts */
343 [ # # ]: 0 : if (likely(nb_pkts <= RTE_PMD_IXGBE_TX_MAX_BURST))
344 : 0 : return tx_xmit_pkts(tx_queue, tx_pkts, nb_pkts);
345 : :
346 : : /* transmit more than the max burst, in chunks of TX_MAX_BURST */
347 : : nb_tx = 0;
348 [ # # ]: 0 : while (nb_pkts) {
349 : : uint16_t ret, n;
350 : :
351 : 0 : n = (uint16_t)RTE_MIN(nb_pkts, RTE_PMD_IXGBE_TX_MAX_BURST);
352 : 0 : ret = tx_xmit_pkts(tx_queue, &(tx_pkts[nb_tx]), n);
353 : 0 : nb_tx = (uint16_t)(nb_tx + ret);
354 : 0 : nb_pkts = (uint16_t)(nb_pkts - ret);
355 [ # # ]: 0 : if (ret < n)
356 : : break;
357 : : }
358 : :
359 : : return nb_tx;
360 : : }
361 : :
362 : : static uint16_t
363 : 0 : ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
364 : : uint16_t nb_pkts)
365 : : {
366 : : uint16_t nb_tx = 0;
367 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
368 : :
369 : : /* we might check first packet's mempool */
370 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
371 : : return nb_pkts;
372 : :
373 : : /* check if we need to initialize default context descriptor */
374 [ # # # # ]: 0 : if (unlikely(!txq->vf_ctx_initialized) &&
375 : 0 : ixgbe_write_default_ctx_desc(txq, tx_pkts[0]->pool, true))
376 : : return 0;
377 : :
378 [ # # ]: 0 : while (nb_pkts) {
379 : : uint16_t ret, num;
380 : :
381 : 0 : num = (uint16_t)RTE_MIN(nb_pkts, txq->tx_rs_thresh);
382 : 0 : ret = ixgbe_xmit_fixed_burst_vec(tx_queue, &tx_pkts[nb_tx],
383 : : num);
384 : 0 : nb_tx += ret;
385 : 0 : nb_pkts -= ret;
386 [ # # ]: 0 : if (ret < num)
387 : : break;
388 : : }
389 : :
390 : : return nb_tx;
391 : : }
392 : :
393 : : static inline void
394 : 0 : ixgbe_set_xmit_ctx(struct ci_tx_queue *txq,
395 : : volatile struct ixgbe_adv_tx_context_desc *ctx_txd,
396 : : uint64_t ol_flags, union ixgbe_tx_offload tx_offload,
397 : : __rte_unused uint64_t *mdata)
398 : : {
399 : : uint32_t type_tucmd_mlhl;
400 : : uint32_t mss_l4len_idx = 0;
401 : : uint32_t ctx_idx;
402 : : uint32_t vlan_macip_lens;
403 : : union ixgbe_tx_offload tx_offload_mask;
404 : : uint32_t seqnum_seed = 0;
405 : :
406 : 0 : ctx_idx = txq->ctx_curr;
407 : 0 : tx_offload_mask.data[0] = 0;
408 : 0 : tx_offload_mask.data[1] = 0;
409 : : type_tucmd_mlhl = 0;
410 : :
411 : : /* Specify which HW CTX to upload. */
412 : 0 : mss_l4len_idx |= (ctx_idx << IXGBE_ADVTXD_IDX_SHIFT);
413 : :
414 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_VLAN)
415 : 0 : tx_offload_mask.vlan_tci |= ~0;
416 : :
417 : : /* check if TCP segmentation required for this packet */
418 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
419 : : /* implies IP cksum in IPv4 */
420 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
421 : : type_tucmd_mlhl = IXGBE_ADVTXD_TUCMD_IPV4 |
422 : : IXGBE_ADVTXD_TUCMD_L4T_TCP |
423 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
424 : : else
425 : : type_tucmd_mlhl = IXGBE_ADVTXD_TUCMD_IPV6 |
426 : : IXGBE_ADVTXD_TUCMD_L4T_TCP |
427 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
428 : :
429 : 0 : tx_offload_mask.l2_len |= ~0;
430 : 0 : tx_offload_mask.l3_len |= ~0;
431 : 0 : tx_offload_mask.l4_len |= ~0;
432 : 0 : tx_offload_mask.tso_segsz |= ~0;
433 : 0 : mss_l4len_idx |= tx_offload.tso_segsz << IXGBE_ADVTXD_MSS_SHIFT;
434 : 0 : mss_l4len_idx |= tx_offload.l4_len << IXGBE_ADVTXD_L4LEN_SHIFT;
435 : : } else { /* no TSO, check if hardware checksum is needed */
436 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
437 : : type_tucmd_mlhl = IXGBE_ADVTXD_TUCMD_IPV4;
438 : 0 : tx_offload_mask.l2_len |= ~0;
439 : 0 : tx_offload_mask.l3_len |= ~0;
440 : : }
441 : :
442 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
443 : 0 : case RTE_MBUF_F_TX_UDP_CKSUM:
444 : 0 : type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_UDP |
445 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
446 : 0 : mss_l4len_idx |= sizeof(struct rte_udp_hdr)
447 : : << IXGBE_ADVTXD_L4LEN_SHIFT;
448 : 0 : tx_offload_mask.l2_len |= ~0;
449 : 0 : tx_offload_mask.l3_len |= ~0;
450 : 0 : break;
451 : 0 : case RTE_MBUF_F_TX_TCP_CKSUM:
452 : 0 : type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP |
453 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
454 : 0 : mss_l4len_idx |= sizeof(struct rte_tcp_hdr)
455 : : << IXGBE_ADVTXD_L4LEN_SHIFT;
456 : 0 : tx_offload_mask.l2_len |= ~0;
457 : 0 : tx_offload_mask.l3_len |= ~0;
458 : 0 : break;
459 : 0 : case RTE_MBUF_F_TX_SCTP_CKSUM:
460 : 0 : type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_SCTP |
461 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
462 : 0 : mss_l4len_idx |= sizeof(struct rte_sctp_hdr)
463 : : << IXGBE_ADVTXD_L4LEN_SHIFT;
464 : 0 : tx_offload_mask.l2_len |= ~0;
465 : 0 : tx_offload_mask.l3_len |= ~0;
466 : 0 : break;
467 : 0 : default:
468 : 0 : type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_RSV |
469 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
470 : 0 : break;
471 : : }
472 : : }
473 : :
474 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM) {
475 : 0 : tx_offload_mask.outer_l2_len |= ~0;
476 : 0 : tx_offload_mask.outer_l3_len |= ~0;
477 : 0 : tx_offload_mask.l2_len |= ~0;
478 : 0 : seqnum_seed |= tx_offload.outer_l3_len
479 : 0 : << IXGBE_ADVTXD_OUTER_IPLEN;
480 : 0 : seqnum_seed |= tx_offload.l2_len
481 : 0 : << IXGBE_ADVTXD_TUNNEL_LEN;
482 : : }
483 : : #ifdef RTE_LIB_SECURITY
484 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
485 : : union ixgbe_crypto_tx_desc_md *md =
486 : : (union ixgbe_crypto_tx_desc_md *)mdata;
487 : 0 : seqnum_seed |=
488 : 0 : (IXGBE_ADVTXD_IPSEC_SA_INDEX_MASK & md->sa_idx);
489 : 0 : type_tucmd_mlhl |= md->enc ?
490 : : (IXGBE_ADVTXD_TUCMD_IPSEC_TYPE_ESP |
491 [ # # ]: 0 : IXGBE_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN) : 0;
492 : 0 : type_tucmd_mlhl |=
493 : 0 : (md->pad_len & IXGBE_ADVTXD_IPSEC_ESP_LEN_MASK);
494 : 0 : tx_offload_mask.sa_idx |= ~0;
495 : 0 : tx_offload_mask.sec_pad_len |= ~0;
496 : : }
497 : : #endif
498 : :
499 : 0 : txq->ctx_cache[ctx_idx].flags = ol_flags;
500 : 0 : txq->ctx_cache[ctx_idx].tx_offload.data[0] =
501 : 0 : tx_offload_mask.data[0] & tx_offload.data[0];
502 : 0 : txq->ctx_cache[ctx_idx].tx_offload.data[1] =
503 : 0 : tx_offload_mask.data[1] & tx_offload.data[1];
504 : 0 : txq->ctx_cache[ctx_idx].tx_offload_mask = tx_offload_mask;
505 : :
506 : 0 : ctx_txd->type_tucmd_mlhl = rte_cpu_to_le_32(type_tucmd_mlhl);
507 : 0 : vlan_macip_lens = tx_offload.l3_len;
508 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
509 : 0 : vlan_macip_lens |= (tx_offload.outer_l2_len <<
510 : : IXGBE_ADVTXD_MACLEN_SHIFT);
511 : : else
512 : 0 : vlan_macip_lens |= (tx_offload.l2_len <<
513 : : IXGBE_ADVTXD_MACLEN_SHIFT);
514 : 0 : vlan_macip_lens |= ((uint32_t)tx_offload.vlan_tci << IXGBE_ADVTXD_VLAN_SHIFT);
515 : 0 : ctx_txd->vlan_macip_lens = rte_cpu_to_le_32(vlan_macip_lens);
516 : 0 : ctx_txd->mss_l4len_idx = rte_cpu_to_le_32(mss_l4len_idx);
517 : 0 : ctx_txd->seqnum_seed = seqnum_seed;
518 : 0 : }
519 : :
520 : : /*
521 : : * Check which hardware context can be used. Use the existing match
522 : : * or create a new context descriptor.
523 : : */
524 : : static inline uint32_t
525 : 0 : what_advctx_update(struct ci_tx_queue *txq, uint64_t flags,
526 : : union ixgbe_tx_offload tx_offload)
527 : : {
528 : : /* If match with the current used context */
529 [ # # # # : 0 : if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
# # ]
530 : : (txq->ctx_cache[txq->ctx_curr].tx_offload.data[0] ==
531 : : (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[0]
532 : : & tx_offload.data[0])) &&
533 : : (txq->ctx_cache[txq->ctx_curr].tx_offload.data[1] ==
534 : : (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[1]
535 : : & tx_offload.data[1]))))
536 : : return txq->ctx_curr;
537 : :
538 : : /* What if match with the next context */
539 : 0 : txq->ctx_curr ^= 1;
540 [ # # # # : 0 : if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
# # ]
541 : : (txq->ctx_cache[txq->ctx_curr].tx_offload.data[0] ==
542 : : (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[0]
543 : : & tx_offload.data[0])) &&
544 : : (txq->ctx_cache[txq->ctx_curr].tx_offload.data[1] ==
545 : : (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[1]
546 : : & tx_offload.data[1]))))
547 : 0 : return txq->ctx_curr;
548 : :
549 : : /* Mismatch, use the previous context */
550 : : return IXGBE_CTX_NUM;
551 : : }
552 : :
553 : : static inline uint32_t
554 : : tx_desc_cksum_flags_to_olinfo(uint64_t ol_flags)
555 : : {
556 : : uint32_t tmp = 0;
557 : :
558 : 0 : if ((ol_flags & RTE_MBUF_F_TX_L4_MASK) != RTE_MBUF_F_TX_L4_NO_CKSUM)
559 : : tmp |= IXGBE_ADVTXD_POPTS_TXSM;
560 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
561 : 0 : tmp |= IXGBE_ADVTXD_POPTS_IXSM;
562 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
563 : 0 : tmp |= IXGBE_ADVTXD_POPTS_TXSM;
564 : : return tmp;
565 : : }
566 : :
567 : : static inline uint32_t
568 : : tx_desc_ol_flags_to_cmdtype(uint64_t ol_flags)
569 : : {
570 : : uint32_t cmdtype = 0;
571 : :
572 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_VLAN)
573 : : cmdtype |= IXGBE_ADVTXD_DCMD_VLE;
574 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
575 : 0 : cmdtype |= IXGBE_ADVTXD_DCMD_TSE;
576 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
577 : 0 : cmdtype |= (1 << IXGBE_ADVTXD_OUTERIPCS_SHIFT);
578 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_MACSEC)
579 : 0 : cmdtype |= IXGBE_ADVTXD_MAC_LINKSEC;
580 : : return cmdtype;
581 : : }
582 : :
583 : : /* Default RS bit threshold values */
584 : : #ifndef DEFAULT_TX_RS_THRESH
585 : : #define DEFAULT_TX_RS_THRESH 32
586 : : #endif
587 : : #ifndef DEFAULT_TX_FREE_THRESH
588 : : #define DEFAULT_TX_FREE_THRESH 32
589 : : #endif
590 : :
591 : : /* Reset transmit descriptors after they have been used */
592 : : static inline int
593 : 0 : ixgbe_xmit_cleanup(struct ci_tx_queue *txq)
594 : : {
595 : 0 : struct ci_tx_entry *sw_ring = txq->sw_ring;
596 : 0 : volatile union ixgbe_adv_tx_desc *txr = txq->ixgbe_tx_ring;
597 : 0 : uint16_t last_desc_cleaned = txq->last_desc_cleaned;
598 : 0 : uint16_t nb_tx_desc = txq->nb_tx_desc;
599 : : uint16_t desc_to_clean_to;
600 : : uint16_t nb_tx_to_clean;
601 : : uint32_t status;
602 : :
603 : : /* Determine the last descriptor needing to be cleaned */
604 : 0 : desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
605 [ # # ]: 0 : if (desc_to_clean_to >= nb_tx_desc)
606 : 0 : desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
607 : :
608 : : /* Check to make sure the last descriptor to clean is done */
609 : 0 : desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
610 : 0 : status = txr[desc_to_clean_to].wb.status;
611 [ # # ]: 0 : if (!(status & rte_cpu_to_le_32(IXGBE_TXD_STAT_DD))) {
612 : : PMD_TX_LOG(DEBUG,
613 : : "TX descriptor %4u is not done"
614 : : "(port=%d queue=%d)",
615 : : desc_to_clean_to,
616 : : txq->port_id, txq->queue_id);
617 : : /* Failed to clean any descriptors, better luck next time */
618 : : return -(1);
619 : : }
620 : :
621 : : /* Figure out how many descriptors will be cleaned */
622 [ # # ]: 0 : if (last_desc_cleaned > desc_to_clean_to)
623 : 0 : nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
624 : : desc_to_clean_to);
625 : : else
626 : 0 : nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
627 : : last_desc_cleaned);
628 : :
629 : : PMD_TX_LOG(DEBUG,
630 : : "Cleaning %4u TX descriptors: %4u to %4u "
631 : : "(port=%d queue=%d)",
632 : : nb_tx_to_clean, last_desc_cleaned, desc_to_clean_to,
633 : : txq->port_id, txq->queue_id);
634 : :
635 : : /*
636 : : * The last descriptor to clean is done, so that means all the
637 : : * descriptors from the last descriptor that was cleaned
638 : : * up to the last descriptor with the RS bit set
639 : : * are done. Only reset the threshold descriptor.
640 : : */
641 : 0 : txr[desc_to_clean_to].wb.status = 0;
642 : :
643 : : /* Update the txq to reflect the last descriptor that was cleaned */
644 : 0 : txq->last_desc_cleaned = desc_to_clean_to;
645 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
646 : :
647 : : /* No Error */
648 : 0 : return 0;
649 : : }
650 : :
651 : : uint16_t
652 : 0 : ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
653 : : uint16_t nb_pkts)
654 : : {
655 : : struct ci_tx_queue *txq;
656 : : struct ci_tx_entry *sw_ring;
657 : : struct ci_tx_entry *txe, *txn;
658 : : volatile union ixgbe_adv_tx_desc *txr;
659 : : volatile union ixgbe_adv_tx_desc *txd, *txp;
660 : : struct rte_mbuf *tx_pkt;
661 : : struct rte_mbuf *m_seg;
662 : : uint64_t buf_dma_addr;
663 : : uint32_t olinfo_status;
664 : : uint32_t cmd_type_len;
665 : : uint32_t pkt_len;
666 : : uint16_t slen;
667 : : uint64_t ol_flags;
668 : : uint16_t tx_id;
669 : : uint16_t tx_last;
670 : : uint16_t nb_tx;
671 : : uint16_t nb_used;
672 : : uint64_t tx_ol_req;
673 : : uint32_t ctx = 0;
674 : : uint32_t new_ctx;
675 : : union ixgbe_tx_offload tx_offload;
676 : : #ifdef RTE_LIB_SECURITY
677 : : uint8_t use_ipsec;
678 : : #endif
679 : :
680 : 0 : tx_offload.data[0] = 0;
681 : 0 : tx_offload.data[1] = 0;
682 : : txq = tx_queue;
683 : 0 : sw_ring = txq->sw_ring;
684 : 0 : txr = txq->ixgbe_tx_ring;
685 : 0 : tx_id = txq->tx_tail;
686 : 0 : txe = &sw_ring[tx_id];
687 : : txp = NULL;
688 : :
689 : : /* Determine if the descriptor ring needs to be cleaned. */
690 [ # # ]: 0 : if (txq->nb_tx_free < txq->tx_free_thresh)
691 : 0 : ixgbe_xmit_cleanup(txq);
692 : :
693 : 0 : rte_prefetch0(&txe->mbuf->pool);
694 : :
695 : : /* TX loop */
696 [ # # ]: 0 : for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
697 : : new_ctx = 0;
698 : 0 : tx_pkt = *tx_pkts++;
699 : 0 : pkt_len = tx_pkt->pkt_len;
700 : :
701 : : /*
702 : : * Determine how many (if any) context descriptors
703 : : * are needed for offload functionality.
704 : : */
705 : 0 : ol_flags = tx_pkt->ol_flags;
706 : : #ifdef RTE_LIB_SECURITY
707 [ # # # # ]: 0 : use_ipsec = txq->using_ipsec && (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
708 : : #endif
709 : :
710 : : /* If hardware offload required */
711 : 0 : tx_ol_req = ol_flags & IXGBE_TX_OFFLOAD_MASK;
712 [ # # ]: 0 : if (tx_ol_req) {
713 : 0 : tx_offload.l2_len = tx_pkt->l2_len;
714 : 0 : tx_offload.l3_len = tx_pkt->l3_len;
715 : 0 : tx_offload.l4_len = tx_pkt->l4_len;
716 : 0 : tx_offload.vlan_tci = tx_pkt->vlan_tci;
717 : 0 : tx_offload.tso_segsz = tx_pkt->tso_segsz;
718 : 0 : tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
719 : 0 : tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
720 : : #ifdef RTE_LIB_SECURITY
721 [ # # ]: 0 : if (use_ipsec) {
722 : : union ixgbe_crypto_tx_desc_md *ipsec_mdata =
723 : : (union ixgbe_crypto_tx_desc_md *)
724 : : rte_security_dynfield(tx_pkt);
725 : 0 : tx_offload.sa_idx = ipsec_mdata->sa_idx;
726 : 0 : tx_offload.sec_pad_len = ipsec_mdata->pad_len;
727 : : }
728 : : #endif
729 : :
730 : : /* If new context need be built or reuse the exist ctx. */
731 : 0 : ctx = what_advctx_update(txq, tx_ol_req,
732 : : tx_offload);
733 : : /* Only allocate context descriptor if required*/
734 : 0 : new_ctx = (ctx == IXGBE_CTX_NUM);
735 : 0 : ctx = txq->ctx_curr;
736 [ # # ]: 0 : } else if (txq->is_vf) {
737 : : /* create default context descriptor for VF */
738 : 0 : tx_offload.l2_len = RTE_ETHER_HDR_LEN;
739 : : /* If new context need be built or reuse the exist ctx. */
740 : 0 : ctx = what_advctx_update(txq, 0, tx_offload);
741 : : /* Only allocate context descriptor if required */
742 : 0 : new_ctx = (ctx == IXGBE_CTX_NUM);
743 : 0 : ctx = txq->ctx_curr;
744 : : }
745 : :
746 : : /*
747 : : * Keep track of how many descriptors are used this loop
748 : : * This will always be the number of segments + the number of
749 : : * Context descriptors required to transmit the packet
750 : : */
751 : 0 : nb_used = (uint16_t)(tx_pkt->nb_segs + new_ctx);
752 : :
753 [ # # ]: 0 : if (txp != NULL &&
754 [ # # ]: 0 : nb_used + txq->nb_tx_used >= txq->tx_rs_thresh)
755 : : /* set RS on the previous packet in the burst */
756 : 0 : txp->read.cmd_type_len |=
757 : : rte_cpu_to_le_32(IXGBE_TXD_CMD_RS);
758 : :
759 : : /*
760 : : * The number of descriptors that must be allocated for a
761 : : * packet is the number of segments of that packet, plus 1
762 : : * Context Descriptor for the hardware offload, if any.
763 : : * Determine the last TX descriptor to allocate in the TX ring
764 : : * for the packet, starting from the current position (tx_id)
765 : : * in the ring.
766 : : */
767 : 0 : tx_last = (uint16_t) (tx_id + nb_used - 1);
768 : :
769 : : /* Circular ring */
770 [ # # ]: 0 : if (tx_last >= txq->nb_tx_desc)
771 : 0 : tx_last = (uint16_t) (tx_last - txq->nb_tx_desc);
772 : :
773 : : PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u pktlen=%u"
774 : : " tx_first=%u tx_last=%u",
775 : : (unsigned) txq->port_id,
776 : : (unsigned) txq->queue_id,
777 : : (unsigned) pkt_len,
778 : : (unsigned) tx_id,
779 : : (unsigned) tx_last);
780 : :
781 : : /*
782 : : * Make sure there are enough TX descriptors available to
783 : : * transmit the entire packet.
784 : : * nb_used better be less than or equal to txq->tx_rs_thresh
785 : : */
786 [ # # ]: 0 : if (nb_used > txq->nb_tx_free) {
787 : : PMD_TX_LOG(DEBUG,
788 : : "Not enough free TX descriptors "
789 : : "nb_used=%4u nb_free=%4u "
790 : : "(port=%d queue=%d)",
791 : : nb_used, txq->nb_tx_free,
792 : : txq->port_id, txq->queue_id);
793 : :
794 [ # # ]: 0 : if (ixgbe_xmit_cleanup(txq) != 0) {
795 : : /* Could not clean any descriptors */
796 [ # # ]: 0 : if (nb_tx == 0)
797 : : return 0;
798 : 0 : goto end_of_tx;
799 : : }
800 : :
801 : : /* nb_used better be <= txq->tx_rs_thresh */
802 [ # # ]: 0 : if (unlikely(nb_used > txq->tx_rs_thresh)) {
803 : : PMD_TX_LOG(DEBUG,
804 : : "The number of descriptors needed to "
805 : : "transmit the packet exceeds the "
806 : : "RS bit threshold. This will impact "
807 : : "performance."
808 : : "nb_used=%4u nb_free=%4u "
809 : : "tx_rs_thresh=%4u. "
810 : : "(port=%d queue=%d)",
811 : : nb_used, txq->nb_tx_free,
812 : : txq->tx_rs_thresh,
813 : : txq->port_id, txq->queue_id);
814 : : /*
815 : : * Loop here until there are enough TX
816 : : * descriptors or until the ring cannot be
817 : : * cleaned.
818 : : */
819 [ # # ]: 0 : while (nb_used > txq->nb_tx_free) {
820 [ # # ]: 0 : if (ixgbe_xmit_cleanup(txq) != 0) {
821 : : /*
822 : : * Could not clean any
823 : : * descriptors
824 : : */
825 [ # # ]: 0 : if (nb_tx == 0)
826 : : return 0;
827 : 0 : goto end_of_tx;
828 : : }
829 : : }
830 : : }
831 : : }
832 : :
833 : : /*
834 : : * By now there are enough free TX descriptors to transmit
835 : : * the packet.
836 : : */
837 : :
838 : : /*
839 : : * Set common flags of all TX Data Descriptors.
840 : : *
841 : : * The following bits must be set in all Data Descriptors:
842 : : * - IXGBE_ADVTXD_DTYP_DATA
843 : : * - IXGBE_ADVTXD_DCMD_DEXT
844 : : *
845 : : * The following bits must be set in the first Data Descriptor
846 : : * and are ignored in the other ones:
847 : : * - IXGBE_ADVTXD_DCMD_IFCS
848 : : * - IXGBE_ADVTXD_MAC_1588
849 : : * - IXGBE_ADVTXD_DCMD_VLE
850 : : *
851 : : * The following bits must only be set in the last Data
852 : : * Descriptor:
853 : : * - IXGBE_TXD_CMD_EOP
854 : : *
855 : : * The following bits can be set in any Data Descriptor, but
856 : : * are only set in the last Data Descriptor:
857 : : * - IXGBE_TXD_CMD_RS
858 : : */
859 : : cmd_type_len = IXGBE_ADVTXD_DTYP_DATA |
860 : : IXGBE_ADVTXD_DCMD_IFCS | IXGBE_ADVTXD_DCMD_DEXT;
861 : :
862 : : #ifdef RTE_LIBRTE_IEEE1588
863 : : if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
864 : : cmd_type_len |= IXGBE_ADVTXD_MAC_1588;
865 : : #endif
866 : :
867 : : olinfo_status = 0;
868 [ # # ]: 0 : if (tx_ol_req || new_ctx) {
869 : :
870 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
871 : : /* when TSO is on, paylen in descriptor is the
872 : : * not the packet len but the tcp payload len */
873 : 0 : pkt_len -= (tx_offload.l2_len +
874 : 0 : tx_offload.l3_len + tx_offload.l4_len);
875 : : }
876 : :
877 : : /*
878 : : * Setup the TX Advanced Context Descriptor if required
879 : : */
880 [ # # ]: 0 : if (new_ctx) {
881 : : volatile struct ixgbe_adv_tx_context_desc *
882 : : ctx_txd;
883 : :
884 : 0 : ctx_txd = (volatile struct
885 : : ixgbe_adv_tx_context_desc *)
886 : 0 : &txr[tx_id];
887 : :
888 : 0 : txn = &sw_ring[txe->next_id];
889 : 0 : rte_prefetch0(&txn->mbuf->pool);
890 : :
891 [ # # ]: 0 : if (txe->mbuf != NULL) {
892 : : rte_pktmbuf_free_seg(txe->mbuf);
893 : 0 : txe->mbuf = NULL;
894 : : }
895 : :
896 : 0 : ixgbe_set_xmit_ctx(txq, ctx_txd, tx_ol_req,
897 : : tx_offload,
898 : : rte_security_dynfield(tx_pkt));
899 : :
900 : 0 : txe->last_id = tx_last;
901 : 0 : tx_id = txe->next_id;
902 : : txe = txn;
903 : : }
904 : :
905 : : /*
906 : : * Setup the TX Advanced Data Descriptor,
907 : : * This path will go through
908 : : * whatever new/reuse the context descriptor
909 : : */
910 [ # # ]: 0 : cmd_type_len |= tx_desc_ol_flags_to_cmdtype(ol_flags);
911 : : olinfo_status |= tx_desc_cksum_flags_to_olinfo(ol_flags);
912 : 0 : olinfo_status |= ctx << IXGBE_ADVTXD_IDX_SHIFT;
913 : : }
914 : : /* for VF, always set CC bit and set valid ctx */
915 [ # # ]: 0 : if (txq->is_vf) {
916 : 0 : olinfo_status |= IXGBE_ADVTXD_CC;
917 : 0 : olinfo_status |= ctx << IXGBE_ADVTXD_IDX_SHIFT;
918 : : }
919 : 0 : olinfo_status |= (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT);
920 : : #ifdef RTE_LIB_SECURITY
921 [ # # ]: 0 : if (use_ipsec)
922 : 0 : olinfo_status |= IXGBE_ADVTXD_POPTS_IPSEC;
923 : : #endif
924 : :
925 : : m_seg = tx_pkt;
926 : : do {
927 : 0 : txd = &txr[tx_id];
928 : 0 : txn = &sw_ring[txe->next_id];
929 : 0 : rte_prefetch0(&txn->mbuf->pool);
930 : :
931 [ # # ]: 0 : if (txe->mbuf != NULL)
932 : : rte_pktmbuf_free_seg(txe->mbuf);
933 : 0 : txe->mbuf = m_seg;
934 : :
935 : : /*
936 : : * Set up Transmit Data Descriptor.
937 : : */
938 [ # # ]: 0 : slen = m_seg->data_len;
939 : : buf_dma_addr = rte_mbuf_data_iova(m_seg);
940 : 0 : txd->read.buffer_addr =
941 : : rte_cpu_to_le_64(buf_dma_addr);
942 : 0 : txd->read.cmd_type_len =
943 : 0 : rte_cpu_to_le_32(cmd_type_len | slen);
944 : 0 : txd->read.olinfo_status =
945 : : rte_cpu_to_le_32(olinfo_status);
946 : 0 : txe->last_id = tx_last;
947 : 0 : tx_id = txe->next_id;
948 : : txe = txn;
949 : 0 : m_seg = m_seg->next;
950 [ # # ]: 0 : } while (m_seg != NULL);
951 : :
952 : : /*
953 : : * The last packet data descriptor needs End Of Packet (EOP)
954 : : */
955 : 0 : cmd_type_len |= IXGBE_TXD_CMD_EOP;
956 : 0 : txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
957 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
958 : :
959 : : /* Set RS bit only on threshold packets' last descriptor */
960 [ # # ]: 0 : if (txq->nb_tx_used >= txq->tx_rs_thresh) {
961 : : PMD_TX_LOG(DEBUG,
962 : : "Setting RS bit on TXD id="
963 : : "%4u (port=%d queue=%d)",
964 : : tx_last, txq->port_id, txq->queue_id);
965 : :
966 : 0 : cmd_type_len |= IXGBE_TXD_CMD_RS;
967 : :
968 : : /* Update txq RS bit counters */
969 : 0 : txq->nb_tx_used = 0;
970 : : txp = NULL;
971 : : } else
972 : : txp = txd;
973 : :
974 : 0 : txd->read.cmd_type_len |= rte_cpu_to_le_32(cmd_type_len);
975 : : }
976 : :
977 : 0 : end_of_tx:
978 : : /* set RS on last packet in the burst */
979 [ # # ]: 0 : if (txp != NULL)
980 : 0 : txp->read.cmd_type_len |= rte_cpu_to_le_32(IXGBE_TXD_CMD_RS);
981 : :
982 : : rte_wmb();
983 : :
984 : : /*
985 : : * Set the Transmit Descriptor Tail (TDT)
986 : : */
987 : : PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
988 : : (unsigned) txq->port_id, (unsigned) txq->queue_id,
989 : : (unsigned) tx_id, (unsigned) nb_tx);
990 [ # # ]: 0 : IXGBE_PCI_REG_WC_WRITE_RELAXED(txq->qtx_tail, tx_id);
991 : 0 : txq->tx_tail = tx_id;
992 : :
993 : 0 : return nb_tx;
994 : : }
995 : :
996 : : /*********************************************************************
997 : : *
998 : : * TX prep functions
999 : : *
1000 : : **********************************************************************/
1001 : : uint16_t
1002 : 0 : ixgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
1003 : : {
1004 : : int i, ret;
1005 : : uint64_t ol_flags;
1006 : : struct rte_mbuf *m;
1007 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
1008 : :
1009 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
1010 : 0 : m = tx_pkts[i];
1011 : 0 : ol_flags = m->ol_flags;
1012 : :
1013 : : /**
1014 : : * Check if packet meets requirements for number of segments
1015 : : *
1016 : : * NOTE: for ixgbe it's always (40 - WTHRESH) for both TSO and
1017 : : * non-TSO
1018 : : */
1019 : :
1020 [ # # ]: 0 : if (m->nb_segs > IXGBE_TX_MAX_SEG - txq->wthresh) {
1021 : 0 : rte_errno = EINVAL;
1022 : 0 : return i;
1023 : : }
1024 : :
1025 [ # # ]: 0 : if (ol_flags & IXGBE_TX_OFFLOAD_NOTSUP_MASK) {
1026 : 0 : rte_errno = ENOTSUP;
1027 : 0 : return i;
1028 : : }
1029 : :
1030 : : /* check the size of packet */
1031 [ # # ]: 0 : if (m->pkt_len < IXGBE_TX_MIN_PKT_LEN) {
1032 : 0 : rte_errno = EINVAL;
1033 : 0 : return i;
1034 : : }
1035 : :
1036 : : #ifdef RTE_ETHDEV_DEBUG_TX
1037 : : ret = rte_validate_tx_offload(m);
1038 : : if (ret != 0) {
1039 : : rte_errno = -ret;
1040 : : return i;
1041 : : }
1042 : : #endif
1043 : : ret = rte_net_intel_cksum_prepare(m);
1044 [ # # ]: 0 : if (ret != 0) {
1045 : 0 : rte_errno = -ret;
1046 : 0 : return i;
1047 : : }
1048 : : }
1049 : :
1050 : 0 : return i;
1051 : : }
1052 : :
1053 : : /*********************************************************************
1054 : : *
1055 : : * RX functions
1056 : : *
1057 : : **********************************************************************/
1058 : :
1059 : : #define IXGBE_PACKET_TYPE_ETHER 0X00
1060 : : #define IXGBE_PACKET_TYPE_IPV4 0X01
1061 : : #define IXGBE_PACKET_TYPE_IPV4_TCP 0X11
1062 : : #define IXGBE_PACKET_TYPE_IPV4_UDP 0X21
1063 : : #define IXGBE_PACKET_TYPE_IPV4_SCTP 0X41
1064 : : #define IXGBE_PACKET_TYPE_IPV4_EXT 0X03
1065 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_TCP 0X13
1066 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_UDP 0X23
1067 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_SCTP 0X43
1068 : : #define IXGBE_PACKET_TYPE_IPV6 0X04
1069 : : #define IXGBE_PACKET_TYPE_IPV6_TCP 0X14
1070 : : #define IXGBE_PACKET_TYPE_IPV6_UDP 0X24
1071 : : #define IXGBE_PACKET_TYPE_IPV6_SCTP 0X44
1072 : : #define IXGBE_PACKET_TYPE_IPV6_EXT 0X0C
1073 : : #define IXGBE_PACKET_TYPE_IPV6_EXT_TCP 0X1C
1074 : : #define IXGBE_PACKET_TYPE_IPV6_EXT_UDP 0X2C
1075 : : #define IXGBE_PACKET_TYPE_IPV6_EXT_SCTP 0X4C
1076 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6 0X05
1077 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_TCP 0X15
1078 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_UDP 0X25
1079 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_SCTP 0X45
1080 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6 0X07
1081 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_TCP 0X17
1082 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_UDP 0X27
1083 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_SCTP 0X47
1084 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT 0X0D
1085 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_TCP 0X1D
1086 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_UDP 0X2D
1087 : : #define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_SCTP 0X4D
1088 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT 0X0F
1089 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_TCP 0X1F
1090 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_UDP 0X2F
1091 : : #define IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_SCTP 0X4F
1092 : :
1093 : : #define IXGBE_PACKET_TYPE_NVGRE 0X00
1094 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4 0X01
1095 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_TCP 0X11
1096 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_UDP 0X21
1097 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_SCTP 0X41
1098 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT 0X03
1099 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_TCP 0X13
1100 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_UDP 0X23
1101 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_SCTP 0X43
1102 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6 0X04
1103 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_TCP 0X14
1104 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_UDP 0X24
1105 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_SCTP 0X44
1106 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT 0X0C
1107 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_TCP 0X1C
1108 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_UDP 0X2C
1109 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_SCTP 0X4C
1110 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6 0X05
1111 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_TCP 0X15
1112 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_UDP 0X25
1113 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT 0X0D
1114 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT_TCP 0X1D
1115 : : #define IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT_UDP 0X2D
1116 : :
1117 : : #define IXGBE_PACKET_TYPE_VXLAN 0X80
1118 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4 0X81
1119 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_TCP 0x91
1120 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_UDP 0xA1
1121 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_SCTP 0xC1
1122 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT 0x83
1123 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_TCP 0X93
1124 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_UDP 0XA3
1125 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_SCTP 0XC3
1126 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6 0X84
1127 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_TCP 0X94
1128 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_UDP 0XA4
1129 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_SCTP 0XC4
1130 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT 0X8C
1131 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_TCP 0X9C
1132 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_UDP 0XAC
1133 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_SCTP 0XCC
1134 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6 0X85
1135 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_TCP 0X95
1136 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_UDP 0XA5
1137 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT 0X8D
1138 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT_TCP 0X9D
1139 : : #define IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT_UDP 0XAD
1140 : :
1141 : : /**
1142 : : * Use 2 different table for normal packet and tunnel packet
1143 : : * to save the space.
1144 : : */
1145 : : const alignas(RTE_CACHE_LINE_SIZE) uint32_t
1146 : : ptype_table[IXGBE_PACKET_TYPE_MAX] = {
1147 : : [IXGBE_PACKET_TYPE_ETHER] = RTE_PTYPE_L2_ETHER,
1148 : : [IXGBE_PACKET_TYPE_IPV4] = RTE_PTYPE_L2_ETHER |
1149 : : RTE_PTYPE_L3_IPV4,
1150 : : [IXGBE_PACKET_TYPE_IPV4_TCP] = RTE_PTYPE_L2_ETHER |
1151 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
1152 : : [IXGBE_PACKET_TYPE_IPV4_UDP] = RTE_PTYPE_L2_ETHER |
1153 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
1154 : : [IXGBE_PACKET_TYPE_IPV4_SCTP] = RTE_PTYPE_L2_ETHER |
1155 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP,
1156 : : [IXGBE_PACKET_TYPE_IPV4_EXT] = RTE_PTYPE_L2_ETHER |
1157 : : RTE_PTYPE_L3_IPV4_EXT,
1158 : : [IXGBE_PACKET_TYPE_IPV4_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1159 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_TCP,
1160 : : [IXGBE_PACKET_TYPE_IPV4_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1161 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
1162 : : [IXGBE_PACKET_TYPE_IPV4_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1163 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_SCTP,
1164 : : [IXGBE_PACKET_TYPE_IPV6] = RTE_PTYPE_L2_ETHER |
1165 : : RTE_PTYPE_L3_IPV6,
1166 : : [IXGBE_PACKET_TYPE_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1167 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
1168 : : [IXGBE_PACKET_TYPE_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1169 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
1170 : : [IXGBE_PACKET_TYPE_IPV6_SCTP] = RTE_PTYPE_L2_ETHER |
1171 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_SCTP,
1172 : : [IXGBE_PACKET_TYPE_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1173 : : RTE_PTYPE_L3_IPV6_EXT,
1174 : : [IXGBE_PACKET_TYPE_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1175 : : RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_TCP,
1176 : : [IXGBE_PACKET_TYPE_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1177 : : RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_UDP,
1178 : : [IXGBE_PACKET_TYPE_IPV6_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1179 : : RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_SCTP,
1180 : : [IXGBE_PACKET_TYPE_IPV4_IPV6] = RTE_PTYPE_L2_ETHER |
1181 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1182 : : RTE_PTYPE_INNER_L3_IPV6,
1183 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1184 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1185 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
1186 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1187 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1188 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
1189 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_SCTP] = RTE_PTYPE_L2_ETHER |
1190 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1191 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_SCTP,
1192 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6] = RTE_PTYPE_L2_ETHER |
1193 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1194 : : RTE_PTYPE_INNER_L3_IPV6,
1195 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1196 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1197 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
1198 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1199 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1200 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
1201 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_SCTP] = RTE_PTYPE_L2_ETHER |
1202 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1203 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_SCTP,
1204 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1205 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1206 : : RTE_PTYPE_INNER_L3_IPV6_EXT,
1207 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1208 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1209 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
1210 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1211 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1212 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
1213 : : [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1214 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
1215 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_SCTP,
1216 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1217 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1218 : : RTE_PTYPE_INNER_L3_IPV6_EXT,
1219 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1220 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1221 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
1222 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1223 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1224 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
1225 : : [IXGBE_PACKET_TYPE_IPV4_EXT_IPV6_EXT_SCTP] =
1226 : : RTE_PTYPE_L2_ETHER |
1227 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_IP |
1228 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_SCTP,
1229 : : };
1230 : :
1231 : : const alignas(RTE_CACHE_LINE_SIZE) uint32_t
1232 : : ptype_table_tn[IXGBE_PACKET_TYPE_TN_MAX] = {
1233 : : [IXGBE_PACKET_TYPE_NVGRE] = RTE_PTYPE_L2_ETHER |
1234 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1235 : : RTE_PTYPE_INNER_L2_ETHER,
1236 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4] = RTE_PTYPE_L2_ETHER |
1237 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1238 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1239 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT] = RTE_PTYPE_L2_ETHER |
1240 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1241 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT,
1242 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6] = RTE_PTYPE_L2_ETHER |
1243 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1244 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6,
1245 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6] = RTE_PTYPE_L2_ETHER |
1246 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1247 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1248 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1249 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1250 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT,
1251 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1252 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1253 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1254 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_TCP] = RTE_PTYPE_L2_ETHER |
1255 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1256 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4 |
1257 : : RTE_PTYPE_INNER_L4_TCP,
1258 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1259 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1260 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6 |
1261 : : RTE_PTYPE_INNER_L4_TCP,
1262 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1263 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1264 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1265 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1266 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1267 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT |
1268 : : RTE_PTYPE_INNER_L4_TCP,
1269 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT_TCP] =
1270 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
1271 : : RTE_PTYPE_TUNNEL_GRE | RTE_PTYPE_INNER_L2_ETHER |
1272 : : RTE_PTYPE_INNER_L3_IPV4,
1273 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_UDP] = RTE_PTYPE_L2_ETHER |
1274 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1275 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4 |
1276 : : RTE_PTYPE_INNER_L4_UDP,
1277 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1278 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1279 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6 |
1280 : : RTE_PTYPE_INNER_L4_UDP,
1281 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_SCTP] = RTE_PTYPE_L2_ETHER |
1282 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1283 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6 |
1284 : : RTE_PTYPE_INNER_L4_SCTP,
1285 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1286 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1287 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1288 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1289 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1290 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT |
1291 : : RTE_PTYPE_INNER_L4_UDP,
1292 : : [IXGBE_PACKET_TYPE_NVGRE_IPV6_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1293 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1294 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT |
1295 : : RTE_PTYPE_INNER_L4_SCTP,
1296 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_IPV6_EXT_UDP] =
1297 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
1298 : : RTE_PTYPE_TUNNEL_GRE | RTE_PTYPE_INNER_L2_ETHER |
1299 : : RTE_PTYPE_INNER_L3_IPV4,
1300 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_SCTP] = RTE_PTYPE_L2_ETHER |
1301 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1302 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4 |
1303 : : RTE_PTYPE_INNER_L4_SCTP,
1304 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1305 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1306 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT |
1307 : : RTE_PTYPE_INNER_L4_SCTP,
1308 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1309 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1310 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT |
1311 : : RTE_PTYPE_INNER_L4_TCP,
1312 : : [IXGBE_PACKET_TYPE_NVGRE_IPV4_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1313 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_TUNNEL_GRE |
1314 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4_EXT |
1315 : : RTE_PTYPE_INNER_L4_UDP,
1316 : :
1317 : : [IXGBE_PACKET_TYPE_VXLAN] = RTE_PTYPE_L2_ETHER |
1318 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1319 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER,
1320 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4] = RTE_PTYPE_L2_ETHER |
1321 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1322 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1323 : : RTE_PTYPE_INNER_L3_IPV4,
1324 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT] = RTE_PTYPE_L2_ETHER |
1325 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1326 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1327 : : RTE_PTYPE_INNER_L3_IPV4_EXT,
1328 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6] = RTE_PTYPE_L2_ETHER |
1329 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1330 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1331 : : RTE_PTYPE_INNER_L3_IPV6,
1332 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6] = RTE_PTYPE_L2_ETHER |
1333 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1334 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1335 : : RTE_PTYPE_INNER_L3_IPV4,
1336 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1337 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1338 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1339 : : RTE_PTYPE_INNER_L3_IPV6_EXT,
1340 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
1341 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1342 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1343 : : RTE_PTYPE_INNER_L3_IPV4,
1344 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_TCP] = RTE_PTYPE_L2_ETHER |
1345 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1346 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1347 : : RTE_PTYPE_INNER_L3_IPV4 | RTE_PTYPE_INNER_L4_TCP,
1348 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1349 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1350 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1351 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
1352 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
1353 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1354 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1355 : : RTE_PTYPE_INNER_L3_IPV4,
1356 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1357 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1358 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1359 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
1360 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT_TCP] =
1361 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
1362 : : RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_VXLAN |
1363 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1364 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_UDP] = RTE_PTYPE_L2_ETHER |
1365 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1366 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1367 : : RTE_PTYPE_INNER_L3_IPV4 | RTE_PTYPE_INNER_L4_UDP,
1368 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1369 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1370 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1371 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
1372 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_SCTP] = RTE_PTYPE_L2_ETHER |
1373 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1374 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1375 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_SCTP,
1376 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
1377 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1378 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1379 : : RTE_PTYPE_INNER_L3_IPV4,
1380 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1381 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1382 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1383 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
1384 : : [IXGBE_PACKET_TYPE_VXLAN_IPV6_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1385 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1386 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1387 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_SCTP,
1388 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_IPV6_EXT_UDP] =
1389 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
1390 : : RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_VXLAN |
1391 : : RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV4,
1392 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_SCTP] = RTE_PTYPE_L2_ETHER |
1393 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1394 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1395 : : RTE_PTYPE_INNER_L3_IPV4 | RTE_PTYPE_INNER_L4_SCTP,
1396 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
1397 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1398 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1399 : : RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_SCTP,
1400 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_TCP] = RTE_PTYPE_L2_ETHER |
1401 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1402 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1403 : : RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_TCP,
1404 : : [IXGBE_PACKET_TYPE_VXLAN_IPV4_EXT_UDP] = RTE_PTYPE_L2_ETHER |
1405 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP |
1406 : : RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_INNER_L2_ETHER |
1407 : : RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_UDP,
1408 : : };
1409 : :
1410 : : static int
1411 : 0 : ixgbe_monitor_callback(const uint64_t value,
1412 : : const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
1413 : : {
1414 : : const uint64_t m = rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD);
1415 : : /*
1416 : : * we expect the DD bit to be set to 1 if this descriptor was already
1417 : : * written to.
1418 : : */
1419 [ # # ]: 0 : return (value & m) == m ? -1 : 0;
1420 : : }
1421 : :
1422 : : int
1423 : 0 : ixgbe_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
1424 : : {
1425 : : volatile union ixgbe_adv_rx_desc *rxdp;
1426 : : struct ixgbe_rx_queue *rxq = rx_queue;
1427 : : uint16_t desc;
1428 : :
1429 : 0 : desc = rxq->rx_tail;
1430 : 0 : rxdp = &rxq->rx_ring[desc];
1431 : : /* watch for changes in status bit */
1432 : 0 : pmc->addr = &rxdp->wb.upper.status_error;
1433 : :
1434 : : /* comparison callback */
1435 : 0 : pmc->fn = ixgbe_monitor_callback;
1436 : :
1437 : : /* the registers are 32-bit */
1438 : 0 : pmc->size = sizeof(uint32_t);
1439 : :
1440 : 0 : return 0;
1441 : : }
1442 : :
1443 : : /* @note: fix ixgbe_dev_supported_ptypes_get() if any change here. */
1444 : : static inline uint32_t
1445 : : ixgbe_rxd_pkt_info_to_pkt_type(uint32_t pkt_info, uint16_t ptype_mask)
1446 : : {
1447 : :
1448 : 0 : if (unlikely(pkt_info & IXGBE_RXDADV_PKTTYPE_ETQF))
1449 : : return RTE_PTYPE_UNKNOWN;
1450 : :
1451 : 0 : pkt_info = (pkt_info >> IXGBE_PACKET_TYPE_SHIFT) & ptype_mask;
1452 : :
1453 : : /* For tunnel packet */
1454 [ # # # # : 0 : if (pkt_info & IXGBE_PACKET_TYPE_TUNNEL_BIT) {
# # ]
1455 : : /* Remove the tunnel bit to save the space. */
1456 : 0 : pkt_info &= IXGBE_PACKET_TYPE_MASK_TUNNEL;
1457 : 0 : return ptype_table_tn[pkt_info];
1458 : : }
1459 : :
1460 : : /**
1461 : : * For x550, if it's not tunnel,
1462 : : * tunnel type bit should be set to 0.
1463 : : * Reuse 82599's mask.
1464 : : */
1465 : 0 : pkt_info &= IXGBE_PACKET_TYPE_MASK_82599;
1466 : :
1467 : 0 : return ptype_table[pkt_info];
1468 : : }
1469 : :
1470 : : static inline uint64_t
1471 : : ixgbe_rxd_pkt_info_to_pkt_flags(uint16_t pkt_info)
1472 : : {
1473 : : static alignas(RTE_CACHE_LINE_SIZE) uint64_t ip_rss_types_map[16] = {
1474 : : 0, RTE_MBUF_F_RX_RSS_HASH, RTE_MBUF_F_RX_RSS_HASH, RTE_MBUF_F_RX_RSS_HASH,
1475 : : 0, RTE_MBUF_F_RX_RSS_HASH, 0, RTE_MBUF_F_RX_RSS_HASH,
1476 : : RTE_MBUF_F_RX_RSS_HASH, 0, 0, 0,
1477 : : 0, 0, 0, RTE_MBUF_F_RX_FDIR,
1478 : : };
1479 : : #ifdef RTE_LIBRTE_IEEE1588
1480 : : static uint64_t ip_pkt_etqf_map[8] = {
1481 : : 0, 0, 0, RTE_MBUF_F_RX_IEEE1588_PTP,
1482 : : 0, 0, 0, 0,
1483 : : };
1484 : :
1485 : : if (likely(pkt_info & IXGBE_RXDADV_PKTTYPE_ETQF))
1486 : : return ip_pkt_etqf_map[(pkt_info >> 4) & 0X07] |
1487 : : ip_rss_types_map[pkt_info & 0XF];
1488 : : else
1489 : : return ip_rss_types_map[pkt_info & 0XF];
1490 : : #else
1491 : 0 : return ip_rss_types_map[pkt_info & 0XF];
1492 : : #endif
1493 : : }
1494 : :
1495 : : static inline uint64_t
1496 : : rx_desc_status_to_pkt_flags(uint32_t rx_status, uint64_t vlan_flags)
1497 : : {
1498 : : uint64_t pkt_flags;
1499 : :
1500 : : /*
1501 : : * Check if VLAN present only.
1502 : : * Do not check whether L3/L4 rx checksum done by NIC or not,
1503 : : * That can be found from rte_eth_rxmode.offloads flag
1504 : : */
1505 : 0 : pkt_flags = (rx_status & IXGBE_RXD_STAT_VP) ? vlan_flags : 0;
1506 : :
1507 : : #ifdef RTE_LIBRTE_IEEE1588
1508 : : if (rx_status & IXGBE_RXD_STAT_TMST)
1509 : : pkt_flags = pkt_flags | RTE_MBUF_F_RX_IEEE1588_TMST;
1510 : : #endif
1511 : : return pkt_flags;
1512 : : }
1513 : :
1514 : : static inline uint64_t
1515 : 0 : rx_desc_error_to_pkt_flags(uint32_t rx_status, uint16_t pkt_info,
1516 : : uint8_t rx_udp_csum_zero_err)
1517 : : {
1518 : : uint64_t pkt_flags;
1519 : :
1520 : : /*
1521 : : * Bit 31: IPE, IPv4 checksum error
1522 : : * Bit 30: L4I, L4I integrity error
1523 : : */
1524 : : static uint64_t error_to_pkt_flags_map[4] = {
1525 : : RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD,
1526 : : RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_BAD,
1527 : : RTE_MBUF_F_RX_IP_CKSUM_BAD | RTE_MBUF_F_RX_L4_CKSUM_GOOD,
1528 : : RTE_MBUF_F_RX_IP_CKSUM_BAD | RTE_MBUF_F_RX_L4_CKSUM_BAD
1529 : : };
1530 : 0 : pkt_flags = error_to_pkt_flags_map[(rx_status >>
1531 : 0 : IXGBE_RXDADV_ERR_CKSUM_BIT) & IXGBE_RXDADV_ERR_CKSUM_MSK];
1532 : :
1533 : : /* Mask out the bad UDP checksum error if the hardware has UDP zero
1534 : : * checksum error issue, so that the software application will then
1535 : : * have to recompute the checksum itself if needed.
1536 : : */
1537 [ # # # # ]: 0 : if ((rx_status & IXGBE_RXDADV_ERR_TCPE) &&
1538 [ # # ]: 0 : (pkt_info & IXGBE_RXDADV_PKTTYPE_UDP) &&
1539 : : rx_udp_csum_zero_err)
1540 : 0 : pkt_flags &= ~RTE_MBUF_F_RX_L4_CKSUM_BAD;
1541 : :
1542 [ # # ]: 0 : if ((rx_status & IXGBE_RXD_STAT_OUTERIPCS) &&
1543 : : (rx_status & IXGBE_RXDADV_ERR_OUTERIPER)) {
1544 : 0 : pkt_flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
1545 : : }
1546 : :
1547 : : #ifdef RTE_LIB_SECURITY
1548 [ # # ]: 0 : if (rx_status & IXGBE_RXD_STAT_SECP) {
1549 : 0 : pkt_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD;
1550 [ # # ]: 0 : if (rx_status & IXGBE_RXDADV_LNKSEC_ERROR_BAD_SIG)
1551 : 0 : pkt_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1552 : : }
1553 : : #endif
1554 : :
1555 : 0 : return pkt_flags;
1556 : : }
1557 : :
1558 : : /*
1559 : : * LOOK_AHEAD defines how many desc statuses to check beyond the
1560 : : * current descriptor.
1561 : : * It must be a pound define for optimal performance.
1562 : : * Do not change the value of LOOK_AHEAD, as the ixgbe_rx_scan_hw_ring
1563 : : * function only works with LOOK_AHEAD=8.
1564 : : */
1565 : : #define LOOK_AHEAD 8
1566 : : #if (LOOK_AHEAD != 8)
1567 : : #error "PMD IXGBE: LOOK_AHEAD must be 8\n"
1568 : : #endif
1569 : : static inline int
1570 : 0 : ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq)
1571 : : {
1572 : : volatile union ixgbe_adv_rx_desc *rxdp;
1573 : : struct ixgbe_rx_entry *rxep;
1574 : : struct rte_mbuf *mb;
1575 : : uint16_t pkt_len;
1576 : : uint64_t pkt_flags;
1577 : : int nb_dd;
1578 : : uint32_t s[LOOK_AHEAD];
1579 : : uint32_t pkt_info[LOOK_AHEAD];
1580 : : int i, j, nb_rx = 0;
1581 : : uint32_t status;
1582 : 0 : uint64_t vlan_flags = rxq->vlan_flags;
1583 : :
1584 : : /* get references to current descriptor and S/W ring entry */
1585 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
1586 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
1587 : :
1588 : 0 : status = rxdp->wb.upper.status_error;
1589 : : /* check to make sure there is at least 1 packet to receive */
1590 [ # # ]: 0 : if (!(status & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD)))
1591 : : return 0;
1592 : :
1593 : : /*
1594 : : * Scan LOOK_AHEAD descriptors at a time to determine which descriptors
1595 : : * reference packets that are ready to be received.
1596 : : */
1597 [ # # ]: 0 : for (i = 0; i < RTE_PMD_IXGBE_RX_MAX_BURST;
1598 : 0 : i += LOOK_AHEAD, rxdp += LOOK_AHEAD, rxep += LOOK_AHEAD) {
1599 : : /* Read desc statuses backwards to avoid race condition */
1600 [ # # ]: 0 : for (j = 0; j < LOOK_AHEAD; j++)
1601 : 0 : s[j] = rte_le_to_cpu_32(rxdp[j].wb.upper.status_error);
1602 : :
1603 : 0 : rte_smp_rmb();
1604 : :
1605 : : /* Compute how many status bits were set */
1606 [ # # ]: 0 : for (nb_dd = 0; nb_dd < LOOK_AHEAD &&
1607 [ # # ]: 0 : (s[nb_dd] & IXGBE_RXDADV_STAT_DD); nb_dd++)
1608 : : ;
1609 : :
1610 [ # # ]: 0 : for (j = 0; j < nb_dd; j++)
1611 : 0 : pkt_info[j] = rte_le_to_cpu_32(rxdp[j].wb.lower.
1612 : : lo_dword.data);
1613 : :
1614 : 0 : nb_rx += nb_dd;
1615 : :
1616 : : /* Translate descriptor info to mbuf format */
1617 [ # # ]: 0 : for (j = 0; j < nb_dd; ++j) {
1618 : 0 : mb = rxep[j].mbuf;
1619 : 0 : pkt_len = rte_le_to_cpu_16(rxdp[j].wb.upper.length) -
1620 : 0 : rxq->crc_len;
1621 : 0 : mb->data_len = pkt_len;
1622 : 0 : mb->pkt_len = pkt_len;
1623 : 0 : mb->vlan_tci = rte_le_to_cpu_16(rxdp[j].wb.upper.vlan);
1624 : :
1625 : : /* convert descriptor fields to rte mbuf flags */
1626 [ # # ]: 0 : pkt_flags = rx_desc_status_to_pkt_flags(s[j],
1627 : : vlan_flags);
1628 : 0 : pkt_flags |= rx_desc_error_to_pkt_flags(s[j],
1629 : 0 : (uint16_t)pkt_info[j],
1630 : 0 : rxq->rx_udp_csum_zero_err);
1631 : 0 : pkt_flags |= ixgbe_rxd_pkt_info_to_pkt_flags
1632 : : ((uint16_t)pkt_info[j]);
1633 : 0 : mb->ol_flags = pkt_flags;
1634 : 0 : mb->packet_type =
1635 : : ixgbe_rxd_pkt_info_to_pkt_type
1636 [ # # ]: 0 : (pkt_info[j], rxq->pkt_type_mask);
1637 : :
1638 [ # # ]: 0 : if (likely(pkt_flags & RTE_MBUF_F_RX_RSS_HASH))
1639 : 0 : mb->hash.rss = rte_le_to_cpu_32(
1640 : : rxdp[j].wb.lower.hi_dword.rss);
1641 [ # # ]: 0 : else if (pkt_flags & RTE_MBUF_F_RX_FDIR) {
1642 : 0 : mb->hash.fdir.hash = rte_le_to_cpu_16(
1643 : 0 : rxdp[j].wb.lower.hi_dword.csum_ip.csum) &
1644 : : IXGBE_ATR_HASH_MASK;
1645 : 0 : mb->hash.fdir.id = rte_le_to_cpu_16(
1646 : : rxdp[j].wb.lower.hi_dword.csum_ip.ip_id);
1647 : : }
1648 : : }
1649 : :
1650 : : /* Move mbuf pointers from the S/W ring to the stage */
1651 [ # # ]: 0 : for (j = 0; j < LOOK_AHEAD; ++j) {
1652 : 0 : rxq->rx_stage[i + j] = rxep[j].mbuf;
1653 : : }
1654 : :
1655 : : /* stop if all requested packets could not be received */
1656 [ # # ]: 0 : if (nb_dd != LOOK_AHEAD)
1657 : : break;
1658 : : }
1659 : :
1660 : : /* clear software ring entries so we can cleanup correctly */
1661 [ # # ]: 0 : for (i = 0; i < nb_rx; ++i) {
1662 : 0 : rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
1663 : : }
1664 : :
1665 : :
1666 : : return nb_rx;
1667 : : }
1668 : :
1669 : : static inline int
1670 : 0 : ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)
1671 : : {
1672 : : volatile union ixgbe_adv_rx_desc *rxdp;
1673 : : struct ixgbe_rx_entry *rxep;
1674 : : struct rte_mbuf *mb;
1675 : : uint16_t alloc_idx;
1676 : : __le64 dma_addr;
1677 : : int diag, i;
1678 : :
1679 : : /* allocate buffers in bulk directly into the S/W ring */
1680 : 0 : alloc_idx = rxq->rx_free_trigger - (rxq->rx_free_thresh - 1);
1681 : 0 : rxep = &rxq->sw_ring[alloc_idx];
1682 [ # # ]: 0 : diag = rte_mempool_get_bulk(rxq->mb_pool, (void *)rxep,
1683 : : rxq->rx_free_thresh);
1684 [ # # ]: 0 : if (unlikely(diag != 0))
1685 : : return -ENOMEM;
1686 : :
1687 : 0 : rxdp = &rxq->rx_ring[alloc_idx];
1688 [ # # ]: 0 : for (i = 0; i < rxq->rx_free_thresh; ++i) {
1689 : : /* populate the static rte mbuf fields */
1690 : 0 : mb = rxep[i].mbuf;
1691 [ # # ]: 0 : if (reset_mbuf) {
1692 : 0 : mb->port = rxq->port_id;
1693 : : }
1694 : :
1695 : : rte_mbuf_refcnt_set(mb, 1);
1696 : 0 : mb->data_off = RTE_PKTMBUF_HEADROOM;
1697 : :
1698 : : /* populate the descriptors */
1699 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
1700 : 0 : rxdp[i].read.hdr_addr = 0;
1701 : 0 : rxdp[i].read.pkt_addr = dma_addr;
1702 : : }
1703 : :
1704 : : /* update state of internal queue structure */
1705 : 0 : rxq->rx_free_trigger = rxq->rx_free_trigger + rxq->rx_free_thresh;
1706 [ # # ]: 0 : if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
1707 : 0 : rxq->rx_free_trigger = rxq->rx_free_thresh - 1;
1708 : :
1709 : : /* no errors */
1710 : : return 0;
1711 : : }
1712 : :
1713 : : static inline uint16_t
1714 : : ixgbe_rx_fill_from_stage(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_pkts,
1715 : : uint16_t nb_pkts)
1716 : : {
1717 : 0 : struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
1718 : : int i;
1719 : :
1720 : : /* how many packets are ready to return? */
1721 : 0 : nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
1722 : :
1723 : : /* copy mbuf pointers to the application's packet list */
1724 [ # # # # ]: 0 : for (i = 0; i < nb_pkts; ++i)
1725 : 0 : rx_pkts[i] = stage[i];
1726 : :
1727 : : /* update internal queue state */
1728 : 0 : rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
1729 : 0 : rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
1730 : :
1731 : : return nb_pkts;
1732 : : }
1733 : :
1734 : : static inline uint16_t
1735 : 0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
1736 : : uint16_t nb_pkts)
1737 : : {
1738 : : struct ixgbe_rx_queue *rxq = (struct ixgbe_rx_queue *)rx_queue;
1739 : : uint16_t nb_rx = 0;
1740 : :
1741 : : /* Any previously recv'd pkts will be returned from the Rx stage */
1742 [ # # ]: 0 : if (rxq->rx_nb_avail)
1743 : 0 : return ixgbe_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1744 : :
1745 : : /* Scan the H/W ring for packets to receive */
1746 : 0 : nb_rx = (uint16_t)ixgbe_rx_scan_hw_ring(rxq);
1747 : :
1748 : : /* update internal queue state */
1749 : 0 : rxq->rx_next_avail = 0;
1750 : 0 : rxq->rx_nb_avail = nb_rx;
1751 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
1752 : :
1753 : : /* if required, allocate new buffers to replenish descriptors */
1754 [ # # ]: 0 : if (rxq->rx_tail > rxq->rx_free_trigger) {
1755 : : uint16_t cur_free_trigger = rxq->rx_free_trigger;
1756 : :
1757 [ # # ]: 0 : if (ixgbe_rx_alloc_bufs(rxq, true) != 0) {
1758 : : int i, j;
1759 : :
1760 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1761 : : "queue_id=%u", (unsigned) rxq->port_id,
1762 : : (unsigned) rxq->queue_id);
1763 : :
1764 : 0 : rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
1765 : 0 : rxq->rx_free_thresh;
1766 : :
1767 : : /*
1768 : : * Need to rewind any previous receives if we cannot
1769 : : * allocate new buffers to replenish the old ones.
1770 : : */
1771 : 0 : rxq->rx_nb_avail = 0;
1772 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
1773 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail; i < nb_rx; ++i, ++j)
1774 : 0 : rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
1775 : :
1776 : : return 0;
1777 : : }
1778 : :
1779 : : /* update tail pointer */
1780 : : rte_wmb();
1781 [ # # ]: 0 : IXGBE_PCI_REG_WC_WRITE_RELAXED(rxq->rdt_reg_addr,
1782 : : cur_free_trigger);
1783 : : }
1784 : :
1785 [ # # ]: 0 : if (rxq->rx_tail >= rxq->nb_rx_desc)
1786 : 0 : rxq->rx_tail = 0;
1787 : :
1788 : : /* received any packets this loop? */
1789 [ # # ]: 0 : if (rxq->rx_nb_avail)
1790 : 0 : return ixgbe_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1791 : :
1792 : : return 0;
1793 : : }
1794 : :
1795 : : /* split requests into chunks of size RTE_PMD_IXGBE_RX_MAX_BURST */
1796 : : uint16_t
1797 : 0 : ixgbe_recv_pkts_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
1798 : : uint16_t nb_pkts)
1799 : : {
1800 : : uint16_t nb_rx;
1801 : :
1802 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
1803 : : return 0;
1804 : :
1805 [ # # ]: 0 : if (likely(nb_pkts <= RTE_PMD_IXGBE_RX_MAX_BURST))
1806 : 0 : return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
1807 : :
1808 : : /* request is relatively large, chunk it up */
1809 : : nb_rx = 0;
1810 [ # # ]: 0 : while (nb_pkts) {
1811 : : uint16_t ret, n;
1812 : :
1813 : 0 : n = (uint16_t)RTE_MIN(nb_pkts, RTE_PMD_IXGBE_RX_MAX_BURST);
1814 : 0 : ret = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
1815 : 0 : nb_rx = (uint16_t)(nb_rx + ret);
1816 : 0 : nb_pkts = (uint16_t)(nb_pkts - ret);
1817 [ # # ]: 0 : if (ret < n)
1818 : : break;
1819 : : }
1820 : :
1821 : : return nb_rx;
1822 : : }
1823 : :
1824 : : uint16_t
1825 : 0 : ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
1826 : : uint16_t nb_pkts)
1827 : : {
1828 : : struct ixgbe_rx_queue *rxq;
1829 : : volatile union ixgbe_adv_rx_desc *rx_ring;
1830 : : volatile union ixgbe_adv_rx_desc *rxdp;
1831 : : struct ixgbe_rx_entry *sw_ring;
1832 : : struct ixgbe_rx_entry *rxe;
1833 : : struct rte_mbuf *rxm;
1834 : : struct rte_mbuf *nmb;
1835 : : union ixgbe_adv_rx_desc rxd;
1836 : : uint64_t dma_addr;
1837 : : uint32_t staterr;
1838 : : uint32_t pkt_info;
1839 : : uint16_t pkt_len;
1840 : : uint16_t rx_id;
1841 : : uint16_t nb_rx;
1842 : : uint16_t nb_hold;
1843 : : uint64_t pkt_flags;
1844 : : uint64_t vlan_flags;
1845 : :
1846 : : nb_rx = 0;
1847 : : nb_hold = 0;
1848 : : rxq = rx_queue;
1849 : 0 : rx_id = rxq->rx_tail;
1850 : 0 : rx_ring = rxq->rx_ring;
1851 : 0 : sw_ring = rxq->sw_ring;
1852 : 0 : vlan_flags = rxq->vlan_flags;
1853 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1854 : : /*
1855 : : * The order of operations here is important as the DD status
1856 : : * bit must not be read after any other descriptor fields.
1857 : : * rx_ring and rxdp are pointing to volatile data so the order
1858 : : * of accesses cannot be reordered by the compiler. If they were
1859 : : * not volatile, they could be reordered which could lead to
1860 : : * using invalid descriptor fields when read from rxd.
1861 : : *
1862 : : * Meanwhile, to prevent the CPU from executing out of order, we
1863 : : * need to use a proper memory barrier to ensure the memory
1864 : : * ordering below.
1865 : : */
1866 : 0 : rxdp = &rx_ring[rx_id];
1867 : 0 : staterr = rxdp->wb.upper.status_error;
1868 [ # # ]: 0 : if (!(staterr & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD)))
1869 : : break;
1870 : :
1871 : : /*
1872 : : * Use acquire fence to ensure that status_error which includes
1873 : : * DD bit is loaded before loading of other descriptor words.
1874 : : */
1875 : : rte_atomic_thread_fence(rte_memory_order_acquire);
1876 : :
1877 : 0 : rxd = *rxdp;
1878 : :
1879 : : /*
1880 : : * End of packet.
1881 : : *
1882 : : * If the IXGBE_RXDADV_STAT_EOP flag is not set, the RX packet
1883 : : * is likely to be invalid and to be dropped by the various
1884 : : * validation checks performed by the network stack.
1885 : : *
1886 : : * Allocate a new mbuf to replenish the RX ring descriptor.
1887 : : * If the allocation fails:
1888 : : * - arrange for that RX descriptor to be the first one
1889 : : * being parsed the next time the receive function is
1890 : : * invoked [on the same queue].
1891 : : *
1892 : : * - Stop parsing the RX ring and return immediately.
1893 : : *
1894 : : * This policy do not drop the packet received in the RX
1895 : : * descriptor for which the allocation of a new mbuf failed.
1896 : : * Thus, it allows that packet to be later retrieved if
1897 : : * mbuf have been freed in the mean time.
1898 : : * As a side effect, holding RX descriptors instead of
1899 : : * systematically giving them back to the NIC may lead to
1900 : : * RX ring exhaustion situations.
1901 : : * However, the NIC can gracefully prevent such situations
1902 : : * to happen by sending specific "back-pressure" flow control
1903 : : * frames to its peer(s).
1904 : : */
1905 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_id=%u "
1906 : : "ext_err_stat=0x%08x pkt_len=%u",
1907 : : (unsigned) rxq->port_id, (unsigned) rxq->queue_id,
1908 : : (unsigned) rx_id, (unsigned) staterr,
1909 : : (unsigned) rte_le_to_cpu_16(rxd.wb.upper.length));
1910 : :
1911 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mb_pool);
1912 [ # # ]: 0 : if (nmb == NULL) {
1913 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1914 : : "queue_id=%u", (unsigned) rxq->port_id,
1915 : : (unsigned) rxq->queue_id);
1916 : 0 : rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
1917 : 0 : break;
1918 : : }
1919 : :
1920 : 0 : nb_hold++;
1921 : 0 : rxe = &sw_ring[rx_id];
1922 : 0 : rx_id++;
1923 [ # # ]: 0 : if (rx_id == rxq->nb_rx_desc)
1924 : : rx_id = 0;
1925 : :
1926 : : /* Prefetch next mbuf while processing current one. */
1927 : 0 : rte_ixgbe_prefetch(sw_ring[rx_id].mbuf);
1928 : :
1929 : : /*
1930 : : * When next RX descriptor is on a cache-line boundary,
1931 : : * prefetch the next 4 RX descriptors and the next 8 pointers
1932 : : * to mbufs.
1933 : : */
1934 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1935 : 0 : rte_ixgbe_prefetch(&rx_ring[rx_id]);
1936 : : rte_ixgbe_prefetch(&sw_ring[rx_id]);
1937 : : }
1938 : :
1939 : 0 : rxm = rxe->mbuf;
1940 : 0 : rxe->mbuf = nmb;
1941 : : dma_addr =
1942 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1943 : 0 : rxdp->read.hdr_addr = 0;
1944 : 0 : rxdp->read.pkt_addr = dma_addr;
1945 : :
1946 : : /*
1947 : : * Initialize the returned mbuf.
1948 : : * 1) setup generic mbuf fields:
1949 : : * - number of segments,
1950 : : * - next segment,
1951 : : * - packet length,
1952 : : * - RX port identifier.
1953 : : * 2) integrate hardware offload data, if any:
1954 : : * - RSS flag & hash,
1955 : : * - IP checksum flag,
1956 : : * - VLAN TCI, if any,
1957 : : * - error flags.
1958 : : */
1959 : 0 : pkt_len = (uint16_t) (rte_le_to_cpu_16(rxd.wb.upper.length) -
1960 : 0 : rxq->crc_len);
1961 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1962 : 0 : rte_packet_prefetch((char *)rxm->buf_addr + rxm->data_off);
1963 : 0 : rxm->nb_segs = 1;
1964 : 0 : rxm->next = NULL;
1965 : 0 : rxm->pkt_len = pkt_len;
1966 : 0 : rxm->data_len = pkt_len;
1967 : 0 : rxm->port = rxq->port_id;
1968 : :
1969 : : pkt_info = rte_le_to_cpu_32(rxd.wb.lower.lo_dword.data);
1970 : : /* Only valid if RTE_MBUF_F_RX_VLAN set in pkt_flags */
1971 [ # # ]: 0 : rxm->vlan_tci = rte_le_to_cpu_16(rxd.wb.upper.vlan);
1972 : :
1973 : : pkt_flags = rx_desc_status_to_pkt_flags(staterr, vlan_flags);
1974 : 0 : pkt_flags = pkt_flags |
1975 : 0 : rx_desc_error_to_pkt_flags(staterr, (uint16_t)pkt_info,
1976 : 0 : rxq->rx_udp_csum_zero_err);
1977 : 0 : pkt_flags = pkt_flags |
1978 : : ixgbe_rxd_pkt_info_to_pkt_flags((uint16_t)pkt_info);
1979 : 0 : rxm->ol_flags = pkt_flags;
1980 : 0 : rxm->packet_type =
1981 : : ixgbe_rxd_pkt_info_to_pkt_type(pkt_info,
1982 [ # # ]: 0 : rxq->pkt_type_mask);
1983 : :
1984 [ # # ]: 0 : if (likely(pkt_flags & RTE_MBUF_F_RX_RSS_HASH))
1985 : 0 : rxm->hash.rss = rte_le_to_cpu_32(
1986 : : rxd.wb.lower.hi_dword.rss);
1987 [ # # ]: 0 : else if (pkt_flags & RTE_MBUF_F_RX_FDIR) {
1988 : 0 : rxm->hash.fdir.hash = rte_le_to_cpu_16(
1989 : 0 : rxd.wb.lower.hi_dword.csum_ip.csum) &
1990 : : IXGBE_ATR_HASH_MASK;
1991 : 0 : rxm->hash.fdir.id = rte_le_to_cpu_16(
1992 : : rxd.wb.lower.hi_dword.csum_ip.ip_id);
1993 : : }
1994 : : /*
1995 : : * Store the mbuf address into the next entry of the array
1996 : : * of returned packets.
1997 : : */
1998 : 0 : rx_pkts[nb_rx++] = rxm;
1999 : : }
2000 : 0 : rxq->rx_tail = rx_id;
2001 : :
2002 : : /*
2003 : : * If the number of free RX descriptors is greater than the RX free
2004 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
2005 : : * register.
2006 : : * Update the RDT with the value of the last processed RX descriptor
2007 : : * minus 1, to guarantee that the RDT register is never equal to the
2008 : : * RDH register, which creates a "full" ring situation from the
2009 : : * hardware point of view...
2010 : : */
2011 : 0 : nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold);
2012 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
2013 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u "
2014 : : "nb_hold=%u nb_rx=%u",
2015 : : (unsigned) rxq->port_id, (unsigned) rxq->queue_id,
2016 : : (unsigned) rx_id, (unsigned) nb_hold,
2017 : : (unsigned) nb_rx);
2018 [ # # ]: 0 : rx_id = (uint16_t) ((rx_id == 0) ?
2019 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
2020 : 0 : IXGBE_PCI_REG_WC_WRITE(rxq->rdt_reg_addr, rx_id);
2021 : : nb_hold = 0;
2022 : : }
2023 : 0 : rxq->nb_rx_hold = nb_hold;
2024 : 0 : return nb_rx;
2025 : : }
2026 : :
2027 : : /**
2028 : : * Detect an RSC descriptor.
2029 : : */
2030 : : static inline uint32_t
2031 : : ixgbe_rsc_count(union ixgbe_adv_rx_desc *rx)
2032 : : {
2033 : 0 : return (rte_le_to_cpu_32(rx->wb.lower.lo_dword.data) &
2034 : 0 : IXGBE_RXDADV_RSCCNT_MASK) >> IXGBE_RXDADV_RSCCNT_SHIFT;
2035 : : }
2036 : :
2037 : : /**
2038 : : * ixgbe_fill_cluster_head_buf - fill the first mbuf of the returned packet
2039 : : *
2040 : : * Fill the following info in the HEAD buffer of the Rx cluster:
2041 : : * - RX port identifier
2042 : : * - hardware offload data, if any:
2043 : : * - RSS flag & hash
2044 : : * - IP checksum flag
2045 : : * - VLAN TCI, if any
2046 : : * - error flags
2047 : : * @head HEAD of the packet cluster
2048 : : * @desc HW descriptor to get data from
2049 : : * @rxq Pointer to the Rx queue
2050 : : */
2051 : : static inline void
2052 : 0 : ixgbe_fill_cluster_head_buf(
2053 : : struct rte_mbuf *head,
2054 : : union ixgbe_adv_rx_desc *desc,
2055 : : struct ixgbe_rx_queue *rxq,
2056 : : uint32_t staterr)
2057 : : {
2058 : : uint32_t pkt_info;
2059 : : uint64_t pkt_flags;
2060 : :
2061 : 0 : head->port = rxq->port_id;
2062 : :
2063 : : /* The vlan_tci field is only valid when RTE_MBUF_F_RX_VLAN is
2064 : : * set in the pkt_flags field.
2065 : : */
2066 : 0 : head->vlan_tci = rte_le_to_cpu_16(desc->wb.upper.vlan);
2067 : 0 : pkt_info = rte_le_to_cpu_32(desc->wb.lower.lo_dword.data);
2068 [ # # ]: 0 : pkt_flags = rx_desc_status_to_pkt_flags(staterr, rxq->vlan_flags);
2069 : 0 : pkt_flags |= rx_desc_error_to_pkt_flags(staterr, (uint16_t)pkt_info,
2070 : 0 : rxq->rx_udp_csum_zero_err);
2071 : 0 : pkt_flags |= ixgbe_rxd_pkt_info_to_pkt_flags((uint16_t)pkt_info);
2072 : 0 : head->ol_flags = pkt_flags;
2073 : 0 : head->packet_type =
2074 [ # # ]: 0 : ixgbe_rxd_pkt_info_to_pkt_type(pkt_info, rxq->pkt_type_mask);
2075 : :
2076 [ # # ]: 0 : if (likely(pkt_flags & RTE_MBUF_F_RX_RSS_HASH))
2077 : 0 : head->hash.rss = rte_le_to_cpu_32(desc->wb.lower.hi_dword.rss);
2078 [ # # ]: 0 : else if (pkt_flags & RTE_MBUF_F_RX_FDIR) {
2079 : 0 : head->hash.fdir.hash =
2080 : 0 : rte_le_to_cpu_16(desc->wb.lower.hi_dword.csum_ip.csum)
2081 : 0 : & IXGBE_ATR_HASH_MASK;
2082 : 0 : head->hash.fdir.id =
2083 : 0 : rte_le_to_cpu_16(desc->wb.lower.hi_dword.csum_ip.ip_id);
2084 : : }
2085 : 0 : }
2086 : :
2087 : : /**
2088 : : * ixgbe_recv_pkts_lro - receive handler for and LRO case.
2089 : : *
2090 : : * @rx_queue Rx queue handle
2091 : : * @rx_pkts table of received packets
2092 : : * @nb_pkts size of rx_pkts table
2093 : : * @bulk_alloc if TRUE bulk allocation is used for a HW ring refilling
2094 : : *
2095 : : * Handles the Rx HW ring completions when RSC feature is configured. Uses an
2096 : : * additional ring of ixgbe_rsc_entry's that will hold the relevant RSC info.
2097 : : *
2098 : : * We use the same logic as in Linux and in FreeBSD ixgbe drivers:
2099 : : * 1) When non-EOP RSC completion arrives:
2100 : : * a) Update the HEAD of the current RSC aggregation cluster with the new
2101 : : * segment's data length.
2102 : : * b) Set the "next" pointer of the current segment to point to the segment
2103 : : * at the NEXTP index.
2104 : : * c) Pass the HEAD of RSC aggregation cluster on to the next NEXTP entry
2105 : : * in the sw_rsc_ring.
2106 : : * 2) When EOP arrives we just update the cluster's total length and offload
2107 : : * flags and deliver the cluster up to the upper layers. In our case - put it
2108 : : * in the rx_pkts table.
2109 : : *
2110 : : * Returns the number of received packets/clusters (according to the "bulk
2111 : : * receive" interface).
2112 : : */
2113 : : static inline uint16_t
2114 : 0 : ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,
2115 : : bool bulk_alloc)
2116 : : {
2117 : : struct ixgbe_rx_queue *rxq = rx_queue;
2118 : 0 : volatile union ixgbe_adv_rx_desc *rx_ring = rxq->rx_ring;
2119 : 0 : struct ixgbe_rx_entry *sw_ring = rxq->sw_ring;
2120 : 0 : struct ixgbe_scattered_rx_entry *sw_sc_ring = rxq->sw_sc_ring;
2121 : 0 : uint16_t rx_id = rxq->rx_tail;
2122 : : uint16_t nb_rx = 0;
2123 : 0 : uint16_t nb_hold = rxq->nb_rx_hold;
2124 : : uint16_t prev_id = rxq->rx_tail;
2125 : :
2126 [ # # ]: 0 : while (nb_rx < nb_pkts) {
2127 : : bool eop;
2128 : : struct ixgbe_rx_entry *rxe;
2129 : : struct ixgbe_scattered_rx_entry *sc_entry;
2130 : : struct ixgbe_scattered_rx_entry *next_sc_entry = NULL;
2131 : : struct ixgbe_rx_entry *next_rxe = NULL;
2132 : : struct rte_mbuf *first_seg;
2133 : : struct rte_mbuf *rxm;
2134 : : struct rte_mbuf *nmb = NULL;
2135 : : union ixgbe_adv_rx_desc rxd;
2136 : : uint16_t data_len;
2137 : : uint16_t next_id;
2138 : : volatile union ixgbe_adv_rx_desc *rxdp;
2139 : : uint32_t staterr;
2140 : :
2141 : 0 : next_desc:
2142 : : /*
2143 : : * "Volatile" only prevents caching of the variable marked
2144 : : * volatile. Most important, "volatile" cannot prevent the CPU
2145 : : * from executing out of order. So, it is necessary to use a
2146 : : * proper memory barrier to ensure the memory ordering below.
2147 : : */
2148 : 0 : rxdp = &rx_ring[rx_id];
2149 : 0 : staterr = rte_le_to_cpu_32(rxdp->wb.upper.status_error);
2150 : :
2151 [ # # ]: 0 : if (!(staterr & IXGBE_RXDADV_STAT_DD))
2152 : : break;
2153 : :
2154 : : /*
2155 : : * Use acquire fence to ensure that status_error which includes
2156 : : * DD bit is loaded before loading of other descriptor words.
2157 : : */
2158 : : rte_atomic_thread_fence(rte_memory_order_acquire);
2159 : :
2160 : 0 : rxd = *rxdp;
2161 : :
2162 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_id=%u "
2163 : : "staterr=0x%x data_len=%u",
2164 : : rxq->port_id, rxq->queue_id, rx_id, staterr,
2165 : : rte_le_to_cpu_16(rxd.wb.upper.length));
2166 : :
2167 [ # # ]: 0 : if (!bulk_alloc) {
2168 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mb_pool);
2169 [ # # ]: 0 : if (nmb == NULL) {
2170 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed "
2171 : : "port_id=%u queue_id=%u",
2172 : : rxq->port_id, rxq->queue_id);
2173 : :
2174 : 0 : rte_eth_devices[rxq->port_id].data->
2175 : 0 : rx_mbuf_alloc_failed++;
2176 : 0 : break;
2177 : : }
2178 [ # # ]: 0 : } else if (nb_hold > rxq->rx_free_thresh) {
2179 : 0 : uint16_t next_rdt = rxq->rx_free_trigger;
2180 : :
2181 [ # # ]: 0 : if (!ixgbe_rx_alloc_bufs(rxq, false)) {
2182 : : rte_wmb();
2183 [ # # ]: 0 : IXGBE_PCI_REG_WC_WRITE_RELAXED(
2184 : : rxq->rdt_reg_addr,
2185 : : next_rdt);
2186 : 0 : nb_hold -= rxq->rx_free_thresh;
2187 : : } else {
2188 : : PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
2189 : : "port_id=%u queue_id=%u",
2190 : : rxq->port_id, rxq->queue_id);
2191 : :
2192 : 0 : rte_eth_devices[rxq->port_id].data->
2193 : 0 : rx_mbuf_alloc_failed++;
2194 : 0 : break;
2195 : : }
2196 : : }
2197 : :
2198 : 0 : nb_hold++;
2199 : 0 : rxe = &sw_ring[rx_id];
2200 : 0 : eop = staterr & IXGBE_RXDADV_STAT_EOP;
2201 : :
2202 : 0 : next_id = rx_id + 1;
2203 [ # # ]: 0 : if (next_id == rxq->nb_rx_desc)
2204 : : next_id = 0;
2205 : :
2206 : : /* Prefetch next mbuf while processing current one. */
2207 : 0 : rte_ixgbe_prefetch(sw_ring[next_id].mbuf);
2208 : :
2209 : : /*
2210 : : * When next RX descriptor is on a cache-line boundary,
2211 : : * prefetch the next 4 RX descriptors and the next 4 pointers
2212 : : * to mbufs.
2213 : : */
2214 [ # # ]: 0 : if ((next_id & 0x3) == 0) {
2215 : 0 : rte_ixgbe_prefetch(&rx_ring[next_id]);
2216 : : rte_ixgbe_prefetch(&sw_ring[next_id]);
2217 : : }
2218 : :
2219 : 0 : rxm = rxe->mbuf;
2220 : :
2221 [ # # ]: 0 : if (!bulk_alloc) {
2222 : : __le64 dma =
2223 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2224 : : /*
2225 : : * Update RX descriptor with the physical address of the
2226 : : * new data buffer of the new allocated mbuf.
2227 : : */
2228 : 0 : rxe->mbuf = nmb;
2229 : :
2230 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
2231 : 0 : rxdp->read.hdr_addr = 0;
2232 : 0 : rxdp->read.pkt_addr = dma;
2233 : : } else
2234 : 0 : rxe->mbuf = NULL;
2235 : :
2236 : : /*
2237 : : * Set data length & data buffer address of mbuf.
2238 : : */
2239 : 0 : data_len = rte_le_to_cpu_16(rxd.wb.upper.length);
2240 : 0 : rxm->data_len = data_len;
2241 : :
2242 [ # # ]: 0 : if (!eop) {
2243 : : uint16_t nextp_id;
2244 : : /*
2245 : : * Get next descriptor index:
2246 : : * - For RSC it's in the NEXTP field.
2247 : : * - For a scattered packet - it's just a following
2248 : : * descriptor.
2249 : : */
2250 [ # # ]: 0 : if (ixgbe_rsc_count(&rxd))
2251 : 0 : nextp_id =
2252 : 0 : (staterr & IXGBE_RXDADV_NEXTP_MASK) >>
2253 : : IXGBE_RXDADV_NEXTP_SHIFT;
2254 : : else
2255 : : nextp_id = next_id;
2256 : :
2257 : 0 : next_sc_entry = &sw_sc_ring[nextp_id];
2258 : 0 : next_rxe = &sw_ring[nextp_id];
2259 : : rte_ixgbe_prefetch(next_rxe);
2260 : : }
2261 : :
2262 : 0 : sc_entry = &sw_sc_ring[rx_id];
2263 : 0 : first_seg = sc_entry->fbuf;
2264 : 0 : sc_entry->fbuf = NULL;
2265 : :
2266 : : /*
2267 : : * If this is the first buffer of the received packet,
2268 : : * set the pointer to the first mbuf of the packet and
2269 : : * initialize its context.
2270 : : * Otherwise, update the total length and the number of segments
2271 : : * of the current scattered packet, and update the pointer to
2272 : : * the last mbuf of the current packet.
2273 : : */
2274 [ # # ]: 0 : if (first_seg == NULL) {
2275 : : first_seg = rxm;
2276 : 0 : first_seg->pkt_len = data_len;
2277 : 0 : first_seg->nb_segs = 1;
2278 : : } else {
2279 : 0 : first_seg->pkt_len += data_len;
2280 : 0 : first_seg->nb_segs++;
2281 : : }
2282 : :
2283 : : prev_id = rx_id;
2284 : : rx_id = next_id;
2285 : :
2286 : : /*
2287 : : * If this is not the last buffer of the received packet, update
2288 : : * the pointer to the first mbuf at the NEXTP entry in the
2289 : : * sw_sc_ring and continue to parse the RX ring.
2290 : : */
2291 [ # # ]: 0 : if (!eop && next_rxe) {
2292 : 0 : rxm->next = next_rxe->mbuf;
2293 : 0 : next_sc_entry->fbuf = first_seg;
2294 : 0 : goto next_desc;
2295 : : }
2296 : :
2297 : : /* Initialize the first mbuf of the returned packet */
2298 : 0 : ixgbe_fill_cluster_head_buf(first_seg, &rxd, rxq, staterr);
2299 : :
2300 : : /*
2301 : : * Deal with the case, when HW CRC srip is disabled.
2302 : : * That can't happen when LRO is enabled, but still could
2303 : : * happen for scattered RX mode.
2304 : : */
2305 : 0 : first_seg->pkt_len -= rxq->crc_len;
2306 [ # # ]: 0 : if (unlikely(rxm->data_len <= rxq->crc_len)) {
2307 : : struct rte_mbuf *lp;
2308 : :
2309 [ # # ]: 0 : for (lp = first_seg; lp->next != rxm; lp = lp->next)
2310 : : ;
2311 : :
2312 : 0 : first_seg->nb_segs--;
2313 : 0 : lp->data_len -= rxq->crc_len - rxm->data_len;
2314 [ # # ]: 0 : lp->next = NULL;
2315 : : rte_pktmbuf_free_seg(rxm);
2316 : : } else
2317 : 0 : rxm->data_len -= rxq->crc_len;
2318 : :
2319 : : /* Prefetch data of first segment, if configured to do so. */
2320 : 0 : rte_packet_prefetch((char *)first_seg->buf_addr +
2321 : : first_seg->data_off);
2322 : :
2323 : : /*
2324 : : * Store the mbuf address into the next entry of the array
2325 : : * of returned packets.
2326 : : */
2327 : 0 : rx_pkts[nb_rx++] = first_seg;
2328 : : }
2329 : :
2330 : : /*
2331 : : * Record index of the next RX descriptor to probe.
2332 : : */
2333 : 0 : rxq->rx_tail = rx_id;
2334 : :
2335 : : /*
2336 : : * If the number of free RX descriptors is greater than the RX free
2337 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
2338 : : * register.
2339 : : * Update the RDT with the value of the last processed RX descriptor
2340 : : * minus 1, to guarantee that the RDT register is never equal to the
2341 : : * RDH register, which creates a "full" ring situation from the
2342 : : * hardware point of view...
2343 : : */
2344 [ # # # # ]: 0 : if (!bulk_alloc && nb_hold > rxq->rx_free_thresh) {
2345 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u "
2346 : : "nb_hold=%u nb_rx=%u",
2347 : : rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);
2348 : :
2349 : : rte_wmb();
2350 [ # # ]: 0 : IXGBE_PCI_REG_WC_WRITE_RELAXED(rxq->rdt_reg_addr, prev_id);
2351 : : nb_hold = 0;
2352 : : }
2353 : :
2354 : 0 : rxq->nb_rx_hold = nb_hold;
2355 : 0 : return nb_rx;
2356 : : }
2357 : :
2358 : : uint16_t
2359 : 0 : ixgbe_recv_pkts_lro_single_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
2360 : : uint16_t nb_pkts)
2361 : : {
2362 : 0 : return ixgbe_recv_pkts_lro(rx_queue, rx_pkts, nb_pkts, false);
2363 : : }
2364 : :
2365 : : uint16_t
2366 : 0 : ixgbe_recv_pkts_lro_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
2367 : : uint16_t nb_pkts)
2368 : : {
2369 : 0 : return ixgbe_recv_pkts_lro(rx_queue, rx_pkts, nb_pkts, true);
2370 : : }
2371 : :
2372 : : /*********************************************************************
2373 : : *
2374 : : * Queue management functions
2375 : : *
2376 : : **********************************************************************/
2377 : :
2378 : : static inline int
2379 : 0 : ixgbe_write_default_ctx_desc(struct ci_tx_queue *txq, struct rte_mempool *mp, bool vec)
2380 : : {
2381 : : volatile struct ixgbe_adv_tx_context_desc *ctx_txd;
2382 : : struct rte_mbuf *dummy;
2383 : : uint32_t vlan_macip_lens, type_tucmd_mlhl;
2384 : :
2385 : : /* allocate a dummy mbuf from tx pool to make sure it can be freed later */
2386 : 0 : dummy = rte_pktmbuf_alloc(mp);
2387 [ # # ]: 0 : if (dummy == NULL) {
2388 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate dummy mbuf for VF context descriptor");
2389 : 0 : return -1;
2390 : : }
2391 : :
2392 : : /* take first buffer in the ring and make it a context descriptor */
2393 : 0 : ctx_txd = (volatile struct ixgbe_adv_tx_context_desc *)&txq->ixgbe_tx_ring[txq->tx_tail];
2394 : :
2395 : : /* populate default context descriptor for VF */
2396 : : vlan_macip_lens = RTE_ETHER_HDR_LEN << IXGBE_ADVTXD_MACLEN_SHIFT;
2397 : : type_tucmd_mlhl = IXGBE_ADVTXD_TUCMD_L4T_RSV |
2398 : : IXGBE_ADVTXD_DTYP_CTXT | IXGBE_ADVTXD_DCMD_DEXT;
2399 : 0 : ctx_txd->vlan_macip_lens = rte_cpu_to_le_32(vlan_macip_lens);
2400 : 0 : ctx_txd->type_tucmd_mlhl = rte_cpu_to_le_32(type_tucmd_mlhl);
2401 : :
2402 : : /* update SW ring */
2403 [ # # ]: 0 : if (vec) {
2404 : : struct ci_tx_entry_vec *txve;
2405 : 0 : txve = &txq->sw_ring_vec[txq->tx_tail];
2406 : 0 : txve->mbuf = dummy;
2407 : : } else {
2408 : : struct ci_tx_entry *txe;
2409 : 0 : txe = &txq->sw_ring[txq->tx_tail];
2410 : 0 : txe->mbuf = dummy;
2411 : : }
2412 : 0 : txq->nb_tx_free--;
2413 : 0 : txq->tx_tail++;
2414 : :
2415 : : /* never come back until queue reset */
2416 : 0 : txq->vf_ctx_initialized = 1;
2417 : :
2418 : 0 : return 0;
2419 : : }
2420 : :
2421 : : static int
2422 : 0 : ixgbe_tx_done_cleanup_full(struct ci_tx_queue *txq, uint32_t free_cnt)
2423 : : {
2424 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
2425 : : uint16_t i, tx_last, tx_id;
2426 : : uint16_t nb_tx_free_last;
2427 : : uint16_t nb_tx_to_clean;
2428 : : uint32_t pkt_cnt;
2429 : :
2430 : : /* Start free mbuf from the next of tx_tail */
2431 : 0 : tx_last = txq->tx_tail;
2432 : 0 : tx_id = swr_ring[tx_last].next_id;
2433 : :
2434 [ # # # # ]: 0 : if (txq->nb_tx_free == 0 && ixgbe_xmit_cleanup(txq))
2435 : : return 0;
2436 : :
2437 : 0 : nb_tx_to_clean = txq->nb_tx_free;
2438 : : nb_tx_free_last = txq->nb_tx_free;
2439 [ # # ]: 0 : if (!free_cnt)
2440 : 0 : free_cnt = txq->nb_tx_desc;
2441 : :
2442 : : /* Loop through swr_ring to count the amount of
2443 : : * freeable mubfs and packets.
2444 : : */
2445 [ # # ]: 0 : for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
2446 : 0 : for (i = 0; i < nb_tx_to_clean &&
2447 [ # # # # ]: 0 : pkt_cnt < free_cnt &&
2448 : 0 : tx_id != tx_last; i++) {
2449 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
2450 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
2451 : 0 : swr_ring[tx_id].mbuf = NULL;
2452 : :
2453 : : /*
2454 : : * last segment in the packet,
2455 : : * increment packet count
2456 : : */
2457 : 0 : pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
2458 : : }
2459 : :
2460 : 0 : tx_id = swr_ring[tx_id].next_id;
2461 : : }
2462 : :
2463 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
2464 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
2465 : : break;
2466 : :
2467 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
2468 [ # # ]: 0 : if (ixgbe_xmit_cleanup(txq))
2469 : : break;
2470 : :
2471 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
2472 : : nb_tx_free_last = txq->nb_tx_free;
2473 : : }
2474 : : }
2475 : :
2476 : 0 : return (int)pkt_cnt;
2477 : : }
2478 : :
2479 : : static int
2480 : 0 : ixgbe_tx_done_cleanup_simple(struct ci_tx_queue *txq,
2481 : : uint32_t free_cnt)
2482 : : {
2483 : : int i, n, cnt;
2484 : :
2485 [ # # # # ]: 0 : if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
2486 : 0 : free_cnt = txq->nb_tx_desc;
2487 : :
2488 : 0 : cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
2489 : :
2490 [ # # ]: 0 : for (i = 0; i < cnt; i += n) {
2491 [ # # ]: 0 : if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
2492 : : break;
2493 : :
2494 : : n = ixgbe_tx_free_bufs(txq);
2495 : :
2496 [ # # ]: 0 : if (n == 0)
2497 : : break;
2498 : : }
2499 : :
2500 : 0 : return i;
2501 : : }
2502 : :
2503 : : static int
2504 : : ixgbe_tx_done_cleanup_vec(struct ci_tx_queue *txq __rte_unused,
2505 : : uint32_t free_cnt __rte_unused)
2506 : : {
2507 : : return -ENOTSUP;
2508 : : }
2509 : :
2510 : : int
2511 : 0 : ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
2512 : : {
2513 : : struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
2514 [ # # ]: 0 : if (txq->offloads == 0 &&
2515 : : #ifdef RTE_LIB_SECURITY
2516 [ # # ]: 0 : !(txq->using_ipsec) &&
2517 : : #endif
2518 [ # # ]: 0 : txq->tx_rs_thresh >= RTE_PMD_IXGBE_TX_MAX_BURST) {
2519 [ # # # # ]: 0 : if (txq->tx_rs_thresh <= RTE_IXGBE_TX_MAX_FREE_BUF_SZ &&
2520 [ # # ]: 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
2521 : 0 : (rte_eal_process_type() != RTE_PROC_PRIMARY ||
2522 [ # # ]: 0 : txq->sw_ring_vec != NULL)) {
2523 : : return ixgbe_tx_done_cleanup_vec(txq, free_cnt);
2524 : : } else {
2525 : 0 : return ixgbe_tx_done_cleanup_simple(txq, free_cnt);
2526 : : }
2527 : : }
2528 : :
2529 : 0 : return ixgbe_tx_done_cleanup_full(txq, free_cnt);
2530 : : }
2531 : :
2532 : : static void __rte_cold
2533 : 0 : ixgbe_tx_free_swring(struct ci_tx_queue *txq)
2534 : : {
2535 [ # # ]: 0 : if (txq != NULL &&
2536 [ # # ]: 0 : txq->sw_ring != NULL)
2537 : 0 : rte_free(txq->sw_ring);
2538 : 0 : }
2539 : :
2540 : : static void __rte_cold
2541 : 0 : ixgbe_tx_queue_release(struct ci_tx_queue *txq)
2542 : : {
2543 [ # # # # ]: 0 : if (txq != NULL && txq->ops != NULL) {
2544 : 0 : ci_txq_release_all_mbufs(txq, false);
2545 : 0 : txq->ops->free_swring(txq);
2546 : 0 : rte_memzone_free(txq->mz);
2547 : 0 : rte_free(txq);
2548 : : }
2549 : 0 : }
2550 : :
2551 : : void __rte_cold
2552 : 0 : ixgbe_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
2553 : : {
2554 : 0 : ixgbe_tx_queue_release(dev->data->tx_queues[qid]);
2555 : 0 : }
2556 : :
2557 : : /* (Re)set dynamic ixgbe_tx_queue fields to defaults */
2558 : : static void __rte_cold
2559 : 0 : ixgbe_reset_tx_queue(struct ci_tx_queue *txq)
2560 : : {
2561 : : static const union ixgbe_adv_tx_desc zeroed_desc = {{0}};
2562 : 0 : struct ci_tx_entry *txe = txq->sw_ring;
2563 : : uint16_t prev, i;
2564 : :
2565 : : /* Zero out HW ring memory */
2566 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
2567 : 0 : txq->ixgbe_tx_ring[i] = zeroed_desc;
2568 : : }
2569 : :
2570 : : /* Initialize SW ring entries */
2571 : 0 : prev = (uint16_t) (txq->nb_tx_desc - 1);
2572 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
2573 : 0 : volatile union ixgbe_adv_tx_desc *txd = &txq->ixgbe_tx_ring[i];
2574 : :
2575 : 0 : txd->wb.status = rte_cpu_to_le_32(IXGBE_TXD_STAT_DD);
2576 : 0 : txe[i].mbuf = NULL;
2577 : 0 : txe[i].last_id = i;
2578 : 0 : txe[prev].next_id = i;
2579 : : prev = i;
2580 : : }
2581 : :
2582 : 0 : txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
2583 : 0 : txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
2584 : :
2585 : 0 : txq->tx_tail = 0;
2586 : 0 : txq->nb_tx_used = 0;
2587 : : /*
2588 : : * Always allow 1 descriptor to be un-allocated to avoid
2589 : : * a H/W race condition
2590 : : */
2591 : 0 : txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
2592 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
2593 : 0 : txq->ctx_curr = 0;
2594 : : /*
2595 : : * When doing Tx on a VF queue, we need to set CC bit and specify a
2596 : : * valid context descriptor regardless of whether we are using any
2597 : : * offloads.
2598 : : *
2599 : : * For simple/vector Tx paths, a default context descriptor will always
2600 : : * be created on Tx start, so we do not need any special handling here.
2601 : : * However, for full offload path, we will be dynamically switching
2602 : : * between two context descriptors (and create new ones when necessary)
2603 : : * based on what kind of offloads are enabled for each packet, so we
2604 : : * need to prepare the offload cache accordingly.
2605 : : *
2606 : : * In case of VF, because we might be transmitting packets with and
2607 : : * without offloads (both of which require context descriptors), we need
2608 : : * to distinguish between "packet with no offloads" and "packet with no
2609 : : * offloads but we've already created a context for it" cases. This
2610 : : * works fine on switchover from having filled offload context cache
2611 : : * previously as no-offload case won't match previously created context,
2612 : : * but to make this work in cases where no previous packets had offloads
2613 : : * (such as on Tx start), we poison the offload cache, so that
2614 : : * no-offload packet also triggers creation of new context descriptor
2615 : : * due to offload cache mismatch.
2616 : : */
2617 [ # # ]: 0 : memset(txq->ctx_cache, 0xFF, IXGBE_CTX_NUM * sizeof(struct ixgbe_advctx_info));
2618 : :
2619 : : /* for PF, we do not need to initialize the context descriptor */
2620 [ # # ]: 0 : if (!txq->is_vf)
2621 : 0 : txq->vf_ctx_initialized = 1;
2622 : 0 : }
2623 : :
2624 : : static const struct ixgbe_txq_ops def_txq_ops = {
2625 : : .free_swring = ixgbe_tx_free_swring,
2626 : : .reset = ixgbe_reset_tx_queue,
2627 : : };
2628 : :
2629 : : static const struct {
2630 : : eth_tx_burst_t pkt_burst;
2631 : : const char *info;
2632 : : } ixgbe_tx_burst_info[] = {
2633 : : { ixgbe_xmit_pkts, "Scalar"},
2634 : : { ixgbe_xmit_pkts_simple, "Scalar simple"},
2635 : : { ixgbe_vf_representor_tx_burst, "Scalar representor"},
2636 : : #ifdef RTE_ARCH_X86
2637 : : { ixgbe_xmit_pkts_vec, "Vector SSE"},
2638 : : #elif defined(RTE_ARCH_ARM)
2639 : : { ixgbe_xmit_pkts_vec, "Vector NEON"},
2640 : : #endif
2641 : : };
2642 : :
2643 : : int
2644 : 0 : ixgbe_tx_burst_mode_get(struct rte_eth_dev *dev,
2645 : : __rte_unused uint16_t queue_id,
2646 : : struct rte_eth_burst_mode *mode)
2647 : : {
2648 : 0 : eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
2649 : : size_t i;
2650 : :
2651 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ixgbe_tx_burst_info); i++) {
2652 [ # # ]: 0 : if (pkt_burst == ixgbe_tx_burst_info[i].pkt_burst) {
2653 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
2654 : 0 : ixgbe_tx_burst_info[i].info);
2655 : 0 : return 0;
2656 : : }
2657 : : }
2658 : :
2659 : : return -EINVAL;
2660 : : }
2661 : :
2662 : : /* Takes an ethdev and a queue and sets up the tx function to be used based on
2663 : : * the queue parameters. Used in tx_queue_setup by primary process and then
2664 : : * in dev_init by secondary process when attaching to an existing ethdev.
2665 : : */
2666 : : void __rte_cold
2667 : 0 : ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ci_tx_queue *txq)
2668 : : {
2669 : : /* Use a simple Tx queue (no offloads, no multi segs) if possible */
2670 [ # # ]: 0 : if ((txq->offloads == 0) &&
2671 : : #ifdef RTE_LIB_SECURITY
2672 [ # # ]: 0 : !(txq->using_ipsec) &&
2673 : : #endif
2674 [ # # ]: 0 : (txq->tx_rs_thresh >= RTE_PMD_IXGBE_TX_MAX_BURST)) {
2675 : 0 : PMD_INIT_LOG(DEBUG, "Using simple tx code path");
2676 : 0 : dev->tx_pkt_prepare = NULL;
2677 [ # # # # ]: 0 : if (txq->tx_rs_thresh <= RTE_IXGBE_TX_MAX_FREE_BUF_SZ &&
2678 [ # # ]: 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128 &&
2679 [ # # ]: 0 : (rte_eal_process_type() != RTE_PROC_PRIMARY ||
2680 : 0 : ixgbe_txq_vec_setup(txq) == 0)) {
2681 : 0 : PMD_INIT_LOG(DEBUG, "Vector tx enabled.");
2682 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
2683 : 0 : dev->recycle_tx_mbufs_reuse = ixgbe_recycle_tx_mbufs_reuse_vec;
2684 : : #endif
2685 : 0 : dev->tx_pkt_burst = ixgbe_xmit_pkts_vec;
2686 : : } else
2687 : 0 : dev->tx_pkt_burst = ixgbe_xmit_pkts_simple;
2688 : : } else {
2689 : 0 : PMD_INIT_LOG(DEBUG, "Using full-featured tx code path");
2690 : 0 : PMD_INIT_LOG(DEBUG,
2691 : : " - offloads = 0x%" PRIx64,
2692 : : txq->offloads);
2693 : 0 : PMD_INIT_LOG(DEBUG,
2694 : : " - tx_rs_thresh = %lu " "[RTE_PMD_IXGBE_TX_MAX_BURST=%lu]",
2695 : : (unsigned long)txq->tx_rs_thresh,
2696 : : (unsigned long)RTE_PMD_IXGBE_TX_MAX_BURST);
2697 : 0 : dev->tx_pkt_burst = ixgbe_xmit_pkts;
2698 : 0 : dev->tx_pkt_prepare = ixgbe_prep_pkts;
2699 : : }
2700 : 0 : }
2701 : :
2702 : : uint64_t
2703 : 0 : ixgbe_get_tx_queue_offloads(struct rte_eth_dev *dev)
2704 : : {
2705 : : RTE_SET_USED(dev);
2706 : :
2707 : 0 : return 0;
2708 : : }
2709 : :
2710 : : uint64_t
2711 : 0 : ixgbe_get_tx_port_offloads(struct rte_eth_dev *dev)
2712 : : {
2713 : : uint64_t tx_offload_capa;
2714 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2715 : :
2716 : : tx_offload_capa =
2717 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
2718 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
2719 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
2720 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
2721 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
2722 : : RTE_ETH_TX_OFFLOAD_TCP_TSO |
2723 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
2724 : :
2725 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB ||
2726 : : hw->mac.type == ixgbe_mac_X540)
2727 : : tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
2728 : :
2729 : 0 : if (hw->mac.type == ixgbe_mac_X550 ||
2730 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
2731 : : hw->mac.type == ixgbe_mac_X550EM_a)
2732 : 0 : tx_offload_capa |= RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
2733 : :
2734 : : #ifdef RTE_LIB_SECURITY
2735 [ # # ]: 0 : if (dev->security_ctx)
2736 : 0 : tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
2737 : : #endif
2738 : 0 : return tx_offload_capa;
2739 : : }
2740 : :
2741 : : int __rte_cold
2742 : 0 : ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
2743 : : uint16_t queue_idx,
2744 : : uint16_t nb_desc,
2745 : : unsigned int socket_id,
2746 : : const struct rte_eth_txconf *tx_conf)
2747 : : {
2748 : : const struct rte_memzone *tz;
2749 : : struct ci_tx_queue *txq;
2750 : : struct ixgbe_hw *hw;
2751 : : uint16_t tx_rs_thresh, tx_free_thresh;
2752 : : uint64_t offloads;
2753 : :
2754 : 0 : PMD_INIT_FUNC_TRACE();
2755 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2756 : :
2757 : 0 : offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
2758 : :
2759 : : /*
2760 : : * Validate number of transmit descriptors.
2761 : : * It must not exceed hardware maximum, and must be multiple
2762 : : * of IXGBE_ALIGN.
2763 : : */
2764 [ # # ]: 0 : if (nb_desc % IXGBE_TXD_ALIGN != 0 ||
2765 [ # # ]: 0 : (nb_desc > IXGBE_MAX_RING_DESC) ||
2766 : : (nb_desc < IXGBE_MIN_RING_DESC)) {
2767 : : return -EINVAL;
2768 : : }
2769 : :
2770 : : /*
2771 : : * The following two parameters control the setting of the RS bit on
2772 : : * transmit descriptors.
2773 : : * TX descriptors will have their RS bit set after txq->tx_rs_thresh
2774 : : * descriptors have been used.
2775 : : * The TX descriptor ring will be cleaned after txq->tx_free_thresh
2776 : : * descriptors are used or if the number of descriptors required
2777 : : * to transmit a packet is greater than the number of free TX
2778 : : * descriptors.
2779 : : * The following constraints must be satisfied:
2780 : : * tx_rs_thresh must be greater than 0.
2781 : : * tx_rs_thresh must be less than the size of the ring minus 2.
2782 : : * tx_rs_thresh must be less than or equal to tx_free_thresh.
2783 : : * tx_rs_thresh must be a divisor of the ring size.
2784 : : * tx_free_thresh must be greater than 0.
2785 : : * tx_free_thresh must be less than the size of the ring minus 3.
2786 : : * tx_free_thresh + tx_rs_thresh must not exceed nb_desc.
2787 : : * One descriptor in the TX ring is used as a sentinel to avoid a
2788 : : * H/W race condition, hence the maximum threshold constraints.
2789 : : * When set to zero use default values.
2790 : : */
2791 [ # # ]: 0 : tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
2792 : : tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH);
2793 : : /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */
2794 [ # # ]: 0 : tx_rs_thresh = (DEFAULT_TX_RS_THRESH + tx_free_thresh > nb_desc) ?
2795 : : nb_desc - tx_free_thresh : DEFAULT_TX_RS_THRESH;
2796 [ # # ]: 0 : if (tx_conf->tx_rs_thresh > 0)
2797 : : tx_rs_thresh = tx_conf->tx_rs_thresh;
2798 [ # # ]: 0 : if (tx_rs_thresh + tx_free_thresh > nb_desc) {
2799 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh + tx_free_thresh must not "
2800 : : "exceed nb_desc. (tx_rs_thresh=%u "
2801 : : "tx_free_thresh=%u nb_desc=%u port = %d queue=%d)",
2802 : : (unsigned int)tx_rs_thresh,
2803 : : (unsigned int)tx_free_thresh,
2804 : : (unsigned int)nb_desc,
2805 : : (int)dev->data->port_id,
2806 : : (int)queue_idx);
2807 : 0 : return -(EINVAL);
2808 : : }
2809 [ # # ]: 0 : if (tx_rs_thresh >= (nb_desc - 2)) {
2810 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the number "
2811 : : "of TX descriptors minus 2. (tx_rs_thresh=%u "
2812 : : "port=%d queue=%d)", (unsigned int)tx_rs_thresh,
2813 : : (int)dev->data->port_id, (int)queue_idx);
2814 : 0 : return -(EINVAL);
2815 : : }
2816 [ # # ]: 0 : if (tx_rs_thresh > DEFAULT_TX_RS_THRESH) {
2817 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less or equal than %u. "
2818 : : "(tx_rs_thresh=%u port=%d queue=%d)",
2819 : : DEFAULT_TX_RS_THRESH, (unsigned int)tx_rs_thresh,
2820 : : (int)dev->data->port_id, (int)queue_idx);
2821 : 0 : return -(EINVAL);
2822 : : }
2823 [ # # ]: 0 : if (tx_free_thresh >= (nb_desc - 3)) {
2824 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
2825 : : "tx_free_thresh must be less than the number of "
2826 : : "TX descriptors minus 3. (tx_free_thresh=%u "
2827 : : "port=%d queue=%d)",
2828 : : (unsigned int)tx_free_thresh,
2829 : : (int)dev->data->port_id, (int)queue_idx);
2830 : 0 : return -(EINVAL);
2831 : : }
2832 [ # # ]: 0 : if (tx_rs_thresh > tx_free_thresh) {
2833 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or equal to "
2834 : : "tx_free_thresh. (tx_free_thresh=%u "
2835 : : "tx_rs_thresh=%u port=%d queue=%d)",
2836 : : (unsigned int)tx_free_thresh,
2837 : : (unsigned int)tx_rs_thresh,
2838 : : (int)dev->data->port_id,
2839 : : (int)queue_idx);
2840 : 0 : return -(EINVAL);
2841 : : }
2842 [ # # ]: 0 : if ((nb_desc % tx_rs_thresh) != 0) {
2843 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
2844 : : "number of TX descriptors. (tx_rs_thresh=%u "
2845 : : "port=%d queue=%d)", (unsigned int)tx_rs_thresh,
2846 : : (int)dev->data->port_id, (int)queue_idx);
2847 : 0 : return -(EINVAL);
2848 : : }
2849 : :
2850 : : /*
2851 : : * If rs_bit_thresh is greater than 1, then TX WTHRESH should be
2852 : : * set to 0. If WTHRESH is greater than zero, the RS bit is ignored
2853 : : * by the NIC and all descriptors are written back after the NIC
2854 : : * accumulates WTHRESH descriptors.
2855 : : */
2856 [ # # # # ]: 0 : if ((tx_rs_thresh > 1) && (tx_conf->tx_thresh.wthresh != 0)) {
2857 : 0 : PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
2858 : : "tx_rs_thresh is greater than 1. (tx_rs_thresh=%u "
2859 : : "port=%d queue=%d)", (unsigned int)tx_rs_thresh,
2860 : : (int)dev->data->port_id, (int)queue_idx);
2861 : 0 : return -(EINVAL);
2862 : : }
2863 : :
2864 : : /* Free memory prior to re-allocation if needed... */
2865 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx] != NULL) {
2866 : 0 : ixgbe_tx_queue_release(dev->data->tx_queues[queue_idx]);
2867 : 0 : dev->data->tx_queues[queue_idx] = NULL;
2868 : : }
2869 : :
2870 : : /* First allocate the tx queue data structure */
2871 : 0 : txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct ci_tx_queue) +
2872 : : sizeof(struct ixgbe_advctx_info) * IXGBE_CTX_NUM,
2873 : : RTE_CACHE_LINE_SIZE, socket_id);
2874 [ # # ]: 0 : if (txq == NULL)
2875 : : return -ENOMEM;
2876 : 0 : txq->ctx_cache = RTE_PTR_ADD(txq, sizeof(struct ci_tx_queue));
2877 : :
2878 : : /*
2879 : : * Allocate TX ring hardware descriptors. A memzone large enough to
2880 : : * handle the maximum ring size is allocated in order to allow for
2881 : : * resizing in later calls to the queue setup function.
2882 : : */
2883 : 0 : tz = rte_eth_dma_zone_reserve(dev, "ixgbe_tx_ring", queue_idx,
2884 : : sizeof(union ixgbe_adv_tx_desc) * IXGBE_MAX_RING_DESC,
2885 : : IXGBE_ALIGN, socket_id);
2886 [ # # ]: 0 : if (tz == NULL) {
2887 : 0 : ixgbe_tx_queue_release(txq);
2888 : 0 : return -ENOMEM;
2889 : : }
2890 : :
2891 : 0 : txq->mz = tz;
2892 : 0 : txq->nb_tx_desc = nb_desc;
2893 : 0 : txq->tx_rs_thresh = tx_rs_thresh;
2894 : 0 : txq->tx_free_thresh = tx_free_thresh;
2895 : 0 : txq->pthresh = tx_conf->tx_thresh.pthresh;
2896 : 0 : txq->hthresh = tx_conf->tx_thresh.hthresh;
2897 : 0 : txq->wthresh = tx_conf->tx_thresh.wthresh;
2898 : 0 : txq->queue_id = queue_idx;
2899 [ # # ]: 0 : txq->reg_idx = (uint16_t)((RTE_ETH_DEV_SRIOV(dev).active == 0) ?
2900 : 0 : queue_idx : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + queue_idx);
2901 : 0 : txq->port_id = dev->data->port_id;
2902 : 0 : txq->offloads = offloads;
2903 : 0 : txq->ops = &def_txq_ops;
2904 : 0 : txq->tx_deferred_start = tx_conf->tx_deferred_start;
2905 : : #ifdef RTE_LIB_SECURITY
2906 : 0 : txq->using_ipsec = !!(dev->data->dev_conf.txmode.offloads &
2907 : : RTE_ETH_TX_OFFLOAD_SECURITY);
2908 : : #endif
2909 : :
2910 : : /*
2911 : : * Modification to set VFTDT for virtual function if vf is detected
2912 : : */
2913 : : if (ixgbe_is_vf(dev)) {
2914 : : /* mark this queue as VF, because VF needs special Tx behavior */
2915 : 0 : txq->is_vf = 1;
2916 : 0 : txq->qtx_tail = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFTDT(queue_idx));
2917 : : } else {
2918 : 0 : txq->qtx_tail = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(txq->reg_idx));
2919 : : }
2920 : :
2921 : 0 : txq->tx_ring_dma = tz->iova;
2922 : 0 : txq->ixgbe_tx_ring = (union ixgbe_adv_tx_desc *)tz->addr;
2923 : :
2924 : : /* Allocate software ring */
2925 : 0 : txq->sw_ring = rte_zmalloc_socket("txq->sw_ring",
2926 : : sizeof(struct ci_tx_entry) * nb_desc,
2927 : : RTE_CACHE_LINE_SIZE, socket_id);
2928 [ # # ]: 0 : if (txq->sw_ring == NULL) {
2929 : 0 : ixgbe_tx_queue_release(txq);
2930 : 0 : return -ENOMEM;
2931 : : }
2932 : 0 : PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
2933 : : txq->sw_ring, txq->ixgbe_tx_ring, txq->tx_ring_dma);
2934 : :
2935 : : /* set up vector or scalar TX function as appropriate */
2936 : 0 : ixgbe_set_tx_function(dev, txq);
2937 : :
2938 : 0 : txq->ops->reset(txq);
2939 : :
2940 : 0 : dev->data->tx_queues[queue_idx] = txq;
2941 : :
2942 : :
2943 : 0 : return 0;
2944 : : }
2945 : :
2946 : : /**
2947 : : * ixgbe_free_sc_cluster - free the not-yet-completed scattered cluster
2948 : : *
2949 : : * The "next" pointer of the last segment of (not-yet-completed) RSC clusters
2950 : : * in the sw_rsc_ring is not set to NULL but rather points to the next
2951 : : * mbuf of this RSC aggregation (that has not been completed yet and still
2952 : : * resides on the HW ring). So, instead of calling for rte_pktmbuf_free() we
2953 : : * will just free first "nb_segs" segments of the cluster explicitly by calling
2954 : : * an rte_pktmbuf_free_seg().
2955 : : *
2956 : : * @m scattered cluster head
2957 : : */
2958 : : static void __rte_cold
2959 : 0 : ixgbe_free_sc_cluster(struct rte_mbuf *m)
2960 : : {
2961 : 0 : uint16_t i, nb_segs = m->nb_segs;
2962 : : struct rte_mbuf *next_seg;
2963 : :
2964 [ # # ]: 0 : for (i = 0; i < nb_segs; i++) {
2965 : 0 : next_seg = m->next;
2966 : : rte_pktmbuf_free_seg(m);
2967 : : m = next_seg;
2968 : : }
2969 : 0 : }
2970 : :
2971 : : static void __rte_cold
2972 : 0 : ixgbe_rx_queue_release_mbufs(struct ixgbe_rx_queue *rxq)
2973 : : {
2974 : : unsigned i;
2975 : :
2976 : : /* SSE Vector driver has a different way of releasing mbufs. */
2977 [ # # ]: 0 : if (rxq->rx_using_sse) {
2978 : 0 : ixgbe_rx_queue_release_mbufs_vec(rxq);
2979 : 0 : return;
2980 : : }
2981 : :
2982 [ # # ]: 0 : if (rxq->sw_ring != NULL) {
2983 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
2984 [ # # ]: 0 : if (rxq->sw_ring[i].mbuf != NULL) {
2985 : : rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf);
2986 : 0 : rxq->sw_ring[i].mbuf = NULL;
2987 : : }
2988 : : }
2989 [ # # ]: 0 : if (rxq->rx_nb_avail) {
2990 [ # # ]: 0 : for (i = 0; i < rxq->rx_nb_avail; ++i) {
2991 : : struct rte_mbuf *mb;
2992 : :
2993 [ # # ]: 0 : mb = rxq->rx_stage[rxq->rx_next_avail + i];
2994 : : rte_pktmbuf_free_seg(mb);
2995 : : }
2996 : 0 : rxq->rx_nb_avail = 0;
2997 : : }
2998 : : }
2999 : :
3000 [ # # ]: 0 : if (rxq->sw_sc_ring)
3001 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++)
3002 [ # # ]: 0 : if (rxq->sw_sc_ring[i].fbuf) {
3003 : 0 : ixgbe_free_sc_cluster(rxq->sw_sc_ring[i].fbuf);
3004 : 0 : rxq->sw_sc_ring[i].fbuf = NULL;
3005 : : }
3006 : : }
3007 : :
3008 : : static void __rte_cold
3009 : 0 : ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
3010 : : {
3011 [ # # ]: 0 : if (rxq != NULL) {
3012 : 0 : ixgbe_rx_queue_release_mbufs(rxq);
3013 : 0 : rte_free(rxq->sw_ring);
3014 : 0 : rte_free(rxq->sw_sc_ring);
3015 : 0 : rte_memzone_free(rxq->mz);
3016 : 0 : rte_free(rxq);
3017 : : }
3018 : 0 : }
3019 : :
3020 : : void __rte_cold
3021 : 0 : ixgbe_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
3022 : : {
3023 : 0 : ixgbe_rx_queue_release(dev->data->rx_queues[qid]);
3024 : 0 : }
3025 : :
3026 : : /*
3027 : : * Check if Rx Burst Bulk Alloc function can be used.
3028 : : * Return
3029 : : * 0: the preconditions are satisfied and the bulk allocation function
3030 : : * can be used.
3031 : : * -EINVAL: the preconditions are NOT satisfied and the default Rx burst
3032 : : * function must be used.
3033 : : */
3034 : : static inline int __rte_cold
3035 : 0 : check_rx_burst_bulk_alloc_preconditions(struct ixgbe_rx_queue *rxq)
3036 : : {
3037 : : int ret = 0;
3038 : :
3039 : : /*
3040 : : * Make sure the following pre-conditions are satisfied:
3041 : : * rxq->rx_free_thresh >= RTE_PMD_IXGBE_RX_MAX_BURST
3042 : : * rxq->rx_free_thresh < rxq->nb_rx_desc
3043 : : * (rxq->nb_rx_desc % rxq->rx_free_thresh) == 0
3044 : : * Scattered packets are not supported. This should be checked
3045 : : * outside of this function.
3046 : : */
3047 [ # # ]: 0 : if (!(rxq->rx_free_thresh >= RTE_PMD_IXGBE_RX_MAX_BURST)) {
3048 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
3049 : : "rxq->rx_free_thresh=%d, "
3050 : : "RTE_PMD_IXGBE_RX_MAX_BURST=%d",
3051 : : rxq->rx_free_thresh, RTE_PMD_IXGBE_RX_MAX_BURST);
3052 : : ret = -EINVAL;
3053 [ # # ]: 0 : } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
3054 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
3055 : : "rxq->rx_free_thresh=%d, "
3056 : : "rxq->nb_rx_desc=%d",
3057 : : rxq->rx_free_thresh, rxq->nb_rx_desc);
3058 : : ret = -EINVAL;
3059 [ # # ]: 0 : } else if (!((rxq->nb_rx_desc % rxq->rx_free_thresh) == 0)) {
3060 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
3061 : : "rxq->nb_rx_desc=%d, "
3062 : : "rxq->rx_free_thresh=%d",
3063 : : rxq->nb_rx_desc, rxq->rx_free_thresh);
3064 : : ret = -EINVAL;
3065 : : }
3066 : :
3067 : 0 : return ret;
3068 : : }
3069 : :
3070 : : /* Reset dynamic ixgbe_rx_queue fields back to defaults */
3071 : : static void __rte_cold
3072 : 0 : ixgbe_reset_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_rx_queue *rxq)
3073 : : {
3074 : : static const union ixgbe_adv_rx_desc zeroed_desc = {{0}};
3075 : : unsigned i;
3076 : 0 : uint16_t len = rxq->nb_rx_desc;
3077 : :
3078 : : /*
3079 : : * By default, the Rx queue setup function allocates enough memory for
3080 : : * IXGBE_MAX_RING_DESC. The Rx Burst bulk allocation function requires
3081 : : * extra memory at the end of the descriptor ring to be zero'd out.
3082 : : */
3083 [ # # ]: 0 : if (adapter->rx_bulk_alloc_allowed)
3084 : : /* zero out extra memory */
3085 : 0 : len += RTE_PMD_IXGBE_RX_MAX_BURST;
3086 : :
3087 : : /*
3088 : : * Zero out HW ring memory. Zero out extra memory at the end of
3089 : : * the H/W ring so look-ahead logic in Rx Burst bulk alloc function
3090 : : * reads extra memory as zeros.
3091 : : */
3092 [ # # ]: 0 : for (i = 0; i < len; i++) {
3093 : 0 : rxq->rx_ring[i] = zeroed_desc;
3094 : : }
3095 : :
3096 : : /*
3097 : : * initialize extra software ring entries. Space for these extra
3098 : : * entries is always allocated
3099 : : */
3100 : 0 : memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
3101 [ # # ]: 0 : for (i = rxq->nb_rx_desc; i < len; ++i) {
3102 : 0 : rxq->sw_ring[i].mbuf = &rxq->fake_mbuf;
3103 : : }
3104 : :
3105 : 0 : rxq->rx_nb_avail = 0;
3106 : 0 : rxq->rx_next_avail = 0;
3107 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
3108 : 0 : rxq->rx_tail = 0;
3109 : 0 : rxq->nb_rx_hold = 0;
3110 : :
3111 : 0 : rte_pktmbuf_free(rxq->pkt_first_seg);
3112 : :
3113 : 0 : rxq->pkt_first_seg = NULL;
3114 : 0 : rxq->pkt_last_seg = NULL;
3115 : :
3116 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3117 : 0 : rxq->rxrearm_start = 0;
3118 : 0 : rxq->rxrearm_nb = 0;
3119 : : #endif
3120 : 0 : }
3121 : :
3122 : : static int
3123 : : ixgbe_is_vf(struct rte_eth_dev *dev)
3124 : : {
3125 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3126 : :
3127 [ # # # # : 0 : switch (hw->mac.type) {
# # ]
3128 : : case ixgbe_mac_82599_vf:
3129 : : case ixgbe_mac_X540_vf:
3130 : : case ixgbe_mac_X550_vf:
3131 : : case ixgbe_mac_X550EM_x_vf:
3132 : : case ixgbe_mac_X550EM_a_vf:
3133 : : case ixgbe_mac_E610_vf:
3134 : : return 1;
3135 : : default:
3136 : : return 0;
3137 : : }
3138 : : }
3139 : :
3140 : : uint64_t
3141 : 0 : ixgbe_get_rx_queue_offloads(struct rte_eth_dev *dev)
3142 : : {
3143 : : uint64_t offloads = 0;
3144 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3145 : :
3146 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB)
3147 : : offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
3148 : :
3149 : 0 : return offloads;
3150 : : }
3151 : :
3152 : : uint64_t
3153 : 0 : ixgbe_get_rx_port_offloads(struct rte_eth_dev *dev)
3154 : : {
3155 : : uint64_t offloads;
3156 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3157 : :
3158 : : offloads = RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
3159 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
3160 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
3161 : : RTE_ETH_RX_OFFLOAD_KEEP_CRC |
3162 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
3163 : : RTE_ETH_RX_OFFLOAD_SCATTER |
3164 : : RTE_ETH_RX_OFFLOAD_RSS_HASH;
3165 : :
3166 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
3167 : : offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
3168 : :
3169 : : if (ixgbe_is_vf(dev) == 0)
3170 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
3171 : :
3172 : : /*
3173 : : * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3174 : : * mode.
3175 : : */
3176 [ # # ]: 0 : if ((hw->mac.type == ixgbe_mac_82599EB ||
3177 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X540 ||
3178 : 0 : hw->mac.type == ixgbe_mac_X550) &&
3179 [ # # ]: 0 : !RTE_ETH_DEV_SRIOV(dev).active)
3180 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_TCP_LRO;
3181 : :
3182 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB ||
3183 : : hw->mac.type == ixgbe_mac_X540)
3184 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_MACSEC_STRIP;
3185 : :
3186 : 0 : if (hw->mac.type == ixgbe_mac_X550 ||
3187 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
3188 : : hw->mac.type == ixgbe_mac_X550EM_a)
3189 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3190 : :
3191 : : #ifdef RTE_LIB_SECURITY
3192 [ # # ]: 0 : if (dev->security_ctx)
3193 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_SECURITY;
3194 : : #endif
3195 : :
3196 : 0 : return offloads;
3197 : : }
3198 : :
3199 : : int __rte_cold
3200 : 0 : ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
3201 : : uint16_t queue_idx,
3202 : : uint16_t nb_desc,
3203 : : unsigned int socket_id,
3204 : : const struct rte_eth_rxconf *rx_conf,
3205 : : struct rte_mempool *mp)
3206 : : {
3207 : : const struct rte_memzone *rz;
3208 : : struct ixgbe_rx_queue *rxq;
3209 : : struct ixgbe_hw *hw;
3210 : : uint16_t len;
3211 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
3212 : : uint64_t offloads;
3213 : :
3214 : 0 : PMD_INIT_FUNC_TRACE();
3215 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3216 : :
3217 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
3218 : :
3219 : : /*
3220 : : * Validate number of receive descriptors.
3221 : : * It must not exceed hardware maximum, and must be multiple
3222 : : * of IXGBE_ALIGN.
3223 : : */
3224 [ # # ]: 0 : if (nb_desc % IXGBE_RXD_ALIGN != 0 ||
3225 [ # # ]: 0 : (nb_desc > IXGBE_MAX_RING_DESC) ||
3226 : : (nb_desc < IXGBE_MIN_RING_DESC)) {
3227 : : return -EINVAL;
3228 : : }
3229 : :
3230 : : /* Free memory prior to re-allocation if needed... */
3231 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx] != NULL) {
3232 : 0 : ixgbe_rx_queue_release(dev->data->rx_queues[queue_idx]);
3233 : 0 : dev->data->rx_queues[queue_idx] = NULL;
3234 : : }
3235 : :
3236 : : /* First allocate the rx queue data structure */
3237 : 0 : rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct ixgbe_rx_queue),
3238 : : RTE_CACHE_LINE_SIZE, socket_id);
3239 [ # # ]: 0 : if (rxq == NULL)
3240 : : return -ENOMEM;
3241 : 0 : rxq->mb_pool = mp;
3242 : 0 : rxq->nb_rx_desc = nb_desc;
3243 : 0 : rxq->rx_free_thresh = rx_conf->rx_free_thresh;
3244 : 0 : rxq->queue_id = queue_idx;
3245 [ # # ]: 0 : rxq->reg_idx = (uint16_t)((RTE_ETH_DEV_SRIOV(dev).active == 0) ?
3246 : 0 : queue_idx : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + queue_idx);
3247 : 0 : rxq->port_id = dev->data->port_id;
3248 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
3249 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
3250 : : else
3251 : 0 : rxq->crc_len = 0;
3252 : 0 : rxq->drop_en = rx_conf->rx_drop_en;
3253 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
3254 : 0 : rxq->offloads = offloads;
3255 : :
3256 : : /*
3257 : : * The packet type in RX descriptor is different for different NICs.
3258 : : * Some bits are used for x550 but reserved for other NICS.
3259 : : * So set different masks for different NICs.
3260 : : */
3261 : 0 : if (hw->mac.type == ixgbe_mac_X550 ||
3262 : : hw->mac.type == ixgbe_mac_X550EM_x ||
3263 : : hw->mac.type == ixgbe_mac_X550EM_a ||
3264 : : hw->mac.type == ixgbe_mac_X550_vf ||
3265 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x_vf ||
3266 : : hw->mac.type == ixgbe_mac_X550EM_a_vf)
3267 : 0 : rxq->pkt_type_mask = IXGBE_PACKET_TYPE_MASK_X550;
3268 : : else
3269 : 0 : rxq->pkt_type_mask = IXGBE_PACKET_TYPE_MASK_82599;
3270 : :
3271 : : /*
3272 : : * 82599 errata, UDP frames with a 0 checksum can be marked as checksum
3273 : : * errors.
3274 : : */
3275 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB)
3276 : 0 : rxq->rx_udp_csum_zero_err = 1;
3277 : :
3278 : : /*
3279 : : * Allocate RX ring hardware descriptors. A memzone large enough to
3280 : : * handle the maximum ring size is allocated in order to allow for
3281 : : * resizing in later calls to the queue setup function.
3282 : : */
3283 : 0 : rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
3284 : : RX_RING_SZ, IXGBE_ALIGN, socket_id);
3285 [ # # ]: 0 : if (rz == NULL) {
3286 : 0 : ixgbe_rx_queue_release(rxq);
3287 : 0 : return -ENOMEM;
3288 : : }
3289 : :
3290 : 0 : rxq->mz = rz;
3291 : : /*
3292 : : * Zero init all the descriptors in the ring.
3293 : : */
3294 [ # # ]: 0 : memset(rz->addr, 0, RX_RING_SZ);
3295 : :
3296 : : /*
3297 : : * Modified to setup VFRDT for Virtual Function
3298 : : */
3299 : : if (ixgbe_is_vf(dev)) {
3300 : 0 : rxq->rdt_reg_addr =
3301 : 0 : IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDT(queue_idx));
3302 : 0 : rxq->rdh_reg_addr =
3303 : 0 : IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDH(queue_idx));
3304 : : } else {
3305 : 0 : rxq->rdt_reg_addr =
3306 [ # # ]: 0 : IXGBE_PCI_REG_ADDR(hw, IXGBE_RDT(rxq->reg_idx));
3307 : 0 : rxq->rdh_reg_addr =
3308 [ # # ]: 0 : IXGBE_PCI_REG_ADDR(hw, IXGBE_RDH(rxq->reg_idx));
3309 : : }
3310 : :
3311 : 0 : rxq->rx_ring_phys_addr = rz->iova;
3312 : 0 : rxq->rx_ring = (union ixgbe_adv_rx_desc *) rz->addr;
3313 : :
3314 : : /*
3315 : : * Certain constraints must be met in order to use the bulk buffer
3316 : : * allocation Rx burst function. If any of Rx queues doesn't meet them
3317 : : * the feature should be disabled for the whole port.
3318 : : */
3319 [ # # ]: 0 : if (check_rx_burst_bulk_alloc_preconditions(rxq)) {
3320 : 0 : PMD_INIT_LOG(DEBUG, "queue[%d] doesn't meet Rx Bulk Alloc "
3321 : : "preconditions - canceling the feature for "
3322 : : "the whole port[%d]",
3323 : : rxq->queue_id, rxq->port_id);
3324 : 0 : adapter->rx_bulk_alloc_allowed = false;
3325 : : }
3326 : :
3327 : : /*
3328 : : * Allocate software ring. Allow for space at the end of the
3329 : : * S/W ring to make sure look-ahead logic in bulk alloc Rx burst
3330 : : * function does not access an invalid memory region.
3331 : : */
3332 : : len = nb_desc;
3333 [ # # ]: 0 : if (adapter->rx_bulk_alloc_allowed)
3334 : 0 : len += RTE_PMD_IXGBE_RX_MAX_BURST;
3335 : :
3336 : 0 : rxq->sw_ring = rte_zmalloc_socket("rxq->sw_ring",
3337 : : sizeof(struct ixgbe_rx_entry) * len,
3338 : : RTE_CACHE_LINE_SIZE, socket_id);
3339 [ # # ]: 0 : if (!rxq->sw_ring) {
3340 : 0 : ixgbe_rx_queue_release(rxq);
3341 : 0 : return -ENOMEM;
3342 : : }
3343 : :
3344 : : /*
3345 : : * Always allocate even if it's not going to be needed in order to
3346 : : * simplify the code.
3347 : : *
3348 : : * This ring is used in LRO and Scattered Rx cases and Scattered Rx may
3349 : : * be requested in ixgbe_dev_rx_init(), which is called later from
3350 : : * dev_start() flow.
3351 : : */
3352 : 0 : rxq->sw_sc_ring =
3353 : 0 : rte_zmalloc_socket("rxq->sw_sc_ring",
3354 : : sizeof(struct ixgbe_scattered_rx_entry) * len,
3355 : : RTE_CACHE_LINE_SIZE, socket_id);
3356 [ # # ]: 0 : if (!rxq->sw_sc_ring) {
3357 : 0 : ixgbe_rx_queue_release(rxq);
3358 : 0 : return -ENOMEM;
3359 : : }
3360 : :
3361 : 0 : PMD_INIT_LOG(DEBUG, "sw_ring=%p sw_sc_ring=%p hw_ring=%p "
3362 : : "dma_addr=0x%"PRIx64,
3363 : : rxq->sw_ring, rxq->sw_sc_ring, rxq->rx_ring,
3364 : : rxq->rx_ring_phys_addr);
3365 : :
3366 [ # # ]: 0 : if (!rte_is_power_of_2(nb_desc)) {
3367 : 0 : PMD_INIT_LOG(DEBUG, "queue[%d] doesn't meet Vector Rx "
3368 : : "preconditions - canceling the feature for "
3369 : : "the whole port[%d]",
3370 : : rxq->queue_id, rxq->port_id);
3371 : 0 : adapter->rx_vec_allowed = false;
3372 : : } else
3373 : 0 : ixgbe_rxq_vec_setup(rxq);
3374 : :
3375 : 0 : dev->data->rx_queues[queue_idx] = rxq;
3376 : :
3377 : 0 : ixgbe_reset_rx_queue(adapter, rxq);
3378 : :
3379 : 0 : return 0;
3380 : : }
3381 : :
3382 : : uint32_t
3383 : 0 : ixgbe_dev_rx_queue_count(void *rx_queue)
3384 : : {
3385 : : #define IXGBE_RXQ_SCAN_INTERVAL 4
3386 : : volatile union ixgbe_adv_rx_desc *rxdp;
3387 : : struct ixgbe_rx_queue *rxq;
3388 : : uint32_t desc = 0;
3389 : :
3390 : : rxq = rx_queue;
3391 : 0 : rxdp = &(rxq->rx_ring[rxq->rx_tail]);
3392 : :
3393 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
3394 [ # # ]: 0 : (rxdp->wb.upper.status_error &
3395 : : rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) {
3396 : 0 : desc += IXGBE_RXQ_SCAN_INTERVAL;
3397 : 0 : rxdp += IXGBE_RXQ_SCAN_INTERVAL;
3398 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
3399 : 0 : rxdp = &(rxq->rx_ring[rxq->rx_tail +
3400 : 0 : desc - rxq->nb_rx_desc]);
3401 : : }
3402 : :
3403 : 0 : return desc;
3404 : : }
3405 : :
3406 : : int
3407 : 0 : ixgbe_dev_rx_descriptor_status(void *rx_queue, uint16_t offset)
3408 : : {
3409 : : struct ixgbe_rx_queue *rxq = rx_queue;
3410 : : volatile uint32_t *status;
3411 : : uint32_t nb_hold, desc;
3412 : :
3413 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
3414 : : return -EINVAL;
3415 : :
3416 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3417 [ # # ]: 0 : if (rxq->rx_using_sse)
3418 : 0 : nb_hold = rxq->rxrearm_nb;
3419 : : else
3420 : : #endif
3421 : 0 : nb_hold = rxq->nb_rx_hold;
3422 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - nb_hold)
3423 : : return RTE_ETH_RX_DESC_UNAVAIL;
3424 : :
3425 : 0 : desc = rxq->rx_tail + offset;
3426 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
3427 : 0 : desc -= rxq->nb_rx_desc;
3428 : :
3429 : 0 : status = &rxq->rx_ring[desc].wb.upper.status_error;
3430 [ # # ]: 0 : if (*status & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))
3431 : 0 : return RTE_ETH_RX_DESC_DONE;
3432 : :
3433 : : return RTE_ETH_RX_DESC_AVAIL;
3434 : : }
3435 : :
3436 : : int
3437 : 0 : ixgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
3438 : : {
3439 : : struct ci_tx_queue *txq = tx_queue;
3440 : : volatile uint32_t *status;
3441 : : uint32_t desc;
3442 : :
3443 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
3444 : : return -EINVAL;
3445 : :
3446 : 0 : desc = txq->tx_tail + offset;
3447 : : /* go to next desc that has the RS bit */
3448 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
3449 : : txq->tx_rs_thresh;
3450 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
3451 : 0 : desc -= txq->nb_tx_desc;
3452 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
3453 : 0 : desc -= txq->nb_tx_desc;
3454 : : }
3455 : :
3456 : 0 : status = &txq->ixgbe_tx_ring[desc].wb.status;
3457 [ # # ]: 0 : if (*status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))
3458 : 0 : return RTE_ETH_TX_DESC_DONE;
3459 : :
3460 : : return RTE_ETH_TX_DESC_FULL;
3461 : : }
3462 : :
3463 : : /*
3464 : : * Set up link loopback for X540/X550 mode Tx->Rx.
3465 : : */
3466 : : static inline void __rte_cold
3467 : 0 : ixgbe_setup_loopback_link_x540_x550(struct ixgbe_hw *hw, bool enable)
3468 : : {
3469 : : uint32_t macc;
3470 : 0 : PMD_INIT_FUNC_TRACE();
3471 : :
3472 : 0 : u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
3473 : :
3474 : 0 : hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
3475 : : IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
3476 : 0 : macc = IXGBE_READ_REG(hw, IXGBE_MACC);
3477 : :
3478 [ # # ]: 0 : if (enable) {
3479 : : /* datasheet 15.2.1: disable AUTONEG (PHY Bit 7.0.C) */
3480 : 0 : autoneg_reg |= IXGBE_MII_AUTONEG_ENABLE;
3481 : : /* datasheet 15.2.1: MACC.FLU = 1 (force link up) */
3482 : 0 : macc |= IXGBE_MACC_FLU;
3483 : : } else {
3484 : 0 : autoneg_reg &= ~IXGBE_MII_AUTONEG_ENABLE;
3485 : 0 : macc &= ~IXGBE_MACC_FLU;
3486 : : }
3487 : :
3488 : 0 : hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
3489 : : IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
3490 : :
3491 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MACC, macc);
3492 : 0 : }
3493 : :
3494 : : void __rte_cold
3495 : 0 : ixgbe_dev_clear_queues(struct rte_eth_dev *dev)
3496 : : {
3497 : : unsigned i;
3498 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
3499 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3500 : :
3501 : 0 : PMD_INIT_FUNC_TRACE();
3502 : :
3503 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3504 : 0 : struct ci_tx_queue *txq = dev->data->tx_queues[i];
3505 : :
3506 [ # # ]: 0 : if (txq != NULL) {
3507 : 0 : ci_txq_release_all_mbufs(txq, false);
3508 : 0 : txq->ops->reset(txq);
3509 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
3510 : : }
3511 : : }
3512 : :
3513 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3514 : 0 : struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
3515 : :
3516 [ # # ]: 0 : if (rxq != NULL) {
3517 : 0 : ixgbe_rx_queue_release_mbufs(rxq);
3518 : 0 : ixgbe_reset_rx_queue(adapter, rxq);
3519 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
3520 : : }
3521 : : }
3522 : : /* If loopback mode was enabled, reconfigure the link accordingly */
3523 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode != 0) {
3524 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X540 ||
3525 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550 ||
3526 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
3527 : : hw->mac.type == ixgbe_mac_X550EM_a)
3528 : 0 : ixgbe_setup_loopback_link_x540_x550(hw, false);
3529 : : }
3530 : 0 : }
3531 : :
3532 : : void
3533 : 0 : ixgbe_dev_free_queues(struct rte_eth_dev *dev)
3534 : : {
3535 : : unsigned i;
3536 : :
3537 : 0 : PMD_INIT_FUNC_TRACE();
3538 : :
3539 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3540 : 0 : ixgbe_dev_rx_queue_release(dev, i);
3541 : 0 : dev->data->rx_queues[i] = NULL;
3542 : : }
3543 : 0 : dev->data->nb_rx_queues = 0;
3544 : :
3545 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3546 : 0 : ixgbe_dev_tx_queue_release(dev, i);
3547 : 0 : dev->data->tx_queues[i] = NULL;
3548 : : }
3549 : 0 : dev->data->nb_tx_queues = 0;
3550 : 0 : }
3551 : :
3552 : : /*********************************************************************
3553 : : *
3554 : : * Device RX/TX init functions
3555 : : *
3556 : : **********************************************************************/
3557 : :
3558 : : /**
3559 : : * Receive Side Scaling (RSS)
3560 : : * See section 7.1.2.8 in the following document:
3561 : : * "Intel 82599 10 GbE Controller Datasheet" - Revision 2.1 October 2009
3562 : : *
3563 : : * Principles:
3564 : : * The source and destination IP addresses of the IP header and the source
3565 : : * and destination ports of TCP/UDP headers, if any, of received packets are
3566 : : * hashed against a configurable random key to compute a 32-bit RSS hash result.
3567 : : * The seven (7) LSBs of the 32-bit hash result are used as an index into a
3568 : : * 128-entry redirection table (RETA). Each entry of the RETA provides a 3-bit
3569 : : * RSS output index which is used as the RX queue index where to store the
3570 : : * received packets.
3571 : : * The following output is supplied in the RX write-back descriptor:
3572 : : * - 32-bit result of the Microsoft RSS hash function,
3573 : : * - 4-bit RSS type field.
3574 : : */
3575 : :
3576 : : /*
3577 : : * RSS random key supplied in section 7.1.2.8.3 of the Intel 82599 datasheet.
3578 : : * Used as the default key.
3579 : : */
3580 : : static uint8_t rss_intel_key[40] = {
3581 : : 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
3582 : : 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
3583 : : 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
3584 : : 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
3585 : : 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
3586 : : };
3587 : :
3588 : : /*
3589 : : * This function removes the rss configuration in the mrqe field of MRQC
3590 : : * register and tries to maintain other configurations in the field, such
3591 : : * DCB and Virtualization.
3592 : : *
3593 : : * The MRQC register supplied in section 8.2.3.7.12 of the Intel 82599
3594 : : * datasheet. From the datasheet, we know that the mrqe field is an enum. So,
3595 : : * masking the mrqe field with '~IXGBE_MRQC_RSSEN' may not completely disable
3596 : : * rss configuration. For example, the value of mrqe is equal to 0101b when DCB
3597 : : * and RSS with 4 TCs configured, however 'mrqe &= ~0x01' is equal to 0100b
3598 : : * which corresponds to DCB and RSS with 8 TCs.
3599 : : */
3600 : : static void
3601 : 0 : ixgbe_mrqc_rss_remove(struct ixgbe_hw *hw)
3602 : : {
3603 : : uint32_t mrqc;
3604 : : uint32_t mrqc_reg;
3605 : : uint32_t mrqe_val;
3606 : :
3607 : 0 : mrqc_reg = ixgbe_mrqc_reg_get(hw->mac.type);
3608 : 0 : mrqc = IXGBE_READ_REG(hw, mrqc_reg);
3609 : 0 : mrqe_val = mrqc & IXGBE_MRQC_MRQE_MASK;
3610 : :
3611 [ # # # # : 0 : switch (mrqe_val) {
# # ]
3612 : 0 : case IXGBE_MRQC_RSSEN:
3613 : : /* Completely disable rss */
3614 : : mrqe_val = 0;
3615 : 0 : break;
3616 : 0 : case IXGBE_MRQC_RTRSS8TCEN:
3617 : : mrqe_val = IXGBE_MRQC_RT8TCEN;
3618 : 0 : break;
3619 : 0 : case IXGBE_MRQC_RTRSS4TCEN:
3620 : : mrqe_val = IXGBE_MRQC_RT4TCEN;
3621 : 0 : break;
3622 : 0 : case IXGBE_MRQC_VMDQRSS64EN:
3623 : : mrqe_val = IXGBE_MRQC_VMDQEN;
3624 : 0 : break;
3625 : 0 : case IXGBE_MRQC_VMDQRSS32EN:
3626 : 0 : PMD_DRV_LOG(WARNING, "There is no regression for virtualization"
3627 : : " and RSS with 32 pools among the MRQE configurations"
3628 : : " after removing RSS, and left it unchanged.");
3629 : 0 : break;
3630 : : default:
3631 : : /* No rss configured, leave it as it is */
3632 : : break;
3633 : : }
3634 : 0 : mrqc = (mrqc & ~IXGBE_MRQC_MRQE_MASK) | mrqe_val;
3635 : 0 : IXGBE_WRITE_REG(hw, mrqc_reg, mrqc);
3636 : 0 : }
3637 : :
3638 : : static void
3639 : : ixgbe_rss_disable(struct rte_eth_dev *dev)
3640 : : {
3641 : : struct ixgbe_hw *hw;
3642 : :
3643 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3644 : : /* Remove the rss configuration and maintain the other configurations */
3645 : 0 : ixgbe_mrqc_rss_remove(hw);
3646 : 0 : }
3647 : :
3648 : : /*
3649 : : * This function checks whether the rss is enabled or not by comparing the mrqe
3650 : : * field with some RSS related enums and also considers the configurations for
3651 : : * DCB + RSS and Virtualization + RSS. It is necessary for getting the correct
3652 : : * rss hash configurations from the RSS Field Enable field of MRQC register
3653 : : * when both RSS and DCB/VMDQ are used.
3654 : : */
3655 : : static bool
3656 : 0 : ixgbe_rss_enabled(struct ixgbe_hw *hw)
3657 : : {
3658 : : uint32_t mrqc;
3659 : : uint32_t mrqc_reg;
3660 : : uint32_t mrqe_val;
3661 : :
3662 : 0 : mrqc_reg = ixgbe_mrqc_reg_get(hw->mac.type);
3663 : 0 : mrqc = IXGBE_READ_REG(hw, mrqc_reg);
3664 : 0 : mrqe_val = mrqc & IXGBE_MRQC_MRQE_MASK;
3665 : :
3666 : 0 : if (mrqe_val == IXGBE_MRQC_RSSEN ||
3667 [ # # ]: 0 : mrqe_val == IXGBE_MRQC_RTRSS8TCEN ||
3668 : 0 : mrqe_val == IXGBE_MRQC_RTRSS4TCEN ||
3669 [ # # # # ]: 0 : mrqe_val == IXGBE_MRQC_VMDQRSS64EN ||
3670 : : mrqe_val == IXGBE_MRQC_VMDQRSS32EN)
3671 : 0 : return true;
3672 : :
3673 : : return false;
3674 : : }
3675 : :
3676 : : static void
3677 : 0 : ixgbe_hw_rss_hash_set(struct ixgbe_hw *hw, struct rte_eth_rss_conf *rss_conf)
3678 : : {
3679 : : uint8_t *hash_key;
3680 : : uint32_t mrqc;
3681 : : uint32_t rss_key;
3682 : : uint64_t rss_hf;
3683 : : uint16_t i;
3684 : : uint32_t mrqc_reg;
3685 : : uint32_t rssrk_reg;
3686 : :
3687 : 0 : mrqc_reg = ixgbe_mrqc_reg_get(hw->mac.type);
3688 : 0 : rssrk_reg = ixgbe_rssrk_reg_get(hw->mac.type, 0);
3689 : :
3690 : 0 : hash_key = rss_conf->rss_key;
3691 [ # # ]: 0 : if (hash_key != NULL) {
3692 : : /* Fill in RSS hash key */
3693 [ # # ]: 0 : for (i = 0; i < 10; i++) {
3694 : 0 : rss_key = hash_key[(i * 4)];
3695 : 0 : rss_key |= hash_key[(i * 4) + 1] << 8;
3696 : 0 : rss_key |= hash_key[(i * 4) + 2] << 16;
3697 : 0 : rss_key |= hash_key[(i * 4) + 3] << 24;
3698 : 0 : IXGBE_WRITE_REG_ARRAY(hw, rssrk_reg, i, rss_key);
3699 : : }
3700 : : }
3701 : :
3702 : : /* Set configured hashing protocols in MRQC register */
3703 : 0 : rss_hf = rss_conf->rss_hf;
3704 : : mrqc = IXGBE_MRQC_RSSEN; /* Enable RSS */
3705 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV4)
3706 : : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4;
3707 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP)
3708 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_TCP;
3709 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6)
3710 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6;
3711 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_EX)
3712 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX;
3713 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP)
3714 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_TCP;
3715 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX)
3716 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP;
3717 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP)
3718 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
3719 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP)
3720 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
3721 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_UDP_EX)
3722 : 0 : mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP;
3723 : 0 : IXGBE_WRITE_REG(hw, mrqc_reg, mrqc);
3724 : 0 : }
3725 : :
3726 : : int
3727 : 0 : ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
3728 : : struct rte_eth_rss_conf *rss_conf)
3729 : : {
3730 : : struct ixgbe_hw *hw;
3731 : : uint64_t rss_hf;
3732 : :
3733 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3734 : :
3735 [ # # ]: 0 : if (!ixgbe_rss_update_sp(hw->mac.type)) {
3736 : 0 : PMD_DRV_LOG(ERR, "RSS hash update is not supported on this "
3737 : : "NIC.");
3738 : 0 : return -ENOTSUP;
3739 : : }
3740 : :
3741 : : /*
3742 : : * Excerpt from section 7.1.2.8 Receive-Side Scaling (RSS):
3743 : : * "RSS enabling cannot be done dynamically while it must be
3744 : : * preceded by a software reset"
3745 : : * Before changing anything, first check that the update RSS operation
3746 : : * does not attempt to disable RSS, if RSS was enabled at
3747 : : * initialization time, or does not attempt to enable RSS, if RSS was
3748 : : * disabled at initialization time.
3749 : : */
3750 : 0 : rss_hf = rss_conf->rss_hf & IXGBE_RSS_OFFLOAD_ALL;
3751 [ # # ]: 0 : if (!ixgbe_rss_enabled(hw)) { /* RSS disabled */
3752 [ # # ]: 0 : if (rss_hf != 0) /* Enable RSS */
3753 : : return -(EINVAL);
3754 : 0 : return 0; /* Nothing to do */
3755 : : }
3756 : : /* RSS enabled */
3757 [ # # ]: 0 : if (rss_hf == 0) /* Disable RSS */
3758 : : return -(EINVAL);
3759 : 0 : ixgbe_hw_rss_hash_set(hw, rss_conf);
3760 : 0 : return 0;
3761 : : }
3762 : :
3763 : : int
3764 : 0 : ixgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
3765 : : struct rte_eth_rss_conf *rss_conf)
3766 : : {
3767 : : struct ixgbe_hw *hw;
3768 : : uint8_t *hash_key;
3769 : : uint32_t mrqc;
3770 : : uint32_t rss_key;
3771 : : uint64_t rss_hf;
3772 : : uint16_t i;
3773 : : uint32_t mrqc_reg;
3774 : : uint32_t rssrk_reg;
3775 : :
3776 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3777 : 0 : mrqc_reg = ixgbe_mrqc_reg_get(hw->mac.type);
3778 : 0 : rssrk_reg = ixgbe_rssrk_reg_get(hw->mac.type, 0);
3779 : 0 : hash_key = rss_conf->rss_key;
3780 [ # # ]: 0 : if (hash_key != NULL) {
3781 : : /* Return RSS hash key */
3782 [ # # ]: 0 : for (i = 0; i < 10; i++) {
3783 : 0 : rss_key = IXGBE_READ_REG_ARRAY(hw, rssrk_reg, i);
3784 : 0 : hash_key[(i * 4)] = rss_key & 0x000000FF;
3785 : 0 : hash_key[(i * 4) + 1] = (rss_key >> 8) & 0x000000FF;
3786 : 0 : hash_key[(i * 4) + 2] = (rss_key >> 16) & 0x000000FF;
3787 : 0 : hash_key[(i * 4) + 3] = (rss_key >> 24) & 0x000000FF;
3788 : : }
3789 : : }
3790 : :
3791 [ # # ]: 0 : if (!ixgbe_rss_enabled(hw)) { /* RSS is disabled */
3792 : 0 : rss_conf->rss_hf = 0;
3793 : 0 : return 0;
3794 : : }
3795 : :
3796 : : /* Get RSS functions configured in MRQC register */
3797 : 0 : mrqc = IXGBE_READ_REG(hw, mrqc_reg);
3798 : :
3799 : : rss_hf = 0;
3800 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV4)
3801 : : rss_hf |= RTE_ETH_RSS_IPV4;
3802 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV4_TCP)
3803 : 0 : rss_hf |= RTE_ETH_RSS_NONFRAG_IPV4_TCP;
3804 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6)
3805 : 0 : rss_hf |= RTE_ETH_RSS_IPV6;
3806 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6_EX)
3807 : 0 : rss_hf |= RTE_ETH_RSS_IPV6_EX;
3808 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6_TCP)
3809 : 0 : rss_hf |= RTE_ETH_RSS_NONFRAG_IPV6_TCP;
3810 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP)
3811 : 0 : rss_hf |= RTE_ETH_RSS_IPV6_TCP_EX;
3812 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV4_UDP)
3813 : 0 : rss_hf |= RTE_ETH_RSS_NONFRAG_IPV4_UDP;
3814 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6_UDP)
3815 : 0 : rss_hf |= RTE_ETH_RSS_NONFRAG_IPV6_UDP;
3816 [ # # ]: 0 : if (mrqc & IXGBE_MRQC_RSS_FIELD_IPV6_EX_UDP)
3817 : 0 : rss_hf |= RTE_ETH_RSS_IPV6_UDP_EX;
3818 : 0 : rss_conf->rss_hf = rss_hf;
3819 : 0 : return 0;
3820 : : }
3821 : :
3822 : : static void
3823 : 0 : ixgbe_rss_configure(struct rte_eth_dev *dev)
3824 : : {
3825 : : struct rte_eth_rss_conf rss_conf;
3826 : : struct ixgbe_adapter *adapter;
3827 : : struct ixgbe_hw *hw;
3828 : : uint32_t reta;
3829 : : uint16_t i;
3830 : : uint16_t j;
3831 : : uint16_t sp_reta_size;
3832 : : uint32_t reta_reg;
3833 : :
3834 : 0 : PMD_INIT_FUNC_TRACE();
3835 : 0 : adapter = dev->data->dev_private;
3836 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3837 : :
3838 : 0 : sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
3839 : :
3840 : : /*
3841 : : * Fill in redirection table
3842 : : * The byte-swap is needed because NIC registers are in
3843 : : * little-endian order.
3844 : : */
3845 [ # # ]: 0 : if (adapter->rss_reta_updated == 0) {
3846 : : reta = 0;
3847 [ # # ]: 0 : for (i = 0, j = 0; i < sp_reta_size; i++, j++) {
3848 : 0 : reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
3849 : :
3850 [ # # ]: 0 : if (j == dev->data->nb_rx_queues)
3851 : : j = 0;
3852 : 0 : reta = (reta << 8) | j;
3853 [ # # ]: 0 : if ((i & 3) == 3)
3854 [ # # ]: 0 : IXGBE_WRITE_REG(hw, reta_reg,
3855 : : rte_bswap32(reta));
3856 : : }
3857 : : }
3858 : :
3859 : : /*
3860 : : * Configure the RSS key and the RSS protocols used to compute
3861 : : * the RSS hash of input packets.
3862 : : */
3863 : 0 : rss_conf = dev->data->dev_conf.rx_adv_conf.rss_conf;
3864 [ # # ]: 0 : if ((rss_conf.rss_hf & IXGBE_RSS_OFFLOAD_ALL) == 0) {
3865 : : ixgbe_rss_disable(dev);
3866 : 0 : return;
3867 : : }
3868 [ # # ]: 0 : if (rss_conf.rss_key == NULL)
3869 : 0 : rss_conf.rss_key = rss_intel_key; /* Default hash key */
3870 : 0 : ixgbe_hw_rss_hash_set(hw, &rss_conf);
3871 : : }
3872 : :
3873 : : #define NUM_VFTA_REGISTERS 128
3874 : : #define NIC_RX_BUFFER_SIZE 0x200
3875 : : #define X550_RX_BUFFER_SIZE 0x180
3876 : :
3877 : : static void
3878 : 0 : ixgbe_vmdq_dcb_configure(struct rte_eth_dev *dev)
3879 : : {
3880 : : struct rte_eth_vmdq_dcb_conf *cfg;
3881 : : struct ixgbe_hw *hw;
3882 : : enum rte_eth_nb_pools num_pools;
3883 : : uint32_t mrqc, vt_ctl, queue_mapping, vlanctrl;
3884 : : uint16_t pbsize;
3885 : : uint8_t nb_tcs; /* number of traffic classes */
3886 : : int i;
3887 : :
3888 : 0 : PMD_INIT_FUNC_TRACE();
3889 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3890 : : cfg = &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
3891 : 0 : num_pools = cfg->nb_queue_pools;
3892 : : /* Check we have a valid number of pools */
3893 [ # # ]: 0 : if (num_pools != RTE_ETH_16_POOLS && num_pools != RTE_ETH_32_POOLS) {
3894 : : ixgbe_rss_disable(dev);
3895 : 0 : return;
3896 : : }
3897 : : /* 16 pools -> 8 traffic classes, 32 pools -> 4 traffic classes */
3898 : 0 : nb_tcs = (uint8_t)(RTE_ETH_VMDQ_DCB_NUM_QUEUES / (int)num_pools);
3899 : :
3900 : : /*
3901 : : * RXPBSIZE
3902 : : * split rx buffer up into sections, each for 1 traffic class
3903 : : */
3904 [ # # ]: 0 : switch (hw->mac.type) {
3905 : 0 : case ixgbe_mac_X550:
3906 : : case ixgbe_mac_X550EM_x:
3907 : : case ixgbe_mac_X550EM_a:
3908 : 0 : pbsize = (uint16_t)(X550_RX_BUFFER_SIZE / nb_tcs);
3909 : 0 : break;
3910 : 0 : default:
3911 : 0 : pbsize = (uint16_t)(NIC_RX_BUFFER_SIZE / nb_tcs);
3912 : 0 : break;
3913 : : }
3914 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
3915 : 0 : uint32_t rxpbsize = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
3916 : :
3917 : 0 : rxpbsize &= (~(0x3FF << IXGBE_RXPBSIZE_SHIFT));
3918 : : /* clear 10 bits. */
3919 : 0 : rxpbsize |= (pbsize << IXGBE_RXPBSIZE_SHIFT); /* set value */
3920 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpbsize);
3921 : : }
3922 : : /* zero alloc all unused TCs */
3923 [ # # ]: 0 : for (i = nb_tcs; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
3924 : 0 : uint32_t rxpbsize = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
3925 : :
3926 : 0 : rxpbsize &= (~(0x3FF << IXGBE_RXPBSIZE_SHIFT));
3927 : : /* clear 10 bits. */
3928 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpbsize);
3929 : : }
3930 : :
3931 : : /* MRQC: enable vmdq and dcb */
3932 : : mrqc = (num_pools == RTE_ETH_16_POOLS) ?
3933 [ # # ]: 0 : IXGBE_MRQC_VMDQRT8TCEN : IXGBE_MRQC_VMDQRT4TCEN;
3934 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
3935 : :
3936 : : /* PFVTCTL: turn on virtualisation and set the default pool */
3937 : : vt_ctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
3938 [ # # ]: 0 : if (cfg->enable_default_pool) {
3939 : 0 : vt_ctl |= (cfg->default_pool << IXGBE_VT_CTL_POOL_SHIFT);
3940 : : } else {
3941 : : vt_ctl |= IXGBE_VT_CTL_DIS_DEFPL;
3942 : : }
3943 : :
3944 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vt_ctl);
3945 : :
3946 : : /* RTRUP2TC: mapping user priorities to traffic classes (TCs) */
3947 : : queue_mapping = 0;
3948 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
3949 : : /*
3950 : : * mapping is done with 3 bits per priority,
3951 : : * so shift by i*3 each time
3952 : : */
3953 : 0 : queue_mapping |= ((cfg->dcb_tc[i] & 0x07) << (i * 3));
3954 : :
3955 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTRUP2TC, queue_mapping);
3956 : :
3957 : : /* RTRPCS: DCB related */
3958 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, IXGBE_RMCS_RRM);
3959 : :
3960 : : /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
3961 : 0 : vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
3962 : 0 : vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
3963 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
3964 : :
3965 : : /* VFTA - enable all vlan filters */
3966 [ # # ]: 0 : for (i = 0; i < NUM_VFTA_REGISTERS; i++) {
3967 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), 0xFFFFFFFF);
3968 : : }
3969 : :
3970 : : /* VFRE: pool enabling for receive - 16 or 32 */
3971 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(0),
3972 : : num_pools == RTE_ETH_16_POOLS ? 0xFFFF : 0xFFFFFFFF);
3973 : :
3974 : : /*
3975 : : * MPSAR - allow pools to read specific mac addresses
3976 : : * In this case, all pools should be able to read from mac addr 0
3977 : : */
3978 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(0), 0xFFFFFFFF);
3979 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(0), 0xFFFFFFFF);
3980 : :
3981 : : /* PFVLVF, PFVLVFB: set up filters for vlan tags as configured */
3982 [ # # ]: 0 : for (i = 0; i < cfg->nb_pool_maps; i++) {
3983 : : /* set vlan id in VF register and set the valid bit */
3984 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLVF(i), (IXGBE_VLVF_VIEN |
3985 : : (cfg->pool_map[i].vlan_id & 0xFFF)));
3986 : : /*
3987 : : * Put the allowed pools in VFB reg. As we only have 16 or 32
3988 : : * pools, we only need to use the first half of the register
3989 : : * i.e. bits 0-31
3990 : : */
3991 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLVFB(i*2), cfg->pool_map[i].pools);
3992 : : }
3993 : : }
3994 : :
3995 : : /**
3996 : : * ixgbe_dcb_config_tx_hw_config - Configure general DCB TX parameters
3997 : : * @dev: pointer to eth_dev structure
3998 : : * @dcb_config: pointer to ixgbe_dcb_config structure
3999 : : */
4000 : : static void
4001 : 0 : ixgbe_dcb_tx_hw_config(struct rte_eth_dev *dev,
4002 : : struct ixgbe_dcb_config *dcb_config)
4003 : : {
4004 : : uint32_t reg;
4005 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4006 : :
4007 : 0 : PMD_INIT_FUNC_TRACE();
4008 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
4009 : : /* Disable the Tx desc arbiter so that MTQC can be changed */
4010 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
4011 : 0 : reg |= IXGBE_RTTDCS_ARBDIS;
4012 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
4013 : :
4014 : : /* Enable DCB for Tx with 8 TCs */
4015 [ # # ]: 0 : if (dcb_config->num_tcs.pg_tcs == 8) {
4016 : : reg = IXGBE_MTQC_RT_ENA | IXGBE_MTQC_8TC_8TQ;
4017 : : } else {
4018 : : reg = IXGBE_MTQC_RT_ENA | IXGBE_MTQC_4TC_4TQ;
4019 : : }
4020 [ # # ]: 0 : if (dcb_config->vt_mode)
4021 : 0 : reg |= IXGBE_MTQC_VT_ENA;
4022 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MTQC, reg);
4023 : :
4024 : : /* Enable the Tx desc arbiter */
4025 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
4026 : 0 : reg &= ~IXGBE_RTTDCS_ARBDIS;
4027 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
4028 : :
4029 : : /* Enable Security TX Buffer IFG for DCB */
4030 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
4031 : 0 : reg |= IXGBE_SECTX_DCB;
4032 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, reg);
4033 : : }
4034 : 0 : }
4035 : :
4036 : : /**
4037 : : * ixgbe_vmdq_dcb_hw_tx_config - Configure general VMDQ+DCB TX parameters
4038 : : * @dev: pointer to rte_eth_dev structure
4039 : : * @dcb_config: pointer to ixgbe_dcb_config structure
4040 : : */
4041 : : static void
4042 : 0 : ixgbe_vmdq_dcb_hw_tx_config(struct rte_eth_dev *dev,
4043 : : struct ixgbe_dcb_config *dcb_config)
4044 : : {
4045 : : struct rte_eth_vmdq_dcb_tx_conf *vmdq_tx_conf =
4046 : 0 : &dev->data->dev_conf.tx_adv_conf.vmdq_dcb_tx_conf;
4047 : : struct ixgbe_hw *hw =
4048 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4049 : :
4050 : 0 : PMD_INIT_FUNC_TRACE();
4051 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB)
4052 : : /*PF VF Transmit Enable*/
4053 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(0),
4054 : : vmdq_tx_conf->nb_queue_pools == RTE_ETH_16_POOLS ? 0xFFFF : 0xFFFFFFFF);
4055 : :
4056 : : /*Configure general DCB TX parameters*/
4057 : 0 : ixgbe_dcb_tx_hw_config(dev, dcb_config);
4058 : 0 : }
4059 : :
4060 : : static void
4061 : 0 : ixgbe_vmdq_dcb_rx_config(struct rte_eth_dev *dev,
4062 : : struct ixgbe_dcb_config *dcb_config)
4063 : : {
4064 : : struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
4065 : 0 : &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
4066 : : struct ixgbe_dcb_tc_config *tc;
4067 : : uint8_t i, j;
4068 : :
4069 : : /* convert rte_eth_conf.rx_adv_conf to struct ixgbe_dcb_config */
4070 [ # # ]: 0 : if (vmdq_rx_conf->nb_queue_pools == RTE_ETH_16_POOLS) {
4071 : 0 : dcb_config->num_tcs.pg_tcs = RTE_ETH_8_TCS;
4072 : 0 : dcb_config->num_tcs.pfc_tcs = RTE_ETH_8_TCS;
4073 : : } else {
4074 : 0 : dcb_config->num_tcs.pg_tcs = RTE_ETH_4_TCS;
4075 : 0 : dcb_config->num_tcs.pfc_tcs = RTE_ETH_4_TCS;
4076 : : }
4077 : :
4078 : : /* Initialize User Priority to Traffic Class mapping */
4079 [ # # ]: 0 : for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
4080 : 0 : tc = &dcb_config->tc_config[j];
4081 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0;
4082 : : }
4083 : :
4084 : : /* User Priority to Traffic Class mapping */
4085 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
4086 : 0 : j = vmdq_rx_conf->dcb_tc[i];
4087 : 0 : tc = &dcb_config->tc_config[j];
4088 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap |=
4089 : 0 : (uint8_t)(1 << i);
4090 : : }
4091 : 0 : }
4092 : :
4093 : : static void
4094 : 0 : ixgbe_dcb_vt_tx_config(struct rte_eth_dev *dev,
4095 : : struct ixgbe_dcb_config *dcb_config)
4096 : : {
4097 : : struct rte_eth_vmdq_dcb_tx_conf *vmdq_tx_conf =
4098 : 0 : &dev->data->dev_conf.tx_adv_conf.vmdq_dcb_tx_conf;
4099 : : struct ixgbe_dcb_tc_config *tc;
4100 : : uint8_t i, j;
4101 : :
4102 : : /* convert rte_eth_conf.rx_adv_conf to struct ixgbe_dcb_config */
4103 [ # # ]: 0 : if (vmdq_tx_conf->nb_queue_pools == RTE_ETH_16_POOLS) {
4104 : 0 : dcb_config->num_tcs.pg_tcs = RTE_ETH_8_TCS;
4105 : 0 : dcb_config->num_tcs.pfc_tcs = RTE_ETH_8_TCS;
4106 : : } else {
4107 : 0 : dcb_config->num_tcs.pg_tcs = RTE_ETH_4_TCS;
4108 : 0 : dcb_config->num_tcs.pfc_tcs = RTE_ETH_4_TCS;
4109 : : }
4110 : :
4111 : : /* Initialize User Priority to Traffic Class mapping */
4112 [ # # ]: 0 : for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
4113 : 0 : tc = &dcb_config->tc_config[j];
4114 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0;
4115 : : }
4116 : :
4117 : : /* User Priority to Traffic Class mapping */
4118 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
4119 : 0 : j = vmdq_tx_conf->dcb_tc[i];
4120 : 0 : tc = &dcb_config->tc_config[j];
4121 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap |=
4122 : 0 : (uint8_t)(1 << i);
4123 : : }
4124 : 0 : }
4125 : :
4126 : : static void
4127 : : ixgbe_dcb_rx_config(struct rte_eth_dev *dev,
4128 : : struct ixgbe_dcb_config *dcb_config)
4129 : : {
4130 : : struct rte_eth_dcb_rx_conf *rx_conf =
4131 : : &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
4132 : : struct ixgbe_dcb_tc_config *tc;
4133 : : uint8_t i, j;
4134 : :
4135 : 0 : dcb_config->num_tcs.pg_tcs = (uint8_t)rx_conf->nb_tcs;
4136 : 0 : dcb_config->num_tcs.pfc_tcs = (uint8_t)rx_conf->nb_tcs;
4137 : :
4138 : : /* Initialize User Priority to Traffic Class mapping */
4139 [ # # ]: 0 : for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
4140 : 0 : tc = &dcb_config->tc_config[j];
4141 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0;
4142 : : }
4143 : :
4144 : : /* User Priority to Traffic Class mapping */
4145 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
4146 : 0 : j = rx_conf->dcb_tc[i];
4147 : 0 : tc = &dcb_config->tc_config[j];
4148 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap |=
4149 : 0 : (uint8_t)(1 << i);
4150 : : }
4151 : : }
4152 : :
4153 : : static void
4154 : : ixgbe_dcb_tx_config(struct rte_eth_dev *dev,
4155 : : struct ixgbe_dcb_config *dcb_config)
4156 : : {
4157 : : struct rte_eth_dcb_tx_conf *tx_conf =
4158 : : &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf;
4159 : : struct ixgbe_dcb_tc_config *tc;
4160 : : uint8_t i, j;
4161 : :
4162 : 0 : dcb_config->num_tcs.pg_tcs = (uint8_t)tx_conf->nb_tcs;
4163 : 0 : dcb_config->num_tcs.pfc_tcs = (uint8_t)tx_conf->nb_tcs;
4164 : :
4165 : : /* Initialize User Priority to Traffic Class mapping */
4166 [ # # ]: 0 : for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
4167 : 0 : tc = &dcb_config->tc_config[j];
4168 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0;
4169 : : }
4170 : :
4171 : : /* User Priority to Traffic Class mapping */
4172 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
4173 : 0 : j = tx_conf->dcb_tc[i];
4174 : 0 : tc = &dcb_config->tc_config[j];
4175 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap |=
4176 : 0 : (uint8_t)(1 << i);
4177 : : }
4178 : : }
4179 : :
4180 : : /**
4181 : : * ixgbe_dcb_rx_hw_config - Configure general DCB RX HW parameters
4182 : : * @dev: pointer to eth_dev structure
4183 : : * @dcb_config: pointer to ixgbe_dcb_config structure
4184 : : */
4185 : : static void
4186 : 0 : ixgbe_dcb_rx_hw_config(struct rte_eth_dev *dev,
4187 : : struct ixgbe_dcb_config *dcb_config)
4188 : : {
4189 : : uint32_t reg;
4190 : : uint32_t vlanctrl;
4191 : : uint8_t i;
4192 : : uint32_t q;
4193 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4194 : :
4195 : 0 : PMD_INIT_FUNC_TRACE();
4196 : : /*
4197 : : * Disable the arbiter before changing parameters
4198 : : * (always enable recycle mode; WSP)
4199 : : */
4200 : : reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC | IXGBE_RTRPCS_ARBDIS;
4201 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
4202 : :
4203 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
4204 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
4205 [ # # ]: 0 : if (dcb_config->num_tcs.pg_tcs == 4) {
4206 [ # # ]: 0 : if (dcb_config->vt_mode)
4207 : 0 : reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
4208 : : IXGBE_MRQC_VMDQRT4TCEN;
4209 : : else {
4210 : : /* no matter the mode is DCB or DCB_RSS, just
4211 : : * set the MRQE to RSSXTCEN. RSS is controlled
4212 : : * by RSS_FIELD
4213 : : */
4214 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0);
4215 : 0 : reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
4216 : : IXGBE_MRQC_RTRSS4TCEN;
4217 : : }
4218 : : }
4219 [ # # ]: 0 : if (dcb_config->num_tcs.pg_tcs == 8) {
4220 [ # # ]: 0 : if (dcb_config->vt_mode)
4221 : 0 : reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
4222 : : IXGBE_MRQC_VMDQRT8TCEN;
4223 : : else {
4224 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0);
4225 : 0 : reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
4226 : : IXGBE_MRQC_RTRSS8TCEN;
4227 : : }
4228 : : }
4229 : :
4230 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC, reg);
4231 : :
4232 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
4233 : : /* Disable drop for all queues in VMDQ mode*/
4234 [ # # ]: 0 : for (q = 0; q < IXGBE_MAX_RX_QUEUE_NUM; q++)
4235 : 0 : IXGBE_WRITE_REG(hw, IXGBE_QDE,
4236 : : (IXGBE_QDE_WRITE |
4237 : : (q << IXGBE_QDE_IDX_SHIFT)));
4238 : : } else {
4239 : : /* Enable drop for all queues in SRIOV mode */
4240 [ # # ]: 0 : for (q = 0; q < IXGBE_MAX_RX_QUEUE_NUM; q++)
4241 : 0 : IXGBE_WRITE_REG(hw, IXGBE_QDE,
4242 : : (IXGBE_QDE_WRITE |
4243 : : (q << IXGBE_QDE_IDX_SHIFT) |
4244 : : IXGBE_QDE_ENABLE));
4245 : : }
4246 : : }
4247 : :
4248 : : /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
4249 : 0 : vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
4250 : 0 : vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
4251 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
4252 : :
4253 : : /* VFTA - enable all vlan filters */
4254 [ # # ]: 0 : for (i = 0; i < NUM_VFTA_REGISTERS; i++) {
4255 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), 0xFFFFFFFF);
4256 : : }
4257 : :
4258 : : /*
4259 : : * Configure Rx packet plane (recycle mode; WSP) and
4260 : : * enable arbiter
4261 : : */
4262 : : reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC;
4263 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
4264 : 0 : }
4265 : :
4266 : : static void
4267 : 0 : ixgbe_dcb_hw_arbite_rx_config(struct ixgbe_hw *hw, uint16_t *refill,
4268 : : uint16_t *max, uint8_t *bwg_id, uint8_t *tsa, uint8_t *map)
4269 : : {
4270 [ # # # ]: 0 : switch (hw->mac.type) {
4271 : 0 : case ixgbe_mac_82598EB:
4272 : 0 : ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, tsa);
4273 : 0 : break;
4274 : 0 : case ixgbe_mac_82599EB:
4275 : : case ixgbe_mac_X540:
4276 : : case ixgbe_mac_X550:
4277 : : case ixgbe_mac_X550EM_x:
4278 : : case ixgbe_mac_X550EM_a:
4279 : 0 : ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id,
4280 : : tsa, map);
4281 : 0 : break;
4282 : : default:
4283 : : break;
4284 : : }
4285 : 0 : }
4286 : :
4287 : : static void
4288 : 0 : ixgbe_dcb_hw_arbite_tx_config(struct ixgbe_hw *hw, uint16_t *refill, uint16_t *max,
4289 : : uint8_t *bwg_id, uint8_t *tsa, uint8_t *map)
4290 : : {
4291 [ # # # ]: 0 : switch (hw->mac.type) {
4292 : 0 : case ixgbe_mac_82598EB:
4293 : 0 : ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max, bwg_id, tsa);
4294 : 0 : ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max, bwg_id, tsa);
4295 : 0 : break;
4296 : 0 : case ixgbe_mac_82599EB:
4297 : : case ixgbe_mac_X540:
4298 : : case ixgbe_mac_X550:
4299 : : case ixgbe_mac_X550EM_x:
4300 : : case ixgbe_mac_X550EM_a:
4301 : 0 : ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwg_id, tsa);
4302 : 0 : ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id, tsa, map);
4303 : 0 : break;
4304 : : default:
4305 : : break;
4306 : : }
4307 : 0 : }
4308 : :
4309 : : #define DCB_RX_CONFIG 1
4310 : : #define DCB_TX_CONFIG 1
4311 : : #define DCB_TX_PB 1024
4312 : : /**
4313 : : * ixgbe_dcb_hw_configure - Enable DCB and configure
4314 : : * general DCB in VT mode and non-VT mode parameters
4315 : : * @dev: pointer to rte_eth_dev structure
4316 : : * @dcb_config: pointer to ixgbe_dcb_config structure
4317 : : */
4318 : : static int
4319 : 0 : ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
4320 : : struct ixgbe_dcb_config *dcb_config)
4321 : : {
4322 : : int ret = 0;
4323 : : uint8_t i, pfc_en, nb_tcs;
4324 : : uint16_t pbsize, rx_buffer_size;
4325 : : uint8_t config_dcb_rx = 0;
4326 : : uint8_t config_dcb_tx = 0;
4327 : 0 : uint8_t tsa[IXGBE_DCB_MAX_TRAFFIC_CLASS] = {0};
4328 : 0 : uint8_t bwgid[IXGBE_DCB_MAX_TRAFFIC_CLASS] = {0};
4329 : 0 : uint16_t refill[IXGBE_DCB_MAX_TRAFFIC_CLASS] = {0};
4330 : 0 : uint16_t max[IXGBE_DCB_MAX_TRAFFIC_CLASS] = {0};
4331 : 0 : uint8_t map[IXGBE_DCB_MAX_TRAFFIC_CLASS] = {0};
4332 : : struct ixgbe_dcb_tc_config *tc;
4333 : 0 : uint32_t max_frame = dev->data->mtu + RTE_ETHER_HDR_LEN +
4334 : : RTE_ETHER_CRC_LEN;
4335 : 0 : struct ixgbe_hw *hw =
4336 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4337 : : struct ixgbe_bw_conf *bw_conf =
4338 : : IXGBE_DEV_PRIVATE_TO_BW_CONF(dev->data->dev_private);
4339 : :
4340 [ # # # ]: 0 : switch (dev->data->dev_conf.rxmode.mq_mode) {
4341 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB:
4342 : 0 : dcb_config->vt_mode = true;
4343 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
4344 : : config_dcb_rx = DCB_RX_CONFIG;
4345 : : /*
4346 : : *get dcb and VT rx configuration parameters
4347 : : *from rte_eth_conf
4348 : : */
4349 : 0 : ixgbe_vmdq_dcb_rx_config(dev, dcb_config);
4350 : : /*Configure general VMDQ and DCB RX parameters*/
4351 : 0 : ixgbe_vmdq_dcb_configure(dev);
4352 : : }
4353 : : break;
4354 : 0 : case RTE_ETH_MQ_RX_DCB:
4355 : : case RTE_ETH_MQ_RX_DCB_RSS:
4356 : 0 : dcb_config->vt_mode = false;
4357 : : config_dcb_rx = DCB_RX_CONFIG;
4358 : : /* Get dcb TX configuration parameters from rte_eth_conf */
4359 : : ixgbe_dcb_rx_config(dev, dcb_config);
4360 : : /*Configure general DCB RX parameters*/
4361 : 0 : ixgbe_dcb_rx_hw_config(dev, dcb_config);
4362 : 0 : break;
4363 : 0 : default:
4364 : 0 : PMD_INIT_LOG(ERR, "Incorrect DCB RX mode configuration");
4365 : 0 : break;
4366 : : }
4367 [ # # # ]: 0 : switch (dev->data->dev_conf.txmode.mq_mode) {
4368 : 0 : case RTE_ETH_MQ_TX_VMDQ_DCB:
4369 : 0 : dcb_config->vt_mode = true;
4370 : : config_dcb_tx = DCB_TX_CONFIG;
4371 : : /* get DCB and VT TX configuration parameters
4372 : : * from rte_eth_conf
4373 : : */
4374 : 0 : ixgbe_dcb_vt_tx_config(dev, dcb_config);
4375 : : /*Configure general VMDQ and DCB TX parameters*/
4376 : 0 : ixgbe_vmdq_dcb_hw_tx_config(dev, dcb_config);
4377 : 0 : break;
4378 : :
4379 : 0 : case RTE_ETH_MQ_TX_DCB:
4380 : 0 : dcb_config->vt_mode = false;
4381 : : config_dcb_tx = DCB_TX_CONFIG;
4382 : : /*get DCB TX configuration parameters from rte_eth_conf*/
4383 : : ixgbe_dcb_tx_config(dev, dcb_config);
4384 : : /*Configure general DCB TX parameters*/
4385 : 0 : ixgbe_dcb_tx_hw_config(dev, dcb_config);
4386 : 0 : break;
4387 : 0 : default:
4388 : 0 : PMD_INIT_LOG(ERR, "Incorrect DCB TX mode configuration");
4389 : 0 : break;
4390 : : }
4391 : :
4392 : 0 : nb_tcs = dcb_config->num_tcs.pfc_tcs;
4393 : : /* Unpack map */
4394 : 0 : ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4395 [ # # ]: 0 : if (nb_tcs == RTE_ETH_4_TCS) {
4396 : : /* Avoid un-configured priority mapping to TC0 */
4397 : : uint8_t j = 4;
4398 : : uint8_t mask = 0xFF;
4399 : :
4400 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES - 4; i++)
4401 : 0 : mask = (uint8_t)(mask & (~(1 << map[i])));
4402 [ # # ]: 0 : for (i = 0; mask && (i < IXGBE_DCB_MAX_TRAFFIC_CLASS); i++) {
4403 [ # # # # ]: 0 : if ((mask & 0x1) && j < RTE_ETH_DCB_NUM_USER_PRIORITIES)
4404 : 0 : map[j++] = i;
4405 : 0 : mask >>= 1;
4406 : : }
4407 : : /* Re-configure 4 TCs BW */
4408 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
4409 : 0 : tc = &dcb_config->tc_config[i];
4410 [ # # ]: 0 : if (bw_conf->tc_num != nb_tcs)
4411 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
4412 : : (uint8_t)(100 / nb_tcs);
4413 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
4414 : : (uint8_t)(100 / nb_tcs);
4415 : : }
4416 [ # # ]: 0 : for (; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4417 : 0 : tc = &dcb_config->tc_config[i];
4418 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent = 0;
4419 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent = 0;
4420 : : }
4421 : : } else {
4422 : : /* Re-configure 8 TCs BW */
4423 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
4424 : 0 : tc = &dcb_config->tc_config[i];
4425 [ # # ]: 0 : if (bw_conf->tc_num != nb_tcs)
4426 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
4427 : 0 : (uint8_t)(100 / nb_tcs + (i & 1));
4428 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
4429 : 0 : (uint8_t)(100 / nb_tcs + (i & 1));
4430 : : }
4431 : : }
4432 : :
4433 [ # # ]: 0 : switch (hw->mac.type) {
4434 : : case ixgbe_mac_X550:
4435 : : case ixgbe_mac_X550EM_x:
4436 : : case ixgbe_mac_X550EM_a:
4437 : : rx_buffer_size = X550_RX_BUFFER_SIZE;
4438 : : break;
4439 : 0 : default:
4440 : : rx_buffer_size = NIC_RX_BUFFER_SIZE;
4441 : 0 : break;
4442 : : }
4443 : :
4444 [ # # ]: 0 : if (config_dcb_rx) {
4445 : : /* Set RX buffer size */
4446 : 0 : pbsize = (uint16_t)(rx_buffer_size / nb_tcs);
4447 : 0 : uint32_t rxpbsize = pbsize << IXGBE_RXPBSIZE_SHIFT;
4448 : :
4449 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
4450 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpbsize);
4451 : : }
4452 : : /* zero alloc all unused TCs */
4453 [ # # ]: 0 : for (; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
4454 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
4455 : : }
4456 [ # # ]: 0 : if (config_dcb_tx) {
4457 : : /* Only support an equally distributed
4458 : : * Tx packet buffer strategy.
4459 : : */
4460 : 0 : uint32_t txpktsize = IXGBE_TXPBSIZE_MAX / nb_tcs;
4461 : 0 : uint32_t txpbthresh = (txpktsize / DCB_TX_PB) - IXGBE_TXPKT_SIZE_MAX;
4462 : :
4463 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
4464 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), txpktsize);
4465 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), txpbthresh);
4466 : : }
4467 : : /* Clear unused TCs, if any, to zero buffer size*/
4468 [ # # ]: 0 : for (; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
4469 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), 0);
4470 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), 0);
4471 : : }
4472 : : }
4473 : :
4474 : : /*Calculates traffic class credits*/
4475 : 0 : ixgbe_dcb_calculate_tc_credits_cee(hw, dcb_config, max_frame,
4476 : : IXGBE_DCB_TX_CONFIG);
4477 : 0 : ixgbe_dcb_calculate_tc_credits_cee(hw, dcb_config, max_frame,
4478 : : IXGBE_DCB_RX_CONFIG);
4479 : :
4480 [ # # ]: 0 : if (config_dcb_rx) {
4481 : : /* Unpack CEE standard containers */
4482 : 0 : ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_RX_CONFIG, refill);
4483 : 0 : ixgbe_dcb_unpack_max_cee(dcb_config, max);
4484 : 0 : ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_RX_CONFIG, bwgid);
4485 : 0 : ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_RX_CONFIG, tsa);
4486 : : /* Configure PG(ETS) RX */
4487 : 0 : ixgbe_dcb_hw_arbite_rx_config(hw, refill, max, bwgid, tsa, map);
4488 : : }
4489 : :
4490 [ # # ]: 0 : if (config_dcb_tx) {
4491 : : /* Unpack CEE standard containers */
4492 : 0 : ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
4493 : 0 : ixgbe_dcb_unpack_max_cee(dcb_config, max);
4494 : 0 : ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_TX_CONFIG, bwgid);
4495 : 0 : ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_TX_CONFIG, tsa);
4496 : : /* Configure PG(ETS) TX */
4497 : 0 : ixgbe_dcb_hw_arbite_tx_config(hw, refill, max, bwgid, tsa, map);
4498 : : }
4499 : :
4500 : : /*Configure queue statistics registers*/
4501 : 0 : ixgbe_dcb_config_tc_stats_82599(hw, dcb_config);
4502 : :
4503 : : /* Check if the PFC is supported */
4504 [ # # ]: 0 : if (dev->data->dev_conf.dcb_capability_en & RTE_ETH_DCB_PFC_SUPPORT) {
4505 : 0 : pbsize = (uint16_t)(rx_buffer_size / nb_tcs);
4506 [ # # ]: 0 : for (i = 0; i < nb_tcs; i++) {
4507 : : /*
4508 : : * If the TC count is 8,and the default high_water is 48,
4509 : : * the low_water is 16 as default.
4510 : : */
4511 : 0 : hw->fc.high_water[i] = (pbsize * 3) / 4;
4512 : 0 : hw->fc.low_water[i] = pbsize / 4;
4513 : : /* Enable pfc for this TC */
4514 : : tc = &dcb_config->tc_config[i];
4515 : 0 : tc->pfc = ixgbe_dcb_pfc_enabled;
4516 : : }
4517 : 0 : ixgbe_dcb_unpack_pfc_cee(dcb_config, map, &pfc_en);
4518 [ # # ]: 0 : if (dcb_config->num_tcs.pfc_tcs == RTE_ETH_4_TCS)
4519 : 0 : pfc_en &= 0x0F;
4520 : 0 : ret = ixgbe_dcb_config_pfc(hw, pfc_en, map);
4521 : : }
4522 : :
4523 : 0 : return ret;
4524 : : }
4525 : :
4526 : : /**
4527 : : * ixgbe_configure_dcb - Configure DCB Hardware
4528 : : * @dev: pointer to rte_eth_dev
4529 : : */
4530 : 0 : void ixgbe_configure_dcb(struct rte_eth_dev *dev)
4531 : : {
4532 : 0 : struct ixgbe_dcb_config *dcb_cfg =
4533 : 0 : IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4534 : : struct rte_eth_conf *dev_conf = &(dev->data->dev_conf);
4535 : :
4536 : 0 : PMD_INIT_FUNC_TRACE();
4537 : :
4538 : : /* check support mq_mode for DCB */
4539 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode != RTE_ETH_MQ_RX_VMDQ_DCB &&
4540 [ # # ]: 0 : dev_conf->rxmode.mq_mode != RTE_ETH_MQ_RX_DCB &&
4541 : : dev_conf->rxmode.mq_mode != RTE_ETH_MQ_RX_DCB_RSS)
4542 : : return;
4543 : :
4544 [ # # ]: 0 : if (dev->data->nb_rx_queues > RTE_ETH_DCB_NUM_QUEUES)
4545 : : return;
4546 : :
4547 : : /** Configure DCB hardware **/
4548 : 0 : ixgbe_dcb_hw_configure(dev, dcb_cfg);
4549 : : }
4550 : :
4551 : : /*
4552 : : * VMDq only support for 10 GbE NIC.
4553 : : */
4554 : : static void
4555 : 0 : ixgbe_vmdq_rx_hw_configure(struct rte_eth_dev *dev)
4556 : : {
4557 : : struct rte_eth_vmdq_rx_conf *cfg;
4558 : : struct ixgbe_hw *hw;
4559 : : enum rte_eth_nb_pools num_pools;
4560 : : uint32_t mrqc, vt_ctl, vlanctrl;
4561 : : uint32_t vmolr = 0;
4562 : : int i;
4563 : :
4564 : 0 : PMD_INIT_FUNC_TRACE();
4565 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4566 : : cfg = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf;
4567 : 0 : num_pools = cfg->nb_queue_pools;
4568 : :
4569 : : ixgbe_rss_disable(dev);
4570 : :
4571 : : /* MRQC: enable vmdq */
4572 : : mrqc = IXGBE_MRQC_VMDQEN;
4573 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
4574 : :
4575 : : /* PFVTCTL: turn on virtualisation and set the default pool */
4576 : : vt_ctl = IXGBE_VT_CTL_VT_ENABLE | IXGBE_VT_CTL_REPLEN;
4577 [ # # ]: 0 : if (cfg->enable_default_pool)
4578 : 0 : vt_ctl |= (cfg->default_pool << IXGBE_VT_CTL_POOL_SHIFT);
4579 : : else
4580 : : vt_ctl |= IXGBE_VT_CTL_DIS_DEFPL;
4581 : :
4582 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vt_ctl);
4583 : :
4584 [ # # ]: 0 : for (i = 0; i < (int)num_pools; i++) {
4585 : 0 : vmolr = ixgbe_convert_vm_rx_mask_to_val(cfg->rx_mode, vmolr);
4586 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMOLR(i), vmolr);
4587 : : }
4588 : :
4589 : : /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
4590 : 0 : vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
4591 : 0 : vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
4592 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
4593 : :
4594 : : /* VFTA - enable all vlan filters */
4595 [ # # ]: 0 : for (i = 0; i < NUM_VFTA_REGISTERS; i++)
4596 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), UINT32_MAX);
4597 : :
4598 : : /* VFRE: pool enabling for receive - 64 */
4599 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), UINT32_MAX);
4600 [ # # ]: 0 : if (num_pools == RTE_ETH_64_POOLS)
4601 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), UINT32_MAX);
4602 : :
4603 : : /*
4604 : : * MPSAR - allow pools to read specific mac addresses
4605 : : * In this case, all pools should be able to read from mac addr 0
4606 : : */
4607 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(0), UINT32_MAX);
4608 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(0), UINT32_MAX);
4609 : :
4610 : : /* PFVLVF, PFVLVFB: set up filters for vlan tags as configured */
4611 [ # # ]: 0 : for (i = 0; i < cfg->nb_pool_maps; i++) {
4612 : : /* set vlan id in VF register and set the valid bit */
4613 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLVF(i), (IXGBE_VLVF_VIEN |
4614 : : (cfg->pool_map[i].vlan_id & IXGBE_RXD_VLAN_ID_MASK)));
4615 : : /*
4616 : : * Put the allowed pools in VFB reg. As we only have 16 or 64
4617 : : * pools, we only need to use the first half of the register
4618 : : * i.e. bits 0-31
4619 : : */
4620 [ # # ]: 0 : if (((cfg->pool_map[i].pools >> 32) & UINT32_MAX) == 0)
4621 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLVFB(i * 2),
4622 : : (cfg->pool_map[i].pools & UINT32_MAX));
4623 : : else
4624 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLVFB((i * 2 + 1)),
4625 : : ((cfg->pool_map[i].pools >> 32) & UINT32_MAX));
4626 : :
4627 : : }
4628 : :
4629 : : /* PFDMA Tx General Switch Control Enables VMDQ loopback */
4630 [ # # ]: 0 : if (cfg->enable_loop_back) {
4631 : 0 : IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
4632 [ # # ]: 0 : for (i = 0; i < RTE_IXGBE_VMTXSW_REGISTER_COUNT; i++)
4633 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VMTXSW(i), UINT32_MAX);
4634 : : }
4635 : :
4636 : 0 : IXGBE_WRITE_FLUSH(hw);
4637 : 0 : }
4638 : :
4639 : : /*
4640 : : * ixgbe_dcb_config_tx_hw_config - Configure general VMDq TX parameters
4641 : : * @hw: pointer to hardware structure
4642 : : */
4643 : : static void
4644 : 0 : ixgbe_vmdq_tx_hw_configure(struct ixgbe_hw *hw)
4645 : : {
4646 : : uint32_t reg;
4647 : : uint32_t q;
4648 : :
4649 : 0 : PMD_INIT_FUNC_TRACE();
4650 : : /*PF VF Transmit Enable*/
4651 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(0), UINT32_MAX);
4652 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTE(1), UINT32_MAX);
4653 : :
4654 : : /* Disable the Tx desc arbiter so that MTQC can be changed */
4655 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
4656 : 0 : reg |= IXGBE_RTTDCS_ARBDIS;
4657 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
4658 : :
4659 : : reg = IXGBE_MTQC_VT_ENA | IXGBE_MTQC_64VF;
4660 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MTQC, reg);
4661 : :
4662 : : /* Disable drop for all queues */
4663 [ # # ]: 0 : for (q = 0; q < IXGBE_MAX_RX_QUEUE_NUM; q++)
4664 : 0 : IXGBE_WRITE_REG(hw, IXGBE_QDE,
4665 : : (IXGBE_QDE_WRITE | (q << IXGBE_QDE_IDX_SHIFT)));
4666 : :
4667 : : /* Enable the Tx desc arbiter */
4668 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
4669 : 0 : reg &= ~IXGBE_RTTDCS_ARBDIS;
4670 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
4671 : :
4672 : 0 : IXGBE_WRITE_FLUSH(hw);
4673 : 0 : }
4674 : :
4675 : : static int __rte_cold
4676 : 0 : ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
4677 : : {
4678 : 0 : struct ixgbe_rx_entry *rxe = rxq->sw_ring;
4679 : : uint64_t dma_addr;
4680 : : unsigned int i;
4681 : :
4682 : : /* Initialize software ring entries */
4683 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
4684 : : volatile union ixgbe_adv_rx_desc *rxd;
4685 : 0 : struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
4686 : :
4687 [ # # ]: 0 : if (mbuf == NULL) {
4688 : 0 : PMD_INIT_LOG(ERR, "RX mbuf alloc failed queue_id=%u",
4689 : : (unsigned) rxq->queue_id);
4690 : 0 : return -ENOMEM;
4691 : : }
4692 : :
4693 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
4694 : 0 : mbuf->port = rxq->port_id;
4695 : :
4696 : : dma_addr =
4697 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
4698 : 0 : rxd = &rxq->rx_ring[i];
4699 : 0 : rxd->read.hdr_addr = 0;
4700 : 0 : rxd->read.pkt_addr = dma_addr;
4701 : 0 : rxe[i].mbuf = mbuf;
4702 : : }
4703 : :
4704 : : return 0;
4705 : : }
4706 : :
4707 : : static int
4708 : 0 : ixgbe_config_vf_rss(struct rte_eth_dev *dev)
4709 : : {
4710 : : struct ixgbe_hw *hw;
4711 : : uint32_t mrqc;
4712 : :
4713 : 0 : ixgbe_rss_configure(dev);
4714 : :
4715 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4716 : :
4717 : : /* MRQC: enable VF RSS */
4718 : 0 : mrqc = IXGBE_READ_REG(hw, IXGBE_MRQC);
4719 : 0 : mrqc &= ~IXGBE_MRQC_MRQE_MASK;
4720 [ # # # ]: 0 : switch (RTE_ETH_DEV_SRIOV(dev).active) {
4721 : 0 : case RTE_ETH_64_POOLS:
4722 : 0 : mrqc |= IXGBE_MRQC_VMDQRSS64EN;
4723 : 0 : break;
4724 : :
4725 : 0 : case RTE_ETH_32_POOLS:
4726 : 0 : mrqc |= IXGBE_MRQC_VMDQRSS32EN;
4727 : 0 : break;
4728 : :
4729 : 0 : default:
4730 : 0 : PMD_INIT_LOG(ERR, "Invalid pool number in IOV mode with VMDQ RSS");
4731 : 0 : return -EINVAL;
4732 : : }
4733 : :
4734 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc);
4735 : :
4736 : 0 : return 0;
4737 : : }
4738 : :
4739 : : static int
4740 : 0 : ixgbe_config_vf_default(struct rte_eth_dev *dev)
4741 : : {
4742 : : struct ixgbe_hw *hw =
4743 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4744 : :
4745 [ # # # # ]: 0 : switch (RTE_ETH_DEV_SRIOV(dev).active) {
4746 : 0 : case RTE_ETH_64_POOLS:
4747 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC,
4748 : : IXGBE_MRQC_VMDQEN);
4749 : : break;
4750 : :
4751 : 0 : case RTE_ETH_32_POOLS:
4752 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC,
4753 : : IXGBE_MRQC_VMDQRT4TCEN);
4754 : : break;
4755 : :
4756 : 0 : case RTE_ETH_16_POOLS:
4757 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MRQC,
4758 : : IXGBE_MRQC_VMDQRT8TCEN);
4759 : : break;
4760 : 0 : default:
4761 : 0 : PMD_INIT_LOG(ERR,
4762 : : "invalid pool number in IOV mode");
4763 : 0 : break;
4764 : : }
4765 : 0 : return 0;
4766 : : }
4767 : :
4768 : : static int
4769 : 0 : ixgbe_dev_mq_rx_configure(struct rte_eth_dev *dev)
4770 : : {
4771 : : struct ixgbe_hw *hw =
4772 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4773 : :
4774 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
4775 : : return 0;
4776 : :
4777 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
4778 : : /*
4779 : : * SRIOV inactive scheme
4780 : : * any DCB/RSS w/o VMDq multi-queue setting
4781 : : */
4782 [ # # # # ]: 0 : switch (dev->data->dev_conf.rxmode.mq_mode) {
4783 : 0 : case RTE_ETH_MQ_RX_RSS:
4784 : : case RTE_ETH_MQ_RX_DCB_RSS:
4785 : : case RTE_ETH_MQ_RX_VMDQ_RSS:
4786 : 0 : ixgbe_rss_configure(dev);
4787 : 0 : break;
4788 : :
4789 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB:
4790 : 0 : ixgbe_vmdq_dcb_configure(dev);
4791 : 0 : break;
4792 : :
4793 : 0 : case RTE_ETH_MQ_RX_VMDQ_ONLY:
4794 : 0 : ixgbe_vmdq_rx_hw_configure(dev);
4795 : 0 : break;
4796 : :
4797 : : case RTE_ETH_MQ_RX_NONE:
4798 : : default:
4799 : : /* if mq_mode is none, disable rss mode.*/
4800 : : ixgbe_rss_disable(dev);
4801 : : break;
4802 : : }
4803 : : } else {
4804 : : /* SRIOV active scheme
4805 : : * Support RSS together with SRIOV.
4806 : : */
4807 [ # # # # ]: 0 : switch (dev->data->dev_conf.rxmode.mq_mode) {
4808 : 0 : case RTE_ETH_MQ_RX_RSS:
4809 : : case RTE_ETH_MQ_RX_VMDQ_RSS:
4810 : 0 : ixgbe_config_vf_rss(dev);
4811 : 0 : break;
4812 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB:
4813 : : case RTE_ETH_MQ_RX_DCB:
4814 : : /* In SRIOV, the configuration is the same as VMDq case */
4815 : 0 : ixgbe_vmdq_dcb_configure(dev);
4816 : 0 : break;
4817 : : /* DCB/RSS together with SRIOV is not supported */
4818 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB_RSS:
4819 : : case RTE_ETH_MQ_RX_DCB_RSS:
4820 : 0 : PMD_INIT_LOG(ERR,
4821 : : "Could not support DCB/RSS with VMDq & SRIOV");
4822 : 0 : return -1;
4823 : 0 : default:
4824 : 0 : ixgbe_config_vf_default(dev);
4825 : 0 : break;
4826 : : }
4827 : : }
4828 : :
4829 : : return 0;
4830 : : }
4831 : :
4832 : : static int
4833 : 0 : ixgbe_dev_mq_tx_configure(struct rte_eth_dev *dev)
4834 : : {
4835 : 0 : struct ixgbe_hw *hw =
4836 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4837 : : uint32_t mtqc;
4838 : : uint32_t rttdcs;
4839 : :
4840 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
4841 : : return 0;
4842 : :
4843 : : /* disable arbiter before setting MTQC */
4844 : 0 : rttdcs = IXGBE_READ_REG(hw, IXGBE_RTTDCS);
4845 : 0 : rttdcs |= IXGBE_RTTDCS_ARBDIS;
4846 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, rttdcs);
4847 : :
4848 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
4849 : : /*
4850 : : * SRIOV inactive scheme
4851 : : * any DCB w/o VMDq multi-queue setting
4852 : : */
4853 [ # # ]: 0 : if (dev->data->dev_conf.txmode.mq_mode == RTE_ETH_MQ_TX_VMDQ_ONLY)
4854 : 0 : ixgbe_vmdq_tx_hw_configure(hw);
4855 : : else {
4856 : : mtqc = IXGBE_MTQC_64Q_1PB;
4857 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MTQC, mtqc);
4858 : : }
4859 : : } else {
4860 [ # # # # ]: 0 : switch (RTE_ETH_DEV_SRIOV(dev).active) {
4861 : :
4862 : : /*
4863 : : * SRIOV active scheme
4864 : : * FIXME if support DCB together with VMDq & SRIOV
4865 : : */
4866 : : case RTE_ETH_64_POOLS:
4867 : : mtqc = IXGBE_MTQC_VT_ENA | IXGBE_MTQC_64VF;
4868 : : break;
4869 : 0 : case RTE_ETH_32_POOLS:
4870 : : mtqc = IXGBE_MTQC_VT_ENA | IXGBE_MTQC_32VF;
4871 : 0 : break;
4872 : 0 : case RTE_ETH_16_POOLS:
4873 : : mtqc = IXGBE_MTQC_VT_ENA | IXGBE_MTQC_RT_ENA |
4874 : : IXGBE_MTQC_8TC_8TQ;
4875 : 0 : break;
4876 : 0 : default:
4877 : : mtqc = IXGBE_MTQC_64Q_1PB;
4878 : 0 : PMD_INIT_LOG(ERR, "invalid pool number in IOV mode");
4879 : : }
4880 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MTQC, mtqc);
4881 : : }
4882 : :
4883 : : /* re-enable arbiter */
4884 : : rttdcs &= ~IXGBE_RTTDCS_ARBDIS;
4885 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, rttdcs);
4886 : :
4887 : 0 : return 0;
4888 : : }
4889 : :
4890 : : /**
4891 : : * ixgbe_get_rscctl_maxdesc - Calculate the RSCCTL[n].MAXDESC for PF
4892 : : *
4893 : : * Return the RSCCTL[n].MAXDESC for 82599 and x540 PF devices according to the
4894 : : * spec rev. 3.0 chapter 8.2.3.8.13.
4895 : : *
4896 : : * @pool Memory pool of the Rx queue
4897 : : */
4898 : : static inline uint32_t
4899 : : ixgbe_get_rscctl_maxdesc(struct rte_mempool *pool)
4900 : : {
4901 : : struct rte_pktmbuf_pool_private *mp_priv = rte_mempool_get_priv(pool);
4902 : :
4903 : : /* MAXDESC * SRRCTL.BSIZEPKT must not exceed 64 KB minus one */
4904 : 0 : uint16_t maxdesc =
4905 : 0 : RTE_IPV4_MAX_PKT_LEN /
4906 : 0 : (mp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM);
4907 : :
4908 [ # # ]: 0 : if (maxdesc >= 16)
4909 : : return IXGBE_RSCCTL_MAXDESC_16;
4910 [ # # ]: 0 : else if (maxdesc >= 8)
4911 : : return IXGBE_RSCCTL_MAXDESC_8;
4912 [ # # ]: 0 : else if (maxdesc >= 4)
4913 : : return IXGBE_RSCCTL_MAXDESC_4;
4914 : : else
4915 : 0 : return IXGBE_RSCCTL_MAXDESC_1;
4916 : : }
4917 : :
4918 : : /**
4919 : : * ixgbe_set_ivar - Setup the correct IVAR register for a particular MSIX
4920 : : * interrupt
4921 : : *
4922 : : * (Taken from FreeBSD tree)
4923 : : * (yes this is all very magic and confusing :)
4924 : : *
4925 : : * @dev port handle
4926 : : * @entry the register array entry
4927 : : * @vector the MSIX vector for this queue
4928 : : * @type RX/TX/MISC
4929 : : */
4930 : : static void
4931 : 0 : ixgbe_set_ivar(struct rte_eth_dev *dev, u8 entry, u8 vector, s8 type)
4932 : : {
4933 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4934 : : u32 ivar, index;
4935 : :
4936 : 0 : vector |= IXGBE_IVAR_ALLOC_VAL;
4937 : :
4938 [ # # # ]: 0 : switch (hw->mac.type) {
4939 : :
4940 : 0 : case ixgbe_mac_82598EB:
4941 [ # # ]: 0 : if (type == -1)
4942 : : entry = IXGBE_IVAR_OTHER_CAUSES_INDEX;
4943 : : else
4944 : 0 : entry += (type * 64);
4945 : 0 : index = (entry >> 2) & 0x1F;
4946 : 0 : ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
4947 : 0 : ivar &= ~(0xFF << (8 * (entry & 0x3)));
4948 : 0 : ivar |= (vector << (8 * (entry & 0x3)));
4949 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
4950 : : break;
4951 : :
4952 : 0 : case ixgbe_mac_82599EB:
4953 : : case ixgbe_mac_X540:
4954 [ # # ]: 0 : if (type == -1) { /* MISC IVAR */
4955 : 0 : index = (entry & 1) * 8;
4956 : 0 : ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
4957 : 0 : ivar &= ~(0xFF << index);
4958 : 0 : ivar |= (vector << index);
4959 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
4960 : : } else { /* RX/TX IVARS */
4961 : 0 : index = (16 * (entry & 1)) + (8 * type);
4962 : 0 : ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(entry >> 1));
4963 : 0 : ivar &= ~(0xFF << index);
4964 : 0 : ivar |= (vector << index);
4965 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR(entry >> 1), ivar);
4966 : : }
4967 : :
4968 : : break;
4969 : :
4970 : : default:
4971 : : break;
4972 : : }
4973 : 0 : }
4974 : :
4975 : : static const struct {
4976 : : eth_rx_burst_t pkt_burst;
4977 : : const char *info;
4978 : : } ixgbe_rx_burst_info[] = {
4979 : : { ixgbe_recv_pkts, "Scalar"},
4980 : : { ixgbe_recv_pkts_bulk_alloc, "Scalar bulk alloc"},
4981 : : { ixgbe_recv_pkts_lro_bulk_alloc, "Scalar LRO bulk alloc"},
4982 : : { ixgbe_recv_pkts_lro_single_alloc, "Scalar LRO single alloc"},
4983 : : { ixgbe_vf_representor_rx_burst, "Scalar representor"},
4984 : : #ifdef RTE_ARCH_X86
4985 : : { ixgbe_recv_pkts_vec, "Vector SSE"},
4986 : : { ixgbe_recv_scattered_pkts_vec, "Vector SSE scattered"},
4987 : : #elif defined(RTE_ARCH_ARM)
4988 : : { ixgbe_recv_pkts_vec, "Vector NEON"},
4989 : : { ixgbe_recv_scattered_pkts_vec, "Vector NEON scattered"},
4990 : : #endif
4991 : : };
4992 : :
4993 : : int
4994 : 0 : ixgbe_rx_burst_mode_get(struct rte_eth_dev *dev,
4995 : : __rte_unused uint16_t queue_id,
4996 : : struct rte_eth_burst_mode *mode)
4997 : : {
4998 : 0 : eth_tx_burst_t pkt_burst = dev->rx_pkt_burst;
4999 : : size_t i;
5000 : :
5001 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ixgbe_rx_burst_info); i++) {
5002 [ # # ]: 0 : if (pkt_burst == ixgbe_rx_burst_info[i].pkt_burst) {
5003 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
5004 : 0 : ixgbe_rx_burst_info[i].info);
5005 : 0 : return 0;
5006 : : }
5007 : : }
5008 : :
5009 : : return -EINVAL;
5010 : : }
5011 : :
5012 : : void __rte_cold
5013 : 0 : ixgbe_set_rx_function(struct rte_eth_dev *dev)
5014 : : {
5015 : : uint16_t i, rx_using_sse;
5016 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
5017 : :
5018 : : /*
5019 : : * In order to allow Vector Rx there are a few configuration
5020 : : * conditions to be met and Rx Bulk Allocation should be allowed.
5021 : : */
5022 [ # # ]: 0 : if (ixgbe_rx_vec_dev_conf_condition_check(dev) ||
5023 [ # # # # ]: 0 : !adapter->rx_bulk_alloc_allowed ||
5024 : 0 : rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_128) {
5025 : 0 : PMD_INIT_LOG(DEBUG, "Port[%d] doesn't meet Vector Rx "
5026 : : "preconditions",
5027 : : dev->data->port_id);
5028 : :
5029 : 0 : adapter->rx_vec_allowed = false;
5030 : : }
5031 : :
5032 : : /*
5033 : : * Initialize the appropriate LRO callback.
5034 : : *
5035 : : * If all queues satisfy the bulk allocation preconditions
5036 : : * (hw->rx_bulk_alloc_allowed is TRUE) then we may use bulk allocation.
5037 : : * Otherwise use a single allocation version.
5038 : : */
5039 [ # # ]: 0 : if (dev->data->lro) {
5040 [ # # ]: 0 : if (adapter->rx_bulk_alloc_allowed) {
5041 : 0 : PMD_INIT_LOG(DEBUG, "LRO is requested. Using a bulk "
5042 : : "allocation version");
5043 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_lro_bulk_alloc;
5044 : : } else {
5045 : 0 : PMD_INIT_LOG(DEBUG, "LRO is requested. Using a single "
5046 : : "allocation version");
5047 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
5048 : : }
5049 [ # # ]: 0 : } else if (dev->data->scattered_rx) {
5050 : : /*
5051 : : * Set the non-LRO scattered callback: there are Vector and
5052 : : * single allocation versions.
5053 : : */
5054 [ # # ]: 0 : if (adapter->rx_vec_allowed) {
5055 : 0 : PMD_INIT_LOG(DEBUG, "Using Vector Scattered Rx "
5056 : : "callback (port=%d).",
5057 : : dev->data->port_id);
5058 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
5059 : 0 : dev->recycle_rx_descriptors_refill =
5060 : : ixgbe_recycle_rx_descriptors_refill_vec;
5061 : : #endif
5062 : 0 : dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
5063 [ # # ]: 0 : } else if (adapter->rx_bulk_alloc_allowed) {
5064 : 0 : PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
5065 : : "allocation callback (port=%d).",
5066 : : dev->data->port_id);
5067 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_lro_bulk_alloc;
5068 : : } else {
5069 : 0 : PMD_INIT_LOG(DEBUG, "Using Regular (non-vector, "
5070 : : "single allocation) "
5071 : : "Scattered Rx callback "
5072 : : "(port=%d).",
5073 : : dev->data->port_id);
5074 : :
5075 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
5076 : : }
5077 : : /*
5078 : : * Below we set "simple" callbacks according to port/queues parameters.
5079 : : * If parameters allow we are going to choose between the following
5080 : : * callbacks:
5081 : : * - Vector
5082 : : * - Bulk Allocation
5083 : : * - Single buffer allocation (the simplest one)
5084 : : */
5085 [ # # ]: 0 : } else if (adapter->rx_vec_allowed) {
5086 : 0 : PMD_INIT_LOG(DEBUG, "Vector rx enabled, please make sure RX "
5087 : : "burst size no less than %d (port=%d).",
5088 : : RTE_IXGBE_DESCS_PER_LOOP,
5089 : : dev->data->port_id);
5090 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
5091 : 0 : dev->recycle_rx_descriptors_refill = ixgbe_recycle_rx_descriptors_refill_vec;
5092 : : #endif
5093 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_vec;
5094 [ # # ]: 0 : } else if (adapter->rx_bulk_alloc_allowed) {
5095 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
5096 : : "satisfied. Rx Burst Bulk Alloc function "
5097 : : "will be used on port=%d.",
5098 : : dev->data->port_id);
5099 : :
5100 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts_bulk_alloc;
5101 : : } else {
5102 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are not "
5103 : : "satisfied, or Scattered Rx is requested "
5104 : : "(port=%d).",
5105 : : dev->data->port_id);
5106 : :
5107 : 0 : dev->rx_pkt_burst = ixgbe_recv_pkts;
5108 : : }
5109 : :
5110 : : /* Propagate information about RX function choice through all queues. */
5111 : :
5112 : : rx_using_sse =
5113 [ # # # # ]: 0 : (dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec ||
5114 : : dev->rx_pkt_burst == ixgbe_recv_pkts_vec);
5115 : :
5116 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5117 : 0 : struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
5118 : :
5119 : 0 : rxq->rx_using_sse = rx_using_sse;
5120 : : #ifdef RTE_LIB_SECURITY
5121 : 0 : rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &
5122 : : RTE_ETH_RX_OFFLOAD_SECURITY);
5123 : : #endif
5124 : : }
5125 : 0 : }
5126 : :
5127 : : /**
5128 : : * ixgbe_set_rsc - configure RSC related port HW registers
5129 : : *
5130 : : * Configures the port's RSC related registers according to the 4.6.7.2 chapter
5131 : : * of 82599 Spec (x540 configuration is virtually the same).
5132 : : *
5133 : : * @dev port handle
5134 : : *
5135 : : * Returns 0 in case of success or a non-zero error code
5136 : : */
5137 : : static int
5138 : 0 : ixgbe_set_rsc(struct rte_eth_dev *dev)
5139 : : {
5140 : 0 : struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
5141 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5142 : 0 : struct rte_eth_dev_info dev_info = { 0 };
5143 : : bool rsc_capable = false;
5144 : : uint16_t i;
5145 : : uint32_t rdrxctl;
5146 : : uint32_t rfctl;
5147 : :
5148 : : /* Sanity check */
5149 : 0 : dev->dev_ops->dev_infos_get(dev, &dev_info);
5150 [ # # ]: 0 : if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_TCP_LRO)
5151 : : rsc_capable = true;
5152 : :
5153 [ # # ]: 0 : if (!rsc_capable && (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO)) {
5154 : 0 : PMD_INIT_LOG(CRIT, "LRO is requested on HW that doesn't "
5155 : : "support it");
5156 : 0 : return -EINVAL;
5157 : : }
5158 : :
5159 : : /* RSC global configuration (chapter 4.6.7.2.1 of 82599 Spec) */
5160 : :
5161 [ # # ]: 0 : if ((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) &&
5162 : : (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO)) {
5163 : : /*
5164 : : * According to chapter of 4.6.7.2.1 of the Spec Rev.
5165 : : * 3.0 RSC configuration requires HW CRC stripping being
5166 : : * enabled. If user requested both HW CRC stripping off
5167 : : * and RSC on - return an error.
5168 : : */
5169 : 0 : PMD_INIT_LOG(CRIT, "LRO can't be enabled when HW CRC "
5170 : : "is disabled");
5171 : 0 : return -EINVAL;
5172 : : }
5173 : :
5174 : : /* RFCTL configuration */
5175 : 0 : rfctl = IXGBE_READ_REG(hw, IXGBE_RFCTL);
5176 [ # # # # ]: 0 : if ((rsc_capable) && (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO))
5177 : 0 : rfctl &= ~IXGBE_RFCTL_RSC_DIS;
5178 : : else
5179 : 0 : rfctl |= IXGBE_RFCTL_RSC_DIS;
5180 : : /* disable NFS filtering */
5181 : 0 : rfctl |= IXGBE_RFCTL_NFSW_DIS | IXGBE_RFCTL_NFSR_DIS;
5182 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RFCTL, rfctl);
5183 : :
5184 : : /* If LRO hasn't been requested - we are done here. */
5185 [ # # ]: 0 : if (!(rx_conf->offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO))
5186 : : return 0;
5187 : :
5188 : : /* Set RDRXCTL.RSCACKC bit */
5189 : 0 : rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
5190 : 0 : rdrxctl |= IXGBE_RDRXCTL_RSCACKC;
5191 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
5192 : :
5193 : : /* Per-queue RSC configuration (chapter 4.6.7.2.2 of 82599 Spec) */
5194 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5195 : 0 : struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
5196 : : uint32_t srrctl =
5197 [ # # # # ]: 0 : IXGBE_READ_REG(hw, IXGBE_SRRCTL(rxq->reg_idx));
5198 : : uint32_t rscctl =
5199 [ # # ]: 0 : IXGBE_READ_REG(hw, IXGBE_RSCCTL(rxq->reg_idx));
5200 : : uint32_t psrtype =
5201 [ # # ]: 0 : IXGBE_READ_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx));
5202 : : uint32_t eitr =
5203 [ # # ]: 0 : IXGBE_READ_REG(hw, IXGBE_EITR(rxq->reg_idx));
5204 : :
5205 : : /*
5206 : : * ixgbe PMD doesn't support header-split at the moment.
5207 : : *
5208 : : * Following the 4.6.7.2.1 chapter of the 82599/x540
5209 : : * Spec if RSC is enabled the SRRCTL[n].BSIZEHEADER
5210 : : * should be configured even if header split is not
5211 : : * enabled. We will configure it 128 bytes following the
5212 : : * recommendation in the spec.
5213 : : */
5214 : 0 : srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
5215 : 0 : srrctl |= (128 << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
5216 : : IXGBE_SRRCTL_BSIZEHDR_MASK;
5217 : :
5218 : : /*
5219 : : * TODO: Consider setting the Receive Descriptor Minimum
5220 : : * Threshold Size for an RSC case. This is not an obviously
5221 : : * beneficiary option but the one worth considering...
5222 : : */
5223 : :
5224 : 0 : rscctl |= IXGBE_RSCCTL_RSCEN;
5225 [ # # ]: 0 : rscctl |= ixgbe_get_rscctl_maxdesc(rxq->mb_pool);
5226 : 0 : psrtype |= IXGBE_PSRTYPE_TCPHDR;
5227 : :
5228 : : /*
5229 : : * RSC: Set ITR interval corresponding to 2K ints/s.
5230 : : *
5231 : : * Full-sized RSC aggregations for a 10Gb/s link will
5232 : : * arrive at about 20K aggregation/s rate.
5233 : : *
5234 : : * 2K inst/s rate will make only 10% of the
5235 : : * aggregations to be closed due to the interrupt timer
5236 : : * expiration for a streaming at wire-speed case.
5237 : : *
5238 : : * For a sparse streaming case this setting will yield
5239 : : * at most 500us latency for a single RSC aggregation.
5240 : : */
5241 : 0 : eitr &= ~IXGBE_EITR_ITR_INT_MASK;
5242 : : eitr |= IXGBE_EITR_INTERVAL_US(IXGBE_QUEUE_ITR_INTERVAL_DEFAULT);
5243 : 0 : eitr |= IXGBE_EITR_CNT_WDIS;
5244 : :
5245 [ # # # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rxq->reg_idx), srrctl);
5246 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(rxq->reg_idx), rscctl);
5247 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx), psrtype);
5248 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_EITR(rxq->reg_idx), eitr);
5249 : :
5250 : : /*
5251 : : * RSC requires the mapping of the queue to the
5252 : : * interrupt vector.
5253 : : */
5254 : 0 : ixgbe_set_ivar(dev, rxq->reg_idx, i, 0);
5255 : : }
5256 : :
5257 : 0 : dev->data->lro = 1;
5258 : :
5259 : 0 : PMD_INIT_LOG(DEBUG, "enabling LRO mode");
5260 : :
5261 : 0 : return 0;
5262 : : }
5263 : :
5264 : : /*
5265 : : * Initializes Receive Unit.
5266 : : */
5267 : : int __rte_cold
5268 : 0 : ixgbe_dev_rx_init(struct rte_eth_dev *dev)
5269 : : {
5270 : : struct ixgbe_hw *hw;
5271 : : struct ixgbe_rx_queue *rxq;
5272 : : uint64_t bus_addr;
5273 : : uint32_t rxctrl;
5274 : : uint32_t fctrl;
5275 : : uint32_t hlreg0;
5276 : : uint32_t maxfrs;
5277 : : uint32_t srrctl;
5278 : : uint32_t rdrxctl;
5279 : : uint32_t rxcsum;
5280 : : uint16_t buf_size;
5281 : : uint16_t i;
5282 : 0 : struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
5283 : 0 : uint32_t frame_size = dev->data->mtu + IXGBE_ETH_OVERHEAD;
5284 : : int rc;
5285 : :
5286 : 0 : PMD_INIT_FUNC_TRACE();
5287 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5288 : :
5289 : : /*
5290 : : * Make sure receives are disabled while setting
5291 : : * up the RX context (registers, descriptor rings, etc.).
5292 : : */
5293 : 0 : rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
5294 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN);
5295 : :
5296 : : /* Enable receipt of broadcasted frames */
5297 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
5298 : : fctrl |= IXGBE_FCTRL_BAM;
5299 : : fctrl |= IXGBE_FCTRL_DPF;
5300 : 0 : fctrl |= IXGBE_FCTRL_PMCF;
5301 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
5302 : :
5303 : : /*
5304 : : * Configure CRC stripping, if any.
5305 : : */
5306 : 0 : hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
5307 [ # # ]: 0 : if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
5308 : 0 : hlreg0 &= ~IXGBE_HLREG0_RXCRCSTRP;
5309 : : else
5310 : 0 : hlreg0 |= IXGBE_HLREG0_RXCRCSTRP;
5311 : :
5312 : : /*
5313 : : * Configure jumbo frame support, if any.
5314 : : */
5315 [ # # ]: 0 : if (dev->data->mtu > RTE_ETHER_MTU) {
5316 : 0 : hlreg0 |= IXGBE_HLREG0_JUMBOEN;
5317 : 0 : maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
5318 : 0 : maxfrs &= 0x0000FFFF;
5319 : 0 : maxfrs |= (frame_size << 16);
5320 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
5321 : : } else
5322 : 0 : hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
5323 : :
5324 : : /*
5325 : : * If loopback mode is configured, set LPBK bit.
5326 : : */
5327 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode != 0) {
5328 : 0 : rc = ixgbe_check_supported_loopback_mode(dev);
5329 [ # # ]: 0 : if (rc < 0) {
5330 : 0 : PMD_INIT_LOG(ERR, "Unsupported loopback mode");
5331 : 0 : return rc;
5332 : : }
5333 : 0 : hlreg0 |= IXGBE_HLREG0_LPBK;
5334 : : } else {
5335 : 0 : hlreg0 &= ~IXGBE_HLREG0_LPBK;
5336 : : }
5337 : :
5338 : 0 : IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
5339 : :
5340 : : /*
5341 : : * Assume no header split and no VLAN strip support
5342 : : * on any Rx queue first .
5343 : : */
5344 : 0 : rx_conf->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
5345 : : /* Setup RX queues */
5346 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5347 : 0 : rxq = dev->data->rx_queues[i];
5348 : :
5349 : : /*
5350 : : * Reset crc_len in case it was changed after queue setup by a
5351 : : * call to configure.
5352 : : */
5353 [ # # ]: 0 : if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
5354 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
5355 : : else
5356 : 0 : rxq->crc_len = 0;
5357 : :
5358 : : /* Setup the Base and Length of the Rx Descriptor Rings */
5359 : 0 : bus_addr = rxq->rx_ring_phys_addr;
5360 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDBAL(rxq->reg_idx),
5361 : : (uint32_t)(bus_addr & 0x00000000ffffffffULL));
5362 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDBAH(rxq->reg_idx),
5363 : : (uint32_t)(bus_addr >> 32));
5364 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDLEN(rxq->reg_idx),
5365 : : rxq->nb_rx_desc * sizeof(union ixgbe_adv_rx_desc));
5366 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDH(rxq->reg_idx), 0);
5367 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDT(rxq->reg_idx), 0);
5368 : :
5369 : : /* Configure the SRRCTL register */
5370 : : srrctl = IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
5371 : :
5372 : : /* Set if packets are dropped when no descriptors available */
5373 [ # # ]: 0 : if (rxq->drop_en)
5374 : : srrctl |= IXGBE_SRRCTL_DROP_EN;
5375 : :
5376 : : /*
5377 : : * Configure the RX buffer size in the BSIZEPACKET field of
5378 : : * the SRRCTL register of the queue.
5379 : : * The value is in 1 KB resolution. Valid values can be from
5380 : : * 1 KB to 16 KB.
5381 : : */
5382 [ # # ]: 0 : buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
5383 : : RTE_PKTMBUF_HEADROOM);
5384 : 0 : srrctl |= ((buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) &
5385 : : IXGBE_SRRCTL_BSIZEPKT_MASK);
5386 : :
5387 [ # # # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rxq->reg_idx), srrctl);
5388 : :
5389 : 0 : buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
5390 : : IXGBE_SRRCTL_BSIZEPKT_SHIFT);
5391 : :
5392 : : /* It adds dual VLAN length for supporting dual VLAN */
5393 [ # # ]: 0 : if (frame_size + 2 * RTE_VLAN_HLEN > buf_size)
5394 : 0 : dev->data->scattered_rx = 1;
5395 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
5396 : 0 : rx_conf->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
5397 : : }
5398 : :
5399 [ # # ]: 0 : if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_SCATTER)
5400 : 0 : dev->data->scattered_rx = 1;
5401 : :
5402 : : /*
5403 : : * Device configured with multiple RX queues.
5404 : : */
5405 : 0 : ixgbe_dev_mq_rx_configure(dev);
5406 : :
5407 : : /*
5408 : : * Setup the Checksum Register.
5409 : : * Disable Full-Packet Checksum which is mutually exclusive with RSS.
5410 : : * Enable IP/L4 checksum computation by hardware if requested to do so.
5411 : : */
5412 : 0 : rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
5413 : : rxcsum |= IXGBE_RXCSUM_PCSD;
5414 [ # # ]: 0 : if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_CHECKSUM)
5415 : 0 : rxcsum |= IXGBE_RXCSUM_IPPCSE;
5416 : : else
5417 : 0 : rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
5418 : :
5419 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXCSUM, rxcsum);
5420 : :
5421 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB ||
5422 : : hw->mac.type == ixgbe_mac_X540) {
5423 : 0 : rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
5424 [ # # ]: 0 : if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
5425 : 0 : rdrxctl &= ~IXGBE_RDRXCTL_CRCSTRIP;
5426 : : else
5427 : 0 : rdrxctl |= IXGBE_RDRXCTL_CRCSTRIP;
5428 : 0 : rdrxctl &= ~IXGBE_RDRXCTL_RSCFRSTSIZE;
5429 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
5430 : : }
5431 : :
5432 : 0 : rc = ixgbe_set_rsc(dev);
5433 [ # # ]: 0 : if (rc)
5434 : : return rc;
5435 : :
5436 : 0 : ixgbe_set_rx_function(dev);
5437 : :
5438 : 0 : return 0;
5439 : : }
5440 : :
5441 : : /*
5442 : : * Initializes Transmit Unit.
5443 : : */
5444 : : void __rte_cold
5445 : 0 : ixgbe_dev_tx_init(struct rte_eth_dev *dev)
5446 : : {
5447 : : struct ixgbe_hw *hw;
5448 : : struct ci_tx_queue *txq;
5449 : : uint64_t bus_addr;
5450 : : uint32_t hlreg0;
5451 : : uint32_t txctrl;
5452 : : uint16_t i;
5453 : :
5454 : 0 : PMD_INIT_FUNC_TRACE();
5455 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5456 : :
5457 : : /* Enable TX CRC (checksum offload requirement) and hw padding
5458 : : * (TSO requirement)
5459 : : */
5460 : 0 : hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
5461 : 0 : hlreg0 |= (IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_TXPADEN);
5462 : 0 : IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
5463 : :
5464 : : /* Setup the Base and Length of the Tx Descriptor Rings */
5465 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
5466 : 0 : txq = dev->data->tx_queues[i];
5467 : :
5468 : 0 : bus_addr = txq->tx_ring_dma;
5469 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDBAL(txq->reg_idx),
5470 : : (uint32_t)(bus_addr & 0x00000000ffffffffULL));
5471 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDBAH(txq->reg_idx),
5472 : : (uint32_t)(bus_addr >> 32));
5473 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDLEN(txq->reg_idx),
5474 : : txq->nb_tx_desc * sizeof(union ixgbe_adv_tx_desc));
5475 : : /* Setup the HW Tx Head and TX Tail descriptor pointers */
5476 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDH(txq->reg_idx), 0);
5477 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDT(txq->reg_idx), 0);
5478 : :
5479 : : /*
5480 : : * Disable Tx Head Writeback RO bit, since this hoses
5481 : : * bookkeeping if things aren't delivered in order.
5482 : : */
5483 [ # # ]: 0 : switch (hw->mac.type) {
5484 : 0 : case ixgbe_mac_82598EB:
5485 : 0 : txctrl = IXGBE_READ_REG(hw,
5486 : : IXGBE_DCA_TXCTRL(txq->reg_idx));
5487 : 0 : txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
5488 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(txq->reg_idx),
5489 : : txctrl);
5490 : : break;
5491 : :
5492 : 0 : case ixgbe_mac_82599EB:
5493 : : case ixgbe_mac_X540:
5494 : : case ixgbe_mac_X550:
5495 : : case ixgbe_mac_X550EM_x:
5496 : : case ixgbe_mac_X550EM_a:
5497 : : default:
5498 : 0 : txctrl = IXGBE_READ_REG(hw,
5499 : : IXGBE_DCA_TXCTRL_82599(txq->reg_idx));
5500 : 0 : txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
5501 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(txq->reg_idx),
5502 : : txctrl);
5503 : : break;
5504 : : }
5505 : : }
5506 : :
5507 : : /* Device configured with multiple TX queues. */
5508 : 0 : ixgbe_dev_mq_tx_configure(dev);
5509 : 0 : }
5510 : :
5511 : : /*
5512 : : * Check if requested loopback mode is supported
5513 : : */
5514 : : int
5515 : 0 : ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev)
5516 : : {
5517 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5518 : :
5519 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_TX_RX)
5520 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB ||
5521 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X540 ||
5522 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550 ||
5523 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
5524 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_a ||
5525 : : hw->mac.type == ixgbe_mac_E610)
5526 : 0 : return 0;
5527 : :
5528 : : return -ENOTSUP;
5529 : : }
5530 : :
5531 : : /*
5532 : : * Set up link for 82599 loopback mode Tx->Rx.
5533 : : */
5534 : : static inline void __rte_cold
5535 : 0 : ixgbe_setup_loopback_link_82599(struct ixgbe_hw *hw)
5536 : : {
5537 : 0 : PMD_INIT_FUNC_TRACE();
5538 : :
5539 [ # # ]: 0 : if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
5540 [ # # ]: 0 : if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM) !=
5541 : : IXGBE_SUCCESS) {
5542 : 0 : PMD_INIT_LOG(ERR, "Could not enable loopback mode");
5543 : : /* ignore error */
5544 : 0 : return;
5545 : : }
5546 : : }
5547 : :
5548 : : /* Restart link */
5549 : 0 : IXGBE_WRITE_REG(hw,
5550 : : IXGBE_AUTOC,
5551 : : IXGBE_AUTOC_LMS_10G_LINK_NO_AN | IXGBE_AUTOC_FLU);
5552 : 0 : ixgbe_reset_pipeline_82599(hw);
5553 : :
5554 : 0 : hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
5555 : 0 : msec_delay(50);
5556 : : }
5557 : :
5558 : :
5559 : : /*
5560 : : * Start Transmit and Receive Units.
5561 : : */
5562 : : int __rte_cold
5563 : 0 : ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
5564 : : {
5565 : : struct ixgbe_hw *hw;
5566 : : struct ci_tx_queue *txq;
5567 : : struct ixgbe_rx_queue *rxq;
5568 : : uint32_t txdctl;
5569 : : uint32_t dmatxctl;
5570 : : uint32_t rxctrl;
5571 : : uint16_t i;
5572 : : int ret = 0;
5573 : :
5574 : 0 : PMD_INIT_FUNC_TRACE();
5575 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5576 : :
5577 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
5578 : 0 : txq = dev->data->tx_queues[i];
5579 : : /* Setup Transmit Threshold Registers */
5580 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
5581 : 0 : txdctl |= txq->pthresh & 0x7F;
5582 : 0 : txdctl |= ((txq->hthresh & 0x7F) << 8);
5583 : 0 : txdctl |= ((txq->wthresh & 0x7F) << 16);
5584 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl);
5585 : : }
5586 : :
5587 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
5588 : 0 : dmatxctl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
5589 : 0 : dmatxctl |= IXGBE_DMATXCTL_TE;
5590 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, dmatxctl);
5591 : : }
5592 : :
5593 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
5594 : 0 : txq = dev->data->tx_queues[i];
5595 [ # # ]: 0 : if (!txq->tx_deferred_start) {
5596 : 0 : ret = ixgbe_dev_tx_queue_start(dev, i);
5597 [ # # ]: 0 : if (ret < 0)
5598 : 0 : return ret;
5599 : : }
5600 : : }
5601 : :
5602 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5603 : 0 : rxq = dev->data->rx_queues[i];
5604 [ # # ]: 0 : if (!rxq->rx_deferred_start) {
5605 : 0 : ret = ixgbe_dev_rx_queue_start(dev, i);
5606 [ # # ]: 0 : if (ret < 0)
5607 : 0 : return ret;
5608 : : }
5609 : : }
5610 : :
5611 : : /* Enable Receive engine */
5612 : 0 : rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
5613 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
5614 : 0 : rxctrl |= IXGBE_RXCTRL_DMBYPS;
5615 : 0 : rxctrl |= IXGBE_RXCTRL_RXEN;
5616 : 0 : hw->mac.ops.enable_rx_dma(hw, rxctrl);
5617 : :
5618 : : /* If loopback mode is enabled, set up the link accordingly */
5619 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode != 0) {
5620 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB)
5621 : 0 : ixgbe_setup_loopback_link_82599(hw);
5622 [ # # ]: 0 : else if (hw->mac.type == ixgbe_mac_X540 ||
5623 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550 ||
5624 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
5625 : : hw->mac.type == ixgbe_mac_X550EM_a)
5626 : 0 : ixgbe_setup_loopback_link_x540_x550(hw, true);
5627 : : }
5628 : :
5629 : : #ifdef RTE_LIB_SECURITY
5630 [ # # ]: 0 : if ((dev->data->dev_conf.rxmode.offloads &
5631 : 0 : RTE_ETH_RX_OFFLOAD_SECURITY) ||
5632 [ # # ]: 0 : (dev->data->dev_conf.txmode.offloads &
5633 : : RTE_ETH_TX_OFFLOAD_SECURITY)) {
5634 : 0 : ret = ixgbe_crypto_enable_ipsec(dev);
5635 [ # # ]: 0 : if (ret != 0) {
5636 : 0 : PMD_DRV_LOG(ERR,
5637 : : "ixgbe_crypto_enable_ipsec fails with %d.",
5638 : : ret);
5639 : 0 : return ret;
5640 : : }
5641 : : }
5642 : : #endif
5643 : :
5644 : : return 0;
5645 : : }
5646 : :
5647 : : /*
5648 : : * Start Receive Units for specified queue.
5649 : : */
5650 : : int __rte_cold
5651 : 0 : ixgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
5652 : : {
5653 : : struct ixgbe_hw *hw;
5654 : : struct ixgbe_rx_queue *rxq;
5655 : : uint32_t rxdctl;
5656 : : int poll_ms;
5657 : :
5658 : 0 : PMD_INIT_FUNC_TRACE();
5659 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5660 : :
5661 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
5662 : :
5663 : : /* Allocate buffers for descriptor rings */
5664 [ # # ]: 0 : if (ixgbe_alloc_rx_queue_mbufs(rxq) != 0) {
5665 : 0 : PMD_INIT_LOG(ERR, "Could not alloc mbuf for queue:%d",
5666 : : rx_queue_id);
5667 : 0 : return -1;
5668 : : }
5669 [ # # ]: 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
5670 : 0 : rxdctl |= IXGBE_RXDCTL_ENABLE;
5671 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), rxdctl);
5672 : :
5673 : : /* Wait until RX Enable ready */
5674 : : poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS;
5675 : : do {
5676 : : rte_delay_ms(1);
5677 [ # # ]: 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
5678 [ # # # # ]: 0 : } while (--poll_ms && !(rxdctl & IXGBE_RXDCTL_ENABLE));
5679 [ # # ]: 0 : if (!poll_ms)
5680 : 0 : PMD_INIT_LOG(ERR, "Could not enable Rx Queue %d", rx_queue_id);
5681 : : rte_wmb();
5682 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDH(rxq->reg_idx), 0);
5683 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RDT(rxq->reg_idx), rxq->nb_rx_desc - 1);
5684 : 0 : dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
5685 : :
5686 : 0 : return 0;
5687 : : }
5688 : :
5689 : : /*
5690 : : * Stop Receive Units for specified queue.
5691 : : */
5692 : : int __rte_cold
5693 : 0 : ixgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
5694 : : {
5695 : : struct ixgbe_hw *hw;
5696 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
5697 : : struct ixgbe_rx_queue *rxq;
5698 : : uint32_t rxdctl;
5699 : : int poll_ms;
5700 : :
5701 : 0 : PMD_INIT_FUNC_TRACE();
5702 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5703 : :
5704 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
5705 : :
5706 [ # # ]: 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
5707 : 0 : rxdctl &= ~IXGBE_RXDCTL_ENABLE;
5708 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), rxdctl);
5709 : :
5710 : : /* Wait until RX Enable bit clear */
5711 : : poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS;
5712 : : do {
5713 : : rte_delay_ms(1);
5714 [ # # ]: 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
5715 [ # # # # ]: 0 : } while (--poll_ms && (rxdctl & IXGBE_RXDCTL_ENABLE));
5716 [ # # ]: 0 : if (!poll_ms)
5717 : 0 : PMD_INIT_LOG(ERR, "Could not disable Rx Queue %d", rx_queue_id);
5718 : :
5719 : 0 : rte_delay_us(RTE_IXGBE_WAIT_100_US);
5720 : :
5721 : 0 : ixgbe_rx_queue_release_mbufs(rxq);
5722 : 0 : ixgbe_reset_rx_queue(adapter, rxq);
5723 : 0 : dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
5724 : :
5725 : 0 : return 0;
5726 : : }
5727 : :
5728 : :
5729 : : /*
5730 : : * Start Transmit Units for specified queue.
5731 : : */
5732 : : int __rte_cold
5733 : 0 : ixgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
5734 : : {
5735 : : struct ixgbe_hw *hw;
5736 : : struct ci_tx_queue *txq;
5737 : : uint32_t txdctl;
5738 : : int poll_ms;
5739 : :
5740 : 0 : PMD_INIT_FUNC_TRACE();
5741 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5742 : :
5743 : 0 : txq = dev->data->tx_queues[tx_queue_id];
5744 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDH(txq->reg_idx), 0);
5745 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
5746 : 0 : txdctl |= IXGBE_TXDCTL_ENABLE;
5747 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl);
5748 : :
5749 : : /* Wait until TX Enable ready */
5750 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB) {
5751 : : poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS;
5752 : : do {
5753 : : rte_delay_ms(1);
5754 : 0 : txdctl = IXGBE_READ_REG(hw,
5755 : : IXGBE_TXDCTL(txq->reg_idx));
5756 [ # # # # ]: 0 : } while (--poll_ms && !(txdctl & IXGBE_TXDCTL_ENABLE));
5757 [ # # ]: 0 : if (!poll_ms)
5758 : 0 : PMD_INIT_LOG(ERR, "Could not enable Tx Queue %d",
5759 : : tx_queue_id);
5760 : : }
5761 : : rte_wmb();
5762 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TDT(txq->reg_idx), 0);
5763 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
5764 : :
5765 : 0 : return 0;
5766 : : }
5767 : :
5768 : : /*
5769 : : * Stop Transmit Units for specified queue.
5770 : : */
5771 : : int __rte_cold
5772 : 0 : ixgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
5773 : : {
5774 : : struct ixgbe_hw *hw;
5775 : : struct ci_tx_queue *txq;
5776 : : uint32_t txdctl;
5777 : : uint32_t txtdh, txtdt;
5778 : : int poll_ms;
5779 : :
5780 : 0 : PMD_INIT_FUNC_TRACE();
5781 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5782 : :
5783 : 0 : txq = dev->data->tx_queues[tx_queue_id];
5784 : :
5785 : : /* Wait until TX queue is empty */
5786 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB) {
5787 : : poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS;
5788 : : do {
5789 : 0 : rte_delay_us(RTE_IXGBE_WAIT_100_US);
5790 : 0 : txtdh = IXGBE_READ_REG(hw,
5791 : : IXGBE_TDH(txq->reg_idx));
5792 : 0 : txtdt = IXGBE_READ_REG(hw,
5793 : : IXGBE_TDT(txq->reg_idx));
5794 [ # # # # ]: 0 : } while (--poll_ms && (txtdh != txtdt));
5795 [ # # ]: 0 : if (!poll_ms)
5796 : 0 : PMD_INIT_LOG(ERR,
5797 : : "Tx Queue %d is not empty when stopping.",
5798 : : tx_queue_id);
5799 : : }
5800 : :
5801 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
5802 : 0 : txdctl &= ~IXGBE_TXDCTL_ENABLE;
5803 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl);
5804 : :
5805 : : /* Wait until TX Enable bit clear */
5806 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB) {
5807 : : poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS;
5808 : : do {
5809 : : rte_delay_ms(1);
5810 : 0 : txdctl = IXGBE_READ_REG(hw,
5811 : : IXGBE_TXDCTL(txq->reg_idx));
5812 [ # # # # ]: 0 : } while (--poll_ms && (txdctl & IXGBE_TXDCTL_ENABLE));
5813 [ # # ]: 0 : if (!poll_ms)
5814 : 0 : PMD_INIT_LOG(ERR, "Could not disable Tx Queue %d",
5815 : : tx_queue_id);
5816 : : }
5817 : :
5818 [ # # ]: 0 : if (txq->ops != NULL) {
5819 : 0 : ci_txq_release_all_mbufs(txq, false);
5820 : 0 : txq->ops->reset(txq);
5821 : : }
5822 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
5823 : :
5824 : 0 : return 0;
5825 : : }
5826 : :
5827 : : void
5828 : 0 : ixgbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
5829 : : struct rte_eth_rxq_info *qinfo)
5830 : : {
5831 : : struct ixgbe_rx_queue *rxq;
5832 : :
5833 : 0 : rxq = dev->data->rx_queues[queue_id];
5834 : :
5835 : 0 : qinfo->mp = rxq->mb_pool;
5836 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
5837 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
5838 : :
5839 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
5840 : 0 : qinfo->conf.rx_drop_en = rxq->drop_en;
5841 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
5842 : 0 : qinfo->conf.offloads = rxq->offloads;
5843 : 0 : }
5844 : :
5845 : : void
5846 : 0 : ixgbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
5847 : : struct rte_eth_txq_info *qinfo)
5848 : : {
5849 : : struct ci_tx_queue *txq;
5850 : :
5851 : 0 : txq = dev->data->tx_queues[queue_id];
5852 : :
5853 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
5854 : :
5855 : 0 : qinfo->conf.tx_thresh.pthresh = txq->pthresh;
5856 : 0 : qinfo->conf.tx_thresh.hthresh = txq->hthresh;
5857 : 0 : qinfo->conf.tx_thresh.wthresh = txq->wthresh;
5858 : :
5859 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
5860 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
5861 : 0 : qinfo->conf.offloads = txq->offloads;
5862 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
5863 : 0 : }
5864 : :
5865 : : void
5866 : 0 : ixgbe_recycle_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
5867 : : struct rte_eth_recycle_rxq_info *recycle_rxq_info)
5868 : : {
5869 : : struct ixgbe_rx_queue *rxq;
5870 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
5871 : :
5872 : 0 : rxq = dev->data->rx_queues[queue_id];
5873 : :
5874 : 0 : recycle_rxq_info->mbuf_ring = (void *)rxq->sw_ring;
5875 : 0 : recycle_rxq_info->mp = rxq->mb_pool;
5876 : 0 : recycle_rxq_info->mbuf_ring_size = rxq->nb_rx_desc;
5877 : 0 : recycle_rxq_info->receive_tail = &rxq->rx_tail;
5878 : :
5879 [ # # ]: 0 : if (adapter->rx_vec_allowed) {
5880 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
5881 : 0 : recycle_rxq_info->refill_requirement = RTE_IXGBE_RXQ_REARM_THRESH;
5882 : 0 : recycle_rxq_info->refill_head = &rxq->rxrearm_start;
5883 : : #endif
5884 : : } else {
5885 : 0 : recycle_rxq_info->refill_requirement = rxq->rx_free_thresh;
5886 : 0 : recycle_rxq_info->refill_head = &rxq->rx_free_trigger;
5887 : : }
5888 : 0 : }
5889 : :
5890 : : /*
5891 : : * [VF] Initializes Receive Unit.
5892 : : */
5893 : : int __rte_cold
5894 : 0 : ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
5895 : : {
5896 : : struct ixgbe_hw *hw;
5897 : : struct ixgbe_rx_queue *rxq;
5898 : 0 : struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
5899 : 0 : uint32_t frame_size = dev->data->mtu + IXGBE_ETH_OVERHEAD;
5900 : : uint64_t bus_addr;
5901 : : uint32_t srrctl, psrtype = 0;
5902 : : uint16_t buf_size;
5903 : : uint16_t i;
5904 : : int ret;
5905 : :
5906 : 0 : PMD_INIT_FUNC_TRACE();
5907 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5908 : :
5909 [ # # ]: 0 : if (rte_is_power_of_2(dev->data->nb_rx_queues) == 0) {
5910 : 0 : PMD_INIT_LOG(ERR, "The number of Rx queue invalid, "
5911 : : "it should be power of 2");
5912 : 0 : return -1;
5913 : : }
5914 : :
5915 [ # # ]: 0 : if (dev->data->nb_rx_queues > hw->mac.max_rx_queues) {
5916 : 0 : PMD_INIT_LOG(ERR, "The number of Rx queue invalid, "
5917 : : "it should be equal to or less than %d",
5918 : : hw->mac.max_rx_queues);
5919 : 0 : return -1;
5920 : : }
5921 : :
5922 : : /*
5923 : : * When the VF driver issues a IXGBE_VF_RESET request, the PF driver
5924 : : * disables the VF receipt of packets if the PF MTU is > 1500.
5925 : : * This is done to deal with 82599 limitations that imposes
5926 : : * the PF and all VFs to share the same MTU.
5927 : : * Then, the PF driver enables again the VF receipt of packet when
5928 : : * the VF driver issues a IXGBE_VF_SET_LPE request.
5929 : : * In the meantime, the VF device cannot be used, even if the VF driver
5930 : : * and the Guest VM network stack are ready to accept packets with a
5931 : : * size up to the PF MTU.
5932 : : * As a work-around to this PF behaviour, force the call to
5933 : : * ixgbevf_rlpml_set_vf even if jumbo frames are not used. This way,
5934 : : * VF packets received can work in all cases.
5935 : : */
5936 [ # # ]: 0 : if (ixgbevf_rlpml_set_vf(hw, frame_size) != 0)
5937 : 0 : PMD_INIT_LOG(ERR, "Set max packet length to %d failed.",
5938 : : frame_size);
5939 : :
5940 : : /*
5941 : : * Assume no header split and no VLAN strip support
5942 : : * on any Rx queue first .
5943 : : */
5944 : 0 : rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
5945 : : /* Setup RX queues */
5946 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5947 : 0 : rxq = dev->data->rx_queues[i];
5948 : :
5949 : : /* Allocate buffers for descriptor rings */
5950 : 0 : ret = ixgbe_alloc_rx_queue_mbufs(rxq);
5951 [ # # ]: 0 : if (ret)
5952 : 0 : return ret;
5953 : :
5954 : : /* Setup the Base and Length of the Rx Descriptor Rings */
5955 : 0 : bus_addr = rxq->rx_ring_phys_addr;
5956 : :
5957 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDBAL(i),
5958 : : (uint32_t)(bus_addr & 0x00000000ffffffffULL));
5959 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDBAH(i),
5960 : : (uint32_t)(bus_addr >> 32));
5961 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDLEN(i),
5962 : : rxq->nb_rx_desc * sizeof(union ixgbe_adv_rx_desc));
5963 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDH(i), 0);
5964 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), 0);
5965 : :
5966 : :
5967 : : /* Configure the SRRCTL register */
5968 : : srrctl = IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
5969 : :
5970 : : /* Set if packets are dropped when no descriptors available */
5971 [ # # ]: 0 : if (rxq->drop_en)
5972 : : srrctl |= IXGBE_SRRCTL_DROP_EN;
5973 : :
5974 : : /*
5975 : : * Configure the RX buffer size in the BSIZEPACKET field of
5976 : : * the SRRCTL register of the queue.
5977 : : * The value is in 1 KB resolution. Valid values can be from
5978 : : * 1 KB to 16 KB.
5979 : : */
5980 [ # # ]: 0 : buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
5981 : : RTE_PKTMBUF_HEADROOM);
5982 : 0 : srrctl |= ((buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) &
5983 : : IXGBE_SRRCTL_BSIZEPKT_MASK);
5984 : :
5985 : : /*
5986 : : * VF modification to write virtual function SRRCTL register
5987 : : */
5988 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFSRRCTL(i), srrctl);
5989 : :
5990 : 0 : buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
5991 : : IXGBE_SRRCTL_BSIZEPKT_SHIFT);
5992 : :
5993 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_SCATTER ||
5994 : : /* It adds dual VLAN length for supporting dual VLAN */
5995 [ # # ]: 0 : (frame_size + 2 * RTE_VLAN_HLEN) > buf_size) {
5996 [ # # ]: 0 : if (!dev->data->scattered_rx)
5997 : 0 : PMD_INIT_LOG(DEBUG, "forcing scatter mode");
5998 : 0 : dev->data->scattered_rx = 1;
5999 : : }
6000 : :
6001 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
6002 : 0 : rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
6003 : : }
6004 : :
6005 : : /* Set RQPL for VF RSS according to max Rx queue */
6006 : 0 : psrtype |= (dev->data->nb_rx_queues >> 1) <<
6007 : : IXGBE_PSRTYPE_RQPL_SHIFT;
6008 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, psrtype);
6009 : :
6010 : : /* Initialize the rss for x550_vf cards if enabled */
6011 [ # # ]: 0 : switch (hw->mac.type) {
6012 : 0 : case ixgbe_mac_X550_vf:
6013 : : case ixgbe_mac_X550EM_x_vf:
6014 : : case ixgbe_mac_X550EM_a_vf:
6015 : : case ixgbe_mac_E610_vf:
6016 [ # # ]: 0 : switch (dev->data->dev_conf.rxmode.mq_mode) {
6017 : 0 : case RTE_ETH_MQ_RX_RSS:
6018 : : case RTE_ETH_MQ_RX_DCB_RSS:
6019 : : case RTE_ETH_MQ_RX_VMDQ_RSS:
6020 : 0 : ixgbe_rss_configure(dev);
6021 : 0 : break;
6022 : : default:
6023 : : break;
6024 : : }
6025 : : break;
6026 : : default:
6027 : : break;
6028 : : }
6029 : :
6030 : 0 : ixgbe_set_rx_function(dev);
6031 : :
6032 : 0 : return 0;
6033 : : }
6034 : :
6035 : : /*
6036 : : * [VF] Initializes Transmit Unit.
6037 : : */
6038 : : void __rte_cold
6039 : 0 : ixgbevf_dev_tx_init(struct rte_eth_dev *dev)
6040 : : {
6041 : : struct ixgbe_hw *hw;
6042 : : struct ci_tx_queue *txq;
6043 : : uint64_t bus_addr;
6044 : : uint32_t txctrl;
6045 : : uint16_t i;
6046 : :
6047 : 0 : PMD_INIT_FUNC_TRACE();
6048 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6049 : :
6050 : : /* Setup the Base and Length of the Tx Descriptor Rings */
6051 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
6052 : 0 : txq = dev->data->tx_queues[i];
6053 : 0 : bus_addr = txq->tx_ring_dma;
6054 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTDBAL(i),
6055 : : (uint32_t)(bus_addr & 0x00000000ffffffffULL));
6056 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTDBAH(i),
6057 : : (uint32_t)(bus_addr >> 32));
6058 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTDLEN(i),
6059 : : txq->nb_tx_desc * sizeof(union ixgbe_adv_tx_desc));
6060 : : /* Setup the HW Tx Head and TX Tail descriptor pointers */
6061 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTDH(i), 0);
6062 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTDT(i), 0);
6063 : :
6064 : : /*
6065 : : * Disable Tx Head Writeback RO bit, since this hoses
6066 : : * bookkeeping if things aren't delivered in order.
6067 : : */
6068 : 0 : txctrl = IXGBE_READ_REG(hw,
6069 : : IXGBE_VFDCA_TXCTRL(i));
6070 : 0 : txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
6071 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFDCA_TXCTRL(i),
6072 : : txctrl);
6073 : : }
6074 : 0 : }
6075 : :
6076 : : /*
6077 : : * [VF] Start Transmit and Receive Units.
6078 : : */
6079 : : void __rte_cold
6080 : 0 : ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
6081 : : {
6082 : : struct ixgbe_hw *hw;
6083 : : struct ci_tx_queue *txq;
6084 : : struct ixgbe_rx_queue *rxq;
6085 : : uint32_t txdctl;
6086 : : uint32_t rxdctl;
6087 : : uint16_t i;
6088 : : int poll_ms;
6089 : :
6090 : 0 : PMD_INIT_FUNC_TRACE();
6091 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6092 : :
6093 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
6094 : 0 : txq = dev->data->tx_queues[i];
6095 : : /* Setup Transmit Threshold Registers */
6096 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
6097 : 0 : txdctl |= txq->pthresh & 0x7F;
6098 : 0 : txdctl |= ((txq->hthresh & 0x7F) << 8);
6099 : 0 : txdctl |= ((txq->wthresh & 0x7F) << 16);
6100 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTXDCTL(i), txdctl);
6101 : : }
6102 : :
6103 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
6104 : :
6105 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
6106 : 0 : txdctl |= IXGBE_TXDCTL_ENABLE;
6107 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTXDCTL(i), txdctl);
6108 : :
6109 : : poll_ms = 10;
6110 : : /* Wait until TX Enable ready */
6111 : : do {
6112 : : rte_delay_ms(1);
6113 : 0 : txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
6114 [ # # # # ]: 0 : } while (--poll_ms && !(txdctl & IXGBE_TXDCTL_ENABLE));
6115 [ # # ]: 0 : if (!poll_ms)
6116 : 0 : PMD_INIT_LOG(ERR, "Could not enable Tx Queue %d", i);
6117 : : else
6118 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
6119 : : }
6120 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
6121 : :
6122 : 0 : rxq = dev->data->rx_queues[i];
6123 : :
6124 : 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
6125 : 0 : rxdctl |= IXGBE_RXDCTL_ENABLE;
6126 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(i), rxdctl);
6127 : :
6128 : : /* Wait until RX Enable ready */
6129 : : poll_ms = 10;
6130 : : do {
6131 : : rte_delay_ms(1);
6132 : 0 : rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
6133 [ # # # # ]: 0 : } while (--poll_ms && !(rxdctl & IXGBE_RXDCTL_ENABLE));
6134 [ # # ]: 0 : if (!poll_ms)
6135 : 0 : PMD_INIT_LOG(ERR, "Could not enable Rx Queue %d", i);
6136 : : else
6137 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
6138 : : rte_wmb();
6139 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), rxq->nb_rx_desc - 1);
6140 : :
6141 : : }
6142 : 0 : }
6143 : :
6144 : : int
6145 : 0 : ixgbe_rss_conf_init(struct ixgbe_rte_flow_rss_conf *out,
6146 : : const struct rte_flow_action_rss *in)
6147 : : {
6148 [ # # ]: 0 : if (in->key_len > RTE_DIM(out->key) ||
6149 [ # # ]: 0 : in->queue_num > RTE_DIM(out->queue))
6150 : : return -EINVAL;
6151 : 0 : out->conf = (struct rte_flow_action_rss){
6152 : 0 : .func = in->func,
6153 : 0 : .level = in->level,
6154 : 0 : .types = in->types,
6155 : : .key_len = in->key_len,
6156 : : .queue_num = in->queue_num,
6157 : 0 : .key = memcpy(out->key, in->key, in->key_len),
6158 : 0 : .queue = memcpy(out->queue, in->queue,
6159 : 0 : sizeof(*in->queue) * in->queue_num),
6160 : : };
6161 : 0 : return 0;
6162 : : }
6163 : :
6164 : : int
6165 : 0 : ixgbe_action_rss_same(const struct rte_flow_action_rss *comp,
6166 : : const struct rte_flow_action_rss *with)
6167 : : {
6168 : 0 : return (comp->func == with->func &&
6169 : 0 : comp->level == with->level &&
6170 [ # # ]: 0 : comp->types == with->types &&
6171 [ # # ]: 0 : comp->key_len == with->key_len &&
6172 : 0 : comp->queue_num == with->queue_num &&
6173 [ # # # # ]: 0 : !memcmp(comp->key, with->key, with->key_len) &&
6174 : 0 : !memcmp(comp->queue, with->queue,
6175 [ # # ]: 0 : sizeof(*with->queue) * with->queue_num));
6176 : : }
6177 : :
6178 : : int
6179 : 0 : ixgbe_config_rss_filter(struct rte_eth_dev *dev,
6180 : : struct ixgbe_rte_flow_rss_conf *conf, bool add)
6181 : : {
6182 : : struct ixgbe_hw *hw;
6183 : : uint32_t reta;
6184 : : uint16_t i;
6185 : : uint16_t j;
6186 : : uint16_t sp_reta_size;
6187 : : uint32_t reta_reg;
6188 : 0 : struct rte_eth_rss_conf rss_conf = {
6189 : 0 : .rss_key = conf->conf.key_len ?
6190 [ # # ]: 0 : (void *)(uintptr_t)conf->conf.key : NULL,
6191 : : .rss_key_len = conf->conf.key_len,
6192 : 0 : .rss_hf = conf->conf.types,
6193 : : };
6194 : : struct ixgbe_filter_info *filter_info =
6195 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6196 : :
6197 : 0 : PMD_INIT_FUNC_TRACE();
6198 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6199 : :
6200 : 0 : sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
6201 : :
6202 [ # # ]: 0 : if (!add) {
6203 [ # # ]: 0 : if (ixgbe_action_rss_same(&filter_info->rss_info.conf,
6204 : 0 : &conf->conf)) {
6205 : : ixgbe_rss_disable(dev);
6206 : 0 : memset(&filter_info->rss_info, 0,
6207 : : sizeof(struct ixgbe_rte_flow_rss_conf));
6208 : 0 : return 0;
6209 : : }
6210 : : return -EINVAL;
6211 : : }
6212 : :
6213 [ # # ]: 0 : if (filter_info->rss_info.conf.queue_num)
6214 : : return -EINVAL;
6215 : : /* Fill in redirection table
6216 : : * The byte-swap is needed because NIC registers are in
6217 : : * little-endian order.
6218 : : */
6219 : : reta = 0;
6220 [ # # ]: 0 : for (i = 0, j = 0; i < sp_reta_size; i++, j++) {
6221 : 0 : reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
6222 : :
6223 [ # # ]: 0 : if (j == conf->conf.queue_num)
6224 : : j = 0;
6225 : 0 : reta = (reta << 8) | conf->conf.queue[j];
6226 [ # # ]: 0 : if ((i & 3) == 3)
6227 [ # # ]: 0 : IXGBE_WRITE_REG(hw, reta_reg,
6228 : : rte_bswap32(reta));
6229 : : }
6230 : :
6231 : : /* Configure the RSS key and the RSS protocols used to compute
6232 : : * the RSS hash of input packets.
6233 : : */
6234 [ # # ]: 0 : if ((rss_conf.rss_hf & IXGBE_RSS_OFFLOAD_ALL) == 0) {
6235 : : ixgbe_rss_disable(dev);
6236 : 0 : return 0;
6237 : : }
6238 [ # # ]: 0 : if (rss_conf.rss_key == NULL)
6239 : 0 : rss_conf.rss_key = rss_intel_key; /* Default hash key */
6240 : 0 : ixgbe_hw_rss_hash_set(hw, &rss_conf);
6241 : :
6242 [ # # ]: 0 : if (ixgbe_rss_conf_init(&filter_info->rss_info, &conf->conf))
6243 : 0 : return -EINVAL;
6244 : :
6245 : : return 0;
6246 : : }
6247 : :
6248 : : /* Stubs needed for linkage when RTE_ARCH_PPC_64, RTE_ARCH_RISCV or
6249 : : * RTE_ARCH_LOONGARCH is set.
6250 : : */
6251 : : #if defined(RTE_ARCH_PPC_64) || defined(RTE_ARCH_RISCV) || \
6252 : : defined(RTE_ARCH_LOONGARCH)
6253 : : int
6254 : : ixgbe_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev)
6255 : : {
6256 : : return -1;
6257 : : }
6258 : :
6259 : : uint16_t
6260 : : ixgbe_recv_pkts_vec(
6261 : : void __rte_unused *rx_queue,
6262 : : struct rte_mbuf __rte_unused **rx_pkts,
6263 : : uint16_t __rte_unused nb_pkts)
6264 : : {
6265 : : return 0;
6266 : : }
6267 : :
6268 : : uint16_t
6269 : : ixgbe_recv_scattered_pkts_vec(
6270 : : void __rte_unused *rx_queue,
6271 : : struct rte_mbuf __rte_unused **rx_pkts,
6272 : : uint16_t __rte_unused nb_pkts)
6273 : : {
6274 : : return 0;
6275 : : }
6276 : :
6277 : : int
6278 : : ixgbe_rxq_vec_setup(struct ixgbe_rx_queue __rte_unused *rxq)
6279 : : {
6280 : : return -1;
6281 : : }
6282 : :
6283 : : uint16_t
6284 : : ixgbe_xmit_fixed_burst_vec(void __rte_unused *tx_queue,
6285 : : struct rte_mbuf __rte_unused **tx_pkts,
6286 : : uint16_t __rte_unused nb_pkts)
6287 : : {
6288 : : return 0;
6289 : : }
6290 : :
6291 : : int
6292 : : ixgbe_txq_vec_setup(struct ci_tx_queue *txq __rte_unused)
6293 : : {
6294 : : return -1;
6295 : : }
6296 : :
6297 : : void
6298 : : ixgbe_rx_queue_release_mbufs_vec(struct ixgbe_rx_queue __rte_unused *rxq)
6299 : : {
6300 : : return;
6301 : : }
6302 : : #endif
|