[dpdk-dev] [PATCH v7 8/9] app/bbdev: handle endianness of test data

Chautru, Nicolas nicolas.chautru at intel.com
Tue Oct 5 01:38:06 CEST 2021



> -----Original Message-----
> From: nipun.gupta at nxp.com <nipun.gupta at nxp.com>
> Sent: Tuesday, September 28, 2021 1:30 AM
> To: dev at dpdk.org; gakhil at marvell.com; Chautru, Nicolas
> <nicolas.chautru at intel.com>
> Cc: david.marchand at redhat.com; hemant.agrawal at nxp.com; Nipun Gupta
> <nipun.gupta at nxp.com>
> Subject: [PATCH v7 8/9] app/bbdev: handle endianness of test data
> 
> From: Nipun Gupta <nipun.gupta at nxp.com>
> 
> 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.
> 
> 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 <nipun.gupta at nxp.com>
> ---
>  app/test-bbdev/test_bbdev_perf.c | 62
> ++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
> 
> diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-
> bbdev/test_bbdev_perf.c
> index 469597b8b3..a0f565ee3f 100644
> --- a/app/test-bbdev/test_bbdev_perf.c
> +++ b/app/test-bbdev/test_bbdev_perf.c
> @@ -227,6 +227,64 @@ clear_soft_out_cap(uint32_t *op_flags)
>  	*op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
>  }
> 
> +static inline void
> +reverse_op(struct op_data_entries *op)

Please refer explicitly to byte endianness in that function name + comment

> +{
> +	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 */
	
Unsure the comment is correct. The code is inverting the byte endianness for all segments of the mbuf. 

> +	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)

Same comment as above, refer explicitly to byte endianness

> +{
> +	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]);


Any reason not to use a for loop through all the enums of these 5 data types
Ie. 
enum op_data_type {
	DATA_INPUT = 0,
	DATA_SOFT_OUTPUT,
	DATA_HARD_OUTPUT,
	DATA_HARQ_INPUT,
	DATA_HARQ_OUTPUT,
	DATA_NUM_TYPES,
};

> +}
> +
>  static int
>  check_dev_cap(const struct rte_bbdev_info *dev_info)  { @@ -234,6 +292,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 be_data = dev_info->drv.support_be_data;
> 
>  	nb_inputs = test_vector.entries[DATA_INPUT].nb_segments;
>  	nb_soft_outputs =
> test_vector.entries[DATA_SOFT_OUTPUT].nb_segments;
> @@ -245,6 +304,9 @@ check_dev_cap(const struct rte_bbdev_info
> *dev_info)
>  		if (op_cap->type != test_vector.op_type)
>  			continue;
> 
> +		if (be_data)
> +			reverse_all_ops();
> +
>  		if (op_cap->type == RTE_BBDEV_OP_TURBO_DEC) {
>  			const struct rte_bbdev_op_cap_turbo_dec *cap =
>  					&op_cap->cap.turbo_dec;
> --
> 2.17.1



More information about the dev mailing list