1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
14 #include "tf_project.h"
19 * Truflow Core API Header File
22 /********** BEGIN Truflow Core DEFINITIONS **********/
25 #define TF_KILOBYTE 1024
26 #define TF_MEGABYTE (1024 * 1024)
32 TF_DIR_RX, /**< Receive */
33 TF_DIR_TX, /**< Transmit */
41 TF_MEM_INTERNAL, /**< Internal */
42 TF_MEM_EXTERNAL, /**< External */
47 * The size of the external action record (Wh+/Brd2)
49 * Currently set to 512.
51 * AR (16B) + encap (256B) + stats_ptrs (8) + resvd (8)
52 * + stats (16) = 304 aligned on a 16B boundary
54 * Theoretically, the size should be smaller. ~304B
56 #define TF_ACTION_RECORD_SZ 512
61 * Defines a single pool of external action records of
62 * fixed size. Currently, this is an index.
64 #define TF_EXT_POOL_ENTRY_SZ_BYTES 1
67 * External pool entry count
69 * Defines the number of entries in the external action pool
71 #define TF_EXT_POOL_ENTRY_CNT (1 * 1024)
74 * Number of external pools
76 #define TF_EXT_POOL_CNT_MAX 1
81 #define TF_EXT_POOL_0 0 /**< matches TF_TBL_TYPE_EXT */
82 #define TF_EXT_POOL_1 1 /**< matches TF_TBL_TYPE_EXT_0 */
84 /** EEM record AR helper
86 * Helper to handle the Action Record Pointer in the EEM Record Entry.
88 * Convert absolute offset to action record pointer in EEM record entry
89 * Convert action record pointer in EEM record entry to absolute offset
91 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
92 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
97 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
99 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
102 * @page general General
104 * @ref tf_open_session
106 * @ref tf_attach_session
108 * @ref tf_close_session
112 /** Session Version defines
114 * The version controls the format of the tf_session and
115 * tf_session_info structure. This is to assure upgrade between
116 * versions can be supported.
118 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
119 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
120 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
124 * Name of the TruFlow control channel interface. Expects
125 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
127 #define TF_SESSION_NAME_MAX 64
129 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
131 /** Session Identifier
133 * Unique session identifier which includes PCIe bus info to
134 * distinguish the PF and session info to identify the associated
135 * TruFlow session. Session ID is constructed from the passed in
136 * ctrl_chan_name in tf_open_session() together with an allocated
137 * fw_session_id. Done by TruFlow on tf_open_session().
139 union tf_session_id {
145 uint8_t fw_session_id;
151 * The version controls the format of the tf_session and
152 * tf_session_info structure. This is to assure upgrade between
153 * versions can be supported.
155 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
157 struct tf_session_version {
163 /** Session supported device types
166 enum tf_device_type {
167 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
168 TF_DEVICE_TYPE_BRD2, /**< TBD */
169 TF_DEVICE_TYPE_BRD3, /**< TBD */
170 TF_DEVICE_TYPE_BRD4, /**< TBD */
171 TF_DEVICE_TYPE_MAX /**< Maximum */
174 /** TruFlow Session Information
176 * Structure defining a TruFlow Session, also known as a Management
177 * session. This structure is initialized at time of
178 * tf_open_session(). It is passed to all of the TruFlow APIs as way
179 * to prescribe and isolate resources between different TruFlow ULP
182 struct tf_session_info {
184 * TrueFlow Version. Used to control the structure layout when
185 * sharing sessions. No guarantee that a secondary process
186 * would come from the same version of an executable.
187 * TruFlow initializes this variable on tf_open_session().
192 struct tf_session_version ver;
194 * will be STAILQ_ENTRY(tf_session_info) next
201 * Session ID is a unique identifier for the session. TruFlow
202 * initializes this variable during tf_open_session()
206 * Access: Truflow & ULP
208 union tf_session_id session_id;
210 * Protects access to core_data. Lock is initialized and owned
211 * by ULP. TruFlow can access the core_data without checking
219 * The core_data holds the TruFlow tf_session data
220 * structure. This memory is allocated and owned by TruFlow on
223 * TruFlow uses this memory for session management control
224 * until the session is closed by ULP. Access control is done
225 * by the spin_lock which ULP controls ahead of TruFlow API
228 * Please see tf_open_session_parms for specification details
236 * The core_data_sz_bytes specifies the size of core_data in
239 * The size is set by TruFlow on tf_open_session().
241 * Please see tf_open_session_parms for specification details
247 uint32_t core_data_sz_bytes;
252 * Contains a pointer to the session info. Allocated by ULP and passed
253 * to TruFlow using tf_open_session(). TruFlow will populate the
254 * session info at that time. Additional 'opens' can be done using
255 * same session_info by using tf_attach_session().
257 * It is expected that ULP allocates this memory as shared memory.
259 * NOTE: This struct must be within the BNXT PMD struct bnxt
260 * (bp). This allows use of container_of() to get access to the PMD.
263 struct tf_session_info *session;
268 * tf_open_session parameters definition.
270 struct tf_open_session_parms {
271 /** [in] ctrl_chan_name
273 * String containing name of control channel interface to be
274 * used for this session to communicate with firmware.
276 * The ctrl_chan_name can be looked up by using
277 * rte_eth_dev_get_name_by_port() within the ULP.
279 * ctrl_chan_name will be used as part of a name for any
280 * shared memory allocation.
282 char ctrl_chan_name[TF_SESSION_NAME_MAX];
285 * Boolean controlling the use and availability of shadow
286 * copy. Shadow copy will allow the TruFlow to keep track of
287 * resource content on the firmware side without having to
288 * query firmware. Additional private session core_data will
289 * be allocated if this boolean is set to 'true', default
292 * Size of memory depends on the NVM Resource settings for the
296 /** [in/out] session_id
298 * Session_id is unique per session.
300 * Session_id is composed of domain, bus, device and
301 * fw_session_id. The construction is done by parsing the
302 * ctrl_chan_name together with allocation of a fw_session_id.
304 * The session_id allows a session to be shared between devices.
306 union tf_session_id session_id;
309 * Device type is passed, one of Wh+, Brd2, Brd3, Brd4
311 enum tf_device_type device_type;
315 * Opens a new TruFlow management session.
317 * TruFlow will allocate session specific memory, shared memory, to
318 * hold its session data. This data is private to TruFlow.
320 * Multiple PFs can share the same session. An association, refcount,
321 * between session and PFs is maintained within TruFlow. Thus, a PF
322 * can attach to an existing session, see tf_attach_session().
324 * No other TruFlow APIs will succeed unless this API is first called and
327 * tf_open_session() returns a session id that can be used on attach.
330 * Pointer to TF handle
332 * Pointer to open parameters
335 * - (0) if successful.
336 * - (-EINVAL) on failure.
338 int tf_open_session(struct tf *tfp,
339 struct tf_open_session_parms *parms);
341 struct tf_attach_session_parms {
342 /** [in] ctrl_chan_name
344 * String containing name of control channel interface to be
345 * used for this session to communicate with firmware.
347 * The ctrl_chan_name can be looked up by using
348 * rte_eth_dev_get_name_by_port() within the ULP.
350 * ctrl_chan_name will be used as part of a name for any
351 * shared memory allocation.
353 char ctrl_chan_name[TF_SESSION_NAME_MAX];
355 /** [in] attach_chan_name
357 * String containing name of attach channel interface to be
358 * used for this session.
360 * The attach_chan_name must be given to a 2nd process after
361 * the primary process has been created. This is the
362 * ctrl_chan_name of the primary process and is used to find
363 * the shared memory for the session that the attach is going
366 char attach_chan_name[TF_SESSION_NAME_MAX];
370 * Session_id is unique per session. For Attach the session_id
371 * should be the session_id that was returned on the first
374 * Session_id is composed of domain, bus, device and
375 * fw_session_id. The construction is done by parsing the
376 * ctrl_chan_name together with allocation of a fw_session_id
377 * during tf_open_session().
379 * A reference count will be incremented on attach. A session
380 * is first fully closed when reference count is zero by
381 * calling tf_close_session().
383 union tf_session_id session_id;
387 * Attaches to an existing session. Used when more than one PF wants
388 * to share a single session. In that case all TruFlow management
389 * traffic will be sent to the TruFlow firmware using the 'PF' that
390 * did the attach not the session ctrl channel.
392 * Attach will increment a ref count as to manage the shared session data.
394 * [in] tfp, pointer to TF handle
395 * [in] parms, pointer to attach parameters
398 * - (0) if successful.
399 * - (-EINVAL) on failure.
401 int tf_attach_session(struct tf *tfp,
402 struct tf_attach_session_parms *parms);
405 * Closes an existing session. Cleans up all hardware and firmware
406 * state associated with the TruFlow application session when the last
407 * PF associated with the session results in refcount to be zero.
409 * Returns success or failure code.
411 int tf_close_session(struct tf *tfp);
414 * @page ident Identity Management
416 * @ref tf_alloc_identifier
418 * @ref tf_free_identifier
420 enum tf_identifier_type {
421 /** The L2 Context is returned from the L2 Ctxt TCAM lookup
422 * and can be used in WC TCAM or EM keys to virtualize further
425 TF_IDENT_TYPE_L2_CTXT,
426 /** The WC profile func is returned from the L2 Ctxt TCAM lookup
427 * to enable virtualization of the profile TCAM.
429 TF_IDENT_TYPE_PROF_FUNC,
430 /** The WC profile ID is included in the WC lookup key
431 * to enable virtualization of the WC TCAM hardware.
433 TF_IDENT_TYPE_WC_PROF,
434 /** The EM profile ID is included in the EM lookup key
435 * to enable virtualization of the EM hardware. (not required for Brd4
436 * as it has table scope)
438 TF_IDENT_TYPE_EM_PROF,
439 /** The L2 func is included in the ILT result and from recycling to
440 * enable virtualization of further lookups.
442 TF_IDENT_TYPE_L2_FUNC
445 /** tf_alloc_identifier parameter definition
447 struct tf_alloc_identifier_parms {
449 * [in] receive or transmit direction
453 * [in] Identifier type
455 enum tf_identifier_type ident_type;
457 * [out] Identifier allocated
462 /** tf_free_identifier parameter definition
464 struct tf_free_identifier_parms {
466 * [in] receive or transmit direction
470 * [in] Identifier type
472 enum tf_identifier_type ident_type;
479 /** allocate identifier resource
481 * TruFlow core will allocate a free id from the per identifier resource type
482 * pool reserved for the session during tf_open(). No firmware is involved.
484 * Returns success or failure code.
486 int tf_alloc_identifier(struct tf *tfp,
487 struct tf_alloc_identifier_parms *parms);
489 /** free identifier resource
491 * TruFlow core will return an id back to the per identifier resource type pool
492 * reserved for the session. No firmware is involved. During tf_close, the
493 * complete pool is returned to the firmware.
495 * Returns success or failure code.
497 int tf_free_identifier(struct tf *tfp,
498 struct tf_free_identifier_parms *parms);
501 * @page dram_table DRAM Table Scope Interface
503 * @ref tf_alloc_tbl_scope
505 * @ref tf_free_tbl_scope
507 * If we allocate the EEM memory from the core, we need to store it in
508 * the shared session data structure to make sure it can be freed later.
509 * (for example if the PF goes away)
511 * Current thought is that memory is allocated within core.
515 /** tf_alloc_tbl_scope_parms definition
517 struct tf_alloc_tbl_scope_parms {
519 * [in] All Maximum key size required.
521 uint16_t rx_max_key_sz_in_bits;
523 * [in] Maximum Action size required (includes inlined items)
525 uint16_t rx_max_action_entry_sz_in_bits;
527 * [in] Memory size in Megabytes
528 * Total memory size allocated by user to be divided
529 * up for actions, hash, counters. Only inline external actions.
530 * Use this variable or the number of flows, do not set both.
532 uint32_t rx_mem_size_in_mb;
534 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
536 uint32_t rx_num_flows_in_k;
538 * [in] Brd4 only receive table access interface id
540 uint32_t rx_tbl_if_id;
542 * [in] All Maximum key size required.
544 uint16_t tx_max_key_sz_in_bits;
546 * [in] Maximum Action size required (includes inlined items)
548 uint16_t tx_max_action_entry_sz_in_bits;
550 * [in] Memory size in Megabytes
551 * Total memory size allocated by user to be divided
552 * up for actions, hash, counters. Only inline external actions.
554 uint32_t tx_mem_size_in_mb;
556 * [in] Number of flows * 1000
558 uint32_t tx_num_flows_in_k;
560 * [in] Brd4 only receive table access interface id
562 uint32_t tx_tbl_if_id;
564 * [out] table scope identifier
566 uint32_t tbl_scope_id;
569 struct tf_free_tbl_scope_parms {
571 * [in] table scope identifier
573 uint32_t tbl_scope_id;
577 * allocate a table scope
579 * On Brd4 Firmware will allocate a scope ID. On other devices, the scope
580 * is a software construct to identify an EEM table. This function will
581 * divide the hash memory/buckets and records according to the device
582 * device constraints based upon calculations using either the number of flows
583 * requested or the size of memory indicated. Other parameters passed in
584 * determine the configuration (maximum key size, maximum external action record
587 * This API will allocate the table region in
588 * DRAM, program the PTU page table entries, and program the number of static
589 * buckets (if Brd4) in the RX and TX CFAs. Buckets are assumed to start at
590 * 0 in the EM memory for the scope. Upon successful completion of this API,
591 * hash tables are fully initialized and ready for entries to be inserted.
593 * A single API is used to allocate a common table scope identifier in both
594 * receive and transmit CFA. The scope identifier is common due to nature of
595 * connection tracking sending notifications between RX and TX direction.
597 * The receive and transmit table access identifiers specify which rings will
598 * be used to initialize table DRAM. The application must ensure mutual
599 * exclusivity of ring usage for table scope allocation and any table update
602 * The hash table buckets, EM keys, and EM lookup results are stored in the
603 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
604 * hash table buckets are stored at the beginning of that memory.
606 * NOTE: No EM internal setup is done here. On chip EM records are managed
607 * internally by TruFlow core.
609 * Returns success or failure code.
611 int tf_alloc_tbl_scope(struct tf *tfp,
612 struct tf_alloc_tbl_scope_parms *parms);
618 * Firmware checks that the table scope ID is owned by the TruFlow
619 * session, verifies that no references to this table scope remains
620 * (Brd4 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
621 * then frees the table scope ID.
623 * Returns success or failure code.
625 int tf_free_tbl_scope(struct tf *tfp,
626 struct tf_free_tbl_scope_parms *parms);
631 enum tf_tcam_tbl_type {
632 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
633 TF_TCAM_TBL_TYPE_PROF_TCAM,
634 TF_TCAM_TBL_TYPE_WC_TCAM,
635 TF_TCAM_TBL_TYPE_SP_TCAM,
636 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
637 TF_TCAM_TBL_TYPE_VEB_TCAM,
643 * @page tcam TCAM Access
645 * @ref tf_alloc_tcam_entry
647 * @ref tf_set_tcam_entry
649 * @ref tf_get_tcam_entry
651 * @ref tf_free_tcam_entry
654 /** tf_alloc_tcam_entry parameter definition
656 struct tf_alloc_tcam_entry_parms {
658 * [in] receive or transmit direction
662 * [in] TCAM table type
664 enum tf_tcam_tbl_type tcam_tbl_type;
666 * [in] Enable search for matching entry
668 uint8_t search_enable;
670 * [in] Key data to match on (if search)
674 * [in] key size in bits (if search)
676 uint16_t key_sz_in_bits;
678 * [in] Mask data to match on (if search)
682 * [in] Priority of entry requested (definition TBD)
686 * [out] If search, set if matching entry found
690 * [out] Current refcnt after allocation
694 * [out] Idx allocated
700 /** allocate TCAM entry
702 * Allocate a TCAM entry - one of these types:
709 * This function allocates a TCAM table record. This function
710 * will attempt to allocate a TCAM table entry from the session
711 * owned TCAM entries or search a shadow copy of the TCAM table for a
712 * matching entry if search is enabled. Key, mask and result must match for
713 * hit to be set. Only TruFlow core data is accessed.
714 * A hash table to entry mapping is maintained for search purposes. If
715 * search is not enabled, the first available free entry is returned based
716 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
717 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
718 * RefCnt is also returned.
720 * Also returns success or failure code.
722 int tf_alloc_tcam_entry(struct tf *tfp,
723 struct tf_alloc_tcam_entry_parms *parms);
725 /** tf_set_tcam_entry parameter definition
727 struct tf_set_tcam_entry_parms {
729 * [in] receive or transmit direction
733 * [in] TCAM table type
735 enum tf_tcam_tbl_type tcam_tbl_type;
737 * [in] base index of the entry to program
741 * [in] struct containing key
745 * [in] struct containing mask fields
749 * [in] key size in bits (if search)
751 uint16_t key_sz_in_bits;
753 * [in] struct containing result
757 * [in] struct containing result size in bits
759 uint16_t result_sz_in_bits;
764 * Program a TCAM table entry for a TruFlow session.
766 * If the entry has not been allocated, an error will be returned.
768 * Returns success or failure code.
770 int tf_set_tcam_entry(struct tf *tfp,
771 struct tf_set_tcam_entry_parms *parms);
773 /** tf_get_tcam_entry parameter definition
775 struct tf_get_tcam_entry_parms {
777 * [in] receive or transmit direction
781 * [in] TCAM table type
783 enum tf_tcam_tbl_type tcam_tbl_type;
785 * [in] index of the entry to get
789 * [out] struct containing key
793 * [out] struct containing mask fields
797 * [out] key size in bits
799 uint16_t key_sz_in_bits;
801 * [out] struct containing result
805 * [out] struct containing result size in bits
807 uint16_t result_sz_in_bits;
812 * Program a TCAM table entry for a TruFlow session.
814 * If the entry has not been allocated, an error will be returned.
816 * Returns success or failure code.
818 int tf_get_tcam_entry(struct tf *tfp,
819 struct tf_get_tcam_entry_parms *parms);
821 /** tf_free_tcam_entry parameter definition
823 struct tf_free_tcam_entry_parms {
825 * [in] receive or transmit direction
829 * [in] TCAM table type
831 enum tf_tcam_tbl_type tcam_tbl_type;
837 * [out] reference count after free
846 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
847 * session. TCAM entry will be invalidated. All-ones mask.
850 * WCTCAM profile id of 0 must be used to invalidate an entry.
852 * Returns success or failure code.
854 int tf_free_tcam_entry(struct tf *tfp,
855 struct tf_free_tcam_entry_parms *parms);
858 * @page table Table Access
860 * @ref tf_alloc_tbl_entry
862 * @ref tf_free_tbl_entry
864 * @ref tf_set_tbl_entry
866 * @ref tf_get_tbl_entry
870 * Enumeration of TruFlow table types. A table type is used to identify a
873 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
874 * the only table type that is connected with a table scope.
877 /** Wh+/Brd2 Action Record */
878 TF_TBL_TYPE_FULL_ACT_RECORD,
879 /** Multicast Groups */
880 TF_TBL_TYPE_MCAST_GROUPS,
881 /** Action Encap 8 Bytes */
882 TF_TBL_TYPE_ACT_ENCAP_8B,
883 /** Action Encap 16 Bytes */
884 TF_TBL_TYPE_ACT_ENCAP_16B,
885 /** Action Encap 64 Bytes */
886 TF_TBL_TYPE_ACT_ENCAP_32B,
887 /** Action Encap 64 Bytes */
888 TF_TBL_TYPE_ACT_ENCAP_64B,
889 /** Action Source Properties SMAC */
890 TF_TBL_TYPE_ACT_SP_SMAC,
891 /** Action Source Properties SMAC IPv4 */
892 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
893 /** Action Source Properties SMAC IPv6 */
894 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
895 /** Action Statistics 64 Bits */
896 TF_TBL_TYPE_ACT_STATS_64,
897 /** Action Modify L4 Src Port */
898 TF_TBL_TYPE_ACT_MODIFY_SPORT,
899 /** Action Modify L4 Dest Port */
900 TF_TBL_TYPE_ACT_MODIFY_DPORT,
901 /** Action Modify IPv4 Source */
902 TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
903 /** Action _Modify L4 Dest Port */
904 TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
905 /** Action Modify IPv6 Source */
906 TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
907 /** Action Modify IPv6 Destination */
908 TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
912 /** Meter Profiles */
913 TF_TBL_TYPE_METER_PROF,
914 /** Meter Instance */
915 TF_TBL_TYPE_METER_INST,
917 TF_TBL_TYPE_MIRROR_CONFIG,
920 /** Brd4 Epoch 0 table */
922 /** Brd4 Epoch 1 table */
925 TF_TBL_TYPE_METADATA,
927 TF_TBL_TYPE_CT_STATE,
928 /** Brd4 Range Profile */
929 TF_TBL_TYPE_RANGE_PROF,
930 /** Brd4 Range Entry */
931 TF_TBL_TYPE_RANGE_ENTRY,
932 /** Brd4 LAG Entry */
934 /** Brd4 only VNIC/SVIF Table */
935 TF_TBL_TYPE_VNIC_SVIF,
939 /** External table type - initially 1 poolsize entries.
940 * All External table types are associated with a table
941 * scope. Internal types are not.
947 /** tf_alloc_tbl_entry parameter definition
949 struct tf_alloc_tbl_entry_parms {
951 * [in] Receive or transmit direction
955 * [in] Type of the allocation
957 enum tf_tbl_type type;
959 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
961 uint32_t tbl_scope_id;
963 * [in] Enable search for matching entry. If the table type is
964 * internal the shadow copy will be searched before
965 * alloc. Session must be configured with shadow copy enabled.
967 uint8_t search_enable;
969 * [in] Result data to search for (if search_enable)
973 * [in] Result data size in bytes (if search_enable)
975 uint16_t result_sz_in_bytes;
977 * [out] If search_enable, set if matching entry found
981 * [out] Current ref count after allocation (if search_enable)
985 * [out] Idx of allocated entry or found entry (if search_enable)
990 /** allocate index table entries
994 * Allocate an on chip index table entry or search for a matching
995 * entry of the indicated type for this TruFlow session.
997 * Allocates an index table record. This function will attempt to
998 * allocate an entry or search an index table for a matching entry if
999 * search is enabled (only the shadow copy of the table is accessed).
1001 * If search is not enabled, the first available free entry is
1002 * returned. If search is enabled and a matching entry to entry_data
1003 * is found hit is set to TRUE and success is returned.
1007 * These are used to allocate inlined action record memory.
1009 * Allocates an external index table action record.
1012 * Implementation of the internals of this function will be a stack with push
1015 * Returns success or failure code.
1017 int tf_alloc_tbl_entry(struct tf *tfp,
1018 struct tf_alloc_tbl_entry_parms *parms);
1020 /** tf_free_tbl_entry parameter definition
1022 struct tf_free_tbl_entry_parms {
1024 * [in] Receive or transmit direction
1028 * [in] Type of the allocation type
1030 enum tf_tbl_type type;
1032 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1034 uint32_t tbl_scope_id;
1036 * [in] Index to free
1040 * [out] Reference count after free, only valid if session has been
1041 * created with shadow_copy.
1046 /** free index table entry
1048 * Used to free a previously allocated table entry.
1052 * If session has shadow_copy enabled the shadow DB is searched and if
1053 * found the element ref_cnt is decremented. If ref_cnt goes to
1054 * zero then the element is returned to the session pool.
1056 * If the session does not have a shadow DB the element is free'ed and
1057 * given back to the session pool.
1061 * Free's an external index table action record.
1064 * Implementation of the internals of this function will be a stack with push
1067 * Returns success or failure code.
1069 int tf_free_tbl_entry(struct tf *tfp,
1070 struct tf_free_tbl_entry_parms *parms);
1072 /** tf_set_tbl_entry parameter definition
1074 struct tf_set_tbl_entry_parms {
1076 * [in] Table scope identifier
1078 uint32_t tbl_scope_id;
1080 * [in] Receive or transmit direction
1084 * [in] Type of object to set
1086 enum tf_tbl_type type;
1094 uint16_t data_sz_in_bytes;
1096 * [in] Entry index to write to
1101 /** set index table entry
1103 * Used to insert an application programmed index table entry into a
1104 * previous allocated table location. A shadow copy of the table
1105 * is maintained (if enabled) (only for internal objects)
1107 * Returns success or failure code.
1109 int tf_set_tbl_entry(struct tf *tfp,
1110 struct tf_set_tbl_entry_parms *parms);
1112 /** tf_get_tbl_entry parameter definition
1114 struct tf_get_tbl_entry_parms {
1116 * [in] Receive or transmit direction
1120 * [in] Type of object to get
1122 enum tf_tbl_type type;
1130 uint16_t data_sz_in_bytes;
1132 * [in] Entry index to read
1137 /** get index table entry
1139 * Used to retrieve a previous set index table entry.
1141 * Reads and compares with the shadow table copy (if enabled) (only
1142 * for internal objects).
1144 * Returns success or failure code. Failure will be returned if the
1145 * provided data buffer is too small for the data type requested.
1147 int tf_get_tbl_entry(struct tf *tfp,
1148 struct tf_get_tbl_entry_parms *parms);
1151 * @page exact_match Exact Match Table
1153 * @ref tf_insert_em_entry
1155 * @ref tf_delete_em_entry
1157 * @ref tf_search_em_entry
1160 /** tf_insert_em_entry parameter definition
1162 struct tf_insert_em_entry_parms {
1164 * [in] receive or transmit direction
1168 * [in] internal or external
1172 * [in] ID of table scope to use (external only)
1174 uint32_t tbl_scope_id;
1176 * [in] ID of table interface to use (Brd4 only)
1180 * [in] ptr to structure containing key fields
1184 * [in] key bit length
1186 uint16_t key_sz_in_bits;
1188 * [in] ptr to structure containing result field
1192 * [out] result size in bits
1194 uint16_t em_record_sz_in_bits;
1196 * [in] duplicate check flag
1200 * [out] Flow handle value for the inserted entry. This is encoded
1201 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1203 uint64_t flow_handle;
1205 * [out] Flow id is returned as null (internal)
1206 * Flow id is the GFID value for the inserted entry (external)
1207 * This is the value written to the BD and useful information for mark.
1212 * tf_delete_em_entry parameter definition
1214 struct tf_delete_em_entry_parms {
1216 * [in] receive or transmit direction
1220 * [in] internal or external
1224 * [in] ID of table scope to use (external only)
1226 uint32_t tbl_scope_id;
1228 * [in] ID of table interface to use (Brd4 only)
1232 * [in] epoch group IDs of entry to delete
1233 * 2 element array with 2 ids. (Brd4 only)
1237 * [in] structure containing flow delete handle information
1239 uint64_t flow_handle;
1242 * tf_search_em_entry parameter definition
1244 struct tf_search_em_entry_parms {
1246 * [in] receive or transmit direction
1250 * [in] internal or external
1254 * [in] ID of table scope to use (external only)
1256 uint32_t tbl_scope_id;
1258 * [in] ID of table interface to use (Brd4 only)
1262 * [in] ptr to structure containing key fields
1266 * [in] key bit length
1268 uint16_t key_sz_in_bits;
1270 * [in/out] ptr to structure containing EM record fields
1274 * [out] result size in bits
1276 uint16_t em_record_sz_in_bits;
1278 * [in] epoch group IDs of entry to lookup
1279 * 2 element array with 2 ids. (Brd4 only)
1283 * [in] ptr to structure containing flow delete handle
1285 uint64_t flow_handle;
1288 /** insert em hash entry in internal table memory
1292 * This API inserts an exact match entry into internal EM table memory
1293 * of the specified direction.
1295 * Note: The EM record is managed within the TruFlow core and not the
1298 * Shadow copy of internal record table an association with hash and 1,2, or 4
1299 * associated buckets
1302 * This API inserts an exact match entry into DRAM EM table memory of the
1303 * specified direction and table scope.
1305 * When inserting an entry into an exact match table, the TruFlow library may
1306 * need to allocate a dynamic bucket for the entry (Brd4 only).
1308 * The insertion of duplicate entries in an EM table is not permitted. If a
1309 * TruFlow application can guarantee that it will never insert duplicates, it
1310 * can disable duplicate checking by passing a zero value in the dup_check
1311 * parameter to this API. This will optimize performance. Otherwise, the
1312 * TruFlow library will enforce protection against inserting duplicate entries.
1314 * Flow handle is defined in this document:
1316 * https://docs.google.com
1317 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1319 * Returns success or busy code.
1322 int tf_insert_em_entry(struct tf *tfp,
1323 struct tf_insert_em_entry_parms *parms);
1325 /** delete em hash entry table memory
1329 * This API deletes an exact match entry from internal EM table memory of the
1330 * specified direction. If a valid flow ptr is passed in then that takes
1331 * precedence over the pointer to the complete key passed in.
1336 * This API deletes an exact match entry from EM table memory of the specified
1337 * direction and table scope. If a valid flow handle is passed in then that
1338 * takes precedence over the pointer to the complete key passed in.
1340 * The TruFlow library may release a dynamic bucket when an entry is deleted.
1343 * Returns success or not found code
1347 int tf_delete_em_entry(struct tf *tfp,
1348 struct tf_delete_em_entry_parms *parms);
1350 /** search em hash entry table memory
1354 * This API looks up an EM entry in table memory with the specified EM
1355 * key or flow (flow takes precedence) and direction.
1357 * The status will be one of: success or entry not found. If the lookup
1358 * succeeds, a pointer to the matching entry and the result record associated
1359 * with the matching entry will be provided.
1361 * If flow_handle is set, search shadow copy.
1363 * Otherwise, query the fw with key to get result.
1367 * This API looks up an EM entry in table memory with the specified EM
1368 * key or flow_handle (flow takes precedence), direction and table scope.
1370 * The status will be one of: success or entry not found. If the lookup
1371 * succeeds, a pointer to the matching entry and the result record associated
1372 * with the matching entry will be provided.
1374 * Returns success or not found code
1377 int tf_search_em_entry(struct tf *tfp,
1378 struct tf_search_em_entry_parms *parms);
1379 #endif /* _TF_CORE_H_ */