net/hns3: fix config when creating RSS rule after flush
[dpdk.git] / app / test-bbdev / test_bbdev_perf.c
index bc73a97..45c0d62 100644 (file)
 #define FLR_4G_TIMEOUT 610
 #endif
 
+#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_5GNR_FEC
+#include <rte_pmd_fpga_5gnr_fec.h>
+#define FPGA_5GNR_PF_DRIVER_NAME ("intel_fpga_5gnr_fec_pf")
+#define FPGA_5GNR_VF_DRIVER_NAME ("intel_fpga_5gnr_fec_vf")
+#define VF_UL_5G_QUEUE_VALUE 4
+#define VF_DL_5G_QUEUE_VALUE 4
+#define UL_5G_BANDWIDTH 3
+#define DL_5G_BANDWIDTH 3
+#define UL_5G_LOAD_BALANCE 128
+#define DL_5G_LOAD_BALANCE 128
+#define FLR_5G_TIMEOUT 610
+#endif
+
 #define OPS_CACHE_SIZE 256U
 #define OPS_POOL_SIZE_MIN 511U /* 0.5K per queue */
 
@@ -595,6 +608,50 @@ add_bbdev_dev(uint8_t dev_id, struct rte_bbdev_info *info,
                                "Failed to configure 4G FPGA PF for bbdev %s",
                                info->dev_name);
        }
+#endif
+#ifdef RTE_LIBRTE_PMD_BBDEV_FPGA_5GNR_FEC
+       if ((get_init_device() == true) &&
+               (!strcmp(info->drv.driver_name, FPGA_5GNR_PF_DRIVER_NAME))) {
+               struct fpga_5gnr_fec_conf conf;
+               unsigned int i;
+
+               printf("Configure FPGA 5GNR FEC Driver %s with default values\n",
+                               info->drv.driver_name);
+
+               /* clear default configuration before initialization */
+               memset(&conf, 0, sizeof(struct fpga_5gnr_fec_conf));
+
+               /* Set PF mode :
+                * true if PF is used for data plane
+                * false for VFs
+                */
+               conf.pf_mode_en = true;
+
+               for (i = 0; i < FPGA_5GNR_FEC_NUM_VFS; ++i) {
+                       /* Number of UL queues per VF (fpga supports 8 VFs) */
+                       conf.vf_ul_queues_number[i] = VF_UL_5G_QUEUE_VALUE;
+                       /* Number of DL queues per VF (fpga supports 8 VFs) */
+                       conf.vf_dl_queues_number[i] = VF_DL_5G_QUEUE_VALUE;
+               }
+
+               /* UL bandwidth. Needed for schedule algorithm */
+               conf.ul_bandwidth = UL_5G_BANDWIDTH;
+               /* DL bandwidth */
+               conf.dl_bandwidth = DL_5G_BANDWIDTH;
+
+               /* UL & DL load Balance Factor to 64 */
+               conf.ul_load_balance = UL_5G_LOAD_BALANCE;
+               conf.dl_load_balance = DL_5G_LOAD_BALANCE;
+
+               /**< FLR timeout value */
+               conf.flr_time_out = FLR_5G_TIMEOUT;
+
+               /* setup FPGA PF with configuration information */
+               ret = fpga_5gnr_fec_configure(info->dev_name, &conf);
+               TEST_ASSERT_SUCCESS(ret,
+                               "Failed to configure 5G FPGA PF for bbdev %s",
+                               info->dev_name);
+       }
 #endif
        nb_queues = RTE_MIN(rte_lcore_count(), info->drv.max_num_queues);
        nb_queues = RTE_MIN(nb_queues, (unsigned int) MAX_QUEUES);
@@ -754,6 +811,9 @@ testsuite_teardown(void)
        /* Clear active devices structs. */
        memset(active_devs, 0, sizeof(active_devs));
        nb_active_devs = 0;
+
+       /* Disable interrupts */
+       intr_enabled = false;
 }
 
 static int
@@ -2561,6 +2621,109 @@ dequeue_event_callback(uint16_t dev_id,
        rte_atomic16_add(&tp->nb_dequeued, deq);
 }
 
+static int
+throughput_intr_lcore_ldpc_dec(void *arg)
+{
+       struct thread_params *tp = arg;
+       unsigned int enqueued;
+       const uint16_t queue_id = tp->queue_id;
+       const uint16_t burst_sz = tp->op_params->burst_sz;
+       const uint16_t num_to_process = tp->op_params->num_to_process;
+       struct rte_bbdev_dec_op *ops[num_to_process];
+       struct test_buffers *bufs = NULL;
+       struct rte_bbdev_info info;
+       int ret, i, j;
+       struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
+       uint16_t num_to_enq, enq;
+
+       bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
+                       RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
+       bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
+                       RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
+
+       TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
+                       "BURST_SIZE should be <= %u", MAX_BURST);
+
+       TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
+                       "Failed to enable interrupts for dev: %u, queue_id: %u",
+                       tp->dev_id, queue_id);
+
+       rte_bbdev_info_get(tp->dev_id, &info);
+
+       TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
+                       "NUM_OPS cannot exceed %u for this device",
+                       info.drv.queue_size_lim);
+
+       bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
+
+       rte_atomic16_clear(&tp->processing_status);
+       rte_atomic16_clear(&tp->nb_dequeued);
+
+       while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
+               rte_pause();
+
+       ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
+                               num_to_process);
+       TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
+                       num_to_process);
+       if (test_vector.op_type != RTE_BBDEV_OP_NONE)
+               copy_reference_ldpc_dec_op(ops, num_to_process, 0, bufs->inputs,
+                               bufs->hard_outputs, bufs->soft_outputs,
+                               bufs->harq_inputs, bufs->harq_outputs, ref_op);
+
+       /* Set counter to validate the ordering */
+       for (j = 0; j < num_to_process; ++j)
+               ops[j]->opaque_data = (void *)(uintptr_t)j;
+
+       for (j = 0; j < TEST_REPETITIONS; ++j) {
+               for (i = 0; i < num_to_process; ++i) {
+                       if (!loopback)
+                               rte_pktmbuf_reset(
+                                       ops[i]->ldpc_dec.hard_output.data);
+                       if (hc_out || loopback)
+                               mbuf_reset(
+                               ops[i]->ldpc_dec.harq_combined_output.data);
+               }
+
+               tp->start_time = rte_rdtsc_precise();
+               for (enqueued = 0; enqueued < num_to_process;) {
+                       num_to_enq = burst_sz;
+
+                       if (unlikely(num_to_process - enqueued < num_to_enq))
+                               num_to_enq = num_to_process - enqueued;
+
+                       enq = 0;
+                       do {
+                               enq += rte_bbdev_enqueue_ldpc_dec_ops(
+                                               tp->dev_id,
+                                               queue_id, &ops[enqueued],
+                                               num_to_enq);
+                       } while (unlikely(num_to_enq != enq));
+                       enqueued += enq;
+
+                       /* Write to thread burst_sz current number of enqueued
+                        * descriptors. It ensures that proper number of
+                        * descriptors will be dequeued in callback
+                        * function - needed for last batch in case where
+                        * the number of operations is not a multiple of
+                        * burst size.
+                        */
+                       rte_atomic16_set(&tp->burst_sz, num_to_enq);
+
+                       /* Wait until processing of previous batch is
+                        * completed
+                        */
+                       while (rte_atomic16_read(&tp->nb_dequeued) !=
+                                       (int16_t) enqueued)
+                               rte_pause();
+               }
+               if (j != TEST_REPETITIONS - 1)
+                       rte_atomic16_clear(&tp->nb_dequeued);
+       }
+
+       return TEST_SUCCESS;
+}
+
 static int
 throughput_intr_lcore_dec(void *arg)
 {
@@ -2740,6 +2903,98 @@ throughput_intr_lcore_enc(void *arg)
        return TEST_SUCCESS;
 }
 
+
+static int
+throughput_intr_lcore_ldpc_enc(void *arg)
+{
+       struct thread_params *tp = arg;
+       unsigned int enqueued;
+       const uint16_t queue_id = tp->queue_id;
+       const uint16_t burst_sz = tp->op_params->burst_sz;
+       const uint16_t num_to_process = tp->op_params->num_to_process;
+       struct rte_bbdev_enc_op *ops[num_to_process];
+       struct test_buffers *bufs = NULL;
+       struct rte_bbdev_info info;
+       int ret, i, j;
+       uint16_t num_to_enq, enq;
+
+       TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
+                       "BURST_SIZE should be <= %u", MAX_BURST);
+
+       TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
+                       "Failed to enable interrupts for dev: %u, queue_id: %u",
+                       tp->dev_id, queue_id);
+
+       rte_bbdev_info_get(tp->dev_id, &info);
+
+       TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
+                       "NUM_OPS cannot exceed %u for this device",
+                       info.drv.queue_size_lim);
+
+       bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
+
+       rte_atomic16_clear(&tp->processing_status);
+       rte_atomic16_clear(&tp->nb_dequeued);
+
+       while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
+               rte_pause();
+
+       ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
+                       num_to_process);
+       TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
+                       num_to_process);
+       if (test_vector.op_type != RTE_BBDEV_OP_NONE)
+               copy_reference_ldpc_enc_op(ops, num_to_process, 0,
+                               bufs->inputs, bufs->hard_outputs,
+                               tp->op_params->ref_enc_op);
+
+       /* Set counter to validate the ordering */
+       for (j = 0; j < num_to_process; ++j)
+               ops[j]->opaque_data = (void *)(uintptr_t)j;
+
+       for (j = 0; j < TEST_REPETITIONS; ++j) {
+               for (i = 0; i < num_to_process; ++i)
+                       rte_pktmbuf_reset(ops[i]->turbo_enc.output.data);
+
+               tp->start_time = rte_rdtsc_precise();
+               for (enqueued = 0; enqueued < num_to_process;) {
+                       num_to_enq = burst_sz;
+
+                       if (unlikely(num_to_process - enqueued < num_to_enq))
+                               num_to_enq = num_to_process - enqueued;
+
+                       enq = 0;
+                       do {
+                               enq += rte_bbdev_enqueue_ldpc_enc_ops(
+                                               tp->dev_id,
+                                               queue_id, &ops[enqueued],
+                                               num_to_enq);
+                       } while (unlikely(enq != num_to_enq));
+                       enqueued += enq;
+
+                       /* Write to thread burst_sz current number of enqueued
+                        * descriptors. It ensures that proper number of
+                        * descriptors will be dequeued in callback
+                        * function - needed for last batch in case where
+                        * the number of operations is not a multiple of
+                        * burst size.
+                        */
+                       rte_atomic16_set(&tp->burst_sz, num_to_enq);
+
+                       /* Wait until processing of previous batch is
+                        * completed
+                        */
+                       while (rte_atomic16_read(&tp->nb_dequeued) !=
+                                       (int16_t) enqueued)
+                               rte_pause();
+               }
+               if (j != TEST_REPETITIONS - 1)
+                       rte_atomic16_clear(&tp->nb_dequeued);
+       }
+
+       return TEST_SUCCESS;
+}
+
 static int
 throughput_pmd_lcore_dec(void *arg)
 {
@@ -3483,11 +3738,11 @@ throughput_test(struct active_device *ad,
                if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
                        throughput_function = throughput_intr_lcore_dec;
                else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
-                       throughput_function = throughput_intr_lcore_dec;
+                       throughput_function = throughput_intr_lcore_ldpc_dec;
                else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
                        throughput_function = throughput_intr_lcore_enc;
                else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
-                       throughput_function = throughput_intr_lcore_enc;
+                       throughput_function = throughput_intr_lcore_ldpc_enc;
                else
                        throughput_function = throughput_intr_lcore_enc;
 
@@ -4445,7 +4700,7 @@ static int
 offload_latency_empty_q_test_dec(uint16_t dev_id, uint16_t queue_id,
                const uint16_t num_to_process, uint16_t burst_sz,
                uint64_t *deq_total_time, uint64_t *deq_min_time,
-               uint64_t *deq_max_time)
+               uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
 {
        int i, deq_total;
        struct rte_bbdev_dec_op *ops[MAX_BURST];
@@ -4459,7 +4714,12 @@ offload_latency_empty_q_test_dec(uint16_t dev_id, uint16_t queue_id,
 
                if (unlikely(num_to_process - deq_total < burst_sz))
                        burst_sz = num_to_process - deq_total;
-               rte_bbdev_dequeue_dec_ops(dev_id, queue_id, ops, burst_sz);
+               if (op_type == RTE_BBDEV_OP_LDPC_DEC)
+                       rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id, ops,
+                                       burst_sz);
+               else
+                       rte_bbdev_dequeue_dec_ops(dev_id, queue_id, ops,
+                                       burst_sz);
 
                deq_last_time = rte_rdtsc_precise() - deq_start_time;
                *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
@@ -4474,7 +4734,7 @@ static int
 offload_latency_empty_q_test_enc(uint16_t dev_id, uint16_t queue_id,
                const uint16_t num_to_process, uint16_t burst_sz,
                uint64_t *deq_total_time, uint64_t *deq_min_time,
-               uint64_t *deq_max_time)
+               uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
 {
        int i, deq_total;
        struct rte_bbdev_enc_op *ops[MAX_BURST];
@@ -4487,7 +4747,12 @@ offload_latency_empty_q_test_enc(uint16_t dev_id, uint16_t queue_id,
 
                if (unlikely(num_to_process - deq_total < burst_sz))
                        burst_sz = num_to_process - deq_total;
-               rte_bbdev_dequeue_enc_ops(dev_id, queue_id, ops, burst_sz);
+               if (op_type == RTE_BBDEV_OP_LDPC_ENC)
+                       rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id, ops,
+                                       burst_sz);
+               else
+                       rte_bbdev_dequeue_enc_ops(dev_id, queue_id, ops,
+                                       burst_sz);
 
                deq_last_time = rte_rdtsc_precise() - deq_start_time;
                *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
@@ -4497,6 +4762,7 @@ offload_latency_empty_q_test_enc(uint16_t dev_id, uint16_t queue_id,
 
        return i;
 }
+
 #endif
 
 static int
@@ -4534,14 +4800,15 @@ offload_latency_empty_q_test(struct active_device *ad,
        printf("== test: offload latency empty dequeue\ndev: %s, burst size: %u, num ops: %u, op type: %s\n",
                        info.dev_name, burst_sz, num_to_process, op_type_str);
 
-       if (op_type == RTE_BBDEV_OP_TURBO_DEC)
+       if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
+                       op_type == RTE_BBDEV_OP_LDPC_DEC)
                iter = offload_latency_empty_q_test_dec(ad->dev_id, queue_id,
                                num_to_process, burst_sz, &deq_total_time,
-                               &deq_min_time, &deq_max_time);
+                               &deq_min_time, &deq_max_time, op_type);
        else
                iter = offload_latency_empty_q_test_enc(ad->dev_id, queue_id,
                                num_to_process, burst_sz, &deq_total_time,
-                               &deq_min_time, &deq_max_time);
+                               &deq_min_time, &deq_max_time, op_type);
 
        if (iter <= 0)
                return TEST_FAILED;