raw/ioat: support secondary process
authorKumar Amber <kumar.amber@intel.com>
Fri, 8 Jan 2021 16:52:16 +0000 (22:22 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 17 Jan 2021 21:52:35 +0000 (22:52 +0100)
Add support for secondary processes in ioat devices. The update
allocates a memzone for a primary process or returns it in a
secondary process.

Signed-off-by: Kumar Amber <kumar.amber@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
drivers/raw/ioat/ioat_common.c
drivers/raw/ioat/ioat_rawdev.c

index 142e171..d055c36 100644 (file)
@@ -215,7 +215,22 @@ idxd_rawdev_create(const char *name, struct rte_device *dev,
                goto cleanup;
        }
 
+       /* Allocate memory for the primary process or else return the memory
+        * of primary memzone for the secondary process.
+        */
        snprintf(mz_name, sizeof(mz_name), "rawdev%u_private", rawdev->dev_id);
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+               mz = rte_memzone_lookup(mz_name);
+               if (mz == NULL) {
+                       IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+                       ret = -ENOMEM;
+                       goto cleanup;
+               }
+               rawdev->dev_private = mz->addr;
+               rawdev->dev_ops = ops;
+               rawdev->device = dev;
+               return 0;
+       }
        mz = rte_memzone_reserve(mz_name, sizeof(struct idxd_rawdev),
                        dev->numa_node, RTE_MEMZONE_IOVA_CONTIG);
        if (mz == NULL) {
index 2c88b43..77216f6 100644 (file)
@@ -165,7 +165,22 @@ ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
                goto cleanup;
        }
 
+       /* Allocate memory for the primary process or else return the memory
+        * of primary memzone for the secondary process.
+        */
        snprintf(mz_name, sizeof(mz_name), "rawdev%u_private", rawdev->dev_id);
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+               mz = rte_memzone_lookup(mz_name);
+               if (mz == NULL) {
+                       IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+                       ret = -ENOMEM;
+                       goto cleanup;
+               }
+               rawdev->dev_private = mz->addr;
+               rawdev->dev_ops = &ioat_rawdev_ops;
+               rawdev->device = &dev->device;
+               return 0;
+       }
        mz = rte_memzone_reserve(mz_name, sizeof(struct rte_ioat_rawdev),
                        dev->device.numa_node, RTE_MEMZONE_IOVA_CONTIG);
        if (mz == NULL) {