common/cnxk: alloc link map array if HWS is available

Message ID 764fb382f2934807b8e6e0ba15c37a606a98d9d2.1654232597.git.sthotton@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series common/cnxk: alloc link map array if HWS is available |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Shijith Thotton June 3, 2022, 5:10 a.m. UTC
  Link map array is required only if work slots are available.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/common/cnxk/roc_sso.c | 45 +++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 20 deletions(-)
  

Comments

Jerin Jacob June 13, 2022, 7:19 a.m. UTC | #1
On Fri, Jun 3, 2022 at 10:41 AM Shijith Thotton <sthotton@marvell.com> wrote:
>
> Link map array is required only if work slots are available.
>
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> ---
>  drivers/common/cnxk/roc_sso.c | 45 +++++++++++++++++++----------------

Applied to dpdk-next-net-eventdev/for-main. Thanks


>  1 file changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
> index 358d37a9f2..34b9896d5f 100644
> --- a/drivers/common/cnxk/roc_sso.c
> +++ b/drivers/common/cnxk/roc_sso.c
> @@ -784,29 +784,34 @@ roc_sso_dev_init(struct roc_sso *roc_sso)
>         }
>         rc = -ENOMEM;
>
> -       sso->link_map =
> -               plt_zmalloc(sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
> -       if (sso->link_map == NULL) {
> -               plt_err("Failed to allocate memory for link_map array");
> -               goto rsrc_fail;
> -       }
> +       if (roc_sso->max_hws) {
> +               sso->link_map = plt_zmalloc(
> +                       sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
> +               if (sso->link_map == NULL) {
> +                       plt_err("Failed to allocate memory for link_map array");
> +                       goto rsrc_fail;
> +               }
>
> -       link_map_sz = plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
> -       sso->link_map_mem = plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
> -       if (sso->link_map_mem == NULL) {
> -               plt_err("Failed to get link_map memory");
> -               goto rsrc_fail;
> -       }
> +               link_map_sz =
> +                       plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
> +               sso->link_map_mem =
> +                       plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
> +               if (sso->link_map_mem == NULL) {
> +                       plt_err("Failed to get link_map memory");
> +                       goto rsrc_fail;
> +               }
>
> -       link_mem = sso->link_map_mem;
> -       for (i = 0; i < roc_sso->max_hws; i++) {
> -               sso->link_map[i] = plt_bitmap_init(roc_sso->max_hwgrp, link_mem,
> -                                                  link_map_sz);
> -               if (sso->link_map[i] == NULL) {
> -                       plt_err("Failed to allocate link map");
> -                       goto link_mem_free;
> +               link_mem = sso->link_map_mem;
> +
> +               for (i = 0; i < roc_sso->max_hws; i++) {
> +                       sso->link_map[i] = plt_bitmap_init(
> +                               roc_sso->max_hwgrp, link_mem, link_map_sz);
> +                       if (sso->link_map[i] == NULL) {
> +                               plt_err("Failed to allocate link map");
> +                               goto link_mem_free;
> +                       }
> +                       link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
>                 }
> -               link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
>         }
>         idev_sso_pffunc_set(sso->dev.pf_func);
>         idev_sso_set(roc_sso);
> --
> 2.25.1
>
  

Patch

diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index 358d37a9f2..34b9896d5f 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -784,29 +784,34 @@  roc_sso_dev_init(struct roc_sso *roc_sso)
 	}
 	rc = -ENOMEM;
 
-	sso->link_map =
-		plt_zmalloc(sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
-	if (sso->link_map == NULL) {
-		plt_err("Failed to allocate memory for link_map array");
-		goto rsrc_fail;
-	}
+	if (roc_sso->max_hws) {
+		sso->link_map = plt_zmalloc(
+			sizeof(struct plt_bitmap *) * roc_sso->max_hws, 0);
+		if (sso->link_map == NULL) {
+			plt_err("Failed to allocate memory for link_map array");
+			goto rsrc_fail;
+		}
 
-	link_map_sz = plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
-	sso->link_map_mem = plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
-	if (sso->link_map_mem == NULL) {
-		plt_err("Failed to get link_map memory");
-		goto rsrc_fail;
-	}
+		link_map_sz =
+			plt_bitmap_get_memory_footprint(roc_sso->max_hwgrp);
+		sso->link_map_mem =
+			plt_zmalloc(link_map_sz * roc_sso->max_hws, 0);
+		if (sso->link_map_mem == NULL) {
+			plt_err("Failed to get link_map memory");
+			goto rsrc_fail;
+		}
 
-	link_mem = sso->link_map_mem;
-	for (i = 0; i < roc_sso->max_hws; i++) {
-		sso->link_map[i] = plt_bitmap_init(roc_sso->max_hwgrp, link_mem,
-						   link_map_sz);
-		if (sso->link_map[i] == NULL) {
-			plt_err("Failed to allocate link map");
-			goto link_mem_free;
+		link_mem = sso->link_map_mem;
+
+		for (i = 0; i < roc_sso->max_hws; i++) {
+			sso->link_map[i] = plt_bitmap_init(
+				roc_sso->max_hwgrp, link_mem, link_map_sz);
+			if (sso->link_map[i] == NULL) {
+				plt_err("Failed to allocate link map");
+				goto link_mem_free;
+			}
+			link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
 		}
-		link_mem = PLT_PTR_ADD(link_mem, link_map_sz);
 	}
 	idev_sso_pffunc_set(sso->dev.pf_func);
 	idev_sso_set(roc_sso);