+
+int
+tf_ident_search(struct tf *tfp __rte_unused,
+ struct tf_ident_search_parms *parms)
+{
+ int rc;
+ struct tf_rm_is_allocated_parms aparms = { 0 };
+ struct tf_shadow_ident_search_parms sparms = { 0 };
+ int allocated = 0;
+ uint32_t base_id;
+ struct ident_rm_db *ident_db;
+ void *ident_db_ptr = NULL;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ if (!shadow_init) {
+ TFP_DRV_LOG(ERR,
+ "%s: Identifier Shadow copy is not enabled\n",
+ tf_dir_2_str(parms->dir));
+ return -EINVAL;
+ }
+
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get ident_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
+ /* Check if element is in use */
+ aparms.rm_db = ident_db->ident_db[parms->dir];
+ aparms.subtype = parms->type;
+ aparms.index = parms->search_id;
+ aparms.base_index = &base_id;
+ aparms.allocated = &allocated;
+ rc = tf_rm_is_allocated(&aparms);
+ if (rc)
+ return rc;
+
+ if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+ TFP_DRV_LOG(ERR,
+ "%s: Entry not allocated, type:%d, index:%d\n",
+ tf_dir_2_str(parms->dir),
+ parms->type,
+ parms->search_id);
+ return -EINVAL;
+ }
+
+ sparms.tf_shadow_ident_db = ident_shadow_db[parms->dir];
+ sparms.type = parms->type;
+ sparms.search_id = base_id;
+ sparms.hit = parms->hit;
+ sparms.ref_cnt = parms->ref_cnt;
+
+ rc = tf_shadow_ident_search(&sparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed search shadow DB, type:%d\n",
+ tf_dir_2_str(parms->dir),
+ parms->type);
+ return rc;
+ }
+
+ return 0;
+}
+
+int
+tf_ident_get_resc_info(struct tf *tfp,
+ struct tf_identifier_resource_info *ident)
+{
+ int rc;
+ int d;
+ struct tf_resource_info *dinfo;
+ struct tf_rm_get_alloc_info_parms ainfo;
+ void *ident_db_ptr = NULL;
+ struct ident_rm_db *ident_db;
+
+ TF_CHECK_PARMS2(tfp, ident);
+
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for ident from session\n");
+ return 0;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
+ /* check if reserved resource for WC is multiple of num_slices */
+ for (d = 0; d < TF_DIR_MAX; d++) {
+ ainfo.rm_db = ident_db->ident_db[d];
+ dinfo = ident[d].info;
+
+ ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+ ainfo.subtype = 0;
+ rc = tf_rm_get_all_info(&ainfo, TF_IDENT_TYPE_MAX);
+ if (rc)
+ return rc;
+ }
+
+ return 0;
+}