net/iavf: enable IRQ mapping configuration for large VF
[dpdk.git] / drivers / crypto / bcmfs / bcmfs_device.c
index a01a5c7..27720e4 100644 (file)
@@ -14,6 +14,7 @@
 #include "bcmfs_logs.h"
 #include "bcmfs_qp.h"
 #include "bcmfs_vfio.h"
+#include "bcmfs_sym_pmd.h"
 
 struct bcmfs_device_attr {
        const char name[BCMFS_MAX_PATH_LEN];
@@ -44,6 +45,47 @@ static struct bcmfs_device_attr dev_table[] = {
        }
 };
 
+struct bcmfs_hw_queue_pair_ops_table bcmfs_hw_queue_pair_ops_table = {
+       .tl =  RTE_SPINLOCK_INITIALIZER,
+       .num_ops = 0
+};
+
+int bcmfs_hw_queue_pair_register_ops(const struct bcmfs_hw_queue_pair_ops *h)
+{
+       struct bcmfs_hw_queue_pair_ops *ops;
+       int16_t ops_index;
+
+       rte_spinlock_lock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+       if (h->enq_one_req == NULL || h->dequeue == NULL ||
+           h->ring_db == NULL || h->startq == NULL || h->stopq == NULL) {
+               rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+               BCMFS_LOG(ERR,
+                         "Missing callback while registering device ops");
+               return -EINVAL;
+       }
+
+       if (strlen(h->name) >= sizeof(ops->name) - 1) {
+               rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+               BCMFS_LOG(ERR, "%s(): fs device_ops <%s>: name too long",
+                               __func__, h->name);
+               return -EEXIST;
+       }
+
+       ops_index = bcmfs_hw_queue_pair_ops_table.num_ops++;
+       ops = &bcmfs_hw_queue_pair_ops_table.qp_ops[ops_index];
+       strlcpy(ops->name, h->name, sizeof(ops->name));
+       ops->enq_one_req = h->enq_one_req;
+       ops->dequeue = h->dequeue;
+       ops->ring_db = h->ring_db;
+       ops->startq = h->startq;
+       ops->stopq = h->stopq;
+
+       rte_spinlock_unlock(&bcmfs_hw_queue_pair_ops_table.tl);
+
+       return ops_index;
+}
+
 TAILQ_HEAD(fsdev_list, bcmfs_device);
 static struct fsdev_list fsdev_list = TAILQ_HEAD_INITIALIZER(fsdev_list);
 
@@ -54,6 +96,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
                       enum bcmfs_device_type dev_type __rte_unused)
 {
        struct bcmfs_device *fsdev;
+       uint32_t i;
 
        fsdev = rte_calloc(__func__, 1, sizeof(*fsdev), 0);
        if (!fsdev)
@@ -69,6 +112,15 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
                goto cleanup;
        }
 
+       /* check if registered ops name is present in directory path */
+       for (i = 0; i < bcmfs_hw_queue_pair_ops_table.num_ops; i++)
+               if (strstr(dirpath,
+                          bcmfs_hw_queue_pair_ops_table.qp_ops[i].name))
+                       fsdev->sym_hw_qp_ops =
+                               &bcmfs_hw_queue_pair_ops_table.qp_ops[i];
+       if (!fsdev->sym_hw_qp_ops)
+               goto cleanup;
+
        strcpy(fsdev->dirname, dirpath);
        strcpy(fsdev->name, devname);
 
@@ -189,6 +241,7 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
        char out_dirname[BCMFS_MAX_PATH_LEN];
        uint32_t fsdev_dev[BCMFS_MAX_NODES];
        enum bcmfs_device_type dtype;
+       int err;
        int i = 0;
        int dev_idx;
        int count = 0;
@@ -240,7 +293,20 @@ bcmfs_vdev_probe(struct rte_vdev_device *vdev)
                return -ENODEV;
        }
 
+       err = bcmfs_sym_dev_create(fsdev);
+       if (err) {
+               BCMFS_LOG(WARNING,
+                         "Failed to create BCMFS SYM PMD for device %s",
+                         fsdev->name);
+               goto pmd_create_fail;
+       }
+
        return 0;
+
+pmd_create_fail:
+       fsdev_release(fsdev);
+
+       return err;
 }
 
 static int