Skip to contentSkip to conversation

raw/ioat: add secondary process support

PATCH Superseded Kumar Amber 3 participants 15 messages Nov 21, 2020 – Jan 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raw/ioat: add secondary process support

add the secondart process support in dsa
and ioat for cbdma

---
 drivers/raw/ioat/ioat_common.c | 18 +++++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_common.c +15 -3
index 142e171bc9..e5a0bac8ab 100644
@@ -215,11 +215,23 @@ idxd_rawdev_create(const char *name, struct rte_device *dev,
 		goto cleanup;
 	}
 
+	/*
+	* Check for primary than allocate memory
+	* else return the memory from primary
+	* memzone.
+	*/
 	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;
 	}
drivers/raw/ioat/ioat_rawdev.c +15 -4
index 2c88b4369f..0fd9ebc60d 100644
@@ -165,15 +165,26 @@ ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
 		goto cleanup;
 	}
 
+	/*
+	* Check for primary than allocate memory
+	* else return the memory from primary
+	* memzone.
+	*/
 	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;
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 raw/ioat: add secondary process support

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.

---
 drivers/raw/ioat/ioat_common.c | 17 ++++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 18 ++++++++++++++----
 2 files changed, 28 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_common.c +14 -3
index 142e171bc9..baa0e856f6 100644
@@ -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;
 	}
drivers/raw/ioat/ioat_rawdev.c +14 -4
index 2c88b4369f..76ed48d5a0 100644
@@ -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;
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 1/1 raw/ioat: add secondary process support

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
 drivers/raw/ioat/ioat_common.c | 17 ++++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 18 ++++++++++++++----
 2 files changed, 28 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_common.c +14 -3
index 142e171bc9..baa0e856f6 100644
@@ -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;
 	}
drivers/raw/ioat/ioat_rawdev.c +14 -4
index 2c88b4369f..76ed48d5a0 100644
@@ -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;
Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 1/1 raw/ioat: add secondary process support

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
 drivers/raw/ioat/ioat_common.c | 16 +++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 17 +++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_common.c +13 -3
index 142e171bc9..c174e4bb28 100644
@@ -215,11 +215,21 @@ 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);
-	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;
 	}
drivers/raw/ioat/ioat_rawdev.c +13 -4
index 2c88b4369f..0d3e904c8d 100644
@@ -165,15 +165,24 @@ 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);
-	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;
Signature · 1 line
2.25.1
#4 lore raw
Quoted 6 lines · Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---

Thanks for the patch. Some comments below.
Also, with each version can you include below the cutline [i.e. here] what has changed since the previous version, to make reviewing easier.

Thanks,
/Bruce

Quoted 11 lines
 drivers/raw/ioat/ioat_common.c | 16 +++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 17 +++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_common.c +0 -0
index 142e171bc9..c174e4bb28 100644
@@ -215,11 +215,21 @@ idxd_rawdev_create(const char *name, struct rte_device *dev,
 		goto cleanup;
 	}

drivers/raw/ioat/ioat_common.c idxd_rawdev_create(const char *name, struct rte_device *dev, · line 224

Quoted 10 lines
drivers/raw/ioat/ioat_common.c +6 -2
 
+	/* 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);
-	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;

I think we should have some error checking here in case the lookup fails. The particular device in question could be unused by the primary.

drivers/raw/ioat/ioat_common.c idxd_rawdev_create(const char *name, struct rte_device *dev, · line 232

Quoted 9 lines
drivers/raw/ioat/ioat_common.c +7 -1
+		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");

Is there a need to change the error message here?

Quoted 23 lines
drivers/raw/ioat/ioat_common.c +0 -0
 		ret = -ENOMEM;
 		goto cleanup;
 	}
drivers/raw/ioat/ioat_rawdev.c +9 -2
index 2c88b4369f..0d3e904c8d 100644
@@ -165,15 +165,24 @@ 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);
-	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,

drivers/raw/ioat/ioat_rawdev.c ioat_rawdev_create(const char *name, struct rte_pci_device *dev) · line 176

Quoted 10 lines
drivers/raw/ioat/ioat_rawdev.c +4 -2
+			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;
 	}
-

Same comments for this file as for previous. Also note the extra line removal here, which probably should not be part of this patch too.

Quoted 6 lines
drivers/raw/ioat/ioat_rawdev.c +0 -0
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = &ioat_rawdev_ops;
 	rawdev->device = &dev->device;
Signature · 1 line
2.25.1
#5 lore raw

PATCH v5 1/1 raw/ioat: add secondary process support

In reply to Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup

---
 drivers/raw/ioat/ioat_common.c | 21 +++++++++++++++++++--
 drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++++--
 2 files changed, 36 insertions(+), 4 deletions(-)
drivers/raw/ioat/ioat_common.c +19 -2
index 142e171bc9..91f0d5122c 100644
@@ -215,14 +215,31 @@ 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);
-	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);
+		if (mz == NULL) {
+			IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+	}
+		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");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +17 -2
index 2c88b4369f..a9846e75f2 100644
@@ -165,9 +165,24 @@ 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);
-	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);
+		if (mz == NULL) {
+			IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+		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");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
#6 lore raw

PATCH v6 1/1 raw/ioat: add secondary process support

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation

---
 drivers/raw/ioat/ioat_common.c | 20 ++++++++++++++++++--
 drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++++--
 2 files changed, 35 insertions(+), 4 deletions(-)
drivers/raw/ioat/ioat_common.c +18 -2
index 142e171bc9..ada691c11d 100644
@@ -215,14 +215,30 @@ 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);
-	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);
+		if (mz == NULL) {
+			IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+		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");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +17 -2
index 2c88b4369f..a9846e75f2 100644
@@ -165,9 +165,24 @@ 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);
-	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);
+		if (mz == NULL) {
+			IOAT_PMD_ERR("Unable lookup memzone for private data\n");
+			ret = -ENOMEM;
+			goto cleanup;
+		}
+		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");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
#7 lore raw

PATCH v7 1/1 raw/ioat: add secondary process support

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary

---
 drivers/raw/ioat/ioat_common.c | 22 ++++++++++++++++++++--
 drivers/raw/ioat/ioat_rawdev.c | 21 +++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
drivers/raw/ioat/ioat_common.c +20 -2
index 142e171bc9..2428c8a5b6 100644
@@ -215,14 +215,32 @@ 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);
-	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);
+		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 rte_ioat_rawdev),
+			dev->numa_node,
+			RTE_MEMZONE_IOVA_CONTIG);
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +19 -2
index 2c88b4369f..e152004219 100644
@@ -165,9 +165,26 @@ 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);
-	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);
+		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) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
Acked-by on v7 1/1
#8 lore raw
Quoted 6 lines · Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

Quoted 8 lines

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary
---

Two comments below. With those fixed, you can add my ack to v8.

Quoted 9 lines
 drivers/raw/ioat/ioat_common.c | 22 ++++++++++++++++++++--
 drivers/raw/ioat/ioat_rawdev.c | 21 +++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
drivers/raw/ioat/ioat_common.c +0 -0
index 142e171bc9..2428c8a5b6 100644

drivers/raw/ioat/ioat_common.c idxd_rawdev_create(const char *name, struct rte_device *dev, · line 220

Quoted 9 lines
drivers/raw/ioat/ioat_common.c +3 -2
@@ -215,14 +215,32 @@ 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);
-	mz = rte_memzone_reserve(mz_name, sizeof(struct idxd_rawdev),
-			dev->numa_node, RTE_MEMZONE_IOVA_CONTIG);

This line actually doesn't need to be changed, and in doing so, it's actually introduced a bug. The sizeof() call here, has "idxd_rawdev" while the replacement below is a copy-paste error using "ioat_rawdev".

Quoted 30 lines
drivers/raw/ioat/ioat_common.c +17 -0
+	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 rte_ioat_rawdev),
+			dev->numa_node,
+			RTE_MEMZONE_IOVA_CONTIG);
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +0 -0
index 2c88b4369f..e152004219 100644

drivers/raw/ioat/ioat_rawdev.c ioat_rawdev_create(const char *name, struct rte_pci_device *dev) · line 170

Quoted 9 lines
drivers/raw/ioat/ioat_rawdev.c +3 -2
@@ -165,9 +165,26 @@ 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);
-	mz = rte_memzone_reserve(mz_name, sizeof(struct rte_ioat_rawdev),
-			dev->device.numa_node, RTE_MEMZONE_IOVA_CONTIG);

No bug introduced here, but again I think changing this line is unnecessary.

Quoted 22 lines
drivers/raw/ioat/ioat_rawdev.c +16 -0
+	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) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
#9 lore raw

PATCH v8 1/1 raw/ioat: add secondary process support

In reply to Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary
v8
* fix wrong memzone alloaction

---
 drivers/raw/ioat/ioat_common.c | 16 ++++++++++++++++
 drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++
 2 files changed, 31 insertions(+)
drivers/raw/ioat/ioat_common.c +16 -0
index 142e171bc9..da464181a5 100644
@@ -215,14 +215,30 @@ 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);
 	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);
+		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;
+	}
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +15 -0
index 2c88b4369f..922fa20e32 100644
@@ -165,9 +165,24 @@ 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);
 	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);
+		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;
+	}
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
#10 lore raw
Quoted 36 lines · Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary
v8
* fix wrong memzone alloaction

---
 drivers/raw/ioat/ioat_common.c | 16 ++++++++++++++++
 drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++
 2 files changed, 31 insertions(+)
drivers/raw/ioat/ioat_common.c +5 -0
index 142e171bc9..da464181a5 100644
@@ -215,14 +215,30 @@ 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);
 	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);

drivers/raw/ioat/ioat_common.c idxd_rawdev_create(const char *name, struct rte_device *dev, · line 235

Quoted 10 lines
drivers/raw/ioat/ioat_common.c +10 -0
+		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;
+	}

This block you inserted still needs to go two lines further up.

drivers/raw/ioat/ioat_common.c idxd_rawdev_create(const char *name, struct rte_device *dev, · line 241

Quoted 6 lines
drivers/raw/ioat/ioat_common.c +1 -0
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
+

You don't need this newline addition.

Quoted 19 lines
drivers/raw/ioat/ioat_common.c +0 -0
 	rawdev->dev_private = mz->addr;
 	rawdev->dev_ops = ops;
 	rawdev->device = dev;
drivers/raw/ioat/ioat_rawdev.c +5 -0
index 2c88b4369f..922fa20e32 100644
@@ -165,9 +165,24 @@ 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);
 	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);

drivers/raw/ioat/ioat_rawdev.c ioat_rawdev_create(const char *name, struct rte_pci_device *dev) · line 185

Quoted 10 lines
drivers/raw/ioat/ioat_rawdev.c +10 -0
+		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;
+	}

As above, these new lines need to be inserted where they were in the previous version.

Quoted 6 lines
drivers/raw/ioat/ioat_rawdev.c +0 -0
 	if (mz == NULL) {
 		IOAT_PMD_ERR("Unable to reserve memzone for private data\n");
 		ret = -ENOMEM;
Signature · 1 line
2.25.1
#11 lore raw

PATCH v9 1/1 raw/ioat: add secondary process support

In reply to Kumar Amber

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary
v8
* fix wrong memzone alloaction
v9
* fix comments

---
 drivers/raw/ioat/ioat_common.c | 15 +++++++++++++++
 drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)
drivers/raw/ioat/ioat_common.c +15 -0
index 142e171bc9..a80d304214 100644
@@ -215,6 +215,21 @@ 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.
+	 */
+	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;
+	}
 	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);
drivers/raw/ioat/ioat_rawdev.c +15 -0
index 2c88b4369f..21b71b45ed 100644
@@ -165,6 +165,21 @@ 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.
+	 */
+	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;
+	}
 	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);
Signature · 1 line
2.25.1
#12 lore raw

PATCH v9 1/1 raw/ioat: add secondary process support

Add support for secondary processes in ioat devices. The update allocates a memzone for a primary process or returns it in a secondary process.

---
v5
* add error check for memzone lookup
v6
* fix compilation
v7
* include dev ops for secondary
v8
* fix wrong memzone alloaction
v9
* fix comments

---
 drivers/raw/ioat/ioat_common.c | 15 +++++++++++++++
 drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)
drivers/raw/ioat/ioat_common.c +15 -0
index 142e171bc9..d055c36a2a 100644
@@ -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) {
drivers/raw/ioat/ioat_rawdev.c +15 -0
index 2c88b4369f..77216f67f5 100644
@@ -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) {
Signature · 1 line
2.25.1