add the secondart process support in dsa and ioat for cbdma Signed-off-by: Kumar Amber <kumar.amber@intel.com> --- drivers/raw/ioat/ioat_common.c | 18 +++++++++++++++--- drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..e5a0bac8ab 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; } diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..0fd9ebc60d 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.17.1
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(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..baa0e856f6 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; } diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..76ed48d5a0 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.25.1
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 | 17 ++++++++++++++--- drivers/raw/ioat/ioat_rawdev.c | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..baa0e856f6 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; } diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..76ed48d5a0 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.25.1
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(-) 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; -- 2.25.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 >
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 --- drivers/raw/ioat/ioat_common.c | 21 +++++++++++++++++++-- drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..91f0d5122c 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..a9846e75f2 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.25.1
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 --- drivers/raw/ioat/ioat_common.c | 20 ++++++++++++++++++-- drivers/raw/ioat/ioat_rawdev.c | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..ada691c11d 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..a9846e75f2 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.25.1
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(-) 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; -- 2.25.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 >
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 v8 * fix wrong memzone alloaction --- drivers/raw/ioat/ioat_common.c | 16 ++++++++++++++++ drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..da464181a5 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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; diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..922fa20e32 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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; -- 2.25.1
On Fri, Jan 08, 2021 at 07:14:56PM +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 > v8 > * fix wrong memzone alloaction > --- > drivers/raw/ioat/ioat_common.c | 16 ++++++++++++++++ > drivers/raw/ioat/ioat_rawdev.c | 15 +++++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c > index 142e171bc9..da464181a5 100644 > --- a/drivers/raw/ioat/ioat_common.c > +++ b/drivers/raw/ioat/ioat_common.c > @@ -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; > + } This block you inserted still needs to go two lines further up. > 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. > 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..922fa20e32 100644 > --- a/drivers/raw/ioat/ioat_rawdev.c > +++ b/drivers/raw/ioat/ioat_rawdev.c > @@ -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; > + } As above, these new lines need to be inserted where they were in the previous version. > if (mz == NULL) { > IOAT_PMD_ERR("Unable to reserve memzone for private data\n"); > ret = -ENOMEM; > -- > 2.25.1 >
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 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(+) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..a80d304214 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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); diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..21b71b45ed 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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); -- 2.25.1
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 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(+) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index 142e171bc9..d055c36a2a 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -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) { diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 2c88b4369f..77216f67f5 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -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) { -- 2.25.1
On Fri, Jan 08, 2021 at 10:22:16PM +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>
>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
08/01/2021 18:05, Bruce Richardson:
> On Fri, Jan 08, 2021 at 10:22:16PM +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>
> >
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Applied, thanks