diff mbox series

[v5,8/9] app/bbdev: handle endianness of test data

Message ID 20210912121510.22699-9-nipun.gupta@nxp.com
State New
Headers show
Series baseband: add NXP LA12xx driver | expand

Commit Message

Nipun Gupta Sept. 12, 2021, 12:15 p.m. UTC
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
test vector and the driver being used.

For instance, if the driver supports big endian data
processing, but the test vector does not mention the data
as a big endian format, conversion from little endian to big
will be handled by the testbbdev application.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

---
 app/test-bbdev/test_bbdev_perf.c   | 84 ++++++++++++++++++++++++++++++
 app/test-bbdev/test_bbdev_vector.c |  4 ++
 2 files changed, 88 insertions(+)

-- 
2.17.1

Comments

Chautru, Nicolas Sept. 13, 2021, 6:45 p.m. UTC | #1
> -----Original Message-----

> From: Nipun Gupta <nipun.gupta@nxp.com>

> Sent: Sunday, September 12, 2021 5:15 AM

> To: dev@dpdk.org; gakhil@marvell.com; Chautru, Nicolas

> <nicolas.chautru@intel.com>

> Cc: david.marchand@redhat.com; hemant.agrawal@nxp.com; Nipun Gupta

> <nipun.gupta@nxp.com>

> Subject: [PATCH v5 8/9] app/bbdev: handle endianness of test data

> 

> 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 test vector and the driver being used.

> 

> For instance, if the driver supports big endian data processing, but the test

> vector does not mention the data as a big endian format, conversion from

> little endian to big will be handled by the testbbdev application.


See command on the 1/9 with regards to how to expose the endianness. This will also simplify some of that code, as same vectors can be used any variant of PMD.

> 

> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

> ---

>  app/test-bbdev/test_bbdev_perf.c   | 84

> ++++++++++++++++++++++++++++++

>  app/test-bbdev/test_bbdev_vector.c |  4 ++

>  2 files changed, 88 insertions(+)

> 

> diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-

> bbdev/test_bbdev_perf.c

> index 469597b8b3..836e07d747 100644

> --- a/app/test-bbdev/test_bbdev_perf.c

> +++ b/app/test-bbdev/test_bbdev_perf.c

> @@ -227,6 +227,71 @@ clear_soft_out_cap(uint32_t *op_flags)

>  	*op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;

>  }

> 

> +static void

> +clear_ldpc_endianness_flag(uint32_t *op_flags) {

> +	*op_flags &= ~RTE_BBDEV_LDPC_ENC_BIG_ENDIAN;

> +	*op_flags &= ~RTE_BBDEV_LDPC_DEC_BIG_ENDIAN; }

> +

> +static inline void

> +reverse_op(struct op_data_entries *op)

> +{

> +	uint8_t nb_segs = op->nb_segments;

> +	uint32_t *data, len;

> +	int complete, rem, i, j;

> +	uint8_t *rem_data, temp;

> +

> +	/* Validate each mbuf segment length */

> +	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 data for last seg */

> +		if (i == (nb_segs - 1)) {

> +			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 inline void

> +reverse_all_ops(void)

> +{

> +	unsigned int nb_inputs, nb_soft_outputs, nb_hard_outputs,

> +		nb_harq_inputs, nb_harq_outputs;

> +

> +	nb_inputs = test_vector.entries[DATA_INPUT].nb_segments;

> +	if (nb_inputs)

> +		reverse_op(&test_vector.entries[DATA_INPUT]);

> +

> +	nb_soft_outputs =

> test_vector.entries[DATA_SOFT_OUTPUT].nb_segments;

> +	if (nb_soft_outputs)

> +		reverse_op(&test_vector.entries[DATA_SOFT_OUTPUT]);

> +

> +	nb_hard_outputs =

> test_vector.entries[DATA_HARD_OUTPUT].nb_segments;

> +	if (nb_hard_outputs)

> +		reverse_op(&test_vector.entries[DATA_HARD_OUTPUT]);

> +

> +	nb_harq_inputs  =

> test_vector.entries[DATA_HARQ_INPUT].nb_segments;

> +	if (nb_harq_inputs)

> +		reverse_op(&test_vector.entries[DATA_HARQ_INPUT]);

> +

> +	nb_harq_outputs =

> test_vector.entries[DATA_HARQ_OUTPUT].nb_segments;

> +	if (nb_harq_outputs)

> +		reverse_op(&test_vector.entries[DATA_HARQ_OUTPUT]);

> +}

> +

>  static int

>  check_dev_cap(const struct rte_bbdev_info *dev_info)  { @@ -324,6

> +389,16 @@ check_dev_cap(const struct rte_bbdev_info *dev_info)

>  			const struct rte_bbdev_op_cap_ldpc_enc *cap =

>  					&op_cap->cap.ldpc_enc;

> 

> +			if ((test_vector.ldpc_enc.op_flags &

> +

> 	RTE_BBDEV_LDPC_ENC_BIG_ENDIAN) !=

> +					(cap->capability_flags &

> +

> 	RTE_BBDEV_LDPC_ENC_BIG_ENDIAN)) {

> +				reverse_all_ops();

> +				clear_ldpc_endianness_flag(

> +					&test_vector.ldpc_enc.op_flags);

> +

> +			}

> +

>  			if (!flags_match(test_vector.ldpc_enc.op_flags,

>  					cap->capability_flags)){

>  				printf("Flag Mismatch\n");

> @@ -352,6 +427,15 @@ check_dev_cap(const struct rte_bbdev_info

> *dev_info)

>  			const struct rte_bbdev_op_cap_ldpc_dec *cap =

>  					&op_cap->cap.ldpc_dec;

> 

> +			if ((test_vector.ldpc_dec.op_flags &

> +

> 	RTE_BBDEV_LDPC_DEC_BIG_ENDIAN) !=

> +					(cap->capability_flags &

> +

> 	RTE_BBDEV_LDPC_DEC_BIG_ENDIAN)) {

> +				reverse_all_ops();

> +				clear_ldpc_endianness_flag(

> +					&test_vector.ldpc_dec.op_flags);

> +			}

> +

>  			if (!flags_match(test_vector.ldpc_dec.op_flags,

>  					cap->capability_flags)){

>  				printf("Flag Mismatch\n");

> diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-

> bbdev/test_bbdev_vector.c

> index 614dbd1a6d..b2e7a9008d 100644

> --- a/app/test-bbdev/test_bbdev_vector.c

> +++ b/app/test-bbdev/test_bbdev_vector.c

> @@ -191,6 +191,8 @@ op_ldpc_decoder_flag_strtoul(char *token, uint32_t

> *op_flag_value)

>  		*op_flag_value =

> RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;

>  	else if (!strcmp(token, "RTE_BBDEV_LDPC_LLR_COMPRESSION"))

>  		*op_flag_value = RTE_BBDEV_LDPC_LLR_COMPRESSION;

> +	else if (!strcmp(token, "RTE_BBDEV_LDPC_DEC_BIG_ENDIAN"))

> +		*op_flag_value = RTE_BBDEV_LDPC_DEC_BIG_ENDIAN;

>  	else if (!strcmp(token,

> 

> 	"RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE"))

>  		*op_flag_value =

> RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;

> @@ -248,6 +250,8 @@ op_ldpc_encoder_flag_strtoul(char *token, uint32_t

> *op_flag_value)

>  		*op_flag_value = RTE_BBDEV_LDPC_ENC_INTERRUPTS;

>  	else if (!strcmp(token,

> "RTE_BBDEV_LDPC_ENC_SCATTER_GATHER"))

>  		*op_flag_value =

> RTE_BBDEV_LDPC_ENC_SCATTER_GATHER;

> +	else if (!strcmp(token, "RTE_BBDEV_LDPC_ENC_BIG_ENDIAN"))

> +		*op_flag_value = RTE_BBDEV_LDPC_ENC_BIG_ENDIAN;

>  	else {

>  		printf("The given value is not a turbo encoder flag\n");

>  		return -1;

> --

> 2.17.1
diff mbox series

Patch

diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
index 469597b8b3..836e07d747 100644
--- a/app/test-bbdev/test_bbdev_perf.c
+++ b/app/test-bbdev/test_bbdev_perf.c
@@ -227,6 +227,71 @@  clear_soft_out_cap(uint32_t *op_flags)
 	*op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
 }
 
+static void
+clear_ldpc_endianness_flag(uint32_t *op_flags)
+{
+	*op_flags &= ~RTE_BBDEV_LDPC_ENC_BIG_ENDIAN;
+	*op_flags &= ~RTE_BBDEV_LDPC_DEC_BIG_ENDIAN;
+}
+
+static inline void
+reverse_op(struct op_data_entries *op)
+{
+	uint8_t nb_segs = op->nb_segments;
+	uint32_t *data, len;
+	int complete, rem, i, j;
+	uint8_t *rem_data, temp;
+
+	/* Validate each mbuf segment length */
+	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 data for last seg */
+		if (i == (nb_segs - 1)) {
+			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 inline void
+reverse_all_ops(void)
+{
+	unsigned int nb_inputs, nb_soft_outputs, nb_hard_outputs,
+		nb_harq_inputs, nb_harq_outputs;
+
+	nb_inputs = test_vector.entries[DATA_INPUT].nb_segments;
+	if (nb_inputs)
+		reverse_op(&test_vector.entries[DATA_INPUT]);
+
+	nb_soft_outputs = test_vector.entries[DATA_SOFT_OUTPUT].nb_segments;
+	if (nb_soft_outputs)
+		reverse_op(&test_vector.entries[DATA_SOFT_OUTPUT]);
+
+	nb_hard_outputs = test_vector.entries[DATA_HARD_OUTPUT].nb_segments;
+	if (nb_hard_outputs)
+		reverse_op(&test_vector.entries[DATA_HARD_OUTPUT]);
+
+	nb_harq_inputs  = test_vector.entries[DATA_HARQ_INPUT].nb_segments;
+	if (nb_harq_inputs)
+		reverse_op(&test_vector.entries[DATA_HARQ_INPUT]);
+
+	nb_harq_outputs = test_vector.entries[DATA_HARQ_OUTPUT].nb_segments;
+	if (nb_harq_outputs)
+		reverse_op(&test_vector.entries[DATA_HARQ_OUTPUT]);
+}
+
 static int
 check_dev_cap(const struct rte_bbdev_info *dev_info)
 {
@@ -324,6 +389,16 @@  check_dev_cap(const struct rte_bbdev_info *dev_info)
 			const struct rte_bbdev_op_cap_ldpc_enc *cap =
 					&op_cap->cap.ldpc_enc;
 
+			if ((test_vector.ldpc_enc.op_flags &
+					RTE_BBDEV_LDPC_ENC_BIG_ENDIAN) !=
+					(cap->capability_flags &
+					RTE_BBDEV_LDPC_ENC_BIG_ENDIAN)) {
+				reverse_all_ops();
+				clear_ldpc_endianness_flag(
+					&test_vector.ldpc_enc.op_flags);
+
+			}
+
 			if (!flags_match(test_vector.ldpc_enc.op_flags,
 					cap->capability_flags)){
 				printf("Flag Mismatch\n");
@@ -352,6 +427,15 @@  check_dev_cap(const struct rte_bbdev_info *dev_info)
 			const struct rte_bbdev_op_cap_ldpc_dec *cap =
 					&op_cap->cap.ldpc_dec;
 
+			if ((test_vector.ldpc_dec.op_flags &
+					RTE_BBDEV_LDPC_DEC_BIG_ENDIAN) !=
+					(cap->capability_flags &
+					RTE_BBDEV_LDPC_DEC_BIG_ENDIAN)) {
+				reverse_all_ops();
+				clear_ldpc_endianness_flag(
+					&test_vector.ldpc_dec.op_flags);
+			}
+
 			if (!flags_match(test_vector.ldpc_dec.op_flags,
 					cap->capability_flags)){
 				printf("Flag Mismatch\n");
diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index 614dbd1a6d..b2e7a9008d 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -191,6 +191,8 @@  op_ldpc_decoder_flag_strtoul(char *token, uint32_t *op_flag_value)
 		*op_flag_value = RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
 	else if (!strcmp(token, "RTE_BBDEV_LDPC_LLR_COMPRESSION"))
 		*op_flag_value = RTE_BBDEV_LDPC_LLR_COMPRESSION;
+	else if (!strcmp(token, "RTE_BBDEV_LDPC_DEC_BIG_ENDIAN"))
+		*op_flag_value = RTE_BBDEV_LDPC_DEC_BIG_ENDIAN;
 	else if (!strcmp(token,
 			"RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE"))
 		*op_flag_value = RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;
@@ -248,6 +250,8 @@  op_ldpc_encoder_flag_strtoul(char *token, uint32_t *op_flag_value)
 		*op_flag_value = RTE_BBDEV_LDPC_ENC_INTERRUPTS;
 	else if (!strcmp(token, "RTE_BBDEV_LDPC_ENC_SCATTER_GATHER"))
 		*op_flag_value = RTE_BBDEV_LDPC_ENC_SCATTER_GATHER;
+	else if (!strcmp(token, "RTE_BBDEV_LDPC_ENC_BIG_ENDIAN"))
+		*op_flag_value = RTE_BBDEV_LDPC_ENC_BIG_ENDIAN;
 	else {
 		printf("The given value is not a turbo encoder flag\n");
 		return -1;