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 /** Meter Profiles */
215 TF_TBL_TYPE_METER_PROF,
216 /** Meter Instance */
217 TF_TBL_TYPE_METER_INST,
219 TF_TBL_TYPE_MIRROR_CONFIG,
222 /** SR2 Epoch 0 table */
224 /** SR2 Epoch 1 table */
227 TF_TBL_TYPE_METADATA,
229 TF_TBL_TYPE_CT_STATE,
230 /** SR2 Range Profile */
231 TF_TBL_TYPE_RANGE_PROF,
232 /** SR2 Range Entry */
233 TF_TBL_TYPE_RANGE_ENTRY,
236 /** SR2 VNIC/SVIF Table */
237 TF_TBL_TYPE_VNIC_SVIF,
238 /** Th/SR2 EM Flexible Key builder */
240 /** Th/SR2 WC Flexible Key builder */
246 * External table type - initially 1 poolsize entries.
247 * All External table types are associated with a table
248 * scope. Internal types are not.
257 enum tf_tcam_tbl_type {
258 /** L2 Context TCAM */
259 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
261 TF_TCAM_TBL_TYPE_PROF_TCAM,
263 TF_TCAM_TBL_TYPE_WC_TCAM,
264 /** Source Properties TCAM */
265 TF_TCAM_TBL_TYPE_SP_TCAM,
266 /** Connection Tracking Rule TCAM */
267 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
268 /** Virtual Edge Bridge TCAM */
269 TF_TCAM_TBL_TYPE_VEB_TCAM,
275 * These defines are provisioned during
278 enum tf_em_tbl_type {
279 /** The number of internal EM records for the session */
280 TF_EM_TBL_TYPE_EM_RECORD,
281 /** The number of table scopes reequested */
282 TF_EM_TBL_TYPE_TBL_SCOPE,
287 * TruFlow Session Information
289 * Structure defining a TruFlow Session, also known as a Management
290 * session. This structure is initialized at time of
291 * tf_open_session(). It is passed to all of the TruFlow APIs as way
292 * to prescribe and isolate resources between different TruFlow ULP
295 * Ownership of the elements is split between ULP and TruFlow. Please
296 * see the individual elements.
298 struct tf_session_info {
300 * TrueFlow Version. Used to control the structure layout when
301 * sharing sessions. No guarantee that a secondary process
302 * would come from the same version of an executable.
303 * TruFlow initializes this variable on tf_open_session().
308 struct tf_session_version ver;
310 * will be STAILQ_ENTRY(tf_session_info) next
317 * Session ID is a unique identifier for the session. TruFlow
318 * initializes this variable during tf_open_session()
322 * Access: Truflow & ULP
324 union tf_session_id session_id;
326 * Protects access to core_data. Lock is initialized and owned
327 * by ULP. TruFlow can access the core_data without checking
335 * The core_data holds the TruFlow tf_session data
336 * structure. This memory is allocated and owned by TruFlow on
339 * TruFlow uses this memory for session management control
340 * until the session is closed by ULP. Access control is done
341 * by the spin_lock which ULP controls ahead of TruFlow API
344 * Please see tf_open_session_parms for specification details
352 * The core_data_sz_bytes specifies the size of core_data in
355 * The size is set by TruFlow on tf_open_session().
357 * Please see tf_open_session_parms for specification details
363 uint32_t core_data_sz_bytes;
369 * Contains a pointer to the session info. Allocated by ULP and passed
370 * to TruFlow using tf_open_session(). TruFlow will populate the
371 * session info at that time. Additional 'opens' can be done using
372 * same session_info by using tf_attach_session().
374 * It is expected that ULP allocates this memory as shared memory.
376 * NOTE: This struct must be within the BNXT PMD struct bnxt
377 * (bp). This allows use of container_of() to get access to the PMD.
380 struct tf_session_info *session;
384 * Identifier resource definition
386 struct tf_identifier_resources {
388 * Array of TF Identifiers where each entry is expected to be
389 * set to the requested resource number of that specific type.
390 * The index used is tf_identifier_type.
392 uint16_t cnt[TF_IDENT_TYPE_MAX];
396 * Table type resource definition
398 struct tf_tbl_resources {
400 * Array of TF Table types where each entry is expected to be
401 * set to the requeste resource number of that specific
402 * type. The index used is tf_tbl_type.
404 uint16_t cnt[TF_TBL_TYPE_MAX];
408 * TCAM type resource definition
410 struct tf_tcam_resources {
412 * Array of TF TCAM types where each entry is expected to be
413 * set to the requested resource number of that specific
414 * type. The index used is tf_tcam_tbl_type.
416 uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
420 * EM type resource definition
422 struct tf_em_resources {
424 * Array of TF EM table types where each entry is expected to
425 * be set to the requested resource number of that specific
426 * type. The index used is tf_em_tbl_type.
428 uint16_t cnt[TF_EM_TBL_TYPE_MAX];
432 * tf_session_resources parameter definition.
434 struct tf_session_resources {
436 * [in] Requested Identifier Resources
438 * Number of identifier resources requested for the
441 struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
443 * [in] Requested Index Table resource counts
445 * The number of index table resources requested for the
448 struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
450 * [in] Requested TCAM Table resource counts
452 * The number of TCAM table resources requested for the
456 struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
458 * [in] Requested EM resource counts
460 * The number of internal EM table resources requested for the
463 struct tf_em_resources em_cnt[TF_DIR_MAX];
467 * tf_open_session parameters definition.
469 struct tf_open_session_parms {
471 * [in] ctrl_chan_name
473 * String containing name of control channel interface to be
474 * used for this session to communicate with firmware.
476 * The ctrl_chan_name can be looked up by using
477 * rte_eth_dev_get_name_by_port() within the ULP.
479 * ctrl_chan_name will be used as part of a name for any
480 * shared memory allocation.
482 char ctrl_chan_name[TF_SESSION_NAME_MAX];
486 * Boolean controlling the use and availability of shadow
487 * copy. Shadow copy will allow the TruFlow to keep track of
488 * resource content on the firmware side without having to
489 * query firmware. Additional private session core_data will
490 * be allocated if this boolean is set to 'true', default
493 * Size of memory depends on the NVM Resource settings for the
498 * [in/out] session_id
500 * Session_id is unique per session.
502 * Session_id is composed of domain, bus, device and
503 * fw_session_id. The construction is done by parsing the
504 * ctrl_chan_name together with allocation of a fw_session_id.
506 * The session_id allows a session to be shared between devices.
508 union tf_session_id session_id;
512 * Device type is passed, one of Wh+, SR, Thor, SR2
514 enum tf_device_type device_type;
517 * Resource allocation
519 struct tf_session_resources resources;
523 * Opens a new TruFlow management session.
525 * TruFlow will allocate session specific memory, shared memory, to
526 * hold its session data. This data is private to TruFlow.
528 * Multiple PFs can share the same session. An association, refcount,
529 * between session and PFs is maintained within TruFlow. Thus, a PF
530 * can attach to an existing session, see tf_attach_session().
532 * No other TruFlow APIs will succeed unless this API is first called and
535 * tf_open_session() returns a session id that can be used on attach.
538 * Pointer to TF handle
540 * Pointer to open parameters
543 * - (0) if successful.
544 * - (-EINVAL) on failure.
546 int tf_open_session(struct tf *tfp,
547 struct tf_open_session_parms *parms);
549 struct tf_attach_session_parms {
551 * [in] ctrl_chan_name
553 * String containing name of control channel interface to be
554 * used for this session to communicate with firmware.
556 * The ctrl_chan_name can be looked up by using
557 * rte_eth_dev_get_name_by_port() within the ULP.
559 * ctrl_chan_name will be used as part of a name for any
560 * shared memory allocation.
562 char ctrl_chan_name[TF_SESSION_NAME_MAX];
565 * [in] attach_chan_name
567 * String containing name of attach channel interface to be
568 * used for this session.
570 * The attach_chan_name must be given to a 2nd process after
571 * the primary process has been created. This is the
572 * ctrl_chan_name of the primary process and is used to find
573 * the shared memory for the session that the attach is going
576 char attach_chan_name[TF_SESSION_NAME_MAX];
581 * Session_id is unique per session. For Attach the session_id
582 * should be the session_id that was returned on the first
585 * Session_id is composed of domain, bus, device and
586 * fw_session_id. The construction is done by parsing the
587 * ctrl_chan_name together with allocation of a fw_session_id
588 * during tf_open_session().
590 * A reference count will be incremented on attach. A session
591 * is first fully closed when reference count is zero by
592 * calling tf_close_session().
594 union tf_session_id session_id;
598 * Attaches to an existing session. Used when more than one PF wants
599 * to share a single session. In that case all TruFlow management
600 * traffic will be sent to the TruFlow firmware using the 'PF' that
601 * did the attach not the session ctrl channel.
603 * Attach will increment a ref count as to manage the shared session data.
605 * [in] tfp, pointer to TF handle
606 * [in] parms, pointer to attach parameters
609 * - (0) if successful.
610 * - (-EINVAL) on failure.
612 int tf_attach_session(struct tf *tfp,
613 struct tf_attach_session_parms *parms);
616 * Closes an existing session. Cleans up all hardware and firmware
617 * state associated with the TruFlow application session when the last
618 * PF associated with the session results in refcount to be zero.
620 * Returns success or failure code.
622 int tf_close_session(struct tf *tfp);
625 * @page ident Identity Management
627 * @ref tf_alloc_identifier
629 * @ref tf_free_identifier
632 * tf_alloc_identifier parameter definition
634 struct tf_alloc_identifier_parms {
636 * [in] receive or transmit direction
640 * [in] Identifier type
642 enum tf_identifier_type ident_type;
644 * [out] Identifier allocated
650 * tf_free_identifier parameter definition
652 struct tf_free_identifier_parms {
654 * [in] receive or transmit direction
658 * [in] Identifier type
660 enum tf_identifier_type ident_type;
668 * allocate identifier resource
670 * TruFlow core will allocate a free id from the per identifier resource type
671 * pool reserved for the session during tf_open(). No firmware is involved.
673 * Returns success or failure code.
675 int tf_alloc_identifier(struct tf *tfp,
676 struct tf_alloc_identifier_parms *parms);
679 * free identifier resource
681 * TruFlow core will return an id back to the per identifier resource type pool
682 * reserved for the session. No firmware is involved. During tf_close, the
683 * complete pool is returned to the firmware.
685 * Returns success or failure code.
687 int tf_free_identifier(struct tf *tfp,
688 struct tf_free_identifier_parms *parms);
691 * @page dram_table DRAM Table Scope Interface
693 * @ref tf_alloc_tbl_scope
695 * @ref tf_free_tbl_scope
697 * If we allocate the EEM memory from the core, we need to store it in
698 * the shared session data structure to make sure it can be freed later.
699 * (for example if the PF goes away)
701 * Current thought is that memory is allocated within core.
706 * tf_alloc_tbl_scope_parms definition
708 struct tf_alloc_tbl_scope_parms {
710 * [in] All Maximum key size required.
712 uint16_t rx_max_key_sz_in_bits;
714 * [in] Maximum Action size required (includes inlined items)
716 uint16_t rx_max_action_entry_sz_in_bits;
718 * [in] Memory size in Megabytes
719 * Total memory size allocated by user to be divided
720 * up for actions, hash, counters. Only inline external actions.
721 * Use this variable or the number of flows, do not set both.
723 uint32_t rx_mem_size_in_mb;
725 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
727 uint32_t rx_num_flows_in_k;
729 * [in] SR2 only receive table access interface id
731 uint32_t rx_tbl_if_id;
733 * [in] All Maximum key size required.
735 uint16_t tx_max_key_sz_in_bits;
737 * [in] Maximum Action size required (includes inlined items)
739 uint16_t tx_max_action_entry_sz_in_bits;
741 * [in] Memory size in Megabytes
742 * Total memory size allocated by user to be divided
743 * up for actions, hash, counters. Only inline external actions.
745 uint32_t tx_mem_size_in_mb;
747 * [in] Number of flows * 1000
749 uint32_t tx_num_flows_in_k;
751 * [in] SR2 only receive table access interface id
753 uint32_t tx_tbl_if_id;
755 * [in] Flush pending HW cached flows every 1/10th of value
756 * set in seconds, both idle and active flows are flushed
757 * from the HW cache. If set to 0, this feature will be disabled.
759 uint8_t hw_flow_cache_flush_timer;
761 * [out] table scope identifier
763 uint32_t tbl_scope_id;
766 struct tf_free_tbl_scope_parms {
768 * [in] table scope identifier
770 uint32_t tbl_scope_id;
774 * allocate a table scope
776 * On SR2 Firmware will allocate a scope ID. On other devices, the scope
777 * is a software construct to identify an EEM table. This function will
778 * divide the hash memory/buckets and records according to the device
779 * device constraints based upon calculations using either the number of flows
780 * requested or the size of memory indicated. Other parameters passed in
781 * determine the configuration (maximum key size, maximum external action record
784 * This API will allocate the table region in
785 * DRAM, program the PTU page table entries, and program the number of static
786 * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at
787 * 0 in the EM memory for the scope. Upon successful completion of this API,
788 * hash tables are fully initialized and ready for entries to be inserted.
790 * A single API is used to allocate a common table scope identifier in both
791 * receive and transmit CFA. The scope identifier is common due to nature of
792 * connection tracking sending notifications between RX and TX direction.
794 * The receive and transmit table access identifiers specify which rings will
795 * be used to initialize table DRAM. The application must ensure mutual
796 * exclusivity of ring usage for table scope allocation and any table update
799 * The hash table buckets, EM keys, and EM lookup results are stored in the
800 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
801 * hash table buckets are stored at the beginning of that memory.
803 * NOTE: No EM internal setup is done here. On chip EM records are managed
804 * internally by TruFlow core.
806 * Returns success or failure code.
808 int tf_alloc_tbl_scope(struct tf *tfp,
809 struct tf_alloc_tbl_scope_parms *parms);
815 * Firmware checks that the table scope ID is owned by the TruFlow
816 * session, verifies that no references to this table scope remains
817 * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
818 * then frees the table scope ID.
820 * Returns success or failure code.
822 int tf_free_tbl_scope(struct tf *tfp,
823 struct tf_free_tbl_scope_parms *parms);
826 * @page tcam TCAM Access
828 * @ref tf_alloc_tcam_entry
830 * @ref tf_set_tcam_entry
832 * @ref tf_get_tcam_entry
834 * @ref tf_free_tcam_entry
839 * tf_alloc_tcam_entry parameter definition
841 struct tf_alloc_tcam_entry_parms {
843 * [in] receive or transmit direction
847 * [in] TCAM table type
849 enum tf_tcam_tbl_type tcam_tbl_type;
851 * [in] Enable search for matching entry
853 uint8_t search_enable;
855 * [in] Key data to match on (if search)
859 * [in] key size in bits (if search)
861 uint16_t key_sz_in_bits;
863 * [in] Mask data to match on (if search)
867 * [in] Priority of entry requested (definition TBD)
871 * [out] If search, set if matching entry found
875 * [out] Current refcnt after allocation
879 * [out] Idx allocated
886 * allocate TCAM entry
888 * Allocate a TCAM entry - one of these types:
895 * This function allocates a TCAM table record. This function
896 * will attempt to allocate a TCAM table entry from the session
897 * owned TCAM entries or search a shadow copy of the TCAM table for a
898 * matching entry if search is enabled. Key, mask and result must match for
899 * hit to be set. Only TruFlow core data is accessed.
900 * A hash table to entry mapping is maintained for search purposes. If
901 * search is not enabled, the first available free entry is returned based
902 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
903 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
904 * RefCnt is also returned.
906 * Also returns success or failure code.
908 int tf_alloc_tcam_entry(struct tf *tfp,
909 struct tf_alloc_tcam_entry_parms *parms);
912 * tf_set_tcam_entry parameter definition
914 struct tf_set_tcam_entry_parms {
916 * [in] receive or transmit direction
920 * [in] TCAM table type
922 enum tf_tcam_tbl_type tcam_tbl_type;
924 * [in] base index of the entry to program
928 * [in] struct containing key
932 * [in] struct containing mask fields
936 * [in] key size in bits (if search)
938 uint16_t key_sz_in_bits;
940 * [in] struct containing result
944 * [in] struct containing result size in bits
946 uint16_t result_sz_in_bits;
952 * Program a TCAM table entry for a TruFlow session.
954 * If the entry has not been allocated, an error will be returned.
956 * Returns success or failure code.
958 int tf_set_tcam_entry(struct tf *tfp,
959 struct tf_set_tcam_entry_parms *parms);
962 * tf_get_tcam_entry parameter definition
964 struct tf_get_tcam_entry_parms {
966 * [in] receive or transmit direction
970 * [in] TCAM table type
972 enum tf_tcam_tbl_type tcam_tbl_type;
974 * [in] index of the entry to get
978 * [out] struct containing key
982 * [out] struct containing mask fields
986 * [out] key size in bits
988 uint16_t key_sz_in_bits;
990 * [out] struct containing result
994 * [out] struct containing result size in bits
996 uint16_t result_sz_in_bits;
1002 * Program a TCAM table entry for a TruFlow session.
1004 * If the entry has not been allocated, an error will be returned.
1006 * Returns success or failure code.
1008 int tf_get_tcam_entry(struct tf *tfp,
1009 struct tf_get_tcam_entry_parms *parms);
1012 * tf_free_tcam_entry parameter definition
1014 struct tf_free_tcam_entry_parms {
1016 * [in] receive or transmit direction
1020 * [in] TCAM table type
1022 enum tf_tcam_tbl_type tcam_tbl_type;
1024 * [in] Index to free
1028 * [out] reference count after free
1038 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1039 * session. TCAM entry will be invalidated. All-ones mask.
1042 * WCTCAM profile id of 0 must be used to invalidate an entry.
1044 * Returns success or failure code.
1046 int tf_free_tcam_entry(struct tf *tfp,
1047 struct tf_free_tcam_entry_parms *parms);
1050 * @page table Table Access
1052 * @ref tf_alloc_tbl_entry
1054 * @ref tf_free_tbl_entry
1056 * @ref tf_set_tbl_entry
1058 * @ref tf_get_tbl_entry
1063 * tf_alloc_tbl_entry parameter definition
1065 struct tf_alloc_tbl_entry_parms {
1067 * [in] Receive or transmit direction
1071 * [in] Type of the allocation
1073 enum tf_tbl_type type;
1075 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1077 uint32_t tbl_scope_id;
1079 * [in] Enable search for matching entry. If the table type is
1080 * internal the shadow copy will be searched before
1081 * alloc. Session must be configured with shadow copy enabled.
1083 uint8_t search_enable;
1085 * [in] Result data to search for (if search_enable)
1089 * [in] Result data size in bytes (if search_enable)
1091 uint16_t result_sz_in_bytes;
1093 * [out] If search_enable, set if matching entry found
1097 * [out] Current ref count after allocation (if search_enable)
1101 * [out] Idx of allocated entry or found entry (if search_enable)
1107 * allocate index table entries
1111 * Allocate an on chip index table entry or search for a matching
1112 * entry of the indicated type for this TruFlow session.
1114 * Allocates an index table record. This function will attempt to
1115 * allocate an entry or search an index table for a matching entry if
1116 * search is enabled (only the shadow copy of the table is accessed).
1118 * If search is not enabled, the first available free entry is
1119 * returned. If search is enabled and a matching entry to entry_data
1120 * is found hit is set to TRUE and success is returned.
1124 * These are used to allocate inlined action record memory.
1126 * Allocates an external index table action record.
1129 * Implementation of the internals of this function will be a stack with push
1132 * Returns success or failure code.
1134 int tf_alloc_tbl_entry(struct tf *tfp,
1135 struct tf_alloc_tbl_entry_parms *parms);
1138 * tf_free_tbl_entry parameter definition
1140 struct tf_free_tbl_entry_parms {
1142 * [in] Receive or transmit direction
1146 * [in] Type of the allocation type
1148 enum tf_tbl_type type;
1150 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1152 uint32_t tbl_scope_id;
1154 * [in] Index to free
1158 * [out] Reference count after free, only valid if session has been
1159 * created with shadow_copy.
1165 * free index table entry
1167 * Used to free a previously allocated table entry.
1171 * If session has shadow_copy enabled the shadow DB is searched and if
1172 * found the element ref_cnt is decremented. If ref_cnt goes to
1173 * zero then the element is returned to the session pool.
1175 * If the session does not have a shadow DB the element is free'ed and
1176 * given back to the session pool.
1180 * Free's an external index table action record.
1183 * Implementation of the internals of this function will be a stack with push
1186 * Returns success or failure code.
1188 int tf_free_tbl_entry(struct tf *tfp,
1189 struct tf_free_tbl_entry_parms *parms);
1192 * tf_set_tbl_entry parameter definition
1194 struct tf_set_tbl_entry_parms {
1196 * [in] Table scope identifier
1198 uint32_t tbl_scope_id;
1200 * [in] Receive or transmit direction
1204 * [in] Type of object to set
1206 enum tf_tbl_type type;
1214 uint16_t data_sz_in_bytes;
1216 * [in] Entry index to write to
1222 * set index table entry
1224 * Used to insert an application programmed index table entry into a
1225 * previous allocated table location. A shadow copy of the table
1226 * is maintained (if enabled) (only for internal objects)
1228 * Returns success or failure code.
1230 int tf_set_tbl_entry(struct tf *tfp,
1231 struct tf_set_tbl_entry_parms *parms);
1234 * tf_get_tbl_entry parameter definition
1236 struct tf_get_tbl_entry_parms {
1238 * [in] Receive or transmit direction
1242 * [in] Type of object to get
1244 enum tf_tbl_type type;
1252 uint16_t data_sz_in_bytes;
1254 * [in] Entry index to read
1260 * get index table entry
1262 * Used to retrieve a previous set index table entry.
1264 * Reads and compares with the shadow table copy (if enabled) (only
1265 * for internal objects).
1267 * Returns success or failure code. Failure will be returned if the
1268 * provided data buffer is too small for the data type requested.
1270 int tf_get_tbl_entry(struct tf *tfp,
1271 struct tf_get_tbl_entry_parms *parms);
1274 * tf_bulk_get_tbl_entry parameter definition
1276 struct tf_bulk_get_tbl_entry_parms {
1278 * [in] Receive or transmit direction
1282 * [in] Type of object to get
1284 enum tf_tbl_type type;
1286 * [in] Starting index to read from
1288 uint32_t starting_idx;
1290 * [in] Number of sequential entries
1292 uint16_t num_entries;
1294 * [in] Size of the single entry
1296 uint16_t entry_sz_in_bytes;
1298 * [out] Host physical address, where the data
1299 * will be copied to by the firmware.
1300 * Use tfp_calloc() API and mem_pa
1301 * variable of the tfp_calloc_parms
1302 * structure for the physical address.
1304 uint64_t physical_mem_addr;
1308 * Bulk get index table entry
1310 * Used to retrieve a previous set index table entry.
1312 * Reads and compares with the shadow table copy (if enabled) (only
1313 * for internal objects).
1315 * Returns success or failure code. Failure will be returned if the
1316 * provided data buffer is too small for the data type requested.
1318 int tf_bulk_get_tbl_entry(struct tf *tfp,
1319 struct tf_bulk_get_tbl_entry_parms *parms);
1322 * @page exact_match Exact Match Table
1324 * @ref tf_insert_em_entry
1326 * @ref tf_delete_em_entry
1328 * @ref tf_search_em_entry
1332 * tf_insert_em_entry parameter definition
1334 struct tf_insert_em_entry_parms {
1336 * [in] receive or transmit direction
1340 * [in] internal or external
1344 * [in] ID of table scope to use (external only)
1346 uint32_t tbl_scope_id;
1348 * [in] ID of table interface to use (SR2 only)
1352 * [in] ptr to structure containing key fields
1356 * [in] key bit length
1358 uint16_t key_sz_in_bits;
1360 * [in] ptr to structure containing result field
1364 * [out] result size in bits
1366 uint16_t em_record_sz_in_bits;
1368 * [in] duplicate check flag
1372 * [out] Flow handle value for the inserted entry. This is encoded
1373 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1375 uint64_t flow_handle;
1377 * [out] Flow id is returned as null (internal)
1378 * Flow id is the GFID value for the inserted entry (external)
1379 * This is the value written to the BD and useful information for mark.
1384 * tf_delete_em_entry parameter definition
1386 struct tf_delete_em_entry_parms {
1388 * [in] receive or transmit direction
1392 * [in] internal or external
1396 * [in] ID of table scope to use (external only)
1398 uint32_t tbl_scope_id;
1400 * [in] ID of table interface to use (SR2 only)
1404 * [in] epoch group IDs of entry to delete
1405 * 2 element array with 2 ids. (SR2 only)
1409 * [out] The index of the entry
1413 * [in] structure containing flow delete handle information
1415 uint64_t flow_handle;
1418 * tf_search_em_entry parameter definition
1420 struct tf_search_em_entry_parms {
1422 * [in] receive or transmit direction
1426 * [in] internal or external
1430 * [in] ID of table scope to use (external only)
1432 uint32_t tbl_scope_id;
1434 * [in] ID of table interface to use (SR2 only)
1438 * [in] ptr to structure containing key fields
1442 * [in] key bit length
1444 uint16_t key_sz_in_bits;
1446 * [in/out] ptr to structure containing EM record fields
1450 * [out] result size in bits
1452 uint16_t em_record_sz_in_bits;
1454 * [in] epoch group IDs of entry to lookup
1455 * 2 element array with 2 ids. (SR2 only)
1459 * [in] ptr to structure containing flow delete handle
1461 uint64_t flow_handle;
1465 * insert em hash entry in internal table memory
1469 * This API inserts an exact match entry into internal EM table memory
1470 * of the specified direction.
1472 * Note: The EM record is managed within the TruFlow core and not the
1475 * Shadow copy of internal record table an association with hash and 1,2, or 4
1476 * associated buckets
1479 * This API inserts an exact match entry into DRAM EM table memory of the
1480 * specified direction and table scope.
1482 * When inserting an entry into an exact match table, the TruFlow library may
1483 * need to allocate a dynamic bucket for the entry (SR2 only).
1485 * The insertion of duplicate entries in an EM table is not permitted. If a
1486 * TruFlow application can guarantee that it will never insert duplicates, it
1487 * can disable duplicate checking by passing a zero value in the dup_check
1488 * parameter to this API. This will optimize performance. Otherwise, the
1489 * TruFlow library will enforce protection against inserting duplicate entries.
1491 * Flow handle is defined in this document:
1493 * https://docs.google.com
1494 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1496 * Returns success or busy code.
1499 int tf_insert_em_entry(struct tf *tfp,
1500 struct tf_insert_em_entry_parms *parms);
1503 * delete em hash entry table memory
1507 * This API deletes an exact match entry from internal EM table memory of the
1508 * specified direction. If a valid flow ptr is passed in then that takes
1509 * precedence over the pointer to the complete key passed in.
1514 * This API deletes an exact match entry from EM table memory of the specified
1515 * direction and table scope. If a valid flow handle is passed in then that
1516 * takes precedence over the pointer to the complete key passed in.
1518 * The TruFlow library may release a dynamic bucket when an entry is deleted.
1521 * Returns success or not found code
1525 int tf_delete_em_entry(struct tf *tfp,
1526 struct tf_delete_em_entry_parms *parms);
1529 * search em hash entry table memory
1533 * This API looks up an EM entry in table memory with the specified EM
1534 * key or flow (flow takes precedence) and direction.
1536 * The status will be one of: success or entry not found. If the lookup
1537 * succeeds, a pointer to the matching entry and the result record associated
1538 * with the matching entry will be provided.
1540 * If flow_handle is set, search shadow copy.
1542 * Otherwise, query the fw with key to get result.
1546 * This API looks up an EM entry in table memory with the specified EM
1547 * key or flow_handle (flow takes precedence), direction and table scope.
1549 * The status will be one of: success or entry not found. If the lookup
1550 * succeeds, a pointer to the matching entry and the result record associated
1551 * with the matching entry will be provided.
1553 * Returns success or not found code
1556 int tf_search_em_entry(struct tf *tfp,
1557 struct tf_search_em_entry_parms *parms);
1560 * @page if_tbl Interface Table Access
1562 * @ref tf_set_if_tbl_entry
1564 * @ref tf_get_if_tbl_entry
1566 * @ref tf_restore_if_tbl_entry
1569 * Enumeration of TruFlow interface table types.
1571 enum tf_if_tbl_type {
1572 /** Default Profile L2 Context Entry */
1573 TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
1574 /** Default Profile TCAM/Lookup Action Record Pointer Table */
1575 TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
1576 /** Error Profile TCAM Miss Action Record Pointer Table */
1577 TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
1578 /** Default Error Profile TCAM Miss Action Record Pointer Table */
1579 TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
1580 /** SR2 Ingress lookup table */
1582 /** SR2 VNIC/SVIF Table */
1583 TF_IF_TBL_TYPE_VNIC_SVIF,
1588 * tf_set_if_tbl_entry parameter definition
1590 struct tf_set_if_tbl_entry_parms {
1592 * [in] Receive or transmit direction
1596 * [in] Type of object to set
1598 enum tf_if_tbl_type type;
1606 uint16_t data_sz_in_bytes;
1608 * [in] Interface to write
1614 * set interface table entry
1616 * Used to set an interface table. This API is used for managing tables indexed
1617 * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
1619 * Returns success or failure code.
1621 int tf_set_if_tbl_entry(struct tf *tfp,
1622 struct tf_set_if_tbl_entry_parms *parms);
1625 * tf_get_if_tbl_entry parameter definition
1627 struct tf_get_if_tbl_entry_parms {
1629 * [in] Receive or transmit direction
1633 * [in] Type of table to get
1635 enum tf_if_tbl_type type;
1643 uint16_t data_sz_in_bytes;
1645 * [in] Entry index to read
1651 * get interface table entry
1653 * Used to retrieve an interface table entry.
1655 * Reads the interface table entry value
1657 * Returns success or failure code. Failure will be returned if the
1658 * provided data buffer is too small for the data type requested.
1660 int tf_get_if_tbl_entry(struct tf *tfp,
1661 struct tf_get_if_tbl_entry_parms *parms);
1663 #endif /* _TF_CORE_H_ */