return 0;
}
+
+int
+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;
+
+ 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_clear_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_clear_tcam(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM shared entries clear failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ return 0;
+}
#endif /* TF_TCAM_SHARED */
int
*/
TF_IDENT_TYPE_EM_PROF,
/**
- * TH
+ * (Future)
* The L2 func is included in the ILT result and from recycling to
* enable virtualization of further lookups.
*/
*
#ifdef TF_TCAM_SHARED
* @ref tf_move_tcam_shared_entries
+ *
+ * @ref tf_clear_tcam_shared_entries
#endif
*/
int tf_move_tcam_shared_entries(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms);
+/**
+ * tf_clear_tcam_shared_entries parameter definition
+ */
+struct tf_clear_tcam_shared_entries_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+};
+
+/**
+ * Clear TCAM shared entries pool
+ *
+ * This API only affects the following TCAM pools within a shared session:
+ *
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
+ *
+ * When called, the indicated WC TCAM high or low pool will be cleared.
+ *
+ * This API is not supported on a non-shared session.
+ *
+ * Returns success or failure code.
+ */
+int tf_clear_tcam_shared_entries(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* TF_TCAM_SHARED */
/**
* @page table Table Access
uint64_t flow_handle;
};
/**
- * tf_search_em_entry parameter definition
+ * tf_search_em_entry parameter definition (Future)
*/
struct tf_search_em_entry_parms {
/**
struct tf_delete_em_entry_parms *parms);
/**
- * search em hash entry table memory
+ * search em hash entry table memory (Future)
*
* Internal:
* -EINVAL - Error
*/
int (*tf_dev_move_tcam)(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms);
+ struct tf_move_tcam_shared_entries_parms *parms);
+
+ /**
+ * Move TCAM shared entries
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to parameters
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_clear_tcam)(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* TF_TCAM_SHARED */
/**
.tf_dev_alloc_search_tcam = NULL,
.tf_dev_set_tcam = NULL,
.tf_dev_get_tcam = NULL,
-#ifdef TF_TCAM_SHARED
- .tf_dev_move_tcam = NULL,
-#endif /* TF_TCAM_SHARED */
.tf_dev_get_tcam_resc_info = NULL,
.tf_dev_insert_int_em_entry = NULL,
.tf_dev_delete_int_em_entry = NULL,
.tf_dev_set_tcam = tf_tcam_shared_set,
.tf_dev_get_tcam = tf_tcam_shared_get,
.tf_dev_move_tcam = tf_tcam_shared_move_p4,
+ .tf_dev_clear_tcam = tf_tcam_shared_clear,
#else /* !TF_TCAM_SHARED */
.tf_dev_alloc_tcam = tf_tcam_alloc,
.tf_dev_free_tcam = tf_tcam_free,
.tf_dev_set_tcam = tf_tcam_shared_set,
.tf_dev_get_tcam = tf_tcam_shared_get,
.tf_dev_move_tcam = tf_tcam_shared_move_p58,
+ .tf_dev_clear_tcam = tf_tcam_shared_clear,
#else /* !TF_TCAM_SHARED */
.tf_dev_alloc_tcam = tf_tcam_alloc,
.tf_dev_free_tcam = tf_tcam_free,
return rc;
}
-int tf_tcam_shared_move_p4(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms)
+int
+tf_tcam_shared_move_p4(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms)
{
int rc = 0;
rc = tf_tcam_shared_move(tfp,
}
-int tf_tcam_shared_move_p58(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms)
+int
+tf_tcam_shared_move_p58(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms)
{
int rc = 0;
rc = tf_tcam_shared_move(tfp,
true); /* set enable bit */
return rc;
}
+
+int
+tf_tcam_shared_clear(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms)
+{
+ int rc = 0;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ uint16_t start;
+ int phy_idx;
+ enum tf_tcam_shared_wc_pool_id id;
+ struct tf_tcam_free_parms nparms;
+ uint16_t hcapi_type;
+ struct tf_rm_alloc_info info;
+ void *tcam_shared_db_ptr = NULL;
+ struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+ int i, cnt;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ if (!tf_session_is_shared_session(tfs) ||
+ (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+ parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW))
+ return -EOPNOTSUPP;
+
+ if (!tf_tcam_db_valid(tfp, parms->dir)) {
+ TFP_DRV_LOG(ERR,
+ "%s: tcam shared pool doesn't exist\n",
+ tf_dir_2_str(parms->dir));
+ return -ENOMEM;
+ }
+
+ rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get tcam_shared_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+
+ if (parms->tcam_tbl_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+ id = TF_TCAM_SHARED_WC_POOL_HI;
+ else
+ id = TF_TCAM_SHARED_WC_POOL_LO;
+
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc)
+ return rc;
+
+ rc = tf_tcam_shared_get_rm_info(tfp,
+ parms->dir,
+ &hcapi_type,
+ &info);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM rm info get failed\n",
+ tf_dir_2_str(parms->dir));
+ return rc;
+ }
+
+ start = tcam_shared_wc->db[parms->dir][id].info.start;
+ cnt = tcam_shared_wc->db[parms->dir][id].info.stride;
+
+ /* Override HI/LO type with parent WC TCAM type */
+ nparms.dir = parms->dir;
+ nparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+ nparms.hcapi_type = hcapi_type;
+
+ for (i = 0; i < cnt; i++) {
+ phy_idx = start + i;
+ nparms.idx = phy_idx;
+
+ /* Clear entry */
+ rc = tf_msg_tcam_entry_free(tfp, dev, &nparms);
+ if (rc) {
+ /* Log error */
+ TFP_DRV_LOG(ERR,
+ "%s: %s: log%d free failed, rc:%s\n",
+ tf_dir_2_str(nparms.dir),
+ tf_tcam_tbl_2_str(nparms.type),
+ phy_idx,
+ strerror(-rc));
+ return rc;
+ }
+ }
+
+ TFP_DRV_LOG(DEBUG,
+ "%s: TCAM shared clear pool(%s)\n",
+ tf_dir_2_str(nparms.dir),
+ tf_pool_2_str(id));
+ return 0;
+}
*
* @ref tf_tcam_shared_get
*
+ * @ref tf_tcam_shared_move_p4
+ *
+ * @ref tf_tcam_shared_move_p58
+ *
+ * @ref tf_tcam_shared_clear
*/
/**
int tf_tcam_shared_move_p58(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms);
+/**
+ * Allocates and clears the entire WC_TCAM_HI or WC_TCAM_LO shared pools
+ *
+ * [in] tfp
+ * Pointer to the truflow handle
+ *
+ * [in] parms
+ * Pointer to parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_clear(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* _TF_TCAM_SHARED_H */
#define _TF_UTIL_H_
#include "tf_core.h"
-#include "tf_device.h"
#define TF_BITS2BYTES(x) (((x) + 7) >> 3)
#define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)