net/bnxt: add base TRUFLOW support for Thor
authorFarah Smith <farah.smith@broadcom.com>
Sun, 30 May 2021 08:58:33 +0000 (14:28 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Wed, 9 Jun 2021 18:47:25 +0000 (20:47 +0200)
Add infrastructure code to support TRUFLOW on Thor NICs.
Also update meson.build

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
13 files changed:
drivers/net/bnxt/tf_core/cfa_resource_types.h
drivers/net/bnxt/tf_core/meson.build
drivers/net/bnxt/tf_core/tf_core.c
drivers/net/bnxt/tf_core/tf_device.c
drivers/net/bnxt/tf_core/tf_device.h
drivers/net/bnxt/tf_core/tf_device_p4.c
drivers/net/bnxt/tf_core/tf_device_p4.h
drivers/net/bnxt/tf_core/tf_device_p58.c [new file with mode: 0644]
drivers/net/bnxt/tf_core/tf_device_p58.h [new file with mode: 0644]
drivers/net/bnxt/tf_core/tf_em_common.c
drivers/net/bnxt/tf_core/tf_msg.c
drivers/net/bnxt/tf_core/tf_rm.c
drivers/net/bnxt/tf_core/tf_shadow_tcam.c

index f55a98a..b63b87b 100644 (file)
 #define CFA_RESOURCE_TYPE_P4_TBL_SCOPE           0x22UL
 #define CFA_RESOURCE_TYPE_P4_LAST               CFA_RESOURCE_TYPE_P4_TBL_SCOPE
 
-
 #endif /* _CFA_RESOURCE_TYPES_H_ */
index b23e0fb..d7e8f66 100644 (file)
@@ -20,6 +20,7 @@ sources += files(
         'tf_session.c',
         'tf_device.c',
         'tf_device_p4.c',
+        'tf_device_p58.c',
         'tf_identifier.c',
         'tf_shadow_tbl.c',
         'tf_shadow_tcam.c',
index feec3cf..b1ce4e7 100644 (file)
@@ -35,6 +35,7 @@ tf_open_session(struct tf *tfp,
         * firmware open session succeeds.
         */
        if (parms->device_type != TF_DEVICE_TYPE_WH &&
+           parms->device_type != TF_DEVICE_TYPE_THOR &&
            parms->device_type != TF_DEVICE_TYPE_SR) {
                TFP_DRV_LOG(ERR,
                            "Unsupported device type %d\n",
index f68eb72..9c63f6d 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "tf_device.h"
 #include "tf_device_p4.h"
+#include "tf_device_p58.h"
 #include "tfp.h"
 #include "tf_em.h"
 
@@ -12,6 +13,7 @@ struct tf;
 
 /* Forward declarations */
 static int tf_dev_unbind_p4(struct tf *tfp);
+static int tf_dev_unbind_p58(struct tf *tfp);
 
 /**
  * Device specific bind function, WH+
@@ -234,6 +236,203 @@ tf_dev_unbind_p4(struct tf *tfp)
        return rc;
 }
 
+/**
+ * Device specific bind function, THOR
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] shadow_copy
+ *   Flag controlling shadow copy DB creation
+ *
+ * [in] resources
+ *   Pointer to resource allocation information
+ *
+ * [out] dev_handle
+ *   Device handle
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on parameter or internal failure.
+ */
+static int
+tf_dev_bind_p58(struct tf *tfp,
+               bool shadow_copy,
+               struct tf_session_resources *resources,
+               struct tf_dev_info *dev_handle)
+{
+       int rc;
+       int frc;
+       struct tf_ident_cfg_parms ident_cfg;
+       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;
+
+       /* Initial function initialization */
+       dev_handle->ops = &tf_dev_ops_p58_init;
+
+       /* Initialize the modules */
+
+       ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
+       ident_cfg.cfg = tf_ident_p58;
+       ident_cfg.shadow_copy = shadow_copy;
+       ident_cfg.resources = resources;
+       rc = tf_ident_bind(tfp, &ident_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Identifier initialization failure\n");
+               goto fail;
+       }
+
+       tbl_cfg.num_elements = TF_TBL_TYPE_MAX;
+       tbl_cfg.cfg = tf_tbl_p58;
+       tbl_cfg.shadow_copy = shadow_copy;
+       tbl_cfg.resources = resources;
+       rc = tf_tbl_bind(tfp, &tbl_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Table initialization failure\n");
+               goto fail;
+       }
+
+       tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX;
+       tcam_cfg.cfg = tf_tcam_p58;
+       tcam_cfg.shadow_copy = shadow_copy;
+       tcam_cfg.resources = resources;
+       rc = tf_tcam_bind(tfp, &tcam_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "TCAM initialization failure\n");
+               goto fail;
+       }
+
+       /*
+        * EM
+        */
+       em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
+       em_cfg.cfg = tf_em_int_p58;
+       em_cfg.resources = resources;
+       em_cfg.mem_type = 0; /* Not used by EM */
+
+       rc = tf_em_int_bind(tfp, &em_cfg);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "EM initialization failure\n");
+               goto fail;
+       }
+
+       /*
+        * IF_TBL
+        */
+       if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+       if_tbl_cfg.cfg = tf_if_tbl_p58;
+       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_p58;
+       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_p58;
+
+       return 0;
+
+ fail:
+       /* Cleanup of already created modules */
+       frc = tf_dev_unbind_p58(tfp);
+       if (frc)
+               return frc;
+
+       return rc;
+}
+
+/**
+ * Device specific unbind function, THOR
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+       tf_dev_unbind_p58(struct tf *tfp)
+{
+       int rc = 0;
+       bool fail = false;
+
+       /* Unbind all the support modules. As this is only done on
+        * close we only report errors as everything has to be cleaned
+        * up regardless.
+        *
+        * In case of residuals TCAMs are cleaned up first as to
+        * invalidate the pipeline in a clean manner.
+        */
+       rc = tf_tcam_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, TCAM\n");
+               fail = true;
+       }
+
+       rc = tf_ident_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, Identifier\n");
+               fail = true;
+       }
+
+       rc = tf_tbl_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, Table Type\n");
+               fail = true;
+       }
+
+       rc = tf_em_int_unbind(tfp);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Device unbind failed, EM\n");
+               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;
+
+       return rc;
+}
+
 int
 tf_dev_bind(struct tf *tfp __rte_unused,
            enum tf_device_type type,
@@ -249,6 +448,12 @@ tf_dev_bind(struct tf *tfp __rte_unused,
                                      shadow_copy,
                                      resources,
                                      dev_handle);
+       case TF_DEVICE_TYPE_THOR:
+               dev_handle->type = type;
+               return tf_dev_bind_p58(tfp,
+                                      shadow_copy,
+                                      resources,
+                                      dev_handle);
        default:
                TFP_DRV_LOG(ERR,
                            "No such device\n");
@@ -264,6 +469,8 @@ tf_dev_unbind(struct tf *tfp,
        case TF_DEVICE_TYPE_WH:
        case TF_DEVICE_TYPE_SR:
                return tf_dev_unbind_p4(tfp);
+       case TF_DEVICE_TYPE_THOR:
+               return tf_dev_unbind_p58(tfp);
        default:
                TFP_DRV_LOG(ERR,
                            "No such device\n");
index d0c4ec8..d5ef723 100644 (file)
@@ -134,6 +134,28 @@ struct tf_dev_ops {
        int (*tf_dev_get_max_types)(struct tf *tfp,
                                    uint16_t *max_types);
 
+       /**
+        * Retrieves the string description for the CFA resource
+        * type
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] resource_id
+        *   HCAPI cfa resource type id
+        *
+        * [out] resource_str
+        *   Pointer to a string
+        *
+        * Returns
+        *   - (0) if successful.
+        *   - (-EINVAL) on failure.
+        */
+       int (*tf_dev_get_resource_str)(struct tf *tfp,
+                                      uint16_t resource_id,
+                                      const char **resource_str);
+
+
        /**
         * Retrieves the WC TCAM slice information that the device
         * supports.
@@ -709,5 +731,7 @@ struct tf_dev_ops {
  */
 extern const struct tf_dev_ops tf_dev_ops_p4_init;
 extern const struct tf_dev_ops tf_dev_ops_p4;
+extern const struct tf_dev_ops tf_dev_ops_p58_init;
+extern const struct tf_dev_ops tf_dev_ops_p58;
 
 #endif /* _TF_DEVICE_H_ */
index 17d2f05..257a0fb 100644 (file)
@@ -4,8 +4,8 @@
  */
 
 #include <rte_common.h>
-#include <cfa_resource_types.h>
 
+#include "cfa_resource_types.h"
 #include "tf_device.h"
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #define TF_DEV_P4_PARIF_MAX 16
 #define TF_DEV_P4_PF_MASK 0xfUL
 
+const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
+       /* CFA_RESOURCE_TYPE_P4_MCG */
+       "mc_group",
+       /* CFA_RESOURCE_TYPE_P4_ENCAP_8B */
+       "encap_8 ",
+       /* CFA_RESOURCE_TYPE_P4_ENCAP_16B */
+       "encap_16",
+       /* CFA_RESOURCE_TYPE_P4_ENCAP_64B */
+       "encap_64",
+       /* CFA_RESOURCE_TYPE_P4_SP_MAC */
+       "sp_mac  ",
+       /* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 */
+       "sp_macv4",
+       /* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */
+       "sp_macv6",
+       /* CFA_RESOURCE_TYPE_P4_COUNTER_64B */
+       "ctr_64b ",
+       /* CFA_RESOURCE_TYPE_P4_NAT_PORT */
+       "nat_port",
+       /* CFA_RESOURCE_TYPE_P4_NAT_IPV4 */
+       "nat_ipv4",
+       /* CFA_RESOURCE_TYPE_P4_METER */
+       "meter   ",
+       /* CFA_RESOURCE_TYPE_P4_FLOW_STATE */
+       "flow_st ",
+       /* CFA_RESOURCE_TYPE_P4_FULL_ACTION */
+       "full_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION */
+       "fmt0_act",
+       /* CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION */
+       "ext0_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION */
+       "fmt1_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION */
+       "fmt2_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION */
+       "fmt3_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION */
+       "fmt4_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION */
+       "fmt5_act",
+       /* CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION */
+       "fmt6_act",
+       /* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH */
+       "l2ctx_hi",
+       /* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW */
+       "l2ctx_lo",
+       /* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH */
+       "l2ctr_hi",
+       /* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW */
+       "l2ctr_lo",
+       /* CFA_RESOURCE_TYPE_P4_PROF_FUNC */
+       "prf_func",
+       /* CFA_RESOURCE_TYPE_P4_PROF_TCAM */
+       "prf_tcam",
+       /* CFA_RESOURCE_TYPE_P4_EM_PROF_ID */
+       "em_prof ",
+       /* CFA_RESOURCE_TYPE_P4_EM_REC */
+       "em_rec  ",
+       /* CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID */
+       "wc_prof ",
+       /* CFA_RESOURCE_TYPE_P4_WC_TCAM */
+       "wc_tcam ",
+       /* CFA_RESOURCE_TYPE_P4_METER_PROF */
+       "mtr_prof",
+       /* CFA_RESOURCE_TYPE_P4_MIRROR */
+       "mirror  ",
+       /* CFA_RESOURCE_TYPE_P4_SP_TCAM */
+       "sp_tcam ",
+       /* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
+       "tb_scope",
+};
+
 /**
  * Device specific function that retrieves the MAX number of HCAPI
  * types the device supports.
@@ -25,7 +98,7 @@
  *   Pointer to TF handle
  *
  * [out] max_types
- *   Pointer to the MAX number of HCAPI types supported
+ *   Pointer to the MAX number of CFA resource types supported
  *
  * Returns
  *   - (0) if successful.
@@ -61,6 +134,38 @@ tf_dev_p4_get_max_types(struct tf *tfp,
 
        return 0;
 }
+/**
+ * Device specific function that retrieves a human readable
+ * string to identify a CFA resource type.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] resource_id
+ *   HCAPI CFA resource id
+ *
+ * [out] resource_str
+ *   Resource string
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p4_get_resource_str(struct tf *tfp __rte_unused,
+                          uint16_t resource_id,
+                          const char **resource_str)
+{
+       if (resource_str == NULL)
+               return -EINVAL;
+
+       if (resource_id > CFA_RESOURCE_TYPE_P4_LAST)
+               return -EINVAL;
+
+       *resource_str = tf_resource_str_p4[resource_id];
+
+       return 0;
+}
 
 /**
  * Device specific function that retrieves the WC TCAM slices the
@@ -142,6 +247,7 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
  */
 const struct tf_dev_ops tf_dev_ops_p4_init = {
        .tf_dev_get_max_types = tf_dev_p4_get_max_types,
+       .tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
        .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
        .tf_dev_alloc_ident = NULL,
        .tf_dev_free_ident = NULL,
@@ -179,6 +285,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
  */
 const struct tf_dev_ops tf_dev_ops_p4 = {
        .tf_dev_get_max_types = tf_dev_p4_get_max_types,
+       .tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
        .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
        .tf_dev_alloc_ident = tf_ident_alloc,
        .tf_dev_free_ident = tf_ident_free,
index 81ed232..bfad02a 100644 (file)
@@ -6,8 +6,7 @@
 #ifndef _TF_DEVICE_P4_H_
 #define _TF_DEVICE_P4_H_
 
-#include <cfa_resource_types.h>
-
+#include "cfa_resource_types.h"
 #include "tf_core.h"
 #include "tf_rm.h"
 #include "tf_if_tbl.h"
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
new file mode 100644 (file)
index 0000000..fb5ad29
--- /dev/null
@@ -0,0 +1,284 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#include <rte_common.h>
+
+#include "cfa_resource_types.h"
+#include "tf_device.h"
+#include "tf_identifier.h"
+#include "tf_tbl.h"
+#include "tf_tcam.h"
+#include "tf_em.h"
+#include "tf_if_tbl.h"
+#include "tfp.h"
+
+#define TF_DEV_P58_PARIF_MAX 16
+#define TF_DEV_P58_PF_MASK 0xfUL
+
+const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
+       /* CFA_RESOURCE_TYPE_P58_METER */
+       "meter   ",
+       /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_0 */
+       "sram_bk0",
+       /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_1 */
+       "sram_bk1",
+       /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_2 */
+       "sram_bk2",
+       /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_3 */
+       "sram_bk3",
+       /* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH */
+       "l2ctx_hi",
+       /* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW */
+       "l2ctx_lo",
+       /* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH */
+       "l2ctr_hi",
+       /* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW */
+       "l2ctr_lo",
+       /* CFA_RESOURCE_TYPE_P58_PROF_FUNC */
+       "prf_func",
+       /* CFA_RESOURCE_TYPE_P58_PROF_TCAM */
+       "prf_tcam",
+       /* CFA_RESOURCE_TYPE_P58_EM_PROF_ID */
+       "em_prof ",
+       /* CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID */
+       "wc_prof ",
+       /* CFA_RESOURCE_TYPE_P58_EM_REC */
+       "em_rec  ",
+       /* CFA_RESOURCE_TYPE_P58_WC_TCAM */
+       "wc_tcam ",
+       /* CFA_RESOURCE_TYPE_P58_METER_PROF */
+       "mtr_prof",
+       /* CFA_RESOURCE_TYPE_P58_MIRROR */
+       "mirror  ",
+       /* CFA_RESOURCE_TYPE_P58_EM_FKB */
+       "em_fkb  ",
+       /* CFA_RESOURCE_TYPE_P58_WC_FKB */
+       "wc_fkb  ",
+       /* CFA_RESOURCE_TYPE_P58_VEB_TCAM */
+       "veb     ",
+};
+
+/**
+ * Device specific function that retrieves the MAX number of HCAPI
+ * types the device supports.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] max_types
+ *   Pointer to the MAX number of HCAPI types supported
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_max_types(struct tf *tfp,
+                       uint16_t *max_types)
+{
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       int rc;
+
+       if (max_types == NULL || tfp == NULL)
+               return -EINVAL;
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc)
+               return rc;
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc)
+               return rc;
+
+       *max_types = CFA_RESOURCE_TYPE_P58_LAST + 1;
+
+       return 0;
+}
+/**
+ * Device specific function that retrieves a human readable
+ * string to identify a CFA resource type.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] resource_id
+ *   HCAPI CFA resource id
+ *
+ * [out] resource_str
+ *   Resource string
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_resource_str(struct tf *tfp __rte_unused,
+                           uint16_t resource_id,
+                           const char **resource_str)
+{
+       if (resource_str == NULL)
+               return -EINVAL;
+
+       if (resource_id > CFA_RESOURCE_TYPE_P58_LAST)
+               return -EINVAL;
+
+       *resource_str = tf_resource_str_p58[resource_id];
+
+       return 0;
+}
+
+/**
+ * Device specific function that retrieves the WC TCAM slices the
+ * device supports.
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [out] slice_size
+ *   Pointer to the WC TCAM slice size
+ *
+ * [out] num_slices_per_row
+ *   Pointer to the WC TCAM row slice configuration
+ *
+ * Returns
+ *   - (0) if successful.
+ *   - (-EINVAL) on failure.
+ */
+static int
+tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,
+                             enum tf_tcam_tbl_type type,
+                             uint16_t key_sz,
+                             uint16_t *num_slices_per_row)
+{
+#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2
+#define CFA_P58_WC_TCAM_SLICE_SIZE     12
+
+       if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+               *num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW;
+               if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)
+                       return -ENOTSUP;
+
+               *num_slices_per_row = 1;
+       } else { /* for other type of tcam */
+               *num_slices_per_row = 1;
+       }
+
+       return 0;
+}
+
+static int
+tf_dev_p58_map_parif(struct tf *tfp __rte_unused,
+                   uint16_t parif_bitmask,
+                   uint16_t pf,
+                   uint8_t *data,
+                   uint8_t *mask,
+                   uint16_t sz_in_bytes)
+{
+       uint32_t parif_pf[2] = { 0 };
+       uint32_t parif_pf_mask[2] = { 0 };
+       uint32_t parif;
+       uint32_t shift;
+
+       if (sz_in_bytes != sizeof(uint64_t))
+               return -ENOTSUP;
+
+       for (parif = 0; parif < TF_DEV_P58_PARIF_MAX; parif++) {
+               if (parif_bitmask & (1UL << parif)) {
+                       if (parif < 8) {
+                               shift = 4 * parif;
+                               parif_pf_mask[0] |= TF_DEV_P58_PF_MASK << shift;
+                               parif_pf[0] |= pf << shift;
+                       } else {
+                               shift = 4 * (parif - 8);
+                               parif_pf_mask[1] |= TF_DEV_P58_PF_MASK << shift;
+                               parif_pf[1] |= pf << shift;
+                       }
+               }
+       }
+       tfp_memcpy(data, parif_pf, sz_in_bytes);
+       tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
+
+       return 0;
+}
+
+
+/**
+ * Truflow P58 device specific functions
+ */
+const struct tf_dev_ops tf_dev_ops_p58_init = {
+       .tf_dev_get_max_types = tf_dev_p58_get_max_types,
+       .tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
+       .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
+       .tf_dev_alloc_ident = NULL,
+       .tf_dev_free_ident = NULL,
+       .tf_dev_search_ident = NULL,
+       .tf_dev_alloc_ext_tbl = NULL,
+       .tf_dev_alloc_tbl = NULL,
+       .tf_dev_free_ext_tbl = NULL,
+       .tf_dev_free_tbl = NULL,
+       .tf_dev_alloc_search_tbl = NULL,
+       .tf_dev_set_tbl = NULL,
+       .tf_dev_set_ext_tbl = NULL,
+       .tf_dev_get_tbl = NULL,
+       .tf_dev_get_bulk_tbl = NULL,
+       .tf_dev_alloc_tcam = NULL,
+       .tf_dev_free_tcam = NULL,
+       .tf_dev_alloc_search_tcam = NULL,
+       .tf_dev_set_tcam = NULL,
+       .tf_dev_get_tcam = NULL,
+       .tf_dev_insert_int_em_entry = NULL,
+       .tf_dev_delete_int_em_entry = NULL,
+       .tf_dev_insert_ext_em_entry = NULL,
+       .tf_dev_delete_ext_em_entry = NULL,
+       .tf_dev_alloc_tbl_scope = NULL,
+       .tf_dev_map_tbl_scope = NULL,
+       .tf_dev_map_parif = NULL,
+       .tf_dev_free_tbl_scope = NULL,
+       .tf_dev_set_if_tbl = NULL,
+       .tf_dev_get_if_tbl = NULL,
+       .tf_dev_set_global_cfg = NULL,
+       .tf_dev_get_global_cfg = NULL,
+};
+
+/**
+ * Truflow P58 device specific functions
+ */
+const struct tf_dev_ops tf_dev_ops_p58 = {
+       .tf_dev_get_max_types = tf_dev_p58_get_max_types,
+       .tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
+       .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
+       .tf_dev_alloc_ident = tf_ident_alloc,
+       .tf_dev_free_ident = tf_ident_free,
+       .tf_dev_search_ident = tf_ident_search,
+       .tf_dev_alloc_tbl = tf_tbl_alloc,
+       .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
+       .tf_dev_free_tbl = tf_tbl_free,
+       .tf_dev_free_ext_tbl = tf_tbl_ext_free,
+       .tf_dev_alloc_search_tbl = tf_tbl_alloc_search,
+       .tf_dev_set_tbl = tf_tbl_set,
+       .tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
+       .tf_dev_get_tbl = tf_tbl_get,
+       .tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+       .tf_dev_alloc_tcam = tf_tcam_alloc,
+       .tf_dev_free_tcam = tf_tcam_free,
+       .tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
+       .tf_dev_set_tcam = tf_tcam_set,
+       .tf_dev_get_tcam = NULL,
+       .tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
+       .tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
+       .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
+       .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
+       .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
+       .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
+       .tf_dev_map_parif = tf_dev_p58_map_parif,
+       .tf_dev_free_tbl_scope = tf_em_ext_common_free,
+       .tf_dev_set_if_tbl = tf_if_tbl_set,
+       .tf_dev_get_if_tbl = tf_if_tbl_get,
+       .tf_dev_set_global_cfg = tf_global_cfg_set,
+       .tf_dev_get_global_cfg = tf_global_cfg_get,
+};
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h
new file mode 100644 (file)
index 0000000..3d6e324
--- /dev/null
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2021 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _TF_DEVICE_P58_H_
+#define _TF_DEVICE_P58_H_
+
+#include "cfa_resource_types.h"
+#include "tf_core.h"
+#include "tf_rm.h"
+#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
+
+struct tf_rm_element_cfg tf_ident_p58[TF_IDENT_TYPE_MAX] = {
+       [TF_IDENT_TYPE_L2_CTXT_HIGH] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH
+       },
+       [TF_IDENT_TYPE_L2_CTXT_LOW] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW
+       },
+       [TF_IDENT_TYPE_PROF_FUNC] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_FUNC
+       },
+       [TF_IDENT_TYPE_WC_PROF] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID
+       },
+       [TF_IDENT_TYPE_EM_PROF] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_PROF_ID
+       },
+};
+
+struct tf_rm_element_cfg tf_tcam_p58[TF_TCAM_TBL_TYPE_MAX] = {
+       [TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH
+       },
+       [TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW
+       },
+       [TF_TCAM_TBL_TYPE_PROF_TCAM] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_TCAM
+       },
+       [TF_TCAM_TBL_TYPE_WC_TCAM] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM
+       },
+       [TF_TCAM_TBL_TYPE_VEB_TCAM] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_VEB_TCAM
+       },
+};
+
+struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
+       [TF_TBL_TYPE_METER_PROF] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF
+       },
+       [TF_TBL_TYPE_METER_INST] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER
+       },
+       [TF_TBL_TYPE_MIRROR_CONFIG] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR
+       },
+};
+
+struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = {
+       [TF_EM_TBL_TYPE_EM_RECORD] = {
+               TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P58_EM_REC
+       },
+};
+
+struct tf_if_tbl_cfg tf_if_tbl_p58[TF_IF_TBL_TYPE_MAX];
+
+struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
+       [TF_TUNNEL_ENCAP] = {
+               TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP
+       },
+       [TF_ACTION_BLOCK] = {
+               TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK
+       },
+};
+#endif /* _TF_DEVICE_P58_H_ */
index c4137af..ddc6b3c 100644 (file)
@@ -1115,8 +1115,8 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp,
                goto cleaner;
        }
 
-       gcfg_parms.type =
-               (enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF;
+       /* Note that TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF is same as below enum */
+       gcfg_parms.type = TF_GLOBAL_CFG_TYPE_MAX;
        gcfg_parms.offset = 0;
        gcfg_parms.config = (uint8_t *)data;
        gcfg_parms.config_mask = (uint8_t *)mask;
index 46fc628..f20a511 100644 (file)
@@ -19,9 +19,6 @@
 #include "hwrm_tf.h"
 #include "tf_em.h"
 
-/* Logging defines */
-#define TF_RM_MSG_DEBUG  0
-
 /* Specific msg size defines as we cannot use defines in tf.yaml. This
  * means we have to manually sync hwrm with these defines if the
  * tf.yaml changes.
@@ -361,29 +358,13 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
                goto cleanup;
        }
 
-#if (TF_RM_MSG_DEBUG == 1)
-       printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
        /* Post process the response */
        data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
 
-#if (TF_RM_MSG_DEBUG == 1)
-       printf("\nQCAPS\n");
-#endif /* (TF_RM_MSG_DEBUG == 1) */
        for (i = 0; i < size; i++) {
                query[i].type = tfp_le_to_cpu_32(data[i].type);
                query[i].min = tfp_le_to_cpu_16(data[i].min);
                query[i].max = tfp_le_to_cpu_16(data[i].max);
-
-#if (TF_RM_MSG_DEBUG == 1)
-               printf("type: %d(0x%x) %d %d\n",
-                      query[i].type,
-                      query[i].type,
-                      query[i].min,
-                      query[i].max);
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
        }
 
        *resv_strategy = resp.flags &
@@ -476,26 +457,12 @@ tf_msg_session_resc_alloc(struct tf *tfp,
                goto cleanup;
        }
 
-#if (TF_RM_MSG_DEBUG == 1)
-       printf("\nRESV\n");
-       printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
-#endif /* (TF_RM_MSG_DEBUG == 1) */
-
        /* Post process the response */
        resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
        for (i = 0; i < size; i++) {
                resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
                resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
                resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
-
-#if (TF_RM_MSG_DEBUG == 1)
-               printf("%d type: %d(0x%x) %d %d\n",
-                      i,
-                      resv[i].type,
-                      resv[i].type,
-                      resv[i].start,
-                      resv[i].stride);
-#endif /* (TF_RM_MSG_DEBUG == 1) */
        }
 
 cleanup:
index 887a3dc..f93a6d9 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 
 #include <rte_common.h>
+#include <rte_debug.h>
 
 #include <cfa_resource_types.h>
 
@@ -596,13 +597,6 @@ tf_rm_create_db(struct tf *tfp,
        rm_db->type = parms->type;
        *parms->rm_db = (void *)rm_db;
 
-#if (TF_RM_DEBUG == 1)
-       printf("%s: type:%d num_entries:%d\n",
-              tf_dir_2_str(parms->dir),
-              parms->type,
-              i);
-#endif /* (TF_RM_DEBUG == 1) */
-
        tfp_free((void *)req);
        tfp_free((void *)resv);
 
index 38b1e76..523261f 100644 (file)
@@ -6,6 +6,7 @@
 #include "tf_common.h"
 #include "tf_util.h"
 #include "tfp.h"
+#include "tf_tcam.h"
 #include "tf_shadow_tcam.h"
 #include "tf_hash.h"
 
@@ -634,8 +635,7 @@ tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms)
                         * requested allocation and return the info
                         */
                        if (sparms->alloc)
-                               ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt =
-                       ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt + 1;
+                               ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt++;
 
                        sparms->hit = 1;
                        sparms->search_status = HIT;