[v4] raw/ioat: add secondary process support

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

Checks

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

Commit Message

Amber, Kumar Jan. 4, 2021, 4:30 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>
---
 drivers/raw/ioat/ioat_common.c | 16 +++++++++++++---
 drivers/raw/ioat/ioat_rawdev.c | 17 +++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)
  

Comments

Bruce Richardson Jan. 6, 2021, 2:07 p.m. UTC | #1
On Mon, Jan 04, 2021 at 10:00:49PM +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>
> ---

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

>  drivers/raw/ioat/ioat_common.c | 16 +++++++++++++---
>  drivers/raw/ioat/ioat_rawdev.c | 17 +++++++++++++----
>  2 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c
> index 142e171bc9..c174e4bb28 100644
> --- a/drivers/raw/ioat/ioat_common.c
> +++ b/drivers/raw/ioat/ioat_common.c
> @@ -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;

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.

> +		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?

>  		ret = -ENOMEM;
>  		goto cleanup;
>  	}
> diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
> index 2c88b4369f..0d3e904c8d 100644
> --- a/drivers/raw/ioat/ioat_rawdev.c
> +++ b/drivers/raw/ioat/ioat_rawdev.c
> @@ -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;
>  	}
> -

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.

>  	rawdev->dev_private = mz->addr;
>  	rawdev->dev_ops = &ioat_rawdev_ops;
>  	rawdev->device = &dev->device;
> -- 
> 2.25.1
>
  

Patch

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