Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <stdlib.h>
7 : : #include <inttypes.h>
8 : : #include <math.h>
9 : :
10 : : #include <rte_eal.h>
11 : : #include <rte_common.h>
12 : : #include <rte_dev.h>
13 : : #include <rte_launch.h>
14 : : #include <rte_bbdev.h>
15 : : #include <rte_cycles.h>
16 : : #include <rte_lcore.h>
17 : : #include <rte_malloc.h>
18 : : #include <rte_random.h>
19 : : #include <rte_hexdump.h>
20 : : #include <rte_interrupts.h>
21 : :
22 : : #include "main.h"
23 : : #include "test_bbdev_vector.h"
24 : :
25 : : #define GET_SOCKET(socket_id) (((socket_id) == SOCKET_ID_ANY) ? 0 : (socket_id))
26 : :
27 : : #define MAX_QUEUES RTE_MAX_LCORE
28 : : #define TEST_REPETITIONS 100
29 : : #define TIME_OUT_POLL 1e9
30 : : #define WAIT_OFFLOAD_US 1000
31 : :
32 : : #ifdef RTE_BASEBAND_FPGA_LTE_FEC
33 : : #include <fpga_lte_fec.h>
34 : : #define FPGA_LTE_PF_DRIVER_NAME ("intel_fpga_lte_fec_pf")
35 : : #define FPGA_LTE_VF_DRIVER_NAME ("intel_fpga_lte_fec_vf")
36 : : #define VF_UL_4G_QUEUE_VALUE 4
37 : : #define VF_DL_4G_QUEUE_VALUE 4
38 : : #define UL_4G_BANDWIDTH 3
39 : : #define DL_4G_BANDWIDTH 3
40 : : #define UL_4G_LOAD_BALANCE 128
41 : : #define DL_4G_LOAD_BALANCE 128
42 : : #define FLR_4G_TIMEOUT 610
43 : : #endif
44 : :
45 : : #ifdef RTE_BASEBAND_FPGA_5GNR_FEC
46 : : #include <rte_pmd_fpga_5gnr_fec.h>
47 : : #define FPGA_5GNR_PF_DRIVER_NAME ("intel_fpga_5gnr_fec_pf")
48 : : #define FPGA_5GNR_VF_DRIVER_NAME ("intel_fpga_5gnr_fec_vf")
49 : : #define VF_UL_5G_QUEUE_VALUE 4
50 : : #define VF_DL_5G_QUEUE_VALUE 4
51 : : #define UL_5G_BANDWIDTH 3
52 : : #define DL_5G_BANDWIDTH 3
53 : : #define UL_5G_LOAD_BALANCE 128
54 : : #define DL_5G_LOAD_BALANCE 128
55 : : #endif
56 : :
57 : : #ifdef RTE_BASEBAND_ACC
58 : : #include <rte_acc_cfg.h>
59 : : #define ACC100PF_DRIVER_NAME ("intel_acc100_pf")
60 : : #define ACC100VF_DRIVER_NAME ("intel_acc100_vf")
61 : : #define ACC100_QMGR_NUM_AQS 16
62 : : #define ACC100_QMGR_NUM_QGS 2
63 : : #define ACC100_QMGR_AQ_DEPTH 5
64 : : #define ACC100_QMGR_INVALID_IDX -1
65 : : #define ACC100_QMGR_RR 1
66 : : #define ACC100_QOS_GBR 0
67 : : #define VRBPF_DRIVER_NAME ("intel_vran_boost_pf")
68 : : #define VRBVF_DRIVER_NAME ("intel_vran_boost_vf")
69 : : #define VRB_QMGR_NUM_AQS 16
70 : : #define VRB_QMGR_NUM_QGS 2
71 : : #define VRB_QMGR_AQ_DEPTH 5
72 : : #define VRB_QMGR_INVALID_IDX -1
73 : : #define VRB_QMGR_RR 1
74 : : #define VRB_QOS_GBR 0
75 : : #endif
76 : :
77 : : #define OPS_CACHE_SIZE 256U
78 : : #define OPS_POOL_SIZE_MIN 511U /* 0.5K per queue */
79 : :
80 : : #define SYNC_WAIT 0
81 : : #define SYNC_START 1
82 : :
83 : : #define INVALID_QUEUE_ID -1
84 : : /* Increment for next code block in external HARQ memory */
85 : : #define HARQ_INCR 32768
86 : : /* Headroom for filler LLRs insertion in HARQ buffer */
87 : : #define FILLER_HEADROOM 2048
88 : : /* Constants from K0 computation from 3GPP 38.212 Table 5.4.2.1-2 */
89 : : #define N_ZC_1 66 /* N = 66 Zc for BG 1 */
90 : : #define N_ZC_2 50 /* N = 50 Zc for BG 2 */
91 : : #define K0_1_1 17 /* K0 fraction numerator for rv 1 and BG 1 */
92 : : #define K0_1_2 13 /* K0 fraction numerator for rv 1 and BG 2 */
93 : : #define K0_2_1 33 /* K0 fraction numerator for rv 2 and BG 1 */
94 : : #define K0_2_2 25 /* K0 fraction numerator for rv 2 and BG 2 */
95 : : #define K0_3_1 56 /* K0 fraction numerator for rv 3 and BG 1 */
96 : : #define K0_3_2 43 /* K0 fraction numerator for rv 3 and BG 2 */
97 : : #define NUM_SC_PER_RB (12) /* Number of subcarriers in a RB in 3GPP. */
98 : : #define BITS_PER_LLR (8) /* Number of bits in a LLR. */
99 : :
100 : : #define HARQ_MEM_TOLERANCE 256
101 : : static struct test_bbdev_vector test_vector;
102 : :
103 : : /* Switch between PMD and Interrupt for throughput TC */
104 : : static bool intr_enabled;
105 : :
106 : : /* LLR arithmetic representation for numerical conversion */
107 : : static int ldpc_llr_decimals;
108 : : static int ldpc_llr_size;
109 : : /* Keep track of the LDPC decoder device capability flag */
110 : : static uint32_t ldpc_cap_flags;
111 : : /* FFT window width predefined on device and on vector. */
112 : : static int fft_window_width_dev;
113 : :
114 : : bool dump_ops = true;
115 : :
116 : : /* Represents tested active devices */
117 : : static struct active_device {
118 : : const char *driver_name;
119 : : uint8_t dev_id;
120 : : uint16_t supported_ops;
121 : : uint16_t queue_ids[MAX_QUEUES];
122 : : uint16_t nb_queues;
123 : : struct rte_mempool *ops_mempool;
124 : : struct rte_mempool *in_mbuf_pool;
125 : : struct rte_mempool *hard_out_mbuf_pool;
126 : : struct rte_mempool *soft_out_mbuf_pool;
127 : : struct rte_mempool *harq_in_mbuf_pool;
128 : : struct rte_mempool *harq_out_mbuf_pool;
129 : : } active_devs[RTE_BBDEV_MAX_DEVS];
130 : :
131 : : static uint8_t nb_active_devs;
132 : :
133 : : /* Data buffers used by BBDEV ops */
134 : : struct test_buffers {
135 : : struct rte_bbdev_op_data *inputs;
136 : : struct rte_bbdev_op_data *hard_outputs;
137 : : struct rte_bbdev_op_data *soft_outputs;
138 : : struct rte_bbdev_op_data *harq_inputs;
139 : : struct rte_bbdev_op_data *harq_outputs;
140 : : };
141 : :
142 : : /* Operation parameters specific for given test case */
143 : : struct test_op_params {
144 : : struct rte_mempool *mp;
145 : : struct rte_bbdev_dec_op *ref_dec_op;
146 : : struct rte_bbdev_enc_op *ref_enc_op;
147 : : struct rte_bbdev_fft_op *ref_fft_op;
148 : : struct rte_bbdev_mldts_op *ref_mldts_op;
149 : : uint16_t burst_sz;
150 : : uint16_t num_to_process;
151 : : uint16_t num_lcores;
152 : : int vector_mask;
153 : : RTE_ATOMIC(uint16_t) sync;
154 : : struct test_buffers q_bufs[RTE_MAX_NUMA_NODES][MAX_QUEUES];
155 : : };
156 : :
157 : : /* Contains per lcore params */
158 : : struct thread_params {
159 : : uint8_t dev_id;
160 : : uint16_t queue_id;
161 : : uint32_t lcore_id;
162 : : uint64_t start_time;
163 : : double ops_per_sec;
164 : : double mbps;
165 : : uint8_t iter_count;
166 : : double iter_average;
167 : : double bler;
168 : : RTE_ATOMIC(uint16_t) nb_dequeued;
169 : : RTE_ATOMIC(int16_t) processing_status;
170 : : RTE_ATOMIC(uint16_t) burst_sz;
171 : : struct test_op_params *op_params;
172 : : struct rte_bbdev_dec_op *dec_ops[MAX_BURST];
173 : : struct rte_bbdev_enc_op *enc_ops[MAX_BURST];
174 : : struct rte_bbdev_fft_op *fft_ops[MAX_BURST];
175 : : struct rte_bbdev_mldts_op *mldts_ops[MAX_BURST];
176 : : };
177 : :
178 : : /* Stores time statistics */
179 : : struct test_time_stats {
180 : : /* Stores software enqueue total working time */
181 : : uint64_t enq_sw_total_time;
182 : : /* Stores minimum value of software enqueue working time */
183 : : uint64_t enq_sw_min_time;
184 : : /* Stores maximum value of software enqueue working time */
185 : : uint64_t enq_sw_max_time;
186 : : /* Stores turbo enqueue total working time */
187 : : uint64_t enq_acc_total_time;
188 : : /* Stores minimum value of accelerator enqueue working time */
189 : : uint64_t enq_acc_min_time;
190 : : /* Stores maximum value of accelerator enqueue working time */
191 : : uint64_t enq_acc_max_time;
192 : : /* Stores dequeue total working time */
193 : : uint64_t deq_total_time;
194 : : /* Stores minimum value of dequeue working time */
195 : : uint64_t deq_min_time;
196 : : /* Stores maximum value of dequeue working time */
197 : : uint64_t deq_max_time;
198 : : };
199 : :
200 : : typedef int (test_case_function)(struct active_device *ad,
201 : : struct test_op_params *op_params);
202 : :
203 : : /* Get device status before timeout exit */
204 : : static inline void
205 : 0 : timeout_exit(uint8_t dev_id)
206 : : {
207 : : struct rte_bbdev_info info;
208 : 0 : rte_bbdev_info_get(dev_id, &info);
209 : 0 : printf("Device Status %s\n", rte_bbdev_device_status_str(info.drv.device_status));
210 : 0 : }
211 : :
212 : : static inline void
213 : : mbuf_reset(struct rte_mbuf *m)
214 : : {
215 : 0 : m->pkt_len = 0;
216 : :
217 : : do {
218 : 0 : m->data_len = 0;
219 : 0 : m = m->next;
220 : 0 : } while (m != NULL);
221 : : }
222 : :
223 : : /* Read flag value 0/1 from bitmap */
224 : : static inline bool
225 : : check_bit(uint32_t bitmap, uint32_t bitmask)
226 : : {
227 : 0 : return bitmap & bitmask;
228 : : }
229 : :
230 : : static inline void
231 : : set_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type)
232 : : {
233 : 0 : ad->supported_ops |= (1 << op_type);
234 : : }
235 : :
236 : : static inline bool
237 : : is_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type)
238 : : {
239 : 0 : return ad->supported_ops & (1 << op_type);
240 : : }
241 : :
242 : : static inline bool
243 : : flags_match(uint32_t flags_req, uint32_t flags_present)
244 : : {
245 : 0 : return (flags_req & flags_present) == flags_req;
246 : : }
247 : :
248 : : static void
249 : : clear_soft_out_cap(uint32_t *op_flags)
250 : : {
251 : 0 : *op_flags &= ~RTE_BBDEV_TURBO_SOFT_OUTPUT;
252 : : *op_flags &= ~RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT;
253 : 0 : *op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
254 : 0 : }
255 : :
256 : : /* This API is to convert all the test vector op data entries
257 : : * to big endian format. It is used when the device supports
258 : : * the input in the big endian format.
259 : : */
260 : : static inline void
261 : 0 : convert_op_data_to_be(void)
262 : : {
263 : : struct op_data_entries *op;
264 : : enum op_data_type type;
265 : : uint8_t nb_segs, *rem_data, temp;
266 : : uint32_t *data, len;
267 : : int complete, rem, i, j;
268 : :
269 : 0 : for (type = DATA_INPUT; type < DATA_NUM_TYPES; ++type) {
270 : 0 : nb_segs = test_vector.entries[type].nb_segments;
271 : : op = &test_vector.entries[type];
272 : :
273 : : /* Invert byte endianness for all the segments */
274 : 0 : for (i = 0; i < nb_segs; ++i) {
275 : 0 : len = op->segments[i].length;
276 : 0 : data = op->segments[i].addr;
277 : :
278 : : /* Swap complete u32 bytes */
279 : 0 : complete = len / 4;
280 : 0 : for (j = 0; j < complete; j++)
281 : 0 : data[j] = rte_bswap32(data[j]);
282 : :
283 : : /* Swap any remaining bytes */
284 : 0 : rem = len % 4;
285 : 0 : rem_data = (uint8_t *)&data[j];
286 : 0 : for (j = 0; j < rem/2; j++) {
287 : 0 : temp = rem_data[j];
288 : 0 : rem_data[j] = rem_data[rem - j - 1];
289 : 0 : rem_data[rem - j - 1] = temp;
290 : : }
291 : : }
292 : : }
293 : 0 : }
294 : :
295 : : static int
296 : 0 : check_dev_cap(const struct rte_bbdev_info *dev_info)
297 : : {
298 : : unsigned int i;
299 : : unsigned int nb_inputs, nb_soft_outputs, nb_hard_outputs,
300 : : nb_harq_inputs, nb_harq_outputs;
301 : 0 : const struct rte_bbdev_op_cap *op_cap = dev_info->drv.capabilities;
302 : 0 : uint8_t dev_data_endianness = dev_info->drv.data_endianness;
303 : :
304 : 0 : nb_inputs = test_vector.entries[DATA_INPUT].nb_segments;
305 : 0 : nb_soft_outputs = test_vector.entries[DATA_SOFT_OUTPUT].nb_segments;
306 : 0 : nb_hard_outputs = test_vector.entries[DATA_HARD_OUTPUT].nb_segments;
307 : 0 : nb_harq_inputs = test_vector.entries[DATA_HARQ_INPUT].nb_segments;
308 : 0 : nb_harq_outputs = test_vector.entries[DATA_HARQ_OUTPUT].nb_segments;
309 : :
310 : 0 : for (i = 0; op_cap->type != RTE_BBDEV_OP_NONE; ++i, ++op_cap) {
311 : 0 : if (op_cap->type != test_vector.op_type)
312 : 0 : continue;
313 : :
314 : 0 : if (dev_data_endianness == RTE_BIG_ENDIAN)
315 : 0 : convert_op_data_to_be();
316 : :
317 : 0 : if (op_cap->type == RTE_BBDEV_OP_TURBO_DEC) {
318 : : const struct rte_bbdev_op_cap_turbo_dec *cap =
319 : : &op_cap->cap.turbo_dec;
320 : : /* Ignore lack of soft output capability, just skip
321 : : * checking if soft output is valid.
322 : : */
323 : 0 : if ((test_vector.turbo_dec.op_flags &
324 : 0 : RTE_BBDEV_TURBO_SOFT_OUTPUT) &&
325 : 0 : !(cap->capability_flags &
326 : : RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
327 : : printf(
328 : : "INFO: Device \"%s\" does not support soft output - soft output flags will be ignored.\n",
329 : 0 : dev_info->dev_name);
330 : : clear_soft_out_cap(
331 : : &test_vector.turbo_dec.op_flags);
332 : : }
333 : :
334 : 0 : if (!flags_match(test_vector.turbo_dec.op_flags,
335 : 0 : cap->capability_flags))
336 : : return TEST_FAILED;
337 : 0 : if (nb_inputs > cap->num_buffers_src) {
338 : 0 : printf("Too many inputs defined: %u, max: %u\n",
339 : : nb_inputs, cap->num_buffers_src);
340 : 0 : return TEST_FAILED;
341 : : }
342 : 0 : if (nb_soft_outputs > cap->num_buffers_soft_out &&
343 : 0 : (test_vector.turbo_dec.op_flags &
344 : : RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
345 : 0 : printf(
346 : : "Too many soft outputs defined: %u, max: %u\n",
347 : : nb_soft_outputs,
348 : : cap->num_buffers_soft_out);
349 : 0 : return TEST_FAILED;
350 : : }
351 : 0 : if (nb_hard_outputs > cap->num_buffers_hard_out) {
352 : 0 : printf(
353 : : "Too many hard outputs defined: %u, max: %u\n",
354 : : nb_hard_outputs,
355 : : cap->num_buffers_hard_out);
356 : 0 : return TEST_FAILED;
357 : : }
358 : 0 : if (intr_enabled && !(cap->capability_flags &
359 : : RTE_BBDEV_TURBO_DEC_INTERRUPTS)) {
360 : : printf(
361 : : "Dequeue interrupts are not supported!\n");
362 : 0 : return TEST_FAILED;
363 : : }
364 : :
365 : : return TEST_SUCCESS;
366 : : } else if (op_cap->type == RTE_BBDEV_OP_TURBO_ENC) {
367 : : const struct rte_bbdev_op_cap_turbo_enc *cap =
368 : : &op_cap->cap.turbo_enc;
369 : :
370 : 0 : if (!flags_match(test_vector.turbo_enc.op_flags,
371 : 0 : cap->capability_flags))
372 : : return TEST_FAILED;
373 : 0 : if (nb_inputs > cap->num_buffers_src) {
374 : 0 : printf("Too many inputs defined: %u, max: %u\n",
375 : : nb_inputs, cap->num_buffers_src);
376 : 0 : return TEST_FAILED;
377 : : }
378 : 0 : if (nb_hard_outputs > cap->num_buffers_dst) {
379 : 0 : printf(
380 : : "Too many hard outputs defined: %u, max: %u\n",
381 : : nb_hard_outputs, cap->num_buffers_dst);
382 : 0 : return TEST_FAILED;
383 : : }
384 : 0 : if (intr_enabled && !(cap->capability_flags &
385 : : RTE_BBDEV_TURBO_ENC_INTERRUPTS)) {
386 : : printf(
387 : : "Dequeue interrupts are not supported!\n");
388 : 0 : return TEST_FAILED;
389 : : }
390 : :
391 : : return TEST_SUCCESS;
392 : : } else if (op_cap->type == RTE_BBDEV_OP_LDPC_ENC) {
393 : : const struct rte_bbdev_op_cap_ldpc_enc *cap =
394 : : &op_cap->cap.ldpc_enc;
395 : :
396 : 0 : if (!flags_match(test_vector.ldpc_enc.op_flags,
397 : 0 : cap->capability_flags)){
398 : : printf("Flag Mismatch\n");
399 : 0 : return TEST_FAILED;
400 : : }
401 : 0 : if (nb_inputs > cap->num_buffers_src) {
402 : 0 : printf("Too many inputs defined: %u, max: %u\n",
403 : : nb_inputs, cap->num_buffers_src);
404 : 0 : return TEST_FAILED;
405 : : }
406 : 0 : if (nb_hard_outputs > cap->num_buffers_dst) {
407 : 0 : printf(
408 : : "Too many hard outputs defined: %u, max: %u\n",
409 : : nb_hard_outputs, cap->num_buffers_dst);
410 : 0 : return TEST_FAILED;
411 : : }
412 : 0 : if (intr_enabled && !(cap->capability_flags &
413 : : RTE_BBDEV_LDPC_ENC_INTERRUPTS)) {
414 : : printf(
415 : : "Dequeue interrupts are not supported!\n");
416 : 0 : return TEST_FAILED;
417 : : }
418 : :
419 : : return TEST_SUCCESS;
420 : : } else if (op_cap->type == RTE_BBDEV_OP_LDPC_DEC) {
421 : : const struct rte_bbdev_op_cap_ldpc_dec *cap =
422 : : &op_cap->cap.ldpc_dec;
423 : :
424 : 0 : if (!flags_match(test_vector.ldpc_dec.op_flags,
425 : 0 : cap->capability_flags)){
426 : : printf("Flag Mismatch\n");
427 : 0 : return TEST_FAILED;
428 : : }
429 : 0 : if (nb_inputs > cap->num_buffers_src) {
430 : 0 : printf("Too many inputs defined: %u, max: %u\n",
431 : : nb_inputs, cap->num_buffers_src);
432 : 0 : return TEST_FAILED;
433 : : }
434 : 0 : if (nb_hard_outputs > cap->num_buffers_hard_out) {
435 : 0 : printf(
436 : : "Too many hard outputs defined: %u, max: %u\n",
437 : : nb_hard_outputs,
438 : : cap->num_buffers_hard_out);
439 : 0 : return TEST_FAILED;
440 : : }
441 : 0 : if (nb_harq_inputs > cap->num_buffers_hard_out) {
442 : 0 : printf(
443 : : "Too many HARQ inputs defined: %u, max: %u\n",
444 : : nb_harq_inputs,
445 : : cap->num_buffers_hard_out);
446 : 0 : return TEST_FAILED;
447 : : }
448 : 0 : if (nb_harq_outputs > cap->num_buffers_hard_out) {
449 : 0 : printf(
450 : : "Too many HARQ outputs defined: %u, max: %u\n",
451 : : nb_harq_outputs,
452 : : cap->num_buffers_hard_out);
453 : 0 : return TEST_FAILED;
454 : : }
455 : 0 : if (intr_enabled && !(cap->capability_flags &
456 : : RTE_BBDEV_LDPC_DEC_INTERRUPTS)) {
457 : : printf(
458 : : "Dequeue interrupts are not supported!\n");
459 : 0 : return TEST_FAILED;
460 : : }
461 : 0 : if (intr_enabled && (test_vector.ldpc_dec.op_flags &
462 : : (RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE |
463 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |
464 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK
465 : : ))) {
466 : : printf("Skip loop-back with interrupt\n");
467 : 0 : return TEST_FAILED;
468 : : }
469 : : return TEST_SUCCESS;
470 : : } else if (op_cap->type == RTE_BBDEV_OP_FFT) {
471 : : const struct rte_bbdev_op_cap_fft *cap = &op_cap->cap.fft;
472 : :
473 : 0 : if (!flags_match(test_vector.fft.op_flags, cap->capability_flags)) {
474 : : printf("Flag Mismatch\n");
475 : 0 : return TEST_FAILED;
476 : : }
477 : 0 : if (nb_inputs > cap->num_buffers_src) {
478 : 0 : printf("Too many inputs defined: %u, max: %u\n",
479 : : nb_inputs, cap->num_buffers_src);
480 : 0 : return TEST_FAILED;
481 : : }
482 : : return TEST_SUCCESS;
483 : : } else if (op_cap->type == RTE_BBDEV_OP_MLDTS) {
484 : : const struct rte_bbdev_op_cap_mld *cap = &op_cap->cap.mld;
485 : 0 : if (!flags_match(test_vector.mldts.op_flags, cap->capability_flags)) {
486 : : printf("Flag Mismatch\n");
487 : 0 : return TEST_FAILED;
488 : : }
489 : 0 : if (nb_inputs > cap->num_buffers_src) {
490 : 0 : printf("Too many inputs defined: %u, max: %u\n",
491 : : nb_inputs, cap->num_buffers_src);
492 : 0 : return TEST_FAILED;
493 : : }
494 : : return TEST_SUCCESS;
495 : : }
496 : : }
497 : :
498 : 0 : if ((i == 0) && (test_vector.op_type == RTE_BBDEV_OP_NONE))
499 : 0 : return TEST_SUCCESS; /* Special case for NULL device */
500 : :
501 : : return TEST_FAILED;
502 : : }
503 : :
504 : : /* calculates optimal mempool size not smaller than the val */
505 : : static unsigned int
506 : : optimal_mempool_size(unsigned int val)
507 : : {
508 : : return rte_align32pow2(val + 1) - 1;
509 : : }
510 : :
511 : : /* allocates mbuf mempool for inputs and outputs */
512 : : static struct rte_mempool *
513 : 0 : create_mbuf_pool(struct op_data_entries *entries, uint8_t dev_id,
514 : : int socket_id, unsigned int mbuf_pool_size,
515 : : const char *op_type_str)
516 : : {
517 : : unsigned int i;
518 : : uint32_t max_seg_sz = 0;
519 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
520 : :
521 : : /* find max input segment size */
522 : 0 : for (i = 0; i < entries->nb_segments; ++i)
523 : 0 : if (entries->segments[i].length > max_seg_sz)
524 : : max_seg_sz = entries->segments[i].length;
525 : :
526 : 0 : snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str,
527 : : dev_id);
528 : 0 : return rte_pktmbuf_pool_create(pool_name, mbuf_pool_size, 0, 0,
529 : 0 : RTE_MAX(max_seg_sz + RTE_PKTMBUF_HEADROOM
530 : : + FILLER_HEADROOM,
531 : : (unsigned int)RTE_MBUF_DEFAULT_BUF_SIZE), socket_id);
532 : : }
533 : :
534 : : static int
535 : 0 : create_mempools(struct active_device *ad, int socket_id,
536 : : enum rte_bbdev_op_type org_op_type, uint16_t num_ops)
537 : : {
538 : : struct rte_mempool *mp;
539 : : unsigned int ops_pool_size, mbuf_pool_size = 0;
540 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
541 : : const char *op_type_str;
542 : : enum rte_bbdev_op_type op_type = org_op_type;
543 : :
544 : : struct op_data_entries *in = &test_vector.entries[DATA_INPUT];
545 : : struct op_data_entries *hard_out =
546 : : &test_vector.entries[DATA_HARD_OUTPUT];
547 : : struct op_data_entries *soft_out =
548 : : &test_vector.entries[DATA_SOFT_OUTPUT];
549 : : struct op_data_entries *harq_in =
550 : : &test_vector.entries[DATA_HARQ_INPUT];
551 : : struct op_data_entries *harq_out =
552 : : &test_vector.entries[DATA_HARQ_OUTPUT];
553 : :
554 : : /* allocate ops mempool */
555 : 0 : ops_pool_size = optimal_mempool_size(RTE_MAX(
556 : : /* Ops used plus 1 reference op */
557 : : RTE_MAX((unsigned int)(ad->nb_queues * num_ops + 1),
558 : : /* Minimal cache size plus 1 reference op */
559 : : (unsigned int)(1.5 * rte_lcore_count() *
560 : : OPS_CACHE_SIZE + 1)),
561 : : OPS_POOL_SIZE_MIN));
562 : :
563 : 0 : if (org_op_type == RTE_BBDEV_OP_NONE)
564 : : op_type = RTE_BBDEV_OP_TURBO_ENC;
565 : :
566 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
567 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
568 : :
569 : 0 : snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str,
570 : 0 : ad->dev_id);
571 : 0 : mp = rte_bbdev_op_pool_create(pool_name, op_type,
572 : : ops_pool_size, OPS_CACHE_SIZE, socket_id);
573 : 0 : TEST_ASSERT_NOT_NULL(mp,
574 : : "ERROR Failed to create %u items ops pool for dev %u on socket %u.",
575 : : ops_pool_size,
576 : : ad->dev_id,
577 : : socket_id);
578 : 0 : ad->ops_mempool = mp;
579 : :
580 : : /* Do not create inputs and outputs mbufs for BaseBand Null Device */
581 : 0 : if (org_op_type == RTE_BBDEV_OP_NONE)
582 : : return TEST_SUCCESS;
583 : :
584 : : /* Inputs */
585 : 0 : if (in->nb_segments > 0) {
586 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
587 : : in->nb_segments);
588 : 0 : mp = create_mbuf_pool(in, ad->dev_id, socket_id,
589 : : mbuf_pool_size, "in");
590 : 0 : TEST_ASSERT_NOT_NULL(mp,
591 : : "ERROR Failed to create %u items input pktmbuf pool for dev %u on socket %u.",
592 : : mbuf_pool_size,
593 : : ad->dev_id,
594 : : socket_id);
595 : 0 : ad->in_mbuf_pool = mp;
596 : : }
597 : :
598 : : /* Hard outputs */
599 : 0 : if (hard_out->nb_segments > 0) {
600 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
601 : : hard_out->nb_segments);
602 : 0 : mp = create_mbuf_pool(hard_out, ad->dev_id, socket_id,
603 : : mbuf_pool_size,
604 : : "hard_out");
605 : 0 : TEST_ASSERT_NOT_NULL(mp,
606 : : "ERROR Failed to create %u items hard output pktmbuf pool for dev %u on socket %u.",
607 : : mbuf_pool_size,
608 : : ad->dev_id,
609 : : socket_id);
610 : 0 : ad->hard_out_mbuf_pool = mp;
611 : : }
612 : :
613 : : /* Soft outputs */
614 : 0 : if (soft_out->nb_segments > 0) {
615 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
616 : : soft_out->nb_segments);
617 : 0 : mp = create_mbuf_pool(soft_out, ad->dev_id, socket_id,
618 : : mbuf_pool_size,
619 : : "soft_out");
620 : 0 : TEST_ASSERT_NOT_NULL(mp,
621 : : "ERROR Failed to create %uB soft output pktmbuf pool for dev %u on socket %u.",
622 : : mbuf_pool_size,
623 : : ad->dev_id,
624 : : socket_id);
625 : 0 : ad->soft_out_mbuf_pool = mp;
626 : : }
627 : :
628 : : /* HARQ inputs */
629 : 0 : if (harq_in->nb_segments > 0) {
630 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
631 : : harq_in->nb_segments);
632 : 0 : mp = create_mbuf_pool(harq_in, ad->dev_id, socket_id,
633 : : mbuf_pool_size,
634 : : "harq_in");
635 : 0 : TEST_ASSERT_NOT_NULL(mp,
636 : : "ERROR Failed to create %uB harq input pktmbuf pool for dev %u on socket %u.",
637 : : mbuf_pool_size,
638 : : ad->dev_id,
639 : : socket_id);
640 : 0 : ad->harq_in_mbuf_pool = mp;
641 : : }
642 : :
643 : : /* HARQ outputs */
644 : 0 : if (harq_out->nb_segments > 0) {
645 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
646 : : harq_out->nb_segments);
647 : 0 : mp = create_mbuf_pool(harq_out, ad->dev_id, socket_id,
648 : : mbuf_pool_size,
649 : : "harq_out");
650 : 0 : TEST_ASSERT_NOT_NULL(mp,
651 : : "ERROR Failed to create %uB harq output pktmbuf pool for dev %u on socket %u.",
652 : : mbuf_pool_size,
653 : : ad->dev_id,
654 : : socket_id);
655 : 0 : ad->harq_out_mbuf_pool = mp;
656 : : }
657 : :
658 : : return TEST_SUCCESS;
659 : : }
660 : :
661 : : static int
662 : 0 : add_bbdev_dev(uint8_t dev_id, struct rte_bbdev_info *info,
663 : : struct test_bbdev_vector *vector)
664 : : {
665 : : int ret;
666 : : unsigned int queue_id;
667 : : struct rte_bbdev_queue_conf qconf;
668 : 0 : struct active_device *ad = &active_devs[nb_active_devs];
669 : : unsigned int nb_queues;
670 : 0 : enum rte_bbdev_op_type op_type = vector->op_type;
671 : :
672 : : /* Configure fpga lte fec with PF & VF values
673 : : * if '-i' flag is set and using fpga device
674 : : */
675 : : #ifdef RTE_BASEBAND_FPGA_LTE_FEC
676 : 0 : if ((get_init_device() == true) &&
677 : 0 : (!strcmp(info->drv.driver_name, FPGA_LTE_PF_DRIVER_NAME))) {
678 : : struct rte_fpga_lte_fec_conf conf;
679 : : unsigned int i;
680 : :
681 : : printf("Configure FPGA LTE FEC Driver %s with default values\n",
682 : : info->drv.driver_name);
683 : :
684 : : /* clear default configuration before initialization */
685 : : memset(&conf, 0, sizeof(struct rte_fpga_lte_fec_conf));
686 : :
687 : : /* Set PF mode :
688 : : * true if PF is used for data plane
689 : : * false for VFs
690 : : */
691 : 0 : conf.pf_mode_en = true;
692 : :
693 : 0 : for (i = 0; i < FPGA_LTE_FEC_NUM_VFS; ++i) {
694 : : /* Number of UL queues per VF (fpga supports 8 VFs) */
695 : 0 : conf.vf_ul_queues_number[i] = VF_UL_4G_QUEUE_VALUE;
696 : : /* Number of DL queues per VF (fpga supports 8 VFs) */
697 : 0 : conf.vf_dl_queues_number[i] = VF_DL_4G_QUEUE_VALUE;
698 : : }
699 : :
700 : : /* UL bandwidth. Needed for schedule algorithm */
701 : 0 : conf.ul_bandwidth = UL_4G_BANDWIDTH;
702 : : /* DL bandwidth */
703 : 0 : conf.dl_bandwidth = DL_4G_BANDWIDTH;
704 : :
705 : : /* UL & DL load Balance Factor to 64 */
706 : 0 : conf.ul_load_balance = UL_4G_LOAD_BALANCE;
707 : 0 : conf.dl_load_balance = DL_4G_LOAD_BALANCE;
708 : :
709 : : /**< FLR timeout value */
710 : 0 : conf.flr_time_out = FLR_4G_TIMEOUT;
711 : :
712 : : /* setup FPGA PF with configuration information */
713 : 0 : ret = rte_fpga_lte_fec_configure(info->dev_name, &conf);
714 : 0 : TEST_ASSERT_SUCCESS(ret,
715 : : "Failed to configure 4G FPGA PF for bbdev %s",
716 : : info->dev_name);
717 : : }
718 : : #endif
719 : : #ifdef RTE_BASEBAND_FPGA_5GNR_FEC
720 : 0 : if ((get_init_device() == true) &&
721 : 0 : (!strcmp(info->drv.driver_name, FPGA_5GNR_PF_DRIVER_NAME))) {
722 : : struct rte_fpga_5gnr_fec_conf conf;
723 : : unsigned int i;
724 : :
725 : : printf("Configure FPGA 5GNR FEC Driver %s with default values\n",
726 : : info->drv.driver_name);
727 : :
728 : : /* clear default configuration before initialization */
729 : : memset(&conf, 0, sizeof(struct rte_fpga_5gnr_fec_conf));
730 : :
731 : : /* Set PF mode :
732 : : * true if PF is used for data plane
733 : : * false for VFs
734 : : */
735 : 0 : conf.pf_mode_en = true;
736 : :
737 : 0 : for (i = 0; i < FPGA_5GNR_FEC_NUM_VFS; ++i) {
738 : : /* Number of UL queues per VF (fpga supports 8 VFs) */
739 : 0 : conf.vf_ul_queues_number[i] = VF_UL_5G_QUEUE_VALUE;
740 : : /* Number of DL queues per VF (fpga supports 8 VFs) */
741 : 0 : conf.vf_dl_queues_number[i] = VF_DL_5G_QUEUE_VALUE;
742 : : }
743 : :
744 : : /* UL bandwidth. Needed only for Vista Creek 5GNR schedule algorithm */
745 : 0 : conf.ul_bandwidth = UL_5G_BANDWIDTH;
746 : : /* DL bandwidth. Needed only for Vista Creek 5GNR schedule algorithm */
747 : 0 : conf.dl_bandwidth = DL_5G_BANDWIDTH;
748 : :
749 : : /* UL & DL load Balance Factor to 64 */
750 : 0 : conf.ul_load_balance = UL_5G_LOAD_BALANCE;
751 : 0 : conf.dl_load_balance = DL_5G_LOAD_BALANCE;
752 : :
753 : : /* setup FPGA PF with configuration information */
754 : 0 : ret = rte_fpga_5gnr_fec_configure(info->dev_name, &conf);
755 : 0 : TEST_ASSERT_SUCCESS(ret,
756 : : "Failed to configure 5G FPGA PF for bbdev %s",
757 : : info->dev_name);
758 : : }
759 : : #endif
760 : : #ifdef RTE_BASEBAND_ACC
761 : 0 : if ((get_init_device() == true) &&
762 : 0 : (!strcmp(info->drv.driver_name, ACC100PF_DRIVER_NAME))) {
763 : : struct rte_acc_conf conf;
764 : : unsigned int i;
765 : :
766 : : printf("Configure ACC100 FEC device %s with default values\n",
767 : : info->drv.driver_name);
768 : :
769 : : /* clear default configuration before initialization */
770 : : memset(&conf, 0, sizeof(struct rte_acc_conf));
771 : :
772 : : /* Always set in PF mode for built-in configuration */
773 : 0 : conf.pf_mode_en = true;
774 : 0 : for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
775 : 0 : conf.arb_dl_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
776 : : conf.arb_dl_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
777 : 0 : conf.arb_dl_4g[i].round_robin_weight = ACC100_QMGR_RR;
778 : 0 : conf.arb_ul_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
779 : : conf.arb_ul_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
780 : 0 : conf.arb_ul_4g[i].round_robin_weight = ACC100_QMGR_RR;
781 : 0 : conf.arb_dl_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
782 : : conf.arb_dl_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
783 : 0 : conf.arb_dl_5g[i].round_robin_weight = ACC100_QMGR_RR;
784 : 0 : conf.arb_ul_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
785 : : conf.arb_ul_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
786 : 0 : conf.arb_ul_5g[i].round_robin_weight = ACC100_QMGR_RR;
787 : : }
788 : :
789 : 0 : conf.input_pos_llr_1_bit = true;
790 : 0 : conf.output_pos_llr_1_bit = true;
791 : 0 : conf.num_vf_bundles = 1; /**< Number of VF bundles to setup */
792 : :
793 : 0 : conf.q_ul_4g.num_qgroups = ACC100_QMGR_NUM_QGS;
794 : 0 : conf.q_ul_4g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
795 : 0 : conf.q_ul_4g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
796 : 0 : conf.q_ul_4g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
797 : 0 : conf.q_dl_4g.num_qgroups = ACC100_QMGR_NUM_QGS;
798 : 0 : conf.q_dl_4g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
799 : 0 : conf.q_dl_4g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
800 : 0 : conf.q_dl_4g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
801 : 0 : conf.q_ul_5g.num_qgroups = ACC100_QMGR_NUM_QGS;
802 : 0 : conf.q_ul_5g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
803 : 0 : conf.q_ul_5g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
804 : 0 : conf.q_ul_5g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
805 : 0 : conf.q_dl_5g.num_qgroups = ACC100_QMGR_NUM_QGS;
806 : 0 : conf.q_dl_5g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
807 : 0 : conf.q_dl_5g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
808 : 0 : conf.q_dl_5g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
809 : :
810 : : /* setup PF with configuration information */
811 : 0 : ret = rte_acc_configure(info->dev_name, &conf);
812 : 0 : TEST_ASSERT_SUCCESS(ret,
813 : : "Failed to configure ACC100 PF for bbdev %s",
814 : : info->dev_name);
815 : : }
816 : 0 : if ((get_init_device() == true) &&
817 : 0 : (!strcmp(info->drv.driver_name, VRBPF_DRIVER_NAME))) {
818 : : struct rte_acc_conf conf;
819 : : unsigned int i;
820 : :
821 : : printf("Configure Driver %s with default values\n",
822 : : info->drv.driver_name);
823 : :
824 : : /* clear default configuration before initialization */
825 : : memset(&conf, 0, sizeof(struct rte_acc_conf));
826 : :
827 : : /* Always set in PF mode for built-in configuration */
828 : 0 : conf.pf_mode_en = true;
829 : 0 : for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
830 : 0 : conf.arb_dl_4g[i].gbr_threshold1 = VRB_QOS_GBR;
831 : : conf.arb_dl_4g[i].gbr_threshold1 = VRB_QOS_GBR;
832 : 0 : conf.arb_dl_4g[i].round_robin_weight = VRB_QMGR_RR;
833 : 0 : conf.arb_ul_4g[i].gbr_threshold1 = VRB_QOS_GBR;
834 : : conf.arb_ul_4g[i].gbr_threshold1 = VRB_QOS_GBR;
835 : 0 : conf.arb_ul_4g[i].round_robin_weight = VRB_QMGR_RR;
836 : 0 : conf.arb_dl_5g[i].gbr_threshold1 = VRB_QOS_GBR;
837 : : conf.arb_dl_5g[i].gbr_threshold1 = VRB_QOS_GBR;
838 : 0 : conf.arb_dl_5g[i].round_robin_weight = VRB_QMGR_RR;
839 : 0 : conf.arb_ul_5g[i].gbr_threshold1 = VRB_QOS_GBR;
840 : : conf.arb_ul_5g[i].gbr_threshold1 = VRB_QOS_GBR;
841 : 0 : conf.arb_ul_5g[i].round_robin_weight = VRB_QMGR_RR;
842 : 0 : conf.arb_fft[i].gbr_threshold1 = VRB_QOS_GBR;
843 : : conf.arb_fft[i].gbr_threshold1 = VRB_QOS_GBR;
844 : 0 : conf.arb_fft[i].round_robin_weight = VRB_QMGR_RR;
845 : 0 : conf.arb_mld[i].gbr_threshold1 = VRB_QOS_GBR;
846 : : conf.arb_mld[i].gbr_threshold1 = VRB_QOS_GBR;
847 : 0 : conf.arb_mld[i].round_robin_weight = VRB_QMGR_RR;
848 : : }
849 : :
850 : 0 : conf.input_pos_llr_1_bit = true;
851 : 0 : conf.output_pos_llr_1_bit = true;
852 : 0 : conf.num_vf_bundles = 1; /**< Number of VF bundles to setup */
853 : :
854 : 0 : conf.q_ul_4g.num_qgroups = VRB_QMGR_NUM_QGS;
855 : 0 : conf.q_ul_4g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
856 : 0 : conf.q_ul_4g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
857 : 0 : conf.q_ul_4g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
858 : 0 : conf.q_dl_4g.num_qgroups = VRB_QMGR_NUM_QGS;
859 : 0 : conf.q_dl_4g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
860 : 0 : conf.q_dl_4g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
861 : 0 : conf.q_dl_4g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
862 : 0 : conf.q_ul_5g.num_qgroups = VRB_QMGR_NUM_QGS;
863 : 0 : conf.q_ul_5g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
864 : 0 : conf.q_ul_5g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
865 : 0 : conf.q_ul_5g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
866 : 0 : conf.q_dl_5g.num_qgroups = VRB_QMGR_NUM_QGS;
867 : 0 : conf.q_dl_5g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
868 : 0 : conf.q_dl_5g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
869 : 0 : conf.q_dl_5g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
870 : 0 : conf.q_fft.num_qgroups = VRB_QMGR_NUM_QGS;
871 : 0 : conf.q_fft.first_qgroup_index = VRB_QMGR_INVALID_IDX;
872 : 0 : conf.q_fft.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
873 : 0 : conf.q_fft.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
874 : 0 : conf.q_mld.num_qgroups = VRB_QMGR_NUM_QGS;
875 : 0 : conf.q_mld.first_qgroup_index = VRB_QMGR_INVALID_IDX;
876 : 0 : conf.q_mld.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
877 : 0 : conf.q_mld.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
878 : :
879 : : /* setup PF with configuration information */
880 : 0 : ret = rte_acc_configure(info->dev_name, &conf);
881 : 0 : TEST_ASSERT_SUCCESS(ret,
882 : : "Failed to configure PF for bbdev %s",
883 : : info->dev_name);
884 : : }
885 : : #endif
886 : : /* Let's refresh this now this is configured */
887 : 0 : rte_bbdev_info_get(dev_id, info);
888 : 0 : if (info->drv.device_status == RTE_BBDEV_DEV_FATAL_ERR)
889 : 0 : printf("Device Status %s\n", rte_bbdev_device_status_str(info->drv.device_status));
890 : 0 : if (info->drv.fft_window_width != NULL)
891 : 0 : fft_window_width_dev = info->drv.fft_window_width[0];
892 : : else
893 : 0 : fft_window_width_dev = 0;
894 : 0 : if (fft_window_width_dev != 0)
895 : : printf(" FFT Window0 width %d\n", fft_window_width_dev);
896 : :
897 : 0 : nb_queues = RTE_MIN(rte_lcore_count(), info->drv.max_num_queues);
898 : 0 : nb_queues = RTE_MIN(nb_queues, (unsigned int) MAX_QUEUES);
899 : :
900 : : /* setup device */
901 : 0 : ret = rte_bbdev_setup_queues(dev_id, nb_queues, info->socket_id);
902 : 0 : if (ret < 0) {
903 : 0 : printf("rte_bbdev_setup_queues(%u, %u, %d) ret %i\n",
904 : : dev_id, nb_queues, info->socket_id, ret);
905 : 0 : return TEST_FAILED;
906 : : }
907 : :
908 : : /* configure interrupts if needed */
909 : 0 : if (intr_enabled) {
910 : 0 : ret = rte_bbdev_intr_enable(dev_id);
911 : 0 : if (ret < 0) {
912 : : printf("rte_bbdev_intr_enable(%u) ret %i\n", dev_id,
913 : : ret);
914 : 0 : return TEST_FAILED;
915 : : }
916 : : }
917 : :
918 : : /* setup device queues */
919 : 0 : qconf.socket = info->socket_id;
920 : 0 : qconf.queue_size = info->drv.default_queue_conf.queue_size;
921 : 0 : qconf.priority = 0;
922 : 0 : qconf.deferred_start = 0;
923 : 0 : qconf.op_type = op_type;
924 : :
925 : 0 : for (queue_id = 0; queue_id < nb_queues; ++queue_id) {
926 : 0 : ret = rte_bbdev_queue_configure(dev_id, queue_id, &qconf);
927 : 0 : if (ret != 0) {
928 : 0 : printf(
929 : : "Allocated all queues (id=%u) at prio%u on dev%u\n",
930 : 0 : queue_id, qconf.priority, dev_id);
931 : 0 : qconf.priority++;
932 : 0 : ret = rte_bbdev_queue_configure(ad->dev_id, queue_id, &qconf);
933 : : }
934 : 0 : if (ret != 0) {
935 : : printf("All queues on dev %u allocated: %u\n", dev_id, queue_id);
936 : : break;
937 : : }
938 : 0 : ret = rte_bbdev_queue_start(ad->dev_id, queue_id);
939 : 0 : if (ret != 0) {
940 : : printf("Failed to start queue on dev %u q_id: %u\n", dev_id, queue_id);
941 : : break;
942 : : }
943 : 0 : ad->queue_ids[queue_id] = queue_id;
944 : : }
945 : 0 : TEST_ASSERT(queue_id != 0,
946 : : "ERROR Failed to configure any queues on dev %u\n"
947 : : "\tthe device may not support the related operation capability\n"
948 : : "\tor the device may not have been configured yet", dev_id);
949 : 0 : ad->nb_queues = queue_id;
950 : :
951 : : set_avail_op(ad, op_type);
952 : :
953 : 0 : return TEST_SUCCESS;
954 : : }
955 : :
956 : : static int
957 : 0 : add_active_device(uint8_t dev_id, struct rte_bbdev_info *info,
958 : : struct test_bbdev_vector *vector)
959 : : {
960 : : int ret;
961 : :
962 : 0 : active_devs[nb_active_devs].driver_name = info->drv.driver_name;
963 : 0 : active_devs[nb_active_devs].dev_id = dev_id;
964 : :
965 : 0 : ret = add_bbdev_dev(dev_id, info, vector);
966 : 0 : if (ret == TEST_SUCCESS)
967 : 0 : ++nb_active_devs;
968 : 0 : return ret;
969 : : }
970 : :
971 : : static uint8_t
972 : 0 : populate_active_devices(void)
973 : : {
974 : : int ret;
975 : : uint8_t dev_id;
976 : : uint8_t nb_devs_added = 0;
977 : : struct rte_bbdev_info info;
978 : :
979 : 0 : RTE_BBDEV_FOREACH(dev_id) {
980 : 0 : rte_bbdev_info_get(dev_id, &info);
981 : :
982 : 0 : if (check_dev_cap(&info)) {
983 : 0 : printf(
984 : : "Device %d (%s) does not support specified capabilities\n",
985 : : dev_id, info.dev_name);
986 : 0 : continue;
987 : : }
988 : :
989 : 0 : ret = add_active_device(dev_id, &info, &test_vector);
990 : 0 : if (ret != 0) {
991 : 0 : printf("Adding active bbdev %s skipped\n",
992 : : info.dev_name);
993 : 0 : continue;
994 : : }
995 : 0 : nb_devs_added++;
996 : : }
997 : :
998 : 0 : return nb_devs_added;
999 : : }
1000 : :
1001 : : static int
1002 : 0 : read_test_vector(void)
1003 : : {
1004 : : int ret;
1005 : :
1006 : : memset(&test_vector, 0, sizeof(test_vector));
1007 : 0 : printf("Test vector file = %s\n", get_vector_filename());
1008 : 0 : ret = test_bbdev_vector_read(get_vector_filename(), &test_vector);
1009 : 0 : TEST_ASSERT_SUCCESS(ret, "Failed to parse file %s\n",
1010 : : get_vector_filename());
1011 : :
1012 : : return TEST_SUCCESS;
1013 : : }
1014 : :
1015 : : static int
1016 : 0 : testsuite_setup(void)
1017 : : {
1018 : 0 : TEST_ASSERT_SUCCESS(read_test_vector(), "Test suite setup failed\n");
1019 : :
1020 : 0 : if (populate_active_devices() == 0) {
1021 : : printf("No suitable devices found!\n");
1022 : 0 : return TEST_SKIPPED;
1023 : : }
1024 : :
1025 : : return TEST_SUCCESS;
1026 : : }
1027 : :
1028 : : static int
1029 : 0 : interrupt_testsuite_setup(void)
1030 : : {
1031 : 0 : TEST_ASSERT_SUCCESS(read_test_vector(), "Test suite setup failed\n");
1032 : :
1033 : : /* Enable interrupts */
1034 : 0 : intr_enabled = true;
1035 : :
1036 : : /* Special case for NULL device (RTE_BBDEV_OP_NONE) */
1037 : 0 : if (populate_active_devices() == 0 ||
1038 : 0 : test_vector.op_type == RTE_BBDEV_OP_NONE) {
1039 : 0 : intr_enabled = false;
1040 : : printf("No suitable devices found!\n");
1041 : 0 : return TEST_SKIPPED;
1042 : : }
1043 : :
1044 : : return TEST_SUCCESS;
1045 : : }
1046 : :
1047 : : static void
1048 : 0 : testsuite_teardown(void)
1049 : : {
1050 : : uint8_t dev_id;
1051 : :
1052 : : /* Unconfigure devices */
1053 : 0 : RTE_BBDEV_FOREACH(dev_id)
1054 : 0 : rte_bbdev_close(dev_id);
1055 : :
1056 : : /* Clear active devices structs. */
1057 : : memset(active_devs, 0, sizeof(active_devs));
1058 : 0 : nb_active_devs = 0;
1059 : :
1060 : : /* Disable interrupts */
1061 : 0 : intr_enabled = false;
1062 : 0 : }
1063 : :
1064 : : static int
1065 : 0 : ut_setup(void)
1066 : : {
1067 : : uint8_t i, dev_id;
1068 : :
1069 : 0 : for (i = 0; i < nb_active_devs; i++) {
1070 : 0 : dev_id = active_devs[i].dev_id;
1071 : : /* reset bbdev stats */
1072 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id),
1073 : : "Failed to reset stats of bbdev %u", dev_id);
1074 : : /* start the device */
1075 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id),
1076 : : "Failed to start bbdev %u", dev_id);
1077 : : }
1078 : :
1079 : : return TEST_SUCCESS;
1080 : : }
1081 : :
1082 : : static void
1083 : 0 : ut_teardown(void)
1084 : : {
1085 : : uint8_t i, dev_id, ret;
1086 : : struct rte_bbdev_stats stats;
1087 : :
1088 : 0 : for (i = 0; i < nb_active_devs; i++) {
1089 : 0 : dev_id = active_devs[i].dev_id;
1090 : : /* read stats and print */
1091 : 0 : ret = rte_bbdev_stats_get(dev_id, &stats);
1092 : 0 : if (ret != 0)
1093 : : printf("Failed to get stats on bbdev %u\n", dev_id);
1094 : : /* Stop the device */
1095 : 0 : rte_bbdev_stop(dev_id);
1096 : : }
1097 : 0 : }
1098 : :
1099 : : static int
1100 : 0 : init_op_data_objs(struct rte_bbdev_op_data *bufs,
1101 : : struct op_data_entries *ref_entries,
1102 : : struct rte_mempool *mbuf_pool, const uint16_t n,
1103 : : enum op_data_type op_type, uint16_t min_alignment)
1104 : : {
1105 : : int ret;
1106 : : unsigned int i, j;
1107 : : bool large_input = false;
1108 : :
1109 : 0 : for (i = 0; i < n; ++i) {
1110 : : char *data;
1111 : 0 : struct op_data_buf *seg = &ref_entries->segments[0];
1112 : 0 : struct rte_mbuf *m_head = rte_pktmbuf_alloc(mbuf_pool);
1113 : 0 : TEST_ASSERT_NOT_NULL(m_head,
1114 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1115 : : op_type, n * ref_entries->nb_segments,
1116 : : mbuf_pool->size);
1117 : :
1118 : 0 : if ((seg->length + RTE_PKTMBUF_HEADROOM) > RTE_BBDEV_LDPC_E_MAX_MBUF) {
1119 : : /*
1120 : : * Special case when DPDK mbuf cannot handle
1121 : : * the required input size
1122 : : */
1123 : : large_input = true;
1124 : : }
1125 : 0 : bufs[i].data = m_head;
1126 : 0 : bufs[i].offset = 0;
1127 : 0 : bufs[i].length = 0;
1128 : :
1129 : 0 : if ((op_type == DATA_INPUT) || (op_type == DATA_HARQ_INPUT)) {
1130 : 0 : if (large_input) {
1131 : : /* Allocate a fake overused mbuf */
1132 : 0 : data = rte_malloc(NULL, seg->length, 0);
1133 : 0 : TEST_ASSERT_NOT_NULL(data,
1134 : : "rte malloc failed with %u bytes",
1135 : : seg->length);
1136 : 0 : memcpy(data, seg->addr, seg->length);
1137 : 0 : m_head->buf_addr = data;
1138 : 0 : rte_mbuf_iova_set(m_head, rte_malloc_virt2iova(data));
1139 : 0 : m_head->data_off = 0;
1140 : 0 : m_head->data_len = seg->length;
1141 : : } else {
1142 : 0 : data = rte_pktmbuf_append(m_head, seg->length);
1143 : 0 : TEST_ASSERT_NOT_NULL(data,
1144 : : "Couldn't append %u bytes to mbuf from %d data type mbuf pool",
1145 : : seg->length, op_type);
1146 : :
1147 : 0 : TEST_ASSERT(data == RTE_PTR_ALIGN(
1148 : : data, min_alignment),
1149 : : "Data addr in mbuf (%p) is not aligned to device min alignment (%u)",
1150 : : data, min_alignment);
1151 : 0 : rte_memcpy(data, seg->addr, seg->length);
1152 : : }
1153 : :
1154 : 0 : bufs[i].length += seg->length;
1155 : :
1156 : 0 : for (j = 1; j < ref_entries->nb_segments; ++j) {
1157 : : struct rte_mbuf *m_tail =
1158 : 0 : rte_pktmbuf_alloc(mbuf_pool);
1159 : 0 : TEST_ASSERT_NOT_NULL(m_tail,
1160 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1161 : : op_type,
1162 : : n * ref_entries->nb_segments,
1163 : : mbuf_pool->size);
1164 : 0 : seg += 1;
1165 : :
1166 : 0 : data = rte_pktmbuf_append(m_tail, seg->length);
1167 : 0 : TEST_ASSERT_NOT_NULL(data,
1168 : : "Couldn't append %u bytes to mbuf from %d data type mbuf pool",
1169 : : seg->length, op_type);
1170 : :
1171 : 0 : TEST_ASSERT(data == RTE_PTR_ALIGN(data,
1172 : : min_alignment),
1173 : : "Data addr in mbuf (%p) is not aligned to device min alignment (%u)",
1174 : : data, min_alignment);
1175 : 0 : rte_memcpy(data, seg->addr, seg->length);
1176 : 0 : bufs[i].length += seg->length;
1177 : :
1178 : : ret = rte_pktmbuf_chain(m_head, m_tail);
1179 : 0 : TEST_ASSERT_SUCCESS(ret,
1180 : : "Couldn't chain mbufs from %d data type mbuf pool",
1181 : : op_type);
1182 : : }
1183 : : } else {
1184 : 0 : if (((op_type == DATA_HARD_OUTPUT) || (op_type == DATA_SOFT_OUTPUT))
1185 : 0 : && ((seg->length + RTE_PKTMBUF_HEADROOM)
1186 : : > RTE_BBDEV_LDPC_E_MAX_MBUF)) {
1187 : : /* Allocate a fake overused mbuf + margin */
1188 : 0 : data = rte_malloc(NULL, seg->length + 1024, 0);
1189 : 0 : TEST_ASSERT_NOT_NULL(data,
1190 : : "rte malloc failed with %u bytes",
1191 : : seg->length + 1024);
1192 : 0 : m_head->buf_addr = data;
1193 : 0 : rte_mbuf_iova_set(m_head, rte_malloc_virt2iova(data));
1194 : 0 : m_head->data_off = 0;
1195 : 0 : m_head->data_len = seg->length;
1196 : : } else {
1197 : : /* allocate chained-mbuf for output buffer */
1198 : 0 : for (j = 1; j < ref_entries->nb_segments; ++j) {
1199 : : struct rte_mbuf *m_tail =
1200 : 0 : rte_pktmbuf_alloc(mbuf_pool);
1201 : 0 : TEST_ASSERT_NOT_NULL(m_tail,
1202 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1203 : : op_type,
1204 : : n * ref_entries->nb_segments,
1205 : : mbuf_pool->size);
1206 : :
1207 : : ret = rte_pktmbuf_chain(m_head, m_tail);
1208 : 0 : TEST_ASSERT_SUCCESS(ret,
1209 : : "Couldn't chain mbufs from %d data type mbuf pool",
1210 : : op_type);
1211 : : }
1212 : : }
1213 : 0 : bufs[i].length += seg->length;
1214 : : }
1215 : : }
1216 : :
1217 : : return 0;
1218 : : }
1219 : :
1220 : : static int
1221 : 0 : allocate_buffers_on_socket(struct rte_bbdev_op_data **buffers, const int len,
1222 : : const int socket)
1223 : : {
1224 : : int i;
1225 : :
1226 : 0 : *buffers = rte_zmalloc_socket(NULL, len, 0, socket);
1227 : 0 : if (*buffers == NULL) {
1228 : : printf("WARNING: Failed to allocate op_data on socket %d\n",
1229 : : socket);
1230 : : /* try to allocate memory on other detected sockets */
1231 : 0 : for (i = 0; i < socket; i++) {
1232 : 0 : *buffers = rte_zmalloc_socket(NULL, len, 0, i);
1233 : 0 : if (*buffers != NULL)
1234 : : break;
1235 : : }
1236 : : }
1237 : :
1238 : 0 : return (*buffers == NULL) ? TEST_FAILED : TEST_SUCCESS;
1239 : : }
1240 : :
1241 : : static void
1242 : 0 : limit_input_llr_val_range(struct rte_bbdev_op_data *input_ops,
1243 : : const uint16_t n, const int8_t max_llr_modulus)
1244 : : {
1245 : : uint16_t i, byte_idx;
1246 : :
1247 : 0 : for (i = 0; i < n; ++i) {
1248 : 0 : struct rte_mbuf *m = input_ops[i].data;
1249 : 0 : while (m != NULL) {
1250 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1251 : : input_ops[i].offset);
1252 : 0 : for (byte_idx = 0; byte_idx < rte_pktmbuf_data_len(m);
1253 : 0 : ++byte_idx)
1254 : 0 : llr[byte_idx] = round((double)max_llr_modulus *
1255 : 0 : llr[byte_idx] / INT8_MAX);
1256 : :
1257 : 0 : m = m->next;
1258 : : }
1259 : : }
1260 : 0 : }
1261 : :
1262 : : /*
1263 : : * We may have to insert filler bits
1264 : : * when they are required by the HARQ assumption
1265 : : */
1266 : : static void
1267 : 0 : ldpc_add_filler(struct rte_bbdev_op_data *input_ops,
1268 : : const uint16_t n, struct test_op_params *op_params)
1269 : : {
1270 : 0 : struct rte_bbdev_op_ldpc_dec dec = op_params->ref_dec_op->ldpc_dec;
1271 : :
1272 : 0 : if (input_ops == NULL)
1273 : : return;
1274 : : /* No need to add filler if not required by device */
1275 : 0 : if (!(ldpc_cap_flags &
1276 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS))
1277 : : return;
1278 : : /* No need to add filler for loopback operation */
1279 : 0 : if (dec.op_flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
1280 : : return;
1281 : :
1282 : : uint16_t i, j, parity_offset;
1283 : 0 : for (i = 0; i < n; ++i) {
1284 : 0 : struct rte_mbuf *m = input_ops[i].data;
1285 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1286 : : input_ops[i].offset);
1287 : 0 : parity_offset = (dec.basegraph == 1 ? 20 : 8)
1288 : 0 : * dec.z_c - dec.n_filler;
1289 : 0 : uint16_t new_hin_size = input_ops[i].length + dec.n_filler;
1290 : 0 : m->data_len = new_hin_size;
1291 : 0 : input_ops[i].length = new_hin_size;
1292 : 0 : for (j = new_hin_size - 1; j >= parity_offset + dec.n_filler;
1293 : 0 : j--)
1294 : 0 : llr[j] = llr[j - dec.n_filler];
1295 : 0 : uint16_t llr_max_pre_scaling = (1 << (ldpc_llr_size - 1)) - 1;
1296 : 0 : for (j = 0; j < dec.n_filler; j++)
1297 : 0 : llr[parity_offset + j] = llr_max_pre_scaling;
1298 : : }
1299 : : }
1300 : :
1301 : : static void
1302 : 0 : ldpc_input_llr_scaling(struct rte_bbdev_op_data *input_ops,
1303 : : const uint16_t n, const int8_t llr_size,
1304 : : const int8_t llr_decimals)
1305 : : {
1306 : 0 : if (input_ops == NULL)
1307 : : return;
1308 : :
1309 : : uint16_t i, byte_idx;
1310 : :
1311 : : int16_t llr_max, llr_min, llr_tmp;
1312 : 0 : llr_max = (1 << (llr_size - 1)) - 1;
1313 : 0 : llr_min = -llr_max;
1314 : 0 : for (i = 0; i < n; ++i) {
1315 : 0 : struct rte_mbuf *m = input_ops[i].data;
1316 : 0 : while (m != NULL) {
1317 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1318 : : input_ops[i].offset);
1319 : 0 : for (byte_idx = 0; byte_idx < rte_pktmbuf_data_len(m);
1320 : 0 : ++byte_idx) {
1321 : :
1322 : 0 : llr_tmp = llr[byte_idx];
1323 : 0 : if (llr_decimals == 4)
1324 : 0 : llr_tmp *= 8;
1325 : 0 : else if (llr_decimals == 2)
1326 : 0 : llr_tmp *= 2;
1327 : 0 : else if (llr_decimals == 0)
1328 : 0 : llr_tmp /= 2;
1329 : 0 : llr_tmp = RTE_MIN(llr_max,
1330 : : RTE_MAX(llr_min, llr_tmp));
1331 : 0 : llr[byte_idx] = (int8_t) llr_tmp;
1332 : : }
1333 : :
1334 : 0 : m = m->next;
1335 : : }
1336 : : }
1337 : : }
1338 : :
1339 : :
1340 : :
1341 : : static int
1342 : 0 : fill_queue_buffers(struct test_op_params *op_params,
1343 : : struct rte_mempool *in_mp, struct rte_mempool *hard_out_mp,
1344 : : struct rte_mempool *soft_out_mp,
1345 : : struct rte_mempool *harq_in_mp, struct rte_mempool *harq_out_mp,
1346 : : uint16_t queue_id,
1347 : : const struct rte_bbdev_op_cap *capabilities,
1348 : : uint16_t min_alignment, const int socket_id)
1349 : : {
1350 : : int ret;
1351 : : enum op_data_type type;
1352 : 0 : const uint16_t n = op_params->num_to_process;
1353 : :
1354 : 0 : struct rte_mempool *mbuf_pools[DATA_NUM_TYPES] = {
1355 : : in_mp,
1356 : : soft_out_mp,
1357 : : hard_out_mp,
1358 : : harq_in_mp,
1359 : : harq_out_mp,
1360 : : };
1361 : :
1362 : 0 : struct rte_bbdev_op_data **queue_ops[DATA_NUM_TYPES] = {
1363 : 0 : &op_params->q_bufs[socket_id][queue_id].inputs,
1364 : 0 : &op_params->q_bufs[socket_id][queue_id].soft_outputs,
1365 : 0 : &op_params->q_bufs[socket_id][queue_id].hard_outputs,
1366 : 0 : &op_params->q_bufs[socket_id][queue_id].harq_inputs,
1367 : 0 : &op_params->q_bufs[socket_id][queue_id].harq_outputs,
1368 : : };
1369 : :
1370 : 0 : for (type = DATA_INPUT; type < DATA_NUM_TYPES; ++type) {
1371 : 0 : struct op_data_entries *ref_entries =
1372 : : &test_vector.entries[type];
1373 : 0 : if (ref_entries->nb_segments == 0)
1374 : 0 : continue;
1375 : :
1376 : 0 : ret = allocate_buffers_on_socket(queue_ops[type],
1377 : 0 : n * sizeof(struct rte_bbdev_op_data),
1378 : : socket_id);
1379 : 0 : TEST_ASSERT_SUCCESS(ret,
1380 : : "Couldn't allocate memory for rte_bbdev_op_data structs");
1381 : :
1382 : 0 : ret = init_op_data_objs(*queue_ops[type], ref_entries,
1383 : : mbuf_pools[type], n, type, min_alignment);
1384 : 0 : TEST_ASSERT_SUCCESS(ret,
1385 : : "Couldn't init rte_bbdev_op_data structs");
1386 : : }
1387 : :
1388 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
1389 : 0 : limit_input_llr_val_range(*queue_ops[DATA_INPUT], n,
1390 : 0 : capabilities->cap.turbo_dec.max_llr_modulus);
1391 : :
1392 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) {
1393 : 0 : bool loopback = op_params->ref_dec_op->ldpc_dec.op_flags &
1394 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK;
1395 : 0 : bool llr_comp = op_params->ref_dec_op->ldpc_dec.op_flags &
1396 : : RTE_BBDEV_LDPC_LLR_COMPRESSION;
1397 : 0 : bool harq_comp = op_params->ref_dec_op->ldpc_dec.op_flags &
1398 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
1399 : :
1400 : 0 : ldpc_llr_decimals = capabilities->cap.ldpc_dec.llr_decimals;
1401 : 0 : ldpc_llr_size = capabilities->cap.ldpc_dec.llr_size;
1402 : 0 : ldpc_cap_flags = capabilities->cap.ldpc_dec.capability_flags;
1403 : 0 : if (!loopback && !llr_comp)
1404 : 0 : ldpc_input_llr_scaling(*queue_ops[DATA_INPUT], n,
1405 : : ldpc_llr_size, ldpc_llr_decimals);
1406 : 0 : if (!loopback && !harq_comp)
1407 : 0 : ldpc_input_llr_scaling(*queue_ops[DATA_HARQ_INPUT], n,
1408 : : ldpc_llr_size, ldpc_llr_decimals);
1409 : 0 : if (!loopback)
1410 : 0 : ldpc_add_filler(*queue_ops[DATA_HARQ_INPUT], n,
1411 : : op_params);
1412 : : }
1413 : :
1414 : : return 0;
1415 : : }
1416 : :
1417 : : static void
1418 : 0 : free_buffers(struct active_device *ad, struct test_op_params *op_params)
1419 : : {
1420 : : unsigned int i, j;
1421 : :
1422 : 0 : rte_mempool_free(ad->ops_mempool);
1423 : 0 : rte_mempool_free(ad->in_mbuf_pool);
1424 : 0 : rte_mempool_free(ad->hard_out_mbuf_pool);
1425 : 0 : rte_mempool_free(ad->soft_out_mbuf_pool);
1426 : 0 : rte_mempool_free(ad->harq_in_mbuf_pool);
1427 : 0 : rte_mempool_free(ad->harq_out_mbuf_pool);
1428 : :
1429 : 0 : for (i = 0; i < rte_lcore_count(); ++i) {
1430 : 0 : for (j = 0; j < RTE_MAX_NUMA_NODES; ++j) {
1431 : 0 : rte_free(op_params->q_bufs[j][i].inputs);
1432 : 0 : rte_free(op_params->q_bufs[j][i].hard_outputs);
1433 : 0 : rte_free(op_params->q_bufs[j][i].soft_outputs);
1434 : 0 : rte_free(op_params->q_bufs[j][i].harq_inputs);
1435 : 0 : rte_free(op_params->q_bufs[j][i].harq_outputs);
1436 : : }
1437 : : }
1438 : 0 : }
1439 : :
1440 : : static void
1441 : 0 : copy_reference_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
1442 : : unsigned int start_idx,
1443 : : struct rte_bbdev_op_data *inputs,
1444 : : struct rte_bbdev_op_data *hard_outputs,
1445 : : struct rte_bbdev_op_data *soft_outputs,
1446 : : struct rte_bbdev_dec_op *ref_op)
1447 : : {
1448 : : unsigned int i;
1449 : : struct rte_bbdev_op_turbo_dec *turbo_dec = &ref_op->turbo_dec;
1450 : :
1451 : 0 : for (i = 0; i < n; ++i) {
1452 : 0 : if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1453 : 0 : ops[i]->turbo_dec.tb_params.ea =
1454 : 0 : turbo_dec->tb_params.ea;
1455 : 0 : ops[i]->turbo_dec.tb_params.eb =
1456 : 0 : turbo_dec->tb_params.eb;
1457 : 0 : ops[i]->turbo_dec.tb_params.k_pos =
1458 : 0 : turbo_dec->tb_params.k_pos;
1459 : 0 : ops[i]->turbo_dec.tb_params.k_neg =
1460 : 0 : turbo_dec->tb_params.k_neg;
1461 : 0 : ops[i]->turbo_dec.tb_params.c =
1462 : 0 : turbo_dec->tb_params.c;
1463 : 0 : ops[i]->turbo_dec.tb_params.c_neg =
1464 : 0 : turbo_dec->tb_params.c_neg;
1465 : 0 : ops[i]->turbo_dec.tb_params.cab =
1466 : 0 : turbo_dec->tb_params.cab;
1467 : 0 : ops[i]->turbo_dec.tb_params.r =
1468 : 0 : turbo_dec->tb_params.r;
1469 : : } else {
1470 : 0 : ops[i]->turbo_dec.cb_params.e = turbo_dec->cb_params.e;
1471 : 0 : ops[i]->turbo_dec.cb_params.k = turbo_dec->cb_params.k;
1472 : : }
1473 : :
1474 : 0 : ops[i]->turbo_dec.ext_scale = turbo_dec->ext_scale;
1475 : 0 : ops[i]->turbo_dec.iter_max = turbo_dec->iter_max;
1476 : 0 : ops[i]->turbo_dec.iter_min = turbo_dec->iter_min;
1477 : 0 : ops[i]->turbo_dec.op_flags = turbo_dec->op_flags;
1478 : 0 : ops[i]->turbo_dec.rv_index = turbo_dec->rv_index;
1479 : 0 : ops[i]->turbo_dec.num_maps = turbo_dec->num_maps;
1480 : 0 : ops[i]->turbo_dec.code_block_mode = turbo_dec->code_block_mode;
1481 : :
1482 : 0 : ops[i]->turbo_dec.hard_output = hard_outputs[start_idx + i];
1483 : 0 : ops[i]->turbo_dec.input = inputs[start_idx + i];
1484 : 0 : if (soft_outputs != NULL)
1485 : 0 : ops[i]->turbo_dec.soft_output =
1486 : 0 : soft_outputs[start_idx + i];
1487 : : }
1488 : 0 : }
1489 : :
1490 : : static void
1491 : 0 : copy_reference_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
1492 : : unsigned int start_idx,
1493 : : struct rte_bbdev_op_data *inputs,
1494 : : struct rte_bbdev_op_data *outputs,
1495 : : struct rte_bbdev_enc_op *ref_op)
1496 : : {
1497 : : unsigned int i;
1498 : : struct rte_bbdev_op_turbo_enc *turbo_enc = &ref_op->turbo_enc;
1499 : 0 : for (i = 0; i < n; ++i) {
1500 : 0 : if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1501 : 0 : ops[i]->turbo_enc.tb_params.ea =
1502 : 0 : turbo_enc->tb_params.ea;
1503 : 0 : ops[i]->turbo_enc.tb_params.eb =
1504 : 0 : turbo_enc->tb_params.eb;
1505 : 0 : ops[i]->turbo_enc.tb_params.k_pos =
1506 : 0 : turbo_enc->tb_params.k_pos;
1507 : 0 : ops[i]->turbo_enc.tb_params.k_neg =
1508 : 0 : turbo_enc->tb_params.k_neg;
1509 : 0 : ops[i]->turbo_enc.tb_params.c =
1510 : 0 : turbo_enc->tb_params.c;
1511 : 0 : ops[i]->turbo_enc.tb_params.c_neg =
1512 : 0 : turbo_enc->tb_params.c_neg;
1513 : 0 : ops[i]->turbo_enc.tb_params.cab =
1514 : 0 : turbo_enc->tb_params.cab;
1515 : 0 : ops[i]->turbo_enc.tb_params.ncb_pos =
1516 : 0 : turbo_enc->tb_params.ncb_pos;
1517 : 0 : ops[i]->turbo_enc.tb_params.ncb_neg =
1518 : 0 : turbo_enc->tb_params.ncb_neg;
1519 : 0 : ops[i]->turbo_enc.tb_params.r = turbo_enc->tb_params.r;
1520 : : } else {
1521 : 0 : ops[i]->turbo_enc.cb_params.e = turbo_enc->cb_params.e;
1522 : 0 : ops[i]->turbo_enc.cb_params.k = turbo_enc->cb_params.k;
1523 : 0 : ops[i]->turbo_enc.cb_params.ncb =
1524 : 0 : turbo_enc->cb_params.ncb;
1525 : : }
1526 : 0 : ops[i]->turbo_enc.rv_index = turbo_enc->rv_index;
1527 : 0 : ops[i]->turbo_enc.op_flags = turbo_enc->op_flags;
1528 : 0 : ops[i]->turbo_enc.code_block_mode = turbo_enc->code_block_mode;
1529 : :
1530 : 0 : ops[i]->turbo_enc.output = outputs[start_idx + i];
1531 : 0 : ops[i]->turbo_enc.input = inputs[start_idx + i];
1532 : : }
1533 : 0 : }
1534 : :
1535 : :
1536 : : /* Returns a random number drawn from a normal distribution
1537 : : * with mean of 0 and variance of 1
1538 : : * Marsaglia algorithm
1539 : : */
1540 : : static double
1541 : 0 : randn(int n)
1542 : : {
1543 : : double S, Z, U1, U2, u, v, fac;
1544 : :
1545 : : do {
1546 : 0 : U1 = (double)rand() / RAND_MAX;
1547 : 0 : U2 = (double)rand() / RAND_MAX;
1548 : 0 : u = 2. * U1 - 1.;
1549 : 0 : v = 2. * U2 - 1.;
1550 : 0 : S = u * u + v * v;
1551 : 0 : } while (S >= 1 || S == 0);
1552 : 0 : fac = sqrt(-2. * log(S) / S);
1553 : 0 : Z = (n % 2) ? u * fac : v * fac;
1554 : 0 : return Z;
1555 : : }
1556 : :
1557 : : static inline double
1558 : 0 : maxstar(double A, double B)
1559 : : {
1560 : 0 : if (fabs(A - B) > 5)
1561 : 0 : return RTE_MAX(A, B);
1562 : : else
1563 : 0 : return RTE_MAX(A, B) + log1p(exp(-fabs(A - B)));
1564 : : }
1565 : :
1566 : : /*
1567 : : * Generate Qm LLRS for Qm==8
1568 : : * Modulation, AWGN and LLR estimation from max log development
1569 : : */
1570 : : static void
1571 : 0 : gen_qm8_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1572 : : {
1573 : : #define QM 8
1574 : : #define QAM 256
1575 : :
1576 : : int m, k;
1577 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1578 : : /* 5.1.4 of TS38.211 */
1579 : 0 : const double symbols_I[QAM] = {
1580 : : 5, 5, 7, 7, 5, 5, 7, 7, 3, 3, 1, 1, 3, 3, 1, 1, 5,
1581 : : 5, 7, 7, 5, 5, 7, 7, 3, 3, 1, 1, 3, 3, 1, 1, 11,
1582 : : 11, 9, 9, 11, 11, 9, 9, 13, 13, 15, 15, 13, 13,
1583 : : 15, 15, 11, 11, 9, 9, 11, 11, 9, 9, 13, 13, 15,
1584 : : 15, 13, 13, 15, 15, 5, 5, 7, 7, 5, 5, 7, 7, 3, 3,
1585 : : 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7, 3, 3, 1,
1586 : : 1, 3, 3, 1, 1, 11, 11, 9, 9, 11, 11, 9, 9, 13, 13,
1587 : : 15, 15, 13, 13, 15, 15, 11, 11, 9, 9, 11, 11, 9, 9,
1588 : : 13, 13, 15, 15, 13, 13, 15, 15, -5, -5, -7, -7, -5,
1589 : : -5, -7, -7, -3, -3, -1, -1, -3, -3, -1, -1, -5, -5,
1590 : : -7, -7, -5, -5, -7, -7, -3, -3, -1, -1, -3, -3,
1591 : : -1, -1, -11, -11, -9, -9, -11, -11, -9, -9, -13,
1592 : : -13, -15, -15, -13, -13, -15, -15, -11, -11, -9,
1593 : : -9, -11, -11, -9, -9, -13, -13, -15, -15, -13,
1594 : : -13, -15, -15, -5, -5, -7, -7, -5, -5, -7, -7, -3,
1595 : : -3, -1, -1, -3, -3, -1, -1, -5, -5, -7, -7, -5, -5,
1596 : : -7, -7, -3, -3, -1, -1, -3, -3, -1, -1, -11, -11,
1597 : : -9, -9, -11, -11, -9, -9, -13, -13, -15, -15, -13,
1598 : : -13, -15, -15, -11, -11, -9, -9, -11, -11, -9, -9,
1599 : : -13, -13, -15, -15, -13, -13, -15, -15};
1600 : 0 : const double symbols_Q[QAM] = {
1601 : : 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 11,
1602 : : 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13, 15, 13,
1603 : : 15, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1,
1604 : : 11, 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13,
1605 : : 15, 13, 15, -5, -7, -5, -7, -3, -1, -3, -1, -5,
1606 : : -7, -5, -7, -3, -1, -3, -1, -11, -9, -11, -9, -13,
1607 : : -15, -13, -15, -11, -9, -11, -9, -13, -15, -13,
1608 : : -15, -5, -7, -5, -7, -3, -1, -3, -1, -5, -7, -5,
1609 : : -7, -3, -1, -3, -1, -11, -9, -11, -9, -13, -15,
1610 : : -13, -15, -11, -9, -11, -9, -13, -15, -13, -15, 5,
1611 : : 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 11,
1612 : : 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13, 15,
1613 : : 13, 15, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1,
1614 : : 3, 1, 11, 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9,
1615 : : 13, 15, 13, 15, -5, -7, -5, -7, -3, -1, -3, -1,
1616 : : -5, -7, -5, -7, -3, -1, -3, -1, -11, -9, -11, -9,
1617 : : -13, -15, -13, -15, -11, -9, -11, -9, -13, -15,
1618 : : -13, -15, -5, -7, -5, -7, -3, -1, -3, -1, -5, -7,
1619 : : -5, -7, -3, -1, -3, -1, -11, -9, -11, -9, -13, -15,
1620 : : -13, -15, -11, -9, -11, -9, -13, -15, -13, -15};
1621 : : /* Average constellation point energy */
1622 : 0 : N0 *= 170.0;
1623 : 0 : for (k = 0; k < QM; k++)
1624 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1625 : : /* 5.1.4 of TS38.211 */
1626 : 0 : I = (1 - 2 * b[0]) * (8 - (1 - 2 * b[2]) *
1627 : 0 : (4 - (1 - 2 * b[4]) * (2 - (1 - 2 * b[6]))));
1628 : 0 : Q = (1 - 2 * b[1]) * (8 - (1 - 2 * b[3]) *
1629 : 0 : (4 - (1 - 2 * b[5]) * (2 - (1 - 2 * b[7]))));
1630 : : /* AWGN channel */
1631 : 0 : I += sqrt(N0 / 2) * randn(0);
1632 : 0 : Q += sqrt(N0 / 2) * randn(1);
1633 : : /*
1634 : : * Calculate the log of the probability that each of
1635 : : * the constellation points was transmitted
1636 : : */
1637 : 0 : for (m = 0; m < QAM; m++)
1638 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1639 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1640 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1641 : 0 : for (k = 0; k < QM; k++) {
1642 : : p0 = -999999;
1643 : : p1 = -999999;
1644 : : /* For each constellation point */
1645 : 0 : for (m = 0; m < QAM; m++) {
1646 : 0 : if ((m >> (QM - k - 1)) & 1)
1647 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1648 : : else
1649 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1650 : : }
1651 : : /* Calculate the LLR */
1652 : 0 : llr_ = p0 - p1;
1653 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1654 : 0 : llr_ = round(llr_);
1655 : 0 : if (llr_ > llr_max)
1656 : : llr_ = llr_max;
1657 : 0 : if (llr_ < -llr_max)
1658 : : llr_ = -llr_max;
1659 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1660 : : }
1661 : : #undef QM
1662 : : #undef QAM
1663 : 0 : }
1664 : :
1665 : :
1666 : : /*
1667 : : * Generate Qm LLRS for Qm==6
1668 : : * Modulation, AWGN and LLR estimation from max log development
1669 : : */
1670 : : static void
1671 : 0 : gen_qm6_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1672 : : {
1673 : : #define QM 6
1674 : : #define QAM 64
1675 : :
1676 : : int m, k;
1677 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1678 : : /* 5.1.4 of TS38.211 */
1679 : 0 : const double symbols_I[QAM] = {
1680 : : 3, 3, 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7,
1681 : : 3, 3, 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7,
1682 : : -3, -3, -1, -1, -3, -3, -1, -1, -5, -5, -7, -7,
1683 : : -5, -5, -7, -7, -3, -3, -1, -1, -3, -3, -1, -1,
1684 : : -5, -5, -7, -7, -5, -5, -7, -7};
1685 : 0 : const double symbols_Q[QAM] = {
1686 : : 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7,
1687 : : -3, -1, -3, -1, -5, -7, -5, -7, -3, -1, -3, -1,
1688 : : -5, -7, -5, -7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1,
1689 : : 5, 7, 5, 7, -3, -1, -3, -1, -5, -7, -5, -7,
1690 : : -3, -1, -3, -1, -5, -7, -5, -7};
1691 : : /* Average constellation point energy */
1692 : 0 : N0 *= 42.0;
1693 : 0 : for (k = 0; k < QM; k++)
1694 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1695 : : /* 5.1.4 of TS38.211 */
1696 : 0 : I = (1 - 2 * b[0])*(4 - (1 - 2 * b[2]) * (2 - (1 - 2 * b[4])));
1697 : 0 : Q = (1 - 2 * b[1])*(4 - (1 - 2 * b[3]) * (2 - (1 - 2 * b[5])));
1698 : : /* AWGN channel */
1699 : 0 : I += sqrt(N0 / 2) * randn(0);
1700 : 0 : Q += sqrt(N0 / 2) * randn(1);
1701 : : /*
1702 : : * Calculate the log of the probability that each of
1703 : : * the constellation points was transmitted
1704 : : */
1705 : 0 : for (m = 0; m < QAM; m++)
1706 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1707 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1708 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1709 : 0 : for (k = 0; k < QM; k++) {
1710 : : p0 = -999999;
1711 : : p1 = -999999;
1712 : : /* For each constellation point */
1713 : 0 : for (m = 0; m < QAM; m++) {
1714 : 0 : if ((m >> (QM - k - 1)) & 1)
1715 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1716 : : else
1717 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1718 : : }
1719 : : /* Calculate the LLR */
1720 : 0 : llr_ = p0 - p1;
1721 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1722 : 0 : llr_ = round(llr_);
1723 : 0 : if (llr_ > llr_max)
1724 : : llr_ = llr_max;
1725 : 0 : if (llr_ < -llr_max)
1726 : : llr_ = -llr_max;
1727 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1728 : : }
1729 : : #undef QM
1730 : : #undef QAM
1731 : 0 : }
1732 : :
1733 : : /*
1734 : : * Generate Qm LLRS for Qm==4
1735 : : * Modulation, AWGN and LLR estimation from max log development
1736 : : */
1737 : : static void
1738 : 0 : gen_qm4_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1739 : : {
1740 : : #define QM 4
1741 : : #define QAM 16
1742 : :
1743 : : int m, k;
1744 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1745 : : /* 5.1.4 of TS38.211 */
1746 : 0 : const double symbols_I[QAM] = {1, 1, 3, 3, 1, 1, 3, 3,
1747 : : -1, -1, -3, -3, -1, -1, -3, -3};
1748 : 0 : const double symbols_Q[QAM] = {1, 3, 1, 3, -1, -3, -1, -3,
1749 : : 1, 3, 1, 3, -1, -3, -1, -3};
1750 : : /* Average constellation point energy */
1751 : 0 : N0 *= 10.0;
1752 : 0 : for (k = 0; k < QM; k++)
1753 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1754 : : /* 5.1.4 of TS38.211 */
1755 : 0 : I = (1 - 2 * b[0]) * (2 - (1 - 2 * b[2]));
1756 : 0 : Q = (1 - 2 * b[1]) * (2 - (1 - 2 * b[3]));
1757 : : /* AWGN channel */
1758 : 0 : I += sqrt(N0 / 2) * randn(0);
1759 : 0 : Q += sqrt(N0 / 2) * randn(1);
1760 : : /*
1761 : : * Calculate the log of the probability that each of
1762 : : * the constellation points was transmitted
1763 : : */
1764 : 0 : for (m = 0; m < QAM; m++)
1765 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1766 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1767 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1768 : 0 : for (k = 0; k < QM; k++) {
1769 : : p0 = -999999;
1770 : : p1 = -999999;
1771 : : /* For each constellation point */
1772 : 0 : for (m = 0; m < QAM; m++) {
1773 : 0 : if ((m >> (QM - k - 1)) & 1)
1774 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1775 : : else
1776 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1777 : : }
1778 : : /* Calculate the LLR */
1779 : 0 : llr_ = p0 - p1;
1780 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1781 : 0 : llr_ = round(llr_);
1782 : 0 : if (llr_ > llr_max)
1783 : : llr_ = llr_max;
1784 : 0 : if (llr_ < -llr_max)
1785 : : llr_ = -llr_max;
1786 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1787 : : }
1788 : : #undef QM
1789 : : #undef QAM
1790 : 0 : }
1791 : :
1792 : : static void
1793 : 0 : gen_qm2_llr(int8_t *llrs, uint32_t j, double N0, double llr_max)
1794 : : {
1795 : : double b, b1, n;
1796 : 0 : double coeff = 2.0 * sqrt(N0);
1797 : :
1798 : : /* Ignore in vectors rare quasi null LLRs not to be saturated */
1799 : 0 : if (llrs[j] < 8 && llrs[j] > -8)
1800 : : return;
1801 : :
1802 : : /* Note don't change sign here */
1803 : 0 : n = randn(j % 2);
1804 : 0 : b1 = ((llrs[j] > 0 ? 2.0 : -2.0)
1805 : 0 : + coeff * n) / N0;
1806 : 0 : b = b1 * (1 << ldpc_llr_decimals);
1807 : 0 : b = round(b);
1808 : 0 : if (b > llr_max)
1809 : : b = llr_max;
1810 : 0 : if (b < -llr_max)
1811 : : b = -llr_max;
1812 : 0 : llrs[j] = (int8_t) b;
1813 : : }
1814 : :
1815 : : /* Simple LLR generation assuming AWGN and QPSK */
1816 : : static void
1817 : 0 : gen_turbo_llr(int8_t *llrs, uint32_t j, double N0, double llr_max)
1818 : : {
1819 : : double b, b1, n;
1820 : 0 : double coeff = 2.0 * sqrt(N0);
1821 : :
1822 : : /* Ignore in vectors null LLRs not to be saturated */
1823 : 0 : if (llrs[j] == 0)
1824 : : return;
1825 : :
1826 : : /* Note don't change sign here */
1827 : 0 : n = randn(j % 2);
1828 : 0 : b1 = ((llrs[j] > 0 ? 2.0 : -2.0)
1829 : 0 : + coeff * n) / N0;
1830 : 0 : b = b1 * (1 << 4);
1831 : 0 : b = round(b);
1832 : 0 : if (b > llr_max)
1833 : : b = llr_max;
1834 : 0 : if (b < -llr_max)
1835 : : b = -llr_max;
1836 : 0 : llrs[j] = (int8_t) b;
1837 : : }
1838 : :
1839 : : /* Generate LLR for a given SNR */
1840 : : static void
1841 : 0 : generate_llr_input(uint16_t n, struct rte_bbdev_op_data *inputs,
1842 : : struct rte_bbdev_dec_op *ref_op)
1843 : : {
1844 : : struct rte_mbuf *m;
1845 : : uint16_t qm;
1846 : : uint32_t i, j, e, range;
1847 : : double N0, llr_max;
1848 : :
1849 : 0 : e = ref_op->ldpc_dec.cb_params.e;
1850 : 0 : qm = ref_op->ldpc_dec.q_m;
1851 : 0 : llr_max = (1 << (ldpc_llr_size - 1)) - 1;
1852 : 0 : range = e / qm;
1853 : 0 : N0 = 1.0 / pow(10.0, get_snr() / 10.0);
1854 : :
1855 : 0 : for (i = 0; i < n; ++i) {
1856 : 0 : m = inputs[i].data;
1857 : 0 : int8_t *llrs = rte_pktmbuf_mtod_offset(m, int8_t *, 0);
1858 : 0 : if (qm == 8) {
1859 : 0 : for (j = 0; j < range; ++j)
1860 : 0 : gen_qm8_llr(llrs, j, N0, llr_max);
1861 : 0 : } else if (qm == 6) {
1862 : 0 : for (j = 0; j < range; ++j)
1863 : 0 : gen_qm6_llr(llrs, j, N0, llr_max);
1864 : 0 : } else if (qm == 4) {
1865 : 0 : for (j = 0; j < range; ++j)
1866 : 0 : gen_qm4_llr(llrs, j, N0, llr_max);
1867 : : } else {
1868 : 0 : for (j = 0; j < e; ++j)
1869 : 0 : gen_qm2_llr(llrs, j, N0, llr_max);
1870 : : }
1871 : : }
1872 : 0 : }
1873 : :
1874 : : /* Generate LLR for turbo decoder for a given SNR */
1875 : : static void
1876 : 0 : generate_turbo_llr_input(uint16_t n, struct rte_bbdev_op_data *inputs,
1877 : : struct rte_bbdev_dec_op *ref_op)
1878 : : {
1879 : : struct rte_mbuf *m;
1880 : : uint32_t i, j, range;
1881 : : double N0, llr_max;
1882 : :
1883 : : llr_max = 127;
1884 : 0 : range = ref_op->turbo_dec.input.length;
1885 : 0 : N0 = 1.0 / pow(10.0, get_snr() / 10.0);
1886 : :
1887 : 0 : if (range > inputs[0].data->data_len) {
1888 : 0 : printf("Warning: Limiting LLR generation to first segment (%d from %d)\n",
1889 : : inputs[0].data->data_len, range);
1890 : 0 : range = inputs[0].data->data_len;
1891 : : }
1892 : :
1893 : 0 : for (i = 0; i < n; ++i) {
1894 : 0 : m = inputs[i].data;
1895 : 0 : int8_t *llrs = rte_pktmbuf_mtod_offset(m, int8_t *, 0);
1896 : 0 : for (j = 0; j < range; ++j)
1897 : 0 : gen_turbo_llr(llrs, j, N0, llr_max);
1898 : : }
1899 : 0 : }
1900 : :
1901 : : static void
1902 : 0 : copy_reference_ldpc_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
1903 : : unsigned int start_idx,
1904 : : struct rte_bbdev_op_data *inputs,
1905 : : struct rte_bbdev_op_data *hard_outputs,
1906 : : struct rte_bbdev_op_data *soft_outputs,
1907 : : struct rte_bbdev_op_data *harq_inputs,
1908 : : struct rte_bbdev_op_data *harq_outputs,
1909 : : struct rte_bbdev_dec_op *ref_op)
1910 : : {
1911 : : unsigned int i;
1912 : : struct rte_bbdev_op_ldpc_dec *ldpc_dec = &ref_op->ldpc_dec;
1913 : :
1914 : 0 : for (i = 0; i < n; ++i) {
1915 : 0 : if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1916 : 0 : ops[i]->ldpc_dec.tb_params.ea =
1917 : 0 : ldpc_dec->tb_params.ea;
1918 : 0 : ops[i]->ldpc_dec.tb_params.eb =
1919 : 0 : ldpc_dec->tb_params.eb;
1920 : 0 : ops[i]->ldpc_dec.tb_params.c =
1921 : 0 : ldpc_dec->tb_params.c;
1922 : 0 : ops[i]->ldpc_dec.tb_params.cab =
1923 : 0 : ldpc_dec->tb_params.cab;
1924 : 0 : ops[i]->ldpc_dec.tb_params.r =
1925 : 0 : ldpc_dec->tb_params.r;
1926 : : } else {
1927 : 0 : ops[i]->ldpc_dec.cb_params.e = ldpc_dec->cb_params.e;
1928 : : }
1929 : :
1930 : 0 : ops[i]->ldpc_dec.basegraph = ldpc_dec->basegraph;
1931 : 0 : ops[i]->ldpc_dec.z_c = ldpc_dec->z_c;
1932 : 0 : ops[i]->ldpc_dec.q_m = ldpc_dec->q_m;
1933 : 0 : ops[i]->ldpc_dec.n_filler = ldpc_dec->n_filler;
1934 : 0 : ops[i]->ldpc_dec.n_cb = ldpc_dec->n_cb;
1935 : 0 : ops[i]->ldpc_dec.iter_max = ldpc_dec->iter_max;
1936 : 0 : ops[i]->ldpc_dec.rv_index = ldpc_dec->rv_index;
1937 : 0 : ops[i]->ldpc_dec.k0 = ldpc_dec->k0;
1938 : 0 : ops[i]->ldpc_dec.op_flags = ldpc_dec->op_flags;
1939 : 0 : ops[i]->ldpc_dec.code_block_mode = ldpc_dec->code_block_mode;
1940 : :
1941 : 0 : if (hard_outputs != NULL)
1942 : 0 : ops[i]->ldpc_dec.hard_output =
1943 : 0 : hard_outputs[start_idx + i];
1944 : 0 : if (inputs != NULL)
1945 : 0 : ops[i]->ldpc_dec.input =
1946 : 0 : inputs[start_idx + i];
1947 : 0 : if (soft_outputs != NULL)
1948 : 0 : ops[i]->ldpc_dec.soft_output =
1949 : 0 : soft_outputs[start_idx + i];
1950 : 0 : if (harq_inputs != NULL)
1951 : 0 : ops[i]->ldpc_dec.harq_combined_input =
1952 : 0 : harq_inputs[start_idx + i];
1953 : 0 : if (harq_outputs != NULL)
1954 : 0 : ops[i]->ldpc_dec.harq_combined_output =
1955 : 0 : harq_outputs[start_idx + i];
1956 : : }
1957 : 0 : }
1958 : :
1959 : :
1960 : : static void
1961 : 0 : copy_reference_ldpc_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
1962 : : unsigned int start_idx,
1963 : : struct rte_bbdev_op_data *inputs,
1964 : : struct rte_bbdev_op_data *outputs,
1965 : : struct rte_bbdev_enc_op *ref_op)
1966 : : {
1967 : : unsigned int i;
1968 : : struct rte_bbdev_op_ldpc_enc *ldpc_enc = &ref_op->ldpc_enc;
1969 : 0 : for (i = 0; i < n; ++i) {
1970 : 0 : if (ldpc_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1971 : 0 : ops[i]->ldpc_enc.tb_params.ea = ldpc_enc->tb_params.ea;
1972 : 0 : ops[i]->ldpc_enc.tb_params.eb = ldpc_enc->tb_params.eb;
1973 : 0 : ops[i]->ldpc_enc.tb_params.cab =
1974 : 0 : ldpc_enc->tb_params.cab;
1975 : 0 : ops[i]->ldpc_enc.tb_params.c = ldpc_enc->tb_params.c;
1976 : 0 : ops[i]->ldpc_enc.tb_params.r = ldpc_enc->tb_params.r;
1977 : : } else {
1978 : 0 : ops[i]->ldpc_enc.cb_params.e = ldpc_enc->cb_params.e;
1979 : : }
1980 : 0 : ops[i]->ldpc_enc.basegraph = ldpc_enc->basegraph;
1981 : 0 : ops[i]->ldpc_enc.z_c = ldpc_enc->z_c;
1982 : 0 : ops[i]->ldpc_enc.q_m = ldpc_enc->q_m;
1983 : 0 : ops[i]->ldpc_enc.n_filler = ldpc_enc->n_filler;
1984 : 0 : ops[i]->ldpc_enc.n_cb = ldpc_enc->n_cb;
1985 : 0 : ops[i]->ldpc_enc.rv_index = ldpc_enc->rv_index;
1986 : 0 : ops[i]->ldpc_enc.op_flags = ldpc_enc->op_flags;
1987 : 0 : ops[i]->ldpc_enc.code_block_mode = ldpc_enc->code_block_mode;
1988 : 0 : ops[i]->ldpc_enc.output = outputs[start_idx + i];
1989 : 0 : ops[i]->ldpc_enc.input = inputs[start_idx + i];
1990 : : }
1991 : 0 : }
1992 : :
1993 : : static void
1994 : 0 : copy_reference_fft_op(struct rte_bbdev_fft_op **ops, unsigned int n,
1995 : : unsigned int start_idx, struct rte_bbdev_op_data *inputs,
1996 : : struct rte_bbdev_op_data *outputs, struct rte_bbdev_op_data *pwrouts,
1997 : : struct rte_bbdev_op_data *win_inputs, struct rte_bbdev_fft_op *ref_op)
1998 : : {
1999 : : unsigned int i, j;
2000 : : struct rte_bbdev_op_fft *fft = &ref_op->fft;
2001 : 0 : for (i = 0; i < n; i++) {
2002 : 0 : ops[i]->fft.input_sequence_size = fft->input_sequence_size;
2003 : 0 : ops[i]->fft.input_leading_padding = fft->input_leading_padding;
2004 : 0 : ops[i]->fft.output_sequence_size = fft->output_sequence_size;
2005 : 0 : ops[i]->fft.output_leading_depadding =
2006 : 0 : fft->output_leading_depadding;
2007 : 0 : for (j = 0; j < RTE_BBDEV_MAX_CS_2; j++)
2008 : 0 : ops[i]->fft.window_index[j] = fft->window_index[j];
2009 : 0 : for (j = 0; j < RTE_BBDEV_MAX_CS; j++) {
2010 : 0 : ops[i]->fft.cs_theta_0[j] = fft->cs_theta_0[j];
2011 : 0 : ops[i]->fft.cs_theta_d[j] = fft->cs_theta_d[j];
2012 : 0 : ops[i]->fft.time_offset[j] = fft->time_offset[j];
2013 : : }
2014 : 0 : ops[i]->fft.cs_bitmap = fft->cs_bitmap;
2015 : 0 : ops[i]->fft.num_antennas_log2 = fft->num_antennas_log2;
2016 : 0 : ops[i]->fft.idft_log2 = fft->idft_log2;
2017 : 0 : ops[i]->fft.dft_log2 = fft->dft_log2;
2018 : 0 : ops[i]->fft.cs_time_adjustment = fft->cs_time_adjustment;
2019 : 0 : ops[i]->fft.idft_shift = fft->idft_shift;
2020 : 0 : ops[i]->fft.dft_shift = fft->dft_shift;
2021 : 0 : ops[i]->fft.ncs_reciprocal = fft->ncs_reciprocal;
2022 : 0 : ops[i]->fft.power_shift = fft->power_shift;
2023 : 0 : ops[i]->fft.fp16_exp_adjust = fft->fp16_exp_adjust;
2024 : 0 : ops[i]->fft.output_depadded_size = fft->output_depadded_size;
2025 : 0 : ops[i]->fft.freq_resample_mode = fft->freq_resample_mode;
2026 : 0 : ops[i]->fft.base_output = outputs[start_idx + i];
2027 : 0 : ops[i]->fft.base_input = inputs[start_idx + i];
2028 : 0 : if (win_inputs != NULL)
2029 : 0 : ops[i]->fft.dewindowing_input = win_inputs[start_idx + i];
2030 : 0 : if (pwrouts != NULL)
2031 : 0 : ops[i]->fft.power_meas_output = pwrouts[start_idx + i];
2032 : 0 : ops[i]->fft.op_flags = fft->op_flags;
2033 : : }
2034 : 0 : }
2035 : :
2036 : : static void
2037 : 0 : copy_reference_mldts_op(struct rte_bbdev_mldts_op **ops, unsigned int n,
2038 : : unsigned int start_idx,
2039 : : struct rte_bbdev_op_data *q_inputs,
2040 : : struct rte_bbdev_op_data *r_inputs,
2041 : : struct rte_bbdev_op_data *outputs,
2042 : : struct rte_bbdev_mldts_op *ref_op)
2043 : : {
2044 : : unsigned int i, j;
2045 : : struct rte_bbdev_op_mldts *mldts = &ref_op->mldts;
2046 : 0 : for (i = 0; i < n; i++) {
2047 : 0 : ops[i]->mldts.c_rep = mldts->c_rep;
2048 : 0 : ops[i]->mldts.num_layers = mldts->num_layers;
2049 : 0 : ops[i]->mldts.num_rbs = mldts->num_rbs;
2050 : 0 : ops[i]->mldts.op_flags = mldts->op_flags;
2051 : 0 : for (j = 0; j < RTE_BBDEV_MAX_MLD_LAYERS; j++)
2052 : 0 : ops[i]->mldts.q_m[j] = mldts->q_m[j];
2053 : 0 : ops[i]->mldts.r_rep = mldts->r_rep;
2054 : 0 : ops[i]->mldts.c_rep = mldts->c_rep;
2055 : 0 : ops[i]->mldts.r_input = r_inputs[start_idx + i];
2056 : 0 : ops[i]->mldts.qhy_input = q_inputs[start_idx + i];
2057 : 0 : ops[i]->mldts.output = outputs[start_idx + i];
2058 : : }
2059 : 0 : }
2060 : :
2061 : : static int
2062 : 0 : check_dec_status_and_ordering(struct rte_bbdev_dec_op *op,
2063 : : unsigned int order_idx, const int expected_status)
2064 : : {
2065 : 0 : int status = op->status;
2066 : : /* ignore parity mismatch false alarms for long iterations */
2067 : 0 : if (get_iter_max() >= 10) {
2068 : 0 : if (!(expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) &&
2069 : 0 : (status & (1 << RTE_BBDEV_SYNDROME_ERROR))) {
2070 : : printf("WARNING: Ignore Syndrome Check mismatch\n");
2071 : 0 : status -= (1 << RTE_BBDEV_SYNDROME_ERROR);
2072 : : }
2073 : 0 : if ((expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) &&
2074 : 0 : !(status & (1 << RTE_BBDEV_SYNDROME_ERROR))) {
2075 : : printf("WARNING: Ignore Syndrome Check mismatch\n");
2076 : 0 : status += (1 << RTE_BBDEV_SYNDROME_ERROR);
2077 : : }
2078 : : }
2079 : :
2080 : 0 : TEST_ASSERT(status == expected_status,
2081 : : "op_status (%d) != expected_status (%d)",
2082 : : op->status, expected_status);
2083 : :
2084 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2085 : : "Ordering error, expected %p, got %p",
2086 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2087 : :
2088 : : return TEST_SUCCESS;
2089 : : }
2090 : :
2091 : : static int
2092 : 0 : check_enc_status_and_ordering(struct rte_bbdev_enc_op *op,
2093 : : unsigned int order_idx, const int expected_status)
2094 : : {
2095 : 0 : TEST_ASSERT(op->status == expected_status,
2096 : : "op_status (%d) != expected_status (%d)",
2097 : : op->status, expected_status);
2098 : :
2099 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2100 : : "Ordering error, expected %p, got %p",
2101 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2102 : :
2103 : : return TEST_SUCCESS;
2104 : : }
2105 : :
2106 : : static int
2107 : 0 : check_fft_status_and_ordering(struct rte_bbdev_fft_op *op,
2108 : : unsigned int order_idx, const int expected_status)
2109 : : {
2110 : 0 : TEST_ASSERT(op->status == expected_status,
2111 : : "op_status (%d) != expected_status (%d)",
2112 : : op->status, expected_status);
2113 : :
2114 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2115 : : "Ordering error, expected %p, got %p",
2116 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2117 : :
2118 : : return TEST_SUCCESS;
2119 : : }
2120 : :
2121 : : static int
2122 : 0 : check_mldts_status_and_ordering(struct rte_bbdev_mldts_op *op,
2123 : : unsigned int order_idx, const int expected_status)
2124 : : {
2125 : 0 : TEST_ASSERT(op->status == expected_status,
2126 : : "op_status (%d) != expected_status (%d)",
2127 : : op->status, expected_status);
2128 : :
2129 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2130 : : "Ordering error, expected %p, got %p",
2131 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2132 : :
2133 : : return TEST_SUCCESS;
2134 : : }
2135 : :
2136 : : static inline int
2137 : 0 : validate_op_chain(struct rte_bbdev_op_data *op,
2138 : : struct op_data_entries *orig_op)
2139 : : {
2140 : : uint8_t i;
2141 : 0 : struct rte_mbuf *m = op->data;
2142 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2143 : : uint32_t total_data_size = 0;
2144 : : bool ignore_mbuf = false; /* ignore mbuf limitations */
2145 : :
2146 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2147 : : "Number of segments differ in original (%u) and filled (%u) op",
2148 : : nb_dst_segments, m->nb_segs);
2149 : :
2150 : : /* Validate each mbuf segment length */
2151 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2152 : : /* Apply offset to the first mbuf segment */
2153 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2154 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2155 : 0 : total_data_size += orig_op->segments[i].length;
2156 : :
2157 : 0 : if ((orig_op->segments[i].length + RTE_PKTMBUF_HEADROOM)
2158 : : > RTE_BBDEV_LDPC_E_MAX_MBUF)
2159 : : ignore_mbuf = true;
2160 : 0 : if (!ignore_mbuf)
2161 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2162 : : "Length of segment differ in original (%u) and filled (%u) op",
2163 : : orig_op->segments[i].length, data_len);
2164 : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(orig_op->segments[i].addr,
2165 : : rte_pktmbuf_mtod_offset(m, uint32_t *, offset),
2166 : : orig_op->segments[i].length,
2167 : : "Output buffers (CB=%u) are not equal", i);
2168 : 0 : m = m->next;
2169 : : }
2170 : :
2171 : : /* Validate total mbuf pkt length */
2172 : 0 : uint32_t pkt_len = rte_pktmbuf_pkt_len(op->data) - op->offset;
2173 : 0 : if (!ignore_mbuf)
2174 : 0 : TEST_ASSERT(total_data_size == pkt_len,
2175 : : "Length of data differ in original (%u) and filled (%u) op",
2176 : : total_data_size, pkt_len);
2177 : :
2178 : : return TEST_SUCCESS;
2179 : : }
2180 : :
2181 : : /*
2182 : : * Compute K0 for a given configuration for HARQ output length computation
2183 : : * As per definition in 3GPP 38.212 Table 5.4.2.1-2
2184 : : */
2185 : : static inline uint16_t
2186 : 0 : get_k0(uint16_t n_cb, uint16_t z_c, uint8_t bg, uint8_t rv_index, uint16_t k0)
2187 : : {
2188 : 0 : if (k0 > 0)
2189 : : return k0;
2190 : 0 : if (rv_index == 0)
2191 : : return 0;
2192 : 0 : uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
2193 : 0 : if (n_cb == n) {
2194 : 0 : if (rv_index == 1)
2195 : 0 : return (bg == 1 ? K0_1_1 : K0_1_2) * z_c;
2196 : 0 : else if (rv_index == 2)
2197 : 0 : return (bg == 1 ? K0_2_1 : K0_2_2) * z_c;
2198 : : else
2199 : 0 : return (bg == 1 ? K0_3_1 : K0_3_2) * z_c;
2200 : : }
2201 : : /* LBRM case - includes a division by N */
2202 : 0 : if (rv_index == 1)
2203 : 0 : return (((bg == 1 ? K0_1_1 : K0_1_2) * n_cb)
2204 : 0 : / n) * z_c;
2205 : 0 : else if (rv_index == 2)
2206 : 0 : return (((bg == 1 ? K0_2_1 : K0_2_2) * n_cb)
2207 : 0 : / n) * z_c;
2208 : : else
2209 : 0 : return (((bg == 1 ? K0_3_1 : K0_3_2) * n_cb)
2210 : 0 : / n) * z_c;
2211 : : }
2212 : :
2213 : : /* HARQ output length including the Filler bits */
2214 : : static inline uint16_t
2215 : 0 : compute_harq_len(struct rte_bbdev_op_ldpc_dec *ops_ld)
2216 : : {
2217 : : uint16_t k0 = 0;
2218 : 0 : uint8_t max_rv = (ops_ld->rv_index == 1) ? 3 : ops_ld->rv_index;
2219 : 0 : k0 = get_k0(ops_ld->n_cb, ops_ld->z_c, ops_ld->basegraph, max_rv, ops_ld->k0);
2220 : : /* Compute RM out size and number of rows */
2221 : 0 : uint16_t parity_offset = (ops_ld->basegraph == 1 ? 20 : 8)
2222 : 0 : * ops_ld->z_c - ops_ld->n_filler;
2223 : 0 : uint16_t deRmOutSize = RTE_MIN(
2224 : : k0 + ops_ld->cb_params.e +
2225 : : ((k0 > parity_offset) ?
2226 : : 0 : ops_ld->n_filler),
2227 : : ops_ld->n_cb);
2228 : 0 : uint16_t numRows = ((deRmOutSize + ops_ld->z_c - 1)
2229 : 0 : / ops_ld->z_c);
2230 : 0 : uint16_t harq_output_len = numRows * ops_ld->z_c;
2231 : 0 : return harq_output_len;
2232 : : }
2233 : :
2234 : : static inline int
2235 : 0 : validate_op_harq_chain(struct rte_bbdev_op_data *op,
2236 : : struct op_data_entries *orig_op,
2237 : : struct rte_bbdev_op_ldpc_dec *ops_ld)
2238 : : {
2239 : : uint8_t i;
2240 : : uint32_t j, jj, k;
2241 : 0 : struct rte_mbuf *m = op->data;
2242 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2243 : : uint32_t total_data_size = 0;
2244 : : int8_t *harq_orig, *harq_out, abs_harq_origin;
2245 : : uint32_t byte_error = 0, cum_error = 0, error;
2246 : 0 : int16_t llr_max = (1 << (ldpc_llr_size - ldpc_llr_decimals)) - 1;
2247 : 0 : int16_t llr_max_pre_scaling = (1 << (ldpc_llr_size - 1)) - 1;
2248 : : uint16_t parity_offset;
2249 : :
2250 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2251 : : "Number of segments differ in original (%u) and filled (%u) op",
2252 : : nb_dst_segments, m->nb_segs);
2253 : :
2254 : : /* Validate each mbuf segment length */
2255 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2256 : : /* Apply offset to the first mbuf segment */
2257 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2258 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2259 : 0 : total_data_size += orig_op->segments[i].length;
2260 : :
2261 : 0 : TEST_ASSERT(orig_op->segments[i].length < (uint32_t)(data_len + HARQ_MEM_TOLERANCE),
2262 : : "Length of segment differ in original (%u) and filled (%u) op",
2263 : : orig_op->segments[i].length, data_len);
2264 : 0 : harq_orig = (int8_t *) orig_op->segments[i].addr;
2265 : 0 : harq_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2266 : :
2267 : : /* Cannot compare HARQ output data for such cases */
2268 : 0 : if ((ldpc_llr_decimals > 1) && ((ops_ld->op_flags & RTE_BBDEV_LDPC_LLR_COMPRESSION)
2269 : : || (ops_ld->op_flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION)
2270 : 0 : || (ops_ld->op_flags & RTE_BBDEV_LDPC_HARQ_4BIT_COMPRESSION)))
2271 : : break;
2272 : :
2273 : 0 : if (!(ldpc_cap_flags &
2274 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS
2275 : 0 : ) || (ops_ld->op_flags &
2276 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)) {
2277 : 0 : data_len -= ops_ld->z_c;
2278 : 0 : parity_offset = data_len;
2279 : : } else {
2280 : : /* Compute RM out size and number of rows */
2281 : 0 : parity_offset = (ops_ld->basegraph == 1 ? 20 : 8)
2282 : 0 : * ops_ld->z_c - ops_ld->n_filler;
2283 : 0 : uint16_t deRmOutSize = compute_harq_len(ops_ld) -
2284 : : ops_ld->n_filler;
2285 : : if (data_len > deRmOutSize)
2286 : : data_len = deRmOutSize;
2287 : : }
2288 : 0 : if (data_len > orig_op->segments[i].length)
2289 : 0 : data_len = orig_op->segments[i].length;
2290 : : /*
2291 : : * HARQ output can have minor differences
2292 : : * due to integer representation and related scaling
2293 : : */
2294 : 0 : for (j = 0, jj = 0; j < data_len; j++, jj++) {
2295 : 0 : if (j == parity_offset) {
2296 : : /* Special Handling of the filler bits */
2297 : 0 : for (k = 0; k < ops_ld->n_filler; k++) {
2298 : 0 : if (harq_out[jj] !=
2299 : : llr_max_pre_scaling) {
2300 : 0 : printf("HARQ Filler issue %d: %d %d\n",
2301 : : jj, harq_out[jj],
2302 : : llr_max);
2303 : 0 : byte_error++;
2304 : : }
2305 : 0 : jj++;
2306 : : }
2307 : : }
2308 : 0 : if (!(ops_ld->op_flags &
2309 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)) {
2310 : 0 : if (ldpc_llr_decimals > 1)
2311 : 0 : harq_out[jj] = (harq_out[jj] + 1)
2312 : 0 : >> (ldpc_llr_decimals - 1);
2313 : : /* Saturated to S7 */
2314 : 0 : if (harq_orig[j] > llr_max)
2315 : 0 : harq_orig[j] = llr_max;
2316 : 0 : if (harq_orig[j] < -llr_max)
2317 : 0 : harq_orig[j] = -llr_max;
2318 : : }
2319 : 0 : if (harq_orig[j] != harq_out[jj]) {
2320 : : error = (harq_orig[j] > harq_out[jj]) ?
2321 : 0 : harq_orig[j] - harq_out[jj] :
2322 : 0 : harq_out[jj] - harq_orig[j];
2323 : 0 : abs_harq_origin = harq_orig[j] > 0 ?
2324 : 0 : harq_orig[j] :
2325 : : -harq_orig[j];
2326 : : /* Residual quantization error */
2327 : 0 : if ((error > 8 && (abs_harq_origin <
2328 : 0 : (llr_max - 16))) ||
2329 : : (error > 16)) {
2330 : : /*
2331 : : printf("HARQ mismatch %d: exp %d act %d => %d\n",
2332 : : j, harq_orig[j],
2333 : : harq_out[jj], error);
2334 : : */
2335 : 0 : byte_error++;
2336 : 0 : cum_error += error;
2337 : : }
2338 : : }
2339 : : }
2340 : 0 : m = m->next;
2341 : : }
2342 : :
2343 : 0 : if (byte_error)
2344 : 0 : TEST_ASSERT(byte_error <= 1,
2345 : : "HARQ output mismatch (%d) %d",
2346 : : byte_error, cum_error);
2347 : :
2348 : : /* Validate total mbuf pkt length */
2349 : 0 : uint32_t pkt_len = rte_pktmbuf_pkt_len(op->data) - op->offset;
2350 : 0 : TEST_ASSERT(total_data_size < pkt_len + HARQ_MEM_TOLERANCE,
2351 : : "Length of data differ in original (%u) and filled (%u) op",
2352 : : total_data_size, pkt_len);
2353 : :
2354 : : return TEST_SUCCESS;
2355 : : }
2356 : :
2357 : :
2358 : : static inline int
2359 : 0 : validate_op_so_chain(struct rte_bbdev_op_data *op,
2360 : : struct op_data_entries *orig_op)
2361 : : {
2362 : 0 : struct rte_mbuf *m = op->data;
2363 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2364 : : uint32_t j, jj;
2365 : : int8_t *so_orig, *so_out;
2366 : : uint32_t byte_error = 0, error, margin_error = 0;
2367 : :
2368 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2369 : : "Number of segments differ in original (%u) and filled (%u) op",
2370 : : nb_dst_segments, m->nb_segs);
2371 : :
2372 : : /* Validate each mbuf segment length. */
2373 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2374 : : /* Apply offset to the first mbuf segment. */
2375 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2376 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2377 : :
2378 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2379 : : "Length of segment differ in original (%u) and filled (%u) op",
2380 : : orig_op->segments[i].length, data_len);
2381 : 0 : so_orig = (int8_t *) orig_op->segments[i].addr;
2382 : 0 : so_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2383 : 0 : margin_error += data_len / 8; /* Allow for few % errors. */
2384 : :
2385 : : /* SO output can have minor differences due to algorithm variations. */
2386 : 0 : for (j = 0, jj = 0; j < data_len; j++, jj++) {
2387 : 0 : if (so_orig[j] != so_out[jj]) {
2388 : 0 : error = (so_orig[j] > so_out[jj]) ? so_orig[j] - so_out[jj] :
2389 : 0 : so_out[jj] - so_orig[j];
2390 : : /* Residual quantization error. */
2391 : 0 : if (error > 32) {
2392 : 0 : printf("Warning: Soft mismatch %d: exp %d act %d => %d\n",
2393 : : j, so_orig[j], so_out[jj], error);
2394 : 0 : byte_error++;
2395 : : }
2396 : : }
2397 : : }
2398 : 0 : m = m->next;
2399 : : }
2400 : :
2401 : 0 : if (byte_error > margin_error)
2402 : 0 : TEST_ASSERT(byte_error <= 1, "Soft output mismatch (%d) %d",
2403 : : byte_error, margin_error);
2404 : :
2405 : : return TEST_SUCCESS;
2406 : : }
2407 : :
2408 : : static int
2409 : 0 : validate_dec_op(struct rte_bbdev_dec_op **ops, const uint16_t n,
2410 : : struct rte_bbdev_dec_op *ref_op)
2411 : : {
2412 : : unsigned int i;
2413 : : int ret;
2414 : : struct op_data_entries *hard_data_orig =
2415 : : &test_vector.entries[DATA_HARD_OUTPUT];
2416 : : struct op_data_entries *soft_data_orig =
2417 : : &test_vector.entries[DATA_SOFT_OUTPUT];
2418 : : struct rte_bbdev_op_turbo_dec *ops_td;
2419 : : struct rte_bbdev_op_data *hard_output;
2420 : : struct rte_bbdev_op_data *soft_output;
2421 : :
2422 : 0 : for (i = 0; i < n; ++i) {
2423 : 0 : ops_td = &ops[i]->turbo_dec;
2424 : 0 : hard_output = &ops_td->hard_output;
2425 : 0 : soft_output = &ops_td->soft_output;
2426 : :
2427 : 0 : ret = check_dec_status_and_ordering(ops[i], i, ref_op->status);
2428 : 0 : TEST_ASSERT_SUCCESS(ret,
2429 : : "Checking status and ordering for decoder failed");
2430 : :
2431 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(hard_output,
2432 : : hard_data_orig),
2433 : : "Hard output buffers (CB=%u) are not equal",
2434 : : i);
2435 : :
2436 : 0 : if (ref_op->turbo_dec.op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT)
2437 : 0 : TEST_ASSERT_SUCCESS(validate_op_so_chain(soft_output,
2438 : : soft_data_orig),
2439 : : "Soft output buffers (CB=%u) are not equal",
2440 : : i);
2441 : : }
2442 : :
2443 : : return TEST_SUCCESS;
2444 : : }
2445 : :
2446 : : /* Check Number of code blocks errors */
2447 : : static int
2448 : 0 : validate_ldpc_bler(struct rte_bbdev_dec_op **ops, const uint16_t n)
2449 : : {
2450 : : unsigned int i;
2451 : : struct op_data_entries *hard_data_orig =
2452 : : &test_vector.entries[DATA_HARD_OUTPUT];
2453 : : struct rte_bbdev_op_ldpc_dec *ops_td;
2454 : : struct rte_bbdev_op_data *hard_output;
2455 : : int errors = 0;
2456 : : struct rte_mbuf *m;
2457 : :
2458 : 0 : for (i = 0; i < n; ++i) {
2459 : 0 : ops_td = &ops[i]->ldpc_dec;
2460 : : hard_output = &ops_td->hard_output;
2461 : 0 : m = hard_output->data;
2462 : 0 : if (memcmp(rte_pktmbuf_mtod_offset(m, uint32_t *, 0),
2463 : 0 : hard_data_orig->segments[0].addr,
2464 : 0 : hard_data_orig->segments[0].length))
2465 : 0 : errors++;
2466 : : }
2467 : 0 : return errors;
2468 : : }
2469 : :
2470 : : /* Check Number of code blocks errors */
2471 : : static int
2472 : 0 : validate_turbo_bler(struct rte_bbdev_dec_op **ops, const uint16_t n)
2473 : : {
2474 : : unsigned int i;
2475 : : struct op_data_entries *hard_data_orig = &test_vector.entries[DATA_HARD_OUTPUT];
2476 : : struct rte_bbdev_op_turbo_dec *ops_td;
2477 : : struct rte_bbdev_op_data *hard_output;
2478 : : int errors = 0;
2479 : : struct rte_mbuf *m;
2480 : :
2481 : 0 : for (i = 0; i < n; ++i) {
2482 : 0 : ops_td = &ops[i]->turbo_dec;
2483 : : hard_output = &ops_td->hard_output;
2484 : 0 : m = hard_output->data;
2485 : 0 : if (memcmp(rte_pktmbuf_mtod_offset(m, uint32_t *, 0),
2486 : 0 : hard_data_orig->segments[0].addr,
2487 : 0 : hard_data_orig->segments[0].length))
2488 : 0 : errors++;
2489 : : }
2490 : 0 : return errors;
2491 : : }
2492 : :
2493 : :
2494 : : static int
2495 : 0 : validate_ldpc_dec_op(struct rte_bbdev_dec_op **ops, const uint16_t n,
2496 : : struct rte_bbdev_dec_op *ref_op, const int vector_mask)
2497 : : {
2498 : : unsigned int i;
2499 : : int ret;
2500 : : struct op_data_entries *hard_data_orig =
2501 : : &test_vector.entries[DATA_HARD_OUTPUT];
2502 : : struct op_data_entries *soft_data_orig =
2503 : : &test_vector.entries[DATA_SOFT_OUTPUT];
2504 : : struct op_data_entries *harq_data_orig =
2505 : : &test_vector.entries[DATA_HARQ_OUTPUT];
2506 : : struct rte_bbdev_op_ldpc_dec *ops_td;
2507 : : struct rte_bbdev_op_data *hard_output;
2508 : : struct rte_bbdev_op_data *harq_output;
2509 : : struct rte_bbdev_op_data *soft_output;
2510 : : struct rte_bbdev_op_ldpc_dec *ref_td = &ref_op->ldpc_dec;
2511 : :
2512 : 0 : for (i = 0; i < n; ++i) {
2513 : 0 : ops_td = &ops[i]->ldpc_dec;
2514 : 0 : hard_output = &ops_td->hard_output;
2515 : 0 : harq_output = &ops_td->harq_combined_output;
2516 : 0 : soft_output = &ops_td->soft_output;
2517 : :
2518 : 0 : ret = check_dec_status_and_ordering(ops[i], i, ref_op->status);
2519 : 0 : TEST_ASSERT_SUCCESS(ret,
2520 : : "Checking status and ordering for decoder failed");
2521 : 0 : if (vector_mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT)
2522 : 0 : TEST_ASSERT(ops_td->iter_count <= ref_td->iter_count,
2523 : : "Returned iter_count (%d) > expected iter_count (%d)",
2524 : : ops_td->iter_count, ref_td->iter_count);
2525 : : /*
2526 : : * We can ignore output data when the decoding failed to
2527 : : * converge or for loop-back cases
2528 : : */
2529 : 0 : if (!check_bit(ops[i]->ldpc_dec.op_flags,
2530 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK
2531 : 0 : ) && (
2532 : 0 : ops[i]->status & (1 << RTE_BBDEV_SYNDROME_ERROR
2533 : : )) == 0)
2534 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(hard_output,
2535 : : hard_data_orig),
2536 : : "Hard output buffers (CB=%u) are not equal",
2537 : : i);
2538 : :
2539 : 0 : if (ref_op->ldpc_dec.op_flags & RTE_BBDEV_LDPC_SOFT_OUT_ENABLE)
2540 : 0 : TEST_ASSERT_SUCCESS(validate_op_so_chain(soft_output,
2541 : : soft_data_orig),
2542 : : "Soft output buffers (CB=%u) are not equal",
2543 : : i);
2544 : 0 : if (ref_op->ldpc_dec.op_flags &
2545 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE) {
2546 : 0 : TEST_ASSERT_SUCCESS(validate_op_harq_chain(harq_output,
2547 : : harq_data_orig, ops_td),
2548 : : "HARQ output buffers (CB=%u) are not equal",
2549 : : i);
2550 : : }
2551 : 0 : if (ref_op->ldpc_dec.op_flags &
2552 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
2553 : 0 : TEST_ASSERT_SUCCESS(validate_op_harq_chain(harq_output,
2554 : : harq_data_orig, ops_td),
2555 : : "HARQ output buffers (CB=%u) are not equal",
2556 : : i);
2557 : :
2558 : : }
2559 : :
2560 : : return TEST_SUCCESS;
2561 : : }
2562 : :
2563 : :
2564 : : static int
2565 : 0 : validate_enc_op(struct rte_bbdev_enc_op **ops, const uint16_t n,
2566 : : struct rte_bbdev_enc_op *ref_op)
2567 : : {
2568 : : unsigned int i;
2569 : : int ret;
2570 : : struct op_data_entries *hard_data_orig =
2571 : : &test_vector.entries[DATA_HARD_OUTPUT];
2572 : :
2573 : 0 : for (i = 0; i < n; ++i) {
2574 : 0 : ret = check_enc_status_and_ordering(ops[i], i, ref_op->status);
2575 : 0 : TEST_ASSERT_SUCCESS(ret,
2576 : : "Checking status and ordering for encoder failed");
2577 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(
2578 : : &ops[i]->turbo_enc.output,
2579 : : hard_data_orig),
2580 : : "Output buffers (CB=%u) are not equal",
2581 : : i);
2582 : : }
2583 : :
2584 : : return TEST_SUCCESS;
2585 : : }
2586 : :
2587 : : static int
2588 : 0 : validate_ldpc_enc_op(struct rte_bbdev_enc_op **ops, const uint16_t n,
2589 : : struct rte_bbdev_enc_op *ref_op)
2590 : : {
2591 : : unsigned int i;
2592 : : int ret;
2593 : : struct op_data_entries *hard_data_orig =
2594 : : &test_vector.entries[DATA_HARD_OUTPUT];
2595 : :
2596 : 0 : for (i = 0; i < n; ++i) {
2597 : 0 : ret = check_enc_status_and_ordering(ops[i], i, ref_op->status);
2598 : 0 : TEST_ASSERT_SUCCESS(ret,
2599 : : "Checking status and ordering for encoder failed");
2600 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(
2601 : : &ops[i]->ldpc_enc.output,
2602 : : hard_data_orig),
2603 : : "Output buffers (CB=%u) are not equal",
2604 : : i);
2605 : : }
2606 : :
2607 : : return TEST_SUCCESS;
2608 : : }
2609 : :
2610 : : static inline int
2611 : 0 : validate_op_fft_chain(struct rte_bbdev_op_data *op, struct op_data_entries *orig_op,
2612 : : bool skip_validate_output)
2613 : : {
2614 : 0 : struct rte_mbuf *m = op->data;
2615 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2616 : : int16_t delt, abs_delt, thres_hold = 4;
2617 : : uint32_t j, data_len_iq, error_num;
2618 : : int16_t *ref_out, *op_out;
2619 : :
2620 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2621 : : "Number of segments differ in original (%u) and filled (%u) op fft",
2622 : : nb_dst_segments, m->nb_segs);
2623 : :
2624 : : /* Due to size limitation of mbuf, FFT doesn't use real mbuf. */
2625 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2626 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2627 : 0 : uint32_t data_len = op->length;
2628 : :
2629 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2630 : : "Length of segment differ in original (%u) and filled (%u) op fft",
2631 : : orig_op->segments[i].length, data_len);
2632 : : /* Divided by 2 to get the number of 16bits data. */
2633 : 0 : data_len_iq = data_len >> 1;
2634 : 0 : ref_out = (int16_t *)(orig_op->segments[i].addr);
2635 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int16_t *, offset);
2636 : : error_num = 0;
2637 : 0 : for (j = 0; j < data_len_iq; j++) {
2638 : 0 : delt = ref_out[j] - op_out[j];
2639 : 0 : abs_delt = delt > 0 ? delt : -delt;
2640 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2641 : : }
2642 : 0 : if ((error_num > 0) && !skip_validate_output) {
2643 : 0 : rte_memdump(stdout, "Buffer A", ref_out, data_len);
2644 : 0 : rte_memdump(stdout, "Buffer B", op_out, data_len);
2645 : 0 : TEST_ASSERT(error_num == 0,
2646 : : "FFT Output are not matched total (%u) errors (%u)",
2647 : : data_len_iq, error_num);
2648 : : }
2649 : :
2650 : 0 : m = m->next;
2651 : : }
2652 : :
2653 : : return TEST_SUCCESS;
2654 : : }
2655 : :
2656 : : static inline int
2657 : 0 : validate_op_fft_meas_chain(struct rte_bbdev_op_data *op, struct op_data_entries *orig_op,
2658 : : bool skip_validate_output)
2659 : : {
2660 : 0 : struct rte_mbuf *m = op->data;
2661 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2662 : : double thres_hold = 1.0;
2663 : : uint32_t j, data_len_iq, error_num;
2664 : : int32_t *ref_out, *op_out;
2665 : : double estSNR, refSNR, delt, abs_delt;
2666 : :
2667 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2668 : : "Number of segments differ in original (%u) and filled (%u) op fft",
2669 : : nb_dst_segments, m->nb_segs);
2670 : :
2671 : : /* Due to size limitation of mbuf, FFT doesn't use real mbuf. */
2672 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2673 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2674 : 0 : uint32_t data_len = op->length;
2675 : :
2676 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2677 : : "Length of segment differ in original (%u) and filled (%u) op fft",
2678 : : orig_op->segments[i].length, data_len);
2679 : :
2680 : : /* Divided by 4 to get the number of 32 bits data. */
2681 : 0 : data_len_iq = data_len >> 2;
2682 : 0 : ref_out = (int32_t *)(orig_op->segments[i].addr);
2683 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int32_t *, offset);
2684 : : error_num = 0;
2685 : 0 : for (j = 0; j < data_len_iq; j++) {
2686 : 0 : estSNR = 10*log10(op_out[j]);
2687 : 0 : refSNR = 10*log10(ref_out[j]);
2688 : 0 : delt = refSNR - estSNR;
2689 : 0 : abs_delt = delt > 0 ? delt : -delt;
2690 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2691 : : }
2692 : 0 : if ((error_num > 0) && !skip_validate_output) {
2693 : 0 : rte_memdump(stdout, "Buffer A", ref_out, data_len);
2694 : 0 : rte_memdump(stdout, "Buffer B", op_out, data_len);
2695 : 0 : TEST_ASSERT(error_num == 0,
2696 : : "FFT Output are not matched total (%u) errors (%u)",
2697 : : data_len_iq, error_num);
2698 : : }
2699 : :
2700 : 0 : m = m->next;
2701 : : }
2702 : :
2703 : : return TEST_SUCCESS;
2704 : : }
2705 : :
2706 : : static inline int
2707 : 0 : validate_op_mldts_chain(struct rte_bbdev_op_data *op,
2708 : : struct op_data_entries *orig_op)
2709 : : {
2710 : : uint8_t i;
2711 : 0 : struct rte_mbuf *m = op->data;
2712 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2713 : : /*the result is not bit exact*/
2714 : : int16_t thres_hold = 3;
2715 : : int16_t delt, abs_delt;
2716 : : uint32_t j, data_len_iq;
2717 : : uint32_t error_num;
2718 : : int8_t *ref_out;
2719 : : int8_t *op_out;
2720 : :
2721 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2722 : : "Number of segments differ in original (%u) and filled (%u) op mldts",
2723 : : nb_dst_segments, m->nb_segs);
2724 : :
2725 : : /* Due to size limitation of mbuf, MLDTS doesn't use real mbuf. */
2726 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2727 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2728 : 0 : uint32_t data_len = op->length;
2729 : :
2730 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2731 : : "Length of segment differ in original (%u) and filled (%u) op mldts",
2732 : : orig_op->segments[i].length, data_len);
2733 : : data_len_iq = data_len;
2734 : 0 : ref_out = (int8_t *)(orig_op->segments[i].addr);
2735 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2736 : : error_num = 0;
2737 : 0 : for (j = 0; j < data_len_iq; j++) {
2738 : :
2739 : 0 : delt = ref_out[j] - op_out[j];
2740 : 0 : abs_delt = delt > 0 ? delt : -delt;
2741 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2742 : 0 : if (error_num > 0)
2743 : 0 : printf("MLD Error %d: Exp %x %d Actual %x %d Diff %d\n",
2744 : : j, ref_out[j], ref_out[j], op_out[j], op_out[j],
2745 : : delt);
2746 : : }
2747 : 0 : TEST_ASSERT(error_num == 0,
2748 : : "MLDTS Output are not matched total (%u) errors (%u)",
2749 : : data_len_iq, error_num);
2750 : :
2751 : 0 : m = m->next;
2752 : : }
2753 : :
2754 : : return TEST_SUCCESS;
2755 : : }
2756 : :
2757 : : static int
2758 : 0 : validate_fft_op(struct rte_bbdev_fft_op **ops, const uint16_t n,
2759 : : struct rte_bbdev_fft_op *ref_op)
2760 : : {
2761 : : unsigned int i;
2762 : : int ret;
2763 : : struct op_data_entries *fft_data_orig = &test_vector.entries[DATA_HARD_OUTPUT];
2764 : : struct op_data_entries *fft_pwr_orig = &test_vector.entries[DATA_SOFT_OUTPUT];
2765 : : bool skip_validate_output = false;
2766 : :
2767 : 0 : if ((test_vector.fft_window_width_vec > 0) &&
2768 : 0 : (test_vector.fft_window_width_vec != fft_window_width_dev)) {
2769 : : printf("The vector FFT width doesn't match with device - skip %d %d\n",
2770 : : test_vector.fft_window_width_vec, fft_window_width_dev);
2771 : : skip_validate_output = true;
2772 : : }
2773 : :
2774 : 0 : for (i = 0; i < n; ++i) {
2775 : 0 : ret = check_fft_status_and_ordering(ops[i], i, ref_op->status);
2776 : 0 : TEST_ASSERT_SUCCESS(ret, "Checking status and ordering for FFT failed");
2777 : 0 : TEST_ASSERT_SUCCESS(validate_op_fft_chain(
2778 : : &ops[i]->fft.base_output, fft_data_orig, skip_validate_output),
2779 : : "FFT Output buffers (op=%u) are not matched", i);
2780 : 0 : if (check_bit(ops[i]->fft.op_flags, RTE_BBDEV_FFT_POWER_MEAS))
2781 : 0 : TEST_ASSERT_SUCCESS(validate_op_fft_meas_chain(
2782 : : &ops[i]->fft.power_meas_output, fft_pwr_orig, skip_validate_output),
2783 : : "FFT Power Output buffers (op=%u) are not matched", i);
2784 : : }
2785 : :
2786 : : return TEST_SUCCESS;
2787 : : }
2788 : :
2789 : : static int
2790 : 0 : validate_mldts_op(struct rte_bbdev_mldts_op **ops, const uint16_t n,
2791 : : struct rte_bbdev_mldts_op *ref_op)
2792 : : {
2793 : : unsigned int i;
2794 : : int ret;
2795 : : struct op_data_entries *mldts_data_orig =
2796 : : &test_vector.entries[DATA_HARD_OUTPUT];
2797 : 0 : for (i = 0; i < n; ++i) {
2798 : 0 : ret = check_mldts_status_and_ordering(ops[i], i, ref_op->status);
2799 : 0 : TEST_ASSERT_SUCCESS(ret,
2800 : : "Checking status and ordering for MLDTS failed");
2801 : 0 : TEST_ASSERT_SUCCESS(validate_op_mldts_chain(
2802 : : &ops[i]->mldts.output,
2803 : : mldts_data_orig),
2804 : : "MLDTS Output buffers (op=%u) are not matched",
2805 : : i);
2806 : : }
2807 : :
2808 : : return TEST_SUCCESS;
2809 : : }
2810 : :
2811 : : static void
2812 : : create_reference_dec_op(struct rte_bbdev_dec_op *op)
2813 : : {
2814 : : unsigned int i;
2815 : : struct op_data_entries *entry;
2816 : :
2817 : 0 : op->turbo_dec = test_vector.turbo_dec;
2818 : : entry = &test_vector.entries[DATA_INPUT];
2819 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2820 : 0 : op->turbo_dec.input.length +=
2821 : 0 : entry->segments[i].length;
2822 : : }
2823 : :
2824 : : static void
2825 : 0 : create_reference_ldpc_dec_op(struct rte_bbdev_dec_op *op)
2826 : : {
2827 : : unsigned int i;
2828 : : struct op_data_entries *entry;
2829 : :
2830 : 0 : op->ldpc_dec = test_vector.ldpc_dec;
2831 : : entry = &test_vector.entries[DATA_INPUT];
2832 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2833 : 0 : op->ldpc_dec.input.length +=
2834 : 0 : entry->segments[i].length;
2835 : 0 : if (test_vector.ldpc_dec.op_flags &
2836 : : RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) {
2837 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2838 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2839 : 0 : op->ldpc_dec.harq_combined_input.length +=
2840 : 0 : entry->segments[i].length;
2841 : : }
2842 : 0 : }
2843 : :
2844 : : static void
2845 : 0 : create_reference_fft_op(struct rte_bbdev_fft_op *op)
2846 : : {
2847 : : unsigned int i;
2848 : : struct op_data_entries *entry;
2849 : 0 : op->fft = test_vector.fft;
2850 : : entry = &test_vector.entries[DATA_INPUT];
2851 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2852 : 0 : op->fft.base_input.length += entry->segments[i].length;
2853 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2854 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2855 : 0 : op->fft.dewindowing_input.length += entry->segments[i].length;
2856 : 0 : }
2857 : :
2858 : : static void
2859 : 0 : create_reference_mldts_op(struct rte_bbdev_mldts_op *op)
2860 : : {
2861 : : unsigned int i;
2862 : : struct op_data_entries *entry;
2863 : 0 : op->mldts = test_vector.mldts;
2864 : : entry = &test_vector.entries[DATA_INPUT];
2865 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2866 : 0 : op->mldts.qhy_input.length += entry->segments[i].length;
2867 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2868 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2869 : 0 : op->mldts.r_input.length += entry->segments[i].length;
2870 : 0 : }
2871 : :
2872 : : static void
2873 : : create_reference_enc_op(struct rte_bbdev_enc_op *op)
2874 : : {
2875 : : unsigned int i;
2876 : : struct op_data_entries *entry;
2877 : :
2878 : 0 : op->turbo_enc = test_vector.turbo_enc;
2879 : : entry = &test_vector.entries[DATA_INPUT];
2880 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2881 : 0 : op->turbo_enc.input.length +=
2882 : 0 : entry->segments[i].length;
2883 : : }
2884 : :
2885 : : static void
2886 : : create_reference_ldpc_enc_op(struct rte_bbdev_enc_op *op)
2887 : : {
2888 : : unsigned int i;
2889 : : struct op_data_entries *entry;
2890 : :
2891 : 0 : op->ldpc_enc = test_vector.ldpc_enc;
2892 : : entry = &test_vector.entries[DATA_INPUT];
2893 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2894 : 0 : op->ldpc_enc.input.length +=
2895 : 0 : entry->segments[i].length;
2896 : : }
2897 : :
2898 : : static uint32_t
2899 : : calc_dec_TB_size(struct rte_bbdev_dec_op *op)
2900 : : {
2901 : : uint8_t i;
2902 : : uint32_t c, r, tb_size = 0;
2903 : :
2904 : 0 : if (op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
2905 : 0 : tb_size = op->turbo_dec.tb_params.k_neg;
2906 : : } else {
2907 : 0 : c = op->turbo_dec.tb_params.c;
2908 : 0 : r = op->turbo_dec.tb_params.r;
2909 : 0 : for (i = 0; i < c-r; i++)
2910 : 0 : tb_size += (r < op->turbo_dec.tb_params.c_neg) ?
2911 : 0 : op->turbo_dec.tb_params.k_neg :
2912 : 0 : op->turbo_dec.tb_params.k_pos;
2913 : : }
2914 : : return tb_size;
2915 : : }
2916 : :
2917 : : static uint32_t
2918 : : calc_ldpc_dec_TB_size(struct rte_bbdev_dec_op *op)
2919 : : {
2920 : : uint8_t num_cbs = 0;
2921 : : uint32_t tb_size = 0;
2922 : 0 : uint16_t sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
2923 : :
2924 : 0 : if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
2925 : : num_cbs = 1;
2926 : : else
2927 : 0 : num_cbs = op->ldpc_dec.tb_params.c - op->ldpc_dec.tb_params.r;
2928 : :
2929 : 0 : tb_size = (sys_cols * op->ldpc_dec.z_c - op->ldpc_dec.n_filler) * num_cbs;
2930 : : return tb_size;
2931 : : }
2932 : :
2933 : : static uint32_t
2934 : : calc_enc_TB_size(struct rte_bbdev_enc_op *op)
2935 : : {
2936 : : uint8_t i;
2937 : : uint32_t c, r, tb_size = 0;
2938 : :
2939 : 0 : if (op->turbo_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
2940 : 0 : tb_size = op->turbo_enc.tb_params.k_neg;
2941 : : } else {
2942 : 0 : c = op->turbo_enc.tb_params.c;
2943 : 0 : r = op->turbo_enc.tb_params.r;
2944 : 0 : for (i = 0; i < c-r; i++)
2945 : 0 : tb_size += (r < op->turbo_enc.tb_params.c_neg) ?
2946 : 0 : op->turbo_enc.tb_params.k_neg :
2947 : 0 : op->turbo_enc.tb_params.k_pos;
2948 : : }
2949 : : return tb_size;
2950 : : }
2951 : :
2952 : : static uint32_t
2953 : : calc_ldpc_enc_TB_size(struct rte_bbdev_enc_op *op)
2954 : : {
2955 : : uint8_t num_cbs = 0;
2956 : : uint32_t tb_size = 0;
2957 : 0 : uint16_t sys_cols = (op->ldpc_enc.basegraph == 1) ? 22 : 10;
2958 : :
2959 : 0 : if (op->ldpc_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK)
2960 : : num_cbs = 1;
2961 : : else
2962 : 0 : num_cbs = op->ldpc_enc.tb_params.c - op->ldpc_enc.tb_params.r;
2963 : :
2964 : 0 : tb_size = (sys_cols * op->ldpc_enc.z_c - op->ldpc_enc.n_filler) * num_cbs;
2965 : : return tb_size;
2966 : : }
2967 : :
2968 : : static uint32_t
2969 : : calc_fft_size(struct rte_bbdev_fft_op *op)
2970 : : {
2971 : : uint32_t output_size;
2972 : : int num_cs = 0, i;
2973 : 0 : for (i = 0; i < 12; i++)
2974 : 0 : if (check_bit(op->fft.cs_bitmap, 1 << i))
2975 : 0 : num_cs++;
2976 : 0 : output_size = (num_cs * op->fft.output_sequence_size * 4) << op->fft.num_antennas_log2;
2977 : : return output_size;
2978 : : }
2979 : :
2980 : : static uint32_t
2981 : : calc_mldts_size(struct rte_bbdev_mldts_op *op)
2982 : : {
2983 : : uint32_t output_size = 0;
2984 : : uint16_t i;
2985 : :
2986 : 0 : for (i = 0; i < op->mldts.num_layers; i++)
2987 : 0 : output_size += op->mldts.q_m[i];
2988 : :
2989 : 0 : output_size *= NUM_SC_PER_RB * BITS_PER_LLR * op->mldts.num_rbs * (op->mldts.c_rep + 1);
2990 : :
2991 : : return output_size;
2992 : : }
2993 : :
2994 : : static int
2995 : 0 : init_test_op_params(struct test_op_params *op_params,
2996 : : enum rte_bbdev_op_type op_type, const int expected_status,
2997 : : const int vector_mask, struct rte_mempool *ops_mp,
2998 : : uint16_t burst_sz, uint16_t num_to_process, uint16_t num_lcores)
2999 : : {
3000 : : int ret = 0;
3001 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
3002 : 0 : op_type == RTE_BBDEV_OP_LDPC_DEC)
3003 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(ops_mp,
3004 : : &op_params->ref_dec_op, 1);
3005 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
3006 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(ops_mp,
3007 : : &op_params->ref_fft_op, 1);
3008 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
3009 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(ops_mp,
3010 : : &op_params->ref_mldts_op, 1);
3011 : : else
3012 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(ops_mp,
3013 : : &op_params->ref_enc_op, 1);
3014 : :
3015 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_op_alloc_bulk() failed");
3016 : :
3017 : 0 : op_params->mp = ops_mp;
3018 : 0 : op_params->burst_sz = burst_sz;
3019 : 0 : op_params->num_to_process = num_to_process;
3020 : 0 : op_params->num_lcores = num_lcores;
3021 : 0 : op_params->vector_mask = vector_mask;
3022 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
3023 : : op_type == RTE_BBDEV_OP_LDPC_DEC)
3024 : 0 : op_params->ref_dec_op->status = expected_status;
3025 : 0 : else if (op_type == RTE_BBDEV_OP_TURBO_ENC
3026 : 0 : || op_type == RTE_BBDEV_OP_LDPC_ENC)
3027 : 0 : op_params->ref_enc_op->status = expected_status;
3028 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
3029 : 0 : op_params->ref_fft_op->status = expected_status;
3030 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
3031 : 0 : op_params->ref_mldts_op->status = expected_status;
3032 : : return 0;
3033 : : }
3034 : :
3035 : : static int
3036 : 0 : run_test_case_on_device(test_case_function *test_case_func, uint8_t dev_id,
3037 : : struct test_op_params *op_params)
3038 : : {
3039 : : int t_ret, f_ret, socket_id = SOCKET_ID_ANY;
3040 : : unsigned int i;
3041 : : struct active_device *ad;
3042 : 0 : unsigned int burst_sz = get_burst_sz();
3043 : 0 : enum rte_bbdev_op_type op_type = test_vector.op_type;
3044 : : const struct rte_bbdev_op_cap *capabilities = NULL;
3045 : :
3046 : 0 : ad = &active_devs[dev_id];
3047 : :
3048 : : /* Check if device supports op_type */
3049 : 0 : if (!is_avail_op(ad, test_vector.op_type))
3050 : : return TEST_SUCCESS;
3051 : :
3052 : : struct rte_bbdev_info info;
3053 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
3054 : 0 : socket_id = GET_SOCKET(info.socket_id);
3055 : :
3056 : 0 : f_ret = create_mempools(ad, socket_id, op_type,
3057 : 0 : get_num_ops());
3058 : 0 : if (f_ret != TEST_SUCCESS) {
3059 : : printf("Couldn't create mempools");
3060 : 0 : goto fail;
3061 : : }
3062 : : if (op_type == RTE_BBDEV_OP_NONE)
3063 : : op_type = RTE_BBDEV_OP_TURBO_ENC;
3064 : :
3065 : 0 : f_ret = init_test_op_params(op_params, test_vector.op_type,
3066 : : test_vector.expected_status,
3067 : : test_vector.mask,
3068 : : ad->ops_mempool,
3069 : : burst_sz,
3070 : 0 : get_num_ops(),
3071 : 0 : get_num_lcores());
3072 : 0 : if (f_ret != TEST_SUCCESS) {
3073 : : printf("Couldn't init test op params");
3074 : 0 : goto fail;
3075 : : }
3076 : :
3077 : :
3078 : : /* Find capabilities */
3079 : 0 : const struct rte_bbdev_op_cap *cap = info.drv.capabilities;
3080 : : do {
3081 : 0 : if (cap->type == test_vector.op_type) {
3082 : : capabilities = cap;
3083 : : break;
3084 : : }
3085 : 0 : cap++;
3086 : 0 : } while (cap->type != RTE_BBDEV_OP_NONE);
3087 : 0 : TEST_ASSERT_NOT_NULL(capabilities,
3088 : : "Couldn't find capabilities");
3089 : :
3090 : : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) {
3091 : 0 : create_reference_dec_op(op_params->ref_dec_op);
3092 : : } else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
3093 : 0 : create_reference_enc_op(op_params->ref_enc_op);
3094 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
3095 : 0 : create_reference_ldpc_enc_op(op_params->ref_enc_op);
3096 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
3097 : 0 : create_reference_ldpc_dec_op(op_params->ref_dec_op);
3098 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
3099 : 0 : create_reference_fft_op(op_params->ref_fft_op);
3100 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
3101 : 0 : create_reference_mldts_op(op_params->ref_mldts_op);
3102 : :
3103 : 0 : for (i = 0; i < ad->nb_queues; ++i) {
3104 : 0 : f_ret = fill_queue_buffers(op_params,
3105 : : ad->in_mbuf_pool,
3106 : : ad->hard_out_mbuf_pool,
3107 : : ad->soft_out_mbuf_pool,
3108 : : ad->harq_in_mbuf_pool,
3109 : : ad->harq_out_mbuf_pool,
3110 : 0 : ad->queue_ids[i],
3111 : : capabilities,
3112 : 0 : info.drv.min_alignment,
3113 : : socket_id);
3114 : 0 : if (f_ret != TEST_SUCCESS) {
3115 : : printf("Couldn't init queue buffers");
3116 : 0 : goto fail;
3117 : : }
3118 : : }
3119 : :
3120 : : /* Run test case function */
3121 : 0 : t_ret = test_case_func(ad, op_params);
3122 : :
3123 : 0 : if (dump_ops) {
3124 : : /* Dump queue information in local file. */
3125 : : static FILE *fd;
3126 : 0 : fd = fopen("./dump_bbdev_queue_ops.txt", "w");
3127 : 0 : if (fd == NULL) {
3128 : : printf("Open dump file error.\n");
3129 : 0 : return -1;
3130 : : }
3131 : 0 : rte_bbdev_queue_ops_dump(ad->dev_id, ad->queue_ids[i], fd);
3132 : 0 : fclose(fd);
3133 : : /* Run it once only. */
3134 : 0 : dump_ops = false;
3135 : : }
3136 : :
3137 : : /* Free active device resources and return */
3138 : 0 : free_buffers(ad, op_params);
3139 : 0 : return t_ret;
3140 : :
3141 : 0 : fail:
3142 : 0 : free_buffers(ad, op_params);
3143 : 0 : return TEST_FAILED;
3144 : : }
3145 : :
3146 : : /* Run given test function per active device per supported op type
3147 : : * per burst size.
3148 : : */
3149 : : static int
3150 : 0 : run_test_case(test_case_function *test_case_func)
3151 : : {
3152 : : int ret = 0;
3153 : : uint8_t dev;
3154 : :
3155 : : /* Alloc op_params */
3156 : 0 : struct test_op_params *op_params = rte_zmalloc(NULL,
3157 : : sizeof(struct test_op_params), RTE_CACHE_LINE_SIZE);
3158 : 0 : TEST_ASSERT_NOT_NULL(op_params, "Failed to alloc %zuB for op_params",
3159 : : RTE_ALIGN(sizeof(struct test_op_params),
3160 : : RTE_CACHE_LINE_SIZE));
3161 : :
3162 : : /* For each device run test case function */
3163 : 0 : for (dev = 0; dev < nb_active_devs; ++dev)
3164 : 0 : ret |= run_test_case_on_device(test_case_func, dev, op_params);
3165 : :
3166 : 0 : rte_free(op_params);
3167 : :
3168 : 0 : return ret;
3169 : : }
3170 : :
3171 : :
3172 : : /* Push back the HARQ output from DDR to host */
3173 : : static void
3174 : 0 : retrieve_harq_ddr(uint16_t dev_id, uint16_t queue_id,
3175 : : struct rte_bbdev_dec_op **ops,
3176 : : const uint16_t n)
3177 : : {
3178 : : uint16_t j;
3179 : : int save_status, ret;
3180 : 0 : uint32_t harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3181 : : struct rte_bbdev_dec_op *ops_deq[MAX_BURST];
3182 : 0 : uint32_t flags = ops[0]->ldpc_dec.op_flags;
3183 : 0 : bool loopback = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK;
3184 : 0 : bool mem_out = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3185 : 0 : bool hc_out = flags & RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE;
3186 : 0 : bool h_comp = flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3187 : 0 : for (j = 0; j < n; ++j) {
3188 : 0 : if ((loopback && mem_out) || hc_out) {
3189 : 0 : save_status = ops[j]->status;
3190 : 0 : ops[j]->ldpc_dec.op_flags =
3191 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK +
3192 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;
3193 : 0 : if (h_comp)
3194 : 0 : ops[j]->ldpc_dec.op_flags +=
3195 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3196 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset =
3197 : : harq_offset;
3198 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset = 0;
3199 : 0 : harq_offset += HARQ_INCR;
3200 : 0 : if (!loopback)
3201 : 0 : ops[j]->ldpc_dec.harq_combined_input.length =
3202 : 0 : ops[j]->ldpc_dec.harq_combined_output.length;
3203 : 0 : rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
3204 : : &ops[j], 1);
3205 : : ret = 0;
3206 : 0 : while (ret == 0)
3207 : 0 : ret = rte_bbdev_dequeue_ldpc_dec_ops(
3208 : : dev_id, queue_id,
3209 : 0 : &ops_deq[j], 1);
3210 : 0 : ops[j]->ldpc_dec.op_flags = flags;
3211 : 0 : ops[j]->status = save_status;
3212 : : }
3213 : : }
3214 : 0 : }
3215 : :
3216 : : /*
3217 : : * Push back the HARQ output from HW DDR to Host
3218 : : * Preload HARQ memory input and adjust HARQ offset
3219 : : */
3220 : : static void
3221 : 0 : preload_harq_ddr(uint16_t dev_id, uint16_t queue_id,
3222 : : struct rte_bbdev_dec_op **ops, const uint16_t n,
3223 : : bool preload)
3224 : : {
3225 : : uint16_t j;
3226 : : int deq;
3227 : 0 : uint32_t harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3228 : : struct rte_bbdev_op_data save_hc_in[MAX_OPS], save_hc_out[MAX_OPS];
3229 : : struct rte_bbdev_dec_op *ops_deq[MAX_OPS];
3230 : 0 : uint32_t flags = ops[0]->ldpc_dec.op_flags;
3231 : : bool mem_in = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;
3232 : : bool hc_in = flags & RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE;
3233 : : bool mem_out = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3234 : : bool hc_out = flags & RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE;
3235 : 0 : bool h_comp = flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3236 : 0 : if ((mem_in || hc_in) && preload) {
3237 : 0 : for (j = 0; j < n; ++j) {
3238 : 0 : save_hc_in[j] = ops[j]->ldpc_dec.harq_combined_input;
3239 : 0 : save_hc_out[j] = ops[j]->ldpc_dec.harq_combined_output;
3240 : 0 : ops[j]->ldpc_dec.op_flags =
3241 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK +
3242 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3243 : 0 : if (h_comp)
3244 : 0 : ops[j]->ldpc_dec.op_flags +=
3245 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3246 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset =
3247 : : harq_offset;
3248 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset = 0;
3249 : 0 : harq_offset += HARQ_INCR;
3250 : : }
3251 : 0 : rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id, &ops[0], n);
3252 : : deq = 0;
3253 : 0 : while (deq != n)
3254 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(
3255 : : dev_id, queue_id, &ops_deq[deq],
3256 : 0 : n - deq);
3257 : : /* Restore the operations */
3258 : 0 : for (j = 0; j < n; ++j) {
3259 : 0 : ops[j]->ldpc_dec.op_flags = flags;
3260 : 0 : ops[j]->ldpc_dec.harq_combined_input = save_hc_in[j];
3261 : 0 : ops[j]->ldpc_dec.harq_combined_output = save_hc_out[j];
3262 : : }
3263 : : }
3264 : : harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3265 : 0 : for (j = 0; j < n; ++j) {
3266 : : /* Adjust HARQ offset when we reach external DDR */
3267 : 0 : if (mem_in || hc_in)
3268 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset
3269 : 0 : = harq_offset;
3270 : 0 : if (mem_out || hc_out)
3271 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset
3272 : 0 : = harq_offset;
3273 : 0 : harq_offset += HARQ_INCR;
3274 : : }
3275 : 0 : }
3276 : :
3277 : : static void
3278 : 0 : dequeue_event_callback(uint16_t dev_id,
3279 : : enum rte_bbdev_event_type event, void *cb_arg,
3280 : : void *ret_param)
3281 : : {
3282 : : int ret;
3283 : : uint16_t i;
3284 : : uint64_t total_time;
3285 : : uint16_t deq, burst_sz, num_ops;
3286 : 0 : uint16_t queue_id = *(uint16_t *) ret_param;
3287 : : struct rte_bbdev_info info;
3288 : : double tb_len_bits;
3289 : : struct thread_params *tp = cb_arg;
3290 : :
3291 : : /* Find matching thread params using queue_id */
3292 : 0 : for (i = 0; i < MAX_QUEUES; ++i, ++tp)
3293 : 0 : if (tp->queue_id == queue_id)
3294 : : break;
3295 : :
3296 : 0 : if (i == MAX_QUEUES) {
3297 : : printf("%s: Queue_id from interrupt details was not found!\n",
3298 : : __func__);
3299 : 0 : return;
3300 : : }
3301 : :
3302 : 0 : if (unlikely(event != RTE_BBDEV_EVENT_DEQUEUE)) {
3303 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3304 : : rte_memory_order_relaxed);
3305 : : printf(
3306 : : "Dequeue interrupt handler called for incorrect event!\n");
3307 : 0 : return;
3308 : : }
3309 : :
3310 : 0 : burst_sz = rte_atomic_load_explicit(&tp->burst_sz, rte_memory_order_relaxed);
3311 : 0 : num_ops = tp->op_params->num_to_process;
3312 : :
3313 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
3314 : 0 : deq = rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
3315 : : &tp->dec_ops[
3316 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3317 : : rte_memory_order_relaxed)],
3318 : : burst_sz);
3319 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
3320 : 0 : deq = rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
3321 : : &tp->dec_ops[
3322 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3323 : : rte_memory_order_relaxed)],
3324 : : burst_sz);
3325 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
3326 : 0 : deq = rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
3327 : : &tp->enc_ops[
3328 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3329 : : rte_memory_order_relaxed)],
3330 : : burst_sz);
3331 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
3332 : 0 : deq = rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
3333 : : &tp->fft_ops[
3334 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3335 : : rte_memory_order_relaxed)],
3336 : : burst_sz);
3337 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
3338 : 0 : deq = rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
3339 : : &tp->mldts_ops[
3340 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3341 : : rte_memory_order_relaxed)],
3342 : : burst_sz);
3343 : : else /*RTE_BBDEV_OP_TURBO_ENC*/
3344 : 0 : deq = rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
3345 : : &tp->enc_ops[
3346 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3347 : : rte_memory_order_relaxed)],
3348 : : burst_sz);
3349 : :
3350 : 0 : if (deq < burst_sz) {
3351 : 0 : printf(
3352 : : "After receiving the interrupt all operations should be dequeued. Expected: %u, got: %u\n",
3353 : : burst_sz, deq);
3354 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3355 : : rte_memory_order_relaxed);
3356 : 0 : return;
3357 : : }
3358 : :
3359 : 0 : if (rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) + deq < num_ops) {
3360 : 0 : rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
3361 : 0 : return;
3362 : : }
3363 : :
3364 : 0 : total_time = rte_rdtsc_precise() - tp->start_time;
3365 : :
3366 : 0 : rte_bbdev_info_get(dev_id, &info);
3367 : :
3368 : : ret = TEST_SUCCESS;
3369 : :
3370 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) {
3371 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3372 : 0 : ret = validate_dec_op(tp->dec_ops, num_ops, ref_op);
3373 : : /* get the max of iter_count for all dequeued ops */
3374 : 0 : for (i = 0; i < num_ops; ++i)
3375 : 0 : tp->iter_count = RTE_MAX(
3376 : : tp->dec_ops[i]->turbo_dec.iter_count,
3377 : : tp->iter_count);
3378 : 0 : rte_bbdev_dec_op_free_bulk(tp->dec_ops, deq);
3379 : : } else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC) {
3380 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
3381 : 0 : ret = validate_enc_op(tp->enc_ops, num_ops, ref_op);
3382 : 0 : rte_bbdev_enc_op_free_bulk(tp->enc_ops, deq);
3383 : : } else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC) {
3384 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
3385 : 0 : ret = validate_ldpc_enc_op(tp->enc_ops, num_ops, ref_op);
3386 : 0 : rte_bbdev_enc_op_free_bulk(tp->enc_ops, deq);
3387 : : } else if (test_vector.op_type == RTE_BBDEV_OP_FFT) {
3388 : 0 : struct rte_bbdev_fft_op *ref_op = tp->op_params->ref_fft_op;
3389 : 0 : ret = validate_fft_op(tp->fft_ops, num_ops, ref_op);
3390 : 0 : rte_bbdev_fft_op_free_bulk(tp->fft_ops, deq);
3391 : : } else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS) {
3392 : 0 : struct rte_bbdev_mldts_op *ref_op = tp->op_params->ref_mldts_op;
3393 : 0 : ret = validate_mldts_op(tp->mldts_ops, num_ops, ref_op);
3394 : 0 : rte_bbdev_mldts_op_free_bulk(tp->mldts_ops, deq);
3395 : : } else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) {
3396 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3397 : 0 : ret = validate_ldpc_dec_op(tp->dec_ops, num_ops, ref_op,
3398 : : tp->op_params->vector_mask);
3399 : 0 : rte_bbdev_dec_op_free_bulk(tp->dec_ops, deq);
3400 : : }
3401 : :
3402 : 0 : if (ret) {
3403 : : printf("Buffers validation failed\n");
3404 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3405 : : rte_memory_order_relaxed);
3406 : : }
3407 : :
3408 : 0 : switch (test_vector.op_type) {
3409 : 0 : case RTE_BBDEV_OP_TURBO_DEC:
3410 : 0 : tb_len_bits = calc_dec_TB_size(tp->op_params->ref_dec_op);
3411 : 0 : break;
3412 : 0 : case RTE_BBDEV_OP_TURBO_ENC:
3413 : 0 : tb_len_bits = calc_enc_TB_size(tp->op_params->ref_enc_op);
3414 : 0 : break;
3415 : 0 : case RTE_BBDEV_OP_LDPC_DEC:
3416 : 0 : tb_len_bits = calc_ldpc_dec_TB_size(tp->op_params->ref_dec_op);
3417 : 0 : break;
3418 : 0 : case RTE_BBDEV_OP_FFT:
3419 : 0 : tb_len_bits = calc_fft_size(tp->op_params->ref_fft_op);
3420 : 0 : break;
3421 : 0 : case RTE_BBDEV_OP_MLDTS:
3422 : 0 : tb_len_bits = calc_mldts_size(tp->op_params->ref_mldts_op);
3423 : 0 : break;
3424 : 0 : case RTE_BBDEV_OP_LDPC_ENC:
3425 : 0 : tb_len_bits = calc_ldpc_enc_TB_size(tp->op_params->ref_enc_op);
3426 : 0 : break;
3427 : : case RTE_BBDEV_OP_NONE:
3428 : : tb_len_bits = 0.0;
3429 : : break;
3430 : 0 : default:
3431 : : printf("Unknown op type: %d\n", test_vector.op_type);
3432 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3433 : : rte_memory_order_relaxed);
3434 : 0 : return;
3435 : : }
3436 : :
3437 : 0 : tp->ops_per_sec += ((double)num_ops) /
3438 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
3439 : 0 : tp->mbps += (((double)(num_ops * tb_len_bits)) / 1000000.0) /
3440 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
3441 : :
3442 : 0 : rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
3443 : : }
3444 : :
3445 : : static int
3446 : 0 : throughput_intr_lcore_ldpc_dec(void *arg)
3447 : : {
3448 : : struct thread_params *tp = arg;
3449 : : unsigned int enqueued;
3450 : 0 : const uint16_t queue_id = tp->queue_id;
3451 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3452 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3453 : 0 : struct rte_bbdev_dec_op **ops = alloca(sizeof(struct rte_bbdev_dec_op *) * num_to_process);
3454 : : struct test_buffers *bufs = NULL;
3455 : : struct rte_bbdev_info info;
3456 : : int ret, i, j;
3457 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3458 : : uint16_t num_to_enq, enq;
3459 : :
3460 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
3461 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
3462 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
3463 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
3464 : :
3465 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3466 : : "BURST_SIZE should be <= %u", MAX_BURST);
3467 : :
3468 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3469 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3470 : : tp->dev_id, queue_id);
3471 : :
3472 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3473 : :
3474 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3475 : : "NUM_OPS cannot exceed %u for this device",
3476 : : info.drv.queue_size_lim);
3477 : :
3478 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3479 : :
3480 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3481 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3482 : :
3483 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3484 : : rte_memory_order_relaxed);
3485 : :
3486 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
3487 : : num_to_process);
3488 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3489 : : num_to_process);
3490 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
3491 : :
3492 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3493 : 0 : copy_reference_ldpc_dec_op(ops, num_to_process, 0, bufs->inputs,
3494 : : bufs->hard_outputs, bufs->soft_outputs,
3495 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
3496 : :
3497 : : /* Set counter to validate the ordering */
3498 : 0 : for (j = 0; j < num_to_process; ++j)
3499 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3500 : :
3501 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3502 : 0 : for (i = 0; i < num_to_process; ++i) {
3503 : 0 : if (!loopback)
3504 : 0 : mbuf_reset(ops[i]->ldpc_dec.hard_output.data);
3505 : 0 : if (hc_out || loopback)
3506 : 0 : mbuf_reset(ops[i]->ldpc_dec.harq_combined_output.data);
3507 : 0 : if (ops[i]->ldpc_dec.soft_output.data != NULL)
3508 : : mbuf_reset(ops[i]->ldpc_dec.soft_output.data);
3509 : : }
3510 : :
3511 : 0 : tp->start_time = rte_rdtsc_precise();
3512 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3513 : : num_to_enq = burst_sz;
3514 : :
3515 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3516 : 0 : num_to_enq = num_to_process - enqueued;
3517 : :
3518 : : /* Write to thread burst_sz current number of enqueued
3519 : : * descriptors. It ensures that proper number of
3520 : : * descriptors will be dequeued in callback
3521 : : * function - needed for last batch in case where
3522 : : * the number of operations is not a multiple of
3523 : : * burst size.
3524 : : */
3525 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3526 : : rte_memory_order_relaxed);
3527 : :
3528 : : enq = 0;
3529 : : do {
3530 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(
3531 : 0 : tp->dev_id,
3532 : 0 : queue_id, &ops[enqueued],
3533 : : num_to_enq);
3534 : 0 : } while (unlikely(num_to_enq != enq));
3535 : 0 : enqueued += enq;
3536 : :
3537 : : /* Wait until processing of previous batch is
3538 : : * completed
3539 : : */
3540 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3541 : : rte_memory_order_relaxed);
3542 : : }
3543 : 0 : if (j != TEST_REPETITIONS - 1)
3544 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3545 : : }
3546 : :
3547 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3548 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3549 : : tp->dev_id, queue_id);
3550 : :
3551 : : return TEST_SUCCESS;
3552 : : }
3553 : :
3554 : : static int
3555 : 0 : throughput_intr_lcore_dec(void *arg)
3556 : : {
3557 : : struct thread_params *tp = arg;
3558 : : unsigned int enqueued;
3559 : 0 : const uint16_t queue_id = tp->queue_id;
3560 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3561 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3562 : 0 : struct rte_bbdev_dec_op **ops = alloca(sizeof(struct rte_bbdev_dec_op *) * num_to_process);
3563 : : struct test_buffers *bufs = NULL;
3564 : : struct rte_bbdev_info info;
3565 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3566 : : int ret, i, j;
3567 : : uint16_t num_to_enq, enq;
3568 : :
3569 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3570 : : "BURST_SIZE should be <= %u", MAX_BURST);
3571 : :
3572 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3573 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3574 : : tp->dev_id, queue_id);
3575 : :
3576 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3577 : :
3578 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3579 : : "NUM_OPS cannot exceed %u for this device",
3580 : : info.drv.queue_size_lim);
3581 : :
3582 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3583 : :
3584 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3585 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3586 : :
3587 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3588 : : rte_memory_order_relaxed);
3589 : :
3590 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
3591 : : num_to_process);
3592 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_to_process);
3593 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
3594 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3595 : 0 : copy_reference_dec_op(ops, num_to_process, 0, bufs->inputs,
3596 : : bufs->hard_outputs, bufs->soft_outputs,
3597 : 0 : tp->op_params->ref_dec_op);
3598 : :
3599 : : /* Set counter to validate the ordering. */
3600 : 0 : for (j = 0; j < num_to_process; ++j)
3601 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3602 : :
3603 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3604 : 0 : for (i = 0; i < num_to_process; ++i) {
3605 : 0 : mbuf_reset(ops[i]->turbo_dec.hard_output.data);
3606 : 0 : if (ops[i]->turbo_dec.soft_output.data != NULL)
3607 : : mbuf_reset(ops[i]->turbo_dec.soft_output.data);
3608 : : }
3609 : :
3610 : 0 : tp->start_time = rte_rdtsc_precise();
3611 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3612 : : num_to_enq = burst_sz;
3613 : :
3614 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3615 : 0 : num_to_enq = num_to_process - enqueued;
3616 : :
3617 : : /* Write to thread burst_sz current number of enqueued
3618 : : * descriptors. It ensures that proper number of
3619 : : * descriptors will be dequeued in callback
3620 : : * function - needed for last batch in case where
3621 : : * the number of operations is not a multiple of
3622 : : * burst size.
3623 : : */
3624 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3625 : : rte_memory_order_relaxed);
3626 : :
3627 : : enq = 0;
3628 : : do {
3629 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
3630 : 0 : queue_id, &ops[enqueued],
3631 : : num_to_enq);
3632 : 0 : } while (unlikely(num_to_enq != enq));
3633 : 0 : enqueued += enq;
3634 : :
3635 : : /* Wait until processing of previous batch is
3636 : : * completed
3637 : : */
3638 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3639 : : rte_memory_order_relaxed);
3640 : : }
3641 : 0 : if (j != TEST_REPETITIONS - 1)
3642 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3643 : : }
3644 : :
3645 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3646 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3647 : : tp->dev_id, queue_id);
3648 : :
3649 : : return TEST_SUCCESS;
3650 : : }
3651 : :
3652 : : static int
3653 : 0 : throughput_intr_lcore_enc(void *arg)
3654 : : {
3655 : : struct thread_params *tp = arg;
3656 : : unsigned int enqueued;
3657 : 0 : const uint16_t queue_id = tp->queue_id;
3658 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3659 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3660 : 0 : struct rte_bbdev_enc_op **ops = alloca(sizeof(struct rte_bbdev_enc_op *) * num_to_process);
3661 : : struct test_buffers *bufs = NULL;
3662 : : struct rte_bbdev_info info;
3663 : : int ret, i, j;
3664 : : uint16_t num_to_enq, enq;
3665 : :
3666 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3667 : : "BURST_SIZE should be <= %u", MAX_BURST);
3668 : :
3669 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3670 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3671 : : tp->dev_id, queue_id);
3672 : :
3673 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3674 : :
3675 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3676 : : "NUM_OPS cannot exceed %u for this device",
3677 : : info.drv.queue_size_lim);
3678 : :
3679 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3680 : :
3681 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3682 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3683 : :
3684 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3685 : : rte_memory_order_relaxed);
3686 : :
3687 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
3688 : : num_to_process);
3689 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3690 : : num_to_process);
3691 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3692 : 0 : copy_reference_enc_op(ops, num_to_process, 0, bufs->inputs,
3693 : 0 : bufs->hard_outputs, tp->op_params->ref_enc_op);
3694 : :
3695 : : /* Set counter to validate the ordering */
3696 : 0 : for (j = 0; j < num_to_process; ++j)
3697 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3698 : :
3699 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3700 : 0 : for (i = 0; i < num_to_process; ++i)
3701 : 0 : mbuf_reset(ops[i]->turbo_enc.output.data);
3702 : :
3703 : 0 : tp->start_time = rte_rdtsc_precise();
3704 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3705 : : num_to_enq = burst_sz;
3706 : :
3707 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3708 : 0 : num_to_enq = num_to_process - enqueued;
3709 : :
3710 : : /* Write to thread burst_sz current number of enqueued
3711 : : * descriptors. It ensures that proper number of
3712 : : * descriptors will be dequeued in callback
3713 : : * function - needed for last batch in case where
3714 : : * the number of operations is not a multiple of
3715 : : * burst size.
3716 : : */
3717 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3718 : : rte_memory_order_relaxed);
3719 : :
3720 : : enq = 0;
3721 : : do {
3722 : 0 : enq += rte_bbdev_enqueue_enc_ops(tp->dev_id,
3723 : 0 : queue_id, &ops[enqueued],
3724 : : num_to_enq);
3725 : 0 : } while (unlikely(enq != num_to_enq));
3726 : 0 : enqueued += enq;
3727 : :
3728 : : /* Wait until processing of previous batch is
3729 : : * completed
3730 : : */
3731 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3732 : : rte_memory_order_relaxed);
3733 : : }
3734 : 0 : if (j != TEST_REPETITIONS - 1)
3735 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3736 : : }
3737 : :
3738 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3739 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3740 : : tp->dev_id, queue_id);
3741 : :
3742 : : return TEST_SUCCESS;
3743 : : }
3744 : :
3745 : :
3746 : : static int
3747 : 0 : throughput_intr_lcore_ldpc_enc(void *arg)
3748 : : {
3749 : : struct thread_params *tp = arg;
3750 : : unsigned int enqueued;
3751 : 0 : const uint16_t queue_id = tp->queue_id;
3752 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3753 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3754 : 0 : struct rte_bbdev_enc_op **ops = alloca(sizeof(struct rte_bbdev_enc_op *) * num_to_process);
3755 : : struct test_buffers *bufs = NULL;
3756 : : struct rte_bbdev_info info;
3757 : : int ret, i, j;
3758 : : uint16_t num_to_enq, enq;
3759 : :
3760 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3761 : : "BURST_SIZE should be <= %u", MAX_BURST);
3762 : :
3763 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3764 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3765 : : tp->dev_id, queue_id);
3766 : :
3767 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3768 : :
3769 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3770 : : "NUM_OPS cannot exceed %u for this device",
3771 : : info.drv.queue_size_lim);
3772 : :
3773 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3774 : :
3775 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3776 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3777 : :
3778 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3779 : : rte_memory_order_relaxed);
3780 : :
3781 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
3782 : : num_to_process);
3783 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3784 : : num_to_process);
3785 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3786 : 0 : copy_reference_ldpc_enc_op(ops, num_to_process, 0,
3787 : : bufs->inputs, bufs->hard_outputs,
3788 : 0 : tp->op_params->ref_enc_op);
3789 : :
3790 : : /* Set counter to validate the ordering */
3791 : 0 : for (j = 0; j < num_to_process; ++j)
3792 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3793 : :
3794 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3795 : 0 : for (i = 0; i < num_to_process; ++i)
3796 : 0 : mbuf_reset(ops[i]->turbo_enc.output.data);
3797 : :
3798 : 0 : tp->start_time = rte_rdtsc_precise();
3799 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3800 : : num_to_enq = burst_sz;
3801 : :
3802 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3803 : 0 : num_to_enq = num_to_process - enqueued;
3804 : :
3805 : : /* Write to thread burst_sz current number of enqueued
3806 : : * descriptors. It ensures that proper number of
3807 : : * descriptors will be dequeued in callback
3808 : : * function - needed for last batch in case where
3809 : : * the number of operations is not a multiple of
3810 : : * burst size.
3811 : : */
3812 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3813 : : rte_memory_order_relaxed);
3814 : :
3815 : : enq = 0;
3816 : : do {
3817 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(
3818 : 0 : tp->dev_id,
3819 : 0 : queue_id, &ops[enqueued],
3820 : : num_to_enq);
3821 : 0 : } while (unlikely(enq != num_to_enq));
3822 : 0 : enqueued += enq;
3823 : :
3824 : : /* Wait until processing of previous batch is
3825 : : * completed
3826 : : */
3827 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3828 : : rte_memory_order_relaxed);
3829 : : }
3830 : 0 : if (j != TEST_REPETITIONS - 1)
3831 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3832 : : }
3833 : :
3834 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3835 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3836 : : tp->dev_id, queue_id);
3837 : :
3838 : : return TEST_SUCCESS;
3839 : : }
3840 : :
3841 : :
3842 : : static int
3843 : 0 : throughput_intr_lcore_fft(void *arg)
3844 : : {
3845 : : struct thread_params *tp = arg;
3846 : : unsigned int enqueued;
3847 : 0 : const uint16_t queue_id = tp->queue_id;
3848 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3849 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3850 : 0 : struct rte_bbdev_fft_op **ops = alloca(sizeof(struct rte_bbdev_fft_op *) * num_to_process);
3851 : : struct test_buffers *bufs = NULL;
3852 : : struct rte_bbdev_info info;
3853 : : int ret, i, j;
3854 : : uint16_t num_to_enq, enq;
3855 : :
3856 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3857 : : "BURST_SIZE should be <= %u", MAX_BURST);
3858 : :
3859 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3860 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3861 : : tp->dev_id, queue_id);
3862 : :
3863 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3864 : :
3865 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3866 : : "NUM_OPS cannot exceed %u for this device",
3867 : : info.drv.queue_size_lim);
3868 : :
3869 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3870 : :
3871 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3872 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3873 : :
3874 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3875 : : rte_memory_order_relaxed);
3876 : :
3877 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops,
3878 : : num_to_process);
3879 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3880 : : num_to_process);
3881 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3882 : 0 : copy_reference_fft_op(ops, num_to_process, 0, bufs->inputs,
3883 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
3884 : 0 : tp->op_params->ref_fft_op);
3885 : :
3886 : : /* Set counter to validate the ordering */
3887 : 0 : for (j = 0; j < num_to_process; ++j)
3888 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3889 : :
3890 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3891 : 0 : for (i = 0; i < num_to_process; ++i)
3892 : 0 : mbuf_reset(ops[i]->fft.base_output.data);
3893 : :
3894 : 0 : tp->start_time = rte_rdtsc_precise();
3895 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3896 : : num_to_enq = burst_sz;
3897 : :
3898 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3899 : 0 : num_to_enq = num_to_process - enqueued;
3900 : :
3901 : : /* Write to thread burst_sz current number of enqueued
3902 : : * descriptors. It ensures that proper number of
3903 : : * descriptors will be dequeued in callback
3904 : : * function - needed for last batch in case where
3905 : : * the number of operations is not a multiple of
3906 : : * burst size.
3907 : : */
3908 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3909 : : rte_memory_order_relaxed);
3910 : :
3911 : : enq = 0;
3912 : : do {
3913 : 0 : enq += rte_bbdev_enqueue_fft_ops(tp->dev_id,
3914 : 0 : queue_id, &ops[enqueued],
3915 : : num_to_enq);
3916 : 0 : } while (unlikely(enq != num_to_enq));
3917 : 0 : enqueued += enq;
3918 : :
3919 : : /* Wait until processing of previous batch is
3920 : : * completed
3921 : : */
3922 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3923 : : rte_memory_order_relaxed);
3924 : : }
3925 : 0 : if (j != TEST_REPETITIONS - 1)
3926 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3927 : : }
3928 : :
3929 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3930 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3931 : : tp->dev_id, queue_id);
3932 : :
3933 : : return TEST_SUCCESS;
3934 : : }
3935 : :
3936 : : static int
3937 : 0 : throughput_intr_lcore_mldts(void *arg)
3938 : : {
3939 : : struct thread_params *tp = arg;
3940 : : unsigned int enqueued;
3941 : 0 : const uint16_t queue_id = tp->queue_id;
3942 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3943 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3944 : : struct rte_bbdev_mldts_op **ops =
3945 : 0 : alloca(sizeof(struct rte_bbdev_mldts_op *) * num_to_process);
3946 : : struct test_buffers *bufs = NULL;
3947 : : struct rte_bbdev_info info;
3948 : : int ret, i, j;
3949 : : uint16_t num_to_enq, enq;
3950 : :
3951 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST), "BURST_SIZE should be <= %u", MAX_BURST);
3952 : :
3953 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3954 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3955 : : tp->dev_id, queue_id);
3956 : :
3957 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3958 : :
3959 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3960 : : "NUM_OPS cannot exceed %u for this device",
3961 : : info.drv.queue_size_lim);
3962 : :
3963 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3964 : :
3965 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3966 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3967 : :
3968 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3969 : : rte_memory_order_relaxed);
3970 : :
3971 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops, num_to_process);
3972 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_to_process);
3973 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3974 : 0 : copy_reference_mldts_op(ops, num_to_process, 0, bufs->inputs, bufs->harq_inputs,
3975 : 0 : bufs->hard_outputs, tp->op_params->ref_mldts_op);
3976 : :
3977 : : /* Set counter to validate the ordering */
3978 : 0 : for (j = 0; j < num_to_process; ++j)
3979 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3980 : :
3981 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3982 : 0 : for (i = 0; i < num_to_process; ++i)
3983 : 0 : mbuf_reset(ops[i]->mldts.output.data);
3984 : :
3985 : 0 : tp->start_time = rte_rdtsc_precise();
3986 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3987 : : num_to_enq = burst_sz;
3988 : :
3989 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3990 : 0 : num_to_enq = num_to_process - enqueued;
3991 : :
3992 : : /* Write to thread burst_sz current number of enqueued
3993 : : * descriptors. It ensures that proper number of
3994 : : * descriptors will be dequeued in callback
3995 : : * function - needed for last batch in case where
3996 : : * the number of operations is not a multiple of
3997 : : * burst size.
3998 : : */
3999 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
4000 : : rte_memory_order_relaxed);
4001 : :
4002 : : enq = 0;
4003 : : do {
4004 : 0 : enq += rte_bbdev_enqueue_mldts_ops(tp->dev_id,
4005 : 0 : queue_id, &ops[enqueued], num_to_enq);
4006 : 0 : } while (unlikely(enq != num_to_enq));
4007 : 0 : enqueued += enq;
4008 : :
4009 : : /* Wait until processing of previous batch is
4010 : : * completed
4011 : : */
4012 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
4013 : : rte_memory_order_relaxed);
4014 : : }
4015 : 0 : if (j != TEST_REPETITIONS - 1)
4016 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
4017 : : }
4018 : :
4019 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
4020 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
4021 : : tp->dev_id, queue_id);
4022 : :
4023 : : return TEST_SUCCESS;
4024 : : }
4025 : :
4026 : : static int
4027 : 0 : throughput_pmd_lcore_dec(void *arg)
4028 : : {
4029 : : struct thread_params *tp = arg;
4030 : : uint16_t enq, deq;
4031 : : uint64_t total_time = 0, start_time;
4032 : 0 : const uint16_t queue_id = tp->queue_id;
4033 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4034 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4035 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4036 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4037 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4038 : : struct test_buffers *bufs = NULL;
4039 : : int i, j, ret;
4040 : : struct rte_bbdev_info info;
4041 : : uint16_t num_to_enq;
4042 : : bool so_enable;
4043 : :
4044 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4045 : : "BURST_SIZE should be <= %u", MAX_BURST);
4046 : :
4047 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4048 : :
4049 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4050 : : "NUM_OPS cannot exceed %u for this device",
4051 : : info.drv.queue_size_lim);
4052 : :
4053 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4054 : :
4055 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4056 : : rte_memory_order_relaxed);
4057 : :
4058 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4059 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4060 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
4061 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4062 : 0 : copy_reference_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4063 : : bufs->hard_outputs, bufs->soft_outputs, ref_op);
4064 : :
4065 : 0 : so_enable = check_bit(ops_enq[0]->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT);
4066 : :
4067 : : /* Set counter to validate the ordering */
4068 : 0 : for (j = 0; j < num_ops; ++j)
4069 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4070 : :
4071 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4072 : : uint32_t time_out = 0;
4073 : 0 : for (j = 0; j < num_ops; ++j)
4074 : 0 : mbuf_reset(ops_enq[j]->turbo_dec.hard_output.data);
4075 : 0 : if (so_enable)
4076 : 0 : for (j = 0; j < num_ops; ++j)
4077 : 0 : mbuf_reset(ops_enq[j]->turbo_dec.soft_output.data);
4078 : :
4079 : : start_time = rte_rdtsc_precise();
4080 : :
4081 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4082 : : num_to_enq = burst_sz;
4083 : :
4084 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4085 : 0 : num_to_enq = num_ops - enq;
4086 : :
4087 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
4088 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4089 : :
4090 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4091 : 0 : queue_id, &ops_deq[deq], enq - deq);
4092 : 0 : time_out++;
4093 : 0 : if (time_out >= TIME_OUT_POLL) {
4094 : 0 : timeout_exit(tp->dev_id);
4095 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4096 : : }
4097 : : }
4098 : :
4099 : : /* dequeue the remaining */
4100 : : time_out = 0;
4101 : 0 : while (deq < enq) {
4102 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4103 : 0 : queue_id, &ops_deq[deq], enq - deq);
4104 : 0 : time_out++;
4105 : 0 : if (time_out >= TIME_OUT_POLL) {
4106 : 0 : timeout_exit(tp->dev_id);
4107 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4108 : : }
4109 : : }
4110 : :
4111 : 0 : total_time += rte_rdtsc_precise() - start_time;
4112 : : }
4113 : :
4114 : 0 : tp->iter_count = 0;
4115 : : /* get the max of iter_count for all dequeued ops */
4116 : 0 : for (i = 0; i < num_ops; ++i) {
4117 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->turbo_dec.iter_count,
4118 : : tp->iter_count);
4119 : : }
4120 : :
4121 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4122 : 0 : ret = validate_dec_op(ops_deq, num_ops, ref_op);
4123 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4124 : : }
4125 : :
4126 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4127 : :
4128 : 0 : double tb_len_bits = calc_dec_TB_size(ref_op);
4129 : :
4130 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4131 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4132 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4133 : 0 : 1000000.0) / ((double)total_time /
4134 : 0 : (double)rte_get_tsc_hz());
4135 : :
4136 : 0 : return TEST_SUCCESS;
4137 : : }
4138 : :
4139 : : static int
4140 : 0 : bler_pmd_lcore_ldpc_dec(void *arg)
4141 : : {
4142 : : struct thread_params *tp = arg;
4143 : : uint16_t enq, deq;
4144 : : uint64_t total_time = 0, start_time;
4145 : 0 : const uint16_t queue_id = tp->queue_id;
4146 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4147 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4148 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4149 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4150 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4151 : : struct test_buffers *bufs = NULL;
4152 : : int i, j, ret;
4153 : : float parity_bler = 0;
4154 : : struct rte_bbdev_info info;
4155 : : uint16_t num_to_enq;
4156 : 0 : bool extDdr = check_bit(ldpc_cap_flags,
4157 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE);
4158 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
4159 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
4160 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
4161 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
4162 : :
4163 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4164 : : "BURST_SIZE should be <= %u", MAX_BURST);
4165 : 0 : TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
4166 : :
4167 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4168 : :
4169 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4170 : : "NUM_OPS cannot exceed %u for this device",
4171 : : info.drv.queue_size_lim);
4172 : :
4173 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4174 : :
4175 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4176 : : rte_memory_order_relaxed);
4177 : :
4178 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4179 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4180 : :
4181 : : /* For BLER tests we need to enable early termination */
4182 : 0 : if (!check_bit(ref_op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
4183 : 0 : ref_op->ldpc_dec.op_flags += RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
4184 : :
4185 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
4186 : :
4187 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4188 : 0 : copy_reference_ldpc_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4189 : : bufs->hard_outputs, bufs->soft_outputs,
4190 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
4191 : 0 : generate_llr_input(num_ops, bufs->inputs, ref_op);
4192 : :
4193 : : /* Set counter to validate the ordering */
4194 : 0 : for (j = 0; j < num_ops; ++j)
4195 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4196 : :
4197 : 0 : for (i = 0; i < 1; ++i) { /* Could add more iterations */
4198 : : uint32_t time_out = 0;
4199 : 0 : for (j = 0; j < num_ops; ++j) {
4200 : 0 : if (!loopback)
4201 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.hard_output.data);
4202 : 0 : if (hc_out || loopback)
4203 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.harq_combined_output.data);
4204 : 0 : if (ops_enq[j]->ldpc_dec.soft_output.data != NULL)
4205 : : mbuf_reset(ops_enq[j]->ldpc_dec.soft_output.data);
4206 : : }
4207 : 0 : if (extDdr)
4208 : 0 : preload_harq_ddr(tp->dev_id, queue_id, ops_enq,
4209 : : num_ops, true);
4210 : : start_time = rte_rdtsc_precise();
4211 : :
4212 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4213 : : num_to_enq = burst_sz;
4214 : :
4215 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4216 : 0 : num_to_enq = num_ops - enq;
4217 : :
4218 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id,
4219 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4220 : :
4221 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4222 : 0 : queue_id, &ops_deq[deq], enq - deq);
4223 : 0 : time_out++;
4224 : 0 : if (time_out >= TIME_OUT_POLL) {
4225 : 0 : timeout_exit(tp->dev_id);
4226 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4227 : : }
4228 : : }
4229 : :
4230 : : /* dequeue the remaining */
4231 : : time_out = 0;
4232 : 0 : while (deq < enq) {
4233 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4234 : 0 : queue_id, &ops_deq[deq], enq - deq);
4235 : 0 : time_out++;
4236 : 0 : if (time_out >= TIME_OUT_POLL) {
4237 : 0 : timeout_exit(tp->dev_id);
4238 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4239 : : }
4240 : : }
4241 : :
4242 : 0 : total_time += rte_rdtsc_precise() - start_time;
4243 : : }
4244 : :
4245 : 0 : tp->iter_count = 0;
4246 : 0 : tp->iter_average = 0;
4247 : : /* get the max of iter_count for all dequeued ops */
4248 : 0 : for (i = 0; i < num_ops; ++i) {
4249 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->ldpc_dec.iter_count,
4250 : : tp->iter_count);
4251 : 0 : tp->iter_average += (double) ops_enq[i]->ldpc_dec.iter_count;
4252 : 0 : if (ops_enq[i]->status & (1 << RTE_BBDEV_SYNDROME_ERROR))
4253 : 0 : parity_bler += 1.0;
4254 : : }
4255 : :
4256 : 0 : parity_bler /= num_ops; /* This one is based on SYND */
4257 : 0 : tp->iter_average /= num_ops;
4258 : 0 : tp->bler = (double) validate_ldpc_bler(ops_deq, num_ops) / num_ops;
4259 : :
4260 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE
4261 : 0 : && tp->bler == 0
4262 : 0 : && parity_bler == 0
4263 : 0 : && !hc_out) {
4264 : 0 : ret = validate_ldpc_dec_op(ops_deq, num_ops, ref_op,
4265 : 0 : tp->op_params->vector_mask);
4266 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4267 : : }
4268 : :
4269 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4270 : :
4271 : 0 : double tb_len_bits = calc_ldpc_dec_TB_size(ref_op);
4272 : 0 : tp->ops_per_sec = ((double)num_ops * 1) /
4273 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4274 : 0 : tp->mbps = (((double)(num_ops * 1 * tb_len_bits)) /
4275 : 0 : 1000000.0) / ((double)total_time /
4276 : 0 : (double)rte_get_tsc_hz());
4277 : :
4278 : 0 : return TEST_SUCCESS;
4279 : : }
4280 : :
4281 : :
4282 : : static int
4283 : 0 : bler_pmd_lcore_turbo_dec(void *arg)
4284 : : {
4285 : : struct thread_params *tp = arg;
4286 : : uint16_t enq, deq;
4287 : : uint64_t total_time = 0, start_time;
4288 : 0 : const uint16_t queue_id = tp->queue_id;
4289 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4290 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4291 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4292 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4293 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4294 : : struct test_buffers *bufs = NULL;
4295 : : int i, j, ret;
4296 : : struct rte_bbdev_info info;
4297 : : uint16_t num_to_enq;
4298 : :
4299 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4300 : : "BURST_SIZE should be <= %u", MAX_BURST);
4301 : 0 : TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
4302 : :
4303 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4304 : :
4305 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4306 : : "NUM_OPS cannot exceed %u for this device",
4307 : : info.drv.queue_size_lim);
4308 : :
4309 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4310 : :
4311 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4312 : : rte_memory_order_relaxed);
4313 : :
4314 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4315 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4316 : :
4317 : : /* For BLER tests we need to enable early termination */
4318 : 0 : if (!check_bit(ref_op->turbo_dec.op_flags, RTE_BBDEV_TURBO_EARLY_TERMINATION))
4319 : 0 : ref_op->turbo_dec.op_flags += RTE_BBDEV_TURBO_EARLY_TERMINATION;
4320 : :
4321 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
4322 : :
4323 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4324 : 0 : copy_reference_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4325 : : bufs->hard_outputs, bufs->soft_outputs,
4326 : : ref_op);
4327 : 0 : generate_turbo_llr_input(num_ops, bufs->inputs, ref_op);
4328 : :
4329 : : /* Set counter to validate the ordering */
4330 : 0 : for (j = 0; j < num_ops; ++j)
4331 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4332 : :
4333 : 0 : for (i = 0; i < 1; ++i) { /* Could add more iterations */
4334 : : uint32_t time_out = 0;
4335 : 0 : for (j = 0; j < num_ops; ++j) {
4336 : 0 : mbuf_reset(
4337 : 0 : ops_enq[j]->turbo_dec.hard_output.data);
4338 : : }
4339 : :
4340 : : start_time = rte_rdtsc_precise();
4341 : :
4342 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4343 : : num_to_enq = burst_sz;
4344 : :
4345 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4346 : 0 : num_to_enq = num_ops - enq;
4347 : :
4348 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
4349 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4350 : :
4351 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4352 : 0 : queue_id, &ops_deq[deq], enq - deq);
4353 : 0 : time_out++;
4354 : 0 : if (time_out >= TIME_OUT_POLL) {
4355 : 0 : timeout_exit(tp->dev_id);
4356 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4357 : : }
4358 : : }
4359 : :
4360 : : /* dequeue the remaining */
4361 : : time_out = 0;
4362 : 0 : while (deq < enq) {
4363 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4364 : 0 : queue_id, &ops_deq[deq], enq - deq);
4365 : 0 : time_out++;
4366 : 0 : if (time_out >= TIME_OUT_POLL) {
4367 : 0 : timeout_exit(tp->dev_id);
4368 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4369 : : }
4370 : : }
4371 : :
4372 : 0 : total_time += rte_rdtsc_precise() - start_time;
4373 : : }
4374 : :
4375 : 0 : tp->iter_count = 0;
4376 : 0 : tp->iter_average = 0;
4377 : : /* get the max of iter_count for all dequeued ops */
4378 : 0 : for (i = 0; i < num_ops; ++i) {
4379 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->turbo_dec.iter_count,
4380 : : tp->iter_count);
4381 : 0 : tp->iter_average += (double) ops_enq[i]->turbo_dec.iter_count;
4382 : : }
4383 : :
4384 : 0 : tp->iter_average /= num_ops;
4385 : 0 : tp->bler = (double) validate_turbo_bler(ops_deq, num_ops) / num_ops;
4386 : :
4387 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4388 : :
4389 : 0 : double tb_len_bits = calc_dec_TB_size(ref_op);
4390 : 0 : tp->ops_per_sec = ((double)num_ops * 1) /
4391 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4392 : 0 : tp->mbps = (((double)(num_ops * 1 * tb_len_bits)) /
4393 : 0 : 1000000.0) / ((double)total_time /
4394 : 0 : (double)rte_get_tsc_hz());
4395 : 0 : printf("TBS %.0f Time %.0f\n", tb_len_bits, 1000000.0 *
4396 : 0 : ((double)total_time / (double)rte_get_tsc_hz()));
4397 : :
4398 : 0 : return TEST_SUCCESS;
4399 : : }
4400 : :
4401 : : static int
4402 : 0 : throughput_pmd_lcore_ldpc_dec(void *arg)
4403 : : {
4404 : : struct thread_params *tp = arg;
4405 : : uint16_t enq, deq;
4406 : : uint64_t total_time = 0, start_time;
4407 : 0 : const uint16_t queue_id = tp->queue_id;
4408 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4409 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4410 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4411 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4412 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4413 : : struct test_buffers *bufs = NULL;
4414 : : int i, j, ret;
4415 : : struct rte_bbdev_info info;
4416 : : uint16_t num_to_enq;
4417 : 0 : bool extDdr = check_bit(ldpc_cap_flags,
4418 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE);
4419 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
4420 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
4421 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
4422 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
4423 : :
4424 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4425 : : "BURST_SIZE should be <= %u", MAX_BURST);
4426 : :
4427 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4428 : :
4429 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4430 : : "NUM_OPS cannot exceed %u for this device",
4431 : : info.drv.queue_size_lim);
4432 : :
4433 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4434 : :
4435 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4436 : : rte_memory_order_relaxed);
4437 : :
4438 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4439 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4440 : :
4441 : : /* For throughput tests we need to disable early termination */
4442 : 0 : if (check_bit(ref_op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
4443 : 0 : ref_op->ldpc_dec.op_flags -= RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
4444 : :
4445 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
4446 : : /* Since ET is disabled, the expected iter_count is iter_max */
4447 : 0 : ref_op->ldpc_dec.iter_count = ref_op->ldpc_dec.iter_max;
4448 : :
4449 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4450 : 0 : copy_reference_ldpc_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4451 : : bufs->hard_outputs, bufs->soft_outputs,
4452 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
4453 : :
4454 : : /* Set counter to validate the ordering */
4455 : 0 : for (j = 0; j < num_ops; ++j)
4456 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4457 : :
4458 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4459 : : uint32_t time_out = 0;
4460 : 0 : for (j = 0; j < num_ops; ++j) {
4461 : 0 : if (!loopback)
4462 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.hard_output.data);
4463 : 0 : if (hc_out || loopback)
4464 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.harq_combined_output.data);
4465 : 0 : if (ops_enq[j]->ldpc_dec.soft_output.data != NULL)
4466 : : mbuf_reset(ops_enq[j]->ldpc_dec.soft_output.data);
4467 : : }
4468 : 0 : if (extDdr)
4469 : 0 : preload_harq_ddr(tp->dev_id, queue_id, ops_enq,
4470 : : num_ops, true);
4471 : : start_time = rte_rdtsc_precise();
4472 : :
4473 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4474 : : num_to_enq = burst_sz;
4475 : :
4476 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4477 : 0 : num_to_enq = num_ops - enq;
4478 : :
4479 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id,
4480 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4481 : :
4482 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4483 : 0 : queue_id, &ops_deq[deq], enq - deq);
4484 : 0 : time_out++;
4485 : 0 : if (time_out >= TIME_OUT_POLL) {
4486 : 0 : timeout_exit(tp->dev_id);
4487 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4488 : : }
4489 : : }
4490 : :
4491 : : /* dequeue the remaining */
4492 : : time_out = 0;
4493 : 0 : while (deq < enq) {
4494 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4495 : 0 : queue_id, &ops_deq[deq], enq - deq);
4496 : 0 : time_out++;
4497 : 0 : if (time_out >= TIME_OUT_POLL) {
4498 : 0 : timeout_exit(tp->dev_id);
4499 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4500 : : }
4501 : : }
4502 : :
4503 : 0 : total_time += rte_rdtsc_precise() - start_time;
4504 : : }
4505 : :
4506 : 0 : tp->iter_count = 0;
4507 : : /* get the max of iter_count for all dequeued ops */
4508 : 0 : for (i = 0; i < num_ops; ++i) {
4509 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->ldpc_dec.iter_count,
4510 : : tp->iter_count);
4511 : : }
4512 : 0 : if (extDdr) {
4513 : : /* Read loopback is not thread safe */
4514 : 0 : retrieve_harq_ddr(tp->dev_id, queue_id, ops_enq, num_ops);
4515 : : }
4516 : :
4517 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4518 : 0 : ret = validate_ldpc_dec_op(ops_deq, num_ops, ref_op,
4519 : 0 : tp->op_params->vector_mask);
4520 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4521 : : }
4522 : :
4523 : 0 : ret = rte_bbdev_queue_stop(tp->dev_id, queue_id);
4524 : 0 : if (ret != 0)
4525 : 0 : printf("Failed to stop queue on dev %u q_id: %u\n", tp->dev_id, queue_id);
4526 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4527 : :
4528 : 0 : double tb_len_bits = calc_ldpc_dec_TB_size(ref_op);
4529 : :
4530 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4531 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4532 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4533 : 0 : 1000000.0) / ((double)total_time /
4534 : 0 : (double)rte_get_tsc_hz());
4535 : :
4536 : 0 : return TEST_SUCCESS;
4537 : : }
4538 : :
4539 : : static int
4540 : 0 : throughput_pmd_lcore_enc(void *arg)
4541 : : {
4542 : : struct thread_params *tp = arg;
4543 : : uint16_t enq, deq;
4544 : : uint64_t total_time = 0, start_time;
4545 : 0 : const uint16_t queue_id = tp->queue_id;
4546 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4547 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4548 : 0 : struct rte_bbdev_enc_op **ops_enq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4549 : 0 : struct rte_bbdev_enc_op **ops_deq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4550 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
4551 : : struct test_buffers *bufs = NULL;
4552 : : int i, j, ret;
4553 : : struct rte_bbdev_info info;
4554 : : uint16_t num_to_enq;
4555 : :
4556 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4557 : : "BURST_SIZE should be <= %u", MAX_BURST);
4558 : :
4559 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4560 : :
4561 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4562 : : "NUM_OPS cannot exceed %u for this device",
4563 : : info.drv.queue_size_lim);
4564 : :
4565 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4566 : :
4567 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4568 : : rte_memory_order_relaxed);
4569 : :
4570 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
4571 : : num_ops);
4572 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
4573 : : num_ops);
4574 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4575 : 0 : copy_reference_enc_op(ops_enq, num_ops, 0, bufs->inputs,
4576 : : bufs->hard_outputs, ref_op);
4577 : :
4578 : : /* Set counter to validate the ordering */
4579 : 0 : for (j = 0; j < num_ops; ++j)
4580 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4581 : :
4582 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4583 : : uint32_t time_out = 0;
4584 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4585 : 0 : for (j = 0; j < num_ops; ++j)
4586 : 0 : mbuf_reset(ops_enq[j]->turbo_enc.output.data);
4587 : :
4588 : : start_time = rte_rdtsc_precise();
4589 : :
4590 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4591 : : num_to_enq = burst_sz;
4592 : :
4593 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4594 : 0 : num_to_enq = num_ops - enq;
4595 : :
4596 : 0 : enq += rte_bbdev_enqueue_enc_ops(tp->dev_id,
4597 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4598 : :
4599 : 0 : deq += rte_bbdev_dequeue_enc_ops(tp->dev_id,
4600 : 0 : queue_id, &ops_deq[deq], enq - deq);
4601 : 0 : time_out++;
4602 : 0 : if (time_out >= TIME_OUT_POLL) {
4603 : 0 : timeout_exit(tp->dev_id);
4604 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4605 : : }
4606 : : }
4607 : :
4608 : : /* dequeue the remaining */
4609 : : time_out = 0;
4610 : 0 : while (deq < enq) {
4611 : 0 : deq += rte_bbdev_dequeue_enc_ops(tp->dev_id,
4612 : 0 : queue_id, &ops_deq[deq], enq - deq);
4613 : 0 : time_out++;
4614 : 0 : if (time_out >= TIME_OUT_POLL) {
4615 : 0 : timeout_exit(tp->dev_id);
4616 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4617 : : }
4618 : : }
4619 : :
4620 : 0 : total_time += rte_rdtsc_precise() - start_time;
4621 : : }
4622 : :
4623 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4624 : 0 : ret = validate_enc_op(ops_deq, num_ops, ref_op);
4625 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4626 : : }
4627 : :
4628 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, num_ops);
4629 : :
4630 : 0 : double tb_len_bits = calc_enc_TB_size(ref_op);
4631 : :
4632 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4633 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4634 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits))
4635 : 0 : / 1000000.0) / ((double)total_time /
4636 : 0 : (double)rte_get_tsc_hz());
4637 : :
4638 : 0 : return TEST_SUCCESS;
4639 : : }
4640 : :
4641 : : static int
4642 : 0 : throughput_pmd_lcore_ldpc_enc(void *arg)
4643 : : {
4644 : : struct thread_params *tp = arg;
4645 : : uint16_t enq, deq;
4646 : : uint64_t total_time = 0, start_time;
4647 : 0 : const uint16_t queue_id = tp->queue_id;
4648 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4649 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4650 : 0 : struct rte_bbdev_enc_op **ops_enq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4651 : 0 : struct rte_bbdev_enc_op **ops_deq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4652 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
4653 : : struct test_buffers *bufs = NULL;
4654 : : int i, j, ret;
4655 : : struct rte_bbdev_info info;
4656 : : uint16_t num_to_enq;
4657 : :
4658 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4659 : : "BURST_SIZE should be <= %u", MAX_BURST);
4660 : :
4661 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4662 : :
4663 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4664 : : "NUM_OPS cannot exceed %u for this device",
4665 : : info.drv.queue_size_lim);
4666 : :
4667 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4668 : :
4669 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4670 : : rte_memory_order_relaxed);
4671 : :
4672 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
4673 : : num_ops);
4674 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
4675 : : num_ops);
4676 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4677 : 0 : copy_reference_ldpc_enc_op(ops_enq, num_ops, 0, bufs->inputs,
4678 : : bufs->hard_outputs, ref_op);
4679 : :
4680 : : /* Set counter to validate the ordering */
4681 : 0 : for (j = 0; j < num_ops; ++j)
4682 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4683 : :
4684 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4685 : : uint32_t time_out = 0;
4686 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4687 : 0 : for (j = 0; j < num_ops; ++j)
4688 : 0 : mbuf_reset(ops_enq[j]->turbo_enc.output.data);
4689 : :
4690 : : start_time = rte_rdtsc_precise();
4691 : :
4692 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4693 : : num_to_enq = burst_sz;
4694 : :
4695 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4696 : 0 : num_to_enq = num_ops - enq;
4697 : :
4698 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(tp->dev_id,
4699 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4700 : :
4701 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(tp->dev_id,
4702 : 0 : queue_id, &ops_deq[deq], enq - deq);
4703 : 0 : time_out++;
4704 : 0 : if (time_out >= TIME_OUT_POLL) {
4705 : 0 : timeout_exit(tp->dev_id);
4706 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4707 : : }
4708 : : }
4709 : :
4710 : : /* dequeue the remaining */
4711 : : time_out = 0;
4712 : 0 : while (deq < enq) {
4713 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(tp->dev_id,
4714 : 0 : queue_id, &ops_deq[deq], enq - deq);
4715 : 0 : time_out++;
4716 : 0 : if (time_out >= TIME_OUT_POLL) {
4717 : 0 : timeout_exit(tp->dev_id);
4718 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4719 : : }
4720 : : }
4721 : :
4722 : 0 : total_time += rte_rdtsc_precise() - start_time;
4723 : : }
4724 : :
4725 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4726 : 0 : ret = validate_ldpc_enc_op(ops_deq, num_ops, ref_op);
4727 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4728 : : }
4729 : :
4730 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, num_ops);
4731 : :
4732 : 0 : double tb_len_bits = calc_ldpc_enc_TB_size(ref_op);
4733 : :
4734 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4735 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4736 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits))
4737 : 0 : / 1000000.0) / ((double)total_time /
4738 : 0 : (double)rte_get_tsc_hz());
4739 : :
4740 : 0 : return TEST_SUCCESS;
4741 : : }
4742 : :
4743 : : static int
4744 : 0 : throughput_pmd_lcore_fft(void *arg)
4745 : : {
4746 : : struct thread_params *tp = arg;
4747 : : uint16_t enq, deq;
4748 : : uint64_t total_time = 0, start_time;
4749 : 0 : const uint16_t queue_id = tp->queue_id;
4750 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4751 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4752 : 0 : struct rte_bbdev_fft_op **ops_enq = alloca(sizeof(struct rte_bbdev_fft_op *) * num_ops);
4753 : 0 : struct rte_bbdev_fft_op **ops_deq = alloca(sizeof(struct rte_bbdev_fft_op *) * num_ops);
4754 : 0 : struct rte_bbdev_fft_op *ref_op = tp->op_params->ref_fft_op;
4755 : : struct test_buffers *bufs = NULL;
4756 : : int i, j, ret;
4757 : : struct rte_bbdev_info info;
4758 : : uint16_t num_to_enq;
4759 : :
4760 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4761 : : "BURST_SIZE should be <= %u", MAX_BURST);
4762 : :
4763 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4764 : :
4765 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4766 : : "NUM_OPS cannot exceed %u for this device",
4767 : : info.drv.queue_size_lim);
4768 : :
4769 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4770 : :
4771 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4772 : : rte_memory_order_relaxed);
4773 : :
4774 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4775 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4776 : :
4777 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4778 : 0 : copy_reference_fft_op(ops_enq, num_ops, 0, bufs->inputs,
4779 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs, ref_op);
4780 : :
4781 : : /* Set counter to validate the ordering */
4782 : 0 : for (j = 0; j < num_ops; ++j)
4783 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4784 : :
4785 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4786 : : uint32_t time_out = 0;
4787 : 0 : for (j = 0; j < num_ops; ++j)
4788 : 0 : mbuf_reset(ops_enq[j]->fft.base_output.data);
4789 : :
4790 : : start_time = rte_rdtsc_precise();
4791 : :
4792 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4793 : : num_to_enq = burst_sz;
4794 : :
4795 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4796 : 0 : num_to_enq = num_ops - enq;
4797 : :
4798 : 0 : enq += rte_bbdev_enqueue_fft_ops(tp->dev_id,
4799 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4800 : :
4801 : 0 : deq += rte_bbdev_dequeue_fft_ops(tp->dev_id,
4802 : 0 : queue_id, &ops_deq[deq], enq - deq);
4803 : 0 : time_out++;
4804 : 0 : if (time_out >= TIME_OUT_POLL) {
4805 : 0 : timeout_exit(tp->dev_id);
4806 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4807 : : }
4808 : : }
4809 : :
4810 : : /* dequeue the remaining */
4811 : : time_out = 0;
4812 : 0 : while (deq < enq) {
4813 : 0 : deq += rte_bbdev_dequeue_fft_ops(tp->dev_id,
4814 : 0 : queue_id, &ops_deq[deq], enq - deq);
4815 : 0 : time_out++;
4816 : 0 : if (time_out >= TIME_OUT_POLL) {
4817 : 0 : timeout_exit(tp->dev_id);
4818 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4819 : : }
4820 : : }
4821 : :
4822 : 0 : total_time += rte_rdtsc_precise() - start_time;
4823 : : }
4824 : :
4825 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4826 : 0 : ret = validate_fft_op(ops_deq, num_ops, ref_op);
4827 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4828 : : }
4829 : :
4830 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, num_ops);
4831 : :
4832 : 0 : double tb_len_bits = calc_fft_size(ref_op);
4833 : :
4834 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4835 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4836 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4837 : 0 : 1000000.0) / ((double)total_time /
4838 : 0 : (double)rte_get_tsc_hz());
4839 : :
4840 : 0 : return TEST_SUCCESS;
4841 : : }
4842 : :
4843 : : static int
4844 : 0 : throughput_pmd_lcore_mldts(void *arg)
4845 : : {
4846 : : struct thread_params *tp = arg;
4847 : : uint16_t enq, deq;
4848 : : uint64_t total_time = 0, start_time;
4849 : 0 : const uint16_t queue_id = tp->queue_id;
4850 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4851 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4852 : 0 : struct rte_bbdev_mldts_op **ops_enq = alloca(sizeof(struct rte_bbdev_mldts_op *) * num_ops);
4853 : 0 : struct rte_bbdev_mldts_op **ops_deq = alloca(sizeof(struct rte_bbdev_mldts_op *) * num_ops);
4854 : 0 : struct rte_bbdev_mldts_op *ref_op = tp->op_params->ref_mldts_op;
4855 : : struct test_buffers *bufs = NULL;
4856 : : int i, j, ret;
4857 : : struct rte_bbdev_info info;
4858 : : uint16_t num_to_enq;
4859 : :
4860 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST), "BURST_SIZE should be <= %u", MAX_BURST);
4861 : :
4862 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4863 : :
4864 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4865 : : "NUM_OPS cannot exceed %u for this device",
4866 : : info.drv.queue_size_lim);
4867 : :
4868 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4869 : :
4870 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4871 : : rte_memory_order_relaxed);
4872 : :
4873 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4874 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4875 : :
4876 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4877 : 0 : copy_reference_mldts_op(ops_enq, num_ops, 0, bufs->inputs, bufs->harq_inputs,
4878 : : bufs->hard_outputs, ref_op);
4879 : :
4880 : : /* Set counter to validate the ordering */
4881 : 0 : for (j = 0; j < num_ops; ++j)
4882 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4883 : :
4884 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4885 : : uint32_t time_out = 0;
4886 : 0 : for (j = 0; j < num_ops; ++j)
4887 : 0 : mbuf_reset(ops_enq[j]->mldts.output.data);
4888 : :
4889 : : start_time = rte_rdtsc_precise();
4890 : :
4891 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4892 : : num_to_enq = burst_sz;
4893 : :
4894 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4895 : 0 : num_to_enq = num_ops - enq;
4896 : :
4897 : 0 : enq += rte_bbdev_enqueue_mldts_ops(tp->dev_id,
4898 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4899 : :
4900 : 0 : deq += rte_bbdev_dequeue_mldts_ops(tp->dev_id,
4901 : 0 : queue_id, &ops_deq[deq], enq - deq);
4902 : 0 : time_out++;
4903 : 0 : if (time_out >= TIME_OUT_POLL) {
4904 : 0 : timeout_exit(tp->dev_id);
4905 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4906 : : }
4907 : : }
4908 : :
4909 : : /* dequeue the remaining */
4910 : : time_out = 0;
4911 : 0 : while (deq < enq) {
4912 : 0 : deq += rte_bbdev_dequeue_mldts_ops(tp->dev_id,
4913 : 0 : queue_id, &ops_deq[deq], enq - deq);
4914 : 0 : time_out++;
4915 : 0 : if (time_out >= TIME_OUT_POLL) {
4916 : 0 : timeout_exit(tp->dev_id);
4917 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4918 : : }
4919 : : }
4920 : :
4921 : 0 : total_time += rte_rdtsc_precise() - start_time;
4922 : : }
4923 : :
4924 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4925 : 0 : ret = validate_mldts_op(ops_deq, num_ops, ref_op);
4926 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4927 : : }
4928 : :
4929 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, num_ops);
4930 : :
4931 : 0 : double tb_len_bits = calc_mldts_size(ref_op);
4932 : :
4933 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4934 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4935 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4936 : 0 : 1000000.0) / ((double)total_time /
4937 : 0 : (double)rte_get_tsc_hz());
4938 : :
4939 : 0 : return TEST_SUCCESS;
4940 : : }
4941 : :
4942 : : static void
4943 : 0 : print_enc_throughput(struct thread_params *t_params, unsigned int used_cores)
4944 : : {
4945 : : unsigned int iter = 0;
4946 : : double total_mops = 0, total_mbps = 0;
4947 : :
4948 : 0 : for (iter = 0; iter < used_cores; iter++) {
4949 : 0 : printf(
4950 : : "Throughput for core (%u): %.8lg Ops/s, %.8lg Mbps\n",
4951 : : t_params[iter].lcore_id, t_params[iter].ops_per_sec,
4952 : 0 : t_params[iter].mbps);
4953 : 0 : total_mops += t_params[iter].ops_per_sec;
4954 : 0 : total_mbps += t_params[iter].mbps;
4955 : : }
4956 : : printf(
4957 : : "\nTotal throughput for %u cores: %.8lg MOPS, %.8lg Mbps\n",
4958 : : used_cores, total_mops, total_mbps);
4959 : 0 : }
4960 : :
4961 : : /* Aggregate the performance results over the number of cores used */
4962 : : static void
4963 : 0 : print_dec_throughput(struct thread_params *t_params, unsigned int used_cores)
4964 : : {
4965 : : unsigned int core_idx = 0;
4966 : : double total_mops = 0, total_mbps = 0;
4967 : : uint8_t iter_count = 0;
4968 : :
4969 : 0 : for (core_idx = 0; core_idx < used_cores; core_idx++) {
4970 : 0 : printf(
4971 : : "Throughput for core (%u): %.8lg Ops/s, %.8lg Mbps @ max %u iterations\n",
4972 : : t_params[core_idx].lcore_id,
4973 : : t_params[core_idx].ops_per_sec,
4974 : : t_params[core_idx].mbps,
4975 : 0 : t_params[core_idx].iter_count);
4976 : 0 : total_mops += t_params[core_idx].ops_per_sec;
4977 : 0 : total_mbps += t_params[core_idx].mbps;
4978 : 0 : iter_count = RTE_MAX(iter_count,
4979 : : t_params[core_idx].iter_count);
4980 : : }
4981 : 0 : printf(
4982 : : "\nTotal throughput for %u cores: %.8lg MOPS, %.8lg Mbps @ max %u iterations\n",
4983 : : used_cores, total_mops, total_mbps, iter_count);
4984 : 0 : }
4985 : :
4986 : : /* Aggregate the performance results over the number of cores used */
4987 : : static void
4988 : 0 : print_dec_bler(struct thread_params *t_params, unsigned int used_cores)
4989 : : {
4990 : : unsigned int core_idx = 0;
4991 : : double total_mbps = 0, total_bler = 0, total_iter = 0;
4992 : 0 : double snr = get_snr();
4993 : :
4994 : 0 : for (core_idx = 0; core_idx < used_cores; core_idx++) {
4995 : 0 : printf("Core%u BLER %.1f %% - Iters %.1f - Tp %.1f Mbps %s\n",
4996 : : t_params[core_idx].lcore_id,
4997 : 0 : t_params[core_idx].bler * 100,
4998 : : t_params[core_idx].iter_average,
4999 : 0 : t_params[core_idx].mbps,
5000 : : get_vector_filename());
5001 : 0 : total_mbps += t_params[core_idx].mbps;
5002 : 0 : total_bler += t_params[core_idx].bler;
5003 : 0 : total_iter += t_params[core_idx].iter_average;
5004 : : }
5005 : 0 : total_bler /= used_cores;
5006 : 0 : total_iter /= used_cores;
5007 : :
5008 : 0 : printf("SNR %.2f BLER %.1f %% - Iterations %.1f %d - Tp %.3f Mbps %s\n",
5009 : : snr, total_bler * 100, total_iter, get_iter_max(),
5010 : : total_mbps, get_vector_filename());
5011 : 0 : }
5012 : :
5013 : : /*
5014 : : * Test function that determines BLER wireless performance
5015 : : */
5016 : : static int
5017 : 0 : bler_test(struct active_device *ad,
5018 : : struct test_op_params *op_params)
5019 : : {
5020 : : int ret;
5021 : : unsigned int lcore_id, used_cores = 0;
5022 : : struct thread_params *t_params;
5023 : : struct rte_bbdev_info info;
5024 : : lcore_function_t *bler_function;
5025 : : uint16_t num_lcores;
5026 : : const char *op_type_str;
5027 : :
5028 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5029 : :
5030 : 0 : op_type_str = rte_bbdev_op_type_str(test_vector.op_type);
5031 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u",
5032 : : test_vector.op_type);
5033 : :
5034 : : printf("+ ------------------------------------------------------- +\n");
5035 : 0 : printf("== test: bler\ndev: %s, nb_queues: %u, burst size: %u, num ops: %u, num_lcores: %u, op type: %s, itr mode: %s, GHz: %lg\n",
5036 : 0 : info.dev_name, ad->nb_queues, op_params->burst_sz,
5037 : 0 : op_params->num_to_process, op_params->num_lcores,
5038 : : op_type_str,
5039 : 0 : intr_enabled ? "Interrupt mode" : "PMD mode",
5040 : 0 : (double)rte_get_tsc_hz() / 1000000000.0);
5041 : :
5042 : : /* Set number of lcores */
5043 : 0 : num_lcores = (ad->nb_queues < (op_params->num_lcores))
5044 : : ? ad->nb_queues
5045 : : : op_params->num_lcores;
5046 : :
5047 : : /* Allocate memory for thread parameters structure */
5048 : 0 : t_params = rte_zmalloc(NULL, num_lcores * sizeof(struct thread_params),
5049 : : RTE_CACHE_LINE_SIZE);
5050 : 0 : TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params",
5051 : : RTE_ALIGN(sizeof(struct thread_params) * num_lcores,
5052 : : RTE_CACHE_LINE_SIZE));
5053 : :
5054 : 0 : if ((test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) &&
5055 : 0 : !check_bit(test_vector.ldpc_dec.op_flags,
5056 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
5057 : 0 : && !check_bit(test_vector.ldpc_dec.op_flags,
5058 : : RTE_BBDEV_LDPC_LLR_COMPRESSION))
5059 : : bler_function = bler_pmd_lcore_ldpc_dec;
5060 : 0 : else if ((test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) &&
5061 : 0 : !check_bit(test_vector.turbo_dec.op_flags,
5062 : : RTE_BBDEV_TURBO_SOFT_OUTPUT))
5063 : : bler_function = bler_pmd_lcore_turbo_dec;
5064 : : else
5065 : : return TEST_SKIPPED;
5066 : :
5067 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
5068 : :
5069 : : /* Main core is set at first entry */
5070 : 0 : t_params[0].dev_id = ad->dev_id;
5071 : 0 : t_params[0].lcore_id = rte_lcore_id();
5072 : 0 : t_params[0].op_params = op_params;
5073 : 0 : t_params[0].queue_id = ad->queue_ids[used_cores++];
5074 : 0 : t_params[0].iter_count = 0;
5075 : :
5076 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
5077 : 0 : if (used_cores >= num_lcores)
5078 : : break;
5079 : :
5080 : 0 : t_params[used_cores].dev_id = ad->dev_id;
5081 : 0 : t_params[used_cores].lcore_id = lcore_id;
5082 : 0 : t_params[used_cores].op_params = op_params;
5083 : 0 : t_params[used_cores].queue_id = ad->queue_ids[used_cores];
5084 : 0 : t_params[used_cores].iter_count = 0;
5085 : :
5086 : 0 : rte_eal_remote_launch(bler_function,
5087 : 0 : &t_params[used_cores++], lcore_id);
5088 : : }
5089 : :
5090 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
5091 : 0 : ret = bler_function(&t_params[0]);
5092 : :
5093 : : /* Main core is always used */
5094 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++)
5095 : 0 : ret |= rte_eal_wait_lcore(t_params[used_cores].lcore_id);
5096 : :
5097 : 0 : print_dec_bler(t_params, num_lcores);
5098 : :
5099 : : /* Return if test failed */
5100 : 0 : if (ret) {
5101 : 0 : rte_free(t_params);
5102 : 0 : return ret;
5103 : : }
5104 : :
5105 : : /* Function to print something here*/
5106 : 0 : rte_free(t_params);
5107 : 0 : return ret;
5108 : : }
5109 : :
5110 : : /*
5111 : : * Test function that determines how long an enqueue + dequeue of a burst
5112 : : * takes on available lcores.
5113 : : */
5114 : : static int
5115 : 0 : throughput_test(struct active_device *ad,
5116 : : struct test_op_params *op_params)
5117 : : {
5118 : : int ret;
5119 : : unsigned int lcore_id, used_cores = 0;
5120 : : struct thread_params *t_params, *tp;
5121 : : struct rte_bbdev_info info;
5122 : : lcore_function_t *throughput_function;
5123 : : uint16_t num_lcores;
5124 : : const char *op_type_str;
5125 : :
5126 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5127 : :
5128 : 0 : op_type_str = rte_bbdev_op_type_str(test_vector.op_type);
5129 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u",
5130 : : test_vector.op_type);
5131 : :
5132 : : printf("+ ------------------------------------------------------- +\n");
5133 : 0 : printf("== test: throughput\ndev: %s, nb_queues: %u, burst size: %u, num ops: %u, num_lcores: %u, op type: %s, itr mode: %s, GHz: %lg\n",
5134 : 0 : info.dev_name, ad->nb_queues, op_params->burst_sz,
5135 : 0 : op_params->num_to_process, op_params->num_lcores,
5136 : : op_type_str,
5137 : 0 : intr_enabled ? "Interrupt mode" : "PMD mode",
5138 : 0 : (double)rte_get_tsc_hz() / 1000000000.0);
5139 : :
5140 : : /* Set number of lcores */
5141 : 0 : num_lcores = (ad->nb_queues < (op_params->num_lcores))
5142 : : ? ad->nb_queues
5143 : : : op_params->num_lcores;
5144 : :
5145 : : /* Allocate memory for thread parameters structure */
5146 : 0 : t_params = rte_zmalloc(NULL, num_lcores * sizeof(struct thread_params),
5147 : : RTE_CACHE_LINE_SIZE);
5148 : 0 : TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params",
5149 : : RTE_ALIGN(sizeof(struct thread_params) * num_lcores,
5150 : : RTE_CACHE_LINE_SIZE));
5151 : :
5152 : 0 : if (intr_enabled) {
5153 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
5154 : : throughput_function = throughput_intr_lcore_dec;
5155 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5156 : : throughput_function = throughput_intr_lcore_ldpc_dec;
5157 : : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
5158 : : throughput_function = throughput_intr_lcore_enc;
5159 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5160 : : throughput_function = throughput_intr_lcore_ldpc_enc;
5161 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
5162 : : throughput_function = throughput_intr_lcore_fft;
5163 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
5164 : : throughput_function = throughput_intr_lcore_mldts;
5165 : : else
5166 : : throughput_function = throughput_intr_lcore_enc;
5167 : :
5168 : : /* Dequeue interrupt callback registration */
5169 : 0 : ret = rte_bbdev_callback_register(ad->dev_id,
5170 : : RTE_BBDEV_EVENT_DEQUEUE, dequeue_event_callback,
5171 : : t_params);
5172 : 0 : if (ret < 0) {
5173 : 0 : rte_free(t_params);
5174 : 0 : return ret;
5175 : : }
5176 : : } else {
5177 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
5178 : : throughput_function = throughput_pmd_lcore_dec;
5179 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5180 : : throughput_function = throughput_pmd_lcore_ldpc_dec;
5181 : : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
5182 : : throughput_function = throughput_pmd_lcore_enc;
5183 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5184 : : throughput_function = throughput_pmd_lcore_ldpc_enc;
5185 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
5186 : : throughput_function = throughput_pmd_lcore_fft;
5187 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
5188 : : throughput_function = throughput_pmd_lcore_mldts;
5189 : : else
5190 : : throughput_function = throughput_pmd_lcore_enc;
5191 : : }
5192 : :
5193 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
5194 : :
5195 : : /* Main core is set at first entry */
5196 : 0 : t_params[0].dev_id = ad->dev_id;
5197 : 0 : t_params[0].lcore_id = rte_lcore_id();
5198 : 0 : t_params[0].op_params = op_params;
5199 : 0 : t_params[0].queue_id = ad->queue_ids[used_cores++];
5200 : 0 : t_params[0].iter_count = 0;
5201 : :
5202 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
5203 : 0 : if (used_cores >= num_lcores)
5204 : : break;
5205 : :
5206 : 0 : t_params[used_cores].dev_id = ad->dev_id;
5207 : 0 : t_params[used_cores].lcore_id = lcore_id;
5208 : 0 : t_params[used_cores].op_params = op_params;
5209 : 0 : t_params[used_cores].queue_id = ad->queue_ids[used_cores];
5210 : 0 : t_params[used_cores].iter_count = 0;
5211 : :
5212 : 0 : rte_eal_remote_launch(throughput_function,
5213 : 0 : &t_params[used_cores++], lcore_id);
5214 : : }
5215 : :
5216 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
5217 : 0 : ret = throughput_function(&t_params[0]);
5218 : :
5219 : : /* Main core is always used */
5220 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++)
5221 : 0 : ret |= rte_eal_wait_lcore(t_params[used_cores].lcore_id);
5222 : :
5223 : : /* Return if test failed */
5224 : 0 : if (ret) {
5225 : 0 : rte_free(t_params);
5226 : 0 : return ret;
5227 : : }
5228 : :
5229 : : /* Print throughput if interrupts are disabled and test passed */
5230 : 0 : if (!intr_enabled) {
5231 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC ||
5232 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5233 : 0 : print_dec_throughput(t_params, num_lcores);
5234 : : else
5235 : 0 : print_enc_throughput(t_params, num_lcores);
5236 : 0 : rte_free(t_params);
5237 : 0 : return ret;
5238 : : }
5239 : :
5240 : : /* In interrupt TC we need to wait for the interrupt callback to deqeue
5241 : : * all pending operations. Skip waiting for queues which reported an
5242 : : * error using processing_status variable.
5243 : : * Wait for main lcore operations.
5244 : : */
5245 : : tp = &t_params[0];
5246 : 0 : while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
5247 : 0 : op_params->num_to_process) &&
5248 : 0 : (rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed) !=
5249 : : TEST_FAILED))
5250 : : rte_pause();
5251 : :
5252 : 0 : tp->ops_per_sec /= TEST_REPETITIONS;
5253 : 0 : tp->mbps /= TEST_REPETITIONS;
5254 : 0 : ret |= (int)rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed);
5255 : :
5256 : : /* Wait for worker lcores operations */
5257 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++) {
5258 : 0 : tp = &t_params[used_cores];
5259 : :
5260 : 0 : while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
5261 : 0 : op_params->num_to_process) &&
5262 : 0 : (rte_atomic_load_explicit(&tp->processing_status,
5263 : : rte_memory_order_relaxed) != TEST_FAILED))
5264 : : rte_pause();
5265 : :
5266 : 0 : tp->ops_per_sec /= TEST_REPETITIONS;
5267 : 0 : tp->mbps /= TEST_REPETITIONS;
5268 : 0 : ret |= (int)rte_atomic_load_explicit(&tp->processing_status,
5269 : : rte_memory_order_relaxed);
5270 : : }
5271 : :
5272 : : /* Print throughput if test passed */
5273 : 0 : if (!ret) {
5274 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC ||
5275 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5276 : 0 : print_dec_throughput(t_params, num_lcores);
5277 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC ||
5278 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5279 : 0 : print_enc_throughput(t_params, num_lcores);
5280 : : }
5281 : :
5282 : 0 : rte_free(t_params);
5283 : 0 : return ret;
5284 : : }
5285 : :
5286 : : static int
5287 : 0 : latency_test_dec(struct rte_mempool *mempool,
5288 : : struct test_buffers *bufs, struct rte_bbdev_dec_op *ref_op,
5289 : : uint16_t dev_id, uint16_t queue_id,
5290 : : const uint16_t num_to_process, uint16_t burst_sz,
5291 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time, bool disable_et)
5292 : : {
5293 : : int ret = TEST_SUCCESS;
5294 : : uint16_t i, j, dequeued;
5295 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5296 : : uint64_t start_time = 0, last_time = 0;
5297 : :
5298 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5299 : : uint16_t enq = 0, deq = 0;
5300 : : uint32_t time_out = 0;
5301 : : bool first_time = true;
5302 : : last_time = 0;
5303 : :
5304 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5305 : 0 : burst_sz = num_to_process - dequeued;
5306 : :
5307 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
5308 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
5309 : :
5310 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
5311 : : /* For validation tests we want to enable early termination */
5312 : 0 : if (!disable_et && !check_bit(ref_op->turbo_dec.op_flags,
5313 : : RTE_BBDEV_TURBO_EARLY_TERMINATION))
5314 : 0 : ref_op->turbo_dec.op_flags |= RTE_BBDEV_TURBO_EARLY_TERMINATION;
5315 : :
5316 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5317 : 0 : copy_reference_dec_op(ops_enq, burst_sz, dequeued,
5318 : : bufs->inputs,
5319 : : bufs->hard_outputs,
5320 : : bufs->soft_outputs,
5321 : : ref_op);
5322 : :
5323 : : /* Set counter to validate the ordering */
5324 : 0 : for (j = 0; j < burst_sz; ++j)
5325 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5326 : :
5327 : : start_time = rte_rdtsc_precise();
5328 : :
5329 : 0 : enq = rte_bbdev_enqueue_dec_ops(dev_id, queue_id, &ops_enq[enq],
5330 : : burst_sz);
5331 : 0 : TEST_ASSERT(enq == burst_sz,
5332 : : "Error enqueueing burst, expected %u, got %u",
5333 : : burst_sz, enq);
5334 : :
5335 : : /* Dequeue */
5336 : : do {
5337 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
5338 : 0 : &ops_deq[deq], burst_sz - deq);
5339 : 0 : if (likely(first_time && (deq > 0))) {
5340 : 0 : last_time = rte_rdtsc_precise() - start_time;
5341 : : first_time = false;
5342 : : }
5343 : 0 : time_out++;
5344 : 0 : if (time_out >= TIME_OUT_POLL) {
5345 : 0 : timeout_exit(dev_id);
5346 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5347 : : }
5348 : 0 : } while (unlikely(burst_sz != deq));
5349 : :
5350 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5351 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5352 : 0 : *total_time += last_time;
5353 : :
5354 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5355 : 0 : ret = validate_dec_op(ops_deq, burst_sz, ref_op);
5356 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5357 : : }
5358 : :
5359 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
5360 : 0 : dequeued += deq;
5361 : : }
5362 : :
5363 : 0 : return i;
5364 : : }
5365 : :
5366 : : /* Test case for latency/validation for LDPC Decoder */
5367 : : static int
5368 : 0 : latency_test_ldpc_dec(struct rte_mempool *mempool,
5369 : : struct test_buffers *bufs, struct rte_bbdev_dec_op *ref_op,
5370 : : int vector_mask, uint16_t dev_id, uint16_t queue_id,
5371 : : const uint16_t num_to_process, uint16_t burst_sz,
5372 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time,
5373 : : bool disable_et)
5374 : : {
5375 : : int ret = TEST_SUCCESS;
5376 : : uint16_t i, j, dequeued;
5377 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5378 : : uint64_t start_time = 0, last_time = 0;
5379 : 0 : bool extDdr = ldpc_cap_flags &
5380 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
5381 : :
5382 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5383 : : uint16_t enq = 0, deq = 0;
5384 : : uint32_t time_out = 0;
5385 : : bool first_time = true;
5386 : : last_time = 0;
5387 : :
5388 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5389 : 0 : burst_sz = num_to_process - dequeued;
5390 : :
5391 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
5392 : 0 : TEST_ASSERT_SUCCESS(ret,
5393 : : "rte_bbdev_dec_op_alloc_bulk() failed");
5394 : :
5395 : : /* For latency tests we need to disable early termination */
5396 : 0 : if (disable_et && check_bit(ref_op->ldpc_dec.op_flags,
5397 : : RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
5398 : 0 : ref_op->ldpc_dec.op_flags -= RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
5399 : :
5400 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
5401 : : /* When ET is disabled, the expected iter_count is iter_max */
5402 : 0 : if (disable_et)
5403 : 0 : ref_op->ldpc_dec.iter_count = ref_op->ldpc_dec.iter_max;
5404 : :
5405 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5406 : 0 : copy_reference_ldpc_dec_op(ops_enq, burst_sz, dequeued,
5407 : : bufs->inputs,
5408 : : bufs->hard_outputs,
5409 : : bufs->soft_outputs,
5410 : : bufs->harq_inputs,
5411 : : bufs->harq_outputs,
5412 : : ref_op);
5413 : :
5414 : 0 : if (extDdr)
5415 : 0 : preload_harq_ddr(dev_id, queue_id, ops_enq,
5416 : : burst_sz, true);
5417 : :
5418 : : /* Set counter to validate the ordering */
5419 : 0 : for (j = 0; j < burst_sz; ++j)
5420 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5421 : :
5422 : : start_time = rte_rdtsc_precise();
5423 : :
5424 : 0 : enq = rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
5425 : : &ops_enq[enq], burst_sz);
5426 : 0 : TEST_ASSERT(enq == burst_sz,
5427 : : "Error enqueueing burst, expected %u, got %u",
5428 : : burst_sz, enq);
5429 : :
5430 : : /* Dequeue */
5431 : : do {
5432 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
5433 : 0 : &ops_deq[deq], burst_sz - deq);
5434 : 0 : if (likely(first_time && (deq > 0))) {
5435 : 0 : last_time = rte_rdtsc_precise() - start_time;
5436 : : first_time = false;
5437 : : }
5438 : 0 : time_out++;
5439 : 0 : if (time_out >= TIME_OUT_POLL) {
5440 : 0 : timeout_exit(dev_id);
5441 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5442 : : }
5443 : 0 : } while (unlikely(burst_sz != deq));
5444 : :
5445 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5446 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5447 : 0 : *total_time += last_time;
5448 : :
5449 : 0 : if (extDdr)
5450 : 0 : retrieve_harq_ddr(dev_id, queue_id, ops_enq, burst_sz);
5451 : :
5452 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5453 : 0 : ret = validate_ldpc_dec_op(ops_deq, burst_sz, ref_op, vector_mask);
5454 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5455 : : }
5456 : :
5457 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
5458 : 0 : dequeued += deq;
5459 : : }
5460 : 0 : return i;
5461 : : }
5462 : :
5463 : : static int
5464 : 0 : latency_test_enc(struct rte_mempool *mempool,
5465 : : struct test_buffers *bufs, struct rte_bbdev_enc_op *ref_op,
5466 : : uint16_t dev_id, uint16_t queue_id,
5467 : : const uint16_t num_to_process, uint16_t burst_sz,
5468 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5469 : : {
5470 : : int ret = TEST_SUCCESS;
5471 : : uint16_t i, j, dequeued;
5472 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5473 : : uint64_t start_time = 0, last_time = 0;
5474 : :
5475 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5476 : : uint16_t enq = 0, deq = 0;
5477 : : uint32_t time_out = 0;
5478 : : bool first_time = true;
5479 : : last_time = 0;
5480 : :
5481 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5482 : 0 : burst_sz = num_to_process - dequeued;
5483 : :
5484 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
5485 : 0 : TEST_ASSERT_SUCCESS(ret,
5486 : : "rte_bbdev_enc_op_alloc_bulk() failed");
5487 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5488 : 0 : copy_reference_enc_op(ops_enq, burst_sz, dequeued,
5489 : : bufs->inputs,
5490 : : bufs->hard_outputs,
5491 : : ref_op);
5492 : :
5493 : : /* Set counter to validate the ordering */
5494 : 0 : for (j = 0; j < burst_sz; ++j)
5495 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5496 : :
5497 : : start_time = rte_rdtsc_precise();
5498 : :
5499 : 0 : enq = rte_bbdev_enqueue_enc_ops(dev_id, queue_id, &ops_enq[enq],
5500 : : burst_sz);
5501 : 0 : TEST_ASSERT(enq == burst_sz,
5502 : : "Error enqueueing burst, expected %u, got %u",
5503 : : burst_sz, enq);
5504 : :
5505 : : /* Dequeue */
5506 : : do {
5507 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
5508 : 0 : &ops_deq[deq], burst_sz - deq);
5509 : 0 : if (likely(first_time && (deq > 0))) {
5510 : 0 : last_time += rte_rdtsc_precise() - start_time;
5511 : : first_time = false;
5512 : : }
5513 : 0 : time_out++;
5514 : 0 : if (time_out >= TIME_OUT_POLL) {
5515 : 0 : timeout_exit(dev_id);
5516 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5517 : : }
5518 : 0 : } while (unlikely(burst_sz != deq));
5519 : :
5520 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5521 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5522 : 0 : *total_time += last_time;
5523 : :
5524 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5525 : 0 : ret = validate_enc_op(ops_deq, burst_sz, ref_op);
5526 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5527 : : }
5528 : :
5529 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
5530 : 0 : dequeued += deq;
5531 : : }
5532 : :
5533 : 0 : return i;
5534 : : }
5535 : :
5536 : : static int
5537 : 0 : latency_test_ldpc_enc(struct rte_mempool *mempool,
5538 : : struct test_buffers *bufs, struct rte_bbdev_enc_op *ref_op,
5539 : : uint16_t dev_id, uint16_t queue_id,
5540 : : const uint16_t num_to_process, uint16_t burst_sz,
5541 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5542 : : {
5543 : : int ret = TEST_SUCCESS;
5544 : : uint16_t i, j, dequeued;
5545 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5546 : : uint64_t start_time = 0, last_time = 0;
5547 : :
5548 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5549 : : uint16_t enq = 0, deq = 0;
5550 : : uint32_t time_out = 0;
5551 : : bool first_time = true;
5552 : : last_time = 0;
5553 : :
5554 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5555 : 0 : burst_sz = num_to_process - dequeued;
5556 : :
5557 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
5558 : 0 : TEST_ASSERT_SUCCESS(ret,
5559 : : "rte_bbdev_enc_op_alloc_bulk() failed");
5560 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5561 : 0 : copy_reference_ldpc_enc_op(ops_enq, burst_sz, dequeued,
5562 : : bufs->inputs,
5563 : : bufs->hard_outputs,
5564 : : ref_op);
5565 : :
5566 : : /* Set counter to validate the ordering */
5567 : 0 : for (j = 0; j < burst_sz; ++j)
5568 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5569 : :
5570 : : start_time = rte_rdtsc_precise();
5571 : :
5572 : 0 : enq = rte_bbdev_enqueue_ldpc_enc_ops(dev_id, queue_id,
5573 : : &ops_enq[enq], burst_sz);
5574 : 0 : TEST_ASSERT(enq == burst_sz,
5575 : : "Error enqueueing burst, expected %u, got %u",
5576 : : burst_sz, enq);
5577 : :
5578 : : /* Dequeue */
5579 : : do {
5580 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
5581 : 0 : &ops_deq[deq], burst_sz - deq);
5582 : 0 : if (likely(first_time && (deq > 0))) {
5583 : 0 : last_time += rte_rdtsc_precise() - start_time;
5584 : : first_time = false;
5585 : : }
5586 : 0 : time_out++;
5587 : 0 : if (time_out >= TIME_OUT_POLL) {
5588 : 0 : timeout_exit(dev_id);
5589 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5590 : : }
5591 : 0 : } while (unlikely(burst_sz != deq));
5592 : :
5593 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5594 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5595 : 0 : *total_time += last_time;
5596 : :
5597 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5598 : 0 : ret = validate_enc_op(ops_deq, burst_sz, ref_op);
5599 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5600 : : }
5601 : :
5602 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
5603 : 0 : dequeued += deq;
5604 : : }
5605 : :
5606 : 0 : return i;
5607 : : }
5608 : :
5609 : :
5610 : : static int
5611 : 0 : latency_test_fft(struct rte_mempool *mempool,
5612 : : struct test_buffers *bufs, struct rte_bbdev_fft_op *ref_op,
5613 : : uint16_t dev_id, uint16_t queue_id,
5614 : : const uint16_t num_to_process, uint16_t burst_sz,
5615 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5616 : : {
5617 : : int ret = TEST_SUCCESS;
5618 : : uint16_t i, j, dequeued;
5619 : : struct rte_bbdev_fft_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5620 : : uint64_t start_time = 0, last_time = 0;
5621 : :
5622 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5623 : : uint16_t enq = 0, deq = 0;
5624 : : uint32_t time_out = 0;
5625 : : bool first_time = true;
5626 : : last_time = 0;
5627 : :
5628 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5629 : 0 : burst_sz = num_to_process - dequeued;
5630 : :
5631 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(mempool, ops_enq, burst_sz);
5632 : 0 : TEST_ASSERT_SUCCESS(ret,
5633 : : "rte_bbdev_fft_op_alloc_bulk() failed");
5634 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5635 : 0 : copy_reference_fft_op(ops_enq, burst_sz, dequeued,
5636 : : bufs->inputs,
5637 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
5638 : : ref_op);
5639 : :
5640 : : /* Set counter to validate the ordering */
5641 : 0 : for (j = 0; j < burst_sz; ++j)
5642 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5643 : :
5644 : : start_time = rte_rdtsc_precise();
5645 : :
5646 : 0 : enq = rte_bbdev_enqueue_fft_ops(dev_id, queue_id,
5647 : : &ops_enq[enq], burst_sz);
5648 : 0 : TEST_ASSERT(enq == burst_sz,
5649 : : "Error enqueueing burst, expected %u, got %u",
5650 : : burst_sz, enq);
5651 : :
5652 : : /* Dequeue */
5653 : : do {
5654 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5655 : 0 : &ops_deq[deq], burst_sz - deq);
5656 : 0 : if (likely(first_time && (deq > 0))) {
5657 : 0 : last_time += rte_rdtsc_precise() - start_time;
5658 : : first_time = false;
5659 : : }
5660 : 0 : time_out++;
5661 : 0 : if (time_out >= TIME_OUT_POLL) {
5662 : 0 : timeout_exit(dev_id);
5663 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5664 : : }
5665 : 0 : } while (unlikely(burst_sz != deq));
5666 : :
5667 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5668 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5669 : 0 : *total_time += last_time;
5670 : :
5671 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5672 : 0 : ret = validate_fft_op(ops_deq, burst_sz, ref_op);
5673 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5674 : : }
5675 : :
5676 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, deq);
5677 : 0 : dequeued += deq;
5678 : : }
5679 : :
5680 : 0 : return i;
5681 : : }
5682 : :
5683 : : static int
5684 : 0 : latency_test_mldts(struct rte_mempool *mempool,
5685 : : struct test_buffers *bufs, struct rte_bbdev_mldts_op *ref_op,
5686 : : uint16_t dev_id, uint16_t queue_id,
5687 : : const uint16_t num_to_process, uint16_t burst_sz,
5688 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5689 : : {
5690 : : int ret = TEST_SUCCESS;
5691 : : uint16_t i, j, dequeued;
5692 : : struct rte_bbdev_mldts_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5693 : : uint64_t start_time = 0, last_time = 0;
5694 : :
5695 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5696 : : uint16_t enq = 0, deq = 0;
5697 : : uint32_t time_out = 0;
5698 : : bool first_time = true;
5699 : : last_time = 0;
5700 : :
5701 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5702 : 0 : burst_sz = num_to_process - dequeued;
5703 : :
5704 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(mempool, ops_enq, burst_sz);
5705 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_mldts_op_alloc_bulk() failed");
5706 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5707 : 0 : copy_reference_mldts_op(ops_enq, burst_sz, dequeued,
5708 : : bufs->inputs, bufs->harq_inputs,
5709 : : bufs->hard_outputs,
5710 : : ref_op);
5711 : :
5712 : : /* Set counter to validate the ordering */
5713 : 0 : for (j = 0; j < burst_sz; ++j)
5714 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5715 : :
5716 : : start_time = rte_rdtsc_precise();
5717 : :
5718 : 0 : enq = rte_bbdev_enqueue_mldts_ops(dev_id, queue_id, &ops_enq[enq], burst_sz);
5719 : 0 : TEST_ASSERT(enq == burst_sz,
5720 : : "Error enqueueing burst, expected %u, got %u",
5721 : : burst_sz, enq);
5722 : :
5723 : : /* Dequeue */
5724 : : do {
5725 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
5726 : 0 : &ops_deq[deq], burst_sz - deq);
5727 : 0 : if (likely(first_time && (deq > 0))) {
5728 : 0 : last_time += rte_rdtsc_precise() - start_time;
5729 : : first_time = false;
5730 : : }
5731 : 0 : time_out++;
5732 : 0 : if (time_out >= TIME_OUT_POLL) {
5733 : 0 : timeout_exit(dev_id);
5734 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5735 : : }
5736 : 0 : } while (unlikely(burst_sz != deq));
5737 : :
5738 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5739 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5740 : 0 : *total_time += last_time;
5741 : :
5742 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5743 : 0 : ret = validate_mldts_op(ops_deq, burst_sz, ref_op);
5744 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5745 : : }
5746 : :
5747 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, deq);
5748 : 0 : dequeued += deq;
5749 : : }
5750 : :
5751 : 0 : return i;
5752 : : }
5753 : :
5754 : : /* Common function for running validation and latency test cases */
5755 : : static int
5756 : 0 : validation_latency_test(struct active_device *ad,
5757 : : struct test_op_params *op_params, bool latency_flag)
5758 : : {
5759 : : int iter;
5760 : 0 : uint16_t burst_sz = op_params->burst_sz;
5761 : 0 : const uint16_t num_to_process = op_params->num_to_process;
5762 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
5763 : 0 : const uint16_t queue_id = ad->queue_ids[0];
5764 : : struct test_buffers *bufs = NULL;
5765 : : struct rte_bbdev_info info;
5766 : : uint64_t total_time, min_time, max_time;
5767 : : const char *op_type_str;
5768 : :
5769 : 0 : total_time = max_time = 0;
5770 : 0 : min_time = UINT64_MAX;
5771 : :
5772 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
5773 : : "BURST_SIZE should be <= %u", MAX_BURST);
5774 : :
5775 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5776 : 0 : bufs = &op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
5777 : :
5778 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
5779 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
5780 : :
5781 : : printf("+ ------------------------------------------------------- +\n");
5782 : 0 : if (latency_flag)
5783 : : printf("== test: latency\ndev:");
5784 : : else
5785 : : printf("== test: validation\ndev:");
5786 : 0 : printf("%s, burst size: %u, num ops: %u, op type: %s\n",
5787 : : info.dev_name, burst_sz, num_to_process, op_type_str);
5788 : :
5789 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC)
5790 : 0 : iter = latency_test_dec(op_params->mp, bufs,
5791 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
5792 : : num_to_process, burst_sz, &total_time,
5793 : : &min_time, &max_time, latency_flag);
5794 : 0 : else if (op_type == RTE_BBDEV_OP_LDPC_ENC)
5795 : 0 : iter = latency_test_ldpc_enc(op_params->mp, bufs,
5796 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
5797 : : num_to_process, burst_sz, &total_time,
5798 : : &min_time, &max_time);
5799 : 0 : else if (op_type == RTE_BBDEV_OP_LDPC_DEC)
5800 : 0 : iter = latency_test_ldpc_dec(op_params->mp, bufs,
5801 : : op_params->ref_dec_op, op_params->vector_mask,
5802 : 0 : ad->dev_id, queue_id, num_to_process,
5803 : : burst_sz, &total_time, &min_time, &max_time,
5804 : : latency_flag);
5805 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
5806 : 0 : iter = latency_test_fft(op_params->mp, bufs,
5807 : : op_params->ref_fft_op,
5808 : 0 : ad->dev_id, queue_id,
5809 : : num_to_process, burst_sz, &total_time,
5810 : : &min_time, &max_time);
5811 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
5812 : 0 : iter = latency_test_mldts(op_params->mp, bufs,
5813 : : op_params->ref_mldts_op,
5814 : 0 : ad->dev_id, queue_id,
5815 : : num_to_process, burst_sz, &total_time,
5816 : : &min_time, &max_time);
5817 : : else /* RTE_BBDEV_OP_TURBO_ENC */
5818 : 0 : iter = latency_test_enc(op_params->mp, bufs,
5819 : : op_params->ref_enc_op,
5820 : 0 : ad->dev_id, queue_id,
5821 : : num_to_process, burst_sz, &total_time,
5822 : : &min_time, &max_time);
5823 : :
5824 : 0 : if (iter <= 0)
5825 : : return TEST_FAILED;
5826 : :
5827 : 0 : printf("Operation latency:\n"
5828 : : "\tavg: %lg cycles, %lg us\n"
5829 : : "\tmin: %lg cycles, %lg us\n"
5830 : : "\tmax: %lg cycles, %lg us\n",
5831 : 0 : (double)total_time / (double)iter,
5832 : 0 : (double)(total_time * 1000000) / (double)iter /
5833 : 0 : (double)rte_get_tsc_hz(), (double)min_time,
5834 : 0 : (double)(min_time * 1000000) / (double)rte_get_tsc_hz(),
5835 : 0 : (double)max_time, (double)(max_time * 1000000) /
5836 : 0 : (double)rte_get_tsc_hz());
5837 : :
5838 : 0 : return TEST_SUCCESS;
5839 : : }
5840 : :
5841 : : static int
5842 : 0 : latency_test(struct active_device *ad, struct test_op_params *op_params)
5843 : : {
5844 : 0 : return validation_latency_test(ad, op_params, true);
5845 : : }
5846 : :
5847 : : static int
5848 : 0 : validation_test(struct active_device *ad, struct test_op_params *op_params)
5849 : : {
5850 : 0 : return validation_latency_test(ad, op_params, false);
5851 : : }
5852 : :
5853 : : static int
5854 : 0 : get_bbdev_queue_stats(uint16_t dev_id, uint16_t queue_id,
5855 : : struct rte_bbdev_stats *stats)
5856 : : {
5857 : 0 : struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
5858 : : struct rte_bbdev_stats *q_stats;
5859 : :
5860 : 0 : if (queue_id >= dev->data->num_queues)
5861 : : return -1;
5862 : :
5863 : 0 : q_stats = &dev->data->queues[queue_id].queue_stats;
5864 : :
5865 : 0 : stats->enqueued_count = q_stats->enqueued_count;
5866 : 0 : stats->dequeued_count = q_stats->dequeued_count;
5867 : 0 : stats->enqueue_err_count = q_stats->enqueue_err_count;
5868 : 0 : stats->dequeue_err_count = q_stats->dequeue_err_count;
5869 : 0 : stats->enqueue_warn_count = q_stats->enqueue_warn_count;
5870 : 0 : stats->dequeue_warn_count = q_stats->dequeue_warn_count;
5871 : 0 : stats->acc_offload_cycles = q_stats->acc_offload_cycles;
5872 : 0 : stats->enqueue_depth_avail = q_stats->enqueue_depth_avail;
5873 : :
5874 : 0 : return 0;
5875 : : }
5876 : :
5877 : : static int
5878 : 0 : offload_latency_test_fft(struct rte_mempool *mempool, struct test_buffers *bufs,
5879 : : struct rte_bbdev_fft_op *ref_op, uint16_t dev_id,
5880 : : uint16_t queue_id, const uint16_t num_to_process,
5881 : : uint16_t burst_sz, struct test_time_stats *time_st)
5882 : : {
5883 : : int i, dequeued, ret;
5884 : : struct rte_bbdev_fft_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5885 : : uint64_t enq_start_time, deq_start_time;
5886 : : uint64_t enq_sw_last_time, deq_last_time;
5887 : : struct rte_bbdev_stats stats;
5888 : :
5889 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5890 : : uint16_t enq = 0, deq = 0;
5891 : :
5892 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5893 : 0 : burst_sz = num_to_process - dequeued;
5894 : :
5895 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(mempool, ops_enq, burst_sz);
5896 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_fft_op_alloc_bulk() failed");
5897 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5898 : 0 : copy_reference_fft_op(ops_enq, burst_sz, dequeued,
5899 : : bufs->inputs,
5900 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
5901 : : ref_op);
5902 : :
5903 : : /* Start time meas for enqueue function offload latency */
5904 : : enq_start_time = rte_rdtsc_precise();
5905 : : do {
5906 : 0 : enq += rte_bbdev_enqueue_fft_ops(dev_id, queue_id,
5907 : 0 : &ops_enq[enq], burst_sz - enq);
5908 : 0 : } while (unlikely(burst_sz != enq));
5909 : :
5910 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
5911 : 0 : TEST_ASSERT_SUCCESS(ret,
5912 : : "Failed to get stats for queue (%u) of device (%u)",
5913 : : queue_id, dev_id);
5914 : :
5915 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
5916 : 0 : stats.acc_offload_cycles;
5917 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
5918 : : enq_sw_last_time);
5919 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
5920 : : enq_sw_last_time);
5921 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
5922 : :
5923 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
5924 : : stats.acc_offload_cycles);
5925 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
5926 : : stats.acc_offload_cycles);
5927 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
5928 : :
5929 : : /* give time for device to process ops */
5930 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
5931 : :
5932 : : /* Start time meas for dequeue function offload latency */
5933 : : deq_start_time = rte_rdtsc_precise();
5934 : : /* Dequeue one operation */
5935 : : do {
5936 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5937 : 0 : &ops_deq[deq], enq);
5938 : 0 : } while (unlikely(deq == 0));
5939 : :
5940 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
5941 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
5942 : : deq_last_time);
5943 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
5944 : : deq_last_time);
5945 : 0 : time_st->deq_total_time += deq_last_time;
5946 : :
5947 : : /* Dequeue remaining operations if needed*/
5948 : 0 : while (burst_sz != deq)
5949 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5950 : 0 : &ops_deq[deq], burst_sz - deq);
5951 : :
5952 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, deq);
5953 : 0 : dequeued += deq;
5954 : : }
5955 : :
5956 : : return i;
5957 : : }
5958 : :
5959 : : static int
5960 : 0 : offload_latency_test_mldts(struct rte_mempool *mempool, struct test_buffers *bufs,
5961 : : struct rte_bbdev_mldts_op *ref_op, uint16_t dev_id,
5962 : : uint16_t queue_id, const uint16_t num_to_process,
5963 : : uint16_t burst_sz, struct test_time_stats *time_st)
5964 : : {
5965 : : int i, dequeued, ret;
5966 : : struct rte_bbdev_mldts_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5967 : : uint64_t enq_start_time, deq_start_time;
5968 : : uint64_t enq_sw_last_time, deq_last_time;
5969 : : struct rte_bbdev_stats stats;
5970 : :
5971 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5972 : : uint16_t enq = 0, deq = 0;
5973 : :
5974 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5975 : 0 : burst_sz = num_to_process - dequeued;
5976 : :
5977 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(mempool, ops_enq, burst_sz);
5978 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_mldts_op_alloc_bulk() failed");
5979 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5980 : 0 : copy_reference_mldts_op(ops_enq, burst_sz, dequeued,
5981 : : bufs->inputs, bufs->harq_inputs,
5982 : : bufs->hard_outputs,
5983 : : ref_op);
5984 : :
5985 : : /* Start time meas for enqueue function offload latency */
5986 : : enq_start_time = rte_rdtsc_precise();
5987 : : do {
5988 : 0 : enq += rte_bbdev_enqueue_mldts_ops(dev_id, queue_id,
5989 : 0 : &ops_enq[enq], burst_sz - enq);
5990 : 0 : } while (unlikely(burst_sz != enq));
5991 : :
5992 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
5993 : 0 : TEST_ASSERT_SUCCESS(ret,
5994 : : "Failed to get stats for queue (%u) of device (%u)",
5995 : : queue_id, dev_id);
5996 : :
5997 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
5998 : 0 : stats.acc_offload_cycles;
5999 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6000 : : enq_sw_last_time);
6001 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6002 : : enq_sw_last_time);
6003 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6004 : :
6005 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6006 : : stats.acc_offload_cycles);
6007 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6008 : : stats.acc_offload_cycles);
6009 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6010 : :
6011 : : /* give time for device to process ops */
6012 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6013 : :
6014 : : /* Start time meas for dequeue function offload latency */
6015 : : deq_start_time = rte_rdtsc_precise();
6016 : : /* Dequeue one operation */
6017 : : do {
6018 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id, &ops_deq[deq], enq);
6019 : 0 : } while (unlikely(deq == 0));
6020 : :
6021 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6022 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time, deq_last_time);
6023 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time, deq_last_time);
6024 : 0 : time_st->deq_total_time += deq_last_time;
6025 : :
6026 : : /* Dequeue remaining operations if needed*/
6027 : 0 : while (burst_sz != deq)
6028 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
6029 : 0 : &ops_deq[deq], burst_sz - deq);
6030 : :
6031 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, deq);
6032 : 0 : dequeued += deq;
6033 : : }
6034 : :
6035 : : return i;
6036 : : }
6037 : :
6038 : : static int
6039 : 0 : offload_latency_test_dec(struct rte_mempool *mempool, struct test_buffers *bufs,
6040 : : struct rte_bbdev_dec_op *ref_op, uint16_t dev_id,
6041 : : uint16_t queue_id, const uint16_t num_to_process,
6042 : : uint16_t burst_sz, struct test_time_stats *time_st)
6043 : : {
6044 : : int i, dequeued, ret;
6045 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6046 : : uint64_t enq_start_time, deq_start_time;
6047 : : uint64_t enq_sw_last_time, deq_last_time;
6048 : : struct rte_bbdev_stats stats;
6049 : :
6050 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6051 : : uint16_t enq = 0, deq = 0;
6052 : :
6053 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6054 : 0 : burst_sz = num_to_process - dequeued;
6055 : :
6056 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
6057 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
6058 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
6059 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6060 : 0 : copy_reference_dec_op(ops_enq, burst_sz, dequeued,
6061 : : bufs->inputs,
6062 : : bufs->hard_outputs,
6063 : : bufs->soft_outputs,
6064 : : ref_op);
6065 : :
6066 : : /* Start time meas for enqueue function offload latency */
6067 : : enq_start_time = rte_rdtsc_precise();
6068 : : do {
6069 : 0 : enq += rte_bbdev_enqueue_dec_ops(dev_id, queue_id,
6070 : 0 : &ops_enq[enq], burst_sz - enq);
6071 : 0 : } while (unlikely(burst_sz != enq));
6072 : :
6073 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6074 : 0 : TEST_ASSERT_SUCCESS(ret,
6075 : : "Failed to get stats for queue (%u) of device (%u)",
6076 : : queue_id, dev_id);
6077 : :
6078 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
6079 : 0 : stats.acc_offload_cycles;
6080 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6081 : : enq_sw_last_time);
6082 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6083 : : enq_sw_last_time);
6084 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6085 : :
6086 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6087 : : stats.acc_offload_cycles);
6088 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6089 : : stats.acc_offload_cycles);
6090 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6091 : :
6092 : : /* give time for device to process ops */
6093 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6094 : :
6095 : : /* Start time meas for dequeue function offload latency */
6096 : : deq_start_time = rte_rdtsc_precise();
6097 : : /* Dequeue one operation */
6098 : : do {
6099 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
6100 : 0 : &ops_deq[deq], enq);
6101 : 0 : } while (unlikely(deq == 0));
6102 : :
6103 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6104 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6105 : : deq_last_time);
6106 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6107 : : deq_last_time);
6108 : 0 : time_st->deq_total_time += deq_last_time;
6109 : :
6110 : : /* Dequeue remaining operations if needed*/
6111 : 0 : while (burst_sz != deq)
6112 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
6113 : 0 : &ops_deq[deq], burst_sz - deq);
6114 : :
6115 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
6116 : 0 : dequeued += deq;
6117 : : }
6118 : :
6119 : : return i;
6120 : : }
6121 : :
6122 : : static int
6123 : 0 : offload_latency_test_ldpc_dec(struct rte_mempool *mempool,
6124 : : struct test_buffers *bufs,
6125 : : struct rte_bbdev_dec_op *ref_op, uint16_t dev_id,
6126 : : uint16_t queue_id, const uint16_t num_to_process,
6127 : : uint16_t burst_sz, struct test_time_stats *time_st)
6128 : : {
6129 : : int i, dequeued, ret;
6130 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6131 : : uint64_t enq_start_time, deq_start_time;
6132 : : uint64_t enq_sw_last_time, deq_last_time;
6133 : : struct rte_bbdev_stats stats;
6134 : 0 : bool extDdr = ldpc_cap_flags &
6135 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
6136 : :
6137 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6138 : : uint16_t enq = 0, deq = 0;
6139 : :
6140 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6141 : 0 : burst_sz = num_to_process - dequeued;
6142 : :
6143 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
6144 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
6145 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
6146 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6147 : 0 : copy_reference_ldpc_dec_op(ops_enq, burst_sz, dequeued,
6148 : : bufs->inputs,
6149 : : bufs->hard_outputs,
6150 : : bufs->soft_outputs,
6151 : : bufs->harq_inputs,
6152 : : bufs->harq_outputs,
6153 : : ref_op);
6154 : :
6155 : 0 : if (extDdr)
6156 : 0 : preload_harq_ddr(dev_id, queue_id, ops_enq,
6157 : : burst_sz, true);
6158 : :
6159 : : /* Start time meas for enqueue function offload latency */
6160 : : enq_start_time = rte_rdtsc_precise();
6161 : : do {
6162 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
6163 : 0 : &ops_enq[enq], burst_sz - enq);
6164 : 0 : } while (unlikely(burst_sz != enq));
6165 : :
6166 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6167 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6168 : 0 : TEST_ASSERT_SUCCESS(ret,
6169 : : "Failed to get stats for queue (%u) of device (%u)",
6170 : : queue_id, dev_id);
6171 : :
6172 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6173 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6174 : : enq_sw_last_time);
6175 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6176 : : enq_sw_last_time);
6177 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6178 : :
6179 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6180 : : stats.acc_offload_cycles);
6181 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6182 : : stats.acc_offload_cycles);
6183 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6184 : :
6185 : : /* give time for device to process ops */
6186 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6187 : :
6188 : : /* Start time meas for dequeue function offload latency */
6189 : : deq_start_time = rte_rdtsc_precise();
6190 : : /* Dequeue one operation */
6191 : : do {
6192 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
6193 : 0 : &ops_deq[deq], enq);
6194 : 0 : } while (unlikely(deq == 0));
6195 : :
6196 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6197 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6198 : : deq_last_time);
6199 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6200 : : deq_last_time);
6201 : 0 : time_st->deq_total_time += deq_last_time;
6202 : :
6203 : : /* Dequeue remaining operations if needed*/
6204 : 0 : while (burst_sz != deq)
6205 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
6206 : 0 : &ops_deq[deq], burst_sz - deq);
6207 : :
6208 : 0 : if (extDdr) {
6209 : : /* Read loopback is not thread safe */
6210 : 0 : retrieve_harq_ddr(dev_id, queue_id, ops_enq, burst_sz);
6211 : : }
6212 : :
6213 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
6214 : 0 : dequeued += deq;
6215 : : }
6216 : :
6217 : : return i;
6218 : : }
6219 : :
6220 : : static int
6221 : 0 : offload_latency_test_enc(struct rte_mempool *mempool, struct test_buffers *bufs,
6222 : : struct rte_bbdev_enc_op *ref_op, uint16_t dev_id,
6223 : : uint16_t queue_id, const uint16_t num_to_process,
6224 : : uint16_t burst_sz, struct test_time_stats *time_st)
6225 : : {
6226 : : int i, dequeued, ret;
6227 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6228 : : uint64_t enq_start_time, deq_start_time;
6229 : : uint64_t enq_sw_last_time, deq_last_time;
6230 : : struct rte_bbdev_stats stats;
6231 : :
6232 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6233 : : uint16_t enq = 0, deq = 0;
6234 : :
6235 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6236 : 0 : burst_sz = num_to_process - dequeued;
6237 : :
6238 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
6239 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_enc_op_alloc_bulk() failed");
6240 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6241 : 0 : copy_reference_enc_op(ops_enq, burst_sz, dequeued,
6242 : : bufs->inputs,
6243 : : bufs->hard_outputs,
6244 : : ref_op);
6245 : :
6246 : : /* Start time meas for enqueue function offload latency */
6247 : : enq_start_time = rte_rdtsc_precise();
6248 : : do {
6249 : 0 : enq += rte_bbdev_enqueue_enc_ops(dev_id, queue_id,
6250 : 0 : &ops_enq[enq], burst_sz - enq);
6251 : 0 : } while (unlikely(burst_sz != enq));
6252 : :
6253 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6254 : :
6255 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6256 : 0 : TEST_ASSERT_SUCCESS(ret,
6257 : : "Failed to get stats for queue (%u) of device (%u)",
6258 : : queue_id, dev_id);
6259 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6260 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6261 : : enq_sw_last_time);
6262 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6263 : : enq_sw_last_time);
6264 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6265 : :
6266 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6267 : : stats.acc_offload_cycles);
6268 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6269 : : stats.acc_offload_cycles);
6270 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6271 : :
6272 : : /* give time for device to process ops */
6273 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6274 : :
6275 : : /* Start time meas for dequeue function offload latency */
6276 : : deq_start_time = rte_rdtsc_precise();
6277 : : /* Dequeue one operation */
6278 : : do {
6279 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
6280 : 0 : &ops_deq[deq], enq);
6281 : 0 : } while (unlikely(deq == 0));
6282 : :
6283 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6284 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6285 : : deq_last_time);
6286 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6287 : : deq_last_time);
6288 : 0 : time_st->deq_total_time += deq_last_time;
6289 : :
6290 : 0 : while (burst_sz != deq)
6291 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
6292 : 0 : &ops_deq[deq], burst_sz - deq);
6293 : :
6294 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
6295 : 0 : dequeued += deq;
6296 : : }
6297 : :
6298 : : return i;
6299 : : }
6300 : :
6301 : : static int
6302 : 0 : offload_latency_test_ldpc_enc(struct rte_mempool *mempool,
6303 : : struct test_buffers *bufs,
6304 : : struct rte_bbdev_enc_op *ref_op, uint16_t dev_id,
6305 : : uint16_t queue_id, const uint16_t num_to_process,
6306 : : uint16_t burst_sz, struct test_time_stats *time_st)
6307 : : {
6308 : : int i, dequeued, ret;
6309 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6310 : : uint64_t enq_start_time, deq_start_time;
6311 : : uint64_t enq_sw_last_time, deq_last_time;
6312 : : struct rte_bbdev_stats stats;
6313 : :
6314 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6315 : : uint16_t enq = 0, deq = 0;
6316 : :
6317 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6318 : 0 : burst_sz = num_to_process - dequeued;
6319 : :
6320 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
6321 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_enc_op_alloc_bulk() failed");
6322 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6323 : 0 : copy_reference_ldpc_enc_op(ops_enq, burst_sz, dequeued,
6324 : : bufs->inputs,
6325 : : bufs->hard_outputs,
6326 : : ref_op);
6327 : :
6328 : : /* Start time meas for enqueue function offload latency */
6329 : : enq_start_time = rte_rdtsc_precise();
6330 : : do {
6331 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(dev_id, queue_id,
6332 : 0 : &ops_enq[enq], burst_sz - enq);
6333 : 0 : } while (unlikely(burst_sz != enq));
6334 : :
6335 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6336 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6337 : 0 : TEST_ASSERT_SUCCESS(ret,
6338 : : "Failed to get stats for queue (%u) of device (%u)",
6339 : : queue_id, dev_id);
6340 : :
6341 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6342 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6343 : : enq_sw_last_time);
6344 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6345 : : enq_sw_last_time);
6346 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6347 : :
6348 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6349 : : stats.acc_offload_cycles);
6350 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6351 : : stats.acc_offload_cycles);
6352 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6353 : :
6354 : : /* give time for device to process ops */
6355 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6356 : :
6357 : : /* Start time meas for dequeue function offload latency */
6358 : : deq_start_time = rte_rdtsc_precise();
6359 : : /* Dequeue one operation */
6360 : : do {
6361 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
6362 : 0 : &ops_deq[deq], enq);
6363 : 0 : } while (unlikely(deq == 0));
6364 : :
6365 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6366 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6367 : : deq_last_time);
6368 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6369 : : deq_last_time);
6370 : 0 : time_st->deq_total_time += deq_last_time;
6371 : :
6372 : 0 : while (burst_sz != deq)
6373 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
6374 : 0 : &ops_deq[deq], burst_sz - deq);
6375 : :
6376 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
6377 : 0 : dequeued += deq;
6378 : : }
6379 : :
6380 : : return i;
6381 : : }
6382 : :
6383 : : static int
6384 : 0 : offload_cost_test(struct active_device *ad,
6385 : : struct test_op_params *op_params)
6386 : : {
6387 : : int iter, ret;
6388 : 0 : uint16_t burst_sz = op_params->burst_sz;
6389 : 0 : const uint16_t num_to_process = op_params->num_to_process;
6390 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
6391 : 0 : const uint16_t queue_id = ad->queue_ids[0];
6392 : : struct test_buffers *bufs = NULL;
6393 : : struct rte_bbdev_info info;
6394 : : const char *op_type_str;
6395 : : struct test_time_stats time_st;
6396 : :
6397 : : memset(&time_st, 0, sizeof(struct test_time_stats));
6398 : 0 : time_st.enq_sw_min_time = UINT64_MAX;
6399 : 0 : time_st.enq_acc_min_time = UINT64_MAX;
6400 : 0 : time_st.deq_min_time = UINT64_MAX;
6401 : :
6402 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
6403 : : "BURST_SIZE should be <= %u", MAX_BURST);
6404 : :
6405 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
6406 : 0 : bufs = &op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
6407 : :
6408 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
6409 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
6410 : :
6411 : : printf("+ ------------------------------------------------------- +\n");
6412 : 0 : printf("== test: offload latency test\ndev: %s, burst size: %u, num ops: %u, op type: %s\n",
6413 : : info.dev_name, burst_sz, num_to_process, op_type_str);
6414 : :
6415 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC)
6416 : 0 : iter = offload_latency_test_dec(op_params->mp, bufs,
6417 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
6418 : : num_to_process, burst_sz, &time_st);
6419 : : else if (op_type == RTE_BBDEV_OP_TURBO_ENC)
6420 : 0 : iter = offload_latency_test_enc(op_params->mp, bufs,
6421 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6422 : : num_to_process, burst_sz, &time_st);
6423 : : else if (op_type == RTE_BBDEV_OP_LDPC_ENC)
6424 : 0 : iter = offload_latency_test_ldpc_enc(op_params->mp, bufs,
6425 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6426 : : num_to_process, burst_sz, &time_st);
6427 : : else if (op_type == RTE_BBDEV_OP_LDPC_DEC)
6428 : 0 : iter = offload_latency_test_ldpc_dec(op_params->mp, bufs,
6429 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
6430 : : num_to_process, burst_sz, &time_st);
6431 : : else if (op_type == RTE_BBDEV_OP_FFT)
6432 : 0 : iter = offload_latency_test_fft(op_params->mp, bufs,
6433 : 0 : op_params->ref_fft_op, ad->dev_id, queue_id,
6434 : : num_to_process, burst_sz, &time_st);
6435 : : else if (op_type == RTE_BBDEV_OP_MLDTS)
6436 : 0 : iter = offload_latency_test_mldts(op_params->mp, bufs,
6437 : 0 : op_params->ref_mldts_op, ad->dev_id, queue_id,
6438 : : num_to_process, burst_sz, &time_st);
6439 : : else
6440 : 0 : iter = offload_latency_test_enc(op_params->mp, bufs,
6441 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6442 : : num_to_process, burst_sz, &time_st);
6443 : :
6444 : 0 : if (iter <= 0)
6445 : : return TEST_FAILED;
6446 : :
6447 : 0 : printf("Enqueue driver offload cost latency:\n"
6448 : : "\tavg: %lg cycles, %lg us\n"
6449 : : "\tmin: %lg cycles, %lg us\n"
6450 : : "\tmax: %lg cycles, %lg us\n"
6451 : : "Enqueue accelerator offload cost latency:\n"
6452 : : "\tavg: %lg cycles, %lg us\n"
6453 : : "\tmin: %lg cycles, %lg us\n"
6454 : : "\tmax: %lg cycles, %lg us\n",
6455 : 0 : (double)time_st.enq_sw_total_time / (double)iter,
6456 : 0 : (double)(time_st.enq_sw_total_time * 1000000) /
6457 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6458 : 0 : (double)time_st.enq_sw_min_time,
6459 : 0 : (double)(time_st.enq_sw_min_time * 1000000) /
6460 : 0 : rte_get_tsc_hz(), (double)time_st.enq_sw_max_time,
6461 : 0 : (double)(time_st.enq_sw_max_time * 1000000) /
6462 : 0 : rte_get_tsc_hz(), (double)time_st.enq_acc_total_time /
6463 : : (double)iter,
6464 : 0 : (double)(time_st.enq_acc_total_time * 1000000) /
6465 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6466 : 0 : (double)time_st.enq_acc_min_time,
6467 : 0 : (double)(time_st.enq_acc_min_time * 1000000) /
6468 : 0 : rte_get_tsc_hz(), (double)time_st.enq_acc_max_time,
6469 : 0 : (double)(time_st.enq_acc_max_time * 1000000) /
6470 : 0 : rte_get_tsc_hz());
6471 : :
6472 : 0 : printf("Dequeue offload cost latency - one op:\n"
6473 : : "\tavg: %lg cycles, %lg us\n"
6474 : : "\tmin: %lg cycles, %lg us\n"
6475 : : "\tmax: %lg cycles, %lg us\n",
6476 : 0 : (double)time_st.deq_total_time / (double)iter,
6477 : 0 : (double)(time_st.deq_total_time * 1000000) /
6478 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6479 : 0 : (double)time_st.deq_min_time,
6480 : 0 : (double)(time_st.deq_min_time * 1000000) /
6481 : 0 : rte_get_tsc_hz(), (double)time_st.deq_max_time,
6482 : 0 : (double)(time_st.deq_max_time * 1000000) /
6483 : 0 : rte_get_tsc_hz());
6484 : :
6485 : 0 : struct rte_bbdev_stats stats = {0};
6486 : 0 : ret = get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
6487 : 0 : TEST_ASSERT_SUCCESS(ret,
6488 : : "Failed to get stats for queue (%u) of device (%u)",
6489 : : queue_id, ad->dev_id);
6490 : 0 : if (stats.enqueue_warn_count > 0)
6491 : : printf("Warning reported on the queue : %10"PRIu64"\n",
6492 : : stats.enqueue_warn_count);
6493 : 0 : if (op_type != RTE_BBDEV_OP_LDPC_DEC) {
6494 : 0 : TEST_ASSERT_SUCCESS(stats.enqueued_count != num_to_process,
6495 : : "Mismatch in enqueue count %10"PRIu64" %d",
6496 : : stats.enqueued_count, num_to_process);
6497 : 0 : TEST_ASSERT_SUCCESS(stats.dequeued_count != num_to_process,
6498 : : "Mismatch in dequeue count %10"PRIu64" %d",
6499 : : stats.dequeued_count, num_to_process);
6500 : : }
6501 : 0 : TEST_ASSERT_SUCCESS(stats.enqueue_err_count != 0,
6502 : : "Enqueue count Error %10"PRIu64"",
6503 : : stats.enqueue_err_count);
6504 : 0 : TEST_ASSERT_SUCCESS(stats.dequeue_err_count != 0,
6505 : : "Dequeue count Error (%10"PRIu64"",
6506 : : stats.dequeue_err_count);
6507 : :
6508 : : return TEST_SUCCESS;
6509 : : }
6510 : :
6511 : : static int
6512 : 0 : offload_latency_empty_q_test_dec(uint16_t dev_id, uint16_t queue_id,
6513 : : const uint16_t num_to_process, uint16_t burst_sz,
6514 : : uint64_t *deq_total_time, uint64_t *deq_min_time,
6515 : : uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
6516 : : {
6517 : : int i, deq_total;
6518 : : struct rte_bbdev_dec_op *ops[MAX_BURST];
6519 : : uint64_t deq_start_time, deq_last_time;
6520 : :
6521 : : /* Test deq offload latency from an empty queue */
6522 : :
6523 : 0 : for (i = 0, deq_total = 0; deq_total < num_to_process;
6524 : 0 : ++i, deq_total += burst_sz) {
6525 : : deq_start_time = rte_rdtsc_precise();
6526 : :
6527 : 0 : if (unlikely(num_to_process - deq_total < burst_sz))
6528 : 0 : burst_sz = num_to_process - deq_total;
6529 : 0 : if (op_type == RTE_BBDEV_OP_LDPC_DEC)
6530 : 0 : rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id, ops,
6531 : : burst_sz);
6532 : : else
6533 : 0 : rte_bbdev_dequeue_dec_ops(dev_id, queue_id, ops,
6534 : : burst_sz);
6535 : :
6536 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6537 : 0 : *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
6538 : 0 : *deq_min_time = RTE_MIN(*deq_min_time, deq_last_time);
6539 : 0 : *deq_total_time += deq_last_time;
6540 : : }
6541 : :
6542 : 0 : return i;
6543 : : }
6544 : :
6545 : : static int
6546 : 0 : offload_latency_empty_q_test_enc(uint16_t dev_id, uint16_t queue_id,
6547 : : const uint16_t num_to_process, uint16_t burst_sz,
6548 : : uint64_t *deq_total_time, uint64_t *deq_min_time,
6549 : : uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
6550 : : {
6551 : : int i, deq_total;
6552 : : struct rte_bbdev_enc_op *ops[MAX_BURST];
6553 : : uint64_t deq_start_time, deq_last_time;
6554 : :
6555 : : /* Test deq offload latency from an empty queue */
6556 : 0 : for (i = 0, deq_total = 0; deq_total < num_to_process;
6557 : 0 : ++i, deq_total += burst_sz) {
6558 : : deq_start_time = rte_rdtsc_precise();
6559 : :
6560 : 0 : if (unlikely(num_to_process - deq_total < burst_sz))
6561 : 0 : burst_sz = num_to_process - deq_total;
6562 : 0 : if (op_type == RTE_BBDEV_OP_LDPC_ENC)
6563 : 0 : rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id, ops,
6564 : : burst_sz);
6565 : : else
6566 : 0 : rte_bbdev_dequeue_enc_ops(dev_id, queue_id, ops,
6567 : : burst_sz);
6568 : :
6569 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6570 : 0 : *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
6571 : 0 : *deq_min_time = RTE_MIN(*deq_min_time, deq_last_time);
6572 : 0 : *deq_total_time += deq_last_time;
6573 : : }
6574 : :
6575 : 0 : return i;
6576 : : }
6577 : :
6578 : : static int
6579 : 0 : offload_latency_empty_q_test(struct active_device *ad,
6580 : : struct test_op_params *op_params)
6581 : : {
6582 : : int iter;
6583 : : uint64_t deq_total_time, deq_min_time, deq_max_time;
6584 : 0 : uint16_t burst_sz = op_params->burst_sz;
6585 : 0 : const uint16_t num_to_process = op_params->num_to_process;
6586 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
6587 : 0 : const uint16_t queue_id = ad->queue_ids[0];
6588 : : struct rte_bbdev_info info;
6589 : : const char *op_type_str;
6590 : :
6591 : 0 : deq_total_time = deq_max_time = 0;
6592 : 0 : deq_min_time = UINT64_MAX;
6593 : :
6594 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
6595 : : "BURST_SIZE should be <= %u", MAX_BURST);
6596 : :
6597 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
6598 : :
6599 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
6600 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
6601 : :
6602 : : printf("+ ------------------------------------------------------- +\n");
6603 : 0 : printf("== test: offload latency empty dequeue\ndev: %s, burst size: %u, num ops: %u, op type: %s\n",
6604 : : info.dev_name, burst_sz, num_to_process, op_type_str);
6605 : :
6606 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
6607 : 0 : op_type == RTE_BBDEV_OP_LDPC_DEC)
6608 : 0 : iter = offload_latency_empty_q_test_dec(ad->dev_id, queue_id,
6609 : : num_to_process, burst_sz, &deq_total_time,
6610 : : &deq_min_time, &deq_max_time, op_type);
6611 : : else
6612 : 0 : iter = offload_latency_empty_q_test_enc(ad->dev_id, queue_id,
6613 : : num_to_process, burst_sz, &deq_total_time,
6614 : : &deq_min_time, &deq_max_time, op_type);
6615 : :
6616 : 0 : if (iter <= 0)
6617 : : return TEST_FAILED;
6618 : :
6619 : 0 : printf("Empty dequeue offload:\n"
6620 : : "\tavg: %lg cycles, %lg us\n"
6621 : : "\tmin: %lg cycles, %lg us\n"
6622 : : "\tmax: %lg cycles, %lg us\n",
6623 : 0 : (double)deq_total_time / (double)iter,
6624 : 0 : (double)(deq_total_time * 1000000) / (double)iter /
6625 : 0 : (double)rte_get_tsc_hz(), (double)deq_min_time,
6626 : 0 : (double)(deq_min_time * 1000000) / rte_get_tsc_hz(),
6627 : 0 : (double)deq_max_time, (double)(deq_max_time * 1000000) /
6628 : 0 : rte_get_tsc_hz());
6629 : :
6630 : 0 : return TEST_SUCCESS;
6631 : : }
6632 : :
6633 : : static int
6634 : 0 : bler_tc(void)
6635 : : {
6636 : 0 : return run_test_case(bler_test);
6637 : : }
6638 : :
6639 : : static int
6640 : 0 : throughput_tc(void)
6641 : : {
6642 : 0 : return run_test_case(throughput_test);
6643 : : }
6644 : :
6645 : : static int
6646 : 0 : offload_cost_tc(void)
6647 : : {
6648 : 0 : return run_test_case(offload_cost_test);
6649 : : }
6650 : :
6651 : : static int
6652 : 0 : offload_latency_empty_q_tc(void)
6653 : : {
6654 : 0 : return run_test_case(offload_latency_empty_q_test);
6655 : : }
6656 : :
6657 : : static int
6658 : 0 : latency_tc(void)
6659 : : {
6660 : 0 : return run_test_case(latency_test);
6661 : : }
6662 : :
6663 : : static int
6664 : 0 : validation_tc(void)
6665 : : {
6666 : 0 : return run_test_case(validation_test);
6667 : : }
6668 : :
6669 : : static int
6670 : 0 : interrupt_tc(void)
6671 : : {
6672 : 0 : return run_test_case(throughput_test);
6673 : : }
6674 : :
6675 : : static struct unit_test_suite bbdev_bler_testsuite = {
6676 : : .suite_name = "BBdev BLER Tests",
6677 : : .setup = testsuite_setup,
6678 : : .teardown = testsuite_teardown,
6679 : : .unit_test_cases = {
6680 : : TEST_CASE_ST(ut_setup, ut_teardown, bler_tc),
6681 : : TEST_CASES_END() /**< NULL terminate unit test array */
6682 : : }
6683 : : };
6684 : :
6685 : : static struct unit_test_suite bbdev_throughput_testsuite = {
6686 : : .suite_name = "BBdev Throughput Tests",
6687 : : .setup = testsuite_setup,
6688 : : .teardown = testsuite_teardown,
6689 : : .unit_test_cases = {
6690 : : TEST_CASE_ST(ut_setup, ut_teardown, throughput_tc),
6691 : : TEST_CASES_END() /**< NULL terminate unit test array */
6692 : : }
6693 : : };
6694 : :
6695 : : static struct unit_test_suite bbdev_validation_testsuite = {
6696 : : .suite_name = "BBdev Validation Tests",
6697 : : .setup = testsuite_setup,
6698 : : .teardown = testsuite_teardown,
6699 : : .unit_test_cases = {
6700 : : TEST_CASE_ST(ut_setup, ut_teardown, validation_tc),
6701 : : TEST_CASES_END() /**< NULL terminate unit test array */
6702 : : }
6703 : : };
6704 : :
6705 : : static struct unit_test_suite bbdev_latency_testsuite = {
6706 : : .suite_name = "BBdev Latency Tests",
6707 : : .setup = testsuite_setup,
6708 : : .teardown = testsuite_teardown,
6709 : : .unit_test_cases = {
6710 : : TEST_CASE_ST(ut_setup, ut_teardown, latency_tc),
6711 : : TEST_CASES_END() /**< NULL terminate unit test array */
6712 : : }
6713 : : };
6714 : :
6715 : : static struct unit_test_suite bbdev_offload_cost_testsuite = {
6716 : : .suite_name = "BBdev Offload Cost Tests",
6717 : : .setup = testsuite_setup,
6718 : : .teardown = testsuite_teardown,
6719 : : .unit_test_cases = {
6720 : : TEST_CASE_ST(ut_setup, ut_teardown, offload_cost_tc),
6721 : : TEST_CASE_ST(ut_setup, ut_teardown, offload_latency_empty_q_tc),
6722 : : TEST_CASES_END() /**< NULL terminate unit test array */
6723 : : }
6724 : : };
6725 : :
6726 : : static struct unit_test_suite bbdev_interrupt_testsuite = {
6727 : : .suite_name = "BBdev Interrupt Tests",
6728 : : .setup = interrupt_testsuite_setup,
6729 : : .teardown = testsuite_teardown,
6730 : : .unit_test_cases = {
6731 : : TEST_CASE_ST(ut_setup, ut_teardown, interrupt_tc),
6732 : : TEST_CASES_END() /**< NULL terminate unit test array */
6733 : : }
6734 : : };
6735 : :
6736 : 0 : REGISTER_TEST_COMMAND(bler, bbdev_bler_testsuite);
6737 : 0 : REGISTER_TEST_COMMAND(throughput, bbdev_throughput_testsuite);
6738 : 0 : REGISTER_TEST_COMMAND(validation, bbdev_validation_testsuite);
6739 : 0 : REGISTER_TEST_COMMAND(latency, bbdev_latency_testsuite);
6740 : 0 : REGISTER_TEST_COMMAND(offload, bbdev_offload_cost_testsuite);
6741 : 0 : REGISTER_TEST_COMMAND(interrupt, bbdev_interrupt_testsuite);
|