1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
14 #include "tf_project.h"
19 * Truflow Core API Header File
22 /********** BEGIN Truflow Core DEFINITIONS **********/
25 #define TF_KILOBYTE 1024
26 #define TF_MEGABYTE (1024 * 1024)
32 TF_DIR_RX, /**< Receive */
33 TF_DIR_TX, /**< Transmit */
41 TF_MEM_INTERNAL, /**< Internal */
42 TF_MEM_EXTERNAL, /**< External */
47 * EEM record AR helper
49 * Helper to handle the Action Record Pointer in the EEM Record Entry.
51 * Convert absolute offset to action record pointer in EEM record entry
52 * Convert action record pointer in EEM record entry to absolute offset
54 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
55 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
60 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
62 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
65 * @page general General
67 * @ref tf_open_session
69 * @ref tf_attach_session
71 * @ref tf_close_session
76 * Session Version defines
78 * The version controls the format of the tf_session and
79 * tf_session_info structure. This is to assure upgrade between
80 * versions can be supported.
82 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
83 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
84 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
89 * Name of the TruFlow control channel interface. Expects
90 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
92 #define TF_SESSION_NAME_MAX 64
94 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
99 * Unique session identifier which includes PCIe bus info to
100 * distinguish the PF and session info to identify the associated
101 * TruFlow session. Session ID is constructed from the passed in
102 * ctrl_chan_name in tf_open_session() together with an allocated
103 * fw_session_id. Done by TruFlow on tf_open_session().
105 union tf_session_id {
111 uint8_t fw_session_id;
118 * The version controls the format of the tf_session and
119 * tf_session_info structure. This is to assure upgrade between
120 * versions can be supported.
122 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
124 struct tf_session_version {
131 * Session supported device types
133 enum tf_device_type {
134 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
135 TF_DEVICE_TYPE_BRD2, /**< TBD */
136 TF_DEVICE_TYPE_BRD3, /**< TBD */
137 TF_DEVICE_TYPE_BRD4, /**< TBD */
138 TF_DEVICE_TYPE_MAX /**< Maximum */
141 /** Identifier resource types
143 enum tf_identifier_type {
144 /** The L2 Context is returned from the L2 Ctxt TCAM lookup
145 * and can be used in WC TCAM or EM keys to virtualize further
148 TF_IDENT_TYPE_L2_CTXT,
149 /** The WC profile func is returned from the L2 Ctxt TCAM lookup
150 * to enable virtualization of the profile TCAM.
152 TF_IDENT_TYPE_PROF_FUNC,
153 /** The WC profile ID is included in the WC lookup key
154 * to enable virtualization of the WC TCAM hardware.
156 TF_IDENT_TYPE_WC_PROF,
157 /** The EM profile ID is included in the EM lookup key
158 * to enable virtualization of the EM hardware. (not required for SR2
159 * as it has table scope)
161 TF_IDENT_TYPE_EM_PROF,
162 /** The L2 func is included in the ILT result and from recycling to
163 * enable virtualization of further lookups.
165 TF_IDENT_TYPE_L2_FUNC,
170 * Enumeration of TruFlow table types. A table type is used to identify a
173 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
174 * the only table type that is connected with a table scope.
179 /** Wh+/SR Action Record */
180 TF_TBL_TYPE_FULL_ACT_RECORD,
181 /** Wh+/SR/Th Multicast Groups */
182 TF_TBL_TYPE_MCAST_GROUPS,
183 /** Wh+/SR Action Encap 8 Bytes */
184 TF_TBL_TYPE_ACT_ENCAP_8B,
185 /** Wh+/SR Action Encap 16 Bytes */
186 TF_TBL_TYPE_ACT_ENCAP_16B,
187 /** Action Encap 32 Bytes */
188 TF_TBL_TYPE_ACT_ENCAP_32B,
189 /** Wh+/SR Action Encap 64 Bytes */
190 TF_TBL_TYPE_ACT_ENCAP_64B,
191 /** Action Source Properties SMAC */
192 TF_TBL_TYPE_ACT_SP_SMAC,
193 /** Wh+/SR Action Source Properties SMAC IPv4 */
194 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
195 /** Action Source Properties SMAC IPv6 */
196 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
197 /** Wh+/SR Action Statistics 64 Bits */
198 TF_TBL_TYPE_ACT_STATS_64,
199 /** Wh+/SR Action Modify L4 Src Port */
200 TF_TBL_TYPE_ACT_MODIFY_SPORT,
201 /** Wh+/SR Action Modify L4 Dest Port */
202 TF_TBL_TYPE_ACT_MODIFY_DPORT,
203 /** Wh+/SR Action Modify IPv4 Source */
204 TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
205 /** Wh+/SR Action _Modify L4 Dest Port */
206 TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
207 /** Action Modify IPv6 Source */
208 TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
209 /** Action Modify IPv6 Destination */
210 TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
211 /** Meter Profiles */
212 TF_TBL_TYPE_METER_PROF,
213 /** Meter Instance */
214 TF_TBL_TYPE_METER_INST,
216 TF_TBL_TYPE_MIRROR_CONFIG,
219 /** SR2 Epoch 0 table */
221 /** SR2 Epoch 1 table */
224 TF_TBL_TYPE_METADATA,
226 TF_TBL_TYPE_CT_STATE,
227 /** SR2 Range Profile */
228 TF_TBL_TYPE_RANGE_PROF,
229 /** SR2 Range Entry */
230 TF_TBL_TYPE_RANGE_ENTRY,
233 /** SR2 VNIC/SVIF Table */
234 TF_TBL_TYPE_VNIC_SVIF,
235 /** Th/SR2 EM Flexible Key builder */
237 /** Th/SR2 WC Flexible Key builder */
242 /** External table type - initially 1 poolsize entries.
243 * All External table types are associated with a table
244 * scope. Internal types are not.
253 enum tf_tcam_tbl_type {
254 /** L2 Context TCAM */
255 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
257 TF_TCAM_TBL_TYPE_PROF_TCAM,
259 TF_TCAM_TBL_TYPE_WC_TCAM,
260 /** Source Properties TCAM */
261 TF_TCAM_TBL_TYPE_SP_TCAM,
262 /** Connection Tracking Rule TCAM */
263 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
264 /** Virtual Edge Bridge TCAM */
265 TF_TCAM_TBL_TYPE_VEB_TCAM,
271 * These defines are provisioned during
274 enum tf_em_tbl_type {
275 /** The number of internal EM records for the session */
276 TF_EM_TBL_TYPE_EM_RECORD,
277 /** The number of table scopes reequested */
278 TF_EM_TBL_TYPE_TBL_SCOPE,
282 /** TruFlow Session Information
284 * Structure defining a TruFlow Session, also known as a Management
285 * session. This structure is initialized at time of
286 * tf_open_session(). It is passed to all of the TruFlow APIs as way
287 * to prescribe and isolate resources between different TruFlow ULP
290 struct tf_session_info {
292 * TrueFlow Version. Used to control the structure layout when
293 * sharing sessions. No guarantee that a secondary process
294 * would come from the same version of an executable.
295 * TruFlow initializes this variable on tf_open_session().
300 struct tf_session_version ver;
302 * will be STAILQ_ENTRY(tf_session_info) next
309 * Session ID is a unique identifier for the session. TruFlow
310 * initializes this variable during tf_open_session()
314 * Access: Truflow & ULP
316 union tf_session_id session_id;
318 * Protects access to core_data. Lock is initialized and owned
319 * by ULP. TruFlow can access the core_data without checking
327 * The core_data holds the TruFlow tf_session data
328 * structure. This memory is allocated and owned by TruFlow on
331 * TruFlow uses this memory for session management control
332 * until the session is closed by ULP. Access control is done
333 * by the spin_lock which ULP controls ahead of TruFlow API
336 * Please see tf_open_session_parms for specification details
344 * The core_data_sz_bytes specifies the size of core_data in
347 * The size is set by TruFlow on tf_open_session().
349 * Please see tf_open_session_parms for specification details
355 uint32_t core_data_sz_bytes;
360 * Contains a pointer to the session info. Allocated by ULP and passed
361 * to TruFlow using tf_open_session(). TruFlow will populate the
362 * session info at that time. Additional 'opens' can be done using
363 * same session_info by using tf_attach_session().
365 * It is expected that ULP allocates this memory as shared memory.
367 * NOTE: This struct must be within the BNXT PMD struct bnxt
368 * (bp). This allows use of container_of() to get access to the PMD.
371 struct tf_session_info *session;
375 * tf_session_resources parameter definition.
377 struct tf_session_resources {
378 /** [in] Requested Identifier Resources
380 * The number of identifier resources requested for the session.
381 * The index used is tf_identifier_type.
383 uint16_t identifer_cnt[TF_DIR_MAX][TF_IDENT_TYPE_MAX];
384 /** [in] Requested Index Table resource counts
386 * The number of index table resources requested for the session.
387 * The index used is tf_tbl_type.
389 uint16_t tbl_cnt[TF_TBL_TYPE_MAX][TF_DIR_MAX];
390 /** [in] Requested TCAM Table resource counts
392 * The number of TCAM table resources requested for the session.
393 * The index used is tf_tcam_tbl_type.
395 uint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX][TF_DIR_MAX];
396 /** [in] Requested EM resource counts
398 * The number of internal EM table resources requested for the session
399 * The index used is tf_em_tbl_type.
401 uint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX][TF_DIR_MAX];
405 * tf_open_session parameters definition.
407 struct tf_open_session_parms {
408 /** [in] ctrl_chan_name
410 * String containing name of control channel interface to be
411 * used for this session to communicate with firmware.
413 * The ctrl_chan_name can be looked up by using
414 * rte_eth_dev_get_name_by_port() within the ULP.
416 * ctrl_chan_name will be used as part of a name for any
417 * shared memory allocation.
419 char ctrl_chan_name[TF_SESSION_NAME_MAX];
422 * Boolean controlling the use and availability of shadow
423 * copy. Shadow copy will allow the TruFlow to keep track of
424 * resource content on the firmware side without having to
425 * query firmware. Additional private session core_data will
426 * be allocated if this boolean is set to 'true', default
429 * Size of memory depends on the NVM Resource settings for the
433 /** [in/out] session_id
435 * Session_id is unique per session.
437 * Session_id is composed of domain, bus, device and
438 * fw_session_id. The construction is done by parsing the
439 * ctrl_chan_name together with allocation of a fw_session_id.
441 * The session_id allows a session to be shared between devices.
443 union tf_session_id session_id;
446 * Device type is passed, one of Wh+, SR, Thor, SR2
448 enum tf_device_type device_type;
451 * Resource allocation
453 struct tf_session_resources resources;
457 * Opens a new TruFlow management session.
459 * TruFlow will allocate session specific memory, shared memory, to
460 * hold its session data. This data is private to TruFlow.
462 * Multiple PFs can share the same session. An association, refcount,
463 * between session and PFs is maintained within TruFlow. Thus, a PF
464 * can attach to an existing session, see tf_attach_session().
466 * No other TruFlow APIs will succeed unless this API is first called and
469 * tf_open_session() returns a session id that can be used on attach.
472 * Pointer to TF handle
474 * Pointer to open parameters
477 * - (0) if successful.
478 * - (-EINVAL) on failure.
480 int tf_open_session(struct tf *tfp,
481 struct tf_open_session_parms *parms);
483 struct tf_attach_session_parms {
484 /** [in] ctrl_chan_name
486 * String containing name of control channel interface to be
487 * used for this session to communicate with firmware.
489 * The ctrl_chan_name can be looked up by using
490 * rte_eth_dev_get_name_by_port() within the ULP.
492 * ctrl_chan_name will be used as part of a name for any
493 * shared memory allocation.
495 char ctrl_chan_name[TF_SESSION_NAME_MAX];
497 /** [in] attach_chan_name
499 * String containing name of attach channel interface to be
500 * used for this session.
502 * The attach_chan_name must be given to a 2nd process after
503 * the primary process has been created. This is the
504 * ctrl_chan_name of the primary process and is used to find
505 * the shared memory for the session that the attach is going
508 char attach_chan_name[TF_SESSION_NAME_MAX];
512 * Session_id is unique per session. For Attach the session_id
513 * should be the session_id that was returned on the first
516 * Session_id is composed of domain, bus, device and
517 * fw_session_id. The construction is done by parsing the
518 * ctrl_chan_name together with allocation of a fw_session_id
519 * during tf_open_session().
521 * A reference count will be incremented on attach. A session
522 * is first fully closed when reference count is zero by
523 * calling tf_close_session().
525 union tf_session_id session_id;
529 * Attaches to an existing session. Used when more than one PF wants
530 * to share a single session. In that case all TruFlow management
531 * traffic will be sent to the TruFlow firmware using the 'PF' that
532 * did the attach not the session ctrl channel.
534 * Attach will increment a ref count as to manage the shared session data.
536 * [in] tfp, pointer to TF handle
537 * [in] parms, pointer to attach parameters
540 * - (0) if successful.
541 * - (-EINVAL) on failure.
543 int tf_attach_session(struct tf *tfp,
544 struct tf_attach_session_parms *parms);
547 * Closes an existing session. Cleans up all hardware and firmware
548 * state associated with the TruFlow application session when the last
549 * PF associated with the session results in refcount to be zero.
551 * Returns success or failure code.
553 int tf_close_session(struct tf *tfp);
556 * @page ident Identity Management
558 * @ref tf_alloc_identifier
560 * @ref tf_free_identifier
562 /** tf_alloc_identifier parameter definition
564 struct tf_alloc_identifier_parms {
566 * [in] receive or transmit direction
570 * [in] Identifier type
572 enum tf_identifier_type ident_type;
574 * [out] Identifier allocated
579 /** tf_free_identifier parameter definition
581 struct tf_free_identifier_parms {
583 * [in] receive or transmit direction
587 * [in] Identifier type
589 enum tf_identifier_type ident_type;
596 /** allocate identifier resource
598 * TruFlow core will allocate a free id from the per identifier resource type
599 * pool reserved for the session during tf_open(). No firmware is involved.
601 * Returns success or failure code.
603 int tf_alloc_identifier(struct tf *tfp,
604 struct tf_alloc_identifier_parms *parms);
606 /** free identifier resource
608 * TruFlow core will return an id back to the per identifier resource type pool
609 * reserved for the session. No firmware is involved. During tf_close, the
610 * complete pool is returned to the firmware.
612 * Returns success or failure code.
614 int tf_free_identifier(struct tf *tfp,
615 struct tf_free_identifier_parms *parms);
618 * @page dram_table DRAM Table Scope Interface
620 * @ref tf_alloc_tbl_scope
622 * @ref tf_free_tbl_scope
624 * If we allocate the EEM memory from the core, we need to store it in
625 * the shared session data structure to make sure it can be freed later.
626 * (for example if the PF goes away)
628 * Current thought is that memory is allocated within core.
632 /** tf_alloc_tbl_scope_parms definition
634 struct tf_alloc_tbl_scope_parms {
636 * [in] All Maximum key size required.
638 uint16_t rx_max_key_sz_in_bits;
640 * [in] Maximum Action size required (includes inlined items)
642 uint16_t rx_max_action_entry_sz_in_bits;
644 * [in] Memory size in Megabytes
645 * Total memory size allocated by user to be divided
646 * up for actions, hash, counters. Only inline external actions.
647 * Use this variable or the number of flows, do not set both.
649 uint32_t rx_mem_size_in_mb;
651 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
653 uint32_t rx_num_flows_in_k;
655 * [in] Brd4 only receive table access interface id
657 uint32_t rx_tbl_if_id;
659 * [in] All Maximum key size required.
661 uint16_t tx_max_key_sz_in_bits;
663 * [in] Maximum Action size required (includes inlined items)
665 uint16_t tx_max_action_entry_sz_in_bits;
667 * [in] Memory size in Megabytes
668 * Total memory size allocated by user to be divided
669 * up for actions, hash, counters. Only inline external actions.
671 uint32_t tx_mem_size_in_mb;
673 * [in] Number of flows * 1000
675 uint32_t tx_num_flows_in_k;
677 * [in] Brd4 only receive table access interface id
679 uint32_t tx_tbl_if_id;
681 * [in] Flush pending HW cached flows every 1/10th of value
682 * set in seconds, both idle and active flows are flushed
683 * from the HW cache. If set to 0, this feature will be disabled.
685 uint8_t hw_flow_cache_flush_timer;
687 * [out] table scope identifier
689 uint32_t tbl_scope_id;
692 struct tf_free_tbl_scope_parms {
694 * [in] table scope identifier
696 uint32_t tbl_scope_id;
700 * allocate a table scope
702 * On Brd4 Firmware will allocate a scope ID. On other devices, the scope
703 * is a software construct to identify an EEM table. This function will
704 * divide the hash memory/buckets and records according to the device
705 * device constraints based upon calculations using either the number of flows
706 * requested or the size of memory indicated. Other parameters passed in
707 * determine the configuration (maximum key size, maximum external action record
710 * This API will allocate the table region in
711 * DRAM, program the PTU page table entries, and program the number of static
712 * buckets (if Brd4) in the RX and TX CFAs. Buckets are assumed to start at
713 * 0 in the EM memory for the scope. Upon successful completion of this API,
714 * hash tables are fully initialized and ready for entries to be inserted.
716 * A single API is used to allocate a common table scope identifier in both
717 * receive and transmit CFA. The scope identifier is common due to nature of
718 * connection tracking sending notifications between RX and TX direction.
720 * The receive and transmit table access identifiers specify which rings will
721 * be used to initialize table DRAM. The application must ensure mutual
722 * exclusivity of ring usage for table scope allocation and any table update
725 * The hash table buckets, EM keys, and EM lookup results are stored in the
726 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
727 * hash table buckets are stored at the beginning of that memory.
729 * NOTE: No EM internal setup is done here. On chip EM records are managed
730 * internally by TruFlow core.
732 * Returns success or failure code.
734 int tf_alloc_tbl_scope(struct tf *tfp,
735 struct tf_alloc_tbl_scope_parms *parms);
741 * Firmware checks that the table scope ID is owned by the TruFlow
742 * session, verifies that no references to this table scope remains
743 * (Brd4 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
744 * then frees the table scope ID.
746 * Returns success or failure code.
748 int tf_free_tbl_scope(struct tf *tfp,
749 struct tf_free_tbl_scope_parms *parms);
753 * @page tcam TCAM Access
755 * @ref tf_alloc_tcam_entry
757 * @ref tf_set_tcam_entry
759 * @ref tf_get_tcam_entry
761 * @ref tf_free_tcam_entry
764 /** tf_alloc_tcam_entry parameter definition
766 struct tf_alloc_tcam_entry_parms {
768 * [in] receive or transmit direction
772 * [in] TCAM table type
774 enum tf_tcam_tbl_type tcam_tbl_type;
776 * [in] Enable search for matching entry
778 uint8_t search_enable;
780 * [in] Key data to match on (if search)
784 * [in] key size in bits (if search)
786 uint16_t key_sz_in_bits;
788 * [in] Mask data to match on (if search)
792 * [in] Priority of entry requested (definition TBD)
796 * [out] If search, set if matching entry found
800 * [out] Current refcnt after allocation
804 * [out] Idx allocated
810 /** allocate TCAM entry
812 * Allocate a TCAM entry - one of these types:
819 * This function allocates a TCAM table record. This function
820 * will attempt to allocate a TCAM table entry from the session
821 * owned TCAM entries or search a shadow copy of the TCAM table for a
822 * matching entry if search is enabled. Key, mask and result must match for
823 * hit to be set. Only TruFlow core data is accessed.
824 * A hash table to entry mapping is maintained for search purposes. If
825 * search is not enabled, the first available free entry is returned based
826 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
827 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
828 * RefCnt is also returned.
830 * Also returns success or failure code.
832 int tf_alloc_tcam_entry(struct tf *tfp,
833 struct tf_alloc_tcam_entry_parms *parms);
835 /** tf_set_tcam_entry parameter definition
837 struct tf_set_tcam_entry_parms {
839 * [in] receive or transmit direction
843 * [in] TCAM table type
845 enum tf_tcam_tbl_type tcam_tbl_type;
847 * [in] base index of the entry to program
851 * [in] struct containing key
855 * [in] struct containing mask fields
859 * [in] key size in bits (if search)
861 uint16_t key_sz_in_bits;
863 * [in] struct containing result
867 * [in] struct containing result size in bits
869 uint16_t result_sz_in_bits;
874 * Program a TCAM table entry for a TruFlow session.
876 * If the entry has not been allocated, an error will be returned.
878 * Returns success or failure code.
880 int tf_set_tcam_entry(struct tf *tfp,
881 struct tf_set_tcam_entry_parms *parms);
883 /** tf_get_tcam_entry parameter definition
885 struct tf_get_tcam_entry_parms {
887 * [in] receive or transmit direction
891 * [in] TCAM table type
893 enum tf_tcam_tbl_type tcam_tbl_type;
895 * [in] index of the entry to get
899 * [out] struct containing key
903 * [out] struct containing mask fields
907 * [out] key size in bits
909 uint16_t key_sz_in_bits;
911 * [out] struct containing result
915 * [out] struct containing result size in bits
917 uint16_t result_sz_in_bits;
923 * Program a TCAM table entry for a TruFlow session.
925 * If the entry has not been allocated, an error will be returned.
927 * Returns success or failure code.
929 int tf_get_tcam_entry(struct tf *tfp,
930 struct tf_get_tcam_entry_parms *parms);
933 * tf_free_tcam_entry parameter definition
935 struct tf_free_tcam_entry_parms {
937 * [in] receive or transmit direction
941 * [in] TCAM table type
943 enum tf_tcam_tbl_type tcam_tbl_type;
949 * [out] reference count after free
957 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
958 * session. TCAM entry will be invalidated. All-ones mask.
961 * WCTCAM profile id of 0 must be used to invalidate an entry.
963 * Returns success or failure code.
965 int tf_free_tcam_entry(struct tf *tfp,
966 struct tf_free_tcam_entry_parms *parms);
969 * @page table Table Access
971 * @ref tf_alloc_tbl_entry
973 * @ref tf_free_tbl_entry
975 * @ref tf_set_tbl_entry
977 * @ref tf_get_tbl_entry
981 * tf_alloc_tbl_entry parameter definition
983 struct tf_alloc_tbl_entry_parms {
985 * [in] Receive or transmit direction
989 * [in] Type of the allocation
991 enum tf_tbl_type type;
993 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
995 uint32_t tbl_scope_id;
997 * [in] Enable search for matching entry. If the table type is
998 * internal the shadow copy will be searched before
999 * alloc. Session must be configured with shadow copy enabled.
1001 uint8_t search_enable;
1003 * [in] Result data to search for (if search_enable)
1007 * [in] Result data size in bytes (if search_enable)
1009 uint16_t result_sz_in_bytes;
1011 * [out] If search_enable, set if matching entry found
1015 * [out] Current ref count after allocation (if search_enable)
1019 * [out] Idx of allocated entry or found entry (if search_enable)
1025 * allocate index table entries
1029 * Allocate an on chip index table entry or search for a matching
1030 * entry of the indicated type for this TruFlow session.
1032 * Allocates an index table record. This function will attempt to
1033 * allocate an entry or search an index table for a matching entry if
1034 * search is enabled (only the shadow copy of the table is accessed).
1036 * If search is not enabled, the first available free entry is
1037 * returned. If search is enabled and a matching entry to entry_data
1038 * is found hit is set to TRUE and success is returned.
1042 * These are used to allocate inlined action record memory.
1044 * Allocates an external index table action record.
1047 * Implementation of the internals of this function will be a stack with push
1050 * Returns success or failure code.
1052 int tf_alloc_tbl_entry(struct tf *tfp,
1053 struct tf_alloc_tbl_entry_parms *parms);
1056 * tf_free_tbl_entry parameter definition
1058 struct tf_free_tbl_entry_parms {
1060 * [in] Receive or transmit direction
1064 * [in] Type of the allocation type
1066 enum tf_tbl_type type;
1068 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1070 uint32_t tbl_scope_id;
1072 * [in] Index to free
1076 * [out] Reference count after free, only valid if session has been
1077 * created with shadow_copy.
1083 * free index table entry
1085 * Used to free a previously allocated table entry.
1089 * If session has shadow_copy enabled the shadow DB is searched and if
1090 * found the element ref_cnt is decremented. If ref_cnt goes to
1091 * zero then the element is returned to the session pool.
1093 * If the session does not have a shadow DB the element is free'ed and
1094 * given back to the session pool.
1098 * Free's an external index table action record.
1101 * Implementation of the internals of this function will be a stack with push
1104 * Returns success or failure code.
1106 int tf_free_tbl_entry(struct tf *tfp,
1107 struct tf_free_tbl_entry_parms *parms);
1110 * tf_set_tbl_entry parameter definition
1112 struct tf_set_tbl_entry_parms {
1114 * [in] Table scope identifier
1116 uint32_t tbl_scope_id;
1118 * [in] Receive or transmit direction
1122 * [in] Type of object to set
1124 enum tf_tbl_type type;
1132 uint16_t data_sz_in_bytes;
1134 * [in] Entry index to write to
1140 * set index table entry
1142 * Used to insert an application programmed index table entry into a
1143 * previous allocated table location. A shadow copy of the table
1144 * is maintained (if enabled) (only for internal objects)
1146 * Returns success or failure code.
1148 int tf_set_tbl_entry(struct tf *tfp,
1149 struct tf_set_tbl_entry_parms *parms);
1152 * tf_get_tbl_entry parameter definition
1154 struct tf_get_tbl_entry_parms {
1156 * [in] Receive or transmit direction
1160 * [in] Type of object to get
1162 enum tf_tbl_type type;
1170 uint16_t data_sz_in_bytes;
1172 * [in] Entry index to read
1178 * get index table entry
1180 * Used to retrieve a previous set index table entry.
1182 * Reads and compares with the shadow table copy (if enabled) (only
1183 * for internal objects).
1185 * Returns success or failure code. Failure will be returned if the
1186 * provided data buffer is too small for the data type requested.
1188 int tf_get_tbl_entry(struct tf *tfp,
1189 struct tf_get_tbl_entry_parms *parms);
1192 * tf_get_bulk_tbl_entry parameter definition
1194 struct tf_get_bulk_tbl_entry_parms {
1196 * [in] Receive or transmit direction
1200 * [in] Type of object to get
1202 enum tf_tbl_type type;
1204 * [in] Clear hardware entries on reads only
1205 * supported for TF_TBL_TYPE_ACT_STATS_64
1209 * [in] Starting index to read from
1211 uint32_t starting_idx;
1213 * [in] Number of sequential entries
1215 uint16_t num_entries;
1217 * [in] Size of the single entry
1219 uint16_t entry_sz_in_bytes;
1221 * [out] Host physical address, where the data
1222 * will be copied to by the firmware.
1223 * Use tfp_calloc() API and mem_pa
1224 * variable of the tfp_calloc_parms
1225 * structure for the physical address.
1227 uint64_t physical_mem_addr;
1231 * Bulk get index table entry
1233 * Used to retrieve a previous set index table entry.
1235 * Reads and compares with the shadow table copy (if enabled) (only
1236 * for internal objects).
1238 * Returns success or failure code. Failure will be returned if the
1239 * provided data buffer is too small for the data type requested.
1241 int tf_get_bulk_tbl_entry(struct tf *tfp,
1242 struct tf_get_bulk_tbl_entry_parms *parms);
1245 * @page exact_match Exact Match Table
1247 * @ref tf_insert_em_entry
1249 * @ref tf_delete_em_entry
1251 * @ref tf_search_em_entry
1255 * tf_insert_em_entry parameter definition
1257 struct tf_insert_em_entry_parms {
1259 * [in] receive or transmit direction
1263 * [in] internal or external
1267 * [in] ID of table scope to use (external only)
1269 uint32_t tbl_scope_id;
1271 * [in] ID of table interface to use (Brd4 only)
1275 * [in] ptr to structure containing key fields
1279 * [in] key bit length
1281 uint16_t key_sz_in_bits;
1283 * [in] ptr to structure containing result field
1287 * [out] result size in bits
1289 uint16_t em_record_sz_in_bits;
1291 * [in] duplicate check flag
1295 * [out] Flow handle value for the inserted entry. This is encoded
1296 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1298 uint64_t flow_handle;
1300 * [out] Flow id is returned as null (internal)
1301 * Flow id is the GFID value for the inserted entry (external)
1302 * This is the value written to the BD and useful information for mark.
1307 * tf_delete_em_entry parameter definition
1309 struct tf_delete_em_entry_parms {
1311 * [in] receive or transmit direction
1315 * [in] internal or external
1319 * [in] ID of table scope to use (external only)
1321 uint32_t tbl_scope_id;
1323 * [in] ID of table interface to use (Brd4 only)
1327 * [in] epoch group IDs of entry to delete
1328 * 2 element array with 2 ids. (Brd4 only)
1332 * [out] The index of the entry
1336 * [in] structure containing flow delete handle information
1338 uint64_t flow_handle;
1341 * tf_search_em_entry parameter definition
1343 struct tf_search_em_entry_parms {
1345 * [in] receive or transmit direction
1349 * [in] internal or external
1353 * [in] ID of table scope to use (external only)
1355 uint32_t tbl_scope_id;
1357 * [in] ID of table interface to use (Brd4 only)
1361 * [in] ptr to structure containing key fields
1365 * [in] key bit length
1367 uint16_t key_sz_in_bits;
1369 * [in/out] ptr to structure containing EM record fields
1373 * [out] result size in bits
1375 uint16_t em_record_sz_in_bits;
1377 * [in] epoch group IDs of entry to lookup
1378 * 2 element array with 2 ids. (Brd4 only)
1382 * [in] ptr to structure containing flow delete handle
1384 uint64_t flow_handle;
1388 * insert em hash entry in internal table memory
1392 * This API inserts an exact match entry into internal EM table memory
1393 * of the specified direction.
1395 * Note: The EM record is managed within the TruFlow core and not the
1398 * Shadow copy of internal record table an association with hash and 1,2, or 4
1399 * associated buckets
1402 * This API inserts an exact match entry into DRAM EM table memory of the
1403 * specified direction and table scope.
1405 * When inserting an entry into an exact match table, the TruFlow library may
1406 * need to allocate a dynamic bucket for the entry (Brd4 only).
1408 * The insertion of duplicate entries in an EM table is not permitted. If a
1409 * TruFlow application can guarantee that it will never insert duplicates, it
1410 * can disable duplicate checking by passing a zero value in the dup_check
1411 * parameter to this API. This will optimize performance. Otherwise, the
1412 * TruFlow library will enforce protection against inserting duplicate entries.
1414 * Flow handle is defined in this document:
1416 * https://docs.google.com
1417 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1419 * Returns success or busy code.
1422 int tf_insert_em_entry(struct tf *tfp,
1423 struct tf_insert_em_entry_parms *parms);
1426 * delete em hash entry table memory
1430 * This API deletes an exact match entry from internal EM table memory of the
1431 * specified direction. If a valid flow ptr is passed in then that takes
1432 * precedence over the pointer to the complete key passed in.
1437 * This API deletes an exact match entry from EM table memory of the specified
1438 * direction and table scope. If a valid flow handle is passed in then that
1439 * takes precedence over the pointer to the complete key passed in.
1441 * The TruFlow library may release a dynamic bucket when an entry is deleted.
1444 * Returns success or not found code
1448 int tf_delete_em_entry(struct tf *tfp,
1449 struct tf_delete_em_entry_parms *parms);
1452 * search em hash entry table memory
1456 * This API looks up an EM entry in table memory with the specified EM
1457 * key or flow (flow takes precedence) and direction.
1459 * The status will be one of: success or entry not found. If the lookup
1460 * succeeds, a pointer to the matching entry and the result record associated
1461 * with the matching entry will be provided.
1463 * If flow_handle is set, search shadow copy.
1465 * Otherwise, query the fw with key to get result.
1469 * This API looks up an EM entry in table memory with the specified EM
1470 * key or flow_handle (flow takes precedence), direction and table scope.
1472 * The status will be one of: success or entry not found. If the lookup
1473 * succeeds, a pointer to the matching entry and the result record associated
1474 * with the matching entry will be provided.
1476 * Returns success or not found code
1479 int tf_search_em_entry(struct tf *tfp,
1480 struct tf_search_em_entry_parms *parms);
1481 #endif /* _TF_CORE_H_ */