From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C46CA0C47; Thu, 7 Oct 2021 11:34:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76EF3411F6; Thu, 7 Oct 2021 11:33:30 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 88893411A6 for ; Thu, 7 Oct 2021 11:33:21 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 69D811A0338; Thu, 7 Oct 2021 11:33:21 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F2F6A1A1D65; Thu, 7 Oct 2021 11:33:20 +0200 (CEST) Received: from lsv03274.swis.in-blr01.nxp.com (lsv03274.swis.in-blr01.nxp.com [92.120.147.114]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 5B710183AD28; Thu, 7 Oct 2021 17:33:20 +0800 (+08) From: nipun.gupta@nxp.com To: dev@dpdk.org, gakhil@marvell.com, nicolas.chautru@intel.com Cc: david.marchand@redhat.com, hemant.agrawal@nxp.com, Nipun Gupta Date: Thu, 7 Oct 2021 15:03:15 +0530 Message-Id: <20211007093315.17384-9-nipun.gupta@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211007093315.17384-1-nipun.gupta@nxp.com> References: <20210318063421.14895-1-hemant.agrawal@nxp.com> <20211007093315.17384-1-nipun.gupta@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v9 8/8] app/bbdev: handle endianness of test data X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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: Nipun Gupta With data input, output and harq also supported in big endian format, this patch updates the testbbdev application to handle the endianness conversion as directed by the the driver being used. The test vectors assumes the data in the little endian order, and thus if the driver supports big endian data processing, conversion from little endian to big is handled by the testbbdev application. Signed-off-by: Nipun Gupta --- app/test-bbdev/test_bbdev_perf.c | 43 ++++++++++++++++++++++++++++++++ doc/guides/tools/testbbdev.rst | 3 +++ 2 files changed, 46 insertions(+) diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c index 469597b8b3..05f12463a8 100644 --- a/app/test-bbdev/test_bbdev_perf.c +++ b/app/test-bbdev/test_bbdev_perf.c @@ -227,6 +227,45 @@ clear_soft_out_cap(uint32_t *op_flags) *op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT; } +/* This API is to convert all the test vector op data entries + * to big endian format. It is used when the device supports + * the input in the big endian format. + */ +static inline void +convert_op_data_to_be(void) +{ + struct op_data_entries *op; + enum op_data_type type; + uint8_t nb_segs, *rem_data, temp; + uint32_t *data, len; + int complete, rem, i, j; + + for (type = DATA_INPUT; type < DATA_NUM_TYPES; ++type) { + nb_segs = test_vector.entries[type].nb_segments; + op = &test_vector.entries[type]; + + /* Invert byte endianness for all the segments */ + for (i = 0; i < nb_segs; ++i) { + len = op->segments[i].length; + data = op->segments[i].addr; + + /* Swap complete u32 bytes */ + complete = len / 4; + for (j = 0; j < complete; j++) + data[j] = rte_bswap32(data[j]); + + /* Swap any remaining bytes */ + rem = len % 4; + rem_data = (uint8_t *)&data[j]; + for (j = 0; j < rem/2; j++) { + temp = rem_data[j]; + rem_data[j] = rem_data[rem - j - 1]; + rem_data[rem - j - 1] = temp; + } + } + } +} + static int check_dev_cap(const struct rte_bbdev_info *dev_info) { @@ -234,6 +273,7 @@ check_dev_cap(const struct rte_bbdev_info *dev_info) unsigned int nb_inputs, nb_soft_outputs, nb_hard_outputs, nb_harq_inputs, nb_harq_outputs; const struct rte_bbdev_op_cap *op_cap = dev_info->drv.capabilities; + uint8_t dev_data_endianness = dev_info->drv.data_endianness; nb_inputs = test_vector.entries[DATA_INPUT].nb_segments; nb_soft_outputs = test_vector.entries[DATA_SOFT_OUTPUT].nb_segments; @@ -245,6 +285,9 @@ check_dev_cap(const struct rte_bbdev_info *dev_info) if (op_cap->type != test_vector.op_type) continue; + if (dev_data_endianness == RTE_BBDEV_BIG_ENDIAN) + convert_op_data_to_be(); + if (op_cap->type == RTE_BBDEV_OP_TURBO_DEC) { const struct rte_bbdev_op_cap_turbo_dec *cap = &op_cap->cap.turbo_dec; diff --git a/doc/guides/tools/testbbdev.rst b/doc/guides/tools/testbbdev.rst index d397d991ff..83a0312062 100644 --- a/doc/guides/tools/testbbdev.rst +++ b/doc/guides/tools/testbbdev.rst @@ -332,6 +332,9 @@ Variable op_type has to be defined as a first variable in file. It specifies what type of operations will be executed. For 4G decoder op_type has to be set to ``RTE_BBDEV_OP_TURBO_DEC`` and for 4G encoder to ``RTE_BBDEV_OP_TURBO_ENC``. +Bbdev-test adjusts the byte endianness based on the PMD capability (data_endianness) +and all the test vectors input/output data are assumed to be LE by default + Full details of the meaning and valid values for the below fields are documented in *rte_bbdev_op.h* -- 2.17.1