[PATCH v2 09/22] app/test: add lib pdcp tests

Akhil Goyal gakhil at marvell.com
Thu May 18 10:03:39 CEST 2023


> diff --git a/app/test/meson.build b/app/test/meson.build
> index 52d9088578..0f658aa2ab 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -96,6 +96,7 @@ test_sources = files(
>          'test_meter.c',
>          'test_mcslock.c',
>          'test_mp_secondary.c',
> +        'test_pdcp.c',
>          'test_per_lcore.c',
>          'test_pflock.c',
>          'test_pmd_perf.c',
> diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
> index abd795f54a..89057dba22 100644
> --- a/app/test/test_cryptodev.h
> +++ b/app/test/test_cryptodev.h
> @@ -4,6 +4,9 @@
>  #ifndef TEST_CRYPTODEV_H_
>  #define TEST_CRYPTODEV_H_
> 
> +#include <rte_crypto.h>
> +#include <rte_cryptodev.h>
> +

Can we remove these includes from here and add in test_pdcp.c directly?


> +	if (conf->is_integrity_protected) {
> +		if (conf->entity.pdcp_xfrm.pkt_dir ==
> RTE_SECURITY_PDCP_UPLINK) {
> +			conf->entity.crypto_xfrm = &conf->a_xfrm;
> +
> +			a_xfrm.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
> +			a_xfrm.next = &conf->c_xfrm;
> +
> +			c_xfrm.cipher.op =
> RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> +			c_xfrm.next = NULL;
> +		} else {
> +			conf->entity.crypto_xfrm = &conf->c_xfrm;
> +
> +			c_xfrm.cipher.op =
> RTE_CRYPTO_CIPHER_OP_DECRYPT;
> +			c_xfrm.next = &conf->a_xfrm;
> +
> +			a_xfrm.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
> +			a_xfrm.next = NULL;
> +		}
> +	} else {
> +		conf->entity.crypto_xfrm = &conf->c_xfrm;
> +		c_xfrm.next = NULL;
> +
> +		if (conf->entity.pdcp_xfrm.pkt_dir ==
> RTE_SECURITY_PDCP_UPLINK)
> +			c_xfrm.cipher.op =
> RTE_CRYPTO_CIPHER_OP_ENCRYPT;
> +		else
> +			c_xfrm.cipher.op =
> RTE_CRYPTO_CIPHER_OP_DECRYPT;
> +	}
> +	/* Update xforms to match PDCP requirements */
> +
> +	if ((c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_AES_CTR) ||
> +	    (c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_ZUC_EEA3 ||
> +	    (c_xfrm.cipher.algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2)))
> +		c_xfrm.cipher.iv.length = 16;
> +	else
> +		c_xfrm.cipher.iv.length = 0;
> +
> +	if (conf->is_integrity_protected) {
> +		if (a_xfrm.auth.algo == RTE_CRYPTO_AUTH_NULL)
> +			a_xfrm.auth.digest_length = 0;
> +		else
> +			a_xfrm.auth.digest_length = 4;

This if-else is not needed. If is_integrity_protected, digest_length should always be 4.
Also define a macro for MAC-I len. It is being used at multiple places.
Similarly for IV length macro can be defined.

> +
> +		if ((a_xfrm.auth.algo == RTE_CRYPTO_AUTH_ZUC_EIA3) ||
> +		    (a_xfrm.auth.algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2))
> +			a_xfrm.auth.iv.length = 16;
> +		else
> +			a_xfrm.auth.iv.length = 0;
> +	}
> +
> +	conf->c_xfrm = c_xfrm;
> +	conf->a_xfrm = a_xfrm;
> +
> +	conf->entity.dev_id = (uint8_t)cryptodev_id_get(conf-
> >is_integrity_protected,
> +			&conf->c_xfrm, &conf->a_xfrm);
> +
> +	if (pdcp_test_params[index].domain ==
> RTE_SECURITY_PDCP_MODE_CONTROL ||
> +	    pdcp_test_params[index].domain ==
> RTE_SECURITY_PDCP_MODE_DATA) {
> +		data = pdcp_test_data_in[index];
> +		hfn = pdcp_test_hfn[index] << pdcp_test_data_sn_size[index];
> +		sn = pdcp_sn_from_raw_get(data,
> pdcp_test_data_sn_size[index]);
> +		count = hfn | sn;
> +	}

The above logic can go inside lib PDCP as well.
This is specific to PDCP and not user dependent.
You can reuse the pdcp_xfrm.hfn as well.





More information about the dev mailing list