[v2,17/25] net/bnxt: check and set initial counter ID
diff mbox series

Message ID 20200916042851.32914-18-ajit.khaparde@broadcom.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Sept. 16, 2020, 4:28 a.m. UTC
From: Somnath Kotur <somnath.kotur@broadcom.com>

Instead of relying on value of Flow counter ID to determine validity
have an explicit boolean flag for the same to check and set.

Fixes: 306c2d28e247 ("net/bnxt: support count action in flow query")
Fixes: 9cf9c8385df7 ("net/bnxt: add ULP flow counter manager")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 8 ++++----
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index df1921d54..5a0bf602a 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -431,8 +431,7 @@  bool ulp_fc_mgr_start_idx_isset(struct bnxt_ulp_context *ctxt, enum tf_dir dir)
 
 	ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
 
-	/* Assuming start_idx of 0 is invalid */
-	return (ulp_fc_info->shadow_hw_tbl[dir].start_idx != 0);
+	return ulp_fc_info->shadow_hw_tbl[dir].start_idx_is_set;
 }
 
 /*
@@ -456,9 +455,10 @@  int32_t ulp_fc_mgr_start_idx_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
 	if (!ulp_fc_info)
 		return -EIO;
 
-	/* Assuming that 0 is an invalid counter ID ? */
-	if (ulp_fc_info->shadow_hw_tbl[dir].start_idx == 0)
+	if (!ulp_fc_info->shadow_hw_tbl[dir].start_idx_is_set) {
 		ulp_fc_info->shadow_hw_tbl[dir].start_idx = start_idx;
+		ulp_fc_info->shadow_hw_tbl[dir].start_idx_is_set = true;
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index 9c317b023..0cb880d4b 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -38,6 +38,7 @@  struct hw_fc_mem_info {
 	 */
 	void *mem_pa;
 	uint32_t start_idx;
+	bool start_idx_is_set;
 };
 
 struct bnxt_ulp_fc_info {