[v2] raw/ioat: add secondary process support
Checks
Commit Message
Adds the check for the process type
primary and secondary. Allocate
memzone only in the primary porcess
space and return the same memzone
in secondary process.
Signed-off-by: Kumar Amber <kumar.amber@intel.com>
---
drivers/raw/ioat/ioat_common.c | 17 ++++++++++++++---
drivers/raw/ioat/ioat_rawdev.c | 18 ++++++++++++++----
2 files changed, 28 insertions(+), 7 deletions(-)
@@ -215,11 +215,22 @@ idxd_rawdev_create(const char *name, struct rte_device *dev,
goto cleanup;
}
+ /* allocate memory for primary process
+ * else return memory of primary
+ * memzone for secondary process
+ */
snprintf(mz_name, sizeof(mz_name), "rawdev%u_private", rawdev->dev_id);
- mz = rte_memzone_reserve(mz_name, sizeof(struct idxd_rawdev),
- dev->numa_node, RTE_MEMZONE_IOVA_CONTIG);
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ mz = rte_memzone_lookup(mz_name);
+ rawdev->dev_private = mz->addr;
+ return 0;
+ }
+ mz = rte_memzone_reserve(mz_name,
+ sizeof(struct rte_ioat_rawdev),
+ dev->numa_node,
+ RTE_MEMZONE_IOVA_CONTIG);
if (mz == NULL) {
- IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
+ IOAT_PMD_ERR("Unable to reserve memzone\n");
ret = -ENOMEM;
goto cleanup;
}
@@ -165,15 +165,25 @@ ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
goto cleanup;
}
+ /* allocate memory for primary process
+ * else return memory of primary
+ * memzone for secondary process
+ */
snprintf(mz_name, sizeof(mz_name), "rawdev%u_private", rawdev->dev_id);
- mz = rte_memzone_reserve(mz_name, sizeof(struct rte_ioat_rawdev),
- dev->device.numa_node, RTE_MEMZONE_IOVA_CONTIG);
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ mz = rte_memzone_lookup(mz_name);
+ rawdev->dev_private = mz->addr;
+ return 0;
+ }
+ mz = rte_memzone_reserve(mz_name,
+ sizeof(struct rte_ioat_rawdev),
+ dev->device.numa_node,
+ RTE_MEMZONE_IOVA_CONTIG);
if (mz == NULL) {
- IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
+ IOAT_PMD_ERR("Unable to reserve memzone\n");
ret = -ENOMEM;
goto cleanup;
}
-
rawdev->dev_private = mz->addr;
rawdev->dev_ops = &ioat_rawdev_ops;
rawdev->device = &dev->device;