[v3,47/51] net/bnxt: add port default rules for ingress and egress
diff mbox series

Message ID 20200702041134.43198-48-ajit.khaparde@broadcom.com
State Superseded
Delegated to: Ajit Khaparde
Headers show
Series
  • add features for host-based flow management
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde July 2, 2020, 4:11 a.m. UTC
From: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>

ingress & egress port default rules are needed to send the packet
from port_to_dpdk & dpdk_to_port respectively.

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c     | 76 +++++++++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h |  3 ++
 2 files changed, 78 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index de8e11a6e..2a19c5040 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -29,6 +29,7 @@ 
 #include "hsi_struct_def_dpdk.h"
 #include "bnxt_nvm_defs.h"
 #include "bnxt_tf_common.h"
+#include "ulp_flow_db.h"
 
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
@@ -1162,6 +1163,73 @@  static int bnxt_handle_if_change_status(struct bnxt *bp)
 	return rc;
 }
 
+static int32_t
+bnxt_create_port_app_df_rule(struct bnxt *bp, uint8_t flow_type,
+			     uint32_t *flow_id)
+{
+	uint16_t port_id = bp->eth_dev->data->port_id;
+	struct ulp_tlv_param param_list[] = {
+		{
+			.type = BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID,
+			.length = 2,
+			.value = {(port_id >> 8) & 0xff, port_id & 0xff}
+		},
+		{
+			.type = BNXT_ULP_DF_PARAM_TYPE_LAST,
+			.length = 0,
+			.value = {0}
+		}
+	};
+
+	return ulp_default_flow_create(bp->eth_dev, param_list, flow_type,
+				       flow_id);
+}
+
+static int32_t
+bnxt_create_df_rules(struct bnxt *bp)
+{
+	struct bnxt_ulp_data *cfg_data;
+	int rc;
+
+	cfg_data = bp->ulp_ctx->cfg_data;
+	rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_PORT_TO_VS,
+					  &cfg_data->port_to_app_flow_id);
+	if (rc) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to create port to app default rule\n");
+		return rc;
+	}
+
+	BNXT_TF_DBG(DEBUG, "***** created port to app default rule ******\n");
+	rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_VS_TO_PORT,
+					  &cfg_data->app_to_port_flow_id);
+	if (!rc) {
+		rc = ulp_default_flow_db_cfa_action_get(bp->ulp_ctx,
+							cfg_data->app_to_port_flow_id,
+							&cfg_data->tx_cfa_action);
+		if (rc)
+			goto err;
+
+		BNXT_TF_DBG(DEBUG,
+			    "***** created app to port default rule *****\n");
+		return 0;
+	}
+
+err:
+	BNXT_TF_DBG(DEBUG, "Failed to create app to port default rule\n");
+	return rc;
+}
+
+static void
+bnxt_destroy_df_rules(struct bnxt *bp)
+{
+	struct bnxt_ulp_data *cfg_data;
+
+	cfg_data = bp->ulp_ctx->cfg_data;
+	ulp_default_flow_destroy(bp->eth_dev, cfg_data->port_to_app_flow_id);
+	ulp_default_flow_destroy(bp->eth_dev, cfg_data->app_to_port_flow_id);
+}
+
 static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
@@ -1330,8 +1398,11 @@  static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp);
 	bnxt_cancel_fc_thread(bp);
 
-	if (BNXT_TRUFLOW_EN(bp))
+	if (BNXT_TRUFLOW_EN(bp)) {
+		if (bp->rep_info != NULL)
+			bnxt_destroy_df_rules(bp);
 		bnxt_ulp_deinit(bp);
+	}
 
 	if (eth_dev->data->dev_started)
 		bnxt_dev_stop_op(eth_dev);
@@ -1581,6 +1652,9 @@  static int bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
 	if (rc != 0)
 		vnic->flags = old_flags;
 
+	if (BNXT_TRUFLOW_EN(bp) && bp->rep_info != NULL)
+		bnxt_create_df_rules(bp);
+
 	return rc;
 }
 
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 3563f63fa..4843da562 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -22,6 +22,9 @@  struct bnxt_ulp_data {
 	struct bnxt_ulp_flow_db		*flow_db;
 	void				*mapper_data;
 	struct bnxt_ulp_port_db		*port_db;
+	uint32_t			port_to_app_flow_id;
+	uint32_t			app_to_port_flow_id;
+	uint32_t			tx_cfa_action;
 };
 
 struct bnxt_ulp_context {