bbdev: add explicit enum for code block mode
authorNicolas Chautru <nicolas.chautru@intel.com>
Sat, 20 Feb 2021 00:15:05 +0000 (16:15 -0800)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 16 Apr 2021 10:43:33 +0000 (12:43 +0200)
Using explicit enum instead of ambiguous integer value

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Reviewed-by: Tom Rix <trix@redhat.com>
app/test-bbdev/test_bbdev_perf.c
app/test-bbdev/test_bbdev_vector.c
drivers/baseband/acc100/rte_acc100_pmd.c
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
drivers/baseband/turbo_sw/bbdev_turbo_software.c
lib/librte_bbdev/rte_bbdev_op.h

index 59b37ed..45b85b9 100644 (file)
@@ -1258,7 +1258,7 @@ copy_reference_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
        struct rte_bbdev_op_turbo_dec *turbo_dec = &ref_op->turbo_dec;
 
        for (i = 0; i < n; ++i) {
-               if (turbo_dec->code_block_mode == 0) {
+               if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        ops[i]->turbo_dec.tb_params.ea =
                                        turbo_dec->tb_params.ea;
                        ops[i]->turbo_dec.tb_params.eb =
@@ -1306,7 +1306,7 @@ copy_reference_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
        unsigned int i;
        struct rte_bbdev_op_turbo_enc *turbo_enc = &ref_op->turbo_enc;
        for (i = 0; i < n; ++i) {
-               if (turbo_enc->code_block_mode == 0) {
+               if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        ops[i]->turbo_enc.tb_params.ea =
                                        turbo_enc->tb_params.ea;
                        ops[i]->turbo_enc.tb_params.eb =
@@ -1661,7 +1661,7 @@ copy_reference_ldpc_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
        struct rte_bbdev_op_ldpc_dec *ldpc_dec = &ref_op->ldpc_dec;
 
        for (i = 0; i < n; ++i) {
-               if (ldpc_dec->code_block_mode == 0) {
+               if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        ops[i]->ldpc_dec.tb_params.ea =
                                        ldpc_dec->tb_params.ea;
                        ops[i]->ldpc_dec.tb_params.eb =
@@ -1715,7 +1715,7 @@ copy_reference_ldpc_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
        unsigned int i;
        struct rte_bbdev_op_ldpc_enc *ldpc_enc = &ref_op->ldpc_enc;
        for (i = 0; i < n; ++i) {
-               if (ldpc_enc->code_block_mode == 0) {
+               if (ldpc_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        ops[i]->ldpc_enc.tb_params.ea = ldpc_enc->tb_params.ea;
                        ops[i]->ldpc_enc.tb_params.eb = ldpc_enc->tb_params.eb;
                        ops[i]->ldpc_enc.tb_params.cab =
@@ -2239,7 +2239,7 @@ calc_dec_TB_size(struct rte_bbdev_dec_op *op)
        uint8_t i;
        uint32_t c, r, tb_size = 0;
 
-       if (op->turbo_dec.code_block_mode) {
+       if (op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
                tb_size = op->turbo_dec.tb_params.k_neg;
        } else {
                c = op->turbo_dec.tb_params.c;
@@ -2259,7 +2259,7 @@ calc_ldpc_dec_TB_size(struct rte_bbdev_dec_op *op)
        uint32_t c, r, tb_size = 0;
        uint16_t sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
 
-       if (op->ldpc_dec.code_block_mode) {
+       if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
                tb_size = sys_cols * op->ldpc_dec.z_c - op->ldpc_dec.n_filler;
        } else {
                c = op->ldpc_dec.tb_params.c;
@@ -2277,7 +2277,7 @@ calc_enc_TB_size(struct rte_bbdev_enc_op *op)
        uint8_t i;
        uint32_t c, r, tb_size = 0;
 
-       if (op->turbo_enc.code_block_mode) {
+       if (op->turbo_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
                tb_size = op->turbo_enc.tb_params.k_neg;
        } else {
                c = op->turbo_enc.tb_params.c;
@@ -2297,7 +2297,7 @@ calc_ldpc_enc_TB_size(struct rte_bbdev_enc_op *op)
        uint32_t c, r, tb_size = 0;
        uint16_t sys_cols = (op->ldpc_enc.basegraph == 1) ? 22 : 10;
 
-       if (op->turbo_enc.code_block_mode) {
+       if (op->ldpc_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
                tb_size = sys_cols * op->ldpc_enc.z_c - op->ldpc_enc.n_filler;
        } else {
                c = op->turbo_enc.tb_params.c;
index 50d1da0..614dbd1 100644 (file)
@@ -1052,9 +1052,9 @@ check_decoder(struct test_bbdev_vector *vector)
        if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
                printf(
                        "WARNING: code_block_mode was not specified in vector file and will be set to 1 (0 - TB Mode, 1 - CB mode)\n");
-               turbo_dec->code_block_mode = 1;
+               turbo_dec->code_block_mode = RTE_BBDEV_CODE_BLOCK;
        }
-       if (turbo_dec->code_block_mode == 0) {
+       if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                if (!(mask & TEST_BBDEV_VF_EA))
                        printf(
                                "WARNING: ea was not specified in vector file and will be set to 0\n");
@@ -1142,9 +1142,9 @@ check_ldpc_decoder(struct test_bbdev_vector *vector)
        if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
                printf(
                        "WARNING: code_block_mode was not specified in vector file and will be set to 1 (0 - TB Mode, 1 - CB mode)\n");
-               ldpc_dec->code_block_mode = 1;
+               ldpc_dec->code_block_mode = RTE_BBDEV_CODE_BLOCK;
        }
-       if (ldpc_dec->code_block_mode == 0) {
+       if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                if (!(mask & TEST_BBDEV_VF_EA))
                        printf(
                                "WARNING: ea was not specified in vector file and will be set to 0\n");
@@ -1210,9 +1210,9 @@ check_encoder(struct test_bbdev_vector *vector)
        if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
                printf(
                        "WARNING: code_block_mode was not specified in vector file and will be set to 1\n");
-               vector->turbo_enc.code_block_mode = 1;
+               vector->turbo_enc.code_block_mode = RTE_BBDEV_CODE_BLOCK;
        }
-       if (vector->turbo_enc.code_block_mode == 0) {
+       if (vector->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                if (!(mask & TEST_BBDEV_VF_EA) && (vector->turbo_enc.op_flags &
                                RTE_BBDEV_TURBO_RATE_MATCH))
                        printf(
@@ -1298,9 +1298,9 @@ check_ldpc_encoder(struct test_bbdev_vector *vector)
        if (!(mask & TEST_BBDEV_VF_CODE_BLOCK_MODE)) {
                printf(
                        "WARNING: code_block_mode was not specified in vector file and will be set to 1\n");
-               vector->turbo_enc.code_block_mode = 1;
+               vector->turbo_enc.code_block_mode = RTE_BBDEV_CODE_BLOCK;
        }
-       if (vector->turbo_enc.code_block_mode == 0) {
+       if (vector->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
        } else {
                if (!(mask & TEST_BBDEV_VF_E) && (vector->turbo_enc.op_flags &
                                RTE_BBDEV_TURBO_RATE_MATCH))
index 5e663a6..ca2703f 100644 (file)
@@ -1168,7 +1168,7 @@ static inline void
 acc100_fcw_te_fill(const struct rte_bbdev_enc_op *op, struct acc100_fcw_te *fcw)
 {
        fcw->code_block_mode = op->turbo_enc.code_block_mode;
-       if (fcw->code_block_mode == 0) { /* For TB mode */
+       if (fcw->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                fcw->k_neg = op->turbo_enc.tb_params.k_neg;
                fcw->k_pos = op->turbo_enc.tb_params.k_pos;
                fcw->c_neg = op->turbo_enc.tb_params.c_neg;
@@ -1271,7 +1271,7 @@ acc100_fcw_td_fill(const struct rte_bbdev_dec_op *op, struct acc100_fcw_td *fcw)
 {
        /* Note : Early termination is always enabled for 4GUL */
        fcw->fcw_ver = 1;
-       if (op->turbo_dec.code_block_mode == 0)
+       if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                fcw->k_pos = op->turbo_dec.tb_params.k_pos;
        else
                fcw->k_pos = op->turbo_dec.cb_params.k;
@@ -1301,7 +1301,7 @@ acc100_fcw_ld_fill(const struct rte_bbdev_dec_op *op, struct acc100_fcw_ld *fcw,
        fcw->ncb = op->ldpc_dec.n_cb;
        fcw->k0 = get_k0(fcw->ncb, fcw->Zc, op->ldpc_dec.basegraph,
                        op->ldpc_dec.rv_index);
-       if (op->ldpc_dec.code_block_mode == 1)
+       if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
                fcw->rm_e = op->ldpc_dec.cb_params.e;
        else
                fcw->rm_e = (op->ldpc_dec.tb_params.r <
@@ -1554,7 +1554,7 @@ acc100_dma_desc_te_fill(struct rte_bbdev_enc_op *op,
        desc->word3 = 0;
        desc->numCBs = 1;
 
-       if (op->turbo_enc.code_block_mode == 0) {
+       if (op->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                ea = op->turbo_enc.tb_params.ea;
                eb = op->turbo_enc.tb_params.eb;
                cab = op->turbo_enc.tb_params.cab;
@@ -1695,7 +1695,7 @@ acc100_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
        desc->word3 = 0;
        desc->numCBs = 1;
 
-       if (op->turbo_dec.code_block_mode == 0) {
+       if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                k = (r < op->turbo_dec.tb_params.c_neg)
                        ? op->turbo_dec.tb_params.k_neg
                        : op->turbo_dec.tb_params.k_pos;
@@ -1707,7 +1707,7 @@ acc100_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
                e = op->turbo_dec.cb_params.e;
        }
 
-       if ((op->turbo_dec.code_block_mode == 0)
+       if ((op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                && !check_bit(op->turbo_dec.op_flags,
                RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
                crc24_overlap = 24;
@@ -2066,15 +2066,15 @@ validate_enc_op(struct rte_bbdev_enc_op *op)
                                turbo_enc->rv_index);
                return -1;
        }
-       if (turbo_enc->code_block_mode != 0 &&
-                       turbo_enc->code_block_mode != 1) {
+       if (turbo_enc->code_block_mode != RTE_BBDEV_TRANSPORT_BLOCK &&
+                       turbo_enc->code_block_mode != RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                turbo_enc->code_block_mode);
                return -1;
        }
 
-       if (turbo_enc->code_block_mode == 0) {
+       if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                tb = &turbo_enc->tb_params;
                if ((tb->k_neg < RTE_BBDEV_TURBO_MIN_CB_SIZE
                                || tb->k_neg > RTE_BBDEV_TURBO_MAX_CB_SIZE)
@@ -2214,7 +2214,7 @@ validate_ldpc_enc_op(struct rte_bbdev_enc_op *op)
                                ldpc_enc->rv_index);
                return -1;
        }
-       if (ldpc_enc->code_block_mode > 1) {
+       if (ldpc_enc->code_block_mode > RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                ldpc_enc->code_block_mode);
@@ -2258,7 +2258,7 @@ validate_ldpc_dec_op(struct rte_bbdev_dec_op *op)
                                ldpc_dec->rv_index);
                return -1;
        }
-       if (ldpc_dec->code_block_mode > 1) {
+       if (ldpc_dec->code_block_mode > RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                ldpc_dec->code_block_mode);
@@ -2581,15 +2581,15 @@ validate_dec_op(struct rte_bbdev_dec_op *op)
                                turbo_dec->iter_min, turbo_dec->iter_max);
                return -1;
        }
-       if (turbo_dec->code_block_mode != 0 &&
-                       turbo_dec->code_block_mode != 1) {
+       if (turbo_dec->code_block_mode != RTE_BBDEV_TRANSPORT_BLOCK &&
+                       turbo_dec->code_block_mode != RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                turbo_dec->code_block_mode);
                return -1;
        }
 
-       if (turbo_dec->code_block_mode == 0) {
+       if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                tb = &turbo_dec->tb_params;
                if ((tb->k_neg < RTE_BBDEV_TURBO_MIN_CB_SIZE
                                || tb->k_neg > RTE_BBDEV_TURBO_MAX_CB_SIZE)
@@ -3411,7 +3411,7 @@ acc100_enqueue_enc(struct rte_bbdev_queue_data *q_data,
 {
        if (unlikely(num == 0))
                return 0;
-       if (ops[0]->turbo_enc.code_block_mode == 0)
+       if (ops[0]->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                return acc100_enqueue_enc_tb(q_data, ops, num);
        else
                return acc100_enqueue_enc_cb(q_data, ops, num);
@@ -3424,7 +3424,7 @@ acc100_enqueue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 {
        if (unlikely(num == 0))
                return 0;
-       if (ops[0]->ldpc_enc.code_block_mode == 0)
+       if (ops[0]->ldpc_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                return acc100_enqueue_enc_tb(q_data, ops, num);
        else
                return acc100_enqueue_ldpc_enc_cb(q_data, ops, num);
@@ -3607,7 +3607,7 @@ acc100_enqueue_dec(struct rte_bbdev_queue_data *q_data,
 {
        if (unlikely(num == 0))
                return 0;
-       if (ops[0]->turbo_dec.code_block_mode == 0)
+       if (ops[0]->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                return acc100_enqueue_dec_tb(q_data, ops, num);
        else
                return acc100_enqueue_dec_cb(q_data, ops, num);
@@ -3625,7 +3625,7 @@ acc100_enqueue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
        if (unlikely((aq_avail == 0) || (num == 0)))
                return 0;
 
-       if (ops[0]->ldpc_dec.code_block_mode == 0)
+       if (ops[0]->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                return acc100_enqueue_ldpc_dec_tb(q_data, ops, num);
        else
                return acc100_enqueue_ldpc_dec_cb(q_data, ops, num);
@@ -3966,7 +3966,7 @@ acc100_dequeue_enc(struct rte_bbdev_queue_data *q_data,
        for (i = 0; i < dequeue_num; ++i) {
                op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
                        & q->sw_ring_wrap_mask))->req.op_addr;
-               if (op->turbo_enc.code_block_mode == 0)
+               if (op->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        ret = dequeue_enc_one_op_tb(q, &ops[i], dequeued_cbs,
                                        &aq_dequeued);
                else
@@ -4050,7 +4050,7 @@ acc100_dequeue_dec(struct rte_bbdev_queue_data *q_data,
        for (i = 0; i < dequeue_num; ++i) {
                op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
                        & q->sw_ring_wrap_mask))->req.op_addr;
-               if (op->turbo_dec.code_block_mode == 0)
+               if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
                                        &aq_dequeued);
                else
@@ -4095,7 +4095,7 @@ acc100_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
        for (i = 0; i < dequeue_num; ++i) {
                op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
                        & q->sw_ring_wrap_mask))->req.op_addr;
-               if (op->ldpc_dec.code_block_mode == 0)
+               if (op->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
                                        &aq_dequeued);
                else
index bd99fb4..026fc89 100644 (file)
@@ -1068,14 +1068,14 @@ validate_enc_op(struct rte_bbdev_enc_op *op __rte_unused)
                                ldpc_enc->basegraph);
                return -1;
        }
-       if (ldpc_enc->code_block_mode > 1) {
+       if (ldpc_enc->code_block_mode > RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0:Tb 1:CB",
                                ldpc_enc->code_block_mode);
                return -1;
        }
 
-       if (ldpc_enc->code_block_mode == 0) {
+       if (ldpc_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                tb = &ldpc_enc->tb_params;
                if (tb->c == 0) {
                        rte_bbdev_log(ERR,
@@ -1161,14 +1161,14 @@ validate_dec_op(struct rte_bbdev_dec_op *op __rte_unused)
                return -1;
        }
 
-       if (ldpc_dec->code_block_mode > 1) {
+       if (ldpc_dec->code_block_mode > RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                ldpc_dec->code_block_mode);
                return -1;
        }
 
-       if (ldpc_dec->code_block_mode == 0) {
+       if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                tb = &ldpc_dec->tb_params;
                if (tb->c < 1) {
                        rte_bbdev_log(ERR,
@@ -1370,7 +1370,7 @@ enqueue_ldpc_enc_one_op_cb(struct fpga_queue *q, struct rte_bbdev_enc_op *op,
        if (enc->op_flags & RTE_BBDEV_LDPC_CRC_24B_ATTACH)
                crc24_bits = 24;
 
-       if (enc->code_block_mode == 0) {
+       if (enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                /* For Transport Block mode */
                /* FIXME */
                c = enc->tb_params.c;
index a0fb11c..1a72aa7 100644 (file)
@@ -1309,7 +1309,7 @@ fpga_dma_desc_td_fill(struct rte_bbdev_dec_op *op,
        desc->k = k;
        desc->crc_type = !check_bit(op->turbo_dec.op_flags,
                        RTE_BBDEV_TURBO_CRC_TYPE_24B);
-       if ((op->turbo_dec.code_block_mode == 0)
+       if ((op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                && !check_bit(op->turbo_dec.op_flags,
                RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP))
                desc->drop_crc = 1;
@@ -1366,15 +1366,15 @@ validate_enc_op(struct rte_bbdev_enc_op *op)
                                turbo_enc->rv_index);
                return -1;
        }
-       if (turbo_enc->code_block_mode != 0 &&
-                       turbo_enc->code_block_mode != 1) {
+       if (turbo_enc->code_block_mode != RTE_BBDEV_TRANSPORT_BLOCK &&
+                       turbo_enc->code_block_mode != RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                turbo_enc->code_block_mode);
                return -1;
        }
 
-       if (turbo_enc->code_block_mode == 0) {
+       if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                tb = &turbo_enc->tb_params;
                if ((tb->k_neg < RTE_BBDEV_TURBO_MIN_CB_SIZE
                                || tb->k_neg > RTE_BBDEV_TURBO_MAX_CB_SIZE)
@@ -1698,15 +1698,15 @@ validate_dec_op(struct rte_bbdev_dec_op *op)
                                turbo_dec->iter_min, turbo_dec->iter_max);
                return -1;
        }
-       if (turbo_dec->code_block_mode != 0 &&
-                       turbo_dec->code_block_mode != 1) {
+       if (turbo_dec->code_block_mode != RTE_BBDEV_TRANSPORT_BLOCK &&
+                       turbo_dec->code_block_mode != RTE_BBDEV_CODE_BLOCK) {
                rte_bbdev_log(ERR,
                                "code_block_mode (%u) is out of range 0 <= value <= 1",
                                turbo_dec->code_block_mode);
                return -1;
        }
 
-       if (turbo_dec->code_block_mode == 0) {
+       if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
 
                if ((turbo_dec->op_flags &
                        RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP) &&
@@ -1957,7 +1957,8 @@ fpga_enqueue_enc(struct rte_bbdev_queue_data *q_data,
                q->ring_ctrl_reg.ring_size + q->head_free_desc - q->tail - 1;
 
        for (i = 0; i < num; ++i) {
-               if (ops[i]->turbo_enc.code_block_mode == 0) {
+               if (ops[i]->turbo_enc.code_block_mode ==
+                               RTE_BBDEV_TRANSPORT_BLOCK) {
                        cbs_in_op = get_num_cbs_in_op_enc(&ops[i]->turbo_enc);
                        /* Check if there is available space for further
                         * processing
@@ -2026,7 +2027,8 @@ fpga_enqueue_dec(struct rte_bbdev_queue_data *q_data,
                q->ring_ctrl_reg.ring_size + q->head_free_desc - q->tail - 1;
 
        for (i = 0; i < num; ++i) {
-               if (ops[i]->turbo_dec.code_block_mode == 0) {
+               if (ops[i]->turbo_dec.code_block_mode ==
+                               RTE_BBDEV_TRANSPORT_BLOCK) {
                        cbs_in_op = get_num_cbs_in_op_dec(&ops[i]->turbo_dec);
                        /* Check if there is available space for further
                         * processing
@@ -2246,7 +2248,7 @@ fpga_dequeue_enc(struct rte_bbdev_queue_data *q_data,
        for (i = 0; (i < num) && (dequeued_cbs < avail); ++i) {
                op = (q->ring_addr + ((q->head_free_desc + dequeued_cbs)
                        & q->sw_ring_wrap_mask))->enc_req.op_addr;
-               if (op->turbo_enc.code_block_mode == 0)
+               if (op->turbo_enc.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        ret = dequeue_enc_one_op_tb(q, &ops[i], dequeued_cbs);
                else
                        ret = dequeue_enc_one_op_cb(q, &ops[i], dequeued_cbs);
@@ -2284,7 +2286,7 @@ fpga_dequeue_dec(struct rte_bbdev_queue_data *q_data,
        for (i = 0; (i < num) && (dequeued_cbs < avail); ++i) {
                op = (q->ring_addr + ((q->head_free_desc + dequeued_cbs)
                        & q->sw_ring_wrap_mask))->dec_req.op_addr;
-               if (op->turbo_dec.code_block_mode == 0)
+               if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs);
                else
                        ret = dequeue_dec_one_op_cb(q, &ops[i], dequeued_cbs);
index aa7f122..85cf93d 100644 (file)
@@ -578,7 +578,7 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
 
        /* CRC24A (for TB) */
        if ((enc->op_flags & RTE_BBDEV_TURBO_CRC_24A_ATTACH) &&
-               (enc->code_block_mode == 1)) {
+               (enc->code_block_mode == RTE_BBDEV_CODE_BLOCK)) {
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
                ret = is_enc_input_valid(k - 24, k_idx, in_length);
                if (ret != 0) {
@@ -1007,7 +1007,7 @@ enqueue_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
                (enc->op_flags & RTE_BBDEV_TURBO_CRC_24A_ATTACH))
                crc24_bits = 24;
 
-       if (enc->code_block_mode == 0) { /* For Transport Block mode */
+       if (enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                c = enc->tb_params.c;
                r = enc->tb_params.r;
        } else {/* For Code Block mode */
@@ -1019,7 +1019,7 @@ enqueue_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
 
                seg_total_left = rte_pktmbuf_data_len(m_in) - in_offset;
 
-               if (enc->code_block_mode == 0) {
+               if (enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        k = (r < enc->tb_params.c_neg) ?
                                enc->tb_params.k_neg : enc->tb_params.k_pos;
                        ncb = (r < enc->tb_params.c_neg) ?
@@ -1101,7 +1101,7 @@ enqueue_ldpc_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
                (enc->op_flags & RTE_BBDEV_TURBO_CRC_24A_ATTACH))
                crc24_bits = 24;
 
-       if (enc->code_block_mode == 0) { /* For Transport Block mode */
+       if (enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                c = enc->tb_params.c;
                r = enc->tb_params.r;
        } else { /* For Code Block mode */
@@ -1113,7 +1113,7 @@ enqueue_ldpc_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op,
 
                seg_total_left = rte_pktmbuf_data_len(m_in) - in_offset;
 
-               if (enc->code_block_mode == 0) {
+               if (enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                        e = (r < enc->tb_params.cab) ?
                                enc->tb_params.ea : enc->tb_params.eb;
                } else {
@@ -1570,7 +1570,7 @@ enqueue_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
                return;
        }
 
-       if (dec->code_block_mode == 0) { /* For Transport Block mode */
+       if (dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                c = dec->tb_params.c;
        } else { /* For Code Block mode */
                k = dec->cb_params.k;
@@ -1582,7 +1582,7 @@ enqueue_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
                crc24_overlap = 24;
 
        while (mbuf_total_left > 0) {
-               if (dec->code_block_mode == 0)
+               if (dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        k = (r < dec->tb_params.c_neg) ?
                                dec->tb_params.k_neg : dec->tb_params.k_pos;
 
@@ -1658,7 +1658,7 @@ enqueue_ldpc_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
                return;
        }
 
-       if (dec->code_block_mode == 0) { /* For Transport Block mode */
+       if (dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
                c = dec->tb_params.c;
                e = dec->tb_params.ea;
        } else { /* For Code Block mode */
@@ -1673,7 +1673,7 @@ enqueue_ldpc_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
        out_length = ((out_length - crc24_overlap - dec->n_filler) >> 3);
 
        while (mbuf_total_left > 0) {
-               if (dec->code_block_mode == 0)
+               if (dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
                        e = (r < dec->tb_params.cab) ?
                                dec->tb_params.ea : dec->tb_params.eb;
                /* Special case handling when overusing mbuf */
index f726d73..f946842 100644 (file)
@@ -112,7 +112,7 @@ enum rte_bbdev_op_td_flag_bitmasks {
        /** Set if a device supports scatter-gather functionality */
        RTE_BBDEV_TURBO_DEC_SCATTER_GATHER = (1ULL << 15),
        /** Set to keep CRC24B bits appended while decoding. Only usable when
-        * decoding Transport Blocks (code_block_mode = 0).
+        * decoding Transport Block mode.
         */
        RTE_BBDEV_TURBO_DEC_TB_CRC_24B_KEEP = (1ULL << 16)
 };
@@ -209,6 +209,14 @@ enum rte_bbdev_op_ldpcenc_flag_bitmasks {
        RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
 };
 
+/** Flags for the Code Block/Transport block mode  */
+enum rte_bbdev_op_cb_mode {
+       /** One operation is one or fraction of one transport block  */
+       RTE_BBDEV_TRANSPORT_BLOCK = 0,
+       /** One operation is one code block mode */
+       RTE_BBDEV_CODE_BLOCK = 1,
+};
+
 /** Data input and output buffer for BBDEV operations */
 struct rte_bbdev_op_data {
        /** The mbuf data structure representing the data for BBDEV operation.