net/bnxt: add port default rules for ingress and egress
authorVenkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Thu, 2 Jul 2020 23:28:34 +0000 (16:28 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:27 +0000 (23:38 +0200)
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
drivers/net/bnxt/tf_ulp/bnxt_ulp.h

index 9d1c40a..e447b74 100644 (file)
@@ -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[] =
@@ -1161,6 +1162,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;
@@ -1329,8 +1397,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);
@@ -1580,6 +1651,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;
 }
 
index 3563f63..4843da5 100644 (file)
@@ -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 {