+/**
+ * @page ident Identity Management
+ *
+ * @ref tf_alloc_identifier
+ *
+ * @ref tf_free_identifier
+ */
+/**
+ * tf_alloc_identifier parameter definition
+ */
+struct tf_alloc_identifier_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Identifier type
+ */
+ enum tf_identifier_type ident_type;
+ /**
+ * [out] Allocated identifier
+ */
+ uint32_t id;
+};
+
+/**
+ * tf_free_identifier parameter definition
+ */
+struct tf_free_identifier_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Identifier type
+ */
+ enum tf_identifier_type ident_type;
+ /**
+ * [in] ID to free
+ */
+ uint32_t id;
+ /**
+ * (experimental)
+ * [out] Current refcnt after free
+ */
+ uint32_t ref_cnt;
+};
+
+/**
+ * tf_search_identifier parameter definition (experimental)
+ */
+struct tf_search_identifier_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Identifier type
+ */
+ enum tf_identifier_type ident_type;
+ /**
+ * [in] Identifier data to search for
+ */
+ uint32_t search_id;
+ /**
+ * [out] Set if matching identifier found
+ */
+ bool hit;
+ /**
+ * [out] Current ref count after allocation
+ */
+ uint32_t ref_cnt;
+};
+
+/**
+ * allocate identifier resource
+ *
+ * TruFlow core will allocate a free id from the per identifier resource type
+ * pool reserved for the session during tf_open(). No firmware is involved.
+ *
+ * If shadow copy is enabled, the internal ref_cnt is set to 1 in the
+ * shadow table for a newly allocated resource.
+ *
+ * Returns success or failure code.
+ */
+int tf_alloc_identifier(struct tf *tfp,
+ struct tf_alloc_identifier_parms *parms);
+
+/**
+ * free identifier resource
+ *
+ * TruFlow core will return an id back to the per identifier resource type pool
+ * reserved for the session. No firmware is involved. During tf_close, the
+ * complete pool is returned to the firmware.
+ *
+ * additional operation (experimental)
+ * Decrement reference count. Only release resource once refcnt goes to 0 if
+ * shadow copy is enabled.
+ *
+ * Returns success or failure code.
+ */
+int tf_free_identifier(struct tf *tfp,
+ struct tf_free_identifier_parms *parms);
+
+/**
+ * Search identifier resource (experimental)
+ *
+ * If the shadow copy is enabled search_id is used to search for a matching
+ * entry in the shadow table. The shadow table consists of an array of
+ * reference counts indexed by identifier. If a matching entry is found hit is
+ * set to TRUE, refcnt is increased by 1 and returned. Otherwise, hit is
+ * set to false and refcnt is set to 0.
+ *
+ * TODO: we may need a per table internal shadow copy enable flag to stage
+ * the shadow table implementation. We do not need the shadow table for other
+ * tables at this time so we may only want to enable the identifier shadow.
+ *
+ * TODO: remove this pseudocode below added to show that if search fails
+ * we shouldn't allocate a new entry but return.
+ *
+ * identifier alloc (search_en=1)
+ * if (ident is allocated and ref_cnt >=1)
+ * return ident - hit is set, incr refcnt
+ * else (not found)
+ * return
+ *
+ */
+int tf_search_identifier(struct tf *tfp,
+ struct tf_search_identifier_parms *parms);
+
+/**
+ * @page dram_table DRAM Table Scope Interface
+ *
+ * @ref tf_alloc_tbl_scope
+ *
+ * @ref tf_free_tbl_scope
+ *
+ * If we allocate the EEM memory from the core, we need to store it in
+ * the shared session data structure to make sure it can be freed later.
+ * (for example if the PF goes away)
+ *
+ * Current thought is that memory is allocated within core.
+ */
+
+/**
+ * tf_alloc_tbl_scope_parms definition
+ */
+struct tf_alloc_tbl_scope_parms {
+ /**
+ * [in] All Maximum key size required.
+ */
+ uint16_t rx_max_key_sz_in_bits;
+ /**
+ * [in] Maximum Action size required (includes inlined items)
+ */
+ uint16_t rx_max_action_entry_sz_in_bits;
+ /**
+ * [in] Memory size in Megabytes
+ * Total memory size allocated by user to be divided
+ * up for actions, hash, counters. Only inline external actions.
+ * Use this variable or the number of flows, do not set both.
+ */
+ uint32_t rx_mem_size_in_mb;
+ /**
+ * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
+ */
+ uint32_t rx_num_flows_in_k;
+ /**
+ * [in] All Maximum key size required.
+ */
+ uint16_t tx_max_key_sz_in_bits;
+ /**
+ * [in] Maximum Action size required (includes inlined items)
+ */
+ uint16_t tx_max_action_entry_sz_in_bits;
+ /**
+ * [in] Memory size in Megabytes
+ * Total memory size allocated by user to be divided
+ * up for actions, hash, counters. Only inline external actions.
+ */
+ uint32_t tx_mem_size_in_mb;
+ /**
+ * [in] Number of flows * 1000
+ */
+ uint32_t tx_num_flows_in_k;
+ /**
+ * [in] Flush pending HW cached flows every 1/10th of value
+ * set in seconds, both idle and active flows are flushed
+ * from the HW cache. If set to 0, this feature will be disabled.
+ */
+ uint8_t hw_flow_cache_flush_timer;
+ /**
+ * [out] table scope identifier
+ */
+ uint32_t tbl_scope_id;
+};
+/**
+ * tf_free_tbl_scope_parms definition
+ */
+struct tf_free_tbl_scope_parms {
+ /**
+ * [in] table scope identifier
+ */
+ uint32_t tbl_scope_id;
+};
+
+/**
+ * tf_map_tbl_scope_parms definition
+ */
+struct tf_map_tbl_scope_parms {
+ /**
+ * [in] table scope identifier
+ */
+ uint32_t tbl_scope_id;
+ /**
+ * [in] Which parifs are associated with this table scope. Bit 0
+ * indicates parif 0.
+ */
+ uint16_t parif_bitmask;
+};
+
+/**
+ * allocate a table scope
+ *
+ * The scope is a software construct to identify an EEM table. This function will
+ * divide the hash memory/buckets and records according to the device
+ * device constraints based upon calculations using either the number of flows
+ * requested or the size of memory indicated. Other parameters passed in
+ * determine the configuration (maximum key size, maximum external action record
+ * size).
+ *
+ * A single API is used to allocate a common table scope identifier in both
+ * receive and transmit CFA. The scope identifier is common due to nature of
+ * connection tracking sending notifications between RX and TX direction.
+ *
+ * The receive and transmit table access identifiers specify which rings will
+ * be used to initialize table DRAM. The application must ensure mutual
+ * exclusivity of ring usage for table scope allocation and any table update
+ * operations.
+ *
+ * The hash table buckets, EM keys, and EM lookup results are stored in the
+ * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
+ * hash table buckets are stored at the beginning of that memory.
+ *
+ * NOTE: No EM internal setup is done here. On chip EM records are managed
+ * internally by TruFlow core.
+ *
+ * Returns success or failure code.
+ */
+int tf_alloc_tbl_scope(struct tf *tfp,
+ struct tf_alloc_tbl_scope_parms *parms);
+
+/**
+ * map a table scope (legacy device only Wh+/SR)
+ *
+ * Map a table scope to one or more partition interfaces (parifs).
+ * The parif can be remapped in the L2 context lookup for legacy devices. This
+ * API allows a number of parifs to be mapped to the same table scope. On
+ * legacy devices a table scope identifies one of 16 sets of EEM table base
+ * addresses and is associated with a PF communication channel. The associated
+ * PF must be configured for the table scope to operate.
+ *
+ * An L2 context TCAM lookup returns a remapped parif value used to
+ * index into the set of 16 parif_to_pf registers which are used to map to one
+ * of the 16 table scopes. This API allows the user to map the parifs in the
+ * mask to the previously allocated table scope (EEM table).
+
+ * Returns success or failure code.
+ */
+int tf_map_tbl_scope(struct tf *tfp,
+ struct tf_map_tbl_scope_parms *parms);
+/**
+ * free a table scope
+ *
+ * Firmware checks that the table scope ID is owned by the TruFlow
+ * session, verifies that no references to this table scope remains
+ * or Profile TCAM entries for either CFA (RX/TX) direction,
+ * then frees the table scope ID.
+ *
+ * Returns success or failure code.
+ */
+int tf_free_tbl_scope(struct tf *tfp,
+ struct tf_free_tbl_scope_parms *parms);
+
+/**
+ * @page tcam TCAM Access
+ *
+ * @ref tf_search_tcam_entry
+ *
+ * @ref tf_alloc_tcam_entry
+ *
+ * @ref tf_set_tcam_entry
+ *
+ * @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
+ */
+
+/**
+ * tf_search_tcam_entry parameter definition (experimental)
+ */
+struct tf_search_tcam_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+ /**
+ * [in] Key data to match on
+ */
+ uint8_t *key;
+ /**
+ * [in] key size in bits
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [in] Mask data to match on
+ */
+ uint8_t *mask;
+ /**
+ * [in] Priority of entry requested (definition TBD)
+ */
+ uint32_t priority;
+ /**
+ * [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 refcnt after allocation
+ */
+ uint16_t ref_cnt;
+ /**
+ * [in out] The result data from the search is copied here
+ */
+ uint8_t *result;
+ /**
+ * [in out] result size in bits for the result data
+ */
+ uint16_t result_sz_in_bits;
+ /**
+ * [out] Index found
+ */
+ uint16_t idx;
+};
+
+/**
+ * search TCAM entry (experimental)
+ *
+ * Search for a TCAM entry
+ *
+ * This function searches the shadow copy of the TCAM table for a matching
+ * entry. Key and mask must match for hit to be set. Only TruFlow core data
+ * is accessed. If shadow_copy is not enabled, an error is returned.
+ *
+ * Implementation:
+ *
+ * A hash is performed on the key/mask data and mapped to a shadow copy entry
+ * where the full key/mask is populated. If the full key/mask matches the
+ * entry, hit is set, ref_cnt is incremented, and search_status indicates what
+ * action the caller can take regarding setting the entry.
+ *
+ * search_status should be used as follows:
+ * - On Miss, the caller should create a result and call tf_set_tcam_entry with
+ * returned index.
+ *
+ * - On Reject, the hash table is full and the entry cannot be added.
+ *
+ * - On Hit, the result data is returned to the caller. Additionally, the
+ * ref_cnt is updated.
+ *
+ * Also returns success or failure code.
+ */
+int tf_search_tcam_entry(struct tf *tfp,
+ struct tf_search_tcam_entry_parms *parms);
+
+/**
+ * tf_alloc_tcam_entry parameter definition
+ */
+struct tf_alloc_tcam_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+ /**
+ * [in] Enable search for matching entry
+ */
+ uint8_t search_enable;
+ /**
+ * [in] Key data to match on (if search)
+ */
+ uint8_t *key;
+ /**
+ * [in] key size in bits (if search)
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [in] Mask data to match on (if search)
+ */
+ uint8_t *mask;
+ /**
+ * [in] Priority of entry requested (definition TBD)
+ */
+ uint32_t priority;
+ /**
+ * [out] If search, set if matching entry found
+ */
+ uint8_t hit;
+ /**
+ * [out] Current refcnt after allocation
+ */
+ uint16_t ref_cnt;
+ /**
+ * [out] Idx allocated
+ *
+ */
+ uint16_t idx;
+};
+
+/**
+ * allocate TCAM entry
+ *
+ * Allocate a TCAM entry - one of these types:
+ *
+ * L2 Context
+ * Profile TCAM
+ * WC TCAM
+ * VEB TCAM
+ *
+ * This function allocates a TCAM table record. This function
+ * will attempt to allocate a TCAM table entry from the session
+ * owned TCAM entries or search a shadow copy of the TCAM table for a
+ * matching entry if search is enabled. Key, mask and result must match for
+ * hit to be set. Only TruFlow core data is accessed.
+ * A hash table to entry mapping is maintained for search purposes. If
+ * search is not enabled, the first available free entry is returned based
+ * on priority and alloc_cnt is set to 1. If search is enabled and a matching
+ * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
+ * RefCnt is also returned.
+ *
+ * Also returns success or failure code.
+ */
+int tf_alloc_tcam_entry(struct tf *tfp,
+ struct tf_alloc_tcam_entry_parms *parms);
+
+/**
+ * tf_set_tcam_entry parameter definition
+ */
+struct tf_set_tcam_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+ /**
+ * [in] base index of the entry to program
+ */
+ uint16_t idx;
+ /**
+ * [in] struct containing key
+ */
+ uint8_t *key;
+ /**
+ * [in] struct containing mask fields
+ */
+ uint8_t *mask;
+ /**
+ * [in] key size in bits (if search)
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [in] struct containing result
+ */
+ uint8_t *result;
+ /**
+ * [in] struct containing result size in bits
+ */
+ uint16_t result_sz_in_bits;
+};
+
+/**
+ * set TCAM entry
+ *
+ * Program a TCAM table entry for a TruFlow session.
+ *
+ * If the entry has not been allocated, an error will be returned.
+ *
+ * Returns success or failure code.
+ */
+int tf_set_tcam_entry(struct tf *tfp,
+ struct tf_set_tcam_entry_parms *parms);
+
+/**
+ * tf_get_tcam_entry parameter definition
+ */
+struct tf_get_tcam_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+ /**
+ * [in] index of the entry to get
+ */
+ uint16_t idx;
+ /**
+ * [out] struct containing key
+ */
+ uint8_t *key;
+ /**
+ * [out] struct containing mask fields
+ */
+ uint8_t *mask;
+ /**
+ * [in/out] key size in bits
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [out] struct containing result
+ */
+ uint8_t *result;
+ /**
+ * [in/out] struct containing result size in bits
+ */
+ uint16_t result_sz_in_bits;
+};
+
+/**
+ * get TCAM entry
+ *
+ * Program a TCAM table entry for a TruFlow session.
+ *
+ * If the entry has not been allocated, an error will be returned.
+ *
+ * Returns success or failure code.
+ */
+int tf_get_tcam_entry(struct tf *tfp,
+ struct tf_get_tcam_entry_parms *parms);
+
+/**
+ * tf_free_tcam_entry parameter definition
+ */
+struct tf_free_tcam_entry_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+ /**
+ * [in] Index to free
+ */
+ uint16_t idx;
+ /**
+ * [out] reference count after free
+ */
+ uint16_t ref_cnt;
+};
+
+/**
+ * free TCAM entry
+ *
+ * Free TCAM entry.
+ *
+ * Firmware checks to ensure the TCAM entries are owned by the TruFlow
+ * session. TCAM entry will be invalidated. All-ones mask.
+ * writes to hw.
+ *
+ * WCTCAM profile id of 0 must be used to invalidate an entry.
+ *
+ * Returns success or failure code.
+ */
+int tf_free_tcam_entry(struct tf *tfp,
+ struct tf_free_tcam_entry_parms *parms);
+
+#ifdef TF_TCAM_SHARED
+/**
+ * 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
+ *
+ * This API only affects the following TCAM pools within a shared session:
+ *
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
+ *
+ * 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.
+ *
+ * This API is not supported on a non-shared session.
+ *
+ * Returns success or failure code.
+ */
+int tf_move_tcam_shared_entries(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms);
+
+/**
+ * tf_clear_tcam_shared_entries parameter definition
+ */
+struct tf_clear_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;
+};
+
+/**
+ * Clear TCAM shared entries pool
+ *
+ * This API only affects the following TCAM pools within a shared session:
+ *
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
+ *
+ * When called, the indicated WC TCAM high or low pool will be cleared.
+ *
+ * This API is not supported on a non-shared session.
+ *
+ * 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
+ *
+ * @ref tf_alloc_tbl_entry
+ *
+ * @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
+ */
+
+/**
+ * tf_alloc_tbl_entry parameter definition
+ */
+struct tf_alloc_tbl_entry_parms {
+ /**
+ * [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;
+
+ /**
+ * [out] Idx of allocated entry
+ */
+ uint32_t idx;
+};
+
+/**
+ * allocate index table entries
+ *
+ * Internal types:
+ *
+ * Allocate an on chip index table entry or search for a matching
+ * entry of the indicated type for this TruFlow session.
+ *
+ * Allocates an index table record. This function will attempt to
+ * allocate an index table entry.
+ *
+ * External types:
+ *
+ * These are used to allocate inlined action record memory.
+ *
+ * Allocates an external index table action record.
+ *
+ * NOTE:
+ * Implementation of the internals of the external function will be a stack with
+ * push and pop.
+ *
+ * Returns success or failure code.
+ */
+int tf_alloc_tbl_entry(struct tf *tfp,
+ struct tf_alloc_tbl_entry_parms *parms);
+
+/**
+ * tf_free_tbl_entry parameter definition
+ */
+struct tf_free_tbl_entry_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of the allocation type
+ */
+ enum tf_tbl_type type;
+ /**
+ * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+ */
+ uint32_t tbl_scope_id;
+ /**
+ * [in] Index to free
+ */
+ uint32_t idx;
+};
+
+/**
+ * free index table entry
+ *
+ * Used to free a previously allocated table entry.
+ *
+ * Internal types:
+ *
+ * The element is freed and given back to the session pool.
+ *
+ * External types:
+ *
+ * Frees an external index table action record.
+ *
+ * NOTE:
+ * Implementation of the internals of the external table will be a stack with
+ * push and pop.
+ *
+ * Returns success or failure code.
+ */
+int tf_free_tbl_entry(struct tf *tfp,
+ struct tf_free_tbl_entry_parms *parms);
+
+/**
+ * tf_set_tbl_entry parameter definition
+ */
+struct tf_set_tbl_entry_parms {
+ /**
+ * [in] Table scope identifier
+ */
+ uint32_t tbl_scope_id;
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to set
+ */
+ enum tf_tbl_type type;
+ /**
+ * [in] Entry data
+ */
+ uint8_t *data;
+ /**
+ * [in] Entry size
+ */
+ uint16_t data_sz_in_bytes;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+ /**
+ * [in] Entry index to write to
+ */
+ uint32_t idx;
+};
+
+/**
+ * set index table entry
+ *
+ * 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
+ */
+struct tf_get_tbl_entry_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to get
+ */
+ enum tf_tbl_type type;
+ /**
+ * [out] Entry data
+ */
+ uint8_t *data;
+ /**
+ * [in] Entry size
+ */
+ uint16_t data_sz_in_bytes;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+ /**
+ * [in] Entry index to read
+ */
+ uint32_t idx;
+};
+
+/**
+ * get index table entry
+ *
+ * Used to retrieve a previous set index table entry.
+ *
+ * Reads and compares with the shadow table copy (if enabled) (only
+ * for internal objects).
+ *
+ * Returns success or failure code. Failure will be returned if the
+ * provided data buffer is too small for the data type requested.
+ */
+int tf_get_tbl_entry(struct tf *tfp,
+ struct tf_get_tbl_entry_parms *parms);
+
+/**
+ * tf_bulk_get_tbl_entry parameter definition
+ */
+struct tf_bulk_get_tbl_entry_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to get
+ */
+ enum tf_tbl_type type;
+ /**
+ * [in] Starting index to read from
+ */
+ uint32_t starting_idx;
+ /**
+ * [in] Number of sequential entries
+ */
+ uint16_t num_entries;
+ /**
+ * [in] Size of the single entry
+ */
+ uint16_t entry_sz_in_bytes;
+ /**
+ * [out] Host physical address, where the data
+ * will be copied to by the firmware.
+ * Use tfp_calloc() API and mem_pa
+ * variable of the tfp_calloc_parms
+ * structure for the physical address.
+ */
+ uint64_t physical_mem_addr;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+};
+
+/**
+ * Bulk get index table entry
+ *
+ * Used to retrieve a set of index table entries.
+ *
+ * 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.
+ */
+int tf_bulk_get_tbl_entry(struct tf *tfp,
+ struct tf_bulk_get_tbl_entry_parms *parms);
+
+/**
+ * @page exact_match Exact Match Table
+ *
+ * @ref tf_insert_em_entry
+ *
+ * @ref tf_delete_em_entry
+ *
+ * @ref tf_search_em_entry
+ *
+ */
+/**
+ * tf_insert_em_entry parameter definition
+ */
+struct tf_insert_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] ptr to structure containing key fields
+ */
+ uint8_t *key;
+ /**
+ * [in] key bit length
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [in] ptr to structure containing result field
+ */
+ uint8_t *em_record;
+ /**
+ * [out] result size in bits
+ */
+ uint16_t em_record_sz_in_bits;
+ /**
+ * [in] duplicate check flag
+ */
+ uint8_t dup_check;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+ /**
+ * [out] Flow handle value for the inserted entry. This is encoded
+ * as the entries[4]:bucket[2]:hashId[1]:hash[14]
+ */
+ uint64_t flow_handle;
+ /**
+ * [out] Flow id is returned as null (internal)
+ * Flow id is the GFID value for the inserted entry (external)
+ * This is the value written to the BD and useful information for mark.
+ */
+ uint64_t flow_id;
+};
+/**
+ * tf_delete_em_entry parameter definition
+ */
+struct tf_delete_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;
+ /**
+ * [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] structure containing flow delete handle information
+ */
+ uint64_t flow_handle;
+};
+/**
+ * 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 {
+ /**
+ * [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] ptr to structure containing key fields
+ */
+ uint8_t *key;
+ /**
+ * [in] key bit length
+ */
+ uint16_t key_sz_in_bits;
+ /**
+ * [in/out] ptr to structure containing EM record fields
+ */
+ uint8_t *em_record;
+ /**
+ * [out] result size in bits
+ */
+ uint16_t em_record_sz_in_bits;
+ /**
+ * [in] External memory channel type to use
+ */
+ enum tf_ext_mem_chan_type chan_type;
+ /**
+ * [in] ptr to structure containing flow delete handle
+ */
+ uint64_t flow_handle;
+};
+
+/**
+ * insert em hash entry in internal table memory
+ *
+ * Internal:
+ *
+ * This API inserts an exact match entry into internal EM table memory
+ * of the specified direction.
+ *
+ * Note: The EM record is managed within the TruFlow core and not the
+ * application.
+ *
+ * Shadow copy of internal record table an association with hash and 1,2, or 4
+ * associated buckets
+ *
+ * External:
+ * This API inserts an exact match entry into DRAM EM table memory of the
+ * specified direction and table scope.
+ *
+ * The insertion of duplicate entries in an EM table is not permitted. If a
+ * TruFlow application can guarantee that it will never insert duplicates, it
+ * can disable duplicate checking by passing a zero value in the dup_check
+ * parameter to this API. This will optimize performance. Otherwise, the
+ * TruFlow library will enforce protection against inserting duplicate entries.
+ *
+ * Flow handle is defined in this document:
+ *
+ * https://docs.google.com
+ * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
+ *
+ * Returns success or busy code.
+ *
+ */
+int tf_insert_em_entry(struct tf *tfp,
+ struct tf_insert_em_entry_parms *parms);
+
+/**
+ * delete em hash entry table memory
+ *
+ * Internal:
+ *
+ * This API deletes an exact match entry from internal EM table memory of the
+ * specified direction. If a valid flow ptr is passed in then that takes
+ * precedence over the pointer to the complete key passed in.
+ *
+ *
+ * External:
+ *
+ * This API deletes an exact match entry from EM table memory of the specified
+ * direction and table scope. If a valid flow handle is passed in then that
+ * takes precedence over the pointer to the complete key passed in.
+ *
+ * The TruFlow library may release a dynamic bucket when an entry is deleted.
+ *
+ *
+ * Returns success or not found code
+ *
+ *
+ */
+int tf_delete_em_entry(struct tf *tfp,
+ struct tf_delete_em_entry_parms *parms);
+
+/**
+ * search em hash entry table memory (Future)
+ *
+ * Internal:
+
+ * This API looks up an EM entry in table memory with the specified EM
+ * key or flow (flow takes precedence) and direction.
+ *
+ * The status will be one of: success or entry not found. If the lookup
+ * succeeds, a pointer to the matching entry and the result record associated
+ * with the matching entry will be provided.
+ *
+ * If flow_handle is set, search shadow copy.
+ *
+ * Otherwise, query the fw with key to get result.
+ *
+ * External:
+ *
+ * This API looks up an EM entry in table memory with the specified EM
+ * key or flow_handle (flow takes precedence), direction and table scope.
+ *
+ * The status will be one of: success or entry not found. If the lookup
+ * succeeds, a pointer to the matching entry and the result record associated
+ * with the matching entry will be provided.
+ *
+ * Returns success or not found code
+ *
+ */
+int tf_search_em_entry(struct tf *tfp,
+ struct tf_search_em_entry_parms *parms);
+
+/**
+ * @page global Global Configuration
+ *
+ * @ref tf_set_global_cfg
+ *
+ * @ref tf_get_global_cfg
+ */
+/**
+ * Tunnel Encapsulation Offsets
+ */
+enum tf_tunnel_encap_offsets {
+ TF_TUNNEL_ENCAP_L2,
+ TF_TUNNEL_ENCAP_NAT,
+ TF_TUNNEL_ENCAP_MPLS,
+ TF_TUNNEL_ENCAP_VXLAN,
+ TF_TUNNEL_ENCAP_GENEVE,
+ TF_TUNNEL_ENCAP_NVGRE,
+ TF_TUNNEL_ENCAP_GRE,
+ TF_TUNNEL_ENCAP_FULL_GENERIC
+};
+/**
+ * Global Configuration Table Types
+ */
+enum tf_global_config_type {
+ 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
+};
+
+/**
+ * tf_global_cfg parameter definition
+ */
+struct tf_global_cfg_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Global config type
+ */
+ enum tf_global_config_type type;
+ /**
+ * [in] Offset @ the type
+ */
+ uint32_t offset;
+ /**
+ * [in/out] Value of the configuration
+ * set - Read, Modify and Write
+ * get - Read the full configuration
+ */
+ uint8_t *config;
+ /**
+ * [in] Configuration mask
+ * set - Read, Modify with mask and Write
+ * get - unused
+ */
+ uint8_t *config_mask;
+ /**
+ * [in] struct containing size
+ */
+ uint16_t config_sz_in_bytes;
+};
+
+/**
+ * Get global configuration
+ *
+ * Retrieve the configuration
+ *
+ * Returns success or failure code.
+ */
+int tf_get_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms);
+
+/**
+ * Update the global configuration table
+ *
+ * Read, modify write the value.
+ *
+ * Returns success or failure code.
+ */
+int tf_set_global_cfg(struct tf *tfp,
+ struct tf_global_cfg_parms *parms);
+
+/**
+ * @page if_tbl Interface Table Access
+ *
+ * @ref tf_set_if_tbl_entry
+ *
+ * @ref tf_get_if_tbl_entry
+ *
+ * @ref tf_restore_if_tbl_entry
+ */
+/**
+ * Enumeration of TruFlow interface table types.
+ */
+enum tf_if_tbl_type {
+ /** Default Profile L2 Context Entry */
+ TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
+ /** Default Profile TCAM/Lookup Action Record Pointer Table */
+ TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
+ /** Error Profile TCAM Miss Action Record Pointer Table */
+ TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
+ /** Default Error Profile TCAM Miss Action Record Pointer Table */
+ TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
+ /** Ingress lookup table */
+ TF_IF_TBL_TYPE_ILT,
+ /** VNIC/SVIF Properties Table */
+ TF_IF_TBL_TYPE_VSPT,
+ TF_IF_TBL_TYPE_MAX
+};
+
+/**
+ * tf_set_if_tbl_entry parameter definition
+ */
+struct tf_set_if_tbl_entry_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to set
+ */
+ enum tf_if_tbl_type type;
+ /**
+ * [in] Entry data
+ */
+ uint8_t *data;
+ /**
+ * [in] Entry size
+ */
+ uint16_t data_sz_in_bytes;
+ /**
+ * [in] Interface to write
+ */
+ uint32_t idx;
+};
+
+/**
+ * set interface table entry
+ *
+ * Used to set an interface table. This API is used for managing tables indexed
+ * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
+ * set.
+ * Returns success or failure code.
+ */
+int tf_set_if_tbl_entry(struct tf *tfp,
+ struct tf_set_if_tbl_entry_parms *parms);
+
+/**
+ * tf_get_if_tbl_entry parameter definition
+ */
+struct tf_get_if_tbl_entry_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of table to get
+ */
+ enum tf_if_tbl_type type;
+ /**
+ * [out] Entry data
+ */
+ uint8_t *data;
+ /**
+ * [in] Entry size
+ */
+ uint16_t data_sz_in_bytes;
+ /**
+ * [in] Entry index to read
+ */
+ uint32_t idx;
+};
+
+/**
+ * get interface table entry
+ *
+ * Used to retrieve an interface table entry.
+ *
+ * Reads the interface table entry value
+ *
+ * Returns success or failure code. Failure will be returned if the
+ * provided data buffer is too small for the data type requested.
+ */
+int tf_get_if_tbl_entry(struct tf *tfp,
+ struct tf_get_if_tbl_entry_parms *parms);
+