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 : :
21 : : /*
22 : : * RX Ring handling
23 : : */
24 : :
25 : : #define GET_OL_FLAGS(rss_flags, ol_index, errors, pi, ol_flags) \
26 : : { \
27 : : uint32_t tmp, of; \
28 : : \
29 : : of = _mm_extract_epi32((rss_flags), (pi)) | \
30 : : rxr->ol_flags_table[_mm_extract_epi32((ol_index), (pi))]; \
31 : : \
32 : : tmp = _mm_extract_epi32((errors), (pi)); \
33 : : if (tmp) \
34 : : of |= rxr->ol_flags_err_table[tmp]; \
35 : : (ol_flags) = of; \
36 : : }
37 : :
38 : : #define GET_DESC_FIELDS(rxcmp, rxcmp1, shuf_msk, ptype_idx, pi, ret) \
39 : : { \
40 : : uint32_t ptype; \
41 : : __m128i r; \
42 : : \
43 : : /* Set mbuf pkt_len, data_len, and rss_hash fields. */ \
44 : : r = _mm_shuffle_epi8((rxcmp), (shuf_msk)); \
45 : : \
46 : : /* Set packet type. */ \
47 : : ptype = bnxt_ptype_table[_mm_extract_epi32((ptype_idx), (pi))]; \
48 : : r = _mm_blend_epi16(r, _mm_set_epi32(0, 0, 0, ptype), 0x3); \
49 : : \
50 : : /* Set vlan_tci. */ \
51 : : r = _mm_blend_epi16(r, _mm_slli_si128((rxcmp1), 6), 0x20); \
52 : : (ret) = r; \
53 : : }
54 : :
55 : : static inline void
56 : 0 : descs_to_mbufs(__m128i mm_rxcmp[4], __m128i mm_rxcmp1[4],
57 : : __m128i mbuf_init, const __m128i shuf_msk,
58 : : struct rte_mbuf **mbuf, struct bnxt_rx_ring_info *rxr)
59 : : {
60 : : const __m128i flags_type_mask =
61 : : _mm_set1_epi32(RX_PKT_CMPL_FLAGS_ITYPE_MASK);
62 : : const __m128i flags2_mask1 =
63 : : _mm_set1_epi32(CMPL_FLAGS2_VLAN_TUN_MSK);
64 : : const __m128i flags2_mask2 =
65 : : _mm_set1_epi32(RX_PKT_CMPL_FLAGS2_IP_TYPE);
66 : : const __m128i rss_mask =
67 : : _mm_set1_epi32(RX_PKT_CMPL_FLAGS_RSS_VALID);
68 : : __m128i t0, t1, flags_type, flags2, index, errors, rss_flags;
69 : : __m128i ptype_idx, is_tunnel;
70 : : uint32_t ol_flags;
71 : :
72 : : /* Validate ptype table indexing at build time. */
73 : : bnxt_check_ptype_constants();
74 : :
75 : : /* Compute packet type table indexes for four packets */
76 [ # # ]: 0 : t0 = _mm_unpacklo_epi32(mm_rxcmp[0], mm_rxcmp[1]);
77 [ # # ]: 0 : t1 = _mm_unpacklo_epi32(mm_rxcmp[2], mm_rxcmp[3]);
78 : : flags_type = _mm_unpacklo_epi64(t0, t1);
79 : : ptype_idx = _mm_srli_epi32(_mm_and_si128(flags_type, flags_type_mask),
80 : : RX_PKT_CMPL_FLAGS_ITYPE_SFT - BNXT_PTYPE_TBL_TYPE_SFT);
81 : :
82 : 0 : t0 = _mm_unpacklo_epi32(mm_rxcmp1[0], mm_rxcmp1[1]);
83 [ # # ]: 0 : t1 = _mm_unpacklo_epi32(mm_rxcmp1[2], mm_rxcmp1[3]);
84 : : flags2 = _mm_unpacklo_epi64(t0, t1);
85 : :
86 : : ptype_idx = _mm_or_si128(ptype_idx,
87 : : _mm_srli_epi32(_mm_and_si128(flags2, flags2_mask1),
88 : : RX_PKT_CMPL_FLAGS2_META_FORMAT_SFT -
89 : : BNXT_PTYPE_TBL_VLAN_SFT));
90 : : ptype_idx = _mm_or_si128(ptype_idx,
91 : : _mm_srli_epi32(_mm_and_si128(flags2, flags2_mask2),
92 : : RX_PKT_CMPL_FLAGS2_IP_TYPE_SFT -
93 : : BNXT_PTYPE_TBL_IP_VER_SFT));
94 : :
95 : : /* Extract RSS valid flags for four packets. */
96 : : rss_flags = _mm_srli_epi32(_mm_and_si128(flags_type, rss_mask), 9);
97 : :
98 : : /* Extract errors_v2 fields for four packets. */
99 : : t0 = _mm_unpackhi_epi32(mm_rxcmp1[0], mm_rxcmp1[1]);
100 : : t1 = _mm_unpackhi_epi32(mm_rxcmp1[2], mm_rxcmp1[3]);
101 : :
102 : : /* Compute ol_flags and checksum error indexes for four packets. */
103 : : is_tunnel = _mm_and_si128(flags2, _mm_set1_epi32(4));
104 : : is_tunnel = _mm_slli_epi32(is_tunnel, 3);
105 : : flags2 = _mm_and_si128(flags2, _mm_set1_epi32(0x1F));
106 : :
107 : : errors = _mm_srli_epi32(_mm_unpacklo_epi64(t0, t1), 4);
108 : : errors = _mm_and_si128(errors, _mm_set1_epi32(0xF));
109 : : errors = _mm_and_si128(errors, flags2);
110 : :
111 : : index = _mm_andnot_si128(errors, flags2);
112 : : errors = _mm_or_si128(errors, _mm_srli_epi32(is_tunnel, 1));
113 : : index = _mm_or_si128(index, is_tunnel);
114 : :
115 : : /* Update mbuf rearm_data for four packets. */
116 [ # # ]: 0 : GET_OL_FLAGS(rss_flags, index, errors, 0, ol_flags);
117 [ # # ]: 0 : _mm_store_si128((void *)&mbuf[0]->rearm_data,
118 : : _mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
119 : :
120 [ # # ]: 0 : GET_OL_FLAGS(rss_flags, index, errors, 1, ol_flags);
121 [ # # ]: 0 : _mm_store_si128((void *)&mbuf[1]->rearm_data,
122 : : _mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
123 : :
124 [ # # ]: 0 : GET_OL_FLAGS(rss_flags, index, errors, 2, ol_flags);
125 [ # # ]: 0 : _mm_store_si128((void *)&mbuf[2]->rearm_data,
126 : : _mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
127 : :
128 [ # # ]: 0 : GET_OL_FLAGS(rss_flags, index, errors, 3, ol_flags);
129 : 0 : _mm_store_si128((void *)&mbuf[3]->rearm_data,
130 : : _mm_or_si128(mbuf_init, _mm_set_epi64x(ol_flags, 0)));
131 : :
132 : : /* Update mbuf rx_descriptor_fields1 for four packes. */
133 : 0 : GET_DESC_FIELDS(mm_rxcmp[0], mm_rxcmp1[0], shuf_msk, ptype_idx, 0, t0);
134 : 0 : _mm_store_si128((void *)&mbuf[0]->rx_descriptor_fields1, t0);
135 : :
136 : 0 : GET_DESC_FIELDS(mm_rxcmp[1], mm_rxcmp1[1], shuf_msk, ptype_idx, 1, t0);
137 : 0 : _mm_store_si128((void *)&mbuf[1]->rx_descriptor_fields1, t0);
138 : :
139 : 0 : GET_DESC_FIELDS(mm_rxcmp[2], mm_rxcmp1[2], shuf_msk, ptype_idx, 2, t0);
140 : 0 : _mm_store_si128((void *)&mbuf[2]->rx_descriptor_fields1, t0);
141 : :
142 : 0 : GET_DESC_FIELDS(mm_rxcmp[3], mm_rxcmp1[3], shuf_msk, ptype_idx, 3, t0);
143 : 0 : _mm_store_si128((void *)&mbuf[3]->rx_descriptor_fields1, t0);
144 : 0 : }
145 : :
146 : : static uint16_t
147 : 0 : recv_burst_vec_sse(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
148 : : {
149 : : struct bnxt_rx_queue *rxq = rx_queue;
150 [ # # ]: 0 : const __m128i mbuf_init = _mm_set_epi64x(0, rxq->mbuf_initializer);
151 : 0 : struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
152 : 0 : struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
153 : 0 : uint16_t cp_ring_size = cpr->cp_ring_struct->ring_size;
154 : 0 : uint16_t rx_ring_size = rxr->rx_ring_struct->ring_size;
155 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
156 : : uint64_t valid, desc_valid_mask = ~0ULL;
157 : : const __m128i info3_v_mask = _mm_set1_epi32(CMPL_BASE_V);
158 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
159 : : uint32_t cons, mbcons;
160 : : int nb_rx_pkts = 0;
161 : : const __m128i valid_target =
162 [ # # ]: 0 : _mm_set1_epi32(!!(raw_cons & cp_ring_size));
163 : : const __m128i shuf_msk =
164 : : _mm_set_epi8(15, 14, 13, 12, /* rss */
165 : : 0xFF, 0xFF, /* vlan_tci (zeroes) */
166 : : 3, 2, /* data_len */
167 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
168 : : 0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
169 : : int i;
170 : :
171 : : /* If Rx Q was stopped return */
172 [ # # ]: 0 : if (unlikely(!rxq->rx_started))
173 : : return 0;
174 : :
175 [ # # ]: 0 : if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
176 : 0 : bnxt_rxq_rearm(rxq, rxr);
177 : :
178 : 0 : cons = raw_cons & (cp_ring_size - 1);
179 : 0 : mbcons = (raw_cons / 2) & (rx_ring_size - 1);
180 : :
181 : : /* Prefetch first four descriptor pairs. */
182 : 0 : rte_prefetch0(&cp_desc_ring[cons]);
183 : 0 : rte_prefetch0(&cp_desc_ring[cons + 4]);
184 : :
185 : : /* Ensure that we do not go past the ends of the rings. */
186 : 0 : nb_pkts = RTE_MIN(nb_pkts, RTE_MIN(rx_ring_size - mbcons,
187 : : (cp_ring_size - cons) / 2));
188 : : /*
189 : : * If we are at the end of the ring, ensure that descriptors after the
190 : : * last valid entry are not treated as valid. Otherwise, force the
191 : : * maximum number of packets to receive to be a multiple of the per-
192 : : * loop count.
193 : : */
194 [ # # ]: 0 : if (nb_pkts < BNXT_RX_DESCS_PER_LOOP_VEC128) {
195 : 0 : desc_valid_mask >>=
196 : 0 : 16 * (BNXT_RX_DESCS_PER_LOOP_VEC128 - nb_pkts);
197 : : } else {
198 : 0 : nb_pkts =
199 : : RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC128);
200 : : }
201 : :
202 : : /* Handle RX burst request */
203 [ # # ]: 0 : for (i = 0; i < nb_pkts; i += BNXT_RX_DESCS_PER_LOOP_VEC128,
204 : 0 : cons += BNXT_RX_DESCS_PER_LOOP_VEC128 * 2,
205 : 0 : mbcons += BNXT_RX_DESCS_PER_LOOP_VEC128) {
206 : : __m128i rxcmp1[BNXT_RX_DESCS_PER_LOOP_VEC128];
207 : : __m128i rxcmp[BNXT_RX_DESCS_PER_LOOP_VEC128];
208 : : __m128i tmp0, tmp1, info3_v;
209 : : uint32_t num_valid;
210 : :
211 : : /* Copy four mbuf pointers to output array. */
212 [ # # ]: 0 : tmp0 = _mm_loadu_si128((void *)&rxr->rx_buf_ring[mbcons]);
213 : : #ifdef RTE_ARCH_X86_64
214 : 0 : tmp1 = _mm_loadu_si128((void *)&rxr->rx_buf_ring[mbcons + 2]);
215 : : #endif
216 [ # # ]: 0 : _mm_storeu_si128((void *)&rx_pkts[i], tmp0);
217 : : #ifdef RTE_ARCH_X86_64
218 : 0 : _mm_storeu_si128((void *)&rx_pkts[i + 2], tmp1);
219 : : #endif
220 : :
221 : : /* Prefetch four descriptor pairs for next iteration. */
222 [ # # ]: 0 : if (i + BNXT_RX_DESCS_PER_LOOP_VEC128 < nb_pkts) {
223 : 0 : rte_prefetch0(&cp_desc_ring[cons + 8]);
224 : 0 : rte_prefetch0(&cp_desc_ring[cons + 12]);
225 : : }
226 : :
227 : : /*
228 : : * Load the four current descriptors into SSE registers in
229 : : * reverse order to ensure consistent state.
230 : : */
231 : 0 : rxcmp1[3] = _mm_load_si128((void *)&cp_desc_ring[cons + 7]);
232 : 0 : rte_compiler_barrier();
233 : 0 : rxcmp[3] = _mm_load_si128((void *)&cp_desc_ring[cons + 6]);
234 : :
235 : 0 : rxcmp1[2] = _mm_load_si128((void *)&cp_desc_ring[cons + 5]);
236 : 0 : rte_compiler_barrier();
237 : 0 : rxcmp[2] = _mm_load_si128((void *)&cp_desc_ring[cons + 4]);
238 : :
239 : 0 : tmp1 = _mm_unpackhi_epi32(rxcmp1[2], rxcmp1[3]);
240 : :
241 : 0 : rxcmp1[1] = _mm_load_si128((void *)&cp_desc_ring[cons + 3]);
242 : 0 : rte_compiler_barrier();
243 : 0 : rxcmp[1] = _mm_load_si128((void *)&cp_desc_ring[cons + 2]);
244 : :
245 : 0 : rxcmp1[0] = _mm_load_si128((void *)&cp_desc_ring[cons + 1]);
246 : 0 : rte_compiler_barrier();
247 [ # # ]: 0 : rxcmp[0] = _mm_load_si128((void *)&cp_desc_ring[cons + 0]);
248 : :
249 [ # # ]: 0 : tmp0 = _mm_unpackhi_epi32(rxcmp1[0], rxcmp1[1]);
250 : :
251 : : /* Isolate descriptor valid flags. */
252 : : info3_v = _mm_and_si128(_mm_unpacklo_epi64(tmp0, tmp1),
253 : : info3_v_mask);
254 : : info3_v = _mm_xor_si128(info3_v, valid_target);
255 : :
256 : : /*
257 : : * Pack the 128-bit array of valid descriptor flags into 64
258 : : * bits and count the number of set bits in order to determine
259 : : * the number of valid descriptors.
260 : : */
261 : 0 : valid = _mm_cvtsi128_si64(_mm_packs_epi32(info3_v, info3_v));
262 [ # # ]: 0 : num_valid = rte_popcount64(valid & desc_valid_mask);
263 : :
264 [ # # ]: 0 : if (num_valid == 0)
265 : : break;
266 : :
267 : 0 : descs_to_mbufs(rxcmp, rxcmp1, mbuf_init, shuf_msk, &rx_pkts[nb_rx_pkts],
268 : : rxr);
269 : 0 : nb_rx_pkts += num_valid;
270 : :
271 [ # # ]: 0 : if (num_valid < BNXT_RX_DESCS_PER_LOOP_VEC128)
272 : : break;
273 : : }
274 : :
275 [ # # ]: 0 : if (nb_rx_pkts) {
276 : 0 : rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);
277 : :
278 : 0 : rxq->rxrearm_nb += nb_rx_pkts;
279 : 0 : cpr->cp_raw_cons += 2 * nb_rx_pkts;
280 : 0 : bnxt_db_cq(cpr);
281 : : }
282 : :
283 : 0 : return nb_rx_pkts;
284 : : }
285 : :
286 : : static uint16_t
287 : 0 : crx_burst_vec_sse(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
288 : : {
289 : : struct bnxt_rx_queue *rxq = rx_queue;
290 [ # # ]: 0 : const __m128i mbuf_init = _mm_set_epi64x(0, rxq->mbuf_initializer);
291 : 0 : struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
292 : 0 : struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
293 : 0 : uint16_t cp_ring_size = cpr->cp_ring_struct->ring_size;
294 : 0 : uint16_t rx_ring_size = rxr->rx_ring_struct->ring_size;
295 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
296 : : uint64_t valid, desc_valid_mask = ~0ULL;
297 : : const __m128i info3_v_mask = _mm_set1_epi32(CMPL_BASE_V);
298 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
299 : : uint32_t cons, mbcons;
300 : : int nb_rx_pkts = 0;
301 : : const __m128i valid_target =
302 [ # # ]: 0 : _mm_set1_epi32(!!(raw_cons & cp_ring_size));
303 : : const __m128i shuf_msk =
304 : : _mm_set_epi8(7, 6, 5, 4, /* rss */
305 : : 0xFF, 0xFF, /* vlan_tci (zeroes) */
306 : : 3, 2, /* data_len */
307 : : 0xFF, 0xFF, 3, 2, /* pkt_len */
308 : : 0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
309 : : int i;
310 : :
311 : : /* If Rx Q was stopped return */
312 [ # # ]: 0 : if (unlikely(!rxq->rx_started))
313 : : return 0;
314 : :
315 [ # # ]: 0 : if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
316 : 0 : bnxt_rxq_rearm(rxq, rxr);
317 : :
318 : 0 : cons = raw_cons & (cp_ring_size - 1);
319 : 0 : mbcons = raw_cons & (rx_ring_size - 1);
320 : :
321 : : /* Prefetch first four descriptor pairs. */
322 : 0 : rte_prefetch0(&cp_desc_ring[cons]);
323 : :
324 : : /* Ensure that we do not go past the ends of the rings. */
325 : 0 : nb_pkts = RTE_MIN(nb_pkts, RTE_MIN(rx_ring_size - mbcons,
326 : : cp_ring_size - cons));
327 : : /*
328 : : * If we are at the end of the ring, ensure that descriptors after the
329 : : * last valid entry are not treated as valid. Otherwise, force the
330 : : * maximum number of packets to receive to be a multiple of the per-
331 : : * loop count.
332 : : */
333 [ # # ]: 0 : if (nb_pkts < BNXT_RX_DESCS_PER_LOOP_VEC128) {
334 : 0 : desc_valid_mask >>=
335 : 0 : 16 * (BNXT_RX_DESCS_PER_LOOP_VEC128 - nb_pkts);
336 : : } else {
337 : 0 : nb_pkts =
338 : : RTE_ALIGN_FLOOR(nb_pkts, BNXT_RX_DESCS_PER_LOOP_VEC128);
339 : : }
340 : :
341 : : /* Handle RX burst request */
342 [ # # ]: 0 : for (i = 0; i < nb_pkts; i += BNXT_RX_DESCS_PER_LOOP_VEC128,
343 : 0 : cons += BNXT_RX_DESCS_PER_LOOP_VEC128,
344 : 0 : mbcons += BNXT_RX_DESCS_PER_LOOP_VEC128) {
345 : : __m128i rxcmp1[BNXT_RX_DESCS_PER_LOOP_VEC128];
346 : : __m128i rxcmp[BNXT_RX_DESCS_PER_LOOP_VEC128];
347 : : __m128i tmp0, tmp1, info3_v;
348 : : uint32_t num_valid;
349 : :
350 : : /* Copy four mbuf pointers to output array. */
351 [ # # ]: 0 : tmp0 = _mm_loadu_si128((void *)&rxr->rx_buf_ring[mbcons]);
352 : : #ifdef RTE_ARCH_X86_64
353 : 0 : tmp1 = _mm_loadu_si128((void *)&rxr->rx_buf_ring[mbcons + 2]);
354 : : #endif
355 [ # # ]: 0 : _mm_storeu_si128((void *)&rx_pkts[i], tmp0);
356 : : #ifdef RTE_ARCH_X86_64
357 : 0 : _mm_storeu_si128((void *)&rx_pkts[i + 2], tmp1);
358 : : #endif
359 : :
360 : : /* Prefetch four descriptor pairs for next iteration. */
361 [ # # ]: 0 : if (i + BNXT_RX_DESCS_PER_LOOP_VEC128 < nb_pkts)
362 : 0 : rte_prefetch0(&cp_desc_ring[cons + 4]);
363 : :
364 : : /*
365 : : * Load the four current descriptors into SSE registers in
366 : : * reverse order to ensure consistent state.
367 : : */
368 : 0 : rxcmp[3] = _mm_load_si128((void *)&cp_desc_ring[cons + 3]);
369 : 0 : rte_compiler_barrier();
370 : 0 : rxcmp[2] = _mm_load_si128((void *)&cp_desc_ring[cons + 2]);
371 : 0 : rte_compiler_barrier();
372 : 0 : rxcmp[1] = _mm_load_si128((void *)&cp_desc_ring[cons + 1]);
373 : 0 : rte_compiler_barrier();
374 [ # # ]: 0 : rxcmp[0] = _mm_load_si128((void *)&cp_desc_ring[cons + 0]);
375 : :
376 [ # # ]: 0 : tmp1 = _mm_unpackhi_epi32(rxcmp[2], rxcmp[3]);
377 [ # # ]: 0 : tmp0 = _mm_unpackhi_epi32(rxcmp[0], rxcmp[1]);
378 : :
379 : : /* Isolate descriptor valid flags. */
380 : : info3_v = _mm_and_si128(_mm_unpacklo_epi64(tmp0, tmp1),
381 : : info3_v_mask);
382 : : info3_v = _mm_xor_si128(info3_v, valid_target);
383 : :
384 : : /*
385 : : * Pack the 128-bit array of valid descriptor flags into 64
386 : : * bits and count the number of set bits in order to determine
387 : : * the number of valid descriptors.
388 : : */
389 : 0 : valid = _mm_cvtsi128_si64(_mm_packs_epi32(info3_v, info3_v));
390 [ # # ]: 0 : num_valid = rte_popcount64(valid & desc_valid_mask);
391 : :
392 [ # # ]: 0 : if (num_valid == 0)
393 : : break;
394 : :
395 : 0 : descs_to_mbufs(rxcmp, rxcmp1, mbuf_init, shuf_msk, &rx_pkts[nb_rx_pkts],
396 : : rxr);
397 : 0 : nb_rx_pkts += num_valid;
398 : :
399 [ # # ]: 0 : if (num_valid < BNXT_RX_DESCS_PER_LOOP_VEC128)
400 : : break;
401 : : }
402 : :
403 [ # # ]: 0 : if (nb_rx_pkts) {
404 : 0 : rxr->rx_raw_prod = RING_ADV(rxr->rx_raw_prod, nb_rx_pkts);
405 : :
406 : 0 : rxq->rxrearm_nb += nb_rx_pkts;
407 : 0 : cpr->cp_raw_cons += nb_rx_pkts;
408 : 0 : bnxt_db_cq(cpr);
409 : : }
410 : :
411 : 0 : return nb_rx_pkts;
412 : : }
413 : :
414 : : uint16_t
415 : 0 : bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
416 : : {
417 : : uint16_t cnt = 0;
418 : :
419 [ # # ]: 0 : while (nb_pkts > RTE_BNXT_MAX_RX_BURST) {
420 : : uint16_t burst;
421 : :
422 : 0 : burst = recv_burst_vec_sse(rx_queue, rx_pkts + cnt,
423 : : RTE_BNXT_MAX_RX_BURST);
424 : :
425 : 0 : cnt += burst;
426 : 0 : nb_pkts -= burst;
427 : :
428 [ # # ]: 0 : if (burst < RTE_BNXT_MAX_RX_BURST)
429 : 0 : return cnt;
430 : : }
431 : :
432 : 0 : return cnt + recv_burst_vec_sse(rx_queue, rx_pkts + cnt, nb_pkts);
433 : : }
434 : :
435 : : uint16_t
436 : 0 : bnxt_crx_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
437 : : {
438 : : uint16_t cnt = 0;
439 : :
440 [ # # ]: 0 : while (nb_pkts > RTE_BNXT_MAX_RX_BURST) {
441 : : uint16_t burst;
442 : :
443 : 0 : burst = crx_burst_vec_sse(rx_queue, rx_pkts + cnt,
444 : : RTE_BNXT_MAX_RX_BURST);
445 : :
446 : 0 : cnt += burst;
447 : 0 : nb_pkts -= burst;
448 : :
449 [ # # ]: 0 : if (burst < RTE_BNXT_MAX_RX_BURST)
450 : 0 : return cnt;
451 : : }
452 : :
453 : 0 : return cnt + crx_burst_vec_sse(rx_queue, rx_pkts + cnt, nb_pkts);
454 : : }
455 : :
456 : : static void
457 : 0 : bnxt_handle_tx_cp_vec(struct bnxt_tx_queue *txq)
458 : : {
459 : 0 : struct bnxt_cp_ring_info *cpr = txq->cp_ring;
460 : 0 : uint32_t raw_cons = cpr->cp_raw_cons;
461 : : uint32_t cons;
462 : : uint32_t nb_tx_pkts = 0;
463 : : struct tx_cmpl *txcmp;
464 : 0 : struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
465 : 0 : struct bnxt_ring *cp_ring_struct = cpr->cp_ring_struct;
466 : 0 : uint32_t ring_mask = cp_ring_struct->ring_mask;
467 : :
468 : : do {
469 : 0 : cons = RING_CMPL(ring_mask, raw_cons);
470 : 0 : txcmp = (struct tx_cmpl *)&cp_desc_ring[cons];
471 : :
472 [ # # ]: 0 : if (!bnxt_cpr_cmp_valid(txcmp, raw_cons, ring_mask + 1))
473 : : break;
474 : :
475 [ # # ]: 0 : if (likely(CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2))
476 : 0 : nb_tx_pkts += txcmp->opaque;
477 : : else
478 : 0 : RTE_LOG_DP(ERR, BNXT,
479 : : "Unhandled CMP type %02x\n",
480 : : CMP_TYPE(txcmp));
481 : 0 : raw_cons = NEXT_RAW_CMP(raw_cons);
482 [ # # ]: 0 : } while (nb_tx_pkts < ring_mask);
483 : :
484 [ # # ]: 0 : if (nb_tx_pkts) {
485 [ # # ]: 0 : if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
486 : 0 : bnxt_tx_cmp_vec_fast(txq, nb_tx_pkts);
487 : : else
488 : 0 : bnxt_tx_cmp_vec(txq, nb_tx_pkts);
489 : 0 : cpr->cp_raw_cons = raw_cons;
490 : 0 : bnxt_db_cq(cpr);
491 : : }
492 : 0 : }
493 : :
494 : : static inline void
495 : : bnxt_xmit_one(struct rte_mbuf *mbuf, struct tx_bd_long *txbd,
496 : : struct rte_mbuf **tx_buf)
497 : : {
498 : : __m128i desc;
499 : :
500 : 0 : *tx_buf = mbuf;
501 : :
502 [ # # # # : 0 : desc = _mm_set_epi64x(mbuf->buf_iova + mbuf->data_off,
# # ]
503 : 0 : bnxt_xmit_flags_len(mbuf->data_len,
504 : : TX_BD_FLAGS_NOCMPL));
505 : : desc = _mm_blend_epi16(desc, _mm_set_epi16(0, 0, 0, 0, 0, 0,
506 [ # # # # : 0 : mbuf->data_len, 0), 0x02);
# # ]
507 : : _mm_store_si128((void *)txbd, desc);
508 : : }
509 : :
510 : : static uint16_t
511 : 0 : bnxt_xmit_fixed_burst_vec(struct bnxt_tx_queue *txq, struct rte_mbuf **tx_pkts,
512 : : uint16_t nb_pkts)
513 : : {
514 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
515 : 0 : uint16_t tx_prod, tx_raw_prod = txr->tx_raw_prod;
516 : : struct tx_bd_long *txbd;
517 : : struct rte_mbuf **tx_buf;
518 : : uint16_t to_send;
519 : :
520 : 0 : tx_prod = RING_IDX(txr->tx_ring_struct, tx_raw_prod);
521 : 0 : txbd = &txr->tx_desc_ring[tx_prod];
522 : 0 : tx_buf = &txr->tx_buf_ring[tx_prod];
523 : :
524 : : /* Prefetch next transmit buffer descriptors. */
525 : : rte_prefetch0(txbd);
526 : 0 : rte_prefetch0(txbd + 3);
527 : :
528 : 0 : nb_pkts = RTE_MIN(nb_pkts, bnxt_tx_avail(txq));
529 : :
530 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
531 : : return 0;
532 : :
533 : : /* Handle TX burst request */
534 : : to_send = nb_pkts;
535 [ # # ]: 0 : while (to_send >= BNXT_TX_DESCS_PER_LOOP) {
536 : : /* Prefetch next transmit buffer descriptors. */
537 : 0 : rte_prefetch0(txbd + 4);
538 : 0 : rte_prefetch0(txbd + 7);
539 : :
540 [ # # ]: 0 : bnxt_xmit_one(tx_pkts[0], txbd++, tx_buf++);
541 [ # # ]: 0 : bnxt_xmit_one(tx_pkts[1], txbd++, tx_buf++);
542 [ # # ]: 0 : bnxt_xmit_one(tx_pkts[2], txbd++, tx_buf++);
543 [ # # ]: 0 : bnxt_xmit_one(tx_pkts[3], txbd++, tx_buf++);
544 : :
545 : 0 : to_send -= BNXT_TX_DESCS_PER_LOOP;
546 : 0 : tx_pkts += BNXT_TX_DESCS_PER_LOOP;
547 : : }
548 : :
549 [ # # ]: 0 : while (to_send) {
550 [ # # ]: 0 : bnxt_xmit_one(tx_pkts[0], txbd++, tx_buf++);
551 : 0 : to_send--;
552 : 0 : tx_pkts++;
553 : : }
554 : :
555 : : /* Request a completion for the final packet of burst. */
556 : 0 : rte_compiler_barrier();
557 : 0 : txbd[-1].opaque = nb_pkts;
558 : 0 : txbd[-1].flags_type &= ~TX_BD_LONG_FLAGS_NO_CMPL;
559 : :
560 : 0 : tx_raw_prod += nb_pkts;
561 [ # # ]: 0 : bnxt_db_write(&txr->tx_db, tx_raw_prod);
562 : :
563 : 0 : txr->tx_raw_prod = tx_raw_prod;
564 : :
565 : 0 : return nb_pkts;
566 : : }
567 : :
568 : : uint16_t
569 : 0 : bnxt_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
570 : : uint16_t nb_pkts)
571 : : {
572 : : int nb_sent = 0;
573 : : struct bnxt_tx_queue *txq = tx_queue;
574 : 0 : struct bnxt_tx_ring_info *txr = txq->tx_ring;
575 : 0 : uint16_t ring_size = txr->tx_ring_struct->ring_size;
576 : :
577 : : /* Tx queue was stopped; wait for it to be restarted */
578 [ # # ]: 0 : if (unlikely(!txq->tx_started)) {
579 : 0 : PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
580 : 0 : return 0;
581 : : }
582 : :
583 : : /* Handle TX completions */
584 [ # # ]: 0 : if (bnxt_tx_bds_in_hw(txq) >= txq->tx_free_thresh)
585 : 0 : bnxt_handle_tx_cp_vec(txq);
586 : :
587 [ # # ]: 0 : while (nb_pkts) {
588 : : uint16_t ret, num;
589 : :
590 : : /*
591 : : * Ensure that no more than RTE_BNXT_MAX_TX_BURST packets
592 : : * are transmitted before the next completion.
593 : : */
594 : 0 : num = RTE_MIN(nb_pkts, RTE_BNXT_MAX_TX_BURST);
595 : :
596 : : /*
597 : : * Ensure that a ring wrap does not occur within a call to
598 : : * bnxt_xmit_fixed_burst_vec().
599 : : */
600 : 0 : num = RTE_MIN(num, ring_size -
601 : : (txr->tx_raw_prod & (ring_size - 1)));
602 : 0 : ret = bnxt_xmit_fixed_burst_vec(txq, &tx_pkts[nb_sent], num);
603 : 0 : nb_sent += ret;
604 : 0 : nb_pkts -= ret;
605 [ # # ]: 0 : if (ret < num)
606 : : break;
607 : : }
608 : :
609 : 0 : return nb_sent;
610 : : }
611 : :
612 : : int __rte_cold
613 : 0 : bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq)
614 : : {
615 : 0 : return bnxt_rxq_vec_setup_common(rxq);
616 : : }
|