+ if (!tf_tcam_db_valid(tfp, dir))
+ continue;
+
+ rc = tf_tcam_shared_get_rm_info(tfp,
+ dir,
+ &hcapi_type,
+ &info);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM shared rm info get failed\n",
+ tf_dir_2_str(dir));
+ return rc;
+ }
+
+ for (pool_id = TF_TCAM_SHARED_WC_POOL_HI;
+ pool_id < TF_TCAM_SHARED_WC_POOL_MAX;
+ pool_id++) {
+ pool = tcam_shared_wc->db[dir][pool_id].pool;
+ start = tcam_shared_wc->db[dir][pool_id].info.start;
+ pool_cnt = ba_inuse_count(pool);
+
+ if (pool_cnt) {
+ TFP_DRV_LOG(INFO,
+ "%s: %s: %d residuals found, freeing\n",
+ tf_dir_2_str(dir),
+ tf_pool_2_str(pool_id),
+ pool_cnt);
+ }
+
+ log_idx = 0;
+
+ for (i = 0; i < pool_cnt; i++) {
+ log_idx = ba_find_next_inuse(pool, log_idx);
+
+ if (log_idx < 0) {
+ TFP_DRV_LOG(ERR,
+ "Expected a found %s entry %d\n",
+ tf_pool_2_str(pool_id),
+ i);
+ /* attempt normal unbind
+ */
+ goto done;
+ }
+ phy_idx = start + log_idx;
+
+ parms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+ parms.hcapi_type = hcapi_type;
+ parms.idx = phy_idx;
+ parms.dir = dir;
+ rc = tf_msg_tcam_entry_free(tfp, dev, &parms);
+ if (rc) {
+ /* Log error */
+ TFP_DRV_LOG(ERR,
+ "%s: %s: %d free failed, rc:%s\n",
+ tf_dir_2_str(parms.dir),
+ tf_tcam_tbl_2_str(parms.type),
+ phy_idx,
+ strerror(-rc));
+ return rc;
+ }
+ }
+ /* Free the pool once all the entries
+ * have been cleared
+ */