#include "bnxt.h"
#include "rand.h"
#include "tf_common.h"
-#include "hwrm_tf.h"
#include "tf_ext_flow_handle.h"
int
return 0;
}
+#ifdef TF_TCAM_SHARED
int
-tf_alloc_tbl_entry(struct tf *tfp,
- struct tf_alloc_tbl_entry_parms *parms)
+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;
- struct tf_tbl_alloc_parms aparms;
- uint32_t idx;
TF_CHECK_PARMS2(tfp, parms);
- /* Can't do static initialization due to UT enum check */
- memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
-
/* Retrieve the session information */
rc = tf_session_get_session(tfp, &tfs);
if (rc) {
return rc;
}
- 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;
- }
+ 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;
}
- parms->idx = idx;
+ rc = dev->ops->tf_dev_move_tcam(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM shared entries move failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
return 0;
}
int
-tf_search_tbl_entry(struct tf *tfp,
- struct tf_search_tbl_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_tbl_alloc_search_parms sparms;
TF_CHECK_PARMS2(tfp, parms);
return rc;
}
- if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
+ if (dev->ops->tf_dev_clear_tcam == NULL) {
rc = -EOPNOTSUPP;
TFP_DRV_LOG(ERR,
"%s: Operation not supported, rc:%s\n",
return rc;
}
- 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);
+ rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
- "%s: TBL allocation failed, rc:%s\n",
+ "%s: TCAM shared entries clear failed, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
}
- /* 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;
+}
+#endif /* TF_TCAM_SHARED */
+
+int
+tf_alloc_tbl_entry(struct tf *tfp,
+ struct tf_alloc_tbl_entry_parms *parms)
+{
+ int rc;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ struct tf_tbl_alloc_parms aparms;
+ uint32_t idx;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Can't do static initialization due to UT enum check */
+ memset(&aparms, 0, sizeof(struct tf_tbl_alloc_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;
+ }
+
+ 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_is_sram_managed(tfp, parms->type)) {
+ rc = dev->ops->tf_dev_alloc_sram_tbl(tfp, &aparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: SRAM table allocation failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+ } else {
+ 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;
}
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) {
return rc;
}
}
-
return 0;
}
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;
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;
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;
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,
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,
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;
}
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;
+}