DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
To: dev@dpdk.org
Cc: Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
	Shuanglin Wang <shuanglin.wang@broadcom.com>,
	Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>,
	Mike Baucom <michael.baucom@broadcom.com>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>
Subject: [PATCH v8 27/47] net/bnxt: tf_ulp: fixed parent child db counters
Date: Thu,  7 Nov 2024 19:22:34 +0530	[thread overview]
Message-ID: <20241107135254.1611676-28-sriharsha.basavapatna@broadcom.com> (raw)
In-Reply-To: <20241107135254.1611676-1-sriharsha.basavapatna@broadcom.com>

From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

The locking for the parent child counters need to be done till the
stats are retrieved. Also the OVS is creating multiple F1 flows for
same tunnel hence reference count needs to be maintined for the F1
flows.

Fix name conflicts for class and action tables. Matcher allocates
hash tables for class and action entries. These tables should have
different names for each port.

Fixes: bdf4a3c6316b ("net/bnxt: support tunnel offload")
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Shuanglin Wang <shuanglin.wang@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c  | 37 +++++++++++++++++----------
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 22 ++++++++++------
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h |  2 ++
 drivers/net/bnxt/tf_ulp/ulp_matcher.c | 12 +++++++--
 4 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index b880b545da..0c46c7d4c9 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -563,23 +563,29 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
 
 	} while (!rc && nxt_resource_index);
 
-	bnxt_ulp_cntxt_release_fdb_lock(ctxt);
-
-	if (rc || !found_cntr_resource)
+	if (rc || !found_cntr_resource) {
+		bnxt_ulp_cntxt_release_fdb_lock(ctxt);
 		return rc;
+	}
 
 	dir = params.direction;
-	if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN))
-		return fc_ops->ulp_flow_stat_get(ctxt, dir,
-						 params.resource_hndl, count);
+	if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN)) {
+		rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+					       params.resource_hndl, count);
+		bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+		return rc;
+	}
 
 	if (!found_parent_flow &&
 	    params.resource_sub_type ==
 			BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) {
 		hw_cntr_id = params.resource_hndl;
-		if (!ulp_fc_info->num_counters)
-			return fc_ops->ulp_flow_stat_get(ctxt, dir,
-							 hw_cntr_id, count);
+		if (!ulp_fc_info->num_counters) {
+			rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+						       hw_cntr_id, count);
+			bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+			return rc;
+		}
 
 		/* TODO:
 		 * Think about optimizing with try_lock later
@@ -603,9 +609,14 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
 		   params.resource_sub_type ==
 			BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) {
 		/* Get stats from the parent child table */
-		ulp_flow_db_parent_flow_count_get(ctxt, pc_idx,
-						  &count->hits, &count->bytes,
-						  count->reset);
+		if (ulp_flow_db_parent_flow_count_get(ctxt, flow_id,
+						      pc_idx,
+						      &count->hits,
+						      &count->bytes,
+						      count->reset)) {
+			bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+			return -EIO;
+		}
 		if (count->hits)
 			count->hits_set = 1;
 		if (count->bytes)
@@ -613,7 +624,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt,
 	} else {
 		rc = -EINVAL;
 	}
-
+	bnxt_ulp_cntxt_release_fdb_lock(ctxt);
 	return rc;
 }
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 2ff5227774..27f1115990 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -838,7 +838,6 @@ ulp_flow_db_fid_free(struct bnxt_ulp_context *ulp_ctxt,
 #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
 	BNXT_DRV_DBG(DEBUG, "flow_id = %u:%u freed\n", flow_type, fid);
 #endif
-
 	/* all good, return success */
 	return 0;
 }
@@ -1385,13 +1384,12 @@ ulp_flow_db_pc_db_parent_flow_set(struct bnxt_ulp_context *ulp_ctxt,
 
 	if (set_flag) {
 		pc_entry->parent_fid = parent_fid;
+		pc_entry->parent_ref_cnt++;
 	} else {
-		if (pc_entry->parent_fid != parent_fid)
-			BNXT_DRV_DBG(ERR, "Panic: invalid parent id\n");
-		pc_entry->parent_fid = 0;
-
+		if (pc_entry->parent_ref_cnt > 0)
+			pc_entry->parent_ref_cnt--;
 		/* Free the parent child db entry if no user present */
-		if (!pc_entry->f2_cnt)
+		if (!pc_entry->parent_ref_cnt && !pc_entry->f2_cnt)
 			ulp_flow_db_pc_db_entry_free(ulp_ctxt, pc_entry);
 	}
 	return 0;
@@ -1446,7 +1444,7 @@ ulp_flow_db_pc_db_child_flow_set(struct bnxt_ulp_context *ulp_ctxt,
 		ULP_INDEX_BITMAP_RESET(t[a_idx], child_fid);
 		if (pc_entry->f2_cnt)
 			pc_entry->f2_cnt--;
-		if (!pc_entry->f2_cnt && !pc_entry->parent_fid)
+		if (!pc_entry->f2_cnt && !pc_entry->parent_ref_cnt)
 			ulp_flow_db_pc_db_entry_free(ulp_ctxt, pc_entry);
 	}
 	return 0;
@@ -1538,7 +1536,7 @@ ulp_flow_db_parent_flow_count_accum_set(struct bnxt_ulp_context *ulp_ctxt,
 	/* check for parent idx validity */
 	p_pdb = &flow_db->parent_child_db;
 	if (pc_idx >= p_pdb->entries_count ||
-	    !p_pdb->parent_flow_tbl[pc_idx].parent_fid) {
+	    !p_pdb->parent_flow_tbl[pc_idx].parent_ref_cnt) {
 		BNXT_DRV_DBG(ERR, "Invalid parent child index %x\n", pc_idx);
 		return -EINVAL;
 	}
@@ -1786,6 +1784,7 @@ ulp_flow_db_parent_flow_count_update(struct bnxt_ulp_context *ulp_ctxt,
  */
 int32_t
 ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt,
+				  uint32_t flow_id,
 				  uint32_t pc_idx, uint64_t *packet_count,
 				  uint64_t *byte_count, uint8_t count_reset)
 {
@@ -1798,6 +1797,13 @@ ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt,
 		return -EINVAL;
 	}
 
+	/* stale parent fid */
+	if (flow_id != pc_entry->parent_fid) {
+		*packet_count = 0;
+		*byte_count = 0;
+		return 0;
+	}
+
 	if (pc_entry->counter_acc) {
 		*packet_count = pc_entry->pkt_count;
 		*byte_count = pc_entry->byte_count;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h
index 39810c81c4..5a4b5a1ebf 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h
@@ -63,6 +63,7 @@ struct bnxt_ulp_flow_tbl {
 struct ulp_fdb_parent_info {
 	uint32_t	valid;
 	uint32_t	parent_fid;
+	uint32_t	parent_ref_cnt;
 	uint32_t	counter_acc;
 	uint64_t	pkt_count;
 	uint64_t	byte_count;
@@ -389,6 +390,7 @@ ulp_flow_db_parent_flow_count_update(struct bnxt_ulp_context *ulp_ctxt,
  */
 int32_t
 ulp_flow_db_parent_flow_count_get(struct bnxt_ulp_context *ulp_ctxt,
+				  uint32_t flow_id,
 				  uint32_t pc_idx,
 				  uint64_t *packet_count,
 				  uint64_t *byte_count,
diff --git a/drivers/net/bnxt/tf_ulp/ulp_matcher.c b/drivers/net/bnxt/tf_ulp/ulp_matcher.c
index b508bd2df6..9615fc7919 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_matcher.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_matcher.c
@@ -327,9 +327,17 @@ ulp_matcher_action_match(struct ulp_rte_parser_params *params,
 int32_t ulp_matcher_init(struct bnxt_ulp_context *ulp_ctx)
 {
 	struct rte_hash_parameters hash_tbl_params = {0};
-	char hash_class_tbl_name[64] = "bnxt_ulp_class_matcher";
-	char hash_act_tbl_name[64] = "bnxt_ulp_act_matcher";
+	char hash_class_tbl_name[64] = {0};
+	char hash_act_tbl_name[64] = {0};
 	struct bnxt_ulp_matcher_data *data;
+	uint16_t port_id;
+
+	/* append port_id to the buffer name */
+	port_id = ulp_ctx->bp->eth_dev->data->port_id;
+	snprintf(hash_class_tbl_name, sizeof(hash_class_tbl_name),
+		 "bnxt_ulp_class_matcher_%d", port_id);
+	snprintf(hash_act_tbl_name, sizeof(hash_act_tbl_name),
+		 "bnxt_ulp_act_matcher_%d", port_id);
 
 	data = rte_zmalloc("bnxt_ulp_matcher_data",
 			   sizeof(struct bnxt_ulp_matcher_data), 0);
-- 
2.39.3


  parent reply	other threads:[~2024-11-07 13:45 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 13:52 [PATCH v8 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 02/47] net/bnxt: tf_core: tcam manager data corruption Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 03/47] net/bnxt: tf_core: External EM support cleanup Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 04/47] net/bnxt: tf_core: Thor TF EM key size check Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 05/47] net/bnxt: tf_core: flow scale improvement Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 06/47] net/bnxt: tf_core: TF support flow scale query Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 07/47] net/bnxt: tf_core: fix slice count in case of HA entry move Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 08/47] net/bnxt: tf_core: convert priority based TCAM manager to dynamic allocation Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 09/47] net/bnxt: tf_core: remove dead AFM code from session-based priority TCAM mgr Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 10/47] net/bnxt: tf_core: remove dead " Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 11/47] net/bnxt: tfc: support tf-core for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 12/47] net/bnxt: tf_ulp: add vxlan-gpe base support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 13/47] net/bnxt: tf_ulp: add custom l2 etype tunnel support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 14/47] net/bnxt: tf_ulp: add support for vf to vf flow offload Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 15/47] net/bnxt: tf_ulp: Wh+ mirroring support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 16/47] net/bnxt: tf_ulp: miscellaneous fixes Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 17/47] net/bnxt: tf_ulp: support for Thor2 ulp layer Sriharsha Basavapatna
2024-12-10 13:32   ` David Marchand
2024-11-07 13:52 ` [PATCH v8 18/47] net/bnxt: tf_ulp: add support for overlapping flows Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 19/47] net/bnxt: tf_ulp: convert recipe table to dynamic memory Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 20/47] net/bnxt: tf_ulp: add feature bit support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 21/47] net/bnxt: tf_ulp: add action read and clear support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 22/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 23/47] net/bnxt: tf_ulp: VFR updates for Thor 2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 24/47] net/bnxt: tf_ulp: add support for tunnel flow stats Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 25/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 26/47] net/bnxt: tf_ulp: enable recipe id generation Sriharsha Basavapatna
2024-11-07 13:52 ` Sriharsha Basavapatna [this message]
2024-11-07 13:52 ` [PATCH v8 28/47] net/bnxt: tf_ulp: modify return values to adhere to C coding standard Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 29/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 30/47] net/bnxt: tf_ulp: add mask defaults when mask is not specified Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 31/47] net/bnxt: tf_ulp: add jump action support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 32/47] net/bnxt: tf_ulp: add support for flow priority Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 33/47] net/bnxt: tf_ulp: support for dynamic tunnel ports Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 34/47] net/bnxt: tf_ulp: add rte_mtr support for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 35/47] net/bnxt: tf_ulp: TF support flow scale query Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 37/47] net/bnxt: tf_ulp: add track type feature to tables Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 38/47] net/bnxt: tf_ulp: inline utility functions and use likely/unlikely Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 40/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 41/47] net/bnxt: tf_ulp: support a few generic template items Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 42/47] net/bnxt: tf_ulp: TFC support flow scale query for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 43/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 44/47] net/bnxt: tf_ulp: enable support for truflow feature configuration Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 45/47] net/bnxt: tf_ulp: support a few feature extensions Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 46/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 47/47] net/bnxt: tf_ulp: add stats cache for thor2 Sriharsha Basavapatna
2024-11-08  2:05 ` [PATCH v8 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-11-08  2:14   ` Ajit Khaparde
2024-11-12 11:00     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241107135254.1611676-28-sriharsha.basavapatna@broadcom.com \
    --to=sriharsha.basavapatna@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=michael.baucom@broadcom.com \
    --cc=shuanglin.wang@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).