net/bnxt: updates to RSS action support

Message ID 20211011225039.62737-1-ajit.khaparde@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Ajit Khaparde
Headers
Series net/bnxt: updates to RSS action support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Ajit Khaparde Oct. 11, 2021, 10:50 p.m. UTC
  Some changes to the RSS action support to return appropriate error.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_filter.h |  2 +-
 drivers/net/bnxt/bnxt_flow.c   | 60 +++++++++++++++++++---------------
 2 files changed, 34 insertions(+), 28 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h
index 07938534a9..587932c96f 100644
--- a/drivers/net/bnxt/bnxt_filter.h
+++ b/drivers/net/bnxt/bnxt_filter.h
@@ -43,7 +43,7 @@  struct bnxt_filter_info {
 #define HWRM_CFA_EM_FILTER	1
 #define HWRM_CFA_NTUPLE_FILTER	2
 #define HWRM_CFA_TUNNEL_REDIRECT_FILTER	3
-#define HWRM_CFA_CONFIG_VNIC	4
+#define HWRM_CFA_CONFIG		4
 	uint8_t                 filter_type;
 	uint32_t                dst_id;
 
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 7043d44b4d..b2ebb5634e 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -738,6 +738,10 @@  bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 	filter->enables = en;
 	filter->valid_flags = valid_flags;
 
+	/* Items parsed but no filter to create in HW. */
+	if (filter->enables == 0 && filter->valid_flags == 0)
+		filter->filter_type = HWRM_CFA_CONFIG;
+
 	return 0;
 }
 
@@ -1127,7 +1131,7 @@  bnxt_vnic_rss_cfg_update(struct bnxt *bp,
 	if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&
 	    rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ) {
 		rte_flow_error_set(error,
-				   EINVAL,
+				   ENOTSUP,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act,
 				   "Unsupported RSS hash function");
@@ -1136,10 +1140,7 @@  bnxt_vnic_rss_cfg_update(struct bnxt *bp,
 	}
 
 	/* key_len should match the hash key supported by hardware */
-	if (rss->queue_num == 0 &&
-	    ((rss->key_len == 0 && rss->key != NULL) ||
-	     (rss->key_len != 0 && rss->key == NULL) ||
-	     (rss->key_len != 0 && rss->key_len != HW_HASH_KEY_SIZE))) {
+	if (rss->key_len != 0 && rss->key_len != HW_HASH_KEY_SIZE) {
 		rte_flow_error_set(error,
 				   EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
@@ -1156,7 +1157,7 @@  bnxt_vnic_rss_cfg_update(struct bnxt *bp,
 	 */
 	if (rss->level > 2) {
 		rte_flow_error_set(error,
-				   EINVAL,
+				   ENOTSUP,
 				   RTE_FLOW_ERROR_TYPE_ACTION,
 				   act,
 				   "Unsupported hash level");
@@ -1187,7 +1188,7 @@  bnxt_vnic_rss_cfg_update(struct bnxt *bp,
 	vnic->hash_mode =
 		bnxt_rte_to_hwrm_hash_level(bp, rss->types, rss->level);
 
-	/* Update RETA table only if key_len != 0 */
+	/* Update RSS key only if key_len != 0 */
 	if (rss->key_len != 0)
 		memcpy(vnic->rss_hash_key, rss->key, rss->key_len);
 
@@ -1272,17 +1273,6 @@  bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 
 	use_ntuple = bnxt_filter_type_check(pattern, error);
 
-	rc = bnxt_validate_rss_action(actions);
-	if (rc != 0) {
-		rte_flow_error_set(error,
-				   EINVAL,
-				   RTE_FLOW_ERROR_TYPE_ACTION,
-				   act,
-				   "Invalid actions specified with RSS");
-		rc = -rte_errno;
-		goto ret;
-	}
-
 start:
 	switch (act->type) {
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
@@ -1504,6 +1494,17 @@  bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		filter->flow_id = filter1->flow_id;
 		break;
 	case RTE_FLOW_ACTION_TYPE_RSS:
+		rc = bnxt_validate_rss_action(actions);
+		if (rc != 0) {
+			rte_flow_error_set(error,
+					   EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act,
+					   "Invalid actions specified with RSS");
+			rc = -rte_errno;
+			goto ret;
+		}
+
 		rss = (const struct rte_flow_action_rss *)act->conf;
 
 		vnic_id = bnxt_get_vnic(bp, attr->group);
@@ -1511,17 +1512,18 @@  bnxt_validate_and_parse_flow(struct rte_eth_dev *dev,
 		BNXT_VALID_VNIC_OR_RET(bp, vnic_id);
 		vnic = &bp->vnic_info[vnic_id];
 
-		if (filter->enables == 0 && filter->valid_flags == 0) {
+		/*
+		 * For non NS3 cases, rte_flow_items will not be considered
+		 * for RSS updates.
+		 */
+		if (filter->filter_type == HWRM_CFA_CONFIG) {
 			/* RSS config update requested */
 			rc = bnxt_vnic_rss_cfg_update(bp, vnic, act, error);
-			if (rc != 0) {
-				rc = -rte_errno;
-				goto ret;
-			} else {
-				filter->dst_id = vnic->fw_vnic_id;
-				filter->filter_type = HWRM_CFA_CONFIG_VNIC;
-				break;
-			}
+			if (rc != 0)
+				return -rte_errno;
+
+			filter->dst_id = vnic->fw_vnic_id;
+			break;
 		}
 
 		/* Check if requested RSS config matches RSS config of VNIC
@@ -2194,6 +2196,10 @@  _bnxt_flow_destroy(struct bnxt *bp,
 			return ret;
 	}
 
+	/* For config type, there is no filter in HW. Finish cleanup here */
+	if (filter->filter_type == HWRM_CFA_CONFIG)
+		goto done;
+
 	ret = bnxt_match_filter(bp, filter);
 	if (ret == 0)
 		PMD_DRV_LOG(ERR, "Could not find matching flow\n");