cryptodev: remove unused PCI probe/remove
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.c
index 02db8a5..3d118b5 100644 (file)
@@ -47,7 +47,6 @@
 #include <rte_debug.h>
 #include <rte_dev.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
@@ -101,18 +100,6 @@ struct rte_cryptodev_callback {
        uint32_t active;                        /**< Callback is executing */
 };
 
-#define RTE_CRYPTODEV_VDEV_NAME                                ("name")
-#define RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG               ("max_nb_queue_pairs")
-#define RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG             ("max_nb_sessions")
-#define RTE_CRYPTODEV_VDEV_SOCKET_ID                   ("socket_id")
-
-static const char *cryptodev_vdev_valid_params[] = {
-       RTE_CRYPTODEV_VDEV_NAME,
-       RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG,
-       RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG,
-       RTE_CRYPTODEV_VDEV_SOCKET_ID
-};
-
 /**
  * The crypto cipher algorithm strings identifiers.
  * It could be used in application command line.
@@ -233,111 +220,6 @@ rte_crypto_auth_operation_strings[] = {
                [RTE_CRYPTO_AUTH_OP_GENERATE]   = "generate"
 };
 
-static uint8_t
-number_of_sockets(void)
-{
-       int sockets = 0;
-       int i;
-       const struct rte_memseg *ms = rte_eal_get_physmem_layout();
-
-       for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
-               if (sockets < ms[i].socket_id)
-                       sockets = ms[i].socket_id;
-       }
-
-       /* Number of sockets = maximum socket_id + 1 */
-       return ++sockets;
-}
-
-/** Parse integer from integer argument */
-static int
-parse_integer_arg(const char *key __rte_unused,
-               const char *value, void *extra_args)
-{
-       int *i = extra_args;
-
-       *i = atoi(value);
-       if (*i < 0) {
-               CDEV_LOG_ERR("Argument has to be positive.");
-               return -1;
-       }
-
-       return 0;
-}
-
-/** Parse name */
-static int
-parse_name_arg(const char *key __rte_unused,
-               const char *value, void *extra_args)
-{
-       struct rte_crypto_vdev_init_params *params = extra_args;
-
-       if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) {
-               CDEV_LOG_ERR("Invalid name %s, should be less than "
-                               "%u bytes", value,
-                               RTE_CRYPTODEV_NAME_MAX_LEN - 1);
-               return -1;
-       }
-
-       strncpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
-
-       return 0;
-}
-
-int
-rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
-               const char *input_args)
-{
-       struct rte_kvargs *kvlist = NULL;
-       int ret = 0;
-
-       if (params == NULL)
-               return -EINVAL;
-
-       if (input_args) {
-               kvlist = rte_kvargs_parse(input_args,
-                               cryptodev_vdev_valid_params);
-               if (kvlist == NULL)
-                       return -1;
-
-               ret = rte_kvargs_process(kvlist,
-                                       RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG,
-                                       &parse_integer_arg,
-                                       &params->max_nb_queue_pairs);
-               if (ret < 0)
-                       goto free_kvlist;
-
-               ret = rte_kvargs_process(kvlist,
-                                       RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG,
-                                       &parse_integer_arg,
-                                       &params->max_nb_sessions);
-               if (ret < 0)
-                       goto free_kvlist;
-
-               ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_SOCKET_ID,
-                                       &parse_integer_arg,
-                                       &params->socket_id);
-               if (ret < 0)
-                       goto free_kvlist;
-
-               ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_NAME,
-                                       &parse_name_arg,
-                                       params);
-               if (ret < 0)
-                       goto free_kvlist;
-
-               if (params->socket_id >= number_of_sockets()) {
-                       CDEV_LOG_ERR("Invalid socket id specified to create "
-                               "the virtual crypto device on");
-                       goto free_kvlist;
-               }
-       }
-
-free_kvlist:
-       rte_kvargs_free(kvlist);
-       return ret;
-}
-
 const struct rte_cryptodev_symmetric_capability *
 rte_cryptodev_sym_capability_get(uint8_t dev_id,
                const struct rte_cryptodev_sym_capability_idx *idx)
@@ -439,7 +321,7 @@ rte_cryptodev_get_feature_name(uint64_t flag)
 int
 rte_cryptodev_create_vdev(const char *name, const char *args)
 {
-       return rte_eal_vdev_init(name, args);
+       return rte_vdev_init(name, args);
 }
 
 struct rte_cryptodev *
@@ -523,7 +405,7 @@ rte_cryptodev_count_devtype(enum rte_cryptodev_type type)
 }
 
 uint8_t
-rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices,
+rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
        uint8_t nb_devices)
 {
        uint8_t i, count = 0;
@@ -533,15 +415,11 @@ rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices,
        for (i = 0; i < max_devs && count < nb_devices; i++) {
 
                if (devs[i].attached == RTE_CRYPTODEV_ATTACHED) {
-                       const struct rte_cryptodev_driver *drv = devs[i].driver;
                        int cmp;
 
-                       if (drv)
-                               cmp = strncmp(drv->pci_drv.driver.name,
-                                               dev_name, strlen(dev_name));
-                       else
-                               cmp = strncmp(devs[i].data->name,
-                                               dev_name, strlen(dev_name));
+                       cmp = strncmp(devs[i].device->driver->name,
+                                       driver_name,
+                                       strlen(driver_name));
 
                        if (cmp == 0)
                                devices[count++] = devs[i].data->dev_id;
@@ -662,144 +540,15 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
        if (cryptodev == NULL)
                return -EINVAL;
 
-       ret = rte_cryptodev_close(cryptodev->data->dev_id);
-       if (ret < 0)
-               return ret;
-
-       cryptodev->attached = RTE_CRYPTODEV_DETACHED;
-       cryptodev_globals.nb_devs--;
-       return 0;
-}
-
-struct rte_cryptodev *
-rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
-               int socket_id)
-{
-       struct rte_cryptodev *cryptodev;
-
-       /* allocate device structure */
-       cryptodev = rte_cryptodev_pmd_allocate(name, socket_id);
-       if (cryptodev == NULL)
-               return NULL;
-
-       /* allocate private device structure */
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-               cryptodev->data->dev_private =
-                               rte_zmalloc_socket("cryptodev device private",
-                                               dev_private_size,
-                                               RTE_CACHE_LINE_SIZE,
-                                               socket_id);
-
-               if (cryptodev->data->dev_private == NULL)
-                       rte_panic("Cannot allocate memzone for private device"
-                                       " data");
-       }
-
-       /* initialise user call-back tail queue */
-       TAILQ_INIT(&(cryptodev->link_intr_cbs));
-
-       return cryptodev;
-}
-
-int
-rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
-                       struct rte_pci_device *pci_dev)
-{
-       struct rte_cryptodev_driver *cryptodrv;
-       struct rte_cryptodev *cryptodev;
-
-       char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-
-       int retval;
-
-       cryptodrv = (struct rte_cryptodev_driver *)pci_drv;
-       if (cryptodrv == NULL)
-               return -ENODEV;
-
-       rte_pci_device_name(&pci_dev->addr, cryptodev_name,
-                       sizeof(cryptodev_name));
-
-       cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
-       if (cryptodev == NULL)
-               return -ENOMEM;
-
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-               cryptodev->data->dev_private =
-                               rte_zmalloc_socket(
-                                               "cryptodev private structure",
-                                               cryptodrv->dev_private_size,
-                                               RTE_CACHE_LINE_SIZE,
-                                               rte_socket_id());
-
-               if (cryptodev->data->dev_private == NULL)
-                       rte_panic("Cannot allocate memzone for private "
-                                       "device data");
+       /* Close device only if device operations have been set */
+       if (cryptodev->dev_ops) {
+               ret = rte_cryptodev_close(cryptodev->data->dev_id);
+               if (ret < 0)
+                       return ret;
        }
 
-       cryptodev->device = &pci_dev->device;
-       cryptodev->driver = cryptodrv;
-
-       /* init user callbacks */
-       TAILQ_INIT(&(cryptodev->link_intr_cbs));
-
-       /* Invoke PMD device initialization function */
-       retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev);
-       if (retval == 0)
-               return 0;
-
-       CDEV_LOG_ERR("driver %s: crypto_dev_init(vendor_id=0x%x device_id=0x%x)"
-                       " failed", pci_drv->driver.name,
-                       (unsigned) pci_dev->id.vendor_id,
-                       (unsigned) pci_dev->id.device_id);
-
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               rte_free(cryptodev->data->dev_private);
-
        cryptodev->attached = RTE_CRYPTODEV_DETACHED;
        cryptodev_globals.nb_devs--;
-
-       return -ENXIO;
-}
-
-int
-rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
-{
-       const struct rte_cryptodev_driver *cryptodrv;
-       struct rte_cryptodev *cryptodev;
-       char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-       int ret;
-
-       if (pci_dev == NULL)
-               return -EINVAL;
-
-       rte_pci_device_name(&pci_dev->addr, cryptodev_name,
-                       sizeof(cryptodev_name));
-
-       cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
-       if (cryptodev == NULL)
-               return -ENODEV;
-
-       cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver;
-       if (cryptodrv == NULL)
-               return -ENODEV;
-
-       /* Invoke PMD device uninit function */
-       if (*cryptodrv->cryptodev_uninit) {
-               ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev);
-               if (ret)
-                       return ret;
-       }
-
-       /* free crypto device */
-       rte_cryptodev_pmd_release_device(cryptodev);
-
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               rte_free(cryptodev->data->dev_private);
-
-       cryptodev->device = NULL;
-       cryptodev->driver = NULL;
-       cryptodev->data = NULL;
-
        return 0;
 }
 
@@ -1163,9 +912,7 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
        RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
        (*dev->dev_ops->dev_infos_get)(dev, dev_info);
 
-       dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
-       if (dev->driver)
-               dev_info->driver_name = dev->driver->pci_drv.driver.name;
+       dev_info->driver_name = dev->device->driver->name;
 }