/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2020 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
* All rights reserved.
*/
struct tf;
+/** RM return codes */
+#define TF_RM_ALLOCATED_ENTRY_FREE 0
+#define TF_RM_ALLOCATED_ENTRY_IN_USE 1
+#define TF_RM_ALLOCATED_NO_ENTRY_FOUND -1
+
/**
* The Resource Manager (RM) module provides basic DB handling for
* internal resources. These resources exists within the actual device
* The RM DB will work on its initial allocated sizes so the
* capability of dynamically growing a particular resource is not
* possible. If this capability later becomes a requirement then the
- * MAX pool size of the Chip œneeds to be added to the tf_rm_elem_info
+ * MAX pool size of the chip needs to be added to the tf_rm_elem_info
* structure and several new APIs would need to be added to allow for
* growth of a single TF resource type.
*
- * The access functions does not check for NULL pointers as it's a
+ * The access functions do not check for NULL pointers as they are a
* support module, not called directly.
*/
* ULP layer that is not controlled by HCAPI within the Firmware.
*/
enum tf_rm_elem_cfg_type {
- /** No configuration */
+ /**
+ * No configuration
+ */
TF_RM_ELEM_CFG_NULL,
- /** HCAPI 'controlled', uses a Pool for internal storage */
+ /** HCAPI 'controlled', no RM storage so the module
+ * using the RM can chose to handle storage locally.
+ */
TF_RM_ELEM_CFG_HCAPI,
- /** Private thus not HCAPI 'controlled', creates a Pool for storage */
- TF_RM_ELEM_CFG_PRIVATE,
+ /** HCAPI 'controlled', uses a bit allocator pool for internal
+ * storage in the RM.
+ */
+ TF_RM_ELEM_CFG_HCAPI_BA,
/**
- * Shared element thus it belongs to a shared FW Session and
- * is not controlled by the Host.
+ * HCAPI 'controlled', uses a bit allocator pool for internal
+ * storage in the RM but multiple TF types map to a single
+ * HCAPI type. Parent manages the table.
*/
- TF_RM_ELEM_CFG_SHARED,
+ TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
+ /**
+ * HCAPI 'controlled', uses a bit allocator pool for internal
+ * storage in the RM but multiple TF types map to a single
+ * HCAPI type. Child accesses the parent db.
+ */
+ TF_RM_ELEM_CFG_HCAPI_BA_CHILD,
+
+
TF_RM_TYPE_MAX
};
* conversion.
*/
uint16_t hcapi_type;
+
+ /**
+ * if cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD
+ *
+ * Parent Truflow module subtype associated with this resource type.
+ */
+ uint16_t parent_subtype;
+
+ /**
+ * if cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD
+ *
+ * Resource slices. How many slices will fit in the
+ * resource pool chunk size.
+ */
+ uint8_t slices;
+
+ /**
+ * Pool element divider count
+ * If 0 or 1, there is 1:1 correspondence between the RM
+ * BA pool resource element and the HCAPI RM firmware
+ * resource. If > 1, the RM BA pool element has a 1:n
+ * correspondence to the HCAPI RM firmware resource.
+ */
+ uint8_t divider;
};
/**
*/
struct tf_rm_create_db_parms {
/**
- * [in] Device module type. Used for logging purposes.
+ * [in] Module type. Used for logging purposes.
*/
- enum tf_device_module_type type;
+ enum tf_module_type module;
/**
* [in] Receive or transmit direction.
*/
/**
* Resource allocation count array. This array content
* originates from the tf_session_resources that is passed in
- * on session open.
- * Array size is num_elements.
+ * on session open. Array size is num_elements.
*/
uint16_t *alloc_cnt;
/**
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] Module subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
* [in] Pointer to the allocated index in normalized
* form. Normalized means the index has been adjusted,
* available index)
*/
uint32_t priority;
+ /**
+ * [in] Pointer to the allocated index before adjusted.
+ */
+ uint32_t *base_index;
};
/**
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
* [in] Index to free
*/
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
* [in] Index to free
*/
* [in] Pointer to flag that indicates the state of the query
*/
int *allocated;
+ /**
+ * [in] Pointer to the allocated index before adjusted.
+ */
+ uint32_t *base_index;
};
/**
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
* [out] Pointer to the requested allocation information for
- * the specified db_index
+ * the specified subtype
*/
struct tf_rm_alloc_info *info;
};
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
- * [out] Pointer to the hcapi type for the specified db_index
+ * [out] Pointer to the hcapi type for the specified subtype
*/
uint16_t *hcapi_type;
};
*/
void *rm_db;
/**
- * [in] DB Index, indicates which DB entry to perform the
- * action on.
+ * [in] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
*/
- uint16_t db_index;
+ uint16_t subtype;
/**
- * [out] Pointer to the inuse count for the specified db_index
+ * [out] Pointer to the inuse count for the specified subtype
*/
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] TF subtype indicates which DB entry to perform the
+ * action on. (e.g. TF_TCAM_TBL_TYPE_L2_CTXT subtype of module
+ * TF_MODULE_TYPE_TCAM)
+ */
+ uint16_t subtype;
+ /**
+ * [in] Starting index
+ */
+ uint16_t starting_index;
+ /**
+ * [in] number of entries
+ */
+ uint16_t num_entries;
+};
+
/**
* @page rm Resource Manager
*
int tf_rm_create_db(struct tf *tfp,
struct tf_rm_create_db_parms *parms);
+/**
+ * Creates and fills a Resource Manager (RM) DB with requested
+ * elements. The DB is indexed per the parms structure. It only retrieve
+ * allocated resource information for a exist session.
+ *
+ * [in] tfp
+ * Pointer to TF handle, used for HCAPI communication
+ *
+ * [in] parms
+ * Pointer to create parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_rm_create_db_no_reservation(struct tf *tfp,
+ struct tf_rm_create_db_parms *parms);
+
/**
* Closes the Resource Manager (RM) DB and frees all allocated
* resources per the associated database.
*/
int tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms);
+/**
+ * Retrieves all elements allocation information from the Resource
+ * Manager (RM) DB.
+ *
+ * [in] parms
+ * Pointer to get info parameters
+ *
+ * [in] size
+ * number of the elements for the specific module
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_rm_get_all_info(struct tf_rm_get_alloc_info_parms *parms, int size);
+
/**
* Performs a lookup in the Resource Manager DB and retrieves the
* requested HCAPI RM type.
*/
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_ */