net/bnxt: support two table scopes
authorJay Ding <jay.ding@broadcom.com>
Mon, 26 Oct 2020 03:56:03 +0000 (20:56 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:35:03 +0000 (23:35 +0100)
Adding support for two table scopes. One for Exact Match tables
and other for External Exact Match tables.
New API to map a PARIF to an EEM table scope (set of Rx and Tx EEM
base addresses). It uses HWRM_TF_GLOBAL_CFG_SET HWRM to configure.
PARIF is handler to a partition of the physical port.
Adjustments to tf_global_cfg_set() to reduce overhead and nominal
name clarification.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
12 files changed:
drivers/net/bnxt/tf_core/tf_core.c
drivers/net/bnxt/tf_core/tf_core.h
drivers/net/bnxt/tf_core/tf_device.h
drivers/net/bnxt/tf_core/tf_device_p4.c
drivers/net/bnxt/tf_core/tf_em.h
drivers/net/bnxt/tf_core/tf_em_common.c
drivers/net/bnxt/tf_core/tf_em_common.h
drivers/net/bnxt/tf_core/tf_em_host.c
drivers/net/bnxt/tf_core/tf_global_cfg.c
drivers/net/bnxt/tf_core/tf_global_cfg.h
drivers/net/bnxt/tf_core/tf_msg.c
drivers/net/bnxt/tf_core/tf_msg.h

index 788335b..0f49a00 100644 (file)
@@ -303,7 +303,6 @@ int tf_get_global_cfg(struct tf *tfp,
        int rc = 0;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_dev_global_cfg_parms gparms = { 0 };
 
        TF_CHECK_PARMS2(tfp, parms);
 
@@ -342,12 +341,7 @@ int tf_get_global_cfg(struct tf *tfp,
                return -EOPNOTSUPP;
        }
 
-       gparms.dir = parms->dir;
-       gparms.type = parms->type;
-       gparms.offset = parms->offset;
-       gparms.config = parms->config;
-       gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
-       rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
+       rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
        if (rc) {
                TFP_DRV_LOG(ERR,
                            "%s: Global Cfg get failed, rc:%s\n",
@@ -371,7 +365,6 @@ int tf_set_global_cfg(struct tf *tfp,
        int rc = 0;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_dev_global_cfg_parms gparms = { 0 };
 
        TF_CHECK_PARMS2(tfp, parms);
 
@@ -410,12 +403,7 @@ int tf_set_global_cfg(struct tf *tfp,
                return -EOPNOTSUPP;
        }
 
-       gparms.dir = parms->dir;
-       gparms.type = parms->type;
-       gparms.offset = parms->offset;
-       gparms.config = parms->config;
-       gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
-       rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
+       rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
        if (rc) {
                TFP_DRV_LOG(ERR,
                            "%s: Global Cfg set failed, rc:%s\n",
@@ -1352,6 +1340,44 @@ tf_alloc_tbl_scope(struct tf *tfp,
 
        return rc;
 }
+int
+tf_map_tbl_scope(struct tf *tfp,
+                  struct tf_map_tbl_scope_parms *parms)
+{
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       int rc;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Failed to lookup session, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Failed to lookup device, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_map_tbl_scope != NULL) {
+               rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
+       } else {
+               TFP_DRV_LOG(ERR,
+                           "Map table scope not supported by device\n");
+               return -EINVAL;
+       }
+
+       return rc;
+}
 
 int
 tf_free_tbl_scope(struct tf *tfp,
index 65be8f5..fa8ab52 100644 (file)
@@ -898,7 +898,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 +908,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 +932,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 +961,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
  *
@@ -1908,6 +1943,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
         */
index fce7f25..cf7c36e 100644 (file)
@@ -573,6 +573,45 @@ struct tf_dev_ops {
         */
        int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
                                      struct tf_alloc_tbl_scope_parms *parms);
+       /**
+        * Map EEM parif
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table scope map parameters
+        *
+        * [in/out] pointer to the parif_2_pf data to be updated
+        *
+        * [in/out] pointer to the parif_2_pf mask to be updated
+        *
+        * [in] sz_in_bytes - number of bytes to be written
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_map_parif)(struct tf *tfp,
+                               struct tf_map_tbl_scope_parms *parms,
+                               uint8_t *data,
+                               uint8_t *mask,
+                               uint16_t sz_in_bytes);
+       /**
+        * Map EEM table scope
+        *
+        * [in] tfp
+        *   Pointer to TF handle
+        *
+        * [in] parms
+        *   Pointer to table scope map parameters
+        *
+        *    returns:
+        *    0       - Success
+        *    -EINVAL - Error
+        */
+       int (*tf_dev_map_tbl_scope)(struct tf *tfp,
+                                   struct tf_map_tbl_scope_parms *parms);
 
        /**
         * Free EEM table scope
@@ -642,7 +681,7 @@ struct tf_dev_ops {
         *    -EINVAL - Error
         */
        int (*tf_dev_set_global_cfg)(struct tf *tfp,
-                                    struct tf_dev_global_cfg_parms *parms);
+                                    struct tf_global_cfg_parms *parms);
 
        /**
         * Get global cfg
@@ -658,7 +697,7 @@ struct tf_dev_ops {
         *    -EINVAL - Error
         */
        int (*tf_dev_get_global_cfg)(struct tf *tfp,
-                                    struct tf_dev_global_cfg_parms *parms);
+                                    struct tf_global_cfg_parms *parms);
 };
 
 /**
index 0344565..07c8d02 100644 (file)
 #include "tf_tcam.h"
 #include "tf_em.h"
 #include "tf_if_tbl.h"
+#include "tfp.h"
+
+#define TF_DEV_P4_PARIF_MAX 16
+#define TF_DEV_P4_PF_MASK 0xfUL
 
 /**
  * Device specific function that retrieves the MAX number of HCAPI
@@ -97,6 +101,42 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
        return 0;
 }
 
+static int
+tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
+                   struct tf_map_tbl_scope_parms *parms,
+                   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;
+       uint32_t scope_id = (uint32_t)(parms->tbl_scope_id);
+
+       if (sz_in_bytes != sizeof(uint64_t))
+               return -ENOTSUP;
+
+       for (parif = 0; parif < TF_DEV_P4_PARIF_MAX; parif++) {
+               if (parms->parif_bitmask & (1UL << parif)) {
+                       if (parif < 8) {
+                               shift = 4 * parif;
+                               parif_pf_mask[0] |= TF_DEV_P4_PF_MASK << shift;
+                               parif_pf[0] |= scope_id << shift;
+                       } else {
+                               shift = 4 * (parif - 8);
+                               parif_pf_mask[1] |= TF_DEV_P4_PF_MASK << shift;
+                               parif_pf[1] |= scope_id << shift;
+                       }
+               }
+       }
+       tfp_memcpy(data, parif_pf, sz_in_bytes);
+       tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
+
+       return 0;
+}
+
+
 /**
  * Truflow P4 device specific functions
  */
@@ -125,6 +165,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
        .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,
@@ -160,6 +202,8 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
        .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_p4_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,
index 51b0813..8820b28 100644 (file)
@@ -358,7 +358,7 @@ int tf_em_ext_free(struct tf *tfp,
                   struct tf_free_tbl_scope_parms *parms);
 
 /**
- * Common free for external EEM using host or system memory
+ * Common free table scope for external EEM using host or system memory
  *
  * [in] tfp
  *   Pointer to TruFlow handle
@@ -374,7 +374,7 @@ int tf_em_ext_common_free(struct tf *tfp,
                          struct tf_free_tbl_scope_parms *parms);
 
 /**
- * Common alloc for external EEM using host or system memory
+ * Common alloc table scope for external EEM using host or system memory
  *
  * [in] tfp
  *   Pointer to TruFlow handle
@@ -388,6 +388,21 @@ int tf_em_ext_common_free(struct tf *tfp,
  */
 int tf_em_ext_common_alloc(struct tf *tfp,
                           struct tf_alloc_tbl_scope_parms *parms);
+/**
+ * Map a set of parifs to a set of EEM base addresses (table scope)
+ *
+ * [in] tfp
+ *   Pointer to TruFlow handle
+ *
+ * [in] parms
+ *   Pointer to input parameters
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tf_em_ext_map_tbl_scope(struct tf *tfp,
+                           struct tf_map_tbl_scope_parms *parms);
 
 /**
  * Allocate External Tbl entry from the scope pool.
index 0d8b908..d4e8469 100644 (file)
@@ -44,28 +44,6 @@ static enum tf_mem_type mem_type;
 /** Table scope array */
 struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
 
-/** Table scope reversal table
- *
- * Table scope are allocated from 15 to 0 within HCAPI RM.  Because of the
- * association between PFs and legacy table scopes, reverse table scope ids.
- * 15 indicates 0, 14 indicates 1, etc... The application will only see the 0
- * based number.  The firmware will only use the 0 based number.  Only HCAPI RM
- * and Truflow RM believe the number is 15.  When HCAPI RM support allocation
- * from low to high is supported, this adjust function can be removed.
- */
-const uint32_t tbl_scope_reverse[TF_NUM_TBL_SCOPE] = {
-       15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
-
-static uint32_t
-tf_tbl_scope_adjust(uint32_t tbl_scope_id)
-{
-       if (tbl_scope_id < TF_NUM_TBL_SCOPE)
-               return tbl_scope_reverse[tbl_scope_id];
-       else
-               return TF_TBL_SCOPE_INVALID;
-};
-
-
 /* API defined in tf_em.h */
 struct tf_tbl_scope_cb *
 tbl_scope_cb_find(uint32_t tbl_scope_id)
@@ -73,17 +51,11 @@ tbl_scope_cb_find(uint32_t tbl_scope_id)
        int i;
        struct tf_rm_is_allocated_parms parms = { 0 };
        int allocated;
-       uint32_t rm_tbl_scope_id;
-
-       rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id);
-
-       if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID)
-               return NULL;
 
        /* Check that id is valid */
        parms.rm_db = eem_db[TF_DIR_RX];
        parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
-       parms.index = rm_tbl_scope_id;
+       parms.index = tbl_scope_id;
        parms.allocated = &allocated;
 
        i = tf_rm_is_allocated(&parms);
@@ -99,61 +71,6 @@ tbl_scope_cb_find(uint32_t tbl_scope_id)
        return NULL;
 }
 
-int tf_tbl_scope_alloc(uint32_t *tbl_scope_id)
-{
-       int rc;
-       struct tf_rm_allocate_parms parms = { 0 };
-       uint32_t rm_tbl_scope_id;
-       uint32_t usr_tbl_scope_id = TF_TBL_SCOPE_INVALID;
-
-       /* Get Table Scope control block from the session pool */
-       parms.rm_db = eem_db[TF_DIR_RX];
-       parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
-       parms.index = &rm_tbl_scope_id;
-
-       rc = tf_rm_allocate(&parms);
-       if (rc) {
-               TFP_DRV_LOG(ERR,
-                           "Failed to allocate table scope rc:%s\n",
-                           strerror(-rc));
-               return rc;
-       }
-
-       usr_tbl_scope_id = tf_tbl_scope_adjust(rm_tbl_scope_id);
-
-       if (usr_tbl_scope_id == TF_TBL_SCOPE_INVALID) {
-               TFP_DRV_LOG(ERR,
-                           "Invalid table scope allocated id:%d\n",
-                           (int)rm_tbl_scope_id);
-               return -EINVAL;
-       }
-       *tbl_scope_id = usr_tbl_scope_id;
-       return 0;
-};
-
-int tf_tbl_scope_free(uint32_t tbl_scope_id)
-{
-       struct tf_rm_free_parms parms = { 0 };
-       uint32_t rm_tbl_scope_id;
-       uint32_t rc;
-
-       rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id);
-
-       if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID) {
-               TFP_DRV_LOG(ERR,
-                           "Invalid table scope allocated id:%d\n",
-                           (int)tbl_scope_id);
-               return -EINVAL;
-       }
-
-       parms.rm_db = eem_db[TF_DIR_RX];
-       parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
-       parms.index = rm_tbl_scope_id;
-
-       rc = tf_rm_free(&parms);
-       return rc;
-};
-
 int
 tf_create_tbl_pool_external(enum tf_dir dir,
                            struct tf_tbl_scope_cb *tbl_scope_cb,
@@ -1129,3 +1046,92 @@ tf_em_ext_common_free(struct tf *tfp,
 {
        return tf_em_ext_free(tfp, parms);
 }
+
+int tf_em_ext_map_tbl_scope(struct tf *tfp,
+                           struct tf_map_tbl_scope_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_tbl_scope_cb *tbl_scope_cb;
+       struct tf_global_cfg_parms gcfg_parms = { 0 };
+       struct tfp_calloc_parms aparms;
+       uint32_t *data, *mask;
+       uint32_t sz_in_bytes = 8;
+       struct tf_dev_info *dev;
+
+       tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
+
+       if (tbl_scope_cb == NULL) {
+               TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb tbl_scope_id(%d)\n",
+                           parms->tbl_scope_id);
+               return -EINVAL;
+       }
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session_internal(tfp, &tfs);
+       if (rc)
+               return rc;
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc)
+               return rc;
+
+       if (dev->ops->tf_dev_map_tbl_scope == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Map table scope operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       aparms.nitems = 2;
+       aparms.size = sizeof(uint32_t);
+       aparms.alignment = 0;
+
+       if (tfp_calloc(&aparms) != 0) {
+               TFP_DRV_LOG(ERR, "Map tbl scope alloc data error %s\n",
+                           strerror(ENOMEM));
+               return -ENOMEM;
+       }
+       data = aparms.mem_va;
+
+       if (tfp_calloc(&aparms) != 0) {
+               TFP_DRV_LOG(ERR, "Map tbl scope alloc mask error %s\n",
+                           strerror(ENOMEM));
+               rc = -ENOMEM;
+               goto clean;
+       }
+       mask = aparms.mem_va;
+
+       rc = dev->ops->tf_dev_map_parif(tfp, parms, (uint8_t *)data,
+                                       (uint8_t *)mask, sz_in_bytes);
+
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Map table scope config failure, rc:%s\n",
+                           strerror(-rc));
+               goto cleaner;
+       }
+
+       gcfg_parms.type =
+               (enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF;
+       gcfg_parms.offset = 0;
+       gcfg_parms.config = (uint8_t *)data;
+       gcfg_parms.config_mask = (uint8_t *)mask;
+       gcfg_parms.config_sz_in_bytes = sizeof(uint64_t);
+
+
+       rc = tf_msg_set_global_cfg(tfp, &gcfg_parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Map tbl scope, set failed, rc:%s\n",
+                           strerror(-rc));
+       }
+cleaner:
+       tfp_free(mask);
+clean:
+       tfp_free(data);
+
+       return rc;
+}
index f71a487..fa313c4 100644 (file)
@@ -9,6 +9,7 @@
 #include "tf_core.h"
 #include "tf_session.h"
 
+
 /**
  * Function to search for table scope control block structure
  * with specified table scope ID.
  */
 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
 
-/**
- * Table Scope Allocate
- *
- * Allocate a table scope
- *
- * [in/out] pointer to tbl_scope_id
- *
- * Returns:
- *  0 - success
- *  -EINVAL - error
- */
-int tf_tbl_scope_alloc(uint32_t *tbl_scope_id);
-
-/**
- * Table Scope Free
- *
- * Free a table scope
- *
- * [in] tbl_scope_id to free
- *
- * Returns:
- *  0 - success
- *  -EINVAL - error
- */
-int tf_tbl_scope_free(uint32_t tbl_scope_id);
-
 /**
  * Create and initialize a stack to use for action entries
  *
index cfcb12f..b5db94f 100644 (file)
@@ -374,8 +374,14 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
        struct tf_tbl_scope_cb *tbl_scope_cb;
        struct hcapi_cfa_em_table *em_tables;
        struct tf_free_tbl_scope_parms free_parms;
-
-       rc = tf_tbl_scope_alloc(&parms->tbl_scope_id);
+       struct tf_rm_allocate_parms aparms = { 0 };
+       struct tf_rm_free_parms fparms = { 0 };
+
+       /* Get Table Scope control block from the session pool */
+       aparms.rm_db = eem_db[TF_DIR_RX];
+       aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+       aparms.index = (uint32_t *)&parms->tbl_scope_id;
+       rc = tf_rm_allocate(&aparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
                            "Failed to allocate table scope\n");
@@ -472,7 +478,11 @@ cleanup_full:
        return -EINVAL;
 
 cleanup:
-       tf_tbl_scope_free(parms->tbl_scope_id);
+       /* Free Table control block */
+       fparms.rm_db = eem_db[TF_DIR_RX];
+       fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+       fparms.index = parms->tbl_scope_id;
+       tf_rm_free(&fparms);
        return -EINVAL;
 }
 
@@ -483,6 +493,7 @@ tf_em_ext_free(struct tf *tfp,
        int rc = 0;
        enum tf_dir  dir;
        struct tf_tbl_scope_cb *tbl_scope_cb;
+       struct tf_rm_free_parms aparms = { 0 };
 
        tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 
@@ -491,7 +502,11 @@ tf_em_ext_free(struct tf *tfp,
                return -EINVAL;
        }
 
-       rc = tf_tbl_scope_free(parms->tbl_scope_id);
+       /* Free Table control block */
+       aparms.rm_db = eem_db[TF_DIR_RX];
+       aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+       aparms.index = parms->tbl_scope_id;
+       rc = tf_rm_free(&aparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
                            "Failed to free table scope\n");
index 4ed4039..ebd1a86 100644 (file)
@@ -113,7 +113,7 @@ tf_global_cfg_unbind(struct tf *tfp __rte_unused)
 
 int
 tf_global_cfg_set(struct tf *tfp,
-                 struct tf_dev_global_cfg_parms *parms)
+                 struct tf_global_cfg_parms *parms)
 {
        int rc;
        struct tf_global_cfg_get_hcapi_parms hparms;
@@ -156,7 +156,7 @@ tf_global_cfg_set(struct tf *tfp,
 
 int
 tf_global_cfg_get(struct tf *tfp,
-                 struct tf_dev_global_cfg_parms *parms)
+                 struct tf_global_cfg_parms *parms)
 
 {
        int rc;
index 5c73bb1..685f38d 100644 (file)
  * The global cfg module provides processing of global cfg types.
  */
 
-struct tf;
+/* struct tf; */
+
+/* Internal type not available to user
+ * but available internally within Truflow
+ */
+enum tf_global_config_internal_type {
+       TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF = TF_GLOBAL_CFG_TYPE_MAX,
+       TF_GLOBAL_CFG_INTERNAL_TYPE_MAX
+};
 
 /**
  * Global cfg configuration enumeration.
@@ -61,34 +69,6 @@ struct tf_global_cfg_cfg_parms {
        struct tf_global_cfg_cfg *cfg;
 };
 
-/**
- * global cfg parameters
- */
-struct tf_dev_global_cfg_parms {
-       /**
-        * [in] Receive or transmit direction
-        */
-       enum tf_dir dir;
-       /**
-        * [in] Global config type
-        */
-       enum tf_global_config_type type;
-       /**
-        * [in] Offset @ the type
-        */
-       uint32_t offset;
-       /**
-        * [in/out] Value of the configuration
-        * set - Read, Modify and Write
-        * get - Read the full configuration
-        */
-       uint8_t *config;
-       /**
-        * [in] struct containing size
-        */
-       uint16_t config_sz_in_bytes;
-};
-
 /**
  * @page global cfg
  *
@@ -149,7 +129,7 @@ tf_global_cfg_unbind(struct tf *tfp);
  *   - (-EINVAL) on failure.
  */
 int tf_global_cfg_set(struct tf *tfp,
-                     struct tf_dev_global_cfg_parms *parms);
+                     struct tf_global_cfg_parms *parms);
 
 /**
  * Get global configuration
@@ -165,6 +145,6 @@ int tf_global_cfg_set(struct tf *tfp,
  *   - (-EINVAL) on failure.
  */
 int tf_global_cfg_get(struct tf *tfp,
-                     struct tf_dev_global_cfg_parms *parms);
+                     struct tf_global_cfg_parms *parms);
 
 #endif /* TF_GLOBAL_CFG_H */
index 7c2ad17..5615eed 100644 (file)
@@ -1075,7 +1075,7 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 
 int
 tf_msg_get_global_cfg(struct tf *tfp,
-                     struct tf_dev_global_cfg_parms *params)
+                     struct tf_global_cfg_parms *params)
 {
        int rc = 0;
        struct tfp_send_msg_parms parms = { 0 };
@@ -1133,7 +1133,7 @@ tf_msg_get_global_cfg(struct tf *tfp,
 
 int
 tf_msg_set_global_cfg(struct tf *tfp,
-                     struct tf_dev_global_cfg_parms *params)
+                     struct tf_global_cfg_parms *params)
 {
        int rc = 0;
        struct tfp_send_msg_parms parms = { 0 };
@@ -1173,6 +1173,15 @@ tf_msg_set_global_cfg(struct tf *tfp,
 
        tfp_memcpy(req.data, params->config,
                   params->config_sz_in_bytes);
+
+       /* Only set mask if pointer is provided
+        */
+       if (params->config_mask) {
+               tfp_memcpy(req.data + params->config_sz_in_bytes,
+                          params->config_mask,
+                          params->config_sz_in_bytes);
+       }
+
        req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
 
        parms.tf_type = HWRM_TF_GLOBAL_CFG_SET;
index 195710e..72bf850 100644 (file)
@@ -462,7 +462,7 @@ int tf_msg_get_tbl_entry(struct tf *tfp,
  *   0 on Success else internal Truflow error
  */
 int tf_msg_get_global_cfg(struct tf *tfp,
-                         struct tf_dev_global_cfg_parms *params);
+                         struct tf_global_cfg_parms *params);
 
 /**
  * Sends global cfg update request to Firmware
@@ -477,7 +477,7 @@ int tf_msg_get_global_cfg(struct tf *tfp,
  *   0 on Success else internal Truflow error
  */
 int tf_msg_set_global_cfg(struct tf *tfp,
-                         struct tf_dev_global_cfg_parms *params);
+                         struct tf_global_cfg_parms *params);
 
 /**
  * Sends bulk get message of a Table Type element to the firmware.