1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017 6WIND S.A.
3 * Copyright 2017 Mellanox Technologies, Ltd
8 * Data plane functions for mlx4 driver.
16 /* Verbs headers do not support -pedantic. */
18 #pragma GCC diagnostic ignored "-Wpedantic"
20 #include <infiniband/verbs.h>
22 #pragma GCC diagnostic error "-Wpedantic"
25 #include <rte_branch_prediction.h>
26 #include <rte_common.h>
29 #include <rte_mempool.h>
30 #include <rte_prefetch.h>
34 #include "mlx4_rxtx.h"
35 #include "mlx4_utils.h"
38 * Pointer-value pair structure used in tx_post_send for saving the first
39 * DWORD (32 byte) of a TXBB.
43 volatile struct mlx4_wqe_data_seg *dseg;
44 volatile uint32_t *dst;
49 /** A helper structure for TSO packet handling. */
51 /** Pointer to the array of saved first DWORD (32 byte) of a TXBB. */
53 /** Current entry in the pv array. */
55 /** Total size of the WQE including padding. */
57 /** Size of TSO header to prepend to each packet to send. */
58 uint16_t tso_header_size;
59 /** Total size of the TSO segment in the WQE. */
60 uint16_t wqe_tso_seg_size;
61 /** Raw WQE size in units of 16 Bytes and without padding. */
65 /** A table to translate Rx completion flags to packet type. */
66 uint32_t mlx4_ptype_table[0x100] __rte_cache_aligned = {
68 * The index to the array should have:
69 * bit[7] - MLX4_CQE_L2_TUNNEL
70 * bit[6] - MLX4_CQE_L2_TUNNEL_IPV4
71 * bit[5] - MLX4_CQE_STATUS_UDP
72 * bit[4] - MLX4_CQE_STATUS_TCP
73 * bit[3] - MLX4_CQE_STATUS_IPV4OPT
74 * bit[2] - MLX4_CQE_STATUS_IPV6
75 * bit[1] - MLX4_CQE_STATUS_IPF
76 * bit[0] - MLX4_CQE_STATUS_IPV4
77 * giving a total of up to 256 entries.
80 [0x00] = RTE_PTYPE_L2_ETHER,
82 [0x01] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
84 [0x02] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
86 [0x03] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
88 [0x04] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
90 [0x06] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
92 [0x08] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
94 [0x09] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
96 [0x0a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
98 [0x0b] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
101 [0x11] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
103 [0x14] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
105 [0x16] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
107 [0x18] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
109 [0x19] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
112 [0x21] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
114 [0x24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
116 [0x26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
118 [0x28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
120 [0x29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT |
122 /* Tunneled - L3 IPV6 */
123 [0x80] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
124 [0x81] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
125 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
126 RTE_PTYPE_INNER_L4_NONFRAG,
127 [0x82] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
128 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
129 RTE_PTYPE_INNER_L4_FRAG,
130 [0x83] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
131 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
132 RTE_PTYPE_INNER_L4_FRAG,
133 [0x84] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
134 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
135 RTE_PTYPE_INNER_L4_NONFRAG,
136 [0x86] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
137 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
138 RTE_PTYPE_INNER_L4_FRAG,
139 [0x88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
140 RTE_PTYPE_INNER_L3_IPV4_EXT |
141 RTE_PTYPE_INNER_L4_NONFRAG,
142 [0x89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
143 RTE_PTYPE_INNER_L3_IPV4_EXT |
144 RTE_PTYPE_INNER_L4_NONFRAG,
145 [0x8a] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
146 RTE_PTYPE_INNER_L3_IPV4_EXT |
147 RTE_PTYPE_INNER_L4_FRAG,
148 [0x8b] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
149 RTE_PTYPE_INNER_L3_IPV4_EXT |
150 RTE_PTYPE_INNER_L4_FRAG,
151 /* Tunneled - L3 IPV6, TCP */
152 [0x91] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
153 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
154 RTE_PTYPE_INNER_L4_TCP,
155 [0x94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
156 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
157 RTE_PTYPE_INNER_L4_TCP,
158 [0x96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
159 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
160 RTE_PTYPE_INNER_L4_FRAG,
161 [0x98] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
162 RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_TCP,
163 [0x99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
164 RTE_PTYPE_INNER_L3_IPV4_EXT | RTE_PTYPE_INNER_L4_TCP,
165 /* Tunneled - L3 IPV6, UDP */
166 [0xa1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
167 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
168 RTE_PTYPE_INNER_L4_UDP,
169 [0xa4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
170 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
171 RTE_PTYPE_INNER_L4_UDP,
172 [0xa6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
173 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
174 RTE_PTYPE_INNER_L4_FRAG,
175 [0xa8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
176 RTE_PTYPE_INNER_L3_IPV4_EXT |
177 RTE_PTYPE_INNER_L4_UDP,
178 [0xa9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
179 RTE_PTYPE_INNER_L3_IPV4_EXT |
180 RTE_PTYPE_INNER_L4_UDP,
181 /* Tunneled - L3 IPV4 */
182 [0xc0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
183 [0xc1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
184 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
185 RTE_PTYPE_INNER_L4_NONFRAG,
186 [0xc2] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
187 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
188 RTE_PTYPE_INNER_L4_FRAG,
189 [0xc3] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
190 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
191 RTE_PTYPE_INNER_L4_FRAG,
192 [0xc4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
193 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
194 RTE_PTYPE_INNER_L4_NONFRAG,
195 [0xc6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
196 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
197 RTE_PTYPE_INNER_L4_FRAG,
198 [0xc8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
199 RTE_PTYPE_INNER_L3_IPV4_EXT |
200 RTE_PTYPE_INNER_L4_NONFRAG,
201 [0xc9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
202 RTE_PTYPE_INNER_L3_IPV4_EXT |
203 RTE_PTYPE_INNER_L4_NONFRAG,
204 [0xca] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
205 RTE_PTYPE_INNER_L3_IPV4_EXT |
206 RTE_PTYPE_INNER_L4_FRAG,
207 [0xcb] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
208 RTE_PTYPE_INNER_L3_IPV4_EXT |
209 RTE_PTYPE_INNER_L4_FRAG,
210 /* Tunneled - L3 IPV4, TCP */
211 [0xd1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
212 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
213 RTE_PTYPE_INNER_L4_TCP,
214 [0xd4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
215 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
216 RTE_PTYPE_INNER_L4_TCP,
217 [0xd6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
218 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
219 RTE_PTYPE_INNER_L4_FRAG,
220 [0xd8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
221 RTE_PTYPE_INNER_L3_IPV4_EXT |
222 RTE_PTYPE_INNER_L4_TCP,
223 [0xd9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
224 RTE_PTYPE_INNER_L3_IPV4_EXT |
225 RTE_PTYPE_INNER_L4_TCP,
226 /* Tunneled - L3 IPV4, UDP */
227 [0xe1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
228 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
229 RTE_PTYPE_INNER_L4_UDP,
230 [0xe4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
231 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
232 RTE_PTYPE_INNER_L4_UDP,
233 [0xe6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
234 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
235 RTE_PTYPE_INNER_L4_FRAG,
236 [0xe8] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
237 RTE_PTYPE_INNER_L3_IPV4_EXT |
238 RTE_PTYPE_INNER_L4_UDP,
239 [0xe9] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
240 RTE_PTYPE_INNER_L3_IPV4_EXT |
241 RTE_PTYPE_INNER_L4_UDP,
245 * Stamp TXBB burst so it won't be reused by the HW.
247 * Routine is used when freeing WQE used by the chip or when failing
248 * building an WQ entry has failed leaving partial information on the queue.
251 * Pointer to the SQ structure.
253 * Pointer to the first TXBB to stamp.
255 * Pointer to the followed end TXBB to stamp.
258 * Stamping burst size in byte units.
261 mlx4_txq_stamp_freed_wqe(struct mlx4_sq *sq, volatile uint32_t *start,
262 volatile uint32_t *end)
264 uint32_t stamp = sq->stamp;
265 int32_t size = (intptr_t)end - (intptr_t)start;
267 assert(start != end);
268 /* Hold SQ ring wrap around. */
270 size = (int32_t)sq->size + size;
273 start += MLX4_SQ_STAMP_DWORDS;
274 } while (start != (volatile uint32_t *)sq->eob);
275 start = (volatile uint32_t *)sq->buf;
276 /* Flip invalid stamping ownership. */
277 stamp ^= RTE_BE32(1u << MLX4_SQ_OWNER_BIT);
284 start += MLX4_SQ_STAMP_DWORDS;
285 } while (start != end);
286 return (uint32_t)size;
290 * Manage Tx completions.
292 * When sending a burst, mlx4_tx_burst() posts several WRs.
293 * To improve performance, a completion event is only required once every
294 * MLX4_PMD_TX_PER_COMP_REQ sends. Doing so discards completion information
295 * for other WRs, but this information would not be used anyway.
298 * Pointer to Tx queue structure.
300 * Tx elements number mask.
302 * Pointer to the SQ structure.
305 mlx4_txq_complete(struct txq *txq, const unsigned int elts_m,
308 unsigned int elts_tail = txq->elts_tail;
309 struct mlx4_cq *cq = &txq->mcq;
310 volatile struct mlx4_cqe *cqe;
312 uint32_t cons_index = cq->cons_index;
313 volatile uint32_t *first_txbb;
316 * Traverse over all CQ entries reported and handle each WQ entry
320 cqe = (volatile struct mlx4_cqe *)mlx4_get_cqe(cq, cons_index);
321 if (unlikely(!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
322 !!(cons_index & cq->cqe_cnt)))
326 * Make sure we read the CQE after we read the ownership bit.
329 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
330 MLX4_CQE_OPCODE_ERROR)) {
331 volatile struct mlx4_err_cqe *cqe_err =
332 (volatile struct mlx4_err_cqe *)cqe;
333 ERROR("%p CQE error - vendor syndrome: 0x%x"
335 (void *)txq, cqe_err->vendor_err,
342 completed = (cons_index - cq->cons_index) * txq->elts_comp_cd_init;
343 if (unlikely(!completed))
345 /* First stamping address is the end of the last one. */
346 first_txbb = (&(*txq->elts)[elts_tail & elts_m])->eocb;
347 elts_tail += completed;
348 /* The new tail element holds the end address. */
349 sq->remain_size += mlx4_txq_stamp_freed_wqe(sq, first_txbb,
350 (&(*txq->elts)[elts_tail & elts_m])->eocb);
351 /* Update CQ consumer index. */
352 cq->cons_index = cons_index;
353 *cq->set_ci_db = rte_cpu_to_be_32(cons_index & MLX4_CQ_DB_CI_MASK);
354 txq->elts_tail = elts_tail;
358 * Write Tx data segment to the SQ.
361 * Pointer to data segment in SQ.
363 * Memory region lkey.
367 * Big endian bytes count of the data to send.
370 mlx4_fill_tx_data_seg(volatile struct mlx4_wqe_data_seg *dseg,
371 uint32_t lkey, uintptr_t addr, rte_be32_t byte_count)
373 dseg->addr = rte_cpu_to_be_64(addr);
375 #if RTE_CACHE_LINE_SIZE < 64
377 * Need a barrier here before writing the byte_count
378 * fields to make sure that all the data is visible
379 * before the byte_count field is set.
380 * Otherwise, if the segment begins a new cacheline,
381 * the HCA prefetcher could grab the 64-byte chunk and
382 * get a valid (!= 0xffffffff) byte count but stale
383 * data, and end up sending the wrong data.
386 #endif /* RTE_CACHE_LINE_SIZE */
387 dseg->byte_count = byte_count;
391 * Obtain and calculate TSO information needed for assembling a TSO WQE.
394 * Pointer to the first packet mbuf.
396 * Pointer to Tx queue structure.
398 * Pointer to a structure to fill the info with.
401 * 0 on success, negative value upon error.
404 mlx4_tx_burst_tso_get_params(struct rte_mbuf *buf,
406 struct tso_info *tinfo)
408 struct mlx4_sq *sq = &txq->msq;
409 const uint8_t tunneled = txq->priv->hw_csum_l2tun &&
410 (buf->ol_flags & PKT_TX_TUNNEL_MASK);
412 tinfo->tso_header_size = buf->l2_len + buf->l3_len + buf->l4_len;
414 tinfo->tso_header_size +=
415 buf->outer_l2_len + buf->outer_l3_len;
416 if (unlikely(buf->tso_segsz == 0 ||
417 tinfo->tso_header_size == 0 ||
418 tinfo->tso_header_size > MLX4_MAX_TSO_HEADER ||
419 tinfo->tso_header_size > buf->data_len))
422 * Calculate the WQE TSO segment size
424 * 1. An LSO segment must be padded such that the subsequent data
425 * segment is 16-byte aligned.
426 * 2. The start address of the TSO segment is always 16 Bytes aligned.
428 tinfo->wqe_tso_seg_size = RTE_ALIGN(sizeof(struct mlx4_wqe_lso_seg) +
429 tinfo->tso_header_size,
430 sizeof(struct mlx4_wqe_data_seg));
431 tinfo->fence_size = ((sizeof(struct mlx4_wqe_ctrl_seg) +
432 tinfo->wqe_tso_seg_size) >> MLX4_SEG_SHIFT) +
435 RTE_ALIGN((uint32_t)(tinfo->fence_size << MLX4_SEG_SHIFT),
437 /* Validate WQE size and WQE space in the send queue. */
438 if (sq->remain_size < tinfo->wqe_size ||
439 tinfo->wqe_size > MLX4_MAX_WQE_SIZE)
442 tinfo->pv = (struct pv *)txq->bounce_buf;
443 tinfo->pv_counter = 0;
448 * Fill the TSO WQE data segments with info on buffers to transmit .
451 * Pointer to the first packet mbuf.
453 * Pointer to Tx queue structure.
455 * Pointer to TSO info to use.
457 * Pointer to the first data segment in the TSO WQE.
459 * Pointer to the control segment in the TSO WQE.
462 * 0 on success, negative value upon error.
464 static inline volatile struct mlx4_wqe_ctrl_seg *
465 mlx4_tx_burst_fill_tso_dsegs(struct rte_mbuf *buf,
467 struct tso_info *tinfo,
468 volatile struct mlx4_wqe_data_seg *dseg,
469 volatile struct mlx4_wqe_ctrl_seg *ctrl)
472 int nb_segs = buf->nb_segs;
474 struct mlx4_sq *sq = &txq->msq;
475 struct rte_mbuf *sbuf = buf;
476 struct pv *pv = tinfo->pv;
477 int *pv_counter = &tinfo->pv_counter;
478 volatile struct mlx4_wqe_ctrl_seg *ctrl_next =
479 (volatile struct mlx4_wqe_ctrl_seg *)
480 ((volatile uint8_t *)ctrl + tinfo->wqe_size);
481 uint16_t data_len = sbuf->data_len - tinfo->tso_header_size;
482 uintptr_t data_addr = rte_pktmbuf_mtod_offset(sbuf, uintptr_t,
483 tinfo->tso_header_size);
486 /* how many dseg entries do we have in the current TXBB ? */
487 nb_segs_txbb = (MLX4_TXBB_SIZE -
488 ((uintptr_t)dseg & (MLX4_TXBB_SIZE - 1))) >>
490 switch (nb_segs_txbb) {
493 /* Should never happen. */
494 rte_panic("%p: Invalid number of SGEs(%d) for a TXBB",
495 (void *)txq, nb_segs_txbb);
496 /* rte_panic never returns. */
500 /* Memory region key for this memory pool. */
501 lkey = mlx4_tx_mb2mr(txq, sbuf);
502 if (unlikely(lkey == (uint32_t)-1))
504 dseg->addr = rte_cpu_to_be_64(data_addr);
507 * This data segment starts at the beginning of a new
508 * TXBB, so we need to postpone its byte_count writing
511 pv[*pv_counter].dseg = dseg;
513 * Zero length segment is treated as inline segment
516 pv[(*pv_counter)++].val =
517 rte_cpu_to_be_32(data_len ?
522 /* Prepare next buf info */
525 data_len = sbuf->data_len;
526 data_addr = rte_pktmbuf_mtod(sbuf, uintptr_t);
529 lkey = mlx4_tx_mb2mr(txq, sbuf);
530 if (unlikely(lkey == (uint32_t)-1))
532 mlx4_fill_tx_data_seg(dseg, lkey, data_addr,
533 rte_cpu_to_be_32(data_len ?
538 /* Prepare next buf info */
541 data_len = sbuf->data_len;
542 data_addr = rte_pktmbuf_mtod(sbuf, uintptr_t);
545 lkey = mlx4_tx_mb2mr(txq, sbuf);
546 if (unlikely(lkey == (uint32_t)-1))
548 mlx4_fill_tx_data_seg(dseg, lkey, data_addr,
549 rte_cpu_to_be_32(data_len ?
554 /* Prepare next buf info */
557 data_len = sbuf->data_len;
558 data_addr = rte_pktmbuf_mtod(sbuf, uintptr_t);
561 lkey = mlx4_tx_mb2mr(txq, sbuf);
562 if (unlikely(lkey == (uint32_t)-1))
564 mlx4_fill_tx_data_seg(dseg, lkey, data_addr,
565 rte_cpu_to_be_32(data_len ?
570 /* Prepare next buf info */
573 data_len = sbuf->data_len;
574 data_addr = rte_pktmbuf_mtod(sbuf, uintptr_t);
577 /* Wrap dseg if it points at the end of the queue. */
578 if ((volatile uint8_t *)dseg >= sq->eob)
579 dseg = (volatile struct mlx4_wqe_data_seg *)
580 ((volatile uint8_t *)dseg - sq->size);
587 * Fill the packet's l2, l3 and l4 headers to the WQE.
589 * This will be used as the header for each TSO segment that is transmitted.
592 * Pointer to the first packet mbuf.
594 * Pointer to Tx queue structure.
596 * Pointer to TSO info to use.
598 * Pointer to the control segment in the TSO WQE.
601 * 0 on success, negative value upon error.
603 static inline volatile struct mlx4_wqe_data_seg *
604 mlx4_tx_burst_fill_tso_hdr(struct rte_mbuf *buf,
606 struct tso_info *tinfo,
607 volatile struct mlx4_wqe_ctrl_seg *ctrl)
609 volatile struct mlx4_wqe_lso_seg *tseg =
610 (volatile struct mlx4_wqe_lso_seg *)(ctrl + 1);
611 struct mlx4_sq *sq = &txq->msq;
612 struct pv *pv = tinfo->pv;
613 int *pv_counter = &tinfo->pv_counter;
614 int remain_size = tinfo->tso_header_size;
615 char *from = rte_pktmbuf_mtod(buf, char *);
616 uint16_t txbb_avail_space;
617 /* Union to overcome volatile constraints when copying TSO header. */
619 volatile uint8_t *vto;
621 } thdr = { .vto = (volatile uint8_t *)tseg->header, };
624 * TSO data always starts at offset 20 from the beginning of the TXBB
625 * (16 byte ctrl + 4byte TSO desc). Since each TXBB is 64Byte aligned
626 * we can write the first 44 TSO header bytes without worry for TxQ
627 * wrapping or overwriting the first TXBB 32bit word.
629 txbb_avail_space = MLX4_TXBB_SIZE -
630 (sizeof(struct mlx4_wqe_ctrl_seg) +
631 sizeof(struct mlx4_wqe_lso_seg));
632 while (remain_size >= (int)(txbb_avail_space + sizeof(uint32_t))) {
633 /* Copy to end of txbb. */
634 rte_memcpy(thdr.to, from, txbb_avail_space);
635 from += txbb_avail_space;
636 thdr.to += txbb_avail_space;
637 /* New TXBB, Check for TxQ wrap. */
638 if (thdr.to >= sq->eob)
640 /* New TXBB, stash the first 32bits for later use. */
641 pv[*pv_counter].dst = (volatile uint32_t *)thdr.to;
642 pv[(*pv_counter)++].val = *(uint32_t *)from,
643 from += sizeof(uint32_t);
644 thdr.to += sizeof(uint32_t);
645 remain_size -= txbb_avail_space + sizeof(uint32_t);
646 /* Avail space in new TXBB is TXBB size - 4 */
647 txbb_avail_space = MLX4_TXBB_SIZE - sizeof(uint32_t);
649 if (remain_size > txbb_avail_space) {
650 rte_memcpy(thdr.to, from, txbb_avail_space);
651 from += txbb_avail_space;
652 thdr.to += txbb_avail_space;
653 remain_size -= txbb_avail_space;
654 /* New TXBB, Check for TxQ wrap. */
655 if (thdr.to >= sq->eob)
657 pv[*pv_counter].dst = (volatile uint32_t *)thdr.to;
658 rte_memcpy(&pv[*pv_counter].val, from, remain_size);
660 } else if (remain_size) {
661 rte_memcpy(thdr.to, from, remain_size);
663 tseg->mss_hdr_size = rte_cpu_to_be_32((buf->tso_segsz << 16) |
664 tinfo->tso_header_size);
665 /* Calculate data segment location */
666 return (volatile struct mlx4_wqe_data_seg *)
667 ((uintptr_t)tseg + tinfo->wqe_tso_seg_size);
671 * Write data segments and header for TSO uni/multi segment packet.
674 * Pointer to the first packet mbuf.
676 * Pointer to Tx queue structure.
678 * Pointer to the WQE control segment.
681 * Pointer to the next WQE control segment on success, NULL otherwise.
683 static volatile struct mlx4_wqe_ctrl_seg *
684 mlx4_tx_burst_tso(struct rte_mbuf *buf, struct txq *txq,
685 volatile struct mlx4_wqe_ctrl_seg *ctrl)
687 volatile struct mlx4_wqe_data_seg *dseg;
688 volatile struct mlx4_wqe_ctrl_seg *ctrl_next;
689 struct mlx4_sq *sq = &txq->msq;
690 struct tso_info tinfo;
695 ret = mlx4_tx_burst_tso_get_params(buf, txq, &tinfo);
698 dseg = mlx4_tx_burst_fill_tso_hdr(buf, txq, &tinfo, ctrl);
699 if (unlikely(dseg == NULL))
701 if ((uintptr_t)dseg >= (uintptr_t)sq->eob)
702 dseg = (volatile struct mlx4_wqe_data_seg *)
703 ((uintptr_t)dseg - sq->size);
704 ctrl_next = mlx4_tx_burst_fill_tso_dsegs(buf, txq, &tinfo, dseg, ctrl);
705 if (unlikely(ctrl_next == NULL))
707 /* Write the first DWORD of each TXBB save earlier. */
708 if (likely(tinfo.pv_counter)) {
710 pv_counter = tinfo.pv_counter;
711 /* Need a barrier here before writing the first TXBB word. */
715 *pv[pv_counter].dst = pv[pv_counter].val;
716 } while (pv_counter > 0);
718 ctrl->fence_size = tinfo.fence_size;
719 sq->remain_size -= tinfo.wqe_size;
722 txq->stats.odropped++;
727 * Write data segments of multi-segment packet.
730 * Pointer to the first packet mbuf.
732 * Pointer to Tx queue structure.
734 * Pointer to the WQE control segment.
737 * Pointer to the next WQE control segment on success, NULL otherwise.
739 static volatile struct mlx4_wqe_ctrl_seg *
740 mlx4_tx_burst_segs(struct rte_mbuf *buf, struct txq *txq,
741 volatile struct mlx4_wqe_ctrl_seg *ctrl)
743 struct pv *pv = (struct pv *)txq->bounce_buf;
744 struct mlx4_sq *sq = &txq->msq;
745 struct rte_mbuf *sbuf = buf;
748 int nb_segs = buf->nb_segs;
750 volatile struct mlx4_wqe_data_seg *dseg =
751 (volatile struct mlx4_wqe_data_seg *)(ctrl + 1);
753 ctrl->fence_size = 1 + nb_segs;
754 wqe_size = RTE_ALIGN((uint32_t)(ctrl->fence_size << MLX4_SEG_SHIFT),
756 /* Validate WQE size and WQE space in the send queue. */
757 if (sq->remain_size < wqe_size ||
758 wqe_size > MLX4_MAX_WQE_SIZE)
761 * Fill the data segments with buffer information.
762 * First WQE TXBB head segment is always control segment,
763 * so jump to tail TXBB data segments code for the first
764 * WQE data segments filling.
768 /* Memory region key (big endian) for this memory pool. */
769 lkey = mlx4_tx_mb2mr(txq, sbuf);
770 if (unlikely(lkey == (uint32_t)-1)) {
771 DEBUG("%p: unable to get MP <-> MR association",
775 /* Handle WQE wraparound. */
777 (volatile struct mlx4_wqe_data_seg *)sq->eob)
778 dseg = (volatile struct mlx4_wqe_data_seg *)
780 dseg->addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(sbuf, uintptr_t));
783 * This data segment starts at the beginning of a new
784 * TXBB, so we need to postpone its byte_count writing
787 pv[pv_counter].dseg = dseg;
789 * Zero length segment is treated as inline segment
792 pv[pv_counter++].val = rte_cpu_to_be_32(sbuf->data_len ?
793 sbuf->data_len : 0x80000000);
798 /* Jump to default if there are more than two segments remaining. */
801 lkey = mlx4_tx_mb2mr(txq, sbuf);
802 if (unlikely(lkey == (uint32_t)-1)) {
803 DEBUG("%p: unable to get MP <-> MR association",
807 mlx4_fill_tx_data_seg(dseg, lkey,
808 rte_pktmbuf_mtod(sbuf, uintptr_t),
809 rte_cpu_to_be_32(sbuf->data_len ?
817 lkey = mlx4_tx_mb2mr(txq, sbuf);
818 if (unlikely(lkey == (uint32_t)-1)) {
819 DEBUG("%p: unable to get MP <-> MR association",
823 mlx4_fill_tx_data_seg(dseg, lkey,
824 rte_pktmbuf_mtod(sbuf, uintptr_t),
825 rte_cpu_to_be_32(sbuf->data_len ?
833 lkey = mlx4_tx_mb2mr(txq, sbuf);
834 if (unlikely(lkey == (uint32_t)-1)) {
835 DEBUG("%p: unable to get MP <-> MR association",
839 mlx4_fill_tx_data_seg(dseg, lkey,
840 rte_pktmbuf_mtod(sbuf, uintptr_t),
841 rte_cpu_to_be_32(sbuf->data_len ?
854 /* Write the first DWORD of each TXBB save earlier. */
856 /* Need a barrier here before writing the byte_count. */
858 for (--pv_counter; pv_counter >= 0; pv_counter--)
859 pv[pv_counter].dseg->byte_count = pv[pv_counter].val;
861 sq->remain_size -= wqe_size;
862 /* Align next WQE address to the next TXBB. */
863 return (volatile struct mlx4_wqe_ctrl_seg *)
864 ((volatile uint8_t *)ctrl + wqe_size);
868 * DPDK callback for Tx.
871 * Generic pointer to Tx queue structure.
873 * Packets to transmit.
875 * Number of packets in array.
878 * Number of packets successfully transmitted (<= pkts_n).
881 mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
883 struct txq *txq = (struct txq *)dpdk_txq;
884 unsigned int elts_head = txq->elts_head;
885 const unsigned int elts_n = txq->elts_n;
886 const unsigned int elts_m = elts_n - 1;
887 unsigned int bytes_sent = 0;
889 unsigned int max = elts_head - txq->elts_tail;
890 struct mlx4_sq *sq = &txq->msq;
891 volatile struct mlx4_wqe_ctrl_seg *ctrl;
894 assert(txq->elts_comp_cd != 0);
895 if (likely(max >= txq->elts_comp_cd_init))
896 mlx4_txq_complete(txq, elts_m, sq);
899 assert(max <= elts_n);
900 /* Always leave one free entry in the ring. */
904 elt = &(*txq->elts)[elts_head & elts_m];
905 /* First Tx burst element saves the next WQE control segment. */
907 for (i = 0; (i != max); ++i) {
908 struct rte_mbuf *buf = pkts[i];
909 struct txq_elt *elt_next = &(*txq->elts)[++elts_head & elts_m];
910 uint32_t owner_opcode = sq->owner_opcode;
911 volatile struct mlx4_wqe_data_seg *dseg =
912 (volatile struct mlx4_wqe_data_seg *)(ctrl + 1);
913 volatile struct mlx4_wqe_ctrl_seg *ctrl_next;
919 bool tso = txq->priv->tso && (buf->ol_flags & PKT_TX_TCP_SEG);
921 /* Clean up old buffer. */
922 if (likely(elt->buf != NULL)) {
923 struct rte_mbuf *tmp = elt->buf;
927 memset(&elt->buf, 0x66, sizeof(struct rte_mbuf *));
929 /* Faster than rte_pktmbuf_free(). */
931 struct rte_mbuf *next = tmp->next;
933 rte_pktmbuf_free_seg(tmp);
935 } while (tmp != NULL);
937 RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf);
939 /* Change opcode to TSO */
940 owner_opcode &= ~MLX4_OPCODE_CONFIG_CMD;
941 owner_opcode |= MLX4_OPCODE_LSO | MLX4_WQE_CTRL_RR;
942 ctrl_next = mlx4_tx_burst_tso(buf, txq, ctrl);
947 } else if (buf->nb_segs == 1) {
948 /* Validate WQE space in the send queue. */
949 if (sq->remain_size < MLX4_TXBB_SIZE) {
953 lkey = mlx4_tx_mb2mr(txq, buf);
954 if (unlikely(lkey == (uint32_t)-1)) {
955 /* MR does not exist. */
956 DEBUG("%p: unable to get MP <-> MR association",
961 mlx4_fill_tx_data_seg(dseg++, lkey,
962 rte_pktmbuf_mtod(buf, uintptr_t),
963 rte_cpu_to_be_32(buf->data_len));
964 /* Set WQE size in 16-byte units. */
965 ctrl->fence_size = 0x2;
966 sq->remain_size -= MLX4_TXBB_SIZE;
967 /* Align next WQE address to the next TXBB. */
968 ctrl_next = ctrl + 0x4;
970 ctrl_next = mlx4_tx_burst_segs(buf, txq, ctrl);
976 /* Hold SQ ring wrap around. */
977 if ((volatile uint8_t *)ctrl_next >= sq->eob) {
978 ctrl_next = (volatile struct mlx4_wqe_ctrl_seg *)
979 ((volatile uint8_t *)ctrl_next - sq->size);
980 /* Flip HW valid ownership. */
981 sq->owner_opcode ^= 1u << MLX4_SQ_OWNER_BIT;
984 * For raw Ethernet, the SOLICIT flag is used to indicate
985 * that no ICRC should be calculated.
987 if (--txq->elts_comp_cd == 0) {
988 /* Save the completion burst end address. */
989 elt_next->eocb = (volatile uint32_t *)ctrl_next;
990 txq->elts_comp_cd = txq->elts_comp_cd_init;
991 srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT |
992 MLX4_WQE_CTRL_CQ_UPDATE);
994 srcrb.flags = RTE_BE32(MLX4_WQE_CTRL_SOLICIT);
996 /* Enable HW checksum offload if requested */
999 (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM))) {
1000 const uint64_t is_tunneled = (buf->ol_flags &
1001 (PKT_TX_TUNNEL_GRE |
1002 PKT_TX_TUNNEL_VXLAN));
1004 if (is_tunneled && txq->csum_l2tun) {
1005 owner_opcode |= MLX4_WQE_CTRL_IIP_HDR_CSUM |
1006 MLX4_WQE_CTRL_IL4_HDR_CSUM;
1007 if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
1009 RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM);
1012 RTE_BE32(MLX4_WQE_CTRL_IP_HDR_CSUM |
1013 MLX4_WQE_CTRL_TCP_UDP_CSUM);
1018 * Copy destination MAC address to the WQE, this allows
1019 * loopback in eSwitch, so that VFs and PF can
1020 * communicate with each other.
1022 srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
1023 ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
1028 ctrl->srcrb_flags = srcrb.flags;
1030 * Make sure descriptor is fully written before
1031 * setting ownership bit (because HW can start
1032 * executing as soon as we do).
1035 ctrl->owner_opcode = rte_cpu_to_be_32(owner_opcode);
1037 bytes_sent += buf->pkt_len;
1041 /* Take a shortcut if nothing must be sent. */
1042 if (unlikely(i == 0))
1044 /* Save WQE address of the next Tx burst element. */
1046 /* Increment send statistics counters. */
1047 txq->stats.opackets += i;
1048 txq->stats.obytes += bytes_sent;
1049 /* Make sure that descriptors are written before doorbell record. */
1051 /* Ring QP doorbell. */
1052 rte_write32(txq->msq.doorbell_qpn, MLX4_TX_BFREG(txq));
1053 txq->elts_head += i;
1058 * Translate Rx completion flags to packet type.
1064 * Packet type for struct rte_mbuf.
1066 static inline uint32_t
1067 rxq_cq_to_pkt_type(volatile struct mlx4_cqe *cqe,
1068 uint32_t l2tun_offload)
1071 uint32_t pinfo = rte_be_to_cpu_32(cqe->vlan_my_qpn);
1072 uint32_t status = rte_be_to_cpu_32(cqe->status);
1075 * The index to the array should have:
1076 * bit[7] - MLX4_CQE_L2_TUNNEL
1077 * bit[6] - MLX4_CQE_L2_TUNNEL_IPV4
1079 if (l2tun_offload && (pinfo & MLX4_CQE_L2_TUNNEL))
1080 idx |= ((pinfo & MLX4_CQE_L2_TUNNEL) >> 20) |
1081 ((pinfo & MLX4_CQE_L2_TUNNEL_IPV4) >> 19);
1083 * The index to the array should have:
1084 * bit[5] - MLX4_CQE_STATUS_UDP
1085 * bit[4] - MLX4_CQE_STATUS_TCP
1086 * bit[3] - MLX4_CQE_STATUS_IPV4OPT
1087 * bit[2] - MLX4_CQE_STATUS_IPV6
1088 * bit[1] - MLX4_CQE_STATUS_IPF
1089 * bit[0] - MLX4_CQE_STATUS_IPV4
1090 * giving a total of up to 256 entries.
1092 idx |= ((status & MLX4_CQE_STATUS_PTYPE_MASK) >> 22);
1093 if (status & MLX4_CQE_STATUS_IPV6)
1094 idx |= ((status & MLX4_CQE_STATUS_IPV6F) >> 11);
1095 return mlx4_ptype_table[idx];
1099 * Translate Rx completion flags to offload flags.
1102 * Rx completion flags returned by mlx4_cqe_flags().
1104 * Whether Rx checksums are enabled.
1106 * Whether Rx L2 tunnel checksums are enabled.
1109 * Offload flags (ol_flags) in mbuf format.
1111 static inline uint32_t
1112 rxq_cq_to_ol_flags(uint32_t flags, int csum, int csum_l2tun)
1114 uint32_t ol_flags = 0;
1118 mlx4_transpose(flags,
1119 MLX4_CQE_STATUS_IP_HDR_CSUM_OK,
1120 PKT_RX_IP_CKSUM_GOOD) |
1121 mlx4_transpose(flags,
1122 MLX4_CQE_STATUS_TCP_UDP_CSUM_OK,
1123 PKT_RX_L4_CKSUM_GOOD);
1124 if ((flags & MLX4_CQE_L2_TUNNEL) && csum_l2tun)
1126 mlx4_transpose(flags,
1127 MLX4_CQE_L2_TUNNEL_IPOK,
1128 PKT_RX_IP_CKSUM_GOOD) |
1129 mlx4_transpose(flags,
1130 MLX4_CQE_L2_TUNNEL_L4_CSUM,
1131 PKT_RX_L4_CKSUM_GOOD);
1136 * Extract checksum information from CQE flags.
1139 * Pointer to CQE structure.
1141 * Whether Rx checksums are enabled.
1143 * Whether Rx L2 tunnel checksums are enabled.
1146 * CQE checksum information.
1148 static inline uint32_t
1149 mlx4_cqe_flags(volatile struct mlx4_cqe *cqe, int csum, int csum_l2tun)
1154 * The relevant bits are in different locations on their
1155 * CQE fields therefore we can join them in one 32bit
1159 flags = (rte_be_to_cpu_32(cqe->status) &
1160 MLX4_CQE_STATUS_IPV4_CSUM_OK);
1162 flags |= (rte_be_to_cpu_32(cqe->vlan_my_qpn) &
1163 (MLX4_CQE_L2_TUNNEL |
1164 MLX4_CQE_L2_TUNNEL_IPOK |
1165 MLX4_CQE_L2_TUNNEL_L4_CSUM |
1166 MLX4_CQE_L2_TUNNEL_IPV4));
1171 * Poll one CQE from CQ.
1174 * Pointer to the receive queue structure.
1179 * Number of bytes of the CQE, 0 in case there is no completion.
1182 mlx4_cq_poll_one(struct rxq *rxq, volatile struct mlx4_cqe **out)
1185 volatile struct mlx4_cqe *cqe = NULL;
1186 struct mlx4_cq *cq = &rxq->mcq;
1188 cqe = (volatile struct mlx4_cqe *)mlx4_get_cqe(cq, cq->cons_index);
1189 if (!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
1190 !!(cq->cons_index & cq->cqe_cnt))
1193 * Make sure we read CQ entry contents after we've checked the
1197 assert(!(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK));
1198 assert((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) !=
1199 MLX4_CQE_OPCODE_ERROR);
1200 ret = rte_be_to_cpu_32(cqe->byte_cnt);
1208 * DPDK callback for Rx with scattered packets support.
1211 * Generic pointer to Rx queue structure.
1213 * Array to store received packets.
1215 * Maximum number of packets in array.
1218 * Number of packets successfully received (<= pkts_n).
1221 mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
1223 struct rxq *rxq = dpdk_rxq;
1224 const uint32_t wr_cnt = (1 << rxq->elts_n) - 1;
1225 const uint16_t sges_n = rxq->sges_n;
1226 struct rte_mbuf *pkt = NULL;
1227 struct rte_mbuf *seg = NULL;
1229 uint32_t rq_ci = rxq->rq_ci << sges_n;
1233 volatile struct mlx4_cqe *cqe;
1234 uint32_t idx = rq_ci & wr_cnt;
1235 struct rte_mbuf *rep = (*rxq->elts)[idx];
1236 volatile struct mlx4_wqe_data_seg *scat = &(*rxq->wqes)[idx];
1238 /* Update the 'next' pointer of the previous segment. */
1243 rte_prefetch0(scat);
1244 rep = rte_mbuf_raw_alloc(rxq->mp);
1245 if (unlikely(rep == NULL)) {
1246 ++rxq->stats.rx_nombuf;
1249 * No buffers before we even started,
1250 * bail out silently.
1254 while (pkt != seg) {
1255 assert(pkt != (*rxq->elts)[idx]);
1259 rte_mbuf_raw_free(pkt);
1265 /* Looking for the new packet. */
1266 len = mlx4_cq_poll_one(rxq, &cqe);
1268 rte_mbuf_raw_free(rep);
1271 if (unlikely(len < 0)) {
1272 /* Rx error, packet is likely too large. */
1273 rte_mbuf_raw_free(rep);
1274 ++rxq->stats.idropped;
1278 assert(len >= (rxq->crc_present << 2));
1279 /* Update packet information. */
1281 rxq_cq_to_pkt_type(cqe, rxq->l2tun_offload);
1282 pkt->ol_flags = PKT_RX_RSS_HASH;
1283 pkt->hash.rss = cqe->immed_rss_invalid;
1284 if (rxq->crc_present)
1285 len -= RTE_ETHER_CRC_LEN;
1287 if (rxq->csum | rxq->csum_l2tun) {
1294 rxq_cq_to_ol_flags(flags,
1300 rep->port = rxq->port_id;
1301 rep->data_len = seg->data_len;
1302 rep->data_off = seg->data_off;
1303 (*rxq->elts)[idx] = rep;
1305 * Fill NIC descriptor with the new buffer. The lkey and size
1306 * of the buffers are already known, only the buffer address
1309 scat->addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(rep, uintptr_t));
1310 /* If there's only one MR, no need to replace LKey in WQE. */
1311 if (unlikely(mlx4_mr_btree_len(&rxq->mr_ctrl.cache_bh) > 1))
1312 scat->lkey = mlx4_rx_mb2mr(rxq, rep);
1313 if (len > seg->data_len) {
1314 len -= seg->data_len;
1319 /* The last segment. */
1320 seg->data_len = len;
1321 /* Increment bytes counter. */
1322 rxq->stats.ibytes += pkt->pkt_len;
1323 /* Return packet. */
1329 /* Align consumer index to the next stride. */
1334 if (unlikely(i == 0 && (rq_ci >> sges_n) == rxq->rq_ci))
1336 /* Update the consumer index. */
1337 rxq->rq_ci = rq_ci >> sges_n;
1339 *rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci);
1340 *rxq->mcq.set_ci_db =
1341 rte_cpu_to_be_32(rxq->mcq.cons_index & MLX4_CQ_DB_CI_MASK);
1342 /* Increment packets counter. */
1343 rxq->stats.ipackets += i;
1348 * Dummy DPDK callback for Tx.
1350 * This function is used to temporarily replace the real callback during
1351 * unsafe control operations on the queue, or in case of error.
1354 * Generic pointer to Tx queue structure.
1356 * Packets to transmit.
1358 * Number of packets in array.
1361 * Number of packets successfully transmitted (<= pkts_n).
1364 mlx4_tx_burst_removed(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
1374 * Dummy DPDK callback for Rx.
1376 * This function is used to temporarily replace the real callback during
1377 * unsafe control operations on the queue, or in case of error.
1380 * Generic pointer to Rx queue structure.
1382 * Array to store received packets.
1384 * Maximum number of packets in array.
1387 * Number of packets successfully received (<= pkts_n).
1390 mlx4_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)