#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];
}
};
+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);
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)
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);
fsdev->vdev = vdev;
+ /* attach to VFIO */
+ 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;
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;
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