common/mlx5: add Direct Verbs constants for Windows
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.c
index 489c461..936102c 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.
  */
 
 #include "tf_tbl.h"
 #include "tf_em.h"
 #include "tf_rm.h"
+#include "tf_global_cfg.h"
 #include "tf_msg.h"
 #include "tfp.h"
 #include "bitalloc.h"
 #include "bnxt.h"
 #include "rand.h"
 #include "tf_common.h"
-#include "hwrm_tf.h"
+#include "tf_ext_flow_handle.h"
 
 int
 tf_open_session(struct tf *tfp,
@@ -33,7 +34,9 @@ tf_open_session(struct tf *tfp,
         * side. It is assumed that the Firmware will be supported if
         * firmware open session succeeds.
         */
-       if (parms->device_type != TF_DEVICE_TYPE_WH) {
+       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",
                            parms->device_type);
@@ -42,15 +45,28 @@ tf_open_session(struct tf *tfp,
 
        /* Verify control channel and build the beginning of session_id */
        rc = sscanf(parms->ctrl_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
                    &device);
        if (rc != 4) {
-               TFP_DRV_LOG(ERR,
+               /* PCI Domain not provided (optional in DPDK), thus we
+                * force domain to 0 and recheck.
+                */
+               domain = 0;
+
+               /* Check parsing of bus/slot/device */
+               rc = sscanf(parms->ctrl_chan_name,
+                           "%x:%x.%u",
+                           &bus,
+                           &slot,
+                           &device);
+               if (rc != 3) {
+                       TFP_DRV_LOG(ERR,
                            "Failed to scan device ctrl_chan_name\n");
-               return -EINVAL;
+                       return -EINVAL;
+               }
        }
 
        parms->session_id.internal.domain = domain;
@@ -61,14 +77,13 @@ tf_open_session(struct tf *tfp,
        /* Session vs session client is decided in
         * tf_session_open_session()
         */
-       printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
        rc = tf_session_open_session(tfp, &oparms);
        /* Logging handled by tf_session_open_session */
        if (rc)
                return rc;
 
        TFP_DRV_LOG(INFO,
-                   "domain:%d, bus:%d, device:%d\n",
+                   "domain:%d, bus:%d, device:%u\n",
                    parms->session_id.internal.domain,
                    parms->session_id.internal.bus,
                    parms->session_id.internal.device);
@@ -88,7 +103,7 @@ tf_attach_session(struct tf *tfp,
 
        /* Verify control channel */
        rc = sscanf(parms->ctrl_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
@@ -101,7 +116,7 @@ tf_attach_session(struct tf *tfp,
 
        /* Verify 'attach' channel */
        rc = sscanf(parms->attach_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
@@ -236,6 +251,7 @@ int tf_delete_em_entry(struct tf *tfp,
        struct tf_session      *tfs;
        struct tf_dev_info     *dev;
        int rc;
+       unsigned int flag = 0;
 
        TF_CHECK_PARMS2(tfp, parms);
 
@@ -259,12 +275,11 @@ int tf_delete_em_entry(struct tf *tfp,
                return rc;
        }
 
-       if (parms->mem == TF_MEM_EXTERNAL)
-               rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
-       else if (parms->mem == TF_MEM_INTERNAL)
+       TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
+       if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
                rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
        else
-               return -EINVAL;
+               rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
 
        if (rc) {
                TFP_DRV_LOG(ERR,
@@ -277,6 +292,130 @@ int tf_delete_em_entry(struct tf *tfp,
        return rc;
 }
 
+/** Get global configuration API
+ *
+ *    returns:
+ *    0       - Success
+ *    -EINVAL - Error
+ */
+int tf_get_global_cfg(struct tf *tfp,
+                     struct tf_global_cfg_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (parms->config == NULL ||
+          parms->config_sz_in_bytes == 0) {
+               TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
+               return -EINVAL;
+       }
+
+       if (dev->ops->tf_dev_get_global_cfg == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return -EOPNOTSUPP;
+       }
+
+       rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Global Cfg get failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return rc;
+}
+
+/** Set global configuration API
+ *
+ *    returns:
+ *    0       - Success
+ *    -EINVAL - Error
+ */
+int tf_set_global_cfg(struct tf *tfp,
+                     struct tf_global_cfg_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (parms->config == NULL ||
+          parms->config_sz_in_bytes == 0) {
+               TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
+               return -EINVAL;
+       }
+
+       if (dev->ops->tf_dev_set_global_cfg == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return -EOPNOTSUPP;
+       }
+
+       rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Global Cfg set failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return rc;
+}
+
 int
 tf_alloc_identifier(struct tf *tfp,
                    struct tf_alloc_identifier_parms *parms)
@@ -384,6 +523,7 @@ tf_free_identifier(struct tf *tfp,
        fparms.dir = parms->dir;
        fparms.type = parms->ident_type;
        fparms.id = parms->id;
+       fparms.ref_cnt = &parms->ref_cnt;
        rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
@@ -396,6 +536,139 @@ tf_free_identifier(struct tf *tfp,
        return 0;
 }
 
+int
+tf_search_identifier(struct tf *tfp,
+                    struct tf_search_identifier_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_ident_search_parms sparms;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Can't do static initialization due to UT enum check */
+       memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_search_ident == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       sparms.dir = parms->dir;
+       sparms.type = parms->ident_type;
+       sparms.search_id = parms->search_id;
+       sparms.hit = &parms->hit;
+       sparms.ref_cnt = &parms->ref_cnt;
+       rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Identifier search failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+
+int
+tf_search_tcam_entry(struct tf *tfp,
+                    struct tf_search_tcam_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_tcam_alloc_search_parms sparms;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       sparms.dir = parms->dir;
+       sparms.type = parms->tcam_tbl_type;
+       sparms.key = parms->key;
+       sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+       sparms.mask = parms->mask;
+       sparms.priority = parms->priority;
+       sparms.alloc = parms->alloc;
+
+       /* Result is an in/out and so no need to copy during outputs */
+       sparms.result = parms->result;
+       sparms.result_size =
+               TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
+
+       rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM allocation failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Copy the outputs */
+       parms->hit = sparms.hit;
+       parms->search_status = sparms.search_status;
+       parms->ref_cnt = sparms.ref_cnt;
+       parms->idx = sparms.idx;
+
+       return 0;
+}
+
 int
 tf_alloc_tcam_entry(struct tf *tfp,
                    struct tf_alloc_tcam_entry_parms *parms)
@@ -403,10 +676,12 @@ tf_alloc_tcam_entry(struct tf *tfp,
        int rc;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_tcam_alloc_parms aparms = { 0 };
+       struct tf_tcam_alloc_parms aparms;
 
        TF_CHECK_PARMS2(tfp, parms);
 
+       memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
+
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
        if (rc) {
@@ -461,10 +736,13 @@ tf_set_tcam_entry(struct tf *tfp,
        int rc;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_tcam_set_parms sparms = { 0 };
+       struct tf_tcam_set_parms sparms;
 
        TF_CHECK_PARMS2(tfp, parms);
 
+       memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
+
+
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
        if (rc) {
@@ -485,7 +763,8 @@ tf_set_tcam_entry(struct tf *tfp,
                return rc;
        }
 
-       if (dev->ops->tf_dev_set_tcam == NULL) {
+       if (dev->ops->tf_dev_set_tcam == NULL ||
+           dev->ops->tf_dev_word_align == NULL) {
                rc = -EOPNOTSUPP;
                TFP_DRV_LOG(ERR,
                            "%s: Operation not supported, rc:%s\n",
@@ -499,14 +778,189 @@ tf_set_tcam_entry(struct tf *tfp,
        sparms.idx = parms->idx;
        sparms.key = parms->key;
        sparms.mask = parms->mask;
-       sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+       sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
        sparms.result = parms->result;
        sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
 
-       rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
+       rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM set failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+
+int
+tf_get_tcam_entry(struct tf *tfp __rte_unused,
+                 struct tf_get_tcam_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_tcam_get_parms gparms;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
+
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_get_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       gparms.dir = parms->dir;
+       gparms.type = parms->tcam_tbl_type;
+       gparms.idx = parms->idx;
+       gparms.key = parms->key;
+       gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
+       gparms.mask = parms->mask;
+       gparms.result = parms->result;
+       gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
+
+       rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM get failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+       parms->key_sz_in_bits = gparms.key_size * 8;
+       parms->result_sz_in_bits = gparms.result_size * 8;
+
+       return 0;
+}
+
+int
+tf_free_tcam_entry(struct tf *tfp,
+                  struct tf_free_tcam_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_tcam_free_parms fparms;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_free_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       fparms.dir = parms->dir;
+       fparms.type = parms->tcam_tbl_type;
+       fparms.idx = parms->idx;
+       rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM free failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+
+#ifdef TF_TCAM_SHARED
+int
+tf_move_tcam_shared_entries(struct tf *tfp,
+                           struct tf_move_tcam_shared_entries_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_move_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_move_tcam(tfp, parms);
        if (rc) {
                TFP_DRV_LOG(ERR,
-                           "%s: TCAM set failed, rc:%s\n",
+                           "%s: TCAM shared entries move failed, rc:%s\n",
                            tf_dir_2_str(parms->dir),
                            strerror(-rc));
                return rc;
@@ -516,21 +970,12 @@ tf_set_tcam_entry(struct tf *tfp,
 }
 
 int
-tf_get_tcam_entry(struct tf *tfp __rte_unused,
-                 struct tf_get_tcam_entry_parms *parms __rte_unused)
-{
-       TF_CHECK_PARMS2(tfp, parms);
-       return -EOPNOTSUPP;
-}
-
-int
-tf_free_tcam_entry(struct tf *tfp,
-                  struct tf_free_tcam_entry_parms *parms)
+tf_clear_tcam_shared_entries(struct tf *tfp,
+                            struct tf_clear_tcam_shared_entries_parms *parms)
 {
        int rc;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_tcam_free_parms fparms = { 0 };
 
        TF_CHECK_PARMS2(tfp, parms);
 
@@ -554,7 +999,7 @@ tf_free_tcam_entry(struct tf *tfp,
                return rc;
        }
 
-       if (dev->ops->tf_dev_free_tcam == NULL) {
+       if (dev->ops->tf_dev_clear_tcam == NULL) {
                rc = -EOPNOTSUPP;
                TFP_DRV_LOG(ERR,
                            "%s: Operation not supported, rc:%s\n",
@@ -563,13 +1008,10 @@ tf_free_tcam_entry(struct tf *tfp,
                return rc;
        }
 
-       fparms.dir = parms->dir;
-       fparms.type = parms->tcam_tbl_type;
-       fparms.idx = parms->idx;
-       rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
+       rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
        if (rc) {
                TFP_DRV_LOG(ERR,
-                           "%s: TCAM free failed, rc:%s\n",
+                           "%s: TCAM shared entries clear failed, rc:%s\n",
                            tf_dir_2_str(parms->dir),
                            strerror(-rc));
                return rc;
@@ -577,6 +1019,7 @@ tf_free_tcam_entry(struct tf *tfp,
 
        return 0;
 }
+#endif /* TF_TCAM_SHARED */
 
 int
 tf_alloc_tbl_entry(struct tf *tfp,
@@ -636,17 +1079,16 @@ tf_alloc_tbl_entry(struct tf *tfp,
                                    strerror(-rc));
                        return rc;
                }
-
-       } else {
-               if (dev->ops->tf_dev_alloc_tbl == NULL) {
-                       rc = -EOPNOTSUPP;
+       } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
+               rc = dev->ops->tf_dev_alloc_sram_tbl(tfp, &aparms);
+               if (rc) {
                        TFP_DRV_LOG(ERR,
-                                   "%s: Operation not supported, rc:%s\n",
+                                   "%s: SRAM table allocation failed, rc:%s\n",
                                    tf_dir_2_str(parms->dir),
                                    strerror(-rc));
-                       return -EOPNOTSUPP;
+                       return rc;
                }
-
+       } else {
                rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
                if (rc) {
                        TFP_DRV_LOG(ERR,
@@ -719,15 +1161,16 @@ tf_free_tbl_entry(struct tf *tfp,
                                    strerror(-rc));
                        return rc;
                }
-       } else {
-               if (dev->ops->tf_dev_free_tbl == NULL) {
-                       rc = -EOPNOTSUPP;
+       } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
+               rc = dev->ops->tf_dev_free_sram_tbl(tfp, &fparms);
+               if (rc) {
                        TFP_DRV_LOG(ERR,
-                                   "%s: Operation not supported, rc:%s\n",
+                                   "%s: SRAM table free failed, rc:%s\n",
                                    tf_dir_2_str(parms->dir),
                                    strerror(-rc));
-                       return -EOPNOTSUPP;
+                       return rc;
                }
+       } else {
 
                rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
                if (rc) {
@@ -738,7 +1181,6 @@ tf_free_tbl_entry(struct tf *tfp,
                        return rc;
                }
        }
-
        return 0;
 }
 
@@ -801,6 +1243,15 @@ tf_set_tbl_entry(struct tf *tfp,
                                    strerror(-rc));
                        return rc;
                }
+       }  else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
+               rc = dev->ops->tf_dev_set_sram_tbl(tfp, &sparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: SRAM table set failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
        } else {
                if (dev->ops->tf_dev_set_tbl == NULL) {
                        rc = -EOPNOTSUPP;
@@ -857,28 +1308,39 @@ tf_get_tbl_entry(struct tf *tfp,
                            strerror(-rc));
                return rc;
        }
-
-       if (dev->ops->tf_dev_get_tbl == NULL) {
-               rc = -EOPNOTSUPP;
-               TFP_DRV_LOG(ERR,
-                           "%s: Operation not supported, rc:%s\n",
-                           tf_dir_2_str(parms->dir),
-                           strerror(-rc));
-               return -EOPNOTSUPP;
-       }
-
        gparms.dir = parms->dir;
        gparms.type = parms->type;
        gparms.data = parms->data;
        gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
        gparms.idx = parms->idx;
-       rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
-       if (rc) {
-               TFP_DRV_LOG(ERR,
-                           "%s: Table get failed, rc:%s\n",
-                           tf_dir_2_str(parms->dir),
-                           strerror(-rc));
-               return rc;
+
+       if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
+               rc = dev->ops->tf_dev_get_sram_tbl(tfp, &gparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: SRAM table get failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
+       } else {
+               if (dev->ops->tf_dev_get_tbl == NULL) {
+                       rc = -EOPNOTSUPP;
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Operation not supported, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return -EOPNOTSUPP;
+               }
+
+               rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Table get failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
        }
 
        return rc;
@@ -918,6 +1380,13 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
                return rc;
        }
 
+       bparms.dir = parms->dir;
+       bparms.type = parms->type;
+       bparms.starting_idx = parms->starting_idx;
+       bparms.num_entries = parms->num_entries;
+       bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
+       bparms.physical_mem_addr = parms->physical_mem_addr;
+
        if (parms->type == TF_TBL_TYPE_EXT) {
                /* Not supported, yet */
                rc = -EOPNOTSUPP;
@@ -927,10 +1396,17 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
                            strerror(-rc));
 
                return rc;
+       } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
+               rc = dev->ops->tf_dev_get_bulk_sram_tbl(tfp, &bparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: SRAM table bulk get failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+               }
+               return rc;
        }
 
-       /* Internal table type processing */
-
        if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
                rc = -EOPNOTSUPP;
                TFP_DRV_LOG(ERR,
@@ -940,12 +1416,6 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
                return -EOPNOTSUPP;
        }
 
-       bparms.dir = parms->dir;
-       bparms.type = parms->type;
-       bparms.starting_idx = parms->starting_idx;
-       bparms.num_entries = parms->num_entries;
-       bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
-       bparms.physical_mem_addr = parms->physical_mem_addr;
        rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
@@ -954,6 +1424,57 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
                            strerror(-rc));
                return rc;
        }
+       return rc;
+}
+
+int tf_get_shared_tbl_increment(struct tf *tfp,
+                               struct tf_get_shared_tbl_increment_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Internal table type processing */
+
+       if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return -EOPNOTSUPP;
+       }
+
+       rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Get table increment not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
 
        return rc;
 }
@@ -996,6 +1517,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,
@@ -1151,3 +1710,95 @@ tf_get_if_tbl_entry(struct tf *tfp,
 
        return 0;
 }
+
+int tf_get_session_info(struct tf *tfp,
+                       struct tf_get_session_info_parms *parms)
+{
+       int rc;
+       struct tf_session      *tfs;
+       struct tf_dev_info     *dev;
+
+       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;
+       }
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Ident get resc info failed, rc:%s\n",
+                           strerror(-rc));
+       }
+
+       if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "Tbl get resc info failed, rc:%s\n",
+                           strerror(-rc));
+       }
+
+       if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "TCAM get resc info failed, rc:%s\n",
+                           strerror(-rc));
+       }
+
+       if (dev->ops->tf_dev_get_em_resc_info == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "Operation not supported, rc:%s\n",
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "EM get resc info failed, rc:%s\n",
+                           strerror(-rc));
+       }
+
+       return 0;
+}