#include <rte_ring.h>
#include <rte_kvargs.h>
#include <rte_cycles.h>
+#include <rte_errno.h>
#include <rte_bbdev.h>
#include <rte_bbdev_pmd.h>
#define DRIVER_NAME baseband_turbo_sw
-RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
+RTE_LOG_REGISTER_DEFAULT(bbdev_turbo_sw_logtype, NOTICE);
/* Helper macro for logging */
#define rte_bbdev_log(level, fmt, ...) \
.cap.ldpc_enc = {
.capability_flags =
RTE_BBDEV_LDPC_RATE_MATCH |
+ RTE_BBDEV_LDPC_CRC_16_ATTACH |
RTE_BBDEV_LDPC_CRC_24A_ATTACH |
RTE_BBDEV_LDPC_CRC_24B_ATTACH,
.num_buffers_src =
.type = RTE_BBDEV_OP_LDPC_DEC,
.cap.ldpc_dec = {
.capability_flags =
+ RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK |
RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK |
RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK |
RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP |
dev_info->capabilities = bbdev_capabilities;
dev_info->min_alignment = 64;
dev_info->harq_buffer_size = 0;
+ dev_info->data_endianness = RTE_LITTLE_ENDIAN;
rte_bbdev_log_debug("got device info from %u\n", dev->data->dev_id);
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->enc_out = rte_zmalloc_socket(name,
((RTE_BBDEV_TURBO_MAX_TB_SIZE >> 3) + 3) *
if (q->enc_out == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->enc_in = rte_zmalloc_socket(name,
(RTE_BBDEV_LDPC_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in),
if (q->enc_in == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->ag = rte_zmalloc_socket(name,
RTE_BBDEV_TURBO_MAX_CB_SIZE * 10 * sizeof(*q->ag),
if (q->ag == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->code_block = rte_zmalloc_socket(name,
RTE_BBDEV_TURBO_MAX_CB_SIZE * sizeof(*q->code_block),
if (q->code_block == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->deint_input = rte_zmalloc_socket(name,
DEINT_INPUT_BUF_SIZE * sizeof(*q->deint_input),
if (q->deint_input == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->deint_output = rte_zmalloc_socket(NULL,
DEINT_OUTPUT_BUF_SIZE * sizeof(*q->deint_output),
if (q->deint_output == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->adapter_output = rte_zmalloc_socket(NULL,
ADAPTER_OUTPUT_BUF_SIZE * sizeof(*q->adapter_output),
if (q->adapter_output == NULL) {
rte_bbdev_log(ERR,
"Failed to allocate queue memory for %s", name);
+ ret = -ENOMEM;
goto free_q;
}
rte_bbdev_log(ERR,
"Creating queue name for device %u queue %u failed",
dev->data->dev_id, q_id);
- return -ENAMETOOLONG;
+ ret = -ENAMETOOLONG;
+ goto free_q;
}
q->processed_pkts = rte_ring_create(name, queue_conf->queue_size,
queue_conf->socket, RING_F_SP_ENQ | RING_F_SC_DEQ);
if (q->processed_pkts == NULL) {
rte_bbdev_log(ERR, "Failed to create ring for %s", name);
+ ret = -rte_errno;
goto free_q;
}
rte_free(q->deint_output);
rte_free(q->adapter_output);
rte_free(q);
- return -EFAULT;
+ return ret;
}
static const struct rte_bbdev_ops pmd_ops = {
/* 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) {
crc_req.len = in_length_in_bits - 24;
crc_resp.data = q->enc_in;
bblib_lte_crc24b_gen(&crc_req, &crc_resp);
+ } else if (enc->op_flags & RTE_BBDEV_LDPC_CRC_16_ATTACH) {
+ rte_memcpy(q->enc_in, in, in_length_in_bytes - 2);
+ crc_req.data = in;
+ crc_req.len = in_length_in_bits - 16;
+ crc_resp.data = q->enc_in;
+ bblib_lte_crc16_gen(&crc_req, &crc_resp);
} else
rte_memcpy(q->enc_in, in, in_length_in_bytes);
(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 */
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) ?
(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 */
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 {
bblib_lte_crc24a_check(&crc_req, &crc_resp);
if (!crc_resp.check_passed)
op->status |= 1 << RTE_BBDEV_CRC_ERROR;
+ } else if (check_bit(dec->op_flags, RTE_BBDEV_LDPC_CRC_TYPE_16_CHECK)) {
+ crc_req.data = adapter_input;
+ crc_req.len = K - dec->n_filler - 16;
+ crc_resp.check_passed = false;
+ crc_resp.data = adapter_input;
+ bblib_lte_crc16_check(&crc_req, &crc_resp);
+ if (!crc_resp.check_passed)
+ op->status |= 1 << RTE_BBDEV_CRC_ERROR;
}
#ifdef RTE_BBDEV_OFFLOAD_COST
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;
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;
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 */
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 */