net/bnxt: add CFA subdirectory of HCAPI
[dpdk.git] / drivers / net / bnxt / tf_core / tf_device.c
index 20b0c59..f68eb72 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2020 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
  * All rights reserved.
  */
 
@@ -44,8 +44,9 @@ tf_dev_bind_p4(struct tf *tfp,
        struct tf_tbl_cfg_parms tbl_cfg;
        struct tf_tcam_cfg_parms tcam_cfg;
        struct tf_em_cfg_parms em_cfg;
+       struct tf_if_tbl_cfg_parms if_tbl_cfg;
+       struct tf_global_cfg_cfg_parms global_cfg;
 
-       dev_handle->type = TF_DEVICE_TYPE_WH;
        /* Initial function initialization */
        dev_handle->ops = &tf_dev_ops_p4_init;
 
@@ -88,10 +89,12 @@ tf_dev_bind_p4(struct tf *tfp,
         * EEM
         */
        em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
-       em_cfg.cfg = tf_em_ext_p4;
+       if (dev_handle->type == TF_DEVICE_TYPE_WH)
+               em_cfg.cfg = tf_em_ext_p4;
+       else
+               em_cfg.cfg = tf_em_ext_p45;
        em_cfg.resources = resources;
        em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST;
-
        rc = tf_em_ext_common_bind(tfp, &em_cfg);
        if (rc) {
                TFP_DRV_LOG(ERR,
@@ -114,6 +117,31 @@ tf_dev_bind_p4(struct tf *tfp,
                goto fail;
        }
 
+       /*
+        * IF_TBL
+        */
+       if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+       if_tbl_cfg.cfg = tf_if_tbl_p4;
+       if_tbl_cfg.shadow_copy = shadow_copy;
+       rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "IF Table initialization failure\n");
+               goto fail;
+       }
+
+       /*
+        * GLOBAL_CFG
+        */
+       global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+       global_cfg.cfg = tf_global_cfg_p4;
+       rc = tf_global_cfg_bind(tfp, &global_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Global Cfg initialization failure\n");
+               goto fail;
+       }
+
        /* Final function initialization */
        dev_handle->ops = &tf_dev_ops_p4;
 
@@ -186,6 +214,20 @@ tf_dev_unbind_p4(struct tf *tfp)
                fail = true;
        }
 
+       rc = tf_if_tbl_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, IF Table Type\n");
+               fail = true;
+       }
+
+       rc = tf_global_cfg_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, Global Cfg Type\n");
+               fail = true;
+       }
+
        if (fail)
                return -1;
 
@@ -201,6 +243,8 @@ tf_dev_bind(struct tf *tfp __rte_unused,
 {
        switch (type) {
        case TF_DEVICE_TYPE_WH:
+       case TF_DEVICE_TYPE_SR:
+               dev_handle->type = type;
                return tf_dev_bind_p4(tfp,
                                      shadow_copy,
                                      resources,
@@ -218,6 +262,7 @@ tf_dev_unbind(struct tf *tfp,
 {
        switch (dev_handle->type) {
        case TF_DEVICE_TYPE_WH:
+       case TF_DEVICE_TYPE_SR:
                return tf_dev_unbind_p4(tfp);
        default:
                TFP_DRV_LOG(ERR,