From patchwork Wed Apr 4 14:05:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Chalupnik X-Patchwork-Id: 37124 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 807401C65F; Wed, 4 Apr 2018 16:06:31 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id DB6521C653 for ; Wed, 4 Apr 2018 16:06:27 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 07:06:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,406,1517904000"; d="scan'208";a="47901084" Received: from kchalupx-mobl.ger.corp.intel.com ([10.103.104.151]) by orsmga002.jf.intel.com with ESMTP; 04 Apr 2018 07:06:25 -0700 From: KamilX Chalupnik To: dev@dpdk.org Cc: amr.mokhtar@intel.com, "Chalupnik, KamilX" Date: Wed, 4 Apr 2018 16:05:57 +0200 Message-Id: <20180404140602.9344-3-kamilx.chalupnik@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20180404140602.9344-1-kamilx.chalupnik@intel.com> References: <20180404140602.9344-1-kamilx.chalupnik@intel.com> Subject: [dpdk-dev] [PATCH] baseband/turbo_sw: optimization of turbo software driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Chalupnik, KamilX" Optimization of Turbo Software driver: - resource-hungry piece of code removed or optimized - validation of decoder/encoder parameters put under debug flag Signed-off-by: KamilX Chalupnik --- drivers/baseband/turbo_sw/bbdev_turbo_software.c | 264 +++++++++++++---------- lib/librte_bbdev/rte_bbdev_op.h | 18 +- 2 files changed, 172 insertions(+), 110 deletions(-) diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c index 70691f3..0d3b00f 100644 --- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c +++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c @@ -21,12 +21,6 @@ #define DRIVER_NAME turbo_sw -/* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ -#define C_SUBBLOCK (32) -#define MAX_TB_SIZE (391656) -#define MAX_CB_SIZE (6144) -#define MAX_KW (18528) - /* private data structure */ struct bbdev_private { unsigned int max_nb_queues; /**< Max number of queues */ @@ -47,6 +41,13 @@ static const char * const turbo_sw_valid_params[] = { TURBO_SW_SOCKET_ID_ARG }; +/* Turbo SW PMD logging ID */ +static int turbosw_pmd_logtype; + +/* Helper macro for logging */ +#define turbosw_pmd_log(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, turbosw_pmd_logtype, fmt "\n", ##__VA_ARGS__) + /* queue */ struct turbo_sw_queue { /* Ring for processed (encoded/decoded) operations which are ready to @@ -79,7 +80,7 @@ compute_idx(uint16_t k) { int32_t result = 0; - if (k < 40 || k > MAX_CB_SIZE) + if (k < RTE_BBDEV_MIN_CB_SIZE || k > RTE_BBDEV_MAX_CB_SIZE) return -1; if (k > 2048) { @@ -169,7 +170,7 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info) dev_info->cpu_flag_reqs = &cpu_flag; dev_info->min_alignment = 64; - rte_bbdev_log_debug("got device info from %u\n", dev->data->dev_id); + turbosw_pmd_log(DEBUG, "got device info from %u\n", dev->data->dev_id); } /* Release queue */ @@ -191,7 +192,7 @@ q_release(struct rte_bbdev *dev, uint16_t q_id) dev->data->queues[q_id].queue_private = NULL; } - rte_bbdev_log_debug("released device queue %u:%u", + turbosw_pmd_log(DEBUG, "released device queue %u:%u", dev->data->dev_id, q_id); return 0; } @@ -209,7 +210,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, q = rte_zmalloc_socket(RTE_STR(DRIVER_NAME), sizeof(*q), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q == NULL) { - rte_bbdev_log(ERR, "Failed to allocate queue memory"); + turbosw_pmd_log(ERR, "Failed to allocate queue memory"); return -ENOMEM; } @@ -217,16 +218,17 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, ret = snprintf(name, RTE_RING_NAMESIZE, RTE_STR(DRIVER_NAME)"_enc_out%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->enc_out = rte_zmalloc_socket(name, - ((MAX_TB_SIZE >> 3) + 3) * sizeof(*q->enc_out) * 3, + ((RTE_BBDEV_MAX_TB_SIZE >> 3) + 3) * + sizeof(*q->enc_out) * 3, RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_out == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -236,16 +238,16 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, RTE_STR(DRIVER_NAME)"_enc_in%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->enc_in = rte_zmalloc_socket(name, - (MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), + (RTE_BBDEV_MAX_CB_SIZE >> 3) * sizeof(*q->enc_in), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->enc_in == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -254,16 +256,16 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, ret = snprintf(name, RTE_RING_NAMESIZE, RTE_STR(DRIVER_NAME)"_ag%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->ag = rte_zmalloc_socket(name, - MAX_CB_SIZE * 10 * sizeof(*q->ag), + RTE_BBDEV_MAX_CB_SIZE * 10 * sizeof(*q->ag), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->ag == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -272,7 +274,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, ret = snprintf(name, RTE_RING_NAMESIZE, RTE_STR(DRIVER_NAME)"_cb%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; @@ -281,7 +283,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, (6144 >> 3) * sizeof(*q->code_block), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->code_block == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -291,16 +293,16 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, RTE_STR(DRIVER_NAME)"_deint_input%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->deint_input = rte_zmalloc_socket(name, - MAX_KW * sizeof(*q->deint_input), + RTE_BBDEV_MAX_KW * sizeof(*q->deint_input), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->deint_input == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -310,16 +312,16 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, RTE_STR(DRIVER_NAME)"_deint_output%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->deint_output = rte_zmalloc_socket(NULL, - MAX_KW * sizeof(*q->deint_output), + RTE_BBDEV_MAX_KW * sizeof(*q->deint_output), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->deint_output == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -329,16 +331,16 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, RTE_STR(DRIVER_NAME)"_adapter_output%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; } q->adapter_output = rte_zmalloc_socket(NULL, - MAX_CB_SIZE * 6 * sizeof(*q->adapter_output), + RTE_BBDEV_MAX_CB_SIZE * 6 * sizeof(*q->adapter_output), RTE_CACHE_LINE_SIZE, queue_conf->socket); if (q->adapter_output == NULL) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Failed to allocate queue memory for %s", name); goto free_q; } @@ -347,7 +349,7 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, ret = snprintf(name, RTE_RING_NAMESIZE, RTE_STR(DRIVER_NAME)"%u:%u", dev->data->dev_id, q_id); if ((ret < 0) || (ret >= (int)RTE_RING_NAMESIZE)) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Creating queue name for device %u queue %u failed", dev->data->dev_id, q_id); return -ENAMETOOLONG; @@ -355,14 +357,14 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id, 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); + turbosw_pmd_log(ERR, "Failed to create ring for %s", name); goto free_q; } q->type = queue_conf->op_type; dev->data->queues[q_id].queue_private = q; - rte_bbdev_log_debug("setup device queue %s", name); + turbosw_pmd_log(DEBUG, "setup device queue %s", name); return 0; free_q: @@ -384,6 +386,7 @@ static const struct rte_bbdev_ops pmd_ops = { .queue_release = q_release }; +#ifdef RTE_LIBRTE_BBDEV_DEBUG /* Checks if the encoder input buffer is correct. * Returns 0 if it's valid, -1 otherwise. */ @@ -392,26 +395,28 @@ is_enc_input_valid(const uint16_t k, const int32_t k_idx, const uint16_t in_length) { if (k_idx < 0) { - rte_bbdev_log(ERR, "K Index is invalid"); + turbosw_pmd_log(ERR, "K Index is invalid"); return -1; } if (in_length - (k >> 3) < 0) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Mismatch between input length (%u bytes) and K (%u bits)", in_length, k); return -1; } - if (k > MAX_CB_SIZE) { - rte_bbdev_log(ERR, "CB size (%u) is too big, max: %d", - k, MAX_CB_SIZE); + if (k > RTE_BBDEV_MAX_CB_SIZE) { + turbosw_pmd_log(ERR, "CB size (%u) is too big, max: %d", + k, RTE_BBDEV_MAX_CB_SIZE); return -1; } return 0; } +#endif +#ifdef RTE_LIBRTE_BBDEV_DEBUG /* Checks if the decoder input buffer is correct. * Returns 0 if it's valid, -1 otherwise. */ @@ -419,37 +424,43 @@ static inline int is_dec_input_valid(int32_t k_idx, int16_t kw, int16_t in_length) { if (k_idx < 0) { - rte_bbdev_log(ERR, "K index is invalid"); + turbosw_pmd_log(ERR, "K index is invalid"); return -1; } if (in_length - kw < 0) { - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Mismatch between input length (%u) and kw (%u)", in_length, kw); return -1; } - if (kw > MAX_KW) { - rte_bbdev_log(ERR, "Input length (%u) is too big, max: %d", - kw, MAX_KW); + if (kw > RTE_BBDEV_MAX_KW) { + turbosw_pmd_log(ERR, "Input length (%u) is too big, max: %d", + kw, RTE_BBDEV_MAX_KW); return -1; } return 0; } +#endif static inline void process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, - uint8_t cb_idx, uint8_t c, uint16_t k, uint16_t ncb, + uint8_t r, uint8_t c, uint16_t k, uint16_t ncb, uint32_t e, struct rte_mbuf *m_in, struct rte_mbuf *m_out, uint16_t in_offset, uint16_t out_offset, uint16_t total_left, struct rte_bbdev_stats *q_stats) { +#ifdef RTE_LIBRTE_BBDEV_DEBUG int ret; +#else + RTE_SET_USED(total_left); +#endif int16_t k_idx; uint16_t m; uint8_t *in, *out0, *out1, *out2, *tmp_out, *rm_out; + uint64_t first_3_bytes = 0; struct rte_bbdev_op_turbo_enc *enc = &op->turbo_enc; struct bblib_crc_request crc_req; struct bblib_crc_response crc_resp; @@ -469,73 +480,116 @@ 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)) { +#ifdef RTE_LIBRTE_BBDEV_DEBUG ret = is_enc_input_valid(k - 24, k_idx, total_left); if (ret != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; return; } - /* copy the input to the temporary buffer to be able to extend - * it by 3 CRC bytes - */ - rte_memcpy(q->enc_in, in, (k - 24) >> 3); +#endif + crc_req.data = in; crc_req.len = (k - 24) >> 3; - crc_resp.data = q->enc_in; + /* Check if there is a room for CRC bits if not use + * the temporary buffer. + */ + if (rte_pktmbuf_append(m_in, 3) == NULL) { + rte_memcpy(q->enc_in, in, (k - 24) >> 3); + in = q->enc_in; + } else { + /* Store 3 first bytes of next CB as they will be + * overwritten by CRC bytes. If it is the last CB then + * there is no point to store 3 next bytes and this + * if..else branch will be omitted. + */ + first_3_bytes = *((uint64_t *)&in[(k - 32) >> 3]); + } + crc_resp.data = in; #ifdef RTE_TEST_BBDEV start_time = rte_rdtsc_precise(); #endif - bblib_lte_crc24a_gen(&crc_req, &crc_resp); - #ifdef RTE_TEST_BBDEV q_stats->turbo_perf_time += rte_rdtsc_precise() - start_time; #endif - - in = q->enc_in; } else if (enc->op_flags & RTE_BBDEV_TURBO_CRC_24B_ATTACH) { /* CRC24B */ +#ifdef RTE_LIBRTE_BBDEV_DEBUG ret = is_enc_input_valid(k - 24, k_idx, total_left); if (ret != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; return; } - /* copy the input to the temporary buffer to be able to extend - * it by 3 CRC bytes - */ - rte_memcpy(q->enc_in, in, (k - 24) >> 3); +#endif + crc_req.data = in; crc_req.len = (k - 24) >> 3; - crc_resp.data = q->enc_in; + /* Check if there is a room for CRC bits if this is the last + * CB in TB. If not use temporary buffer. + */ + if ((c - r == 1) && (rte_pktmbuf_append(m_in, 3) == NULL)) { + rte_memcpy(q->enc_in, in, (k - 24) >> 3); + in = q->enc_in; + } else if (c - r > 1) { + /* Store 3 first bytes of next CB as they will be + * overwritten by CRC bytes. If it is the last CB then + * there is no point to store 3 next bytes and this + * if..else branch will be omitted. + */ + first_3_bytes = *((uint64_t *)&in[(k - 32) >> 3]); + } + crc_resp.data = in; #ifdef RTE_TEST_BBDEV start_time = rte_rdtsc_precise(); #endif - bblib_lte_crc24b_gen(&crc_req, &crc_resp); - #ifdef RTE_TEST_BBDEV q_stats->turbo_perf_time += rte_rdtsc_precise() - start_time; #endif - - in = q->enc_in; - } else { + } +#ifdef RTE_LIBRTE_BBDEV_DEBUG + else { ret = is_enc_input_valid(k, k_idx, total_left); if (ret != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; return; } } +#endif /* Turbo encoder */ /* Each bit layer output from turbo encoder is (k+4) bits long, i.e. * input length + 4 tail bits. That's (k/8) + 1 bytes after rounding up. * So dst_data's length should be 3*(k/8) + 3 bytes. + * In Rate-matching bypass case outputs pointers passed to encoder + * (out0, out1 and out2) can directly point to addresses of output from + * turbo_enc entity. */ - out0 = q->enc_out; - out1 = RTE_PTR_ADD(out0, (k >> 3) + 1); - out2 = RTE_PTR_ADD(out1, (k >> 3) + 1); + if (enc->op_flags & RTE_BBDEV_TURBO_RATE_MATCH) { + out0 = q->enc_out; + out1 = RTE_PTR_ADD(out0, (k >> 3) + 1); + out2 = RTE_PTR_ADD(out1, (k >> 3) + 1); + } else { + out0 = (uint8_t *)rte_pktmbuf_append(m_out, (k >> 3) * 3 + 2); + if (out0 == NULL) { + op->status |= 1 << RTE_BBDEV_DATA_ERROR; + turbosw_pmd_log(ERR, + "Too little space in output mbuf"); + return; + } + enc->output.length += (k >> 3) * 3 + 2; + /* rte_bbdev_op_data.offset can be different than the + * offset of the appended bytes + */ + out0 = rte_pktmbuf_mtod_offset(m_out, uint8_t *, out_offset); + out1 = rte_pktmbuf_mtod_offset(m_out, uint8_t *, + out_offset + (k >> 3) + 1); + out2 = rte_pktmbuf_mtod_offset(m_out, uint8_t *, + out_offset + 2 * ((k >> 3) + 1)); + } turbo_req.case_id = k_idx; turbo_req.input_win = in; @@ -550,7 +604,7 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, if (bblib_turbo_encoder(&turbo_req, &turbo_resp) != 0) { op->status |= 1 << RTE_BBDEV_DRV_ERROR; - rte_bbdev_log(ERR, "Turbo Encoder failed"); + turbosw_pmd_log(ERR, "Turbo Encoder failed"); return; } @@ -558,13 +612,17 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, q_stats->turbo_perf_time += rte_rdtsc_precise() - start_time; #endif + /* Restore 3 first bytes of next CB if they were overwritten by CRC*/ + if (first_3_bytes != 0) + *((uint64_t *)&in[(k - 32) >> 3]) = first_3_bytes; + /* Rate-matching */ if (enc->op_flags & RTE_BBDEV_TURBO_RATE_MATCH) { /* get output data starting address */ rm_out = (uint8_t *)rte_pktmbuf_append(m_out, (e >> 3)); if (rm_out == NULL) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Too little space in output mbuf"); return; } @@ -574,7 +632,7 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, rm_out = rte_pktmbuf_mtod_offset(m_out, uint8_t *, out_offset); /* index of current code block */ - rm_req.r = cb_idx; + rm_req.r = r; /* total number of code block */ rm_req.C = c; /* For DL - 1, UL - 0 */ @@ -613,7 +671,7 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, if (bblib_rate_match_dl(&rm_req, &rm_resp) != 0) { op->status |= 1 << RTE_BBDEV_DRV_ERROR; - rte_bbdev_log(ERR, "Rate matching failed"); + turbosw_pmd_log(ERR, "Rate matching failed"); return; } @@ -644,23 +702,6 @@ process_enc_cb(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, tmp_out++; } *tmp_out = 0; - - /* copy shifted output to turbo_enc entity */ - out0 = (uint8_t *)rte_pktmbuf_append(m_out, - (k >> 3) * 3 + 2); - if (out0 == NULL) { - op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, - "Too little space in output mbuf"); - return; - } - enc->output.length += (k >> 3) * 3 + 2; - /* rte_bbdev_op_data.offset can be different than the - * offset of the appended bytes - */ - out0 = rte_pktmbuf_mtod_offset(m_out, uint8_t *, - out_offset); - rte_memcpy(out0, q->enc_out, (k >> 3) * 3 + 2); } } @@ -681,15 +722,15 @@ enqueue_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, /* Clear op status */ op->status = 0; - if (total_left > MAX_TB_SIZE >> 3) { - rte_bbdev_log(ERR, "TB size (%u) is too big, max: %d", - total_left, MAX_TB_SIZE); + if (total_left > RTE_BBDEV_MAX_TB_SIZE >> 3) { + turbosw_pmd_log(ERR, "TB size (%u) is too big, max: %d", + total_left, RTE_BBDEV_MAX_TB_SIZE); op->status = 1 << RTE_BBDEV_DATA_ERROR; return; } if (m_in == NULL || m_out == NULL) { - rte_bbdev_log(ERR, "Invalid mbuf pointer"); + turbosw_pmd_log(ERR, "Invalid mbuf pointer"); op->status = 1 << RTE_BBDEV_DATA_ERROR; return; } @@ -737,7 +778,7 @@ enqueue_enc_one_op(struct turbo_sw_queue *q, struct rte_bbdev_enc_op *op, /* check if all input data was processed */ if (total_left != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Mismatch between mbuf length and included CBs sizes"); } } @@ -772,11 +813,11 @@ remove_nulls_from_circular_buf(const uint8_t *in, uint8_t *out, uint16_t k, const uint32_t d = k + 4; const uint32_t kw = (ncb / 3); const uint32_t nd = kw - d; - const uint32_t r_subblock = kw / C_SUBBLOCK; + const uint32_t r_subblock = kw / RTE_BBDEV_C_SUBBLOCK; /* Inter-column permutation pattern */ - const uint32_t P[C_SUBBLOCK] = {0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, - 26, 6, 22, 14, 30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, - 11, 27, 7, 23, 15, 31}; + const uint32_t P[RTE_BBDEV_C_SUBBLOCK] = {0, 16, 8, 24, 4, 20, 12, 28, + 2, 18, 10, 26, 6, 22, 14, 30, 1, 17, 9, 25, 5, 21, 13, + 29, 3, 19, 11, 27, 7, 23, 15, 31}; in_idx = 0; out_idx = 0; @@ -857,7 +898,11 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op, struct rte_mbuf *m_out, uint16_t in_offset, uint16_t out_offset, bool check_crc_24b, uint16_t total_left) { +#ifdef RTE_LIBRTE_BBDEV_DEBUG int ret; +#else + RTE_SET_USED(total_left); +#endif int32_t k_idx; int32_t iter_cnt; uint8_t *in, *out, *adapter_input; @@ -870,11 +915,13 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op, k_idx = compute_idx(k); +#ifdef RTE_LIBRTE_BBDEV_DEBUG ret = is_dec_input_valid(k_idx, kw, total_left); if (ret != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; return; } +#endif in = rte_pktmbuf_mtod_offset(m_in, uint8_t *, in_offset); ncb = kw; @@ -904,7 +951,7 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op, adapter_req.isinverted = 0; else { op->status |= 1 << RTE_BBDEV_DRV_ERROR; - rte_bbdev_log(ERR, "LLR format wasn't specified"); + turbosw_pmd_log(ERR, "LLR format wasn't specified"); return; } @@ -916,7 +963,7 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op, out = (uint8_t *)rte_pktmbuf_append(m_out, (k >> 3)); if (out == NULL) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, "Too little space in output mbuf"); + turbosw_pmd_log(ERR, "Too little space in output mbuf"); return; } /* rte_bbdev_op_data.offset can be different than the offset of the @@ -945,7 +992,7 @@ process_dec_cb(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op, dec->iter_count = RTE_MAX(iter_cnt, dec->iter_count); } else { op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, "Turbo Decoder failed"); + turbosw_pmd_log(ERR, "Turbo Decoder failed"); return; } } @@ -966,7 +1013,7 @@ enqueue_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op) op->status = 0; if (m_in == NULL || m_out == NULL) { - rte_bbdev_log(ERR, "Invalid mbuf pointer"); + turbosw_pmd_log(ERR, "Invalid mbuf pointer"); op->status = 1 << RTE_BBDEV_DATA_ERROR; return; } @@ -993,7 +1040,7 @@ enqueue_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op) * where D is the size of each output from turbo encoder block * (k + 4). */ - kw = RTE_ALIGN_CEIL(k + 4, C_SUBBLOCK) * 3; + kw = RTE_ALIGN_CEIL(k + 4, RTE_BBDEV_C_SUBBLOCK) * 3; process_dec_cb(q, op, c, k, kw, m_in, m_out, in_offset, out_offset, check_bit(dec->op_flags, @@ -1012,7 +1059,7 @@ enqueue_dec_one_op(struct turbo_sw_queue *q, struct rte_bbdev_dec_op *op) } if (total_left != 0) { op->status |= 1 << RTE_BBDEV_DATA_ERROR; - rte_bbdev_log(ERR, + turbosw_pmd_log(ERR, "Mismatch between mbuf length and included Circular buffer sizes"); } } @@ -1102,7 +1149,7 @@ parse_u16_arg(const char *key, const char *value, void *extra_args) errno = 0; result = strtoul(value, NULL, 0); if ((result >= (1 << 16)) || (errno != 0)) { - rte_bbdev_log(ERR, "Invalid value %lu for %s", result, key); + turbosw_pmd_log(ERR, "Invalid value %lu for %s", result, key); return -ERANGE; } *u16 = (uint16_t)result; @@ -1134,7 +1181,7 @@ parse_turbo_sw_params(struct turbo_sw_params *params, const char *input_args) goto exit; if (params->socket_id >= RTE_MAX_NUMA_NODES) { - rte_bbdev_log(ERR, "Invalid socket, must be < %u", + turbosw_pmd_log(ERR, "Invalid socket, must be < %u", RTE_MAX_NUMA_NODES); goto exit; } @@ -1202,7 +1249,7 @@ turbo_sw_bbdev_probe(struct rte_vdev_device *vdev) input_args = rte_vdev_device_args(vdev); parse_turbo_sw_params(&init_params, input_args); - rte_bbdev_log_debug( + turbosw_pmd_log(DEBUG, "Initialising %s on NUMA node %d with max queues: %d\n", name, init_params.socket_id, init_params.queues_num); @@ -1242,12 +1289,11 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME, TURBO_SW_MAX_NB_QUEUES_ARG"= " TURBO_SW_SOCKET_ID_ARG"="); -int bbdev_logtype; RTE_INIT(null_bbdev_init_log); static void null_bbdev_init_log(void) { - bbdev_logtype = rte_log_register("pmd.bbdev.turbo_sw"); - if (bbdev_logtype >= 0) - rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE); + turbosw_pmd_logtype = rte_log_register("pmd.bbdev.turbo_sw"); + if (turbosw_pmd_logtype >= 0) + rte_log_set_level(turbosw_pmd_logtype, RTE_LOG_NOTICE); } diff --git a/lib/librte_bbdev/rte_bbdev_op.h b/lib/librte_bbdev/rte_bbdev_op.h index 9a80c64..1a80588 100644 --- a/lib/librte_bbdev/rte_bbdev_op.h +++ b/lib/librte_bbdev/rte_bbdev_op.h @@ -25,7 +25,23 @@ extern "C" { #include #include -#define RTE_BBDEV_MAX_CODE_BLOCKS 64 +/* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */ +#define RTE_BBDEV_C_SUBBLOCK (32) +/* Maximum size of Transport Block (36.213, Table, Table 7.1.7.2.5-1) */ +#define RTE_BBDEV_MAX_TB_SIZE (391656) +/* Maximum size of Code Block (36.212, Table 5.1.3-3) */ +#define RTE_BBDEV_MAX_CB_SIZE (6144) +/* Minimum size of Code Block (36.212, Table 5.1.3-3) */ +#define RTE_BBDEV_MIN_CB_SIZE (40) +/* Maximum size of circular buffer */ +#define RTE_BBDEV_MAX_KW (18528) +/* + * Maximum number of Code Blocks in Transport Block. It is calculated based on + * maximum size of one Code Block and one Transport Block (considering CRC24A + * and CRC24B): + * (391656 + 24) / (6144 - 24) = 64 + */ +#define RTE_BBDEV_MAX_CODE_BLOCKS (64) /** Flags for turbo decoder operation and capability structure */ enum rte_bbdev_op_td_flag_bitmasks {