/**
* Bulk get index table entry
*
- * Used to retrieve a previous set index table entry.
+ * Used to retrieve a set of index table entries.
*
- * Reads and compares with the shadow table copy (if enabled) (only
- * for internal objects).
+ * Entries within the range may not have been allocated using
+ * tf_alloc_tbl_entry() at the time of access. But the range must
+ * be within the bounds determined from tf_open_session() for the
+ * given table type. Currently, this is only used for collecting statistics.
*
* Returns success or failure code. Failure will be returned if the
* provided data buffer is too small for the data type requested.
return rc;
*fw_session_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
- *fw_session_client_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
+ *fw_session_client_id =
+ (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
return rc;
}
}
*parms->index = index;
- *parms->base_index = id;
+ if (parms->base_index)
+ *parms->base_index = id;
return rc;
}
if (rc)
return rc;
- *parms->base_index = adj_index;
+ if (parms->base_index)
+ *parms->base_index = adj_index;
*parms->allocated = ba_inuse(rm_db->db[parms->db_index].pool,
adj_index);
return rc;
}
+
+int
+tf_rm_check_indexes_in_range(struct tf_rm_check_indexes_in_range_parms *parms)
+{
+ struct tf_rm_new_db *rm_db;
+ enum tf_rm_elem_cfg_type cfg_type;
+ uint32_t base_index;
+ uint32_t stride;
+ int rc = 0;
+
+ TF_CHECK_PARMS2(parms, parms->rm_db);
+
+ rm_db = (struct tf_rm_new_db *)parms->rm_db;
+ cfg_type = rm_db->db[parms->db_index].cfg_type;
+
+ /* Bail out if not controlled by RM */
+ if (cfg_type != TF_RM_ELEM_CFG_HCAPI_BA)
+ return -ENOTSUP;
+
+ /* Bail out if the pool is not valid, should never happen */
+ if (rm_db->db[parms->db_index].pool == NULL) {
+ rc = -ENOTSUP;
+ TFP_DRV_LOG(ERR,
+ "%s: Invalid pool for this type:%d, rc:%s\n",
+ tf_dir_2_str(rm_db->dir),
+ parms->db_index,
+ strerror(-rc));
+ return rc;
+ }
+
+ base_index = rm_db->db[parms->db_index].alloc.entry.start;
+ stride = rm_db->db[parms->db_index].alloc.entry.stride;
+
+ if (parms->starting_index < base_index ||
+ parms->starting_index + parms->num_entries > base_index + stride)
+ return -EINVAL;
+
+ return rc;
+}
uint16_t *count;
};
+/**
+ * Check if the indexes are in the range of reserved resource
+ */
+struct tf_rm_check_indexes_in_range_parms {
+ /**
+ * [in] RM DB Handle
+ */
+ void *rm_db;
+ /**
+ * [in] DB Index, indicates which DB entry to perform the
+ * action on.
+ */
+ uint16_t db_index;
+ /**
+ * [in] Starting index
+ */
+ uint16_t starting_index;
+ /**
+ * [in] number of entries
+ */
+ uint16_t num_entries;
+};
+
/**
* @page rm Resource Manager
*
*/
int tf_rm_get_inuse_count(struct tf_rm_get_inuse_count_parms *parms);
+/**
+ * Check if the requested indexes are in the range of reserved resource.
+ *
+ * [in] parms
+ * Pointer to get inuse parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int
+tf_rm_check_indexes_in_range(struct tf_rm_check_indexes_in_range_parms *parms);
+
+
#endif /* TF_RM_NEW_H_ */
struct tf_tbl_get_bulk_parms *parms)
{
int rc;
- int i;
uint16_t hcapi_type;
- uint32_t idx;
- int allocated = 0;
- struct tf_rm_is_allocated_parms aparms = { 0 };
struct tf_rm_get_hcapi_parms hparms = { 0 };
+ struct tf_rm_check_indexes_in_range_parms cparms = { 0 };
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
- /* Verify that the entries has been previously allocated */
- aparms.rm_db = tbl_db[parms->dir];
- aparms.db_index = parms->type;
- aparms.allocated = &allocated;
- idx = parms->starting_idx;
- for (i = 0; i < parms->num_entries; i++) {
- aparms.index = idx;
- rc = tf_rm_is_allocated(&aparms);
- if (rc)
- return rc;
- if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
- TFP_DRV_LOG(ERR,
- "%s, Invalid or not allocated index, type:%d, idx:%d\n",
- tf_dir_2_str(parms->dir),
- parms->type,
- idx);
- return -EINVAL;
- }
- idx++;
+ /* Verify that the entries are in the range of reserved resources. */
+ cparms.rm_db = tbl_db[parms->dir];
+ cparms.db_index = parms->type;
+ cparms.starting_index = parms->starting_idx;
+ cparms.num_entries = parms->num_entries;
+
+ rc = tf_rm_check_indexes_in_range(&cparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s, Invalid or %d index starting from %d"
+ " not in range, type:%d",
+ tf_dir_2_str(parms->dir),
+ parms->starting_idx,
+ parms->num_entries,
+ parms->type);
+ return rc;
}
hparms.rm_db = tbl_db[parms->dir];