/********** BEGIN Truflow Core DEFINITIONS **********/
-
#define TF_KILOBYTE 1024
#define TF_MEGABYTE (1024 * 1024)
TF_EXT_MEM_CHAN_TYPE_MAX
};
+/**
+ * WC TCAM number of slice per row that devices supported
+ */
+enum tf_wc_num_slice {
+ TF_WC_TCAM_1_SLICE_PER_ROW = 1,
+ TF_WC_TCAM_2_SLICE_PER_ROW = 2,
+ TF_WC_TCAM_4_SLICE_PER_ROW = 4,
+ TF_WC_TCAM_8_SLICE_PER_ROW = 8,
+};
+
/**
* EEM record AR helper
*
#define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
#define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
-
/*
* Helper Macros
*/
TF_MODULE_TYPE_MAX
};
-
/**
* Identifier resource types
*/
*/
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.
*/
TF_TBL_TYPE_ACT_MODIFY_32B,
/** TH 64B Modify Record */
TF_TBL_TYPE_ACT_MODIFY_64B,
- /** (Future) Meter Profiles */
+ /** Meter Profiles */
TF_TBL_TYPE_METER_PROF,
- /** (Future) Meter Instance */
+ /** Meter Instance */
TF_TBL_TYPE_METER_INST,
/** Wh+/SR/Th Mirror Config */
TF_TBL_TYPE_MIRROR_CONFIG,
TF_TBL_TYPE_EM_FKB,
/** TH WC Flexible Key builder */
TF_TBL_TYPE_WC_FKB,
+ /** Meter Drop Counter */
+ TF_TBL_TYPE_METER_DROP_CNT,
/* External */
TF_TBL_TYPE_MAX
};
+/** Enable Shared TCAM Management
+ *
+ * This feature allows for management of high and low pools within
+ * the WC TCAM. These pools are only valid when this feature is enabled.
+ *
+ * For normal OVS-DPDK operation, this feature is not required and can
+ * be disabled by commenting out TF_TCAM_SHARED in this header file.
+ *
+ * Operation:
+ *
+ * When a shared session is created with WC TCAM entries allocated during
+ * tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided
+ * into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW.
+ *
+ * The user will allocate and free entries from either of these pools to obtain
+ * WC_TCAM entry offsets. For the WC_TCAM_HI/LO management, alloc/free is done
+ * using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared
+ * session.
+ *
+ * The use case for this feature is so that applications can have a shared
+ * session and use the TF core to allocate/set/free entries within a given
+ * region of the WC_TCAM within the shared session. Application A only writes
+ * to the LOW region for example and Application B only writes to the HIGH
+ * region during normal operation. After Application A goes down, Application
+ * B may decide to overwrite the LOW region with the HIGH region's entries
+ * and switch to the low region.
+ *
+ * For other TCAM types in the shared session, no alloc/free operations are
+ * permitted. Only set should be used for other TCAM table types after getting
+ * the range as provided by the tf_get_resource_info() API.
+ *
+ */
+#define TF_TCAM_SHARED 1
+
/**
* TCAM table type
*/
TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
/** Virtual Edge Bridge TCAM */
TF_TCAM_TBL_TYPE_VEB_TCAM,
+#ifdef TF_TCAM_SHARED
+ /** Wildcard TCAM HI Priority */
+ TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
+ /** Wildcard TCAM Low Priority */
+ TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
+#endif /* TF_TCAM_SHARED */
TF_TCAM_TBL_TYPE_MAX
};
enum tf_em_tbl_type {
/** The number of internal EM records for the session */
TF_EM_TBL_TYPE_EM_RECORD,
- /** The number of table scopes reequested */
+ /** The number of table scopes requested */
TF_EM_TBL_TYPE_TBL_SCOPE,
TF_EM_TBL_TYPE_MAX
};
*/
struct tf_session_info {
/**
- * TrueFlow Version. Used to control the structure layout when
+ * TruFlow Version. Used to control the structure layout when
* sharing sessions. No guarantee that a secondary process
* would come from the same version of an executable.
* TruFlow initializes this variable on tf_open_session().
*/
struct tf {
struct tf_session_info *session;
+ /**
+ * the pointer to the parent bp struct
+ */
+ void *bp;
};
/**
struct tf_tbl_resources {
/**
* Array of TF Table types where each entry is expected to be
- * set to the requeste resource number of that specific
+ * set to the requested resource number of that specific
* type. The index used is tf_tbl_type.
*/
uint16_t cnt[TF_TBL_TYPE_MAX];
* rte_eth_dev_get_name_by_port() within the ULP.
*
* ctrl_chan_name will be used as part of a name for any
- * shared memory allocation.
+ * shared memory allocation. The ctrl_chan_name is usually in format
+ * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared.
*/
char ctrl_chan_name[TF_SESSION_NAME_MAX];
/**
* Resource allocation for the session.
*/
struct tf_session_resources resources;
+
+ /**
+ * [in] bp
+ * The pointer to the parent bp struct. This is only used for HWRM
+ * message passing within the portability layer. The type is struct
+ * bnxt.
+ */
+ void *bp;
+
+ /**
+ * [in]
+ *
+ * The number of slices per row for WC TCAM entry.
+ */
+ enum tf_wc_num_slice wc_num_slices;
+
+ /**
+ * [out] shared_session_creator
+ *
+ * Indicates whether the application created the session if set.
+ * Otherwise the shared session already existed. Just for information
+ * purposes.
+ */
+ int shared_session_creator;
};
/**
* Opens a new TruFlow Session or session client.
*
- * What gets created depends on the passed in tfp content. If the tfp
- * does not have prior session data a new session with associated
- * session client. If tfp has a session already a session client will
- * be created. In both cases the session client is created using the
- * provided ctrl_chan_name.
+ * What gets created depends on the passed in tfp content. If the tfp does not
+ * have prior session data a new session with associated session client. If tfp
+ * has a session already a session client will be created. In both cases the
+ * session client is created using the provided ctrl_chan_name.
*
- * In case of session creation TruFlow will allocate session specific
- * memory, shared memory, to hold its session data. This data is
- * private to TruFlow.
+ * In case of session creation TruFlow will allocate session specific memory to
+ * hold its session data. This data is private to TruFlow.
*
* No other TruFlow APIs will succeed unless this API is first called
* and succeeds.
*
- * tf_open_session() returns a session id and session client id that
- * is used on all other TF APIs.
+ * tf_open_session() returns a session id and session client id. These are
+ * also stored within the tfp structure passed in to all other APIs.
*
* A Session or session client can be closed using tf_close_session().
*
+ * There are 2 types of sessions - shared and not. For non-shared all
+ * the allocated resources are owned and managed by a single session instance.
+ * No other applications have access to the resources owned by the non-shared
+ * session. For a shared session, resources are shared between 2 applications.
+ *
+ * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name
+ * like "0000:02:00.0-tf_shared", it is a request to create a new "shared"
+ * session in the firmware or access the existing shared session. There is
+ * only 1 shared session that can be created. If the shared session has
+ * already been created in the firmware, this API will return this indication
+ * by clearing the shared_session_creator flag. Only the first shared session
+ * create will have the shared_session_creator flag set.
+ *
+ * The shared session should always be the first session to be created by
+ * application and the last session closed due to RM management preference.
+ *
+ * Sessions remain open in the firmware until the last client of the session
+ * closes the session (tf_close_session()).
+ *
* [in] tfp
* Pointer to TF handle
*
int tf_open_session(struct tf *tfp,
struct tf_open_session_parms *parms);
+/**
+ * General internal resource info
+ *
+ */
+struct tf_resource_info {
+ uint16_t start;
+ uint16_t stride;
+};
+
+/**
+ * Identifier resource definition
+ */
+struct tf_identifier_resource_info {
+ /**
+ * Array of TF Identifiers. The index used is tf_identifier_type.
+ */
+ struct tf_resource_info info[TF_IDENT_TYPE_MAX];
+};
+
+/**
+ * Table type resource info definition
+ */
+struct tf_tbl_resource_info {
+ /**
+ * Array of TF Table types. The index used is tf_tbl_type.
+ */
+ struct tf_resource_info info[TF_TBL_TYPE_MAX];
+};
+
+/**
+ * TCAM type resource definition
+ */
+struct tf_tcam_resource_info {
+ /**
+ * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
+ */
+ struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
+};
+
+/**
+ * EM type resource definition
+ */
+struct tf_em_resource_info {
+ /**
+ * Array of TF EM table types. The index used is tf_em_tbl_type.
+ */
+ struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
+};
+
+/**
+ * tf_session_resources parameter definition.
+ */
+struct tf_session_resource_info {
+ /**
+ * [in] Requested Identifier Resources
+ *
+ * Number of identifier resources requested for the
+ * session.
+ */
+ struct tf_identifier_resource_info ident[TF_DIR_MAX];
+ /**
+ * [in] Requested Index Table resource counts
+ *
+ * The number of index table resources requested for the
+ * session.
+ */
+ struct tf_tbl_resource_info tbl[TF_DIR_MAX];
+ /**
+ * [in] Requested TCAM Table resource counts
+ *
+ * The number of TCAM table resources requested for the
+ * session.
+ */
+
+ struct tf_tcam_resource_info tcam[TF_DIR_MAX];
+ /**
+ * [in] Requested EM resource counts
+ *
+ * The number of internal EM table resources requested for the
+ * session.
+ */
+ struct tf_em_resource_info em[TF_DIR_MAX];
+};
+
+/**
+ * tf_get_session_resources parameter definition.
+ */
+struct tf_get_session_info_parms {
+ /**
+ * [out] the structure is used to return the information of
+ * allocated resources.
+ *
+ */
+ struct tf_session_resource_info session_info;
+};
+
+/** (experimental)
+ * Gets info about a TruFlow Session
+ *
+ * Get info about the session which has been created. Whether it exists and
+ * what resource start and stride offsets are in use. This API is primarily
+ * intended to be used by an application which has created a shared session
+ * This application needs to obtain the resources which have already been
+ * allocated for the shared session.
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to get parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_get_session_info(struct tf *tfp,
+ struct tf_get_session_info_parms *parms);
/**
* Experimental
*
* Current thought is that memory is allocated within core.
*/
-
/**
* tf_alloc_tbl_scope_parms definition
*/
* [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
*/
uint32_t rx_num_flows_in_k;
- /**
- * [in] SR2 only receive table access interface id
- */
- uint32_t rx_tbl_if_id;
/**
* [in] All Maximum key size required.
*/
* [in] Number of flows * 1000
*/
uint32_t tx_num_flows_in_k;
- /**
- * [in] SR2 only receive table access interface id
- */
- uint32_t tx_tbl_if_id;
/**
* [in] Flush pending HW cached flows every 1/10th of value
* set in seconds, both idle and active flows are flushed
* @ref tf_get_tcam_entry
*
* @ref tf_free_tcam_entry
+ *
+#ifdef TF_TCAM_SHARED
+ * @ref tf_move_tcam_shared_entries
+ *
+ * @ref tf_clear_tcam_shared_entries
+#endif
*/
/**
int tf_free_tcam_entry(struct tf *tfp,
struct tf_free_tcam_entry_parms *parms);
+#ifdef TF_TCAM_SHARED
/**
- * @page table Table Access
+ * tf_move_tcam_shared_entries parameter definition
+ */
+struct tf_move_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;
+};
+
+/**
+ * Move TCAM entries
*
- * @ref tf_alloc_tbl_entry
+ * This API only affects the following TCAM pools within a shared session:
*
- * @ref tf_free_tbl_entry
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
*
- * @ref tf_set_tbl_entry
+ * When called, all allocated entries from the high pool will be moved to
+ * the low pool. Then the allocated entries in the high pool will be
+ * cleared and freed.
*
- * @ref tf_get_tbl_entry
+ * This API is not supported on a non-shared session.
*
- * @ref tf_bulk_get_tbl_entry
+ * Returns success or failure code.
*/
+int tf_move_tcam_shared_entries(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms);
/**
- * tf_alloc_tbl_entry parameter definition
+ * tf_clear_tcam_shared_entries parameter definition
*/
-struct tf_search_tbl_entry_parms {
+struct tf_clear_tcam_shared_entries_parms {
/**
- * [in] Receive or transmit direction
+ * [in] receive or transmit direction
*/
enum tf_dir dir;
/**
- * [in] Type of the allocation
- */
- enum tf_tbl_type type;
- /**
- * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
- */
- uint32_t tbl_scope_id;
- /**
- * [in] Result data to search for
- */
- uint8_t *result;
- /**
- * [in] Result data size in bytes
- */
- uint16_t result_sz_in_bytes;
- /**
- * [in] Allocate on miss.
- */
- uint8_t alloc;
- /**
- * [out] Set if matching entry found
- */
- uint8_t hit;
- /**
- * [out] Search result status (hit, miss, reject)
- */
- enum tf_search_status search_status;
- /**
- * [out] Current ref count after allocation
- */
- uint16_t ref_cnt;
- /**
- * [out] Idx of allocated entry or found entry
+ * [in] TCAM table type
*/
- uint32_t idx;
+ enum tf_tcam_tbl_type tcam_tbl_type;
};
/**
- * search Table Entry (experimental)
+ * Clear TCAM shared entries pool
*
- * This function searches the shadow copy of an index table for a matching
- * entry. The result data must match for hit to be set. Only TruFlow core
- * data is accessed. If shadow_copy is not enabled, an error is returned.
+ * This API only affects the following TCAM pools within a shared session:
*
- * Implementation:
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
*
- * A hash is performed on the result data and mappe3d to a shadow copy entry
- * where the result is populated. If the result matches the entry, hit is set,
- * ref_cnt is incremented (if alloc), and the search status indicates what
- * action the caller can take regarding setting the entry.
+ * When called, the indicated WC TCAM high or low pool will be cleared.
*
- * search status should be used as follows:
- * - On MISS, the caller should set the result into the returned index.
+ * This API is not supported on a non-shared session.
*
- * - On REJECT, the caller should reject the flow since there are no resources.
+ * 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
*
- * - On Hit, the matching index is returned to the caller. Additionally, the
- * ref_cnt is updated.
+ * @ref tf_alloc_tbl_entry
*
- * Also returns success or failure code.
+ * @ref tf_free_tbl_entry
+ *
+ * @ref tf_set_tbl_entry
+ *
+ * @ref tf_get_tbl_entry
+ *
+ * @ref tf_bulk_get_tbl_entry
+ *
+ * @ref tf_get_shared_tbl_increment
*/
-int tf_search_tbl_entry(struct tf *tfp,
- struct tf_search_tbl_entry_parms *parms);
/**
* tf_alloc_tbl_entry parameter definition
* [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
*/
uint32_t tbl_scope_id;
+
/**
- * [in] Enable search for matching entry. If the table type is
- * internal the shadow copy will be searched before
- * alloc. Session must be configured with shadow copy enabled.
- */
- uint8_t search_enable;
- /**
- * [in] Result data to search for (if search_enable)
- */
- uint8_t *result;
- /**
- * [in] Result data size in bytes (if search_enable)
- */
- uint16_t result_sz_in_bytes;
- /**
- * [out] If search_enable, set if matching entry found
- */
- uint8_t hit;
- /**
- * [out] Current ref count after allocation (if search_enable)
- */
- uint16_t ref_cnt;
- /**
- * [out] Idx of allocated entry or found entry (if search_enable)
+ * [out] Idx of allocated entry
*/
uint32_t idx;
};
* entry of the indicated type for this TruFlow session.
*
* Allocates an index table record. This function will attempt to
- * allocate an entry or search an index table for a matching entry if
- * search is enabled (only the shadow copy of the table is accessed).
- *
- * If search is not enabled, the first available free entry is
- * returned. If search is enabled and a matching entry to entry_data
- * is found hit is set to TRUE and success is returned.
+ * allocate an index table entry.
*
* External types:
*
* Allocates an external index table action record.
*
* NOTE:
- * Implementation of the internals of this function will be a stack with push
- * and pop.
+ * Implementation of the internals of the external function will be a stack with
+ * push and pop.
*
* Returns success or failure code.
*/
* [in] Index to free
*/
uint32_t idx;
- /**
- * [out] Reference count after free, only valid if session has been
- * created with shadow_copy.
- */
- uint16_t ref_cnt;
};
/**
*
* Internal types:
*
- * If session has shadow_copy enabled the shadow DB is searched and if
- * found the element ref_cnt is decremented. If ref_cnt goes to
- * zero then the element is returned to the session pool.
- *
- * If the session does not have a shadow DB the element is free'ed and
- * given back to the session pool.
+ * The element is freed and given back to the session pool.
*
* External types:
*
- * Free's an external index table action record.
+ * Frees an external index table action record.
*
* NOTE:
- * Implementation of the internals of this function will be a stack with push
- * and pop.
+ * Implementation of the internals of the external table will be a stack with
+ * push and pop.
*
* Returns success or failure code.
*/
/**
* set index table entry
*
- * Used to insert an application programmed index table entry into a
- * previous allocated table location. A shadow copy of the table
- * is maintained (if enabled) (only for internal objects)
+ * Used to set an application programmed index table entry into a
+ * previous allocated table location.
*
* Returns success or failure code.
*/
int tf_set_tbl_entry(struct tf *tfp,
struct tf_set_tbl_entry_parms *parms);
+/**
+ * tf_get_shared_tbl_increment parameter definition
+ */
+struct tf_get_shared_tbl_increment_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to set
+ */
+ enum tf_tbl_type type;
+ /**
+ * [out] Value to increment by for resource type
+ */
+ uint32_t increment_cnt;
+};
+
+/**
+ * tf_get_shared_tbl_increment
+ *
+ * This API is currently only required for use in the shared
+ * session for Thor (p58) actions. An increment count is returned per
+ * type to indicate how much to increment the start by for each
+ * entry (see tf_resource_info)
+ *
+ * Returns success or failure code.
+ */
+int tf_get_shared_tbl_increment(struct tf *tfp,
+ struct tf_get_shared_tbl_increment_parms *parms);
+
/**
* tf_get_tbl_entry parameter definition
*/
uint64_t flow_handle;
};
/**
- * tf_search_em_entry parameter definition
+ * tf_move_em_entry parameter definition
+ */
+struct tf_move_em_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] internal or external
+ */
+ enum tf_mem mem;
+ /**
+ * [in] ID of table scope to use (external only)
+ */
+ uint32_t tbl_scope_id;
+ /**
+ * [in] ID of table interface to use (SR2 only)
+ */
+ uint32_t tbl_if_id;
+ /**
+ * [in] epoch group IDs of entry to delete
+ * 2 element array with 2 ids. (SR2 only)
+ */
+ uint16_t *epochs;
+ /**
+ * [out] The index of the entry
+ */
+ uint16_t index;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+ /**
+ * [in] The index of the new EM record
+ */
+ uint32_t new_index;
+ /**
+ * [in] structure containing flow delete handle information
+ */
+ uint64_t flow_handle;
+};
+/**
+ * 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:
TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */
TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */
TF_COUNTER_CFG, /**< Counter Configuration (CNTRS_CTRL) */
+ TF_METER_CFG, /**< Meter Config(ACTP4_FMTCR) */
+ TF_METER_INTERVAL_CFG, /**< Meter Interval Config(FMTCR_INTERVAL) */
TF_GLOBAL_CFG_TYPE_MAX
};