Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause */
2 : : /* Copyright(c) 2019-2023 Broadcom All rights reserved. */
3 : :
4 : : #include <inttypes.h>
5 : : #include <stdbool.h>
6 : :
7 : : #include <rte_bitmap.h>
8 : : #include <rte_byteorder.h>
9 : : #include <rte_malloc.h>
10 : : #include <rte_memory.h>
11 : : #include <rte_vect.h>
12 : :
13 : : #include "bnxt.h"
14 : : #include "bnxt_cpr.h"
15 : : #include "bnxt_ring.h"
16 : :
17 : : #include "bnxt_txq.h"
18 : : #include "bnxt_txr.h"
19 : : #include "bnxt_rxtx_vec_common.h"
20 : : #include <unistd.h>
21 : :
22 : : static uint16_t
23 : 0 : recv_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
24 : : {
25 : : struct bnxt_rx_queue *rxq = rx_queue;
26 : : const __m256i mbuf_init =
27 [ # # ]: 0 : _mm256_set_epi64x(0, 0, 0, rxq->mbuf_initializer);
28 : 0 : struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
29 : 0 : struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
30 : 0 : uint16_t cp_ring_size = cpr->cp_ring_struct->ring_size;
31 : 0 : uint16_t rx_ring_size = rxr->rx_ring_struct->ring_size;
32 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
33 : : uint64_t valid, desc_valid_mask = ~0ULL;
34 : : const __m256i info3_v_mask = _mm256_set1_epi32(CMPL_BASE_V);
35 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
36 : : uint32_t cons, mbcons;
37 : : int nb_rx_pkts = 0;
38 : : int i;
39 : : const __m256i valid_target =
40 [ # # ]: 0 : _mm256_set1_epi32(!!(raw_cons & cp_ring_size));
41 : : const __m256i dsc_shuf_msk =
42 : : _mm256_set_epi8(0xff, 0xff, 0xff, 0xff, /* Zeroes. */
43 : : 7, 6, /* metadata type */
44 : : 9, 8, /* flags2 low 16 */
45 : : 5, 4, /* vlan_tci */
46 : : 1, 0, /* errors_v2 */
47 : : 0xff, 0xff, 0xff, 0xff, /* Zeroes. */
48 : : 0xff, 0xff, 0xff, 0xff, /* Zeroes. */
49 : : 7, 6, /* metadata type */
50 : : 9, 8, /* flags2 low 16 */
51 : : 5, 4, /* vlan_tci */
52 : : 1, 0, /* errors_v2 */
53 : : 0xff, 0xff, 0xff, 0xff); /* Zeroes. */
54 : : const __m256i shuf_msk =
55 : : _mm256_set_epi8(15, 14, 13, 12, /* rss */
56 : : 7, 6, /* vlan_tci */
57 : : 3, 2, /* data_len */
58 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
59 : : 0xFF, 0xFF, 0xFF, 0xFF, /* pkt_type (zeroes) */
60 : : 15, 14, 13, 12, /* rss */
61 : : 7, 6, /* vlan_tci */
62 : : 3, 2, /* data_len */
63 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
64 : : 0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
65 : : const __m256i flags_type_mask =
66 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_ITYPE_MASK);
67 : : const __m256i flags2_mask1 =
68 : : _mm256_set1_epi32(CMPL_FLAGS2_VLAN_TUN_MSK);
69 : : const __m256i flags2_mask2 =
70 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS2_IP_TYPE);
71 : : const __m256i rss_mask =
72 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_RSS_VALID);
73 : : __m256i t0, t1, flags_type, flags2, index, errors;
74 : : __m256i ptype_idx, ptypes, is_tunnel;
75 : : __m256i mbuf01, mbuf23, mbuf45, mbuf67;
76 : : __m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5, rearm6, rearm7;
77 : : __m256i ol_flags, ol_flags_hi;
78 : : __m256i rss_flags;
79 : :
80 : : /* Validate ptype table indexing at build time. */
81 : : bnxt_check_ptype_constants();
82 : :
83 : : /* If Rx Q was stopped return */
84 [ # # ]: 0 : if (unlikely(!rxq->rx_started))
85 : : return 0;
86 : :
87 [ # # ]: 0 : if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
88 : 0 : bnxt_rxq_rearm(rxq, rxr);
89 : :
90 : 0 : nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC256);
91 : :
92 : 0 : cons = raw_cons & (cp_ring_size - 1);
93 : 0 : mbcons = (raw_cons / 2) & (rx_ring_size - 1);
94 : :
95 : : /* Return immediately if there is not at least one completed packet. */
96 [ # # ]: 0 : if (!bnxt_cpr_cmp_valid(&cp_desc_ring[cons], raw_cons, cp_ring_size))
97 : : return 0;
98 : :
99 : : /* Ensure that we do not go past the ends of the rings. */
100 : 0 : nb_pkts = RTE_MIN(nb_pkts, RTE_MIN(rx_ring_size - mbcons,
101 : : (cp_ring_size - cons) / 2));
102 : : /*
103 : : * If we are at the end of the ring, ensure that descriptors after the
104 : : * last valid entry are not treated as valid. Otherwise, force the
105 : : * maximum number of packets to receive to be a multiple of the per-
106 : : * loop count.
107 : : */
108 [ # # ]: 0 : if (nb_pkts < BNXT_RX_DESCS_PER_LOOP_VEC256) {
109 : 0 : desc_valid_mask >>=
110 : 0 : CHAR_BIT * (BNXT_RX_DESCS_PER_LOOP_VEC256 - nb_pkts);
111 : : } else {
112 : 0 : nb_pkts =
113 : : RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC256);
114 : : }
115 : :
116 : : /* Handle RX burst request */
117 [ # # ]: 0 : for (i = 0; i < nb_pkts; i += BNXT_RX_DESCS_PER_LOOP_VEC256,
118 : 0 : cons += BNXT_RX_DESCS_PER_LOOP_VEC256 * 2,
119 : 0 : mbcons += BNXT_RX_DESCS_PER_LOOP_VEC256) {
120 : : __m256i desc0, desc1, desc2, desc3, desc4, desc5, desc6, desc7;
121 : : __m256i rxcmp0_1, rxcmp2_3, rxcmp4_5, rxcmp6_7, info3_v;
122 : : __m256i errors_v2;
123 : : uint32_t num_valid;
124 : :
125 : : /* Copy eight mbuf pointers to output array. */
126 : 0 : t0 = _mm256_loadu_si256((void *)&rxr->rx_buf_ring[mbcons]);
127 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i], t0);
128 : : #ifdef RTE_ARCH_X86_64
129 : 0 : t0 = _mm256_loadu_si256((void *)&rxr->rx_buf_ring[mbcons + 4]);
130 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 4], t0);
131 : : #endif
132 : :
133 : : /*
134 : : * Load eight receive completion descriptors into 256-bit
135 : : * registers. Loads are issued in reverse order in order to
136 : : * ensure consistent state.
137 : : */
138 : 0 : desc7 = _mm256_load_si256((void *)&cp_desc_ring[cons + 14]);
139 : 0 : rte_compiler_barrier();
140 : 0 : desc6 = _mm256_load_si256((void *)&cp_desc_ring[cons + 12]);
141 : 0 : rte_compiler_barrier();
142 : 0 : desc5 = _mm256_load_si256((void *)&cp_desc_ring[cons + 10]);
143 : 0 : rte_compiler_barrier();
144 : 0 : desc4 = _mm256_load_si256((void *)&cp_desc_ring[cons + 8]);
145 : 0 : rte_compiler_barrier();
146 : 0 : desc3 = _mm256_load_si256((void *)&cp_desc_ring[cons + 6]);
147 : 0 : rte_compiler_barrier();
148 : 0 : desc2 = _mm256_load_si256((void *)&cp_desc_ring[cons + 4]);
149 : 0 : rte_compiler_barrier();
150 : 0 : desc1 = _mm256_load_si256((void *)&cp_desc_ring[cons + 2]);
151 : 0 : rte_compiler_barrier();
152 [ # # ]: 0 : desc0 = _mm256_load_si256((void *)&cp_desc_ring[cons + 0]);
153 : :
154 : : /*
155 : : * Pack needed fields from each descriptor into a compressed
156 : : * 128-bit layout and pair two compressed descriptors into
157 : : * 256-bit registers. The 128-bit compressed layout is as
158 : : * follows:
159 : : * Bits 0-15: flags_type field from low completion record.
160 : : * Bits 16-31: len field from low completion record.
161 : : * Bits 32-47: flags2 (low 16 bits) from high completion.
162 : : * Bits 48-79: metadata from high completion record.
163 : : * Bits 80-95: errors_v2 from high completion record.
164 : : * Bits 96-127: rss hash from low completion record.
165 : : */
166 : : t0 = _mm256_permute2f128_si256(desc6, desc7, 0x20);
167 : : t1 = _mm256_permute2f128_si256(desc6, desc7, 0x31);
168 : : t1 = _mm256_shuffle_epi8(t1, dsc_shuf_msk);
169 : : rxcmp6_7 = _mm256_blend_epi32(t0, t1, 0x66);
170 : :
171 : : t0 = _mm256_permute2f128_si256(desc4, desc5, 0x20);
172 : : t1 = _mm256_permute2f128_si256(desc4, desc5, 0x31);
173 : : t1 = _mm256_shuffle_epi8(t1, dsc_shuf_msk);
174 : : rxcmp4_5 = _mm256_blend_epi32(t0, t1, 0x66);
175 : :
176 : : t0 = _mm256_permute2f128_si256(desc2, desc3, 0x20);
177 : : t1 = _mm256_permute2f128_si256(desc2, desc3, 0x31);
178 : : t1 = _mm256_shuffle_epi8(t1, dsc_shuf_msk);
179 : : rxcmp2_3 = _mm256_blend_epi32(t0, t1, 0x66);
180 : :
181 : : t0 = _mm256_permute2f128_si256(desc0, desc1, 0x20);
182 : : t1 = _mm256_permute2f128_si256(desc0, desc1, 0x31);
183 : : t1 = _mm256_shuffle_epi8(t1, dsc_shuf_msk);
184 : : rxcmp0_1 = _mm256_blend_epi32(t0, t1, 0x66);
185 : :
186 : : /* Compute packet type table indices for eight packets. */
187 : : t0 = _mm256_unpacklo_epi32(rxcmp0_1, rxcmp2_3);
188 : : t1 = _mm256_unpacklo_epi32(rxcmp4_5, rxcmp6_7);
189 : : flags_type = _mm256_unpacklo_epi64(t0, t1);
190 : : ptype_idx = _mm256_and_si256(flags_type, flags_type_mask);
191 : : ptype_idx = _mm256_srli_epi32(ptype_idx,
192 : : RX_PKT_CMPL_FLAGS_ITYPE_SFT -
193 : : BNXT_PTYPE_TBL_TYPE_SFT);
194 : :
195 : : t0 = _mm256_unpacklo_epi32(rxcmp0_1, rxcmp2_3);
196 : : t1 = _mm256_unpacklo_epi32(rxcmp4_5, rxcmp6_7);
197 : : flags2 = _mm256_unpackhi_epi64(t0, t1);
198 : :
199 : : t0 = _mm256_srli_epi32(_mm256_and_si256(flags2, flags2_mask1),
200 : : RX_PKT_CMPL_FLAGS2_META_FORMAT_SFT -
201 : : BNXT_PTYPE_TBL_VLAN_SFT);
202 : : ptype_idx = _mm256_or_si256(ptype_idx, t0);
203 : :
204 : : t0 = _mm256_srli_epi32(_mm256_and_si256(flags2, flags2_mask2),
205 : : RX_PKT_CMPL_FLAGS2_IP_TYPE_SFT -
206 : : BNXT_PTYPE_TBL_IP_VER_SFT);
207 : : ptype_idx = _mm256_or_si256(ptype_idx, t0);
208 : :
209 : : /*
210 : : * Load ptypes for eight packets using gather. Gather operations
211 : : * have extremely high latency (~19 cycles), execution and use
212 : : * of result should be separated as much as possible.
213 : : */
214 : : ptypes = _mm256_i32gather_epi32((int *)bnxt_ptype_table,
215 : : ptype_idx, sizeof(uint32_t));
216 : : /*
217 : : * Compute ol_flags and checksum error table indices for eight
218 : : * packets.
219 : : */
220 : : is_tunnel = _mm256_and_si256(flags2, _mm256_set1_epi32(4));
221 : : is_tunnel = _mm256_slli_epi32(is_tunnel, 3);
222 : : flags2 = _mm256_and_si256(flags2, _mm256_set1_epi32(0x1F));
223 : :
224 : : /* Extract errors_v2 fields for eight packets. */
225 : : t0 = _mm256_unpackhi_epi32(rxcmp0_1, rxcmp2_3);
226 : : t1 = _mm256_unpackhi_epi32(rxcmp4_5, rxcmp6_7);
227 : : errors_v2 = _mm256_unpacklo_epi64(t0, t1);
228 : :
229 : : errors = _mm256_srli_epi32(errors_v2, 4);
230 : : errors = _mm256_and_si256(errors, _mm256_set1_epi32(0xF));
231 : : errors = _mm256_and_si256(errors, flags2);
232 : :
233 : : index = _mm256_andnot_si256(errors, flags2);
234 : : errors = _mm256_or_si256(errors,
235 : : _mm256_srli_epi32(is_tunnel, 1));
236 : : index = _mm256_or_si256(index, is_tunnel);
237 : :
238 : : /*
239 : : * Load ol_flags for eight packets using gather. Gather
240 : : * operations have extremely high latency (~19 cycles),
241 : : * execution and use of result should be separated as much
242 : : * as possible.
243 : : */
244 : 0 : ol_flags = _mm256_i32gather_epi32((int *)rxr->ol_flags_table,
245 : : index, sizeof(uint32_t));
246 [ # # ]: 0 : errors = _mm256_i32gather_epi32((int *)rxr->ol_flags_err_table,
247 : : errors, sizeof(uint32_t));
248 : :
249 : : /*
250 : : * Pack the 128-bit array of valid descriptor flags into 64
251 : : * bits and count the number of set bits in order to determine
252 : : * the number of valid descriptors.
253 : : */
254 : : const __m256i perm_msk =
255 : : _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0);
256 : : info3_v = _mm256_permutevar8x32_epi32(errors_v2, perm_msk);
257 : : info3_v = _mm256_and_si256(errors_v2, info3_v_mask);
258 : : info3_v = _mm256_xor_si256(info3_v, valid_target);
259 : :
260 : : info3_v = _mm256_packs_epi32(info3_v, _mm256_setzero_si256());
261 : 0 : valid = _mm_cvtsi128_si64(_mm256_extracti128_si256(info3_v, 1));
262 [ # # ]: 0 : valid = (valid << CHAR_BIT) |
263 : 0 : _mm_cvtsi128_si64(_mm256_castsi256_si128(info3_v));
264 [ # # ]: 0 : num_valid = rte_popcount64(valid & desc_valid_mask);
265 : :
266 [ # # ]: 0 : if (num_valid == 0)
267 : : break;
268 : :
269 : : /* Update mbuf rearm_data for eight packets. */
270 : : mbuf01 = _mm256_shuffle_epi8(rxcmp0_1, shuf_msk);
271 : : mbuf23 = _mm256_shuffle_epi8(rxcmp2_3, shuf_msk);
272 : : mbuf45 = _mm256_shuffle_epi8(rxcmp4_5, shuf_msk);
273 : : mbuf67 = _mm256_shuffle_epi8(rxcmp6_7, shuf_msk);
274 : :
275 : : /* Blend in ptype field for two mbufs at a time. */
276 : : mbuf01 = _mm256_blend_epi32(mbuf01, ptypes, 0x11);
277 : : mbuf23 = _mm256_blend_epi32(mbuf23,
278 : : _mm256_srli_si256(ptypes, 4), 0x11);
279 : : mbuf45 = _mm256_blend_epi32(mbuf45,
280 : : _mm256_srli_si256(ptypes, 8), 0x11);
281 : : mbuf67 = _mm256_blend_epi32(mbuf67,
282 : : _mm256_srli_si256(ptypes, 12), 0x11);
283 : :
284 : : /* Unpack rearm data, set fixed fields for first four mbufs. */
285 : : rearm0 = _mm256_permute2f128_si256(mbuf_init, mbuf01, 0x20);
286 : : rearm1 = _mm256_blend_epi32(mbuf_init, mbuf01, 0xF0);
287 : : rearm2 = _mm256_permute2f128_si256(mbuf_init, mbuf23, 0x20);
288 : : rearm3 = _mm256_blend_epi32(mbuf_init, mbuf23, 0xF0);
289 : :
290 : : /* Compute final ol_flags values for eight packets. */
291 : : rss_flags = _mm256_and_si256(flags_type, rss_mask);
292 : : rss_flags = _mm256_srli_epi32(rss_flags, 9);
293 : : ol_flags = _mm256_or_si256(ol_flags, errors);
294 : : ol_flags = _mm256_or_si256(ol_flags, rss_flags);
295 : : ol_flags_hi = _mm256_permute2f128_si256(ol_flags,
296 : : ol_flags, 0x11);
297 : :
298 : : /* Set ol_flags fields for first four packets. */
299 : : rearm0 = _mm256_blend_epi32(rearm0,
300 : : _mm256_slli_si256(ol_flags, 8),
301 : : 0x04);
302 : : rearm1 = _mm256_blend_epi32(rearm1,
303 : : _mm256_slli_si256(ol_flags_hi, 8),
304 : : 0x04);
305 : : rearm2 = _mm256_blend_epi32(rearm2,
306 : : _mm256_slli_si256(ol_flags, 4),
307 : : 0x04);
308 : : rearm3 = _mm256_blend_epi32(rearm3,
309 : : _mm256_slli_si256(ol_flags_hi, 4),
310 : : 0x04);
311 : :
312 : : /* Store all mbuf fields for first four packets. */
313 [ # # ]: 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
314 : : rearm0);
315 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
316 : : rearm1);
317 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
318 : : rearm2);
319 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
320 : : rearm3);
321 : :
322 : : /* Unpack rearm data, set fixed fields for final four mbufs. */
323 : : rearm4 = _mm256_permute2f128_si256(mbuf_init, mbuf45, 0x20);
324 : : rearm5 = _mm256_blend_epi32(mbuf_init, mbuf45, 0xF0);
325 : : rearm6 = _mm256_permute2f128_si256(mbuf_init, mbuf67, 0x20);
326 : : rearm7 = _mm256_blend_epi32(mbuf_init, mbuf67, 0xF0);
327 : :
328 : : /* Set ol_flags fields for final four packets. */
329 : : rearm4 = _mm256_blend_epi32(rearm4, ol_flags, 0x04);
330 : : rearm5 = _mm256_blend_epi32(rearm5, ol_flags_hi, 0x04);
331 : : rearm6 = _mm256_blend_epi32(rearm6,
332 : : _mm256_srli_si256(ol_flags, 4),
333 : : 0x04);
334 : : rearm7 = _mm256_blend_epi32(rearm7,
335 : : _mm256_srli_si256(ol_flags_hi, 4),
336 : : 0x04);
337 : :
338 : : /* Store all mbuf fields for final four packets. */
339 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
340 : : rearm4);
341 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
342 : : rearm5);
343 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
344 : : rearm6);
345 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
346 : : rearm7);
347 : :
348 : 0 : nb_rx_pkts += num_valid;
349 [ # # ]: 0 : if (num_valid < BNXT_RX_DESCS_PER_LOOP_VEC256)
350 : : break;
351 : : }
352 : :
353 [ # # ]: 0 : if (nb_rx_pkts) {
354 : 0 : rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);
355 : :
356 : 0 : rxq->rxrearm_nb += nb_rx_pkts;
357 : 0 : cpr->cp_raw_cons += 2 * nb_rx_pkts;
358 : 0 : bnxt_db_cq(cpr);
359 : : }
360 : :
361 : 0 : return nb_rx_pkts;
362 : : }
363 : :
364 : : static uint16_t
365 : 0 : crx_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
366 : : {
367 : : struct bnxt_rx_queue *rxq = rx_queue;
368 : : const __m256i mbuf_init =
369 [ # # ]: 0 : _mm256_set_epi64x(0, 0, 0, rxq->mbuf_initializer);
370 : 0 : struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
371 : 0 : struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
372 : 0 : uint16_t cp_ring_size = cpr->cp_ring_struct->ring_size;
373 : 0 : uint16_t rx_ring_size = rxr->rx_ring_struct->ring_size;
374 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
375 : : uint64_t valid, desc_valid_mask = ~0ULL;
376 : : const __m256i info3_v_mask = _mm256_set1_epi32(CMPL_BASE_V);
377 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
378 : : uint32_t cons, mbcons;
379 : : int nb_rx_pkts = 0;
380 : : int i;
381 : : const __m256i valid_target =
382 [ # # ]: 0 : _mm256_set1_epi32(!!(raw_cons & cp_ring_size));
383 : : const __m256i shuf_msk =
384 : : _mm256_set_epi8(15, 14, 13, 12, /* rss */
385 : : 7, 6, /* vlan_tci */
386 : : 3, 2, /* data_len */
387 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
388 : : 0xFF, 0xFF, 0xFF, 0xFF, /* pkt_type (zeroes) */
389 : : 15, 14, 13, 12, /* rss */
390 : : 7, 6, /* vlan_tci */
391 : : 3, 2, /* data_len */
392 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
393 : : 0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
394 : : const __m256i flags_type_mask =
395 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_ITYPE_MASK);
396 : : const __m256i flags2_mask1 =
397 : : _mm256_set1_epi32(CMPL_FLAGS2_VLAN_TUN_MSK);
398 : : const __m256i flags2_mask2 =
399 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS2_IP_TYPE);
400 : : const __m256i rss_mask =
401 : : _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_RSS_VALID);
402 : : __m256i t0, t1, flags_type, flags2, index, errors;
403 : : __m256i ptype_idx, ptypes, is_tunnel;
404 : : __m256i mbuf01, mbuf23, mbuf45, mbuf67;
405 : : __m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5, rearm6, rearm7;
406 : : __m256i ol_flags, ol_flags_hi;
407 : : __m256i rss_flags;
408 : :
409 : : /* Validate ptype table indexing at build time. */
410 : : bnxt_check_ptype_constants();
411 : :
412 : : /* If Rx Q was stopped return */
413 [ # # ]: 0 : if (unlikely(!rxq->rx_started))
414 : : return 0;
415 : :
416 [ # # ]: 0 : if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
417 : 0 : bnxt_rxq_rearm(rxq, rxr);
418 : :
419 : 0 : nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC256);
420 : :
421 : 0 : cons = raw_cons & (cp_ring_size - 1);
422 : 0 : mbcons = raw_cons & (rx_ring_size - 1);
423 : :
424 : : /* Return immediately if there is not at least one completed packet. */
425 [ # # ]: 0 : if (!bnxt_cpr_cmp_valid(&cp_desc_ring[cons], raw_cons, cp_ring_size))
426 : : return 0;
427 : :
428 : : /* Ensure that we do not go past the ends of the rings. */
429 : 0 : nb_pkts = RTE_MIN(nb_pkts, RTE_MIN(rx_ring_size - mbcons,
430 : : cp_ring_size - cons));
431 : : /*
432 : : * If we are at the end of the ring, ensure that descriptors after the
433 : : * last valid entry are not treated as valid. Otherwise, force the
434 : : * maximum number of packets to receive to be a multiple of the per-
435 : : * loop count.
436 : : */
437 [ # # ]: 0 : if (nb_pkts < BNXT_RX_DESCS_PER_LOOP_VEC256) {
438 : 0 : desc_valid_mask >>=
439 : 0 : CHAR_BIT * (BNXT_RX_DESCS_PER_LOOP_VEC256 - nb_pkts);
440 : : } else {
441 : 0 : nb_pkts =
442 : : RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC256);
443 : : }
444 : :
445 : : /* Handle RX burst request */
446 [ # # ]: 0 : for (i = 0; i < nb_pkts; i += BNXT_RX_DESCS_PER_LOOP_VEC256,
447 : 0 : cons += BNXT_RX_DESCS_PER_LOOP_VEC256,
448 : 0 : mbcons += BNXT_RX_DESCS_PER_LOOP_VEC256) {
449 : : __m256i rxcmp0_1, rxcmp2_3, rxcmp4_5, rxcmp6_7, info3_v;
450 : : __m256i errors_v2;
451 : : uint32_t num_valid;
452 : :
453 : : /* Copy eight mbuf pointers to output array. */
454 : 0 : t0 = _mm256_loadu_si256((void *)&rxr->rx_buf_ring[mbcons]);
455 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i], t0);
456 : : #ifdef RTE_ARCH_X86_64
457 : 0 : t0 = _mm256_loadu_si256((void *)&rxr->rx_buf_ring[mbcons + 4]);
458 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 4], t0);
459 : : #endif
460 : :
461 : : /*
462 : : * Load eight receive completion descriptors into 256-bit
463 : : * registers. Loads are issued in reverse order in order to
464 : : * ensure consistent state.
465 : : */
466 : 0 : rxcmp6_7 = _mm256_loadu_si256((void *)&cp_desc_ring[cons + 6]);
467 : 0 : rte_compiler_barrier();
468 : 0 : rxcmp4_5 = _mm256_loadu_si256((void *)&cp_desc_ring[cons + 4]);
469 : 0 : rte_compiler_barrier();
470 : 0 : rxcmp2_3 = _mm256_loadu_si256((void *)&cp_desc_ring[cons + 2]);
471 : 0 : rte_compiler_barrier();
472 [ # # ]: 0 : rxcmp0_1 = _mm256_loadu_si256((void *)&cp_desc_ring[cons + 0]);
473 : :
474 : : /* Compute packet type table indices for eight packets. */
475 : : t0 = _mm256_unpacklo_epi32(rxcmp0_1, rxcmp2_3);
476 : : t1 = _mm256_unpacklo_epi32(rxcmp4_5, rxcmp6_7);
477 : : flags_type = _mm256_unpacklo_epi64(t0, t1);
478 : : ptype_idx = _mm256_and_si256(flags_type, flags_type_mask);
479 : : ptype_idx = _mm256_srli_epi32(ptype_idx,
480 : : RX_PKT_CMPL_FLAGS_ITYPE_SFT -
481 : : BNXT_PTYPE_TBL_TYPE_SFT);
482 : :
483 : : t0 = _mm256_unpacklo_epi32(rxcmp0_1, rxcmp2_3);
484 : : t1 = _mm256_unpacklo_epi32(rxcmp4_5, rxcmp6_7);
485 : : flags2 = _mm256_unpackhi_epi64(t0, t1);
486 : :
487 : : t0 = _mm256_srli_epi32(_mm256_and_si256(flags2, flags2_mask1),
488 : : RX_PKT_CMPL_FLAGS2_META_FORMAT_SFT -
489 : : BNXT_PTYPE_TBL_VLAN_SFT);
490 : : ptype_idx = _mm256_or_si256(ptype_idx, t0);
491 : :
492 : : t0 = _mm256_srli_epi32(_mm256_and_si256(flags2, flags2_mask2),
493 : : RX_PKT_CMPL_FLAGS2_IP_TYPE_SFT -
494 : : BNXT_PTYPE_TBL_IP_VER_SFT);
495 : : ptype_idx = _mm256_or_si256(ptype_idx, t0);
496 : :
497 : : /*
498 : : * Load ptypes for eight packets using gather. Gather operations
499 : : * have extremely high latency (~19 cycles), execution and use
500 : : * of result should be separated as much as possible.
501 : : */
502 : : ptypes = _mm256_i32gather_epi32((int *)bnxt_ptype_table,
503 : : ptype_idx, sizeof(uint32_t));
504 : : /*
505 : : * Compute ol_flags and checksum error table indices for eight
506 : : * packets.
507 : : */
508 : : is_tunnel = _mm256_and_si256(flags2, _mm256_set1_epi32(4));
509 : : is_tunnel = _mm256_slli_epi32(is_tunnel, 3);
510 : : flags2 = _mm256_and_si256(flags2, _mm256_set1_epi32(0x1F));
511 : :
512 : : /* Extract errors_v2 fields for eight packets. */
513 : : t0 = _mm256_unpackhi_epi32(rxcmp0_1, rxcmp2_3);
514 : : t1 = _mm256_unpackhi_epi32(rxcmp4_5, rxcmp6_7);
515 : : errors_v2 = _mm256_unpacklo_epi64(t0, t1);
516 : :
517 : : errors = _mm256_srli_epi32(errors_v2, 4);
518 : : errors = _mm256_and_si256(errors, _mm256_set1_epi32(0xF));
519 : : errors = _mm256_and_si256(errors, flags2);
520 : :
521 : : index = _mm256_andnot_si256(errors, flags2);
522 : : errors = _mm256_or_si256(errors,
523 : : _mm256_srli_epi32(is_tunnel, 1));
524 : : index = _mm256_or_si256(index, is_tunnel);
525 : :
526 : : /*
527 : : * Load ol_flags for eight packets using gather. Gather
528 : : * operations have extremely high latency (~19 cycles),
529 : : * execution and use of result should be separated as much
530 : : * as possible.
531 : : */
532 : 0 : ol_flags = _mm256_i32gather_epi32((int *)rxr->ol_flags_table,
533 : : index, sizeof(uint32_t));
534 [ # # ]: 0 : errors = _mm256_i32gather_epi32((int *)rxr->ol_flags_err_table,
535 : : errors, sizeof(uint32_t));
536 : :
537 : : /*
538 : : * Pack the 128-bit array of valid descriptor flags into 64
539 : : * bits and count the number of set bits in order to determine
540 : : * the number of valid descriptors.
541 : : */
542 : : const __m256i perm_msk =
543 : : _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0);
544 : : info3_v = _mm256_permutevar8x32_epi32(errors_v2, perm_msk);
545 : : info3_v = _mm256_and_si256(errors_v2, info3_v_mask);
546 : : info3_v = _mm256_xor_si256(info3_v, valid_target);
547 : :
548 : : info3_v = _mm256_packs_epi32(info3_v, _mm256_setzero_si256());
549 : 0 : valid = _mm_cvtsi128_si64(_mm256_extracti128_si256(info3_v, 1));
550 [ # # ]: 0 : valid = (valid << CHAR_BIT) |
551 : 0 : _mm_cvtsi128_si64(_mm256_castsi256_si128(info3_v));
552 [ # # ]: 0 : num_valid = rte_popcount64(valid & desc_valid_mask);
553 : :
554 [ # # ]: 0 : if (num_valid == 0)
555 : : break;
556 : :
557 : : /* Update mbuf rearm_data for eight packets. */
558 : : mbuf01 = _mm256_shuffle_epi8(rxcmp0_1, shuf_msk);
559 : : mbuf23 = _mm256_shuffle_epi8(rxcmp2_3, shuf_msk);
560 : : mbuf45 = _mm256_shuffle_epi8(rxcmp4_5, shuf_msk);
561 : : mbuf67 = _mm256_shuffle_epi8(rxcmp6_7, shuf_msk);
562 : :
563 : : /* Blend in ptype field for two mbufs at a time. */
564 : : mbuf01 = _mm256_blend_epi32(mbuf01, ptypes, 0x11);
565 : : mbuf23 = _mm256_blend_epi32(mbuf23,
566 : : _mm256_srli_si256(ptypes, 4), 0x11);
567 : : mbuf45 = _mm256_blend_epi32(mbuf45,
568 : : _mm256_srli_si256(ptypes, 8), 0x11);
569 : : mbuf67 = _mm256_blend_epi32(mbuf67,
570 : : _mm256_srli_si256(ptypes, 12), 0x11);
571 : :
572 : : /* Unpack rearm data, set fixed fields for first four mbufs. */
573 : : rearm0 = _mm256_permute2f128_si256(mbuf_init, mbuf01, 0x20);
574 : : rearm1 = _mm256_blend_epi32(mbuf_init, mbuf01, 0xF0);
575 : : rearm2 = _mm256_permute2f128_si256(mbuf_init, mbuf23, 0x20);
576 : : rearm3 = _mm256_blend_epi32(mbuf_init, mbuf23, 0xF0);
577 : :
578 : : /* Compute final ol_flags values for eight packets. */
579 : : rss_flags = _mm256_and_si256(flags_type, rss_mask);
580 : : rss_flags = _mm256_srli_epi32(rss_flags, 9);
581 : : ol_flags = _mm256_or_si256(ol_flags, errors);
582 : : ol_flags = _mm256_or_si256(ol_flags, rss_flags);
583 : : ol_flags_hi = _mm256_permute2f128_si256(ol_flags,
584 : : ol_flags, 0x11);
585 : :
586 : : /* Set ol_flags fields for first four packets. */
587 : : rearm0 = _mm256_blend_epi32(rearm0,
588 : : _mm256_slli_si256(ol_flags, 8),
589 : : 0x04);
590 : : rearm1 = _mm256_blend_epi32(rearm1,
591 : : _mm256_slli_si256(ol_flags_hi, 8),
592 : : 0x04);
593 : : rearm2 = _mm256_blend_epi32(rearm2,
594 : : _mm256_slli_si256(ol_flags, 4),
595 : : 0x04);
596 : : rearm3 = _mm256_blend_epi32(rearm3,
597 : : _mm256_slli_si256(ol_flags_hi, 4),
598 : : 0x04);
599 : :
600 : : /* Store all mbuf fields for first four packets. */
601 [ # # ]: 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 0]->rearm_data,
602 : : rearm0);
603 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 1]->rearm_data,
604 : : rearm1);
605 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 2]->rearm_data,
606 : : rearm2);
607 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 3]->rearm_data,
608 : : rearm3);
609 : :
610 : : /* Unpack rearm data, set fixed fields for final four mbufs. */
611 : : rearm4 = _mm256_permute2f128_si256(mbuf_init, mbuf45, 0x20);
612 : : rearm5 = _mm256_blend_epi32(mbuf_init, mbuf45, 0xF0);
613 : : rearm6 = _mm256_permute2f128_si256(mbuf_init, mbuf67, 0x20);
614 : : rearm7 = _mm256_blend_epi32(mbuf_init, mbuf67, 0xF0);
615 : :
616 : : /* Set ol_flags fields for final four packets. */
617 : : rearm4 = _mm256_blend_epi32(rearm4, ol_flags, 0x04);
618 : : rearm5 = _mm256_blend_epi32(rearm5, ol_flags_hi, 0x04);
619 : : rearm6 = _mm256_blend_epi32(rearm6,
620 : : _mm256_srli_si256(ol_flags, 4),
621 : : 0x04);
622 : : rearm7 = _mm256_blend_epi32(rearm7,
623 : : _mm256_srli_si256(ol_flags_hi, 4),
624 : : 0x04);
625 : :
626 : : /* Store all mbuf fields for final four packets. */
627 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 4]->rearm_data,
628 : : rearm4);
629 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 5]->rearm_data,
630 : : rearm5);
631 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 6]->rearm_data,
632 : : rearm6);
633 : 0 : _mm256_storeu_si256((void *)&rx_pkts[i + 7]->rearm_data,
634 : : rearm7);
635 : :
636 : 0 : nb_rx_pkts += num_valid;
637 [ # # ]: 0 : if (num_valid < BNXT_RX_DESCS_PER_LOOP_VEC256)
638 : : break;
639 : : }
640 : :
641 [ # # ]: 0 : if (nb_rx_pkts) {
642 : 0 : rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);
643 : :
644 : 0 : rxq->rxrearm_nb += nb_rx_pkts;
645 : 0 : cpr->cp_raw_cons += nb_rx_pkts;
646 : 0 : bnxt_db_cq(cpr);
647 : : }
648 : :
649 : 0 : return nb_rx_pkts;
650 : : }
651 : :
652 : : uint16_t
653 : 0 : bnxt_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
654 : : uint16_t nb_pkts)
655 : : {
656 : : uint16_t cnt = 0;
657 : :
658 [ # # ]: 0 : while (nb_pkts > RTE_BNXT_MAX_RX_BURST) {
659 : : uint16_t burst;
660 : :
661 : 0 : burst = recv_burst_vec_avx2(rx_queue, rx_pkts + cnt,
662 : : RTE_BNXT_MAX_RX_BURST);
663 : :
664 : 0 : cnt += burst;
665 : 0 : nb_pkts -= burst;
666 : :
667 [ # # ]: 0 : if (burst < RTE_BNXT_MAX_RX_BURST)
668 : 0 : return cnt;
669 : : }
670 : 0 : return cnt + recv_burst_vec_avx2(rx_queue, rx_pkts + cnt, nb_pkts);
671 : : }
672 : :
673 : : uint16_t
674 : 0 : bnxt_crx_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
675 : : uint16_t nb_pkts)
676 : : {
677 : : uint16_t cnt = 0;
678 : :
679 [ # # ]: 0 : while (nb_pkts > RTE_BNXT_MAX_RX_BURST) {
680 : : uint16_t burst;
681 : :
682 : 0 : burst = crx_burst_vec_avx2(rx_queue, rx_pkts + cnt,
683 : : RTE_BNXT_MAX_RX_BURST);
684 : :
685 : 0 : cnt += burst;
686 : 0 : nb_pkts -= burst;
687 : :
688 [ # # ]: 0 : if (burst < RTE_BNXT_MAX_RX_BURST)
689 : 0 : return cnt;
690 : : }
691 : 0 : return cnt + crx_burst_vec_avx2(rx_queue, rx_pkts + cnt, nb_pkts);
692 : : }
693 : :
694 : : static void
695 : 0 : bnxt_handle_tx_cp_vec(struct bnxt_tx_queue *txq)
696 : : {
697 : 0 : struct bnxt_cp_ring_info *cpr = txq->cp_ring;
698 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
699 : : uint32_t cons;
700 : : uint32_t nb_tx_pkts = 0;
701 : : struct tx_cmpl *txcmp;
702 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
703 : 0 : struct bnxt_ring *cp_ring_struct = cpr->cp_ring_struct;
704 : 0 : uint32_t ring_mask = cp_ring_struct->ring_mask;
705 : :
706 : : do {
707 : 0 : cons = RING_CMPL(ring_mask, raw_cons);
708 : 0 : txcmp = (struct tx_cmpl *)&cp_desc_ring[cons];
709 : :
710 [ # # ]: 0 : if (!bnxt_cpr_cmp_valid(txcmp, raw_cons, ring_mask + 1))
711 : : break;
712 : :
713 : 0 : nb_tx_pkts += txcmp->opaque;
714 : 0 : raw_cons = NEXT_RAW_CMP(raw_cons);
715 [ # # ]: 0 : } while (nb_tx_pkts < ring_mask);
716 : :
717 [ # # ]: 0 : if (nb_tx_pkts) {
718 [ # # ]: 0 : if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
719 : 0 : bnxt_tx_cmp_vec_fast(txq, nb_tx_pkts);
720 : : else
721 : 0 : bnxt_tx_cmp_vec(txq, nb_tx_pkts);
722 : 0 : cpr->cp_raw_cons = raw_cons;
723 : 0 : bnxt_db_cq(cpr);
724 : : }
725 : 0 : }
726 : :
727 : : static inline void
728 : : bnxt_xmit_one(struct rte_mbuf *mbuf, struct tx_bd_long *txbd,
729 : : struct rte_mbuf **tx_buf)
730 : : {
731 : : uint64_t dsc_hi, dsc_lo;
732 : : __m128i desc;
733 : :
734 : 0 : *tx_buf = mbuf;
735 : :
736 : 0 : dsc_hi = mbuf->buf_iova + mbuf->data_off;
737 : 0 : dsc_lo = (mbuf->data_len << 16) |
738 : : bnxt_xmit_flags_len(mbuf->data_len, TX_BD_FLAGS_NOCMPL);
739 : :
740 : 0 : desc = _mm_set_epi64x(dsc_hi, dsc_lo);
741 : : _mm_store_si128((void *)txbd, desc);
742 : : }
743 : :
744 : : static uint16_t
745 : 0 : bnxt_xmit_fixed_burst_vec(struct bnxt_tx_queue *txq, struct rte_mbuf **pkts,
746 : : uint16_t nb_pkts)
747 : : {
748 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
749 : 0 : uint16_t tx_prod, tx_raw_prod = txr->tx_raw_prod;
750 : : struct tx_bd_long *txbd;
751 : : struct rte_mbuf **tx_buf;
752 : : uint16_t to_send;
753 : :
754 : 0 : tx_prod = RING_IDX(txr->tx_ring_struct, tx_raw_prod);
755 : 0 : txbd = &txr->tx_desc_ring[tx_prod];
756 : 0 : tx_buf = &txr->tx_buf_ring[tx_prod];
757 : :
758 : : /* Prefetch next transmit buffer descriptors. */
759 : : rte_prefetch0(txbd);
760 : 0 : rte_prefetch0(txbd + 3);
761 : :
762 : 0 : nb_pkts = RTE_MIN(nb_pkts, bnxt_tx_avail(txq));
763 : :
764 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
765 : : return 0;
766 : :
767 : : /* Handle TX burst request */
768 : : to_send = nb_pkts;
769 : :
770 : : /*
771 : : * If current descriptor is not on a 32-byte boundary, send one packet
772 : : * to align for 32-byte stores.
773 : : */
774 [ # # ]: 0 : if (tx_prod & 1) {
775 [ # # ]: 0 : bnxt_xmit_one(pkts[0], txbd++, tx_buf++);
776 : 0 : to_send--;
777 : 0 : pkts++;
778 : : }
779 : :
780 : : /*
781 : : * Send four packets per loop, with a single store for each pair
782 : : * of descriptors.
783 : : */
784 [ # # ]: 0 : while (to_send >= BNXT_TX_DESCS_PER_LOOP) {
785 : : uint64_t dsc0_hi, dsc0_lo, dsc1_hi, dsc1_lo;
786 : : uint64_t dsc2_hi, dsc2_lo, dsc3_hi, dsc3_lo;
787 : : __m256i dsc01, dsc23;
788 : :
789 : : /* Prefetch next transmit buffer descriptors. */
790 : 0 : rte_prefetch0(txbd + 4);
791 : 0 : rte_prefetch0(txbd + 7);
792 : :
793 : : /* Copy four mbuf pointers to tx buf ring. */
794 : : #ifdef RTE_ARCH_X86_64
795 : : __m256i tmp = _mm256_loadu_si256((void *)pkts);
796 : : _mm256_storeu_si256((void *)tx_buf, tmp);
797 : : #else
798 : : __m128i tmp = _mm_loadu_si128((void *)pkts);
799 : : _mm_storeu_si128((void *)tx_buf, tmp);
800 : : #endif
801 : :
802 : 0 : dsc0_hi = tx_buf[0]->buf_iova + tx_buf[0]->data_off;
803 [ # # ]: 0 : dsc0_lo = (tx_buf[0]->data_len << 16) |
804 : : bnxt_xmit_flags_len(tx_buf[0]->data_len,
805 : : TX_BD_FLAGS_NOCMPL);
806 : :
807 : 0 : dsc1_hi = tx_buf[1]->buf_iova + tx_buf[1]->data_off;
808 [ # # ]: 0 : dsc1_lo = (tx_buf[1]->data_len << 16) |
809 : : bnxt_xmit_flags_len(tx_buf[1]->data_len,
810 : : TX_BD_FLAGS_NOCMPL);
811 : :
812 [ # # ]: 0 : dsc01 = _mm256_set_epi64x(dsc1_hi, dsc1_lo, dsc0_hi, dsc0_lo);
813 : :
814 : 0 : dsc2_hi = tx_buf[2]->buf_iova + tx_buf[2]->data_off;
815 [ # # ]: 0 : dsc2_lo = (tx_buf[2]->data_len << 16) |
816 : : bnxt_xmit_flags_len(tx_buf[2]->data_len,
817 : : TX_BD_FLAGS_NOCMPL);
818 : :
819 : 0 : dsc3_hi = tx_buf[3]->buf_iova + tx_buf[3]->data_off;
820 [ # # ]: 0 : dsc3_lo = (tx_buf[3]->data_len << 16) |
821 : : bnxt_xmit_flags_len(tx_buf[3]->data_len,
822 : : TX_BD_FLAGS_NOCMPL);
823 : :
824 : 0 : dsc23 = _mm256_set_epi64x(dsc3_hi, dsc3_lo, dsc2_hi, dsc2_lo);
825 : :
826 : : _mm256_store_si256((void *)txbd, dsc01);
827 : : _mm256_store_si256((void *)(txbd + 2), dsc23);
828 : :
829 : 0 : to_send -= BNXT_TX_DESCS_PER_LOOP;
830 : 0 : pkts += BNXT_TX_DESCS_PER_LOOP;
831 : : txbd += BNXT_TX_DESCS_PER_LOOP;
832 : 0 : tx_buf += BNXT_TX_DESCS_PER_LOOP;
833 : : }
834 : :
835 : : /* Send any remaining packets, writing each descriptor individually. */
836 [ # # ]: 0 : while (to_send) {
837 [ # # ]: 0 : bnxt_xmit_one(pkts[0], txbd++, tx_buf++);
838 : 0 : to_send--;
839 : 0 : pkts++;
840 : : }
841 : :
842 : : /* Request a completion for the final packet of the burst. */
843 : 0 : txbd[-1].opaque = nb_pkts;
844 : 0 : txbd[-1].flags_type &= ~TX_BD_LONG_FLAGS_NO_CMPL;
845 : :
846 : 0 : tx_raw_prod += nb_pkts;
847 [ # # ]: 0 : bnxt_db_write(&txr->tx_db, tx_raw_prod);
848 : :
849 : 0 : txr->tx_raw_prod = tx_raw_prod;
850 : :
851 : 0 : return nb_pkts;
852 : : }
853 : :
854 : : uint16_t
855 : 0 : bnxt_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
856 : : uint16_t nb_pkts)
857 : : {
858 : : int nb_sent = 0;
859 : : struct bnxt_tx_queue *txq = tx_queue;
860 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
861 : 0 : uint16_t ring_size = txr->tx_ring_struct->ring_size;
862 : :
863 : : /* Tx queue was stopped; wait for it to be restarted */
864 [ # # ]: 0 : if (unlikely(!txq->tx_started)) {
865 : 0 : PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
866 : 0 : return 0;
867 : : }
868 : :
869 : : /* Handle TX completions */
870 [ # # ]: 0 : if (bnxt_tx_bds_in_hw(txq) >= txq->tx_free_thresh)
871 : 0 : bnxt_handle_tx_cp_vec(txq);
872 : :
873 [ # # ]: 0 : while (nb_pkts) {
874 : : uint16_t ret, num;
875 : :
876 : : /*
877 : : * Ensure that no more than RTE_BNXT_MAX_TX_BURST packets
878 : : * are transmitted before the next completion.
879 : : */
880 : 0 : num = RTE_MIN(nb_pkts, RTE_BNXT_MAX_TX_BURST);
881 : :
882 : : /*
883 : : * Ensure that a ring wrap does not occur within a call to
884 : : * bnxt_xmit_fixed_burst_vec().
885 : : */
886 : 0 : num = RTE_MIN(num, ring_size -
887 : : (txr->tx_raw_prod & (ring_size - 1)));
888 : 0 : ret = bnxt_xmit_fixed_burst_vec(txq, &tx_pkts[nb_sent], num);
889 : 0 : nb_sent += ret;
890 : 0 : nb_pkts -= ret;
891 [ # # ]: 0 : if (ret < num)
892 : : break;
893 : : }
894 : :
895 : 0 : return nb_sent;
896 : : }
|