net/bnxt: add shadow table capability with search
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.c
index 8b3e15c..0dbde1d 100644 (file)
@@ -11,6 +11,7 @@
 #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"
@@ -48,9 +49,22 @@ tf_open_session(struct tf *tfp,
                    &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.%d",
+                           &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;
@@ -58,21 +72,19 @@ tf_open_session(struct tf *tfp,
        parms->session_id.internal.device = device;
        oparms.open_cfg = parms;
 
+       /* Session vs session client is decided in
+        * tf_session_open_session()
+        */
        rc = tf_session_open_session(tfp, &oparms);
        /* Logging handled by tf_session_open_session */
        if (rc)
                return rc;
 
        TFP_DRV_LOG(INFO,
-                   "Session created, session_id:%d\n",
-                   parms->session_id.id);
-
-       TFP_DRV_LOG(INFO,
-                   "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
+                   "domain:%d, bus:%d, device:%d\n",
                    parms->session_id.internal.domain,
                    parms->session_id.internal.bus,
-                   parms->session_id.internal.device,
-                   parms->session_id.internal.fw_session_id);
+                   parms->session_id.internal.device);
 
        return 0;
 }
@@ -152,6 +164,9 @@ tf_close_session(struct tf *tfp)
 
        cparms.ref_count = &ref_count;
        cparms.session_id = &session_id;
+       /* Session vs session client is decided in
+        * tf_session_close_session()
+        */
        rc = tf_session_close_session(tfp,
                                      &cparms);
        /* Logging handled by tf_session_close_session */
@@ -159,16 +174,10 @@ tf_close_session(struct tf *tfp)
                return rc;
 
        TFP_DRV_LOG(INFO,
-                   "Closed session, session_id:%d, ref_count:%d\n",
-                   cparms.session_id->id,
-                   *cparms.ref_count);
-
-       TFP_DRV_LOG(INFO,
-                   "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
+                   "domain:%d, bus:%d, device:%d\n",
                    cparms.session_id->internal.domain,
                    cparms.session_id->internal.bus,
-                   cparms.session_id->internal.device,
-                   cparms.session_id->internal.fw_session_id);
+                   cparms.session_id->internal.device);
 
        return rc;
 }
@@ -186,7 +195,7 @@ int tf_insert_em_entry(struct tf *tfp,
        struct tf_dev_info     *dev;
        int rc;
 
-       TF_CHECK_PARMS_SESSION(tfp, parms);
+       TF_CHECK_PARMS2(tfp, parms);
 
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
@@ -241,7 +250,7 @@ int tf_delete_em_entry(struct tf *tfp,
        struct tf_dev_info     *dev;
        int rc;
 
-       TF_CHECK_PARMS_SESSION(tfp, parms);
+       TF_CHECK_PARMS2(tfp, parms);
 
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
@@ -281,6 +290,142 @@ 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;
+       struct tf_dev_global_cfg_parms gparms = { 0 };
+
+       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;
+       }
+
+       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);
+       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;
+       struct tf_dev_global_cfg_parms gparms = { 0 };
+
+       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;
+       }
+
+       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);
+       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)
@@ -388,6 +533,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,
@@ -400,6 +546,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)
@@ -407,10 +686,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) {
@@ -465,10 +746,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) {
@@ -523,7 +807,7 @@ int
 tf_get_tcam_entry(struct tf *tfp __rte_unused,
                  struct tf_get_tcam_entry_parms *parms __rte_unused)
 {
-       TF_CHECK_PARMS_SESSION(tfp, parms);
+       TF_CHECK_PARMS2(tfp, parms);
        return -EOPNOTSUPP;
 }
 
@@ -534,10 +818,12 @@ tf_free_tcam_entry(struct tf *tfp,
        int rc;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
-       struct tf_tcam_free_parms fparms = { 0 };
+       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) {
@@ -573,7 +859,7 @@ tf_free_tcam_entry(struct tf *tfp,
        rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
-                           "%s: TCAM allocation failed, rc:%s\n",
+                           "%s: TCAM free failed, rc:%s\n",
                            tf_dir_2_str(parms->dir),
                            strerror(-rc));
                return rc;
@@ -617,28 +903,116 @@ tf_alloc_tbl_entry(struct tf *tfp,
                return rc;
        }
 
-       if (dev->ops->tf_dev_alloc_tbl == NULL) {
+       aparms.dir = parms->dir;
+       aparms.type = parms->type;
+       aparms.idx = &idx;
+       aparms.tbl_scope_id = parms->tbl_scope_id;
+
+       if (parms->type == TF_TBL_TYPE_EXT) {
+               if (dev->ops->tf_dev_alloc_ext_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_alloc_ext_tbl(tfp, &aparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: External table allocation failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
+
+       } else {
+               if (dev->ops->tf_dev_alloc_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_alloc_tbl(tfp, &aparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Table allocation failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
+       }
+
+       parms->idx = idx;
+
+       return 0;
+}
+
+int
+tf_search_tbl_entry(struct tf *tfp,
+                   struct tf_search_tbl_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_tbl_alloc_search_parms sparms;
+
+       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_alloc_search_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;
+               return rc;
        }
 
-       aparms.dir = parms->dir;
-       aparms.type = parms->type;
-       aparms.idx = &idx;
-       rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
+       memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
+       sparms.dir = parms->dir;
+       sparms.type = parms->type;
+       sparms.result = parms->result;
+       sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
+       sparms.alloc = parms->alloc;
+       sparms.tbl_scope_id = parms->tbl_scope_id;
+       rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
        if (rc) {
                TFP_DRV_LOG(ERR,
-                           "%s: Table allocation failed, rc:%s\n",
+                           "%s: TBL allocation failed, rc:%s\n",
                            tf_dir_2_str(parms->dir),
                            strerror(-rc));
                return rc;
        }
 
-       parms->idx = idx;
+       /* Return the outputs from the search */
+       parms->hit = sparms.hit;
+       parms->search_status = sparms.search_status;
+       parms->ref_cnt = sparms.ref_cnt;
+       parms->idx = sparms.idx;
 
        return 0;
 }
@@ -677,25 +1051,47 @@ tf_free_tbl_entry(struct tf *tfp,
                return rc;
        }
 
-       if (dev->ops->tf_dev_free_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;
-       }
-
        fparms.dir = parms->dir;
        fparms.type = parms->type;
        fparms.idx = parms->idx;
-       rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
-       if (rc) {
-               TFP_DRV_LOG(ERR,
-                           "%s: Table free failed, rc:%s\n",
-                           tf_dir_2_str(parms->dir),
-                           strerror(-rc));
-               return rc;
+       fparms.tbl_scope_id = parms->tbl_scope_id;
+
+       if (parms->type == TF_TBL_TYPE_EXT) {
+               if (dev->ops->tf_dev_free_ext_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_free_ext_tbl(tfp, &fparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Table free failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
+       } else {
+               if (dev->ops->tf_dev_free_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_free_tbl(tfp, &fparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Table free failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
        }
 
        return 0;
@@ -735,27 +1131,49 @@ tf_set_tbl_entry(struct tf *tfp,
                return rc;
        }
 
-       if (dev->ops->tf_dev_set_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;
-       }
-
        sparms.dir = parms->dir;
        sparms.type = parms->type;
        sparms.data = parms->data;
        sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
        sparms.idx = parms->idx;
-       rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
-       if (rc) {
-               TFP_DRV_LOG(ERR,
-                           "%s: Table set failed, rc:%s\n",
-                           tf_dir_2_str(parms->dir),
-                           strerror(-rc));
-               return rc;
+       sparms.tbl_scope_id = parms->tbl_scope_id;
+
+       if (parms->type == TF_TBL_TYPE_EXT) {
+               if (dev->ops->tf_dev_set_ext_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_set_ext_tbl(tfp, &sparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: 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;
+                       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_tbl(tfp, &sparms);
+               if (rc) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: Table set failed, rc:%s\n",
+                                   tf_dir_2_str(parms->dir),
+                                   strerror(-rc));
+                       return rc;
+               }
        }
 
        return rc;
@@ -821,7 +1239,80 @@ tf_get_tbl_entry(struct tf *tfp,
        return rc;
 }
 
-/* API defined in tf_core.h */
+int
+tf_bulk_get_tbl_entry(struct tf *tfp,
+                struct tf_bulk_get_tbl_entry_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_tbl_get_bulk_parms bparms;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Can't do static initialization due to UT enum check */
+       memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_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->type == TF_TBL_TYPE_EXT) {
+               /* Not supported, yet */
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s, External table type not supported, 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,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               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,
+                           "%s: Table get bulk failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return rc;
+}
+
 int
 tf_alloc_tbl_scope(struct tf *tfp,
                   struct tf_alloc_tbl_scope_parms *parms)
@@ -830,7 +1321,7 @@ tf_alloc_tbl_scope(struct tf *tfp,
        struct tf_dev_info *dev;
        int rc;
 
-       TF_CHECK_PARMS_SESSION_NO_DIR(tfp, parms);
+       TF_CHECK_PARMS2(tfp, parms);
 
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
@@ -861,7 +1352,6 @@ tf_alloc_tbl_scope(struct tf *tfp,
        return rc;
 }
 
-/* API defined in tf_core.h */
 int
 tf_free_tbl_scope(struct tf *tfp,
                  struct tf_free_tbl_scope_parms *parms)
@@ -870,7 +1360,7 @@ tf_free_tbl_scope(struct tf *tfp,
        struct tf_dev_info *dev;
        int rc;
 
-       TF_CHECK_PARMS_SESSION_NO_DIR(tfp, parms);
+       TF_CHECK_PARMS2(tfp, parms);
 
        /* Retrieve the session information */
        rc = tf_session_get_session(tfp, &tfs);
@@ -900,3 +1390,119 @@ tf_free_tbl_scope(struct tf *tfp,
 
        return rc;
 }
+
+int
+tf_set_if_tbl_entry(struct tf *tfp,
+                   struct tf_set_if_tbl_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_if_tbl_set_parms sparms = { 0 };
+
+       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_set_if_tbl == 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->type;
+       sparms.idx = parms->idx;
+       sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
+       sparms.data = parms->data;
+
+       rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: If_tbl set failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+
+int
+tf_get_if_tbl_entry(struct tf *tfp,
+                   struct tf_get_if_tbl_entry_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+       struct tf_if_tbl_get_parms gparms = { 0 };
+
+       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_get_if_tbl == 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->type;
+       gparms.idx = parms->idx;
+       gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
+       gparms.data = parms->data;
+
+       rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: If_tbl get failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}