1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
13 #include "hcapi_cfa_defs.h"
14 #include "tf_project.h"
19 * Truflow Core API Header File
22 /********** BEGIN Truflow Core DEFINITIONS **********/
24 #define TF_KILOBYTE 1024
25 #define TF_MEGABYTE (1024 * 1024)
31 TF_DIR_RX, /**< Receive */
32 TF_DIR_TX, /**< Transmit */
40 TF_MEM_INTERNAL, /**< Internal */
41 TF_MEM_EXTERNAL, /**< External */
46 * External memory control channel type
48 enum tf_ext_mem_chan_type {
50 * Direct memory write(Wh+/SR)
52 TF_EXT_MEM_CHAN_TYPE_DIRECT = 0,
56 TF_EXT_MEM_CHAN_TYPE_RING_IF,
58 * Use HWRM message to firmware
60 TF_EXT_MEM_CHAN_TYPE_FW,
62 * Use ring_if message to firmware
64 TF_EXT_MEM_CHAN_TYPE_RING_IF_FW,
65 TF_EXT_MEM_CHAN_TYPE_MAX
69 * WC TCAM number of slice per row that devices supported
71 enum tf_wc_num_slice {
72 TF_WC_TCAM_1_SLICE_PER_ROW = 1,
73 TF_WC_TCAM_2_SLICE_PER_ROW = 2,
74 TF_WC_TCAM_4_SLICE_PER_ROW = 4,
75 TF_WC_TCAM_8_SLICE_PER_ROW = 8,
81 enum tf_sram_bank_id {
82 TF_SRAM_BANK_ID_0, /**< SRAM Bank 0 id */
83 TF_SRAM_BANK_ID_1, /**< SRAM Bank 1 id */
84 TF_SRAM_BANK_ID_2, /**< SRAM Bank 2 id */
85 TF_SRAM_BANK_ID_3, /**< SRAM Bank 3 id */
86 TF_SRAM_BANK_ID_MAX /**< SRAM Bank index limit */
90 * EEM record AR helper
92 * Helper to handle the Action Record Pointer in the EEM Record Entry.
94 * Convert absolute offset to action record pointer in EEM record entry
95 * Convert action record pointer in EEM record entry to absolute offset
97 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
98 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
103 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
105 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
108 * @page general General
110 * @ref tf_open_session
112 * @ref tf_attach_session
114 * @ref tf_close_session
118 * Session Version defines
120 * The version controls the format of the tf_session and
121 * tf_session_info structure. This is to assure upgrade between
122 * versions can be supported.
124 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
125 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
126 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
131 * Name of the TruFlow control channel interface. Expects
132 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
134 #define TF_SESSION_NAME_MAX 64
136 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
141 * Unique session identifier which includes PCIe bus info to
142 * distinguish the PF and session info to identify the associated
143 * TruFlow session. Session ID is constructed from the passed in
144 * ctrl_chan_name in tf_open_session() together with an allocated
145 * fw_session_id. Done by TruFlow on tf_open_session().
147 union tf_session_id {
153 uint8_t fw_session_id;
158 * Session Client Identifier
160 * Unique identifier for a client within a session. Session Client ID
161 * is constructed from the passed in session and a firmware allocated
162 * fw_session_client_id. Done by TruFlow on tf_open_session().
164 union tf_session_client_id {
167 uint8_t fw_session_id;
168 uint8_t fw_session_client_id;
175 * The version controls the format of the tf_session and
176 * tf_session_info structure. This is to assure upgrade between
177 * versions can be supported.
179 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
181 struct tf_session_version {
188 * Session supported device types
190 enum tf_device_type {
191 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
192 TF_DEVICE_TYPE_SR, /**< Stingray */
193 TF_DEVICE_TYPE_THOR, /**< Thor */
194 TF_DEVICE_TYPE_MAX /**< Maximum */
200 enum tf_module_type {
204 TF_MODULE_TYPE_IDENTIFIER,
208 TF_MODULE_TYPE_TABLE,
221 * Identifier resource types
223 enum tf_identifier_type {
226 * The L2 Context is returned from the L2 Ctxt TCAM lookup
227 * and can be used in WC TCAM or EM keys to virtualize further
230 TF_IDENT_TYPE_L2_CTXT_HIGH,
233 * The L2 Context is returned from the L2 Ctxt TCAM lookup
234 * and can be used in WC TCAM or EM keys to virtualize further
237 TF_IDENT_TYPE_L2_CTXT_LOW,
240 * The WC profile func is returned from the L2 Ctxt TCAM lookup
241 * to enable virtualization of the profile TCAM.
243 TF_IDENT_TYPE_PROF_FUNC,
246 * The WC profile ID is included in the WC lookup key
247 * to enable virtualization of the WC TCAM hardware.
249 TF_IDENT_TYPE_WC_PROF,
252 * The EM profile ID is included in the EM lookup key
253 * to enable virtualization of the EM hardware.
255 TF_IDENT_TYPE_EM_PROF,
258 * The L2 func is included in the ILT result and from recycling to
259 * enable virtualization of further lookups.
261 TF_IDENT_TYPE_L2_FUNC,
266 * Enumeration of TruFlow table types. A table type is used to identify a
269 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
270 * the only table type that is connected with a table scope.
275 /** Wh+/SR/TH Action Record */
276 TF_TBL_TYPE_FULL_ACT_RECORD,
277 /** TH Compact Action Record */
278 TF_TBL_TYPE_COMPACT_ACT_RECORD,
279 /** (Future) Multicast Groups */
280 TF_TBL_TYPE_MCAST_GROUPS,
281 /** Wh+/SR/TH Action Encap 8 Bytes */
282 TF_TBL_TYPE_ACT_ENCAP_8B,
283 /** Wh+/SR/TH Action Encap 16 Bytes */
284 TF_TBL_TYPE_ACT_ENCAP_16B,
285 /** WH+/SR/TH Action Encap 32 Bytes */
286 TF_TBL_TYPE_ACT_ENCAP_32B,
287 /** Wh+/SR/TH Action Encap 64 Bytes */
288 TF_TBL_TYPE_ACT_ENCAP_64B,
289 /** WH+/SR/TH Action Source Properties SMAC */
290 TF_TBL_TYPE_ACT_SP_SMAC,
291 /** Wh+/SR/TH Action Source Properties SMAC IPv4 */
292 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
293 /** WH+/SR/TH Action Source Properties SMAC IPv6 */
294 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
295 /** Wh+/SR/TH Action Statistics 64 Bits */
296 TF_TBL_TYPE_ACT_STATS_64,
297 /** Wh+/SR Action Modify IPv4 Source */
298 TF_TBL_TYPE_ACT_MODIFY_IPV4,
299 /** TH 8B Modify Record */
300 TF_TBL_TYPE_ACT_MODIFY_8B,
301 /** TH 16B Modify Record */
302 TF_TBL_TYPE_ACT_MODIFY_16B,
303 /** TH 32B Modify Record */
304 TF_TBL_TYPE_ACT_MODIFY_32B,
305 /** TH 64B Modify Record */
306 TF_TBL_TYPE_ACT_MODIFY_64B,
307 /** Meter Profiles */
308 TF_TBL_TYPE_METER_PROF,
309 /** Meter Instance */
310 TF_TBL_TYPE_METER_INST,
311 /** Wh+/SR/Th Mirror Config */
312 TF_TBL_TYPE_MIRROR_CONFIG,
315 /** (Future) TH Metadata */
316 TF_TBL_TYPE_METADATA,
317 /** (Future) TH CT State */
318 TF_TBL_TYPE_CT_STATE,
319 /** (Future) TH Range Profile */
320 TF_TBL_TYPE_RANGE_PROF,
321 /** TH EM Flexible Key builder */
323 /** TH WC Flexible Key builder */
325 /** Meter Drop Counter */
326 TF_TBL_TYPE_METER_DROP_CNT,
331 * External table type - initially 1 poolsize entries.
332 * All External table types are associated with a table
333 * scope. Internal types are not. Currently this is
334 * a pool of 64B entries.
340 /** Enable Shared TCAM Management
342 * This feature allows for management of high and low pools within
343 * the WC TCAM. These pools are only valid when this feature is enabled.
345 * For normal OVS-DPDK operation, this feature is not required and can
346 * be disabled by commenting out TF_TCAM_SHARED in this header file.
350 * When a shared session is created with WC TCAM entries allocated during
351 * tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided
352 * into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and
353 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW.
355 * The user will allocate and free entries from either of these pools to obtain
356 * WC_TCAM entry offsets. For the WC_TCAM_HI/LO management, alloc/free is done
357 * using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared
360 * The use case for this feature is so that applications can have a shared
361 * session and use the TF core to allocate/set/free entries within a given
362 * region of the WC_TCAM within the shared session. Application A only writes
363 * to the LOW region for example and Application B only writes to the HIGH
364 * region during normal operation. After Application A goes down, Application
365 * B may decide to overwrite the LOW region with the HIGH region's entries
366 * and switch to the low region.
368 * For other TCAM types in the shared session, no alloc/free operations are
369 * permitted. Only set should be used for other TCAM table types after getting
370 * the range as provided by the tf_get_resource_info() API.
373 #define TF_TCAM_SHARED 1
378 enum tf_tcam_tbl_type {
379 /** L2 Context TCAM */
380 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH,
381 /** L2 Context TCAM */
382 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW,
384 TF_TCAM_TBL_TYPE_PROF_TCAM,
386 TF_TCAM_TBL_TYPE_WC_TCAM,
387 /** Source Properties TCAM */
388 TF_TCAM_TBL_TYPE_SP_TCAM,
389 /** Connection Tracking Rule TCAM */
390 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
391 /** Virtual Edge Bridge TCAM */
392 TF_TCAM_TBL_TYPE_VEB_TCAM,
393 #ifdef TF_TCAM_SHARED
394 /** Wildcard TCAM HI Priority */
395 TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
396 /** Wildcard TCAM Low Priority */
397 TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
398 #endif /* TF_TCAM_SHARED */
405 enum tf_search_status {
406 /** The entry was not found, but an idx was allocated if requested. */
408 /** The entry was found, and the result/idx are valid */
410 /** The entry was not found and the table is full */
416 * These defines are provisioned during
419 enum tf_em_tbl_type {
420 /** The number of internal EM records for the session */
421 TF_EM_TBL_TYPE_EM_RECORD,
422 /** The number of table scopes requested */
423 TF_EM_TBL_TYPE_TBL_SCOPE,
428 * TruFlow Session Information
430 * Structure defining a TruFlow Session, also known as a Management
431 * session. This structure is initialized at time of
432 * tf_open_session(). It is passed to all of the TruFlow APIs as way
433 * to prescribe and isolate resources between different TruFlow ULP
436 * Ownership of the elements is split between ULP and TruFlow. Please
437 * see the individual elements.
439 struct tf_session_info {
441 * TruFlow Version. Used to control the structure layout when
442 * sharing sessions. No guarantee that a secondary process
443 * would come from the same version of an executable.
444 * TruFlow initializes this variable on tf_open_session().
449 struct tf_session_version ver;
451 * will be STAILQ_ENTRY(tf_session_info) next
458 * Session ID is a unique identifier for the session. TruFlow
459 * initializes this variable during tf_open_session()
463 * Access: Truflow & ULP
465 union tf_session_id session_id;
467 * Protects access to core_data. Lock is initialized and owned
468 * by ULP. TruFlow can access the core_data without checking
476 * The core_data holds the TruFlow tf_session data
477 * structure. This memory is allocated and owned by TruFlow on
480 * TruFlow uses this memory for session management control
481 * until the session is closed by ULP. Access control is done
482 * by the spin_lock which ULP controls ahead of TruFlow API
485 * Please see tf_open_session_parms for specification details
493 * The core_data_sz_bytes specifies the size of core_data in
496 * The size is set by TruFlow on tf_open_session().
498 * Please see tf_open_session_parms for specification details
504 uint32_t core_data_sz_bytes;
510 * Contains a pointer to the session info. Allocated by ULP and passed
511 * to TruFlow using tf_open_session(). TruFlow will populate the
512 * session info at that time. A TruFlow Session can be used by more
513 * than one PF/VF by using the tf_open_session().
515 * It is expected that ULP allocates this memory as shared memory.
517 * NOTE: This struct must be within the BNXT PMD struct bnxt
518 * (bp). This allows use of container_of() to get access to the PMD.
521 struct tf_session_info *session;
523 * the pointer to the parent bp struct
529 * Identifier resource definition
531 struct tf_identifier_resources {
533 * Array of TF Identifiers where each entry is expected to be
534 * set to the requested resource number of that specific type.
535 * The index used is tf_identifier_type.
537 uint16_t cnt[TF_IDENT_TYPE_MAX];
541 * Table type resource definition
543 struct tf_tbl_resources {
545 * Array of TF Table types where each entry is expected to be
546 * set to the requested resource number of that specific
547 * type. The index used is tf_tbl_type.
549 uint16_t cnt[TF_TBL_TYPE_MAX];
553 * TCAM type resource definition
555 struct tf_tcam_resources {
557 * Array of TF TCAM types where each entry is expected to be
558 * set to the requested resource number of that specific
559 * type. The index used is tf_tcam_tbl_type.
561 uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
565 * EM type resource definition
567 struct tf_em_resources {
569 * Array of TF EM table types where each entry is expected to
570 * be set to the requested resource number of that specific
571 * type. The index used is tf_em_tbl_type.
573 uint16_t cnt[TF_EM_TBL_TYPE_MAX];
577 * tf_session_resources parameter definition.
579 struct tf_session_resources {
581 * [in] Requested Identifier Resources
583 * Number of identifier resources requested for the
586 struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
588 * [in] Requested Index Table resource counts
590 * The number of index table resources requested for the
593 struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
595 * [in] Requested TCAM Table resource counts
597 * The number of TCAM table resources requested for the
601 struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
603 * [in] Requested EM resource counts
605 * The number of internal EM table resources requested for the
608 struct tf_em_resources em_cnt[TF_DIR_MAX];
612 * tf_open_session parameters definition.
614 struct tf_open_session_parms {
616 * [in] ctrl_chan_name
618 * String containing name of control channel interface to be
619 * used for this session to communicate with firmware.
621 * The ctrl_chan_name can be looked up by using
622 * rte_eth_dev_get_name_by_port() within the ULP.
624 * ctrl_chan_name will be used as part of a name for any
625 * shared memory allocation. The ctrl_chan_name is usually in format
626 * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared.
628 char ctrl_chan_name[TF_SESSION_NAME_MAX];
632 * Boolean controlling the use and availability of shadow
633 * copy. Shadow copy will allow the TruFlow to keep track of
634 * resource content on the firmware side without having to
635 * query firmware. Additional private session core_data will
636 * be allocated if this boolean is set to 'true', default
639 * Size of memory depends on the NVM Resource settings for the
644 * [in/out] session_id
646 * Session_id is unique per session.
648 * Session_id is composed of domain, bus, device and
649 * fw_session_id. The construction is done by parsing the
650 * ctrl_chan_name together with allocation of a fw_session_id.
652 * The session_id allows a session to be shared between devices.
654 union tf_session_id session_id;
656 * [in/out] session_client_id
658 * Session_client_id is unique per client.
660 * Session_client_id is composed of session_id and the
661 * fw_session_client_id fw_session_id. The construction is
662 * done by parsing the ctrl_chan_name together with allocation
663 * of a fw_session_client_id during tf_open_session().
665 * A reference count will be incremented in the session on
666 * which a client is created.
668 * A session can first be closed if there is one Session
669 * Client left. Session Clients should closed using
670 * tf_close_session().
672 union tf_session_client_id session_client_id;
676 * Device type for the session.
678 enum tf_device_type device_type;
682 * Resource allocation for the session.
684 struct tf_session_resources resources;
688 * The pointer to the parent bp struct. This is only used for HWRM
689 * message passing within the portability layer. The type is struct
697 * The number of slices per row for WC TCAM entry.
699 enum tf_wc_num_slice wc_num_slices;
702 * [out] shared_session_creator
704 * Indicates whether the application created the session if set.
705 * Otherwise the shared session already existed. Just for information
708 int shared_session_creator;
712 * Opens a new TruFlow Session or session client.
714 * What gets created depends on the passed in tfp content. If the tfp does not
715 * have prior session data a new session with associated session client. If tfp
716 * has a session already a session client will be created. In both cases the
717 * session client is created using the provided ctrl_chan_name.
719 * In case of session creation TruFlow will allocate session specific memory to
720 * hold its session data. This data is private to TruFlow.
722 * No other TruFlow APIs will succeed unless this API is first called
725 * tf_open_session() returns a session id and session client id. These are
726 * also stored within the tfp structure passed in to all other APIs.
728 * A Session or session client can be closed using tf_close_session().
730 * There are 2 types of sessions - shared and not. For non-shared all
731 * the allocated resources are owned and managed by a single session instance.
732 * No other applications have access to the resources owned by the non-shared
733 * session. For a shared session, resources are shared between 2 applications.
735 * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name
736 * like "0000:02:00.0-tf_shared", it is a request to create a new "shared"
737 * session in the firmware or access the existing shared session. There is
738 * only 1 shared session that can be created. If the shared session has
739 * already been created in the firmware, this API will return this indication
740 * by clearing the shared_session_creator flag. Only the first shared session
741 * create will have the shared_session_creator flag set.
743 * The shared session should always be the first session to be created by
744 * application and the last session closed due to RM management preference.
746 * Sessions remain open in the firmware until the last client of the session
747 * closes the session (tf_close_session()).
750 * Pointer to TF handle
753 * Pointer to open parameters
756 * - (0) if successful.
757 * - (-EINVAL) on failure.
759 int tf_open_session(struct tf *tfp,
760 struct tf_open_session_parms *parms);
763 * General internal resource info
766 struct tf_resource_info {
772 * Identifier resource definition
774 struct tf_identifier_resource_info {
776 * Array of TF Identifiers. The index used is tf_identifier_type.
778 struct tf_resource_info info[TF_IDENT_TYPE_MAX];
782 * Table type resource info definition
784 struct tf_tbl_resource_info {
786 * Array of TF Table types. The index used is tf_tbl_type.
788 struct tf_resource_info info[TF_TBL_TYPE_MAX];
792 * TCAM type resource definition
794 struct tf_tcam_resource_info {
796 * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
798 struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
802 * EM type resource definition
804 struct tf_em_resource_info {
806 * Array of TF EM table types. The index used is tf_em_tbl_type.
808 struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
812 * tf_session_resources parameter definition.
814 struct tf_session_resource_info {
816 * [in] Requested Identifier Resources
818 * Number of identifier resources requested for the
821 struct tf_identifier_resource_info ident[TF_DIR_MAX];
823 * [in] Requested Index Table resource counts
825 * The number of index table resources requested for the
828 struct tf_tbl_resource_info tbl[TF_DIR_MAX];
830 * [in] Requested TCAM Table resource counts
832 * The number of TCAM table resources requested for the
836 struct tf_tcam_resource_info tcam[TF_DIR_MAX];
838 * [in] Requested EM resource counts
840 * The number of internal EM table resources requested for the
843 struct tf_em_resource_info em[TF_DIR_MAX];
847 * tf_get_session_resources parameter definition.
849 struct tf_get_session_info_parms {
851 * [out] the structure is used to return the information of
852 * allocated resources.
855 struct tf_session_resource_info session_info;
859 * Gets info about a TruFlow Session
861 * Get info about the session which has been created. Whether it exists and
862 * what resource start and stride offsets are in use. This API is primarily
863 * intended to be used by an application which has created a shared session
864 * This application needs to obtain the resources which have already been
865 * allocated for the shared session.
868 * Pointer to TF handle
871 * Pointer to get parameters
874 * - (0) if successful.
875 * - (-EINVAL) on failure.
877 int tf_get_session_info(struct tf *tfp,
878 struct tf_get_session_info_parms *parms);
882 * tf_attach_session parameters definition.
884 struct tf_attach_session_parms {
886 * [in] ctrl_chan_name
888 * String containing name of control channel interface to be
889 * used for this session to communicate with firmware.
891 * The ctrl_chan_name can be looked up by using
892 * rte_eth_dev_get_name_by_port() within the ULP.
894 * ctrl_chan_name will be used as part of a name for any
895 * shared memory allocation.
897 char ctrl_chan_name[TF_SESSION_NAME_MAX];
900 * [in] attach_chan_name
902 * String containing name of attach channel interface to be
903 * used for this session.
905 * The attach_chan_name must be given to a 2nd process after
906 * the primary process has been created. This is the
907 * ctrl_chan_name of the primary process and is used to find
908 * the shared memory for the session that the attach is going
911 char attach_chan_name[TF_SESSION_NAME_MAX];
916 * Session_id is unique per session. For Attach the session_id
917 * should be the session_id that was returned on the first
920 * Session_id is composed of domain, bus, device and
921 * fw_session_id. The construction is done by parsing the
922 * ctrl_chan_name together with allocation of a fw_session_id
923 * during tf_open_session().
925 * A reference count will be incremented on attach. A session
926 * is first fully closed when reference count is zero by
927 * calling tf_close_session().
929 union tf_session_id session_id;
935 * Allows a 2nd application instance to attach to an existing
936 * session. Used when a session is to be shared between two processes.
938 * Attach will increment a ref count as to manage the shared session data.
941 * Pointer to TF handle
944 * Pointer to attach parameters
947 * - (0) if successful.
948 * - (-EINVAL) on failure.
950 int tf_attach_session(struct tf *tfp,
951 struct tf_attach_session_parms *parms);
954 * Closes an existing session client or the session it self. The
955 * session client is default closed and if the session reference count
956 * is 0 then the session is closed as well.
958 * On session close all hardware and firmware state associated with
959 * the TruFlow application is cleaned up.
961 * The session client is extracted from the tfp. Thus tf_close_session()
962 * cannot close a session client on behalf of another function.
964 * Returns success or failure code.
966 int tf_close_session(struct tf *tfp);
969 * @page ident Identity Management
971 * @ref tf_alloc_identifier
973 * @ref tf_free_identifier
976 * tf_alloc_identifier parameter definition
978 struct tf_alloc_identifier_parms {
980 * [in] receive or transmit direction
984 * [in] Identifier type
986 enum tf_identifier_type ident_type;
988 * [out] Allocated identifier
994 * tf_free_identifier parameter definition
996 struct tf_free_identifier_parms {
998 * [in] receive or transmit direction
1002 * [in] Identifier type
1004 enum tf_identifier_type ident_type;
1011 * [out] Current refcnt after free
1017 * tf_search_identifier parameter definition (experimental)
1019 struct tf_search_identifier_parms {
1021 * [in] receive or transmit direction
1025 * [in] Identifier type
1027 enum tf_identifier_type ident_type;
1029 * [in] Identifier data to search for
1033 * [out] Set if matching identifier found
1037 * [out] Current ref count after allocation
1043 * allocate identifier resource
1045 * TruFlow core will allocate a free id from the per identifier resource type
1046 * pool reserved for the session during tf_open(). No firmware is involved.
1048 * If shadow copy is enabled, the internal ref_cnt is set to 1 in the
1049 * shadow table for a newly allocated resource.
1051 * Returns success or failure code.
1053 int tf_alloc_identifier(struct tf *tfp,
1054 struct tf_alloc_identifier_parms *parms);
1057 * free identifier resource
1059 * TruFlow core will return an id back to the per identifier resource type pool
1060 * reserved for the session. No firmware is involved. During tf_close, the
1061 * complete pool is returned to the firmware.
1063 * additional operation (experimental)
1064 * Decrement reference count. Only release resource once refcnt goes to 0 if
1065 * shadow copy is enabled.
1067 * Returns success or failure code.
1069 int tf_free_identifier(struct tf *tfp,
1070 struct tf_free_identifier_parms *parms);
1073 * Search identifier resource (experimental)
1075 * If the shadow copy is enabled search_id is used to search for a matching
1076 * entry in the shadow table. The shadow table consists of an array of
1077 * reference counts indexed by identifier. If a matching entry is found hit is
1078 * set to TRUE, refcnt is increased by 1 and returned. Otherwise, hit is
1079 * set to false and refcnt is set to 0.
1081 * TODO: we may need a per table internal shadow copy enable flag to stage
1082 * the shadow table implementation. We do not need the shadow table for other
1083 * tables at this time so we may only want to enable the identifier shadow.
1085 * TODO: remove this pseudocode below added to show that if search fails
1086 * we shouldn't allocate a new entry but return.
1088 * identifier alloc (search_en=1)
1089 * if (ident is allocated and ref_cnt >=1)
1090 * return ident - hit is set, incr refcnt
1095 int tf_search_identifier(struct tf *tfp,
1096 struct tf_search_identifier_parms *parms);
1099 * @page dram_table DRAM Table Scope Interface
1101 * @ref tf_alloc_tbl_scope
1103 * @ref tf_free_tbl_scope
1105 * If we allocate the EEM memory from the core, we need to store it in
1106 * the shared session data structure to make sure it can be freed later.
1107 * (for example if the PF goes away)
1109 * Current thought is that memory is allocated within core.
1113 * tf_alloc_tbl_scope_parms definition
1115 struct tf_alloc_tbl_scope_parms {
1117 * [in] All Maximum key size required.
1119 uint16_t rx_max_key_sz_in_bits;
1121 * [in] Maximum Action size required (includes inlined items)
1123 uint16_t rx_max_action_entry_sz_in_bits;
1125 * [in] Memory size in Megabytes
1126 * Total memory size allocated by user to be divided
1127 * up for actions, hash, counters. Only inline external actions.
1128 * Use this variable or the number of flows, do not set both.
1130 uint32_t rx_mem_size_in_mb;
1132 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
1134 uint32_t rx_num_flows_in_k;
1136 * [in] All Maximum key size required.
1138 uint16_t tx_max_key_sz_in_bits;
1140 * [in] Maximum Action size required (includes inlined items)
1142 uint16_t tx_max_action_entry_sz_in_bits;
1144 * [in] Memory size in Megabytes
1145 * Total memory size allocated by user to be divided
1146 * up for actions, hash, counters. Only inline external actions.
1148 uint32_t tx_mem_size_in_mb;
1150 * [in] Number of flows * 1000
1152 uint32_t tx_num_flows_in_k;
1154 * [in] Flush pending HW cached flows every 1/10th of value
1155 * set in seconds, both idle and active flows are flushed
1156 * from the HW cache. If set to 0, this feature will be disabled.
1158 uint8_t hw_flow_cache_flush_timer;
1160 * [out] table scope identifier
1162 uint32_t tbl_scope_id;
1165 * tf_free_tbl_scope_parms definition
1167 struct tf_free_tbl_scope_parms {
1169 * [in] table scope identifier
1171 uint32_t tbl_scope_id;
1175 * tf_map_tbl_scope_parms definition
1177 struct tf_map_tbl_scope_parms {
1179 * [in] table scope identifier
1181 uint32_t tbl_scope_id;
1183 * [in] Which parifs are associated with this table scope. Bit 0
1184 * indicates parif 0.
1186 uint16_t parif_bitmask;
1190 * allocate a table scope
1192 * The scope is a software construct to identify an EEM table. This function will
1193 * divide the hash memory/buckets and records according to the device
1194 * device constraints based upon calculations using either the number of flows
1195 * requested or the size of memory indicated. Other parameters passed in
1196 * determine the configuration (maximum key size, maximum external action record
1199 * A single API is used to allocate a common table scope identifier in both
1200 * receive and transmit CFA. The scope identifier is common due to nature of
1201 * connection tracking sending notifications between RX and TX direction.
1203 * The receive and transmit table access identifiers specify which rings will
1204 * be used to initialize table DRAM. The application must ensure mutual
1205 * exclusivity of ring usage for table scope allocation and any table update
1208 * The hash table buckets, EM keys, and EM lookup results are stored in the
1209 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
1210 * hash table buckets are stored at the beginning of that memory.
1212 * NOTE: No EM internal setup is done here. On chip EM records are managed
1213 * internally by TruFlow core.
1215 * Returns success or failure code.
1217 int tf_alloc_tbl_scope(struct tf *tfp,
1218 struct tf_alloc_tbl_scope_parms *parms);
1221 * map a table scope (legacy device only Wh+/SR)
1223 * Map a table scope to one or more partition interfaces (parifs).
1224 * The parif can be remapped in the L2 context lookup for legacy devices. This
1225 * API allows a number of parifs to be mapped to the same table scope. On
1226 * legacy devices a table scope identifies one of 16 sets of EEM table base
1227 * addresses and is associated with a PF communication channel. The associated
1228 * PF must be configured for the table scope to operate.
1230 * An L2 context TCAM lookup returns a remapped parif value used to
1231 * index into the set of 16 parif_to_pf registers which are used to map to one
1232 * of the 16 table scopes. This API allows the user to map the parifs in the
1233 * mask to the previously allocated table scope (EEM table).
1235 * Returns success or failure code.
1237 int tf_map_tbl_scope(struct tf *tfp,
1238 struct tf_map_tbl_scope_parms *parms);
1240 * free a table scope
1242 * Firmware checks that the table scope ID is owned by the TruFlow
1243 * session, verifies that no references to this table scope remains
1244 * or Profile TCAM entries for either CFA (RX/TX) direction,
1245 * then frees the table scope ID.
1247 * Returns success or failure code.
1249 int tf_free_tbl_scope(struct tf *tfp,
1250 struct tf_free_tbl_scope_parms *parms);
1253 * @page tcam TCAM Access
1255 * @ref tf_search_tcam_entry
1257 * @ref tf_alloc_tcam_entry
1259 * @ref tf_set_tcam_entry
1261 * @ref tf_get_tcam_entry
1263 * @ref tf_free_tcam_entry
1265 #ifdef TF_TCAM_SHARED
1266 * @ref tf_move_tcam_shared_entries
1268 * @ref tf_clear_tcam_shared_entries
1273 * tf_search_tcam_entry parameter definition (experimental)
1275 struct tf_search_tcam_entry_parms {
1277 * [in] receive or transmit direction
1281 * [in] TCAM table type
1283 enum tf_tcam_tbl_type tcam_tbl_type;
1285 * [in] Key data to match on
1289 * [in] key size in bits
1291 uint16_t key_sz_in_bits;
1293 * [in] Mask data to match on
1297 * [in] Priority of entry requested (definition TBD)
1301 * [in] Allocate on miss.
1305 * [out] Set if matching entry found
1309 * [out] Search result status (hit, miss, reject)
1311 enum tf_search_status search_status;
1313 * [out] Current refcnt after allocation
1317 * [in out] The result data from the search is copied here
1321 * [in out] result size in bits for the result data
1323 uint16_t result_sz_in_bits;
1331 * search TCAM entry (experimental)
1333 * Search for a TCAM entry
1335 * This function searches the shadow copy of the TCAM table for a matching
1336 * entry. Key and mask must match for hit to be set. Only TruFlow core data
1337 * is accessed. If shadow_copy is not enabled, an error is returned.
1341 * A hash is performed on the key/mask data and mapped to a shadow copy entry
1342 * where the full key/mask is populated. If the full key/mask matches the
1343 * entry, hit is set, ref_cnt is incremented, and search_status indicates what
1344 * action the caller can take regarding setting the entry.
1346 * search_status should be used as follows:
1347 * - On Miss, the caller should create a result and call tf_set_tcam_entry with
1350 * - On Reject, the hash table is full and the entry cannot be added.
1352 * - On Hit, the result data is returned to the caller. Additionally, the
1353 * ref_cnt is updated.
1355 * Also returns success or failure code.
1357 int tf_search_tcam_entry(struct tf *tfp,
1358 struct tf_search_tcam_entry_parms *parms);
1361 * tf_alloc_tcam_entry parameter definition
1363 struct tf_alloc_tcam_entry_parms {
1365 * [in] receive or transmit direction
1369 * [in] TCAM table type
1371 enum tf_tcam_tbl_type tcam_tbl_type;
1373 * [in] Enable search for matching entry
1375 uint8_t search_enable;
1377 * [in] Key data to match on (if search)
1381 * [in] key size in bits (if search)
1383 uint16_t key_sz_in_bits;
1385 * [in] Mask data to match on (if search)
1389 * [in] Priority of entry requested (definition TBD)
1393 * [out] If search, set if matching entry found
1397 * [out] Current refcnt after allocation
1401 * [out] Idx allocated
1408 * allocate TCAM entry
1410 * Allocate a TCAM entry - one of these types:
1417 * This function allocates a TCAM table record. This function
1418 * will attempt to allocate a TCAM table entry from the session
1419 * owned TCAM entries or search a shadow copy of the TCAM table for a
1420 * matching entry if search is enabled. Key, mask and result must match for
1421 * hit to be set. Only TruFlow core data is accessed.
1422 * A hash table to entry mapping is maintained for search purposes. If
1423 * search is not enabled, the first available free entry is returned based
1424 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
1425 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
1426 * RefCnt is also returned.
1428 * Also returns success or failure code.
1430 int tf_alloc_tcam_entry(struct tf *tfp,
1431 struct tf_alloc_tcam_entry_parms *parms);
1434 * tf_set_tcam_entry parameter definition
1436 struct tf_set_tcam_entry_parms {
1438 * [in] receive or transmit direction
1442 * [in] TCAM table type
1444 enum tf_tcam_tbl_type tcam_tbl_type;
1446 * [in] base index of the entry to program
1450 * [in] struct containing key
1454 * [in] struct containing mask fields
1458 * [in] key size in bits (if search)
1460 uint16_t key_sz_in_bits;
1462 * [in] struct containing result
1466 * [in] struct containing result size in bits
1468 uint16_t result_sz_in_bits;
1474 * Program a TCAM table entry for a TruFlow session.
1476 * If the entry has not been allocated, an error will be returned.
1478 * Returns success or failure code.
1480 int tf_set_tcam_entry(struct tf *tfp,
1481 struct tf_set_tcam_entry_parms *parms);
1484 * tf_get_tcam_entry parameter definition
1486 struct tf_get_tcam_entry_parms {
1488 * [in] receive or transmit direction
1492 * [in] TCAM table type
1494 enum tf_tcam_tbl_type tcam_tbl_type;
1496 * [in] index of the entry to get
1500 * [out] struct containing key
1504 * [out] struct containing mask fields
1508 * [in/out] key size in bits
1510 uint16_t key_sz_in_bits;
1512 * [out] struct containing result
1516 * [in/out] struct containing result size in bits
1518 uint16_t result_sz_in_bits;
1524 * Program a TCAM table entry for a TruFlow session.
1526 * If the entry has not been allocated, an error will be returned.
1528 * Returns success or failure code.
1530 int tf_get_tcam_entry(struct tf *tfp,
1531 struct tf_get_tcam_entry_parms *parms);
1534 * tf_free_tcam_entry parameter definition
1536 struct tf_free_tcam_entry_parms {
1538 * [in] receive or transmit direction
1542 * [in] TCAM table type
1544 enum tf_tcam_tbl_type tcam_tbl_type;
1546 * [in] Index to free
1550 * [out] reference count after free
1560 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1561 * session. TCAM entry will be invalidated. All-ones mask.
1564 * WCTCAM profile id of 0 must be used to invalidate an entry.
1566 * Returns success or failure code.
1568 int tf_free_tcam_entry(struct tf *tfp,
1569 struct tf_free_tcam_entry_parms *parms);
1571 #ifdef TF_TCAM_SHARED
1573 * tf_move_tcam_shared_entries parameter definition
1575 struct tf_move_tcam_shared_entries_parms {
1577 * [in] receive or transmit direction
1581 * [in] TCAM table type
1583 enum tf_tcam_tbl_type tcam_tbl_type;
1589 * This API only affects the following TCAM pools within a shared session:
1591 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
1592 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
1594 * When called, all allocated entries from the high pool will be moved to
1595 * the low pool. Then the allocated entries in the high pool will be
1596 * cleared and freed.
1598 * This API is not supported on a non-shared session.
1600 * Returns success or failure code.
1602 int tf_move_tcam_shared_entries(struct tf *tfp,
1603 struct tf_move_tcam_shared_entries_parms *parms);
1606 * tf_clear_tcam_shared_entries parameter definition
1608 struct tf_clear_tcam_shared_entries_parms {
1610 * [in] receive or transmit direction
1614 * [in] TCAM table type
1616 enum tf_tcam_tbl_type tcam_tbl_type;
1620 * Clear TCAM shared entries pool
1622 * This API only affects the following TCAM pools within a shared session:
1624 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
1625 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
1627 * When called, the indicated WC TCAM high or low pool will be cleared.
1629 * This API is not supported on a non-shared session.
1631 * Returns success or failure code.
1633 int tf_clear_tcam_shared_entries(struct tf *tfp,
1634 struct tf_clear_tcam_shared_entries_parms *parms);
1636 #endif /* TF_TCAM_SHARED */
1638 * @page table Table Access
1640 * @ref tf_alloc_tbl_entry
1642 * @ref tf_free_tbl_entry
1644 * @ref tf_set_tbl_entry
1646 * @ref tf_get_tbl_entry
1648 * @ref tf_bulk_get_tbl_entry
1650 * @ref tf_get_shared_tbl_increment
1654 * tf_alloc_tbl_entry parameter definition
1656 struct tf_alloc_tbl_entry_parms {
1658 * [in] Receive or transmit direction
1662 * [in] Type of the allocation
1664 enum tf_tbl_type type;
1666 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1668 uint32_t tbl_scope_id;
1671 * [out] Idx of allocated entry
1677 * allocate index table entries
1681 * Allocate an on chip index table entry or search for a matching
1682 * entry of the indicated type for this TruFlow session.
1684 * Allocates an index table record. This function will attempt to
1685 * allocate an index table entry.
1689 * These are used to allocate inlined action record memory.
1691 * Allocates an external index table action record.
1694 * Implementation of the internals of the external function will be a stack with
1697 * Returns success or failure code.
1699 int tf_alloc_tbl_entry(struct tf *tfp,
1700 struct tf_alloc_tbl_entry_parms *parms);
1703 * tf_free_tbl_entry parameter definition
1705 struct tf_free_tbl_entry_parms {
1707 * [in] Receive or transmit direction
1711 * [in] Type of the allocation type
1713 enum tf_tbl_type type;
1715 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1717 uint32_t tbl_scope_id;
1719 * [in] Index to free
1725 * free index table entry
1727 * Used to free a previously allocated table entry.
1731 * The element is freed and given back to the session pool.
1735 * Frees an external index table action record.
1738 * Implementation of the internals of the external table will be a stack with
1741 * Returns success or failure code.
1743 int tf_free_tbl_entry(struct tf *tfp,
1744 struct tf_free_tbl_entry_parms *parms);
1747 * tf_set_tbl_entry parameter definition
1749 struct tf_set_tbl_entry_parms {
1751 * [in] Table scope identifier
1753 uint32_t tbl_scope_id;
1755 * [in] Receive or transmit direction
1759 * [in] Type of object to set
1761 enum tf_tbl_type type;
1769 uint16_t data_sz_in_bytes;
1771 * [in] External memory channel type to use
1773 enum tf_ext_mem_chan_type chan_type;
1775 * [in] Entry index to write to
1781 * set index table entry
1783 * Used to set an application programmed index table entry into a
1784 * previous allocated table location.
1786 * Returns success or failure code.
1788 int tf_set_tbl_entry(struct tf *tfp,
1789 struct tf_set_tbl_entry_parms *parms);
1792 * tf_get_shared_tbl_increment parameter definition
1794 struct tf_get_shared_tbl_increment_parms {
1796 * [in] Receive or transmit direction
1800 * [in] Type of object to set
1802 enum tf_tbl_type type;
1804 * [out] Value to increment by for resource type
1806 uint32_t increment_cnt;
1810 * tf_get_shared_tbl_increment
1812 * This API is currently only required for use in the shared
1813 * session for Thor (p58) actions. An increment count is returned per
1814 * type to indicate how much to increment the start by for each
1815 * entry (see tf_resource_info)
1817 * Returns success or failure code.
1819 int tf_get_shared_tbl_increment(struct tf *tfp,
1820 struct tf_get_shared_tbl_increment_parms *parms);
1823 * tf_get_tbl_entry parameter definition
1825 struct tf_get_tbl_entry_parms {
1827 * [in] Receive or transmit direction
1831 * [in] Type of object to get
1833 enum tf_tbl_type type;
1841 uint16_t data_sz_in_bytes;
1843 * [in] External memory channel type to use
1845 enum tf_ext_mem_chan_type chan_type;
1847 * [in] Entry index to read
1853 * get index table entry
1855 * Used to retrieve a previous set index table entry.
1857 * Reads and compares with the shadow table copy (if enabled) (only
1858 * for internal objects).
1860 * Returns success or failure code. Failure will be returned if the
1861 * provided data buffer is too small for the data type requested.
1863 int tf_get_tbl_entry(struct tf *tfp,
1864 struct tf_get_tbl_entry_parms *parms);
1867 * tf_bulk_get_tbl_entry parameter definition
1869 struct tf_bulk_get_tbl_entry_parms {
1871 * [in] Receive or transmit direction
1875 * [in] Type of object to get
1877 enum tf_tbl_type type;
1879 * [in] Starting index to read from
1881 uint32_t starting_idx;
1883 * [in] Number of sequential entries
1885 uint16_t num_entries;
1887 * [in] Size of the single entry
1889 uint16_t entry_sz_in_bytes;
1891 * [out] Host physical address, where the data
1892 * will be copied to by the firmware.
1893 * Use tfp_calloc() API and mem_pa
1894 * variable of the tfp_calloc_parms
1895 * structure for the physical address.
1897 uint64_t physical_mem_addr;
1899 * [in] External memory channel type to use
1901 enum tf_ext_mem_chan_type chan_type;
1905 * Bulk get index table entry
1907 * Used to retrieve a set of index table entries.
1909 * Entries within the range may not have been allocated using
1910 * tf_alloc_tbl_entry() at the time of access. But the range must
1911 * be within the bounds determined from tf_open_session() for the
1912 * given table type. Currently, this is only used for collecting statistics.
1914 * Returns success or failure code. Failure will be returned if the
1915 * provided data buffer is too small for the data type requested.
1917 int tf_bulk_get_tbl_entry(struct tf *tfp,
1918 struct tf_bulk_get_tbl_entry_parms *parms);
1921 * @page exact_match Exact Match Table
1923 * @ref tf_insert_em_entry
1925 * @ref tf_delete_em_entry
1927 * @ref tf_search_em_entry
1931 * tf_insert_em_entry parameter definition
1933 struct tf_insert_em_entry_parms {
1935 * [in] receive or transmit direction
1939 * [in] internal or external
1943 * [in] ID of table scope to use (external only)
1945 uint32_t tbl_scope_id;
1947 * [in] ptr to structure containing key fields
1951 * [in] key bit length
1953 uint16_t key_sz_in_bits;
1955 * [in] ptr to structure containing result field
1959 * [out] result size in bits
1961 uint16_t em_record_sz_in_bits;
1963 * [in] duplicate check flag
1967 * [in] External memory channel type to use
1969 enum tf_ext_mem_chan_type chan_type;
1971 * [out] Flow handle value for the inserted entry. This is encoded
1972 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1974 uint64_t flow_handle;
1976 * [out] Flow id is returned as null (internal)
1977 * Flow id is the GFID value for the inserted entry (external)
1978 * This is the value written to the BD and useful information for mark.
1983 * tf_delete_em_entry parameter definition
1985 struct tf_delete_em_entry_parms {
1987 * [in] receive or transmit direction
1991 * [in] internal or external
1995 * [in] ID of table scope to use (external only)
1997 uint32_t tbl_scope_id;
1999 * [out] The index of the entry
2003 * [in] External memory channel type to use
2005 enum tf_ext_mem_chan_type chan_type;
2007 * [in] structure containing flow delete handle information
2009 uint64_t flow_handle;
2012 * tf_move_em_entry parameter definition
2014 struct tf_move_em_entry_parms {
2016 * [in] receive or transmit direction
2020 * [in] internal or external
2024 * [in] ID of table scope to use (external only)
2026 uint32_t tbl_scope_id;
2028 * [in] ID of table interface to use (SR2 only)
2032 * [in] epoch group IDs of entry to delete
2033 * 2 element array with 2 ids. (SR2 only)
2037 * [out] The index of the entry
2041 * [in] External memory channel type to use
2043 enum tf_ext_mem_chan_type chan_type;
2045 * [in] The index of the new EM record
2049 * [in] structure containing flow delete handle information
2051 uint64_t flow_handle;
2054 * tf_search_em_entry parameter definition (Future)
2056 struct tf_search_em_entry_parms {
2058 * [in] receive or transmit direction
2062 * [in] internal or external
2066 * [in] ID of table scope to use (external only)
2068 uint32_t tbl_scope_id;
2070 * [in] ptr to structure containing key fields
2074 * [in] key bit length
2076 uint16_t key_sz_in_bits;
2078 * [in/out] ptr to structure containing EM record fields
2082 * [out] result size in bits
2084 uint16_t em_record_sz_in_bits;
2086 * [in] External memory channel type to use
2088 enum tf_ext_mem_chan_type chan_type;
2090 * [in] ptr to structure containing flow delete handle
2092 uint64_t flow_handle;
2096 * insert em hash entry in internal table memory
2100 * This API inserts an exact match entry into internal EM table memory
2101 * of the specified direction.
2103 * Note: The EM record is managed within the TruFlow core and not the
2106 * Shadow copy of internal record table an association with hash and 1,2, or 4
2107 * associated buckets
2110 * This API inserts an exact match entry into DRAM EM table memory of the
2111 * specified direction and table scope.
2113 * The insertion of duplicate entries in an EM table is not permitted. If a
2114 * TruFlow application can guarantee that it will never insert duplicates, it
2115 * can disable duplicate checking by passing a zero value in the dup_check
2116 * parameter to this API. This will optimize performance. Otherwise, the
2117 * TruFlow library will enforce protection against inserting duplicate entries.
2119 * Flow handle is defined in this document:
2121 * https://docs.google.com
2122 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
2124 * Returns success or busy code.
2127 int tf_insert_em_entry(struct tf *tfp,
2128 struct tf_insert_em_entry_parms *parms);
2131 * delete em hash entry table memory
2135 * This API deletes an exact match entry from internal EM table memory of the
2136 * specified direction. If a valid flow ptr is passed in then that takes
2137 * precedence over the pointer to the complete key passed in.
2142 * This API deletes an exact match entry from EM table memory of the specified
2143 * direction and table scope. If a valid flow handle is passed in then that
2144 * takes precedence over the pointer to the complete key passed in.
2146 * The TruFlow library may release a dynamic bucket when an entry is deleted.
2149 * Returns success or not found code
2153 int tf_delete_em_entry(struct tf *tfp,
2154 struct tf_delete_em_entry_parms *parms);
2157 * search em hash entry table memory (Future)
2161 * This API looks up an EM entry in table memory with the specified EM
2162 * key or flow (flow takes precedence) and direction.
2164 * The status will be one of: success or entry not found. If the lookup
2165 * succeeds, a pointer to the matching entry and the result record associated
2166 * with the matching entry will be provided.
2168 * If flow_handle is set, search shadow copy.
2170 * Otherwise, query the fw with key to get result.
2174 * This API looks up an EM entry in table memory with the specified EM
2175 * key or flow_handle (flow takes precedence), direction and table scope.
2177 * The status will be one of: success or entry not found. If the lookup
2178 * succeeds, a pointer to the matching entry and the result record associated
2179 * with the matching entry will be provided.
2181 * Returns success or not found code
2184 int tf_search_em_entry(struct tf *tfp,
2185 struct tf_search_em_entry_parms *parms);
2188 * @page global Global Configuration
2190 * @ref tf_set_global_cfg
2192 * @ref tf_get_global_cfg
2195 * Tunnel Encapsulation Offsets
2197 enum tf_tunnel_encap_offsets {
2199 TF_TUNNEL_ENCAP_NAT,
2200 TF_TUNNEL_ENCAP_MPLS,
2201 TF_TUNNEL_ENCAP_VXLAN,
2202 TF_TUNNEL_ENCAP_GENEVE,
2203 TF_TUNNEL_ENCAP_NVGRE,
2204 TF_TUNNEL_ENCAP_GRE,
2205 TF_TUNNEL_ENCAP_FULL_GENERIC
2208 * Global Configuration Table Types
2210 enum tf_global_config_type {
2211 TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */
2212 TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */
2213 TF_COUNTER_CFG, /**< Counter Configuration (CNTRS_CTRL) */
2214 TF_METER_CFG, /**< Meter Config(ACTP4_FMTCR) */
2215 TF_METER_INTERVAL_CFG, /**< Meter Interval Config(FMTCR_INTERVAL) */
2216 TF_GLOBAL_CFG_TYPE_MAX
2220 * tf_global_cfg parameter definition
2222 struct tf_global_cfg_parms {
2224 * [in] receive or transmit direction
2228 * [in] Global config type
2230 enum tf_global_config_type type;
2232 * [in] Offset @ the type
2236 * [in/out] Value of the configuration
2237 * set - Read, Modify and Write
2238 * get - Read the full configuration
2242 * [in] Configuration mask
2243 * set - Read, Modify with mask and Write
2246 uint8_t *config_mask;
2248 * [in] struct containing size
2250 uint16_t config_sz_in_bytes;
2254 * Get global configuration
2256 * Retrieve the configuration
2258 * Returns success or failure code.
2260 int tf_get_global_cfg(struct tf *tfp,
2261 struct tf_global_cfg_parms *parms);
2264 * Update the global configuration table
2266 * Read, modify write the value.
2268 * Returns success or failure code.
2270 int tf_set_global_cfg(struct tf *tfp,
2271 struct tf_global_cfg_parms *parms);
2274 * @page if_tbl Interface Table Access
2276 * @ref tf_set_if_tbl_entry
2278 * @ref tf_get_if_tbl_entry
2280 * @ref tf_restore_if_tbl_entry
2283 * Enumeration of TruFlow interface table types.
2285 enum tf_if_tbl_type {
2286 /** Default Profile L2 Context Entry */
2287 TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
2288 /** Default Profile TCAM/Lookup Action Record Pointer Table */
2289 TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
2290 /** Error Profile TCAM Miss Action Record Pointer Table */
2291 TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
2292 /** Default Error Profile TCAM Miss Action Record Pointer Table */
2293 TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
2294 /** Ingress lookup table */
2296 /** VNIC/SVIF Properties Table */
2297 TF_IF_TBL_TYPE_VSPT,
2302 * tf_set_if_tbl_entry parameter definition
2304 struct tf_set_if_tbl_entry_parms {
2306 * [in] Receive or transmit direction
2310 * [in] Type of object to set
2312 enum tf_if_tbl_type type;
2320 uint16_t data_sz_in_bytes;
2322 * [in] Interface to write
2328 * set interface table entry
2330 * Used to set an interface table. This API is used for managing tables indexed
2331 * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
2333 * Returns success or failure code.
2335 int tf_set_if_tbl_entry(struct tf *tfp,
2336 struct tf_set_if_tbl_entry_parms *parms);
2339 * tf_get_if_tbl_entry parameter definition
2341 struct tf_get_if_tbl_entry_parms {
2343 * [in] Receive or transmit direction
2347 * [in] Type of table to get
2349 enum tf_if_tbl_type type;
2357 uint16_t data_sz_in_bytes;
2359 * [in] Entry index to read
2365 * get interface table entry
2367 * Used to retrieve an interface table entry.
2369 * Reads the interface table entry value
2371 * Returns success or failure code. Failure will be returned if the
2372 * provided data buffer is too small for the data type requested.
2374 int tf_get_if_tbl_entry(struct tf *tfp,
2375 struct tf_get_if_tbl_entry_parms *parms);
2378 * tf_get_version parameters definition.
2380 struct tf_get_version_parms {
2384 * Device type for the session.
2386 enum tf_device_type device_type;
2390 * The pointer to the parent bp struct. This is only used for HWRM
2391 * message passing within the portability layer. The type is struct
2398 * Version Major number.
2404 * Version Minor number.
2410 * Version Update number.
2415 * [out] dev_ident_caps
2417 * fw available identifier resource list
2419 uint32_t dev_ident_caps;
2422 * [out] dev_tbl_caps
2424 * fw available table resource list
2426 uint32_t dev_tbl_caps;
2429 * [out] dev_tcam_caps
2431 * fw available tcam resource list
2433 uint32_t dev_tcam_caps;
2438 * fw available em resource list
2440 uint32_t dev_em_caps;
2446 * Used to retrieve Truflow fw version information.
2448 * Returns success or failure code.
2450 int tf_get_version(struct tf *tfp,
2451 struct tf_get_version_parms *parms);
2454 * tf_query_sram_resources parameter definition
2456 struct tf_query_sram_resources_parms {
2460 * Device type for the session.
2462 enum tf_device_type device_type;
2466 * The pointer to the parent bp struct. This is only used for HWRM
2467 * message passing within the portability layer. The type is struct
2473 * [in] Receive or transmit direction
2478 * [out] Bank resource count in 8 bytes entry
2481 uint32_t bank_resc_count[TF_SRAM_BANK_ID_MAX];
2484 * [out] Dynamic SRAM Enable
2486 bool dynamic_sram_capable;
2489 * [out] SRAM profile
2491 uint8_t sram_profile;
2495 * Get SRAM resources information
2497 * Used to retrieve sram bank partition information
2499 * Returns success or failure code.
2501 int tf_query_sram_resources(struct tf *tfp,
2502 struct tf_query_sram_resources_parms *parms);
2505 * tf_set_sram_policy parameter definition
2507 struct tf_set_sram_policy_parms {
2511 * Device type for the session.
2513 enum tf_device_type device_type;
2516 * [in] Receive or transmit direction
2521 * [in] Array of Bank id for each truflow tbl type
2523 enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1];
2529 * Used to assign SRAM bank index to all truflow table type.
2531 * Returns success or failure code.
2533 int tf_set_sram_policy(struct tf *tfp,
2534 struct tf_set_sram_policy_parms *parms);
2537 * tf_get_sram_policy parameter definition
2539 struct tf_get_sram_policy_parms {
2543 * Device type for the session.
2545 enum tf_device_type device_type;
2548 * [in] Receive or transmit direction
2553 * [out] Array of Bank id for each truflow tbl type
2555 enum tf_sram_bank_id bank_id[TF_TBL_TYPE_ACT_MODIFY_64B + 1];
2561 * Used to get the assigned bank of table types.
2563 * Returns success or failure code.
2565 int tf_get_sram_policy(struct tf *tfp,
2566 struct tf_get_sram_policy_parms *parms);
2568 #endif /* _TF_CORE_H_ */