#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
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+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 |
RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |
RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE,
.llr_size = 8,
- .llr_decimals = 2,
- .harq_memory_size = 0,
+ .llr_decimals = 4,
.num_buffers_src =
RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
.num_buffers_hard_out =
dev_info->default_queue_conf = default_queue_conf;
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 {
static inline void
process_ldpc_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op,
- uint8_t c, uint16_t out_length, uint16_t e,
+ uint8_t c, uint16_t out_length, uint32_t e,
struct rte_mbuf *m_in,
struct rte_mbuf *m_out_head, struct rte_mbuf *m_out,
struct rte_mbuf *m_harq_in,
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;
struct rte_bbdev_stats *queue_stats)
{
uint8_t c, r = 0;
- uint16_t e, out_length;
- uint16_t crc24_overlap = 0;
+ uint32_t e;
+ uint16_t out_length, crc24_overlap = 0;
struct rte_bbdev_op_ldpc_dec *dec = &op->ldpc_dec;
struct rte_mbuf *m_in = dec->input.data;
struct rte_mbuf *m_harq_in = dec->harq_combined_input.data;
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;
-
- seg_total_left = rte_pktmbuf_data_len(m_in) - in_offset;
+ /* Special case handling when overusing mbuf */
+ if (e < RTE_BBDEV_LDPC_E_MAX_MBUF)
+ seg_total_left = rte_pktmbuf_data_len(m_in) - in_offset;
+ else
+ seg_total_left = e;
process_ldpc_dec_cb(q, op, c, out_length, e,
m_in, m_out_head, m_out,
TURBO_SW_MAX_NB_QUEUES_ARG"=<int> "
TURBO_SW_SOCKET_ID_ARG"=<int>");
RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
-
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
- bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
- if (bbdev_turbo_sw_logtype >= 0)
- rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}