[dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev

De Lara Guarch, Pablo pablo.de.lara.guarch at intel.com
Tue Jun 26 11:20:11 CEST 2018


Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma at caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch at intel.com>
> Cc: Trahe, Fiona <fiona.trahe at intel.com>; akhil.goyal at nxp.com;
> dev at dpdk.org; pathreya at caviumnetworks.com; Sunila Sahu
> <sunila.sahu at caviumnetworks.com>; Ashish Gupta
> <ashish.gupta at caviumnetworks.com>
> Subject: [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
> 
> Extend DPDK librte_cryptodev to:
> - define asym op type in rte_crypto_op_type and associated
>   op pool create/alloc APIs
> - define asym session and associated session APIs
> 
> If PMD shows in its feature flag that it supports both sym and asym then it must
> support those on all its qps.
> 
> Changes from v2:
> - added rte_cryptodev_asym_session_set/get_private_data for app to setup
> private data in a session as per latest dpdk-next-crypto spec
> - rename rte_cryptodev_get_asym_session_private_size to be consistent with
> other API names
> - correct rte_cryptodev_asym_session_create to pass void** to
> rte_mempool_get() and add for private_data_size flag
> 
> Changes from v1
>     - resolve new line error in librte_cryptodev/rte_cryptodev_version.map
> 
> Signed-off-by: Shally Verma <shally.verma at caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu at caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta at caviumnetworks.com>

...

> +int __rte_experimental
> +rte_cryptodev_asym_session_init(uint8_t dev_id,
> +		struct rte_cryptodev_asym_session *sess,
> +		struct rte_crypto_asym_xform *xforms,
> +		struct rte_mempool *mp)
> +{
> +	struct rte_cryptodev *dev;
> +	uint8_t index;
> +	int ret;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +
> +	if (sess == NULL || xforms == NULL || dev == NULL)
> +		return -EINVAL;
> +
> +	index = dev->driver_id;
> +

Check if asym_session_configure is implemented in the device, like this:

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure, -ENOTSUP);

This way, there won't be a segmentation fault when using a device that
does not support asymmetric operations.

> +	if (sess->sess_private_data[index] == NULL) {
> +		ret = dev->dev_ops->asym_session_configure(dev,
> +							xforms,
> +							sess, mp);
> +		if (ret < 0) {
> +			CDEV_LOG_ERR(
> +				"dev_id %d failed to configure session details",
> +				dev_id);
> +			return ret;

...

> +int __rte_experimental
> +rte_cryptodev_asym_session_clear(uint8_t dev_id,
> +		struct rte_cryptodev_asym_session *sess) {
> +	struct rte_cryptodev *dev;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +
> +	if (dev == NULL || sess == NULL)
> +		return -EINVAL;
> +

Same as above, add the following.

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP);

> +	dev->dev_ops->asym_session_clear(dev, sess);
> +
> +	return 0;
> +}

I will send a patch doing the same for symmetric.

Pablo


More information about the dev mailing list