[34/36] net/bnxt: enable vfr flag processing with mark db opcode
diff mbox series

Message ID 20200610065733.18698-35-somnath.kotur@broadcom.com
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series
  • bnxt fixes and enhancements
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Somnath Kotur June 10, 2020, 6:57 a.m. UTC
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Removed the mark and vfr flags and replaced it with the new
opcode and added the vfr flag process in mark database

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Michael Baucom <michael.baucom@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c            | 74 ++++++++++++++++++++++---
 drivers/net/bnxt/tf_ulp/ulp_template_db_class.c | 45 +++++----------
 drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h  | 15 ++---
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h   |  3 +-
 4 files changed, 87 insertions(+), 50 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 56c1f13..f86cd76 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -899,11 +899,13 @@  ulp_mapper_mark_gfid_process(struct bnxt_ulp_mapper_parms *parms,
 {
 	struct ulp_flow_db_res_params fid_parms;
 	uint32_t mark, gfid, mark_flag;
+	enum bnxt_ulp_mark_db_opcode mark_op = tbl->mark_db_opcode;
 	int32_t rc = 0;
 
-	if (!(tbl->mark_enable &&
-	      (ULP_BITMAP_ISSET(parms->act_bitmap->bits,
-			      BNXT_ULP_ACTION_BIT_MARK) || tbl->vfr_flag)))
+	if (mark_op == BNXT_ULP_MARK_DB_OPCODE_NOP ||
+	    !(mark_op == BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION &&
+	     ULP_BITMAP_ISSET(parms->act_bitmap->bits,
+			      BNXT_ULP_ACTION_BIT_MARK)))
 		return rc; /* no need to perform gfid process */
 
 	/* Get the mark id details from action property */
@@ -913,7 +915,7 @@  ulp_mapper_mark_gfid_process(struct bnxt_ulp_mapper_parms *parms,
 
 	TF_GET_GFID_FROM_FLOW_ID(flow_id, gfid);
 	mark_flag  = BNXT_ULP_MARK_GLOBAL_HW_FID;
-	mark_flag |= (tbl->vfr_flag) ? BNXT_ULP_MARK_VFR_ID : 0;
+
 	rc = ulp_mark_db_mark_add(parms->ulp_ctx, mark_flag,
 				  gfid, mark);
 	if (rc) {
@@ -941,11 +943,13 @@  ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms,
 	struct ulp_flow_db_res_params fid_parms;
 	uint32_t act_idx, mark, mark_flag;
 	uint64_t val64;
+	enum bnxt_ulp_mark_db_opcode mark_op = tbl->mark_db_opcode;
 	int32_t rc = 0;
 
-	if (!(tbl->mark_enable &&
-	      (ULP_BITMAP_ISSET(parms->act_bitmap->bits,
-				BNXT_ULP_ACTION_BIT_MARK) || tbl->vfr_flag)))
+	if (mark_op == BNXT_ULP_MARK_DB_OPCODE_NOP ||
+	    !(mark_op == BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION &&
+	     ULP_BITMAP_ISSET(parms->act_bitmap->bits,
+			      BNXT_ULP_ACTION_BIT_MARK)))
 		return rc; /* no need to perform mark action process */
 
 	/* Get the mark id details from action property */
@@ -961,7 +965,55 @@  ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms,
 	}
 	act_idx = tfp_be_to_cpu_64(val64);
 	mark_flag  = BNXT_ULP_MARK_LOCAL_HW_FID;
-	mark_flag |= (tbl->vfr_flag) ? BNXT_ULP_MARK_VFR_ID : 0;
+	rc = ulp_mark_db_mark_add(parms->ulp_ctx, mark_flag,
+				  act_idx, mark);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to add mark to flow\n");
+		return rc;
+	}
+	fid_parms.direction = tbl->direction;
+	fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_HW_FID;
+	fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;
+	fid_parms.resource_type	= mark_flag;
+	fid_parms.resource_hndl	= act_idx;
+	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+				      parms->tbl_idx,
+				      parms->fid,
+				      &fid_parms);
+	if (rc)
+		BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc);
+	return rc;
+}
+
+static int32_t
+ulp_mapper_mark_vfr_idx_process(struct bnxt_ulp_mapper_parms *parms,
+				struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+	struct ulp_flow_db_res_params fid_parms;
+	uint32_t act_idx, mark, mark_flag;
+	uint64_t val64;
+	enum bnxt_ulp_mark_db_opcode mark_op = tbl->mark_db_opcode;
+	int32_t rc = 0;
+
+	if (mark_op == BNXT_ULP_MARK_DB_OPCODE_NOP ||
+	    mark_op == BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION)
+		return rc; /* no need to perform mark action process */
+
+	/* Get the mark id details from the computed field of dev port id */
+	mark = ULP_COMP_FLD_IDX_RD(parms, BNXT_ULP_CF_IDX_DEV_PORT_ID);
+
+	 /* Get the main action pointer */
+	if (!ulp_regfile_read(parms->regfile,
+			      BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
+			      &val64)) {
+		BNXT_TF_DBG(ERR, "read action ptr main failed\n");
+		return -EINVAL;
+	}
+	act_idx = tfp_be_to_cpu_64(val64);
+
+	/* Set the mark flag to local fid and vfr flag */
+	mark_flag  = BNXT_ULP_MARK_LOCAL_HW_FID | BNXT_ULP_MARK_VFR_ID;
+
 	rc = ulp_mark_db_mark_add(parms->ulp_ctx, mark_flag,
 				  act_idx, mark);
 	if (rc) {
@@ -1525,6 +1577,12 @@  ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		goto error;
 	}
 
+	/* Perform the VF rep action */
+	rc = ulp_mapper_mark_vfr_idx_process(parms, tbl);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to add vfr mark rc = %d\n", rc);
+		goto error;
+	}
 	return rc;
 error:
 	/*
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c
index cc81b31..aa66c7f 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c
@@ -112,8 +112,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 0,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -135,8 +134,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 1,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -158,8 +156,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 1,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -181,8 +178,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 2,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -204,8 +200,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 2,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_YES,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -227,8 +222,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 2,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -250,8 +244,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 3,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -273,8 +266,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 3,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -296,8 +288,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 4,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -319,8 +310,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 4,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_YES,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -342,8 +332,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 4,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -365,8 +354,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 5,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -388,8 +376,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 5,
 	.ident_nums = 1,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -411,8 +398,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 6,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	},
@@ -434,8 +420,7 @@  struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.encap_num_fields = 0,
 	.ident_start_idx = 6,
 	.ident_nums = 0,
-	.mark_enable = BNXT_ULP_MARK_ENABLE_YES,
-	.vfr_flag = BNXT_ULP_VFR_FLAG_NO,
+	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION,
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES,
 	.regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
 	}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
index 7f280fd..5376245 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
@@ -151,10 +151,11 @@  enum bnxt_ulp_hdr_type {
 	BNXT_ULP_HDR_TYPE_LAST = 3
 };
 
-enum bnxt_ulp_mark_enable {
-	BNXT_ULP_MARK_ENABLE_NO = 0,
-	BNXT_ULP_MARK_ENABLE_YES = 1,
-	BNXT_ULP_MARK_ENABLE_LAST = 2
+enum bnxt_ulp_mark_db_opcode {
+	BNXT_ULP_MARK_DB_OPCODE_NOP = 0,
+	BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION = 1,
+	BNXT_ULP_MARK_DB_OPCODE_SET_VFR_FLAG = 2,
+	BNXT_ULP_MARK_DB_OPCODE_LAST = 3
 };
 
 enum bnxt_ulp_mapper_opc {
@@ -214,12 +215,6 @@  enum bnxt_ulp_search_before_alloc {
 	BNXT_ULP_SEARCH_BEFORE_ALLOC_LAST = 2
 };
 
-enum bnxt_ulp_vfr_flag {
-	BNXT_ULP_VFR_FLAG_NO = 0,
-	BNXT_ULP_VFR_FLAG_YES = 1,
-	BNXT_ULP_VFR_FLAG_LAST = 2
-};
-
 enum bnxt_ulp_fdb_resource_flags {
 	BNXT_ULP_FDB_RESOURCE_FLAGS_DIR_EGR = 0x01,
 	BNXT_ULP_FDB_RESOURCE_FLAGS_DIR_INGR = 0x00
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
index 8de6c4c..5d11a7e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
@@ -181,9 +181,8 @@  struct bnxt_ulp_mapper_tbl_info {
 	uint32_t	ident_start_idx;
 	uint16_t	ident_nums;
 
-	uint8_t		mark_enable;
 	enum bnxt_ulp_regfile_index	regfile_idx;
-	enum bnxt_ulp_vfr_flag		vfr_flag;
+	enum bnxt_ulp_mark_db_opcode	mark_db_opcode;
 };
 
 struct bnxt_ulp_mapper_class_key_field_info {