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 * tf_session_resources parameter definition.
390 struct tf_session_resources {
391 /** [in] Requested Identifier Resources
393 * The number of identifier resources requested for the session.
394 * The index used is tf_identifier_type.
396 uint16_t identifier_cnt[TF_IDENT_TYPE_MAX][TF_DIR_MAX];
397 /** [in] Requested Index Table resource counts
399 * The number of index table resources requested for the session.
400 * The index used is tf_tbl_type.
402 uint16_t tbl_cnt[TF_TBL_TYPE_MAX][TF_DIR_MAX];
403 /** [in] Requested TCAM Table resource counts
405 * The number of TCAM table resources requested for the session.
406 * The index used is tf_tcam_tbl_type.
408 uint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX][TF_DIR_MAX];
409 /** [in] Requested EM resource counts
411 * The number of internal EM table resources requested for the session
412 * The index used is tf_em_tbl_type.
414 uint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX][TF_DIR_MAX];
418 * tf_open_session parameters definition.
420 struct tf_open_session_parms {
422 * [in] ctrl_chan_name
424 * String containing name of control channel interface to be
425 * used for this session to communicate with firmware.
427 * The ctrl_chan_name can be looked up by using
428 * rte_eth_dev_get_name_by_port() within the ULP.
430 * ctrl_chan_name will be used as part of a name for any
431 * shared memory allocation.
433 char ctrl_chan_name[TF_SESSION_NAME_MAX];
437 * Boolean controlling the use and availability of shadow
438 * copy. Shadow copy will allow the TruFlow to keep track of
439 * resource content on the firmware side without having to
440 * query firmware. Additional private session core_data will
441 * be allocated if this boolean is set to 'true', default
444 * Size of memory depends on the NVM Resource settings for the
449 * [in/out] session_id
451 * Session_id is unique per session.
453 * Session_id is composed of domain, bus, device and
454 * fw_session_id. The construction is done by parsing the
455 * ctrl_chan_name together with allocation of a fw_session_id.
457 * The session_id allows a session to be shared between devices.
459 union tf_session_id session_id;
463 * Device type is passed, one of Wh+, SR, Thor, SR2
465 enum tf_device_type device_type;
468 * Resource allocation
470 struct tf_session_resources resources;
474 * Opens a new TruFlow management session.
476 * TruFlow will allocate session specific memory, shared memory, to
477 * hold its session data. This data is private to TruFlow.
479 * Multiple PFs can share the same session. An association, refcount,
480 * between session and PFs is maintained within TruFlow. Thus, a PF
481 * can attach to an existing session, see tf_attach_session().
483 * No other TruFlow APIs will succeed unless this API is first called and
486 * tf_open_session() returns a session id that can be used on attach.
489 * Pointer to TF handle
491 * Pointer to open parameters
494 * - (0) if successful.
495 * - (-EINVAL) on failure.
497 int tf_open_session(struct tf *tfp,
498 struct tf_open_session_parms *parms);
500 int tf_open_session_new(struct tf *tfp,
501 struct tf_open_session_parms *parms);
503 struct tf_attach_session_parms {
505 * [in] ctrl_chan_name
507 * String containing name of control channel interface to be
508 * used for this session to communicate with firmware.
510 * The ctrl_chan_name can be looked up by using
511 * rte_eth_dev_get_name_by_port() within the ULP.
513 * ctrl_chan_name will be used as part of a name for any
514 * shared memory allocation.
516 char ctrl_chan_name[TF_SESSION_NAME_MAX];
519 * [in] attach_chan_name
521 * String containing name of attach channel interface to be
522 * used for this session.
524 * The attach_chan_name must be given to a 2nd process after
525 * the primary process has been created. This is the
526 * ctrl_chan_name of the primary process and is used to find
527 * the shared memory for the session that the attach is going
530 char attach_chan_name[TF_SESSION_NAME_MAX];
535 * Session_id is unique per session. For Attach the session_id
536 * should be the session_id that was returned on the first
539 * Session_id is composed of domain, bus, device and
540 * fw_session_id. The construction is done by parsing the
541 * ctrl_chan_name together with allocation of a fw_session_id
542 * during tf_open_session().
544 * A reference count will be incremented on attach. A session
545 * is first fully closed when reference count is zero by
546 * calling tf_close_session().
548 union tf_session_id session_id;
552 * Attaches to an existing session. Used when more than one PF wants
553 * to share a single session. In that case all TruFlow management
554 * traffic will be sent to the TruFlow firmware using the 'PF' that
555 * did the attach not the session ctrl channel.
557 * Attach will increment a ref count as to manage the shared session data.
559 * [in] tfp, pointer to TF handle
560 * [in] parms, pointer to attach parameters
563 * - (0) if successful.
564 * - (-EINVAL) on failure.
566 int tf_attach_session(struct tf *tfp,
567 struct tf_attach_session_parms *parms);
568 int tf_attach_session_new(struct tf *tfp,
569 struct tf_attach_session_parms *parms);
572 * Closes an existing session. Cleans up all hardware and firmware
573 * state associated with the TruFlow application session when the last
574 * PF associated with the session results in refcount to be zero.
576 * Returns success or failure code.
578 int tf_close_session(struct tf *tfp);
579 int tf_close_session_new(struct tf *tfp);
582 * @page ident Identity Management
584 * @ref tf_alloc_identifier
586 * @ref tf_free_identifier
589 * tf_alloc_identifier parameter definition
591 struct tf_alloc_identifier_parms {
593 * [in] receive or transmit direction
597 * [in] Identifier type
599 enum tf_identifier_type ident_type;
601 * [out] Identifier allocated
607 * tf_free_identifier parameter definition
609 struct tf_free_identifier_parms {
611 * [in] receive or transmit direction
615 * [in] Identifier type
617 enum tf_identifier_type ident_type;
625 * allocate identifier resource
627 * TruFlow core will allocate a free id from the per identifier resource type
628 * pool reserved for the session during tf_open(). No firmware is involved.
630 * Returns success or failure code.
632 int tf_alloc_identifier(struct tf *tfp,
633 struct tf_alloc_identifier_parms *parms);
634 int tf_alloc_identifier_new(struct tf *tfp,
635 struct tf_alloc_identifier_parms *parms);
638 * free identifier resource
640 * TruFlow core will return an id back to the per identifier resource type pool
641 * reserved for the session. No firmware is involved. During tf_close, the
642 * complete pool is returned to the firmware.
644 * Returns success or failure code.
646 int tf_free_identifier(struct tf *tfp,
647 struct tf_free_identifier_parms *parms);
648 int tf_free_identifier_new(struct tf *tfp,
649 struct tf_free_identifier_parms *parms);
652 * @page dram_table DRAM Table Scope Interface
654 * @ref tf_alloc_tbl_scope
656 * @ref tf_free_tbl_scope
658 * If we allocate the EEM memory from the core, we need to store it in
659 * the shared session data structure to make sure it can be freed later.
660 * (for example if the PF goes away)
662 * Current thought is that memory is allocated within core.
667 * tf_alloc_tbl_scope_parms definition
669 struct tf_alloc_tbl_scope_parms {
671 * [in] All Maximum key size required.
673 uint16_t rx_max_key_sz_in_bits;
675 * [in] Maximum Action size required (includes inlined items)
677 uint16_t rx_max_action_entry_sz_in_bits;
679 * [in] Memory size in Megabytes
680 * Total memory size allocated by user to be divided
681 * up for actions, hash, counters. Only inline external actions.
682 * Use this variable or the number of flows, do not set both.
684 uint32_t rx_mem_size_in_mb;
686 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
688 uint32_t rx_num_flows_in_k;
690 * [in] SR2 only receive table access interface id
692 uint32_t rx_tbl_if_id;
694 * [in] All Maximum key size required.
696 uint16_t tx_max_key_sz_in_bits;
698 * [in] Maximum Action size required (includes inlined items)
700 uint16_t tx_max_action_entry_sz_in_bits;
702 * [in] Memory size in Megabytes
703 * Total memory size allocated by user to be divided
704 * up for actions, hash, counters. Only inline external actions.
706 uint32_t tx_mem_size_in_mb;
708 * [in] Number of flows * 1000
710 uint32_t tx_num_flows_in_k;
712 * [in] SR2 only receive table access interface id
714 uint32_t tx_tbl_if_id;
716 * [in] Flush pending HW cached flows every 1/10th of value
717 * set in seconds, both idle and active flows are flushed
718 * from the HW cache. If set to 0, this feature will be disabled.
720 uint8_t hw_flow_cache_flush_timer;
722 * [out] table scope identifier
724 uint32_t tbl_scope_id;
727 struct tf_free_tbl_scope_parms {
729 * [in] table scope identifier
731 uint32_t tbl_scope_id;
735 * allocate a table scope
737 * On SR2 Firmware will allocate a scope ID. On other devices, the scope
738 * is a software construct to identify an EEM table. This function will
739 * divide the hash memory/buckets and records according to the device
740 * device constraints based upon calculations using either the number of flows
741 * requested or the size of memory indicated. Other parameters passed in
742 * determine the configuration (maximum key size, maximum external action record
745 * This API will allocate the table region in
746 * DRAM, program the PTU page table entries, and program the number of static
747 * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at
748 * 0 in the EM memory for the scope. Upon successful completion of this API,
749 * hash tables are fully initialized and ready for entries to be inserted.
751 * A single API is used to allocate a common table scope identifier in both
752 * receive and transmit CFA. The scope identifier is common due to nature of
753 * connection tracking sending notifications between RX and TX direction.
755 * The receive and transmit table access identifiers specify which rings will
756 * be used to initialize table DRAM. The application must ensure mutual
757 * exclusivity of ring usage for table scope allocation and any table update
760 * The hash table buckets, EM keys, and EM lookup results are stored in the
761 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
762 * hash table buckets are stored at the beginning of that memory.
764 * NOTE: No EM internal setup is done here. On chip EM records are managed
765 * internally by TruFlow core.
767 * Returns success or failure code.
769 int tf_alloc_tbl_scope(struct tf *tfp,
770 struct tf_alloc_tbl_scope_parms *parms);
776 * Firmware checks that the table scope ID is owned by the TruFlow
777 * session, verifies that no references to this table scope remains
778 * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
779 * then frees the table scope ID.
781 * Returns success or failure code.
783 int tf_free_tbl_scope(struct tf *tfp,
784 struct tf_free_tbl_scope_parms *parms);
787 * @page tcam TCAM Access
789 * @ref tf_alloc_tcam_entry
791 * @ref tf_set_tcam_entry
793 * @ref tf_get_tcam_entry
795 * @ref tf_free_tcam_entry
800 * tf_alloc_tcam_entry parameter definition
802 struct tf_alloc_tcam_entry_parms {
804 * [in] receive or transmit direction
808 * [in] TCAM table type
810 enum tf_tcam_tbl_type tcam_tbl_type;
812 * [in] Enable search for matching entry
814 uint8_t search_enable;
816 * [in] Key data to match on (if search)
820 * [in] key size in bits (if search)
822 uint16_t key_sz_in_bits;
824 * [in] Mask data to match on (if search)
828 * [in] Priority of entry requested (definition TBD)
832 * [out] If search, set if matching entry found
836 * [out] Current refcnt after allocation
840 * [out] Idx allocated
847 * allocate TCAM entry
849 * Allocate a TCAM entry - one of these types:
856 * This function allocates a TCAM table record. This function
857 * will attempt to allocate a TCAM table entry from the session
858 * owned TCAM entries or search a shadow copy of the TCAM table for a
859 * matching entry if search is enabled. Key, mask and result must match for
860 * hit to be set. Only TruFlow core data is accessed.
861 * A hash table to entry mapping is maintained for search purposes. If
862 * search is not enabled, the first available free entry is returned based
863 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
864 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
865 * RefCnt is also returned.
867 * Also returns success or failure code.
869 int tf_alloc_tcam_entry(struct tf *tfp,
870 struct tf_alloc_tcam_entry_parms *parms);
873 * tf_set_tcam_entry parameter definition
875 struct tf_set_tcam_entry_parms {
877 * [in] receive or transmit direction
881 * [in] TCAM table type
883 enum tf_tcam_tbl_type tcam_tbl_type;
885 * [in] base index of the entry to program
889 * [in] struct containing key
893 * [in] struct containing mask fields
897 * [in] key size in bits (if search)
899 uint16_t key_sz_in_bits;
901 * [in] struct containing result
905 * [in] struct containing result size in bits
907 uint16_t result_sz_in_bits;
913 * Program a TCAM table entry for a TruFlow session.
915 * If the entry has not been allocated, an error will be returned.
917 * Returns success or failure code.
919 int tf_set_tcam_entry(struct tf *tfp,
920 struct tf_set_tcam_entry_parms *parms);
923 * tf_get_tcam_entry parameter definition
925 struct tf_get_tcam_entry_parms {
927 * [in] receive or transmit direction
931 * [in] TCAM table type
933 enum tf_tcam_tbl_type tcam_tbl_type;
935 * [in] index of the entry to get
939 * [out] struct containing key
943 * [out] struct containing mask fields
947 * [out] key size in bits
949 uint16_t key_sz_in_bits;
951 * [out] struct containing result
955 * [out] struct containing result size in bits
957 uint16_t result_sz_in_bits;
963 * Program a TCAM table entry for a TruFlow session.
965 * If the entry has not been allocated, an error will be returned.
967 * Returns success or failure code.
969 int tf_get_tcam_entry(struct tf *tfp,
970 struct tf_get_tcam_entry_parms *parms);
973 * tf_free_tcam_entry parameter definition
975 struct tf_free_tcam_entry_parms {
977 * [in] receive or transmit direction
981 * [in] TCAM table type
983 enum tf_tcam_tbl_type tcam_tbl_type;
989 * [out] reference count after free
999 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1000 * session. TCAM entry will be invalidated. All-ones mask.
1003 * WCTCAM profile id of 0 must be used to invalidate an entry.
1005 * Returns success or failure code.
1007 int tf_free_tcam_entry(struct tf *tfp,
1008 struct tf_free_tcam_entry_parms *parms);
1011 * @page table Table Access
1013 * @ref tf_alloc_tbl_entry
1015 * @ref tf_free_tbl_entry
1017 * @ref tf_set_tbl_entry
1019 * @ref tf_get_tbl_entry
1024 * tf_alloc_tbl_entry parameter definition
1026 struct tf_alloc_tbl_entry_parms {
1028 * [in] Receive or transmit direction
1032 * [in] Type of the allocation
1034 enum tf_tbl_type type;
1036 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1038 uint32_t tbl_scope_id;
1040 * [in] Enable search for matching entry. If the table type is
1041 * internal the shadow copy will be searched before
1042 * alloc. Session must be configured with shadow copy enabled.
1044 uint8_t search_enable;
1046 * [in] Result data to search for (if search_enable)
1050 * [in] Result data size in bytes (if search_enable)
1052 uint16_t result_sz_in_bytes;
1054 * [out] If search_enable, set if matching entry found
1058 * [out] Current ref count after allocation (if search_enable)
1062 * [out] Idx of allocated entry or found entry (if search_enable)
1068 * allocate index table entries
1072 * Allocate an on chip index table entry or search for a matching
1073 * entry of the indicated type for this TruFlow session.
1075 * Allocates an index table record. This function will attempt to
1076 * allocate an entry or search an index table for a matching entry if
1077 * search is enabled (only the shadow copy of the table is accessed).
1079 * If search is not enabled, the first available free entry is
1080 * returned. If search is enabled and a matching entry to entry_data
1081 * is found hit is set to TRUE and success is returned.
1085 * These are used to allocate inlined action record memory.
1087 * Allocates an external index table action record.
1090 * Implementation of the internals of this function will be a stack with push
1093 * Returns success or failure code.
1095 int tf_alloc_tbl_entry(struct tf *tfp,
1096 struct tf_alloc_tbl_entry_parms *parms);
1099 * tf_free_tbl_entry parameter definition
1101 struct tf_free_tbl_entry_parms {
1103 * [in] Receive or transmit direction
1107 * [in] Type of the allocation type
1109 enum tf_tbl_type type;
1111 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1113 uint32_t tbl_scope_id;
1115 * [in] Index to free
1119 * [out] Reference count after free, only valid if session has been
1120 * created with shadow_copy.
1126 * free index table entry
1128 * Used to free a previously allocated table entry.
1132 * If session has shadow_copy enabled the shadow DB is searched and if
1133 * found the element ref_cnt is decremented. If ref_cnt goes to
1134 * zero then the element is returned to the session pool.
1136 * If the session does not have a shadow DB the element is free'ed and
1137 * given back to the session pool.
1141 * Free's an external index table action record.
1144 * Implementation of the internals of this function will be a stack with push
1147 * Returns success or failure code.
1149 int tf_free_tbl_entry(struct tf *tfp,
1150 struct tf_free_tbl_entry_parms *parms);
1153 * tf_set_tbl_entry parameter definition
1155 struct tf_set_tbl_entry_parms {
1157 * [in] Table scope identifier
1159 uint32_t tbl_scope_id;
1161 * [in] Receive or transmit direction
1165 * [in] Type of object to set
1167 enum tf_tbl_type type;
1175 uint16_t data_sz_in_bytes;
1177 * [in] Entry index to write to
1183 * set index table entry
1185 * Used to insert an application programmed index table entry into a
1186 * previous allocated table location. A shadow copy of the table
1187 * is maintained (if enabled) (only for internal objects)
1189 * Returns success or failure code.
1191 int tf_set_tbl_entry(struct tf *tfp,
1192 struct tf_set_tbl_entry_parms *parms);
1195 * tf_get_tbl_entry parameter definition
1197 struct tf_get_tbl_entry_parms {
1199 * [in] Receive or transmit direction
1203 * [in] Type of object to get
1205 enum tf_tbl_type type;
1213 uint16_t data_sz_in_bytes;
1215 * [in] Entry index to read
1221 * get index table entry
1223 * Used to retrieve a previous set index table entry.
1225 * Reads and compares with the shadow table copy (if enabled) (only
1226 * for internal objects).
1228 * Returns success or failure code. Failure will be returned if the
1229 * provided data buffer is too small for the data type requested.
1231 int tf_get_tbl_entry(struct tf *tfp,
1232 struct tf_get_tbl_entry_parms *parms);
1235 * tf_bulk_get_tbl_entry parameter definition
1237 struct tf_bulk_get_tbl_entry_parms {
1239 * [in] Receive or transmit direction
1243 * [in] Type of object to get
1245 enum tf_tbl_type type;
1247 * [in] Starting index to read from
1249 uint32_t starting_idx;
1251 * [in] Number of sequential entries
1253 uint16_t num_entries;
1255 * [in] Size of the single entry
1257 uint16_t entry_sz_in_bytes;
1259 * [out] Host physical address, where the data
1260 * will be copied to by the firmware.
1261 * Use tfp_calloc() API and mem_pa
1262 * variable of the tfp_calloc_parms
1263 * structure for the physical address.
1265 uint64_t physical_mem_addr;
1269 * Bulk get index table entry
1271 * Used to retrieve a previous set index table entry.
1273 * Reads and compares with the shadow table copy (if enabled) (only
1274 * for internal objects).
1276 * Returns success or failure code. Failure will be returned if the
1277 * provided data buffer is too small for the data type requested.
1279 int tf_bulk_get_tbl_entry(struct tf *tfp,
1280 struct tf_bulk_get_tbl_entry_parms *parms);
1283 * @page exact_match Exact Match Table
1285 * @ref tf_insert_em_entry
1287 * @ref tf_delete_em_entry
1289 * @ref tf_search_em_entry
1293 * tf_insert_em_entry parameter definition
1295 struct tf_insert_em_entry_parms {
1297 * [in] receive or transmit direction
1301 * [in] internal or external
1305 * [in] ID of table scope to use (external only)
1307 uint32_t tbl_scope_id;
1309 * [in] ID of table interface to use (SR2 only)
1313 * [in] ptr to structure containing key fields
1317 * [in] key bit length
1319 uint16_t key_sz_in_bits;
1321 * [in] ptr to structure containing result field
1325 * [out] result size in bits
1327 uint16_t em_record_sz_in_bits;
1329 * [in] duplicate check flag
1333 * [out] Flow handle value for the inserted entry. This is encoded
1334 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1336 uint64_t flow_handle;
1338 * [out] Flow id is returned as null (internal)
1339 * Flow id is the GFID value for the inserted entry (external)
1340 * This is the value written to the BD and useful information for mark.
1345 * tf_delete_em_entry parameter definition
1347 struct tf_delete_em_entry_parms {
1349 * [in] receive or transmit direction
1353 * [in] internal or external
1357 * [in] ID of table scope to use (external only)
1359 uint32_t tbl_scope_id;
1361 * [in] ID of table interface to use (SR2 only)
1365 * [in] epoch group IDs of entry to delete
1366 * 2 element array with 2 ids. (SR2 only)
1370 * [out] The index of the entry
1374 * [in] structure containing flow delete handle information
1376 uint64_t flow_handle;
1379 * tf_search_em_entry parameter definition
1381 struct tf_search_em_entry_parms {
1383 * [in] receive or transmit direction
1387 * [in] internal or external
1391 * [in] ID of table scope to use (external only)
1393 uint32_t tbl_scope_id;
1395 * [in] ID of table interface to use (SR2 only)
1399 * [in] ptr to structure containing key fields
1403 * [in] key bit length
1405 uint16_t key_sz_in_bits;
1407 * [in/out] ptr to structure containing EM record fields
1411 * [out] result size in bits
1413 uint16_t em_record_sz_in_bits;
1415 * [in] epoch group IDs of entry to lookup
1416 * 2 element array with 2 ids. (SR2 only)
1420 * [in] ptr to structure containing flow delete handle
1422 uint64_t flow_handle;
1426 * insert em hash entry in internal table memory
1430 * This API inserts an exact match entry into internal EM table memory
1431 * of the specified direction.
1433 * Note: The EM record is managed within the TruFlow core and not the
1436 * Shadow copy of internal record table an association with hash and 1,2, or 4
1437 * associated buckets
1440 * This API inserts an exact match entry into DRAM EM table memory of the
1441 * specified direction and table scope.
1443 * When inserting an entry into an exact match table, the TruFlow library may
1444 * need to allocate a dynamic bucket for the entry (SR2 only).
1446 * The insertion of duplicate entries in an EM table is not permitted. If a
1447 * TruFlow application can guarantee that it will never insert duplicates, it
1448 * can disable duplicate checking by passing a zero value in the dup_check
1449 * parameter to this API. This will optimize performance. Otherwise, the
1450 * TruFlow library will enforce protection against inserting duplicate entries.
1452 * Flow handle is defined in this document:
1454 * https://docs.google.com
1455 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1457 * Returns success or busy code.
1460 int tf_insert_em_entry(struct tf *tfp,
1461 struct tf_insert_em_entry_parms *parms);
1464 * delete em hash entry table memory
1468 * This API deletes an exact match entry from internal EM table memory of the
1469 * specified direction. If a valid flow ptr is passed in then that takes
1470 * precedence over the pointer to the complete key passed in.
1475 * This API deletes an exact match entry from EM table memory of the specified
1476 * direction and table scope. If a valid flow handle is passed in then that
1477 * takes precedence over the pointer to the complete key passed in.
1479 * The TruFlow library may release a dynamic bucket when an entry is deleted.
1482 * Returns success or not found code
1486 int tf_delete_em_entry(struct tf *tfp,
1487 struct tf_delete_em_entry_parms *parms);
1490 * search em hash entry table memory
1494 * This API looks up an EM entry in table memory with the specified EM
1495 * key or flow (flow takes precedence) and direction.
1497 * The status will be one of: success or entry not found. If the lookup
1498 * succeeds, a pointer to the matching entry and the result record associated
1499 * with the matching entry will be provided.
1501 * If flow_handle is set, search shadow copy.
1503 * Otherwise, query the fw with key to get result.
1507 * This API looks up an EM entry in table memory with the specified EM
1508 * key or flow_handle (flow takes precedence), direction and table scope.
1510 * The status will be one of: success or entry not found. If the lookup
1511 * succeeds, a pointer to the matching entry and the result record associated
1512 * with the matching entry will be provided.
1514 * Returns success or not found code
1517 int tf_search_em_entry(struct tf *tfp,
1518 struct tf_search_em_entry_parms *parms);
1520 #endif /* _TF_CORE_H_ */