compressdev: support stateless operations

Added private transform data (priv_xform) in compression
operation, which will contain the private data from each
PMD to support stateless operations.
Also, added functions to create/free this data.

Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
This commit is contained in:
Fiona Trahe 2018-04-27 14:23:59 +01:00 committed by Pablo de Lara
parent 96086db5a3
commit 32176b0285
4 changed files with 138 additions and 0 deletions

View File

@ -554,6 +554,54 @@ rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info)
dev_info->driver_name = dev->device->driver->name;
}
int __rte_experimental
rte_compressdev_private_xform_create(uint8_t dev_id,
const struct rte_comp_xform *xform,
void **priv_xform)
{
struct rte_compressdev *dev;
int ret;
dev = rte_compressdev_get_dev(dev_id);
if (xform == NULL || priv_xform == NULL || dev == NULL)
return -EINVAL;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->private_xform_create, -ENOTSUP);
ret = (*dev->dev_ops->private_xform_create)(dev, xform, priv_xform);
if (ret < 0) {
COMPRESSDEV_LOG(ERR,
"dev_id %d failed to create private_xform: err=%d",
dev_id, ret);
return ret;
};
return 0;
}
int __rte_experimental
rte_compressdev_private_xform_free(uint8_t dev_id, void *priv_xform)
{
struct rte_compressdev *dev;
int ret;
dev = rte_compressdev_get_dev(dev_id);
if (dev == NULL || priv_xform == NULL)
return -EINVAL;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->private_xform_free, -ENOTSUP);
ret = dev->dev_ops->private_xform_free(dev, priv_xform);
if (ret < 0) {
COMPRESSDEV_LOG(ERR,
"dev_id %d failed to free private xform: err=%d",
dev_id, ret);
return ret;
};
return 0;
}
const char * __rte_experimental
rte_compressdev_name_get(uint8_t dev_id)
{

View File

@ -89,6 +89,8 @@ struct rte_compressdev_config {
/**< Socket on which to allocate resources */
uint16_t nb_queue_pairs;
/**< Total number of queue pairs to configure on a device */
uint16_t max_nb_priv_xforms;
/**< Max number of private_xforms which will be created on the device */
};
/**
@ -314,6 +316,52 @@ uint16_t __rte_experimental
rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
struct rte_comp_op **ops, uint16_t nb_ops);
/**
* This should alloc a private_xform from the device's mempool and initialise
* it. The application should call this API when setting up for stateless
* processing on a device. If it returns non-shareable, then the appl cannot
* share this handle with multiple in-flight ops and should call this API again
* to get a separate handle for every in-flight op.
* The handle returned is only valid for use with ops of op_type STATELESS.
*
* @param dev_id
* Compress device identifier
* @param xform
* xform data
* @param private_xform
* Pointer to where PMD's private_xform handle should be stored
*
* @return
* - if successful returns 0
* and valid private_xform handle
* - <0 in error cases
* - Returns -EINVAL if input parameters are invalid.
* - Returns -ENOTSUP if comp device does not support the comp transform.
* - Returns -ENOMEM if the private_xform could not be allocated.
*/
int __rte_experimental
rte_compressdev_private_xform_create(uint8_t dev_id,
const struct rte_comp_xform *xform,
void **private_xform);
/**
* This should clear the private_xform and return it to the device's mempool.
*
* @param dev_id
* Compress device identifier
*
* @param private_xform
* PMD's private_xform data
*
* @return
* - 0 if successful
* - <0 in error cases
* - Returns -EINVAL if input parameters are invalid.
* - Returns -EBUSY if can't free private_xform due to inflight operations
*/
int __rte_experimental
rte_compressdev_private_xform_free(uint8_t dev_id, void *private_xform);
#ifdef __cplusplus
}
#endif

View File

@ -166,6 +166,41 @@ typedef int (*compressdev_queue_pair_release_t)(struct rte_compressdev *dev,
*/
typedef uint32_t (*compressdev_queue_pair_count_t)(struct rte_compressdev *dev);
/**
* Create driver private_xform data.
*
* @param dev
* Compressdev device
* @param xform
* xform data
* @param private_xform
* ptr where handle of pmd's private_xform data should be stored
* @return
* - if successful returns 0
* and valid private_xform handle
* - <0 in error cases
* - Returns -EINVAL if input parameters are invalid.
* - Returns -ENOTSUP if comp device does not support the comp transform.
* - Returns -ENOMEM if the private_xform could not be allocated.
*/
typedef int (*compressdev_private_xform_create_t)(struct rte_compressdev *dev,
const struct rte_comp_xform *xform, void **private_xform);
/**
* Free driver private_xform data.
*
* @param dev
* Compressdev device
* @param private_xform
* handle of pmd's private_xform data
* @return
* - 0 if successful
* - <0 in error cases
* - Returns -EINVAL if input parameters are invalid.
* - Returns -EBUSY if can't free private_xform due to inflight operations
*/
typedef int (*compressdev_private_xform_free_t)(struct rte_compressdev *dev,
void *private_xform);
/** comp device operations function pointer table */
struct rte_compressdev_ops {
@ -180,6 +215,11 @@ struct rte_compressdev_ops {
/**< Set up a device queue pair. */
compressdev_queue_pair_release_t queue_pair_release;
/**< Release a queue pair. */
compressdev_private_xform_create_t private_xform_create;
/**< Create a comp private_xform and initialise its private data. */
compressdev_private_xform_free_t private_xform_free;
/**< Free a comp private_xform's data. */
};
/**

View File

@ -18,6 +18,8 @@ EXPERIMENTAL {
rte_compressdev_pmd_get_named_dev;
rte_compressdev_pmd_parse_input_args;
rte_compressdev_pmd_release_device;
rte_compressdev_private_xform_create;
rte_compressdev_private_xform_free;
rte_compressdev_queue_pair_count;
rte_compressdev_queue_pair_setup;
rte_compressdev_socket_id;