Skip to contentSkip to conversation

net/bnxt: modify mark manager validity checks

PATCH In review Mike Baucom 2 participants 2 messages May 4, 2020 – May 5, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: modify mark manager validity checks

From: Kishore Padmanabha <[email protected]>

The ulp mark manager originally assumed that zero was an invalid mark and used it for invalidation and deletion. The mark manager now supports adding zero as a mark, flags for validity and type, and adds explicit bounds checking instead of relying on mask.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c   |  22 ++---
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c | 176 ++++++++++++++++++++-------------
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h |  25 ++---
 3 files changed, 127 insertions(+), 96 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +6 -16
index 9ea6fdb..938b88e 100644
@@ -459,18 +459,9 @@
 ulp_mapper_mark_free(struct bnxt_ulp_context *ulp,
 		     struct ulp_flow_db_res_params *res)
 {
-	uint32_t flag;
-	uint32_t fid;
-	uint32_t gfid;
-
-	fid	  = (uint32_t)res->resource_hndl;
-	TF_GET_FLAG_FROM_FLOW_ID(fid, flag);
-	TF_GET_GFID_FROM_FLOW_ID(fid, gfid);
-
 	return ulp_mark_db_mark_del(ulp,
-				    (flag == TF_GFID_TABLE_EXTERNAL),
-				    gfid,
-				    0);
+				    res->resource_type,
+				    res->resource_hndl);
 }
 
 /*
@@ -1318,10 +1309,9 @@
 		mark = tfp_be_to_cpu_32(val);
 
 		TF_GET_GFID_FROM_FLOW_ID(iparms.flow_id, gfid);
-		TF_GET_FLAG_FROM_FLOW_ID(iparms.flow_id, flag);
-
+		flag = BNXT_ULP_MARK_GLOBAL_HW_FID;
 		rc = ulp_mark_db_mark_add(parms->ulp_ctx,
-					  (flag == TF_GFID_TABLE_EXTERNAL),
+					  flag,
 					  gfid,
 					  mark);
 		if (rc) {
@@ -1336,8 +1326,8 @@
 		memset(&fid_parms, 0, sizeof(fid_parms));
 		fid_parms.direction	= tbl->direction;
 		fid_parms.resource_func	= BNXT_ULP_RESOURCE_FUNC_HW_FID;
-		fid_parms.resource_type	= tbl->table_type;
-		fid_parms.resource_hndl	= iparms.flow_id;
+		fid_parms.resource_type	= flag;
+		fid_parms.resource_hndl	= gfid;
 		fid_parms.critical_resource = 0;
 
 		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +108 -68

264 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mark_mgr.h +13 -12
index 0f8a5e5..fd0d840 100644
@@ -8,23 +8,27 @@
 
 #include "bnxt_ulp.h"
 
-#define ULP_MARK_INVALID (0)
+#define BNXT_ULP_MARK_VALID   0x1
+#define BNXT_ULP_MARK_GLOBAL_HW_FID 0x4
+#define BNXT_ULP_MARK_LOCAL_HW_FID 0x8
+
 struct bnxt_lfid_mark_info {
 	uint16_t	mark_id;
-	bool		valid;
+	uint16_t	flags;
 };
 
 struct bnxt_gfid_mark_info {
 	uint32_t	mark_id;
-	bool		valid;
+	uint16_t	flags;
 };
 
 struct bnxt_ulp_mark_tbl {
 	struct bnxt_lfid_mark_info	*lfid_tbl;
 	struct bnxt_gfid_mark_info	*gfid_tbl;
+	uint32_t			lfid_num_entries;
+	uint32_t			gfid_num_entries;
 	uint32_t			gfid_mask;
 	uint32_t			gfid_type_bit;
-	uint32_t			gfid_max;
 };
 
 /*
@@ -77,7 +81,7 @@ struct bnxt_ulp_mark_tbl {
  *
  * ctxt [in] The ulp context for the mark manager
  *
- * is_gfid [in] The type of fid (GFID or LFID)
+ * mark_flag [in] mark flags.
  *
  * fid [in] The flow id that is returned by HW in BD
  *
@@ -86,7 +90,7 @@ struct bnxt_ulp_mark_tbl {
  */
 int32_t
 ulp_mark_db_mark_add(struct bnxt_ulp_context *ctxt,
-		     bool is_gfid,
+		     uint32_t mark_flag,
 		     uint32_t gfid,
 		     uint32_t mark);
 
@@ -95,17 +99,14 @@ struct bnxt_ulp_mark_tbl {
  *
  * ctxt [in] The ulp context for the mark manager
  *
- * is_gfid [in] The type of fid (GFID or LFID)
+ * mark_flag [in] mark flags
  *
  * fid [in] The flow id that is returned by HW in BD
  *
- * mark [in] The mark to be associated with the FID
- *
  */
 int32_t
 ulp_mark_db_mark_del(struct bnxt_ulp_context *ctxt,
-		     bool is_gfid,
-		     uint32_t gfid,
-		     uint32_t mark);
+		     uint32_t mark_flag,
+		     uint32_t gfid);
 
 #endif /* _ULP_MARK_MGR_H_ */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Mike Baucom

From: Kishore Padmanabha <[email protected]>

The ulp mark manager originally assumed that zero was an invalid mark and used it for invalidation and deletion. The mark manager now supports adding zero as a mark, flags for validity and type, and adds explicit bounds checking instead of relying on mask.

Patch applied to dpdk-next-net-brcm.