[v7] raw/ioat: add secondary process support

Message ID 20210107122312.564619-1-kumar.amber@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v7] raw/ioat: add secondary process support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Amber, Kumar Jan. 7, 2021, 12:23 p.m. UTC
  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>

---
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(-)
  

Comments

Bruce Richardson Jan. 7, 2021, 12:37 p.m. UTC | #1
On Thu, Jan 07, 2021 at 05:53:12PM +0530, Kumar Amber wrote:
> 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>
> 
> ---
> 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.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

>  drivers/raw/ioat/ioat_common.c | 22 ++++++++++++++++++++--
>  drivers/raw/ioat/ioat_rawdev.c | 21 +++++++++++++++++++--
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c
> index 142e171bc9..2428c8a5b6 100644
> --- a/drivers/raw/ioat/ioat_common.c
> +++ b/drivers/raw/ioat/ioat_common.c
> @@ -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".

> +	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;
> diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
> index 2c88b4369f..e152004219 100644
> --- a/drivers/raw/ioat/ioat_rawdev.c
> +++ b/drivers/raw/ioat/ioat_rawdev.c
> @@ -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.

> +	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;
> -- 
> 2.25.1
>
  

Patch

diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c
index 142e171bc9..2428c8a5b6 100644
--- a/drivers/raw/ioat/ioat_common.c
+++ b/drivers/raw/ioat/ioat_common.c
@@ -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;
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index 2c88b4369f..e152004219 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -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;