1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
13 #include "hcapi/hcapi_cfa.h"
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)
61 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
63 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
66 * @page general General
68 * @ref tf_open_session
70 * @ref tf_attach_session
72 * @ref tf_close_session
77 * Session Version defines
79 * The version controls the format of the tf_session and
80 * tf_session_info structure. This is to assure upgrade between
81 * versions can be supported.
83 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
84 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
85 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
90 * Name of the TruFlow control channel interface. Expects
91 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
93 #define TF_SESSION_NAME_MAX 64
95 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
100 * Unique session identifier which includes PCIe bus info to
101 * distinguish the PF and session info to identify the associated
102 * TruFlow session. Session ID is constructed from the passed in
103 * ctrl_chan_name in tf_open_session() together with an allocated
104 * fw_session_id. Done by TruFlow on tf_open_session().
106 union tf_session_id {
112 uint8_t fw_session_id;
119 * The version controls the format of the tf_session and
120 * tf_session_info structure. This is to assure upgrade between
121 * versions can be supported.
123 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
125 struct tf_session_version {
132 * Session supported device types
134 enum tf_device_type {
135 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
136 TF_DEVICE_TYPE_SR, /**< Stingray */
137 TF_DEVICE_TYPE_THOR, /**< Thor */
138 TF_DEVICE_TYPE_SR2, /**< Stingray2 */
139 TF_DEVICE_TYPE_MAX /**< Maximum */
143 * Identifier resource types
145 enum tf_identifier_type {
147 * The L2 Context is returned from the L2 Ctxt TCAM lookup
148 * and can be used in WC TCAM or EM keys to virtualize further
151 TF_IDENT_TYPE_L2_CTXT,
153 * The WC profile func is returned from the L2 Ctxt TCAM lookup
154 * to enable virtualization of the profile TCAM.
156 TF_IDENT_TYPE_PROF_FUNC,
158 * The WC profile ID is included in the WC lookup key
159 * to enable virtualization of the WC TCAM hardware.
161 TF_IDENT_TYPE_WC_PROF,
163 * The EM profile ID is included in the EM lookup key
164 * to enable virtualization of the EM hardware. (not required for SR2
165 * as it has table scope)
167 TF_IDENT_TYPE_EM_PROF,
169 * The L2 func is included in the ILT result and from recycling to
170 * enable virtualization of further lookups.
172 TF_IDENT_TYPE_L2_FUNC,
177 * Enumeration of TruFlow table types. A table type is used to identify a
180 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
181 * the only table type that is connected with a table scope.
186 /** Wh+/SR Action Record */
187 TF_TBL_TYPE_FULL_ACT_RECORD,
188 /** Wh+/SR/Th Multicast Groups */
189 TF_TBL_TYPE_MCAST_GROUPS,
190 /** Wh+/SR Action Encap 8 Bytes */
191 TF_TBL_TYPE_ACT_ENCAP_8B,
192 /** Wh+/SR Action Encap 16 Bytes */
193 TF_TBL_TYPE_ACT_ENCAP_16B,
194 /** Action Encap 32 Bytes */
195 TF_TBL_TYPE_ACT_ENCAP_32B,
196 /** Wh+/SR Action Encap 64 Bytes */
197 TF_TBL_TYPE_ACT_ENCAP_64B,
198 /** Action Source Properties SMAC */
199 TF_TBL_TYPE_ACT_SP_SMAC,
200 /** Wh+/SR Action Source Properties SMAC IPv4 */
201 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
202 /** Action Source Properties SMAC IPv6 */
203 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
204 /** Wh+/SR Action Statistics 64 Bits */
205 TF_TBL_TYPE_ACT_STATS_64,
206 /** Wh+/SR Action Modify L4 Src Port */
207 TF_TBL_TYPE_ACT_MODIFY_SPORT,
208 /** Wh+/SR Action Modify L4 Dest Port */
209 TF_TBL_TYPE_ACT_MODIFY_DPORT,
210 /** Wh+/SR Action Modify IPv4 Source */
211 TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
212 /** Wh+/SR Action _Modify L4 Dest Port */
213 TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
214 /** Action Modify IPv6 Source */
215 TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
216 /** Action Modify IPv6 Destination */
217 TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
218 /** Meter Profiles */
219 TF_TBL_TYPE_METER_PROF,
220 /** Meter Instance */
221 TF_TBL_TYPE_METER_INST,
223 TF_TBL_TYPE_MIRROR_CONFIG,
226 /** SR2 Epoch 0 table */
228 /** SR2 Epoch 1 table */
231 TF_TBL_TYPE_METADATA,
233 TF_TBL_TYPE_CT_STATE,
234 /** SR2 Range Profile */
235 TF_TBL_TYPE_RANGE_PROF,
236 /** SR2 Range Entry */
237 TF_TBL_TYPE_RANGE_ENTRY,
240 /** SR2 VNIC/SVIF Table */
241 TF_TBL_TYPE_VNIC_SVIF,
242 /** Th/SR2 EM Flexible Key builder */
244 /** Th/SR2 WC Flexible Key builder */
250 * External table type - initially 1 poolsize entries.
251 * All External table types are associated with a table
252 * scope. Internal types are not.
261 enum tf_tcam_tbl_type {
262 /** L2 Context TCAM */
263 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
265 TF_TCAM_TBL_TYPE_PROF_TCAM,
267 TF_TCAM_TBL_TYPE_WC_TCAM,
268 /** Source Properties TCAM */
269 TF_TCAM_TBL_TYPE_SP_TCAM,
270 /** Connection Tracking Rule TCAM */
271 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
272 /** Virtual Edge Bridge TCAM */
273 TF_TCAM_TBL_TYPE_VEB_TCAM,
279 * These defines are provisioned during
282 enum tf_em_tbl_type {
283 /** The number of internal EM records for the session */
284 TF_EM_TBL_TYPE_EM_RECORD,
285 /** The number of table scopes reequested */
286 TF_EM_TBL_TYPE_TBL_SCOPE,
291 * TruFlow Session Information
293 * Structure defining a TruFlow Session, also known as a Management
294 * session. This structure is initialized at time of
295 * tf_open_session(). It is passed to all of the TruFlow APIs as way
296 * to prescribe and isolate resources between different TruFlow ULP
299 * Ownership of the elements is split between ULP and TruFlow. Please
300 * see the individual elements.
302 struct tf_session_info {
304 * TrueFlow Version. Used to control the structure layout when
305 * sharing sessions. No guarantee that a secondary process
306 * would come from the same version of an executable.
307 * TruFlow initializes this variable on tf_open_session().
312 struct tf_session_version ver;
314 * will be STAILQ_ENTRY(tf_session_info) next
321 * Session ID is a unique identifier for the session. TruFlow
322 * initializes this variable during tf_open_session()
326 * Access: Truflow & ULP
328 union tf_session_id session_id;
330 * Protects access to core_data. Lock is initialized and owned
331 * by ULP. TruFlow can access the core_data without checking
339 * The core_data holds the TruFlow tf_session data
340 * structure. This memory is allocated and owned by TruFlow on
343 * TruFlow uses this memory for session management control
344 * until the session is closed by ULP. Access control is done
345 * by the spin_lock which ULP controls ahead of TruFlow API
348 * Please see tf_open_session_parms for specification details
356 * The core_data_sz_bytes specifies the size of core_data in
359 * The size is set by TruFlow on tf_open_session().
361 * Please see tf_open_session_parms for specification details
367 uint32_t core_data_sz_bytes;
373 * Contains a pointer to the session info. Allocated by ULP and passed
374 * to TruFlow using tf_open_session(). TruFlow will populate the
375 * session info at that time. Additional 'opens' can be done using
376 * same session_info by using tf_attach_session().
378 * It is expected that ULP allocates this memory as shared memory.
380 * NOTE: This struct must be within the BNXT PMD struct bnxt
381 * (bp). This allows use of container_of() to get access to the PMD.
384 struct tf_session_info *session;
388 * Identifier resource definition
390 struct tf_identifier_resources {
392 * Array of TF Identifiers where each entry is expected to be
393 * set to the requested resource number of that specific type.
394 * The index used is tf_identifier_type.
396 uint16_t cnt[TF_IDENT_TYPE_MAX];
400 * Table type resource definition
402 struct tf_tbl_resources {
404 * Array of TF Table types where each entry is expected to be
405 * set to the requeste resource number of that specific
406 * type. The index used is tf_tbl_type.
408 uint16_t cnt[TF_TBL_TYPE_MAX];
412 * TCAM type resource definition
414 struct tf_tcam_resources {
416 * Array of TF TCAM types where each entry is expected to be
417 * set to the requested resource number of that specific
418 * type. The index used is tf_tcam_tbl_type.
420 uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
424 * EM type resource definition
426 struct tf_em_resources {
428 * Array of TF EM table types where each entry is expected to
429 * be set to the requested resource number of that specific
430 * type. The index used is tf_em_tbl_type.
432 uint16_t cnt[TF_EM_TBL_TYPE_MAX];
436 * tf_session_resources parameter definition.
438 struct tf_session_resources {
440 * [in] Requested Identifier Resources
442 * Number of identifier resources requested for the
445 struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
447 * [in] Requested Index Table resource counts
449 * The number of index table resources requested for the
452 struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
454 * [in] Requested TCAM Table resource counts
456 * The number of TCAM table resources requested for the
460 struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
462 * [in] Requested EM resource counts
464 * The number of internal EM table resources requested for the
467 struct tf_em_resources em_cnt[TF_DIR_MAX];
471 * tf_open_session parameters definition.
473 struct tf_open_session_parms {
475 * [in] ctrl_chan_name
477 * String containing name of control channel interface to be
478 * used for this session to communicate with firmware.
480 * The ctrl_chan_name can be looked up by using
481 * rte_eth_dev_get_name_by_port() within the ULP.
483 * ctrl_chan_name will be used as part of a name for any
484 * shared memory allocation.
486 char ctrl_chan_name[TF_SESSION_NAME_MAX];
490 * Boolean controlling the use and availability of shadow
491 * copy. Shadow copy will allow the TruFlow to keep track of
492 * resource content on the firmware side without having to
493 * query firmware. Additional private session core_data will
494 * be allocated if this boolean is set to 'true', default
497 * Size of memory depends on the NVM Resource settings for the
502 * [in/out] session_id
504 * Session_id is unique per session.
506 * Session_id is composed of domain, bus, device and
507 * fw_session_id. The construction is done by parsing the
508 * ctrl_chan_name together with allocation of a fw_session_id.
510 * The session_id allows a session to be shared between devices.
512 union tf_session_id session_id;
516 * Device type is passed, one of Wh+, SR, Thor, SR2
518 enum tf_device_type device_type;
521 * Resource allocation
523 struct tf_session_resources resources;
527 * Opens a new TruFlow management session.
529 * TruFlow will allocate session specific memory, shared memory, to
530 * hold its session data. This data is private to TruFlow.
532 * Multiple PFs can share the same session. An association, refcount,
533 * between session and PFs is maintained within TruFlow. Thus, a PF
534 * can attach to an existing session, see tf_attach_session().
536 * No other TruFlow APIs will succeed unless this API is first called and
539 * tf_open_session() returns a session id that can be used on attach.
542 * Pointer to TF handle
544 * Pointer to open parameters
547 * - (0) if successful.
548 * - (-EINVAL) on failure.
550 int tf_open_session(struct tf *tfp,
551 struct tf_open_session_parms *parms);
553 struct tf_attach_session_parms {
555 * [in] ctrl_chan_name
557 * String containing name of control channel interface to be
558 * used for this session to communicate with firmware.
560 * The ctrl_chan_name can be looked up by using
561 * rte_eth_dev_get_name_by_port() within the ULP.
563 * ctrl_chan_name will be used as part of a name for any
564 * shared memory allocation.
566 char ctrl_chan_name[TF_SESSION_NAME_MAX];
569 * [in] attach_chan_name
571 * String containing name of attach channel interface to be
572 * used for this session.
574 * The attach_chan_name must be given to a 2nd process after
575 * the primary process has been created. This is the
576 * ctrl_chan_name of the primary process and is used to find
577 * the shared memory for the session that the attach is going
580 char attach_chan_name[TF_SESSION_NAME_MAX];
585 * Session_id is unique per session. For Attach the session_id
586 * should be the session_id that was returned on the first
589 * Session_id is composed of domain, bus, device and
590 * fw_session_id. The construction is done by parsing the
591 * ctrl_chan_name together with allocation of a fw_session_id
592 * during tf_open_session().
594 * A reference count will be incremented on attach. A session
595 * is first fully closed when reference count is zero by
596 * calling tf_close_session().
598 union tf_session_id session_id;
602 * Attaches to an existing session. Used when more than one PF wants
603 * to share a single session. In that case all TruFlow management
604 * traffic will be sent to the TruFlow firmware using the 'PF' that
605 * did the attach not the session ctrl channel.
607 * Attach will increment a ref count as to manage the shared session data.
609 * [in] tfp, pointer to TF handle
610 * [in] parms, pointer to attach parameters
613 * - (0) if successful.
614 * - (-EINVAL) on failure.
616 int tf_attach_session(struct tf *tfp,
617 struct tf_attach_session_parms *parms);
620 * Closes an existing session. Cleans up all hardware and firmware
621 * state associated with the TruFlow application session when the last
622 * PF associated with the session results in refcount to be zero.
624 * Returns success or failure code.
626 int tf_close_session(struct tf *tfp);
629 * @page ident Identity Management
631 * @ref tf_alloc_identifier
633 * @ref tf_free_identifier
636 * tf_alloc_identifier parameter definition
638 struct tf_alloc_identifier_parms {
640 * [in] receive or transmit direction
644 * [in] Identifier type
646 enum tf_identifier_type ident_type;
648 * [out] Identifier allocated
654 * tf_free_identifier parameter definition
656 struct tf_free_identifier_parms {
658 * [in] receive or transmit direction
662 * [in] Identifier type
664 enum tf_identifier_type ident_type;
672 * allocate identifier resource
674 * TruFlow core will allocate a free id from the per identifier resource type
675 * pool reserved for the session during tf_open(). No firmware is involved.
677 * Returns success or failure code.
679 int tf_alloc_identifier(struct tf *tfp,
680 struct tf_alloc_identifier_parms *parms);
683 * free identifier resource
685 * TruFlow core will return an id back to the per identifier resource type pool
686 * reserved for the session. No firmware is involved. During tf_close, the
687 * complete pool is returned to the firmware.
689 * Returns success or failure code.
691 int tf_free_identifier(struct tf *tfp,
692 struct tf_free_identifier_parms *parms);
695 * @page dram_table DRAM Table Scope Interface
697 * @ref tf_alloc_tbl_scope
699 * @ref tf_free_tbl_scope
701 * If we allocate the EEM memory from the core, we need to store it in
702 * the shared session data structure to make sure it can be freed later.
703 * (for example if the PF goes away)
705 * Current thought is that memory is allocated within core.
710 * tf_alloc_tbl_scope_parms definition
712 struct tf_alloc_tbl_scope_parms {
714 * [in] All Maximum key size required.
716 uint16_t rx_max_key_sz_in_bits;
718 * [in] Maximum Action size required (includes inlined items)
720 uint16_t rx_max_action_entry_sz_in_bits;
722 * [in] Memory size in Megabytes
723 * Total memory size allocated by user to be divided
724 * up for actions, hash, counters. Only inline external actions.
725 * Use this variable or the number of flows, do not set both.
727 uint32_t rx_mem_size_in_mb;
729 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
731 uint32_t rx_num_flows_in_k;
733 * [in] SR2 only receive table access interface id
735 uint32_t rx_tbl_if_id;
737 * [in] All Maximum key size required.
739 uint16_t tx_max_key_sz_in_bits;
741 * [in] Maximum Action size required (includes inlined items)
743 uint16_t tx_max_action_entry_sz_in_bits;
745 * [in] Memory size in Megabytes
746 * Total memory size allocated by user to be divided
747 * up for actions, hash, counters. Only inline external actions.
749 uint32_t tx_mem_size_in_mb;
751 * [in] Number of flows * 1000
753 uint32_t tx_num_flows_in_k;
755 * [in] SR2 only receive table access interface id
757 uint32_t tx_tbl_if_id;
759 * [in] Flush pending HW cached flows every 1/10th of value
760 * set in seconds, both idle and active flows are flushed
761 * from the HW cache. If set to 0, this feature will be disabled.
763 uint8_t hw_flow_cache_flush_timer;
765 * [out] table scope identifier
767 uint32_t tbl_scope_id;
770 struct tf_free_tbl_scope_parms {
772 * [in] table scope identifier
774 uint32_t tbl_scope_id;
778 * allocate a table scope
780 * On SR2 Firmware will allocate a scope ID. On other devices, the scope
781 * is a software construct to identify an EEM table. This function will
782 * divide the hash memory/buckets and records according to the device
783 * device constraints based upon calculations using either the number of flows
784 * requested or the size of memory indicated. Other parameters passed in
785 * determine the configuration (maximum key size, maximum external action record
788 * This API will allocate the table region in
789 * DRAM, program the PTU page table entries, and program the number of static
790 * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at
791 * 0 in the EM memory for the scope. Upon successful completion of this API,
792 * hash tables are fully initialized and ready for entries to be inserted.
794 * A single API is used to allocate a common table scope identifier in both
795 * receive and transmit CFA. The scope identifier is common due to nature of
796 * connection tracking sending notifications between RX and TX direction.
798 * The receive and transmit table access identifiers specify which rings will
799 * be used to initialize table DRAM. The application must ensure mutual
800 * exclusivity of ring usage for table scope allocation and any table update
803 * The hash table buckets, EM keys, and EM lookup results are stored in the
804 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
805 * hash table buckets are stored at the beginning of that memory.
807 * NOTE: No EM internal setup is done here. On chip EM records are managed
808 * internally by TruFlow core.
810 * Returns success or failure code.
812 int tf_alloc_tbl_scope(struct tf *tfp,
813 struct tf_alloc_tbl_scope_parms *parms);
819 * Firmware checks that the table scope ID is owned by the TruFlow
820 * session, verifies that no references to this table scope remains
821 * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
822 * then frees the table scope ID.
824 * Returns success or failure code.
826 int tf_free_tbl_scope(struct tf *tfp,
827 struct tf_free_tbl_scope_parms *parms);
830 * @page tcam TCAM Access
832 * @ref tf_alloc_tcam_entry
834 * @ref tf_set_tcam_entry
836 * @ref tf_get_tcam_entry
838 * @ref tf_free_tcam_entry
843 * tf_alloc_tcam_entry parameter definition
845 struct tf_alloc_tcam_entry_parms {
847 * [in] receive or transmit direction
851 * [in] TCAM table type
853 enum tf_tcam_tbl_type tcam_tbl_type;
855 * [in] Enable search for matching entry
857 uint8_t search_enable;
859 * [in] Key data to match on (if search)
863 * [in] key size in bits (if search)
865 uint16_t key_sz_in_bits;
867 * [in] Mask data to match on (if search)
871 * [in] Priority of entry requested (definition TBD)
875 * [out] If search, set if matching entry found
879 * [out] Current refcnt after allocation
883 * [out] Idx allocated
890 * allocate TCAM entry
892 * Allocate a TCAM entry - one of these types:
899 * This function allocates a TCAM table record. This function
900 * will attempt to allocate a TCAM table entry from the session
901 * owned TCAM entries or search a shadow copy of the TCAM table for a
902 * matching entry if search is enabled. Key, mask and result must match for
903 * hit to be set. Only TruFlow core data is accessed.
904 * A hash table to entry mapping is maintained for search purposes. If
905 * search is not enabled, the first available free entry is returned based
906 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
907 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
908 * RefCnt is also returned.
910 * Also returns success or failure code.
912 int tf_alloc_tcam_entry(struct tf *tfp,
913 struct tf_alloc_tcam_entry_parms *parms);
916 * tf_set_tcam_entry parameter definition
918 struct tf_set_tcam_entry_parms {
920 * [in] receive or transmit direction
924 * [in] TCAM table type
926 enum tf_tcam_tbl_type tcam_tbl_type;
928 * [in] base index of the entry to program
932 * [in] struct containing key
936 * [in] struct containing mask fields
940 * [in] key size in bits (if search)
942 uint16_t key_sz_in_bits;
944 * [in] struct containing result
948 * [in] struct containing result size in bits
950 uint16_t result_sz_in_bits;
956 * Program a TCAM table entry for a TruFlow session.
958 * If the entry has not been allocated, an error will be returned.
960 * Returns success or failure code.
962 int tf_set_tcam_entry(struct tf *tfp,
963 struct tf_set_tcam_entry_parms *parms);
966 * tf_get_tcam_entry parameter definition
968 struct tf_get_tcam_entry_parms {
970 * [in] receive or transmit direction
974 * [in] TCAM table type
976 enum tf_tcam_tbl_type tcam_tbl_type;
978 * [in] index of the entry to get
982 * [out] struct containing key
986 * [out] struct containing mask fields
990 * [out] key size in bits
992 uint16_t key_sz_in_bits;
994 * [out] struct containing result
998 * [out] struct containing result size in bits
1000 uint16_t result_sz_in_bits;
1006 * Program a TCAM table entry for a TruFlow session.
1008 * If the entry has not been allocated, an error will be returned.
1010 * Returns success or failure code.
1012 int tf_get_tcam_entry(struct tf *tfp,
1013 struct tf_get_tcam_entry_parms *parms);
1016 * tf_free_tcam_entry parameter definition
1018 struct tf_free_tcam_entry_parms {
1020 * [in] receive or transmit direction
1024 * [in] TCAM table type
1026 enum tf_tcam_tbl_type tcam_tbl_type;
1028 * [in] Index to free
1032 * [out] reference count after free
1042 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1043 * session. TCAM entry will be invalidated. All-ones mask.
1046 * WCTCAM profile id of 0 must be used to invalidate an entry.
1048 * Returns success or failure code.
1050 int tf_free_tcam_entry(struct tf *tfp,
1051 struct tf_free_tcam_entry_parms *parms);
1054 * @page table Table Access
1056 * @ref tf_alloc_tbl_entry
1058 * @ref tf_free_tbl_entry
1060 * @ref tf_set_tbl_entry
1062 * @ref tf_get_tbl_entry
1067 * tf_alloc_tbl_entry parameter definition
1069 struct tf_alloc_tbl_entry_parms {
1071 * [in] Receive or transmit direction
1075 * [in] Type of the allocation
1077 enum tf_tbl_type type;
1079 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1081 uint32_t tbl_scope_id;
1083 * [in] Enable search for matching entry. If the table type is
1084 * internal the shadow copy will be searched before
1085 * alloc. Session must be configured with shadow copy enabled.
1087 uint8_t search_enable;
1089 * [in] Result data to search for (if search_enable)
1093 * [in] Result data size in bytes (if search_enable)
1095 uint16_t result_sz_in_bytes;
1097 * [out] If search_enable, set if matching entry found
1101 * [out] Current ref count after allocation (if search_enable)
1105 * [out] Idx of allocated entry or found entry (if search_enable)
1111 * allocate index table entries
1115 * Allocate an on chip index table entry or search for a matching
1116 * entry of the indicated type for this TruFlow session.
1118 * Allocates an index table record. This function will attempt to
1119 * allocate an entry or search an index table for a matching entry if
1120 * search is enabled (only the shadow copy of the table is accessed).
1122 * If search is not enabled, the first available free entry is
1123 * returned. If search is enabled and a matching entry to entry_data
1124 * is found hit is set to TRUE and success is returned.
1128 * These are used to allocate inlined action record memory.
1130 * Allocates an external index table action record.
1133 * Implementation of the internals of this function will be a stack with push
1136 * Returns success or failure code.
1138 int tf_alloc_tbl_entry(struct tf *tfp,
1139 struct tf_alloc_tbl_entry_parms *parms);
1142 * tf_free_tbl_entry parameter definition
1144 struct tf_free_tbl_entry_parms {
1146 * [in] Receive or transmit direction
1150 * [in] Type of the allocation type
1152 enum tf_tbl_type type;
1154 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1156 uint32_t tbl_scope_id;
1158 * [in] Index to free
1162 * [out] Reference count after free, only valid if session has been
1163 * created with shadow_copy.
1169 * free index table entry
1171 * Used to free a previously allocated table entry.
1175 * If session has shadow_copy enabled the shadow DB is searched and if
1176 * found the element ref_cnt is decremented. If ref_cnt goes to
1177 * zero then the element is returned to the session pool.
1179 * If the session does not have a shadow DB the element is free'ed and
1180 * given back to the session pool.
1184 * Free's an external index table action record.
1187 * Implementation of the internals of this function will be a stack with push
1190 * Returns success or failure code.
1192 int tf_free_tbl_entry(struct tf *tfp,
1193 struct tf_free_tbl_entry_parms *parms);
1196 * tf_set_tbl_entry parameter definition
1198 struct tf_set_tbl_entry_parms {
1200 * [in] Table scope identifier
1202 uint32_t tbl_scope_id;
1204 * [in] Receive or transmit direction
1208 * [in] Type of object to set
1210 enum tf_tbl_type type;
1218 uint16_t data_sz_in_bytes;
1220 * [in] Entry index to write to
1226 * set index table entry
1228 * Used to insert an application programmed index table entry into a
1229 * previous allocated table location. A shadow copy of the table
1230 * is maintained (if enabled) (only for internal objects)
1232 * Returns success or failure code.
1234 int tf_set_tbl_entry(struct tf *tfp,
1235 struct tf_set_tbl_entry_parms *parms);
1238 * tf_get_tbl_entry parameter definition
1240 struct tf_get_tbl_entry_parms {
1242 * [in] Receive or transmit direction
1246 * [in] Type of object to get
1248 enum tf_tbl_type type;
1256 uint16_t data_sz_in_bytes;
1258 * [in] Entry index to read
1264 * get index table entry
1266 * Used to retrieve a previous set index table entry.
1268 * Reads and compares with the shadow table copy (if enabled) (only
1269 * for internal objects).
1271 * Returns success or failure code. Failure will be returned if the
1272 * provided data buffer is too small for the data type requested.
1274 int tf_get_tbl_entry(struct tf *tfp,
1275 struct tf_get_tbl_entry_parms *parms);
1278 * tf_bulk_get_tbl_entry parameter definition
1280 struct tf_bulk_get_tbl_entry_parms {
1282 * [in] Receive or transmit direction
1286 * [in] Type of object to get
1288 enum tf_tbl_type type;
1290 * [in] Starting index to read from
1292 uint32_t starting_idx;
1294 * [in] Number of sequential entries
1296 uint16_t num_entries;
1298 * [in] Size of the single entry
1300 uint16_t entry_sz_in_bytes;
1302 * [out] Host physical address, where the data
1303 * will be copied to by the firmware.
1304 * Use tfp_calloc() API and mem_pa
1305 * variable of the tfp_calloc_parms
1306 * structure for the physical address.
1308 uint64_t physical_mem_addr;
1312 * Bulk get index table entry
1314 * Used to retrieve a previous set index table entry.
1316 * Reads and compares with the shadow table copy (if enabled) (only
1317 * for internal objects).
1319 * Returns success or failure code. Failure will be returned if the
1320 * provided data buffer is too small for the data type requested.
1322 int tf_bulk_get_tbl_entry(struct tf *tfp,
1323 struct tf_bulk_get_tbl_entry_parms *parms);
1326 * @page exact_match Exact Match Table
1328 * @ref tf_insert_em_entry
1330 * @ref tf_delete_em_entry
1332 * @ref tf_search_em_entry
1336 * tf_insert_em_entry parameter definition
1338 struct tf_insert_em_entry_parms {
1340 * [in] receive or transmit direction
1344 * [in] internal or external
1348 * [in] ID of table scope to use (external only)
1350 uint32_t tbl_scope_id;
1352 * [in] ID of table interface to use (SR2 only)
1356 * [in] ptr to structure containing key fields
1360 * [in] key bit length
1362 uint16_t key_sz_in_bits;
1364 * [in] ptr to structure containing result field
1368 * [out] result size in bits
1370 uint16_t em_record_sz_in_bits;
1372 * [in] duplicate check flag
1376 * [out] Flow handle value for the inserted entry. This is encoded
1377 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1379 uint64_t flow_handle;
1381 * [out] Flow id is returned as null (internal)
1382 * Flow id is the GFID value for the inserted entry (external)
1383 * This is the value written to the BD and useful information for mark.
1388 * tf_delete_em_entry parameter definition
1390 struct tf_delete_em_entry_parms {
1392 * [in] receive or transmit direction
1396 * [in] internal or external
1400 * [in] ID of table scope to use (external only)
1402 uint32_t tbl_scope_id;
1404 * [in] ID of table interface to use (SR2 only)
1408 * [in] epoch group IDs of entry to delete
1409 * 2 element array with 2 ids. (SR2 only)
1413 * [out] The index of the entry
1417 * [in] structure containing flow delete handle information
1419 uint64_t flow_handle;
1422 * tf_search_em_entry parameter definition
1424 struct tf_search_em_entry_parms {
1426 * [in] receive or transmit direction
1430 * [in] internal or external
1434 * [in] ID of table scope to use (external only)
1436 uint32_t tbl_scope_id;
1438 * [in] ID of table interface to use (SR2 only)
1442 * [in] ptr to structure containing key fields
1446 * [in] key bit length
1448 uint16_t key_sz_in_bits;
1450 * [in/out] ptr to structure containing EM record fields
1454 * [out] result size in bits
1456 uint16_t em_record_sz_in_bits;
1458 * [in] epoch group IDs of entry to lookup
1459 * 2 element array with 2 ids. (SR2 only)
1463 * [in] ptr to structure containing flow delete handle
1465 uint64_t flow_handle;
1469 * insert em hash entry in internal table memory
1473 * This API inserts an exact match entry into internal EM table memory
1474 * of the specified direction.
1476 * Note: The EM record is managed within the TruFlow core and not the
1479 * Shadow copy of internal record table an association with hash and 1,2, or 4
1480 * associated buckets
1483 * This API inserts an exact match entry into DRAM EM table memory of the
1484 * specified direction and table scope.
1486 * When inserting an entry into an exact match table, the TruFlow library may
1487 * need to allocate a dynamic bucket for the entry (SR2 only).
1489 * The insertion of duplicate entries in an EM table is not permitted. If a
1490 * TruFlow application can guarantee that it will never insert duplicates, it
1491 * can disable duplicate checking by passing a zero value in the dup_check
1492 * parameter to this API. This will optimize performance. Otherwise, the
1493 * TruFlow library will enforce protection against inserting duplicate entries.
1495 * Flow handle is defined in this document:
1497 * https://docs.google.com
1498 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1500 * Returns success or busy code.
1503 int tf_insert_em_entry(struct tf *tfp,
1504 struct tf_insert_em_entry_parms *parms);
1507 * delete em hash entry table memory
1511 * This API deletes an exact match entry from internal EM table memory of the
1512 * specified direction. If a valid flow ptr is passed in then that takes
1513 * precedence over the pointer to the complete key passed in.
1518 * This API deletes an exact match entry from EM table memory of the specified
1519 * direction and table scope. If a valid flow handle is passed in then that
1520 * takes precedence over the pointer to the complete key passed in.
1522 * The TruFlow library may release a dynamic bucket when an entry is deleted.
1525 * Returns success or not found code
1529 int tf_delete_em_entry(struct tf *tfp,
1530 struct tf_delete_em_entry_parms *parms);
1533 * search em hash entry table memory
1537 * This API looks up an EM entry in table memory with the specified EM
1538 * key or flow (flow takes precedence) and direction.
1540 * The status will be one of: success or entry not found. If the lookup
1541 * succeeds, a pointer to the matching entry and the result record associated
1542 * with the matching entry will be provided.
1544 * If flow_handle is set, search shadow copy.
1546 * Otherwise, query the fw with key to get result.
1550 * This API looks up an EM entry in table memory with the specified EM
1551 * key or flow_handle (flow takes precedence), direction and table scope.
1553 * The status will be one of: success or entry not found. If the lookup
1554 * succeeds, a pointer to the matching entry and the result record associated
1555 * with the matching entry will be provided.
1557 * Returns success or not found code
1560 int tf_search_em_entry(struct tf *tfp,
1561 struct tf_search_em_entry_parms *parms);
1563 #endif /* _TF_CORE_H_ */