X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fbcmfs%2Fbcmfs_device.c;h=27720e4eb85ed9b5ed86cde8f695cafac760171d;hb=f593944fc988dfccebed62205fd0b88c60ed7d77;hp=0ccddea20292c202f859029788ee907965240eba;hpb=26b7dbae673812c66dfdc7a489f93f7726ecc6ce;p=dpdk.git diff --git a/drivers/crypto/bcmfs/bcmfs_device.c b/drivers/crypto/bcmfs/bcmfs_device.c index 0ccddea202..27720e4eb8 100644 --- a/drivers/crypto/bcmfs/bcmfs_device.c +++ b/drivers/crypto/bcmfs/bcmfs_device.c @@ -12,7 +12,9 @@ #include "bcmfs_device.h" #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]; @@ -43,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); @@ -53,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) @@ -68,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); @@ -77,6 +130,9 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev, if (bcmfs_attach_vfio(fsdev)) goto cleanup; + /* Maximum number of QPs supported */ + fsdev->max_hw_qps = fsdev->mmap_size / BCMFS_HW_QUEUE_IO_ADDR_LEN; + TAILQ_INSERT_TAIL(&fsdev_list, fsdev, next); return fsdev; @@ -185,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; @@ -236,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