common/cnxk: fix incorrect free of MCAM counter

Message ID 20210917043746.3652748-1-psatheesh@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series common/cnxk: fix incorrect free of MCAM counter |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Satheesh Paul Antonysamy Sept. 17, 2021, 4:37 a.m. UTC
  From: Satheesh Paul <psatheesh@marvell.com>

Upon MCAM allocation failure, free counters only if counters
were allocated earlier for the flow rule.

Fixes: f9af9080746 ("common/cnxk: add mcam utility API")

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
---
 drivers/common/cnxk/roc_npc_mcam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Jerin Jacob Oct. 4, 2021, 3:46 p.m. UTC | #1
On Fri, Sep 17, 2021 at 10:08 AM <psatheesh@marvell.com> wrote:
>
> From: Satheesh Paul <psatheesh@marvell.com>
>
> Upon MCAM allocation failure, free counters only if counters
> were allocated earlier for the flow rule.
>
> Fixes: f9af9080746 ("common/cnxk: add mcam utility API")
>
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks
> ---
>  drivers/common/cnxk/roc_npc_mcam.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c
> index 8ccaaad0af..7d9b0ed3e3 100644
> --- a/drivers/common/cnxk/roc_npc_mcam.c
> +++ b/drivers/common/cnxk/roc_npc_mcam.c
> @@ -519,7 +519,8 @@ npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow,
>
>         entry = npc_check_preallocated_entry_cache(mbox, flow, npc);
>         if (entry < 0) {
> -               npc_mcam_free_counter(npc, ctr);
> +               if (use_ctr)
> +                       npc_mcam_free_counter(npc, ctr);
>                 return NPC_ERR_MCAM_ALLOC;
>         }
>
> --
> 2.25.4
>
  

Patch

diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c
index 8ccaaad0af..7d9b0ed3e3 100644
--- a/drivers/common/cnxk/roc_npc_mcam.c
+++ b/drivers/common/cnxk/roc_npc_mcam.c
@@ -519,7 +519,8 @@  npc_mcam_alloc_and_write(struct npc *npc, struct roc_npc_flow *flow,
 
 	entry = npc_check_preallocated_entry_cache(mbox, flow, npc);
 	if (entry < 0) {
-		npc_mcam_free_counter(npc, ctr);
+		if (use_ctr)
+			npc_mcam_free_counter(npc, ctr);
 		return NPC_ERR_MCAM_ALLOC;
 	}