[35/47] net/bnxt: tf_ulp: TF support flow scale query

Message ID 20240830140049.1715230-36-sriharsha.basavapatna@broadcom.com (mailing list archive)
State Superseded
Delegated to: Ajit Khaparde
Headers
Series TruFlow update for Thor2 |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Sriharsha Basavapatna Aug. 30, 2024, 2 p.m. UTC
From: Shuanglin Wang <shuanglin.wang@broadcom.com>

TF supports the flow scale query feature for OVS application.
The resource usage is tracked when opening a TF session
or adding/deleting a flow. The resources includes WC TCAM,
EM, Action, Counter, Meter, ACT_ENCAP, ACT_ENCAP, and SP_SMAC.
User can query the resource usage using niccli.

This feature is disabled by default. Using the build flag
-DTF_FLOW_SCALE_QUERY to enable it.

Improvement on flow scale query feature

Several improvements on flow scale query feature:
1. Some default rules require both RX and TX resources;
   need to update usage states on both direcitons.
2. Update resoure usage state for regular flows only.
3. Added a buffer dirty state to avoid unnecessary
   state sync with firmware.

Signed-off-by: Shuanglin Wang <shuanglin.wang@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 17 +++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c  | 13 +++++++++++++
 2 files changed, 30 insertions(+)
  

Patch

diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 79e2931e43..e7ac617d7a 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -12,6 +12,9 @@ 
 #include "ulp_flow_db.h"
 #include "ulp_fc_mgr.h"
 #include "ulp_tun.h"
+#ifdef TF_FLOW_SCALE_QUERY
+#include "tf_resources.h"
+#endif /* TF_FLOW_SCALE_QUERY */
 
 #define ULP_FLOW_DB_RES_DIR_BIT		31
 #define ULP_FLOW_DB_RES_DIR_MASK	0x80000000
@@ -956,8 +959,15 @@  ulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,
 		return -EINVAL;
 	}
 
+#ifdef TF_FLOW_SCALE_QUERY
+	tf_resc_pause_usage_update();
+#endif
 	while (!ulp_flow_db_next_entry_get(flow_db, flow_type, &fid))
 		ulp_mapper_resources_free(ulp_ctx, flow_type, fid, NULL);
+#ifdef TF_FLOW_SCALE_QUERY
+	tf_resc_resume_usage_update();
+	tf_resc_usage_update_all(ulp_ctx->bp);
+#endif
 
 	bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
 
@@ -994,6 +1004,9 @@  ulp_flow_db_function_flow_flush(struct bnxt_ulp_context *ulp_ctx,
 		return -EINVAL;
 	}
 
+#ifdef TF_FLOW_SCALE_QUERY
+	tf_resc_pause_usage_update();
+#endif
 	while (!ulp_flow_db_next_entry_get(flow_db, BNXT_ULP_FDB_TYPE_REGULAR,
 					   &flow_id)) {
 		if (flow_db->func_id_tbl[flow_id] == func_id)
@@ -1002,6 +1015,10 @@  ulp_flow_db_function_flow_flush(struct bnxt_ulp_context *ulp_ctx,
 						  flow_id,
 						  NULL);
 	}
+#ifdef TF_FLOW_SCALE_QUERY
+	tf_resc_resume_usage_update();
+	tf_resc_usage_update_all(ulp_ctx->bp);
+#endif
 	bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
 	return 0;
 }
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 17e5b99562..3bf0307980 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -21,6 +21,9 @@ 
 #include "ulp_port_db.h"
 #include "ulp_ha_mgr.h"
 #include "bnxt_tf_pmd_shim.h"
+#ifdef TF_FLOW_SCALE_QUERY
+#include "tf_resources.h"
+#endif /* TF_FLOW_SCALE_QUERY */
 
 static uint8_t mapper_fld_zeros[16] = { 0 };
 
@@ -4315,6 +4318,12 @@  ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx,
 	if (rc)
 		frc = rc;
 
+#ifdef TF_FLOW_SCALE_QUERY
+	/* update for regular flows only */
+	if (flow_type == BNXT_ULP_FDB_TYPE_REGULAR)
+		tf_resc_usage_update_all(ulp_ctx->bp);
+#endif /* TF_FLOW_SCALE_QUERY */
+
 	return frc;
 }
 
@@ -4464,6 +4473,10 @@  ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 			goto flow_error;
 	}
 
+#ifdef TF_FLOW_SCALE_QUERY
+	tf_resc_usage_update_all(ulp_ctx->bp);
+#endif /* TF_FLOW_SCALE_QUERY */
+
 	return rc;
 
 batch_error: