net/bnxt: support Thor WC TCAM
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.h
index db10935..fcba492 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.
  */
 
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include "hcapi/hcapi_cfa.h"
+#include "hcapi/cfa/hcapi_cfa_defs.h"
 #include "tf_project.h"
 
 /**
@@ -153,39 +153,69 @@ enum tf_device_type {
        TF_DEVICE_TYPE_MAX     /**< Maximum   */
 };
 
+/**
+ * Module types
+ */
+enum tf_module_type {
+       /**
+        * Identifier module
+        */
+       TF_MODULE_TYPE_IDENTIFIER,
+       /**
+        * Table type module
+        */
+       TF_MODULE_TYPE_TABLE,
+       /**
+        * TCAM module
+        */
+       TF_MODULE_TYPE_TCAM,
+       /**
+        * EM module
+        */
+       TF_MODULE_TYPE_EM,
+       TF_MODULE_TYPE_MAX
+};
+
+
 /**
  * Identifier resource types
  */
 enum tf_identifier_type {
        /**
+        *  WH/SR/TH/SR2
         *  The L2 Context is returned from the L2 Ctxt TCAM lookup
         *  and can be used in WC TCAM or EM keys to virtualize further
         *  lookups.
         */
        TF_IDENT_TYPE_L2_CTXT_HIGH,
        /**
+        *  WH/SR/TH/SR2
         *  The L2 Context is returned from the L2 Ctxt TCAM lookup
         *  and can be used in WC TCAM or EM keys to virtualize further
         *  lookups.
         */
        TF_IDENT_TYPE_L2_CTXT_LOW,
        /**
+        *  WH/SR/TH/SR2
         *  The WC profile func is returned from the L2 Ctxt TCAM lookup
         *  to enable virtualization of the profile TCAM.
         */
        TF_IDENT_TYPE_PROF_FUNC,
        /**
+        *  WH/SR/TH/SR2
         *  The WC profile ID is included in the WC lookup key
         *  to enable virtualization of the WC TCAM hardware.
         */
        TF_IDENT_TYPE_WC_PROF,
        /**
+        *  WH/SR/TH/SR2
         *  The EM profile ID is included in the EM lookup key
         *  to enable virtualization of the EM hardware. (not required for SR2
         *  as it has table scope)
         */
        TF_IDENT_TYPE_EM_PROF,
        /**
+        *  TH/SR2
         *  The L2 func is included in the ILT result and from recycling to
         *  enable virtualization of further lookups.
         */
@@ -203,59 +233,63 @@ enum tf_identifier_type {
 enum tf_tbl_type {
        /* Internal */
 
-       /** Wh+/SR Action Record */
+       /** Wh+/SR/TH Action Record */
        TF_TBL_TYPE_FULL_ACT_RECORD,
-       /** Wh+/SR/Th Multicast Groups */
+       /** TH Compact Action Record */
+       TF_TBL_TYPE_COMPACT_ACT_RECORD,
+       /** (Future) Multicast Groups */
        TF_TBL_TYPE_MCAST_GROUPS,
-       /** Wh+/SR Action Encap 8 Bytes */
+       /** Wh+/SR/TH Action Encap 8 Bytes */
        TF_TBL_TYPE_ACT_ENCAP_8B,
-       /** Wh+/SR Action Encap 16 Bytes */
+       /** Wh+/SR/TH Action Encap 16 Bytes */
        TF_TBL_TYPE_ACT_ENCAP_16B,
-       /** Action Encap 32 Bytes */
+       /** WH+/SR/TH Action Encap 32 Bytes */
        TF_TBL_TYPE_ACT_ENCAP_32B,
-       /** Wh+/SR Action Encap 64 Bytes */
+       /** Wh+/SR/TH Action Encap 64 Bytes */
        TF_TBL_TYPE_ACT_ENCAP_64B,
-       /** Action Source Properties SMAC */
+       /** WH+/SR/TH Action Source Properties SMAC */
        TF_TBL_TYPE_ACT_SP_SMAC,
-       /** Wh+/SR Action Source Properties SMAC IPv4 */
+       /** Wh+/SR/TH Action Source Properties SMAC IPv4 */
        TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
-       /** Action Source Properties SMAC IPv6 */
+       /** WH+/SR/TH Action Source Properties SMAC IPv6 */
        TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
-       /** Wh+/SR Action Statistics 64 Bits */
+       /** Wh+/SR/TH Action Statistics 64 Bits */
        TF_TBL_TYPE_ACT_STATS_64,
-       /** Wh+/SR Action Modify L4 Src Port */
-       TF_TBL_TYPE_ACT_MODIFY_SPORT,
-       /** Wh+/SR Action Modify L4 Dest Port */
-       TF_TBL_TYPE_ACT_MODIFY_DPORT,
        /** Wh+/SR Action Modify IPv4 Source */
        TF_TBL_TYPE_ACT_MODIFY_IPV4,
-       /** Meter Profiles */
+       /** TH 8B Modify Record */
+       TF_TBL_TYPE_ACT_MODIFY_8B,
+       /** TH 16B Modify Record */
+       TF_TBL_TYPE_ACT_MODIFY_16B,
+       /** TH 32B Modify Record */
+       TF_TBL_TYPE_ACT_MODIFY_32B,
+       /** TH 64B Modify Record */
+       TF_TBL_TYPE_ACT_MODIFY_64B,
+       /** (Future) Meter Profiles */
        TF_TBL_TYPE_METER_PROF,
-       /** Meter Instance */
+       /** (Future) Meter Instance */
        TF_TBL_TYPE_METER_INST,
-       /** Mirror Config */
+       /** Wh+/SR/Th Mirror Config */
        TF_TBL_TYPE_MIRROR_CONFIG,
-       /** UPAR */
+       /** (Future) UPAR */
        TF_TBL_TYPE_UPAR,
-       /** SR2 Epoch 0 table */
+       /** (Future) SR2 Epoch 0 table */
        TF_TBL_TYPE_EPOCH0,
-       /** SR2 Epoch 1 table  */
+       /** (Future) SR2 Epoch 1 table  */
        TF_TBL_TYPE_EPOCH1,
-       /** SR2 Metadata  */
+       /** (Future) TH/SR2 Metadata  */
        TF_TBL_TYPE_METADATA,
-       /** SR2 CT State  */
+       /** (Future) TH/SR2 CT State  */
        TF_TBL_TYPE_CT_STATE,
-       /** SR2 Range Profile  */
+       /** (Future) TH/SR2 Range Profile  */
        TF_TBL_TYPE_RANGE_PROF,
-       /** SR2 Range Entry  */
+       /** (Future) SR2 Range Entry  */
        TF_TBL_TYPE_RANGE_ENTRY,
-       /** SR2 LAG Entry  */
+       /** (Future) SR2 LAG Entry  */
        TF_TBL_TYPE_LAG,
-       /** SR2 VNIC/SVIF Table */
-       TF_TBL_TYPE_VNIC_SVIF,
-       /** Th/SR2 EM Flexible Key builder */
+       /** TH/SR2 EM Flexible Key builder */
        TF_TBL_TYPE_EM_FKB,
-       /** Th/SR2 WC Flexible Key builder */
+       /** TH/SR2 WC Flexible Key builder */
        TF_TBL_TYPE_WC_FKB,
 
        /* External */
@@ -263,9 +297,18 @@ enum tf_tbl_type {
        /**
         * External table type - initially 1 poolsize entries.
         * All External table types are associated with a table
-        * scope. Internal types are not.
+        * scope. Internal types are not.  Currently this is
+        * a pool of 64B entries.
         */
        TF_TBL_TYPE_EXT,
+       /* (Future) SR2 32B External EM Action 32B Pool */
+       TF_TBL_TYPE_EXT_32B,
+       /* (Future) SR2 64B External EM Action 64B Pool */
+       TF_TBL_TYPE_EXT_64B,
+       /* (Future) SR2 96B External EM Action 96B Pool */
+       TF_TBL_TYPE_EXT_96B,
+       /* (Future) SR2 128B External EM Action 128B Pool */
+       TF_TBL_TYPE_EXT_128B,
        TF_TBL_TYPE_MAX
 };
 
@@ -898,7 +941,9 @@ struct tf_alloc_tbl_scope_parms {
         */
        uint32_t tbl_scope_id;
 };
-
+/**
+ * tf_free_tbl_scope_parms definition
+ */
 struct tf_free_tbl_scope_parms {
        /**
         * [in] table scope identifier
@@ -906,6 +951,21 @@ struct tf_free_tbl_scope_parms {
        uint32_t tbl_scope_id;
 };
 
+/**
+ * tf_map_tbl_scope_parms definition
+ */
+struct tf_map_tbl_scope_parms {
+       /**
+        * [in] table scope identifier
+        */
+       uint32_t tbl_scope_id;
+       /**
+        * [in] Which parifs are associated with this table scope.  Bit 0
+        *      indicates parif 0.
+        */
+       uint16_t parif_bitmask;
+};
+
 /**
  * allocate a table scope
  *
@@ -915,13 +975,13 @@ struct tf_free_tbl_scope_parms {
  * device constraints based upon calculations using either the number of flows
  * requested or the size of memory indicated.  Other parameters passed in
  * determine the configuration (maximum key size, maximum external action record
- * size.
+ * size).
  *
- * This API will allocate the table region in
- * DRAM, program the PTU page table entries, and program the number of static
- * buckets (if SR2) in the RX and TX CFAs.  Buckets are assumed to start at
- * 0 in the EM memory for the scope.  Upon successful completion of this API,
- * hash tables are fully initialized and ready for entries to be inserted.
+ * This API will allocate the table region in DRAM, program the PTU page table
+ * entries, and program the number of static buckets (if SR2) in the RX and TX
+ * CFAs.  Buckets are assumed to start at 0 in the EM memory for the scope.
+ * Upon successful completion of this API, hash tables are fully initialized and
+ * ready for entries to be inserted.
  *
  * A single API is used to allocate a common table scope identifier in both
  * receive and transmit CFA. The scope identifier is common due to nature of
@@ -944,7 +1004,25 @@ struct tf_free_tbl_scope_parms {
 int tf_alloc_tbl_scope(struct tf *tfp,
                       struct tf_alloc_tbl_scope_parms *parms);
 
+/**
+ * map a table scope (legacy device only Wh+/SR)
+ *
+ * Map a table scope to one or more partition interfaces (parifs).
+ * The parif can be remapped in the L2 context lookup for legacy devices.  This
+ * API allows a number of parifs to be mapped to the same table scope.  On
+ * legacy devices a table scope identifies one of 16 sets of EEM table base
+ * addresses and is associated with a PF communication channel.  The associated
+ * PF must be configured for the table scope to operate.
+ *
+ * An L2 context TCAM lookup returns a remapped parif value used to
+ * index into the set of 16 parif_to_pf registers which are used to map to one
+ * of the 16 table scopes.  This API allows the user to map the parifs in the
+ * mask to the previously allocated table scope (EEM table).
 
+ * Returns success or failure code.
+ */
+int tf_map_tbl_scope(struct tf *tfp,
+                     struct tf_map_tbl_scope_parms *parms);
 /**
  * free a table scope
  *
@@ -1208,7 +1286,7 @@ struct tf_get_tcam_entry_parms {
         */
        uint8_t *mask;
        /**
-        * [out] key size in bits
+        * [in/out] key size in bits
         */
        uint16_t key_sz_in_bits;
        /**
@@ -1216,7 +1294,7 @@ struct tf_get_tcam_entry_parms {
         */
        uint8_t *result;
        /**
-        * [out] struct containing result size in bits
+        * [in/out] struct containing result size in bits
         */
        uint16_t result_sz_in_bits;
 };
@@ -1883,6 +1961,7 @@ enum tf_tunnel_encap_offsets {
 enum tf_global_config_type {
        TF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */
        TF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */
+       TF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */
        TF_GLOBAL_CFG_TYPE_MAX
 };
 
@@ -1908,6 +1987,12 @@ struct tf_global_cfg_parms {
         * get - Read the full configuration
         */
        uint8_t *config;
+       /**
+        * [in] Configuration mask
+        * set - Read, Modify with mask and Write
+        * get - unused
+        */
+       uint8_t *config_mask;
        /**
         * [in] struct containing size
         */
@@ -1957,8 +2042,8 @@ enum tf_if_tbl_type {
        TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
        /** SR2 Ingress lookup table */
        TF_IF_TBL_TYPE_ILT,
-       /** SR2 VNIC/SVIF Table */
-       TF_IF_TBL_TYPE_VNIC_SVIF,
+       /** SR2 VNIC/SVIF Properties Table */
+       TF_IF_TBL_TYPE_VSPT,
        TF_IF_TBL_TYPE_MAX
 };