summaryrefslogtreecommitdiff
path: root/drivers/compress/isal/isal_compress_pmd.c
diff options
context:
space:
mode:
authorLee Daly <lee.daly@intel.com>2018-05-09 17:14:27 +0100
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2018-05-10 17:46:20 +0100
commit490e725b95b2a9a02eb979fc0ef35e9d46367329 (patch)
tree89965fad22d6bda42be58863c5f193659f4a313c /drivers/compress/isal/isal_compress_pmd.c
parent3c32e89f68e1f6edfd715b76925b95700e9cd4aa (diff)
downloaddpdk-490e725b95b2a9a02eb979fc0ef35e9d46367329.zip
dpdk-490e725b95b2a9a02eb979fc0ef35e9d46367329.tar.gz
dpdk-490e725b95b2a9a02eb979fc0ef35e9d46367329.tar.xz
compress/isal: add device init and de-init
This patch adds device initialization functionality such as probe and create, also adding deinitialize functionality. Dynamic logging component also added. Signed-off-by: Lee Daly <lee.daly@intel.com> Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Diffstat (limited to 'drivers/compress/isal/isal_compress_pmd.c')
-rw-r--r--drivers/compress/isal/isal_compress_pmd.c74
1 files changed, 70 insertions, 4 deletions
diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index d7137fd..5cc9409 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -3,20 +3,76 @@
*/
#include <rte_bus_vdev.h>
+#include <rte_common.h>
+#include <rte_malloc.h>
#include <rte_compressdev_pmd.h>
-/** Remove compression device */
+#include "isal_compress_pmd_private.h"
+
+int isal_logtype_driver;
+
+/* Create ISA-L compression device */
static int
-compdev_isal_remove_dev(struct rte_vdev_device *vdev __rte_unused)
+compdev_isal_create(const char *name, struct rte_vdev_device *vdev,
+ struct rte_compressdev_pmd_init_params *init_params)
{
+ struct rte_compressdev *dev;
+
+ dev = rte_compressdev_pmd_create(name, &vdev->device,
+ sizeof(struct isal_comp_private), init_params);
+ if (dev == NULL) {
+ ISAL_PMD_LOG(ERR, "failed to create compressdev vdev");
+ return -EFAULT;
+ }
+
+ dev->dev_ops = isal_compress_pmd_ops;
+
return 0;
}
+/** Remove compression device */
+static int
+compdev_isal_remove_dev(struct rte_vdev_device *vdev)
+{
+ struct rte_compressdev *compdev;
+ const char *name;
+
+ name = rte_vdev_device_name(vdev);
+ if (name == NULL)
+ return -EINVAL;
+
+ compdev = rte_compressdev_pmd_get_named_dev(name);
+ if (compdev == NULL)
+ return -ENODEV;
+
+ return rte_compressdev_pmd_destroy(compdev);
+}
+
/** Initialise ISA-L compression device */
static int
-compdev_isal_probe(struct rte_vdev_device *dev __rte_unused)
+compdev_isal_probe(struct rte_vdev_device *dev)
{
- return 0;
+ struct rte_compressdev_pmd_init_params init_params = {
+ "",
+ rte_socket_id(),
+ };
+ const char *name, *args;
+ int retval;
+
+ name = rte_vdev_device_name(dev);
+ if (name == NULL)
+ return -EINVAL;
+
+ args = rte_vdev_device_args(dev);
+
+ retval = rte_compressdev_pmd_parse_input_args(&init_params, args);
+ if (retval) {
+ ISAL_PMD_LOG(ERR,
+ "Failed to parse initialisation arguments[%s]\n", args);
+ return -EINVAL;
+ }
+
+ return compdev_isal_create(name, dev, &init_params);
}
static struct rte_vdev_driver compdev_isal_pmd_drv = {
@@ -27,3 +83,13 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
"socket_id=<int>");
+
+RTE_INIT(isal_init_log);
+
+static void
+isal_init_log(void)
+{
+ isal_logtype_driver = rte_log_register("comp_isal");
+ if (isal_logtype_driver >= 0)
+ rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
+}