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 * EEM record AR helper
71 * Helper to handle the Action Record Pointer in the EEM Record Entry.
73 * Convert absolute offset to action record pointer in EEM record entry
74 * Convert action record pointer in EEM record entry to absolute offset
76 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
77 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
82 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
84 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
87 * @page general General
89 * @ref tf_open_session
91 * @ref tf_attach_session
93 * @ref tf_close_session
97 * Session Version defines
99 * The version controls the format of the tf_session and
100 * tf_session_info structure. This is to assure upgrade between
101 * versions can be supported.
103 #define TF_SESSION_VER_MAJOR 1 /**< Major Version */
104 #define TF_SESSION_VER_MINOR 0 /**< Minor Version */
105 #define TF_SESSION_VER_UPDATE 0 /**< Update Version */
110 * Name of the TruFlow control channel interface. Expects
111 * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
113 #define TF_SESSION_NAME_MAX 64
115 #define TF_FW_SESSION_ID_INVALID 0xFF /**< Invalid FW Session ID define */
120 * Unique session identifier which includes PCIe bus info to
121 * distinguish the PF and session info to identify the associated
122 * TruFlow session. Session ID is constructed from the passed in
123 * ctrl_chan_name in tf_open_session() together with an allocated
124 * fw_session_id. Done by TruFlow on tf_open_session().
126 union tf_session_id {
132 uint8_t fw_session_id;
137 * Session Client Identifier
139 * Unique identifier for a client within a session. Session Client ID
140 * is constructed from the passed in session and a firmware allocated
141 * fw_session_client_id. Done by TruFlow on tf_open_session().
143 union tf_session_client_id {
146 uint8_t fw_session_id;
147 uint8_t fw_session_client_id;
154 * The version controls the format of the tf_session and
155 * tf_session_info structure. This is to assure upgrade between
156 * versions can be supported.
158 * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
160 struct tf_session_version {
167 * Session supported device types
169 enum tf_device_type {
170 TF_DEVICE_TYPE_WH = 0, /**< Whitney+ */
171 TF_DEVICE_TYPE_SR, /**< Stingray */
172 TF_DEVICE_TYPE_THOR, /**< Thor */
173 TF_DEVICE_TYPE_MAX /**< Maximum */
179 enum tf_module_type {
183 TF_MODULE_TYPE_IDENTIFIER,
187 TF_MODULE_TYPE_TABLE,
200 * Identifier resource types
202 enum tf_identifier_type {
205 * The L2 Context is returned from the L2 Ctxt TCAM lookup
206 * and can be used in WC TCAM or EM keys to virtualize further
209 TF_IDENT_TYPE_L2_CTXT_HIGH,
212 * The L2 Context is returned from the L2 Ctxt TCAM lookup
213 * and can be used in WC TCAM or EM keys to virtualize further
216 TF_IDENT_TYPE_L2_CTXT_LOW,
219 * The WC profile func is returned from the L2 Ctxt TCAM lookup
220 * to enable virtualization of the profile TCAM.
222 TF_IDENT_TYPE_PROF_FUNC,
225 * The WC profile ID is included in the WC lookup key
226 * to enable virtualization of the WC TCAM hardware.
228 TF_IDENT_TYPE_WC_PROF,
231 * The EM profile ID is included in the EM lookup key
232 * to enable virtualization of the EM hardware.
234 TF_IDENT_TYPE_EM_PROF,
237 * The L2 func is included in the ILT result and from recycling to
238 * enable virtualization of further lookups.
240 TF_IDENT_TYPE_L2_FUNC,
245 * Enumeration of TruFlow table types. A table type is used to identify a
248 * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
249 * the only table type that is connected with a table scope.
254 /** Wh+/SR/TH Action Record */
255 TF_TBL_TYPE_FULL_ACT_RECORD,
256 /** TH Compact Action Record */
257 TF_TBL_TYPE_COMPACT_ACT_RECORD,
258 /** (Future) Multicast Groups */
259 TF_TBL_TYPE_MCAST_GROUPS,
260 /** Wh+/SR/TH Action Encap 8 Bytes */
261 TF_TBL_TYPE_ACT_ENCAP_8B,
262 /** Wh+/SR/TH Action Encap 16 Bytes */
263 TF_TBL_TYPE_ACT_ENCAP_16B,
264 /** WH+/SR/TH Action Encap 32 Bytes */
265 TF_TBL_TYPE_ACT_ENCAP_32B,
266 /** Wh+/SR/TH Action Encap 64 Bytes */
267 TF_TBL_TYPE_ACT_ENCAP_64B,
268 /** WH+/SR/TH Action Source Properties SMAC */
269 TF_TBL_TYPE_ACT_SP_SMAC,
270 /** Wh+/SR/TH Action Source Properties SMAC IPv4 */
271 TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
272 /** WH+/SR/TH Action Source Properties SMAC IPv6 */
273 TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
274 /** Wh+/SR/TH Action Statistics 64 Bits */
275 TF_TBL_TYPE_ACT_STATS_64,
276 /** Wh+/SR Action Modify IPv4 Source */
277 TF_TBL_TYPE_ACT_MODIFY_IPV4,
278 /** TH 8B Modify Record */
279 TF_TBL_TYPE_ACT_MODIFY_8B,
280 /** TH 16B Modify Record */
281 TF_TBL_TYPE_ACT_MODIFY_16B,
282 /** TH 32B Modify Record */
283 TF_TBL_TYPE_ACT_MODIFY_32B,
284 /** TH 64B Modify Record */
285 TF_TBL_TYPE_ACT_MODIFY_64B,
286 /** (Future) Meter Profiles */
287 TF_TBL_TYPE_METER_PROF,
288 /** (Future) Meter Instance */
289 TF_TBL_TYPE_METER_INST,
290 /** Wh+/SR/Th Mirror Config */
291 TF_TBL_TYPE_MIRROR_CONFIG,
294 /** (Future) TH Metadata */
295 TF_TBL_TYPE_METADATA,
296 /** (Future) TH CT State */
297 TF_TBL_TYPE_CT_STATE,
298 /** (Future) TH Range Profile */
299 TF_TBL_TYPE_RANGE_PROF,
300 /** TH EM Flexible Key builder */
302 /** TH WC Flexible Key builder */
308 * External table type - initially 1 poolsize entries.
309 * All External table types are associated with a table
310 * scope. Internal types are not. Currently this is
311 * a pool of 64B entries.
317 /** Enable Shared TCAM Management
319 * This feature allows for management of high and low pools within
320 * the WC TCAM. These pools are only valid when this feature is enabled.
322 * For normal OVS-DPDK operation, this feature is not required and can
323 * be disabled by commenting out TF_TCAM_SHARED in this header file.
327 * When a shared session is created with WC TCAM entries allocated during
328 * tf_open_session(), the TF_TCAM_TBL_TYPE_WC_TCAM pool entries will be divided
329 * into 2 equal pools - TF_TCAM_TBL_TYPE_WC_TCAM_HIGH and
330 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW.
332 * The user will allocate and free entries from either of these pools to obtain
333 * WC_TCAM entry offsets. For the WC_TCAM_HI/LO management, alloc/free is done
334 * using the tf_alloc_tcam_entry()/tf_free_tcam_entry() APIs for the shared
337 * The use case for this feature is so that applications can have a shared
338 * session and use the TF core to allocate/set/free entries within a given
339 * region of the WC_TCAM within the shared session. Application A only writes
340 * to the LOW region for example and Application B only writes to the HIGH
341 * region during normal operation. After Application A goes down, Application
342 * B may decide to overwrite the LOW region with the HIGH region's entries
343 * and switch to the low region.
345 * For other TCAM types in the shared session, no alloc/free operations are
346 * permitted. Only set should be used for other TCAM table types after getting
347 * the range as provided by the tf_get_resource_info() API.
350 #define TF_TCAM_SHARED 1
355 enum tf_tcam_tbl_type {
356 /** L2 Context TCAM */
357 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH,
358 /** L2 Context TCAM */
359 TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW,
361 TF_TCAM_TBL_TYPE_PROF_TCAM,
363 TF_TCAM_TBL_TYPE_WC_TCAM,
364 /** Source Properties TCAM */
365 TF_TCAM_TBL_TYPE_SP_TCAM,
366 /** Connection Tracking Rule TCAM */
367 TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
368 /** Virtual Edge Bridge TCAM */
369 TF_TCAM_TBL_TYPE_VEB_TCAM,
370 #ifdef TF_TCAM_SHARED
371 /** Wildcard TCAM HI Priority */
372 TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
373 /** Wildcard TCAM Low Priority */
374 TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
375 #endif /* TF_TCAM_SHARED */
382 enum tf_search_status {
383 /** The entry was not found, but an idx was allocated if requested. */
385 /** The entry was found, and the result/idx are valid */
387 /** The entry was not found and the table is full */
393 * These defines are provisioned during
396 enum tf_em_tbl_type {
397 /** The number of internal EM records for the session */
398 TF_EM_TBL_TYPE_EM_RECORD,
399 /** The number of table scopes reequested */
400 TF_EM_TBL_TYPE_TBL_SCOPE,
405 * TruFlow Session Information
407 * Structure defining a TruFlow Session, also known as a Management
408 * session. This structure is initialized at time of
409 * tf_open_session(). It is passed to all of the TruFlow APIs as way
410 * to prescribe and isolate resources between different TruFlow ULP
413 * Ownership of the elements is split between ULP and TruFlow. Please
414 * see the individual elements.
416 struct tf_session_info {
418 * TrueFlow Version. Used to control the structure layout when
419 * sharing sessions. No guarantee that a secondary process
420 * would come from the same version of an executable.
421 * TruFlow initializes this variable on tf_open_session().
426 struct tf_session_version ver;
428 * will be STAILQ_ENTRY(tf_session_info) next
435 * Session ID is a unique identifier for the session. TruFlow
436 * initializes this variable during tf_open_session()
440 * Access: Truflow & ULP
442 union tf_session_id session_id;
444 * Protects access to core_data. Lock is initialized and owned
445 * by ULP. TruFlow can access the core_data without checking
453 * The core_data holds the TruFlow tf_session data
454 * structure. This memory is allocated and owned by TruFlow on
457 * TruFlow uses this memory for session management control
458 * until the session is closed by ULP. Access control is done
459 * by the spin_lock which ULP controls ahead of TruFlow API
462 * Please see tf_open_session_parms for specification details
470 * The core_data_sz_bytes specifies the size of core_data in
473 * The size is set by TruFlow on tf_open_session().
475 * Please see tf_open_session_parms for specification details
481 uint32_t core_data_sz_bytes;
487 * Contains a pointer to the session info. Allocated by ULP and passed
488 * to TruFlow using tf_open_session(). TruFlow will populate the
489 * session info at that time. A TruFlow Session can be used by more
490 * than one PF/VF by using the tf_open_session().
492 * It is expected that ULP allocates this memory as shared memory.
494 * NOTE: This struct must be within the BNXT PMD struct bnxt
495 * (bp). This allows use of container_of() to get access to the PMD.
498 struct tf_session_info *session;
500 * the pointer to the parent bp struct
506 * Identifier resource definition
508 struct tf_identifier_resources {
510 * Array of TF Identifiers where each entry is expected to be
511 * set to the requested resource number of that specific type.
512 * The index used is tf_identifier_type.
514 uint16_t cnt[TF_IDENT_TYPE_MAX];
518 * Table type resource definition
520 struct tf_tbl_resources {
522 * Array of TF Table types where each entry is expected to be
523 * set to the requeste resource number of that specific
524 * type. The index used is tf_tbl_type.
526 uint16_t cnt[TF_TBL_TYPE_MAX];
530 * TCAM type resource definition
532 struct tf_tcam_resources {
534 * Array of TF TCAM types where each entry is expected to be
535 * set to the requested resource number of that specific
536 * type. The index used is tf_tcam_tbl_type.
538 uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
542 * EM type resource definition
544 struct tf_em_resources {
546 * Array of TF EM table types where each entry is expected to
547 * be set to the requested resource number of that specific
548 * type. The index used is tf_em_tbl_type.
550 uint16_t cnt[TF_EM_TBL_TYPE_MAX];
554 * tf_session_resources parameter definition.
556 struct tf_session_resources {
558 * [in] Requested Identifier Resources
560 * Number of identifier resources requested for the
563 struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
565 * [in] Requested Index Table resource counts
567 * The number of index table resources requested for the
570 struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
572 * [in] Requested TCAM Table resource counts
574 * The number of TCAM table resources requested for the
578 struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
580 * [in] Requested EM resource counts
582 * The number of internal EM table resources requested for the
585 struct tf_em_resources em_cnt[TF_DIR_MAX];
589 * tf_open_session parameters definition.
591 struct tf_open_session_parms {
593 * [in] ctrl_chan_name
595 * String containing name of control channel interface to be
596 * used for this session to communicate with firmware.
598 * The ctrl_chan_name can be looked up by using
599 * rte_eth_dev_get_name_by_port() within the ULP.
601 * ctrl_chan_name will be used as part of a name for any
602 * shared memory allocation. The ctrl_chan_name is usually in format
603 * 0000:02:00.0. The name for shared session is 0000:02:00.0-tf_shared.
605 char ctrl_chan_name[TF_SESSION_NAME_MAX];
609 * Boolean controlling the use and availability of shadow
610 * copy. Shadow copy will allow the TruFlow to keep track of
611 * resource content on the firmware side without having to
612 * query firmware. Additional private session core_data will
613 * be allocated if this boolean is set to 'true', default
616 * Size of memory depends on the NVM Resource settings for the
621 * [in/out] session_id
623 * Session_id is unique per session.
625 * Session_id is composed of domain, bus, device and
626 * fw_session_id. The construction is done by parsing the
627 * ctrl_chan_name together with allocation of a fw_session_id.
629 * The session_id allows a session to be shared between devices.
631 union tf_session_id session_id;
633 * [in/out] session_client_id
635 * Session_client_id is unique per client.
637 * Session_client_id is composed of session_id and the
638 * fw_session_client_id fw_session_id. The construction is
639 * done by parsing the ctrl_chan_name together with allocation
640 * of a fw_session_client_id during tf_open_session().
642 * A reference count will be incremented in the session on
643 * which a client is created.
645 * A session can first be closed if there is one Session
646 * Client left. Session Clients should closed using
647 * tf_close_session().
649 union tf_session_client_id session_client_id;
653 * Device type for the session.
655 enum tf_device_type device_type;
659 * Resource allocation for the session.
661 struct tf_session_resources resources;
665 * The pointer to the parent bp struct. This is only used for HWRM
666 * message passing within the portability layer. The type is struct
672 * [out] shared_session_creator
674 * Indicates whether the application created the session if set.
675 * Otherwise the shared session already existed. Just for information
678 int shared_session_creator;
682 * Opens a new TruFlow Session or session client.
684 * What gets created depends on the passed in tfp content. If the tfp does not
685 * have prior session data a new session with associated session client. If tfp
686 * has a session already a session client will be created. In both cases the
687 * session client is created using the provided ctrl_chan_name.
689 * In case of session creation TruFlow will allocate session specific memory to
690 * hold its session data. This data is private to TruFlow.
692 * No other TruFlow APIs will succeed unless this API is first called
695 * tf_open_session() returns a session id and session client id. These are
696 * also stored within the tfp structure passed in to all other APIs.
698 * A Session or session client can be closed using tf_close_session().
700 * There are 2 types of sessions - shared and not. For non-shared all
701 * the allocated resources are owned and managed by a single session instance.
702 * No other applications have access to the resources owned by the non-shared
703 * session. For a shared session, resources are shared between 2 applications.
705 * When the caller of tf_open_session() sets the ctrl_chan_name[] to a name
706 * like "0000:02:00.0-tf_shared", it is a request to create a new "shared"
707 * session in the firmware or access the existing shared session. There is
708 * only 1 shared session that can be created. If the shared session has
709 * already been created in the firmware, this API will return this indication
710 * by clearing the shared_session_creator flag. Only the first shared session
711 * create will have the shared_session_creator flag set.
713 * The shared session should always be the first session to be created by
714 * application and the last session closed due to RM management preference.
716 * Sessions remain open in the firmware until the last client of the session
717 * closes the session (tf_close_session()).
720 * Pointer to TF handle
723 * Pointer to open parameters
726 * - (0) if successful.
727 * - (-EINVAL) on failure.
729 int tf_open_session(struct tf *tfp,
730 struct tf_open_session_parms *parms);
733 * General internal resource info
735 * TODO: remove tf_rm_new_entry structure and use this structure
738 struct tf_resource_info {
744 * Identifier resource definition
746 struct tf_identifier_resource_info {
748 * Array of TF Identifiers. The index used is tf_identifier_type.
750 struct tf_resource_info info[TF_IDENT_TYPE_MAX];
754 * Table type resource info definition
756 struct tf_tbl_resource_info {
758 * Array of TF Table types. The index used is tf_tbl_type.
760 struct tf_resource_info info[TF_TBL_TYPE_MAX];
764 * TCAM type resource definition
766 struct tf_tcam_resource_info {
768 * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
770 struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
774 * EM type resource definition
776 struct tf_em_resource_info {
778 * Array of TF EM table types. The index used is tf_em_tbl_type.
780 struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
784 * tf_session_resources parameter definition.
786 struct tf_session_resource_info {
788 * [in] Requested Identifier Resources
790 * Number of identifier resources requested for the
793 struct tf_identifier_resource_info ident[TF_DIR_MAX];
795 * [in] Requested Index Table resource counts
797 * The number of index table resources requested for the
800 struct tf_tbl_resource_info tbl[TF_DIR_MAX];
802 * [in] Requested TCAM Table resource counts
804 * The number of TCAM table resources requested for the
808 struct tf_tcam_resource_info tcam[TF_DIR_MAX];
810 * [in] Requested EM resource counts
812 * The number of internal EM table resources requested for the
815 struct tf_em_resource_info em[TF_DIR_MAX];
819 * tf_get_session_resources parameter definition.
821 struct tf_get_session_info_parms {
823 * [out] the structure is used to return the information of
824 * allocated resources.
827 struct tf_session_resource_info session_info;
831 * Gets info about a TruFlow Session
833 * Get info about the session which has been created. Whether it exists and
834 * what resource start and stride offsets are in use. This API is primarily
835 * intended to be used by an application which has created a shared session
836 * This application needs to obtain the resources which have already been
837 * allocated for the shared session.
840 * Pointer to TF handle
843 * Pointer to get parameters
846 * - (0) if successful.
847 * - (-EINVAL) on failure.
849 int tf_get_session_info(struct tf *tfp,
850 struct tf_get_session_info_parms *parms);
854 * tf_attach_session parameters definition.
856 struct tf_attach_session_parms {
858 * [in] ctrl_chan_name
860 * String containing name of control channel interface to be
861 * used for this session to communicate with firmware.
863 * The ctrl_chan_name can be looked up by using
864 * rte_eth_dev_get_name_by_port() within the ULP.
866 * ctrl_chan_name will be used as part of a name for any
867 * shared memory allocation.
869 char ctrl_chan_name[TF_SESSION_NAME_MAX];
872 * [in] attach_chan_name
874 * String containing name of attach channel interface to be
875 * used for this session.
877 * The attach_chan_name must be given to a 2nd process after
878 * the primary process has been created. This is the
879 * ctrl_chan_name of the primary process and is used to find
880 * the shared memory for the session that the attach is going
883 char attach_chan_name[TF_SESSION_NAME_MAX];
888 * Session_id is unique per session. For Attach the session_id
889 * should be the session_id that was returned on the first
892 * Session_id is composed of domain, bus, device and
893 * fw_session_id. The construction is done by parsing the
894 * ctrl_chan_name together with allocation of a fw_session_id
895 * during tf_open_session().
897 * A reference count will be incremented on attach. A session
898 * is first fully closed when reference count is zero by
899 * calling tf_close_session().
901 union tf_session_id session_id;
907 * Allows a 2nd application instance to attach to an existing
908 * session. Used when a session is to be shared between two processes.
910 * Attach will increment a ref count as to manage the shared session data.
913 * Pointer to TF handle
916 * Pointer to attach parameters
919 * - (0) if successful.
920 * - (-EINVAL) on failure.
922 int tf_attach_session(struct tf *tfp,
923 struct tf_attach_session_parms *parms);
926 * Closes an existing session client or the session it self. The
927 * session client is default closed and if the session reference count
928 * is 0 then the session is closed as well.
930 * On session close all hardware and firmware state associated with
931 * the TruFlow application is cleaned up.
933 * The session client is extracted from the tfp. Thus tf_close_session()
934 * cannot close a session client on behalf of another function.
936 * Returns success or failure code.
938 int tf_close_session(struct tf *tfp);
941 * @page ident Identity Management
943 * @ref tf_alloc_identifier
945 * @ref tf_free_identifier
948 * tf_alloc_identifier parameter definition
950 struct tf_alloc_identifier_parms {
952 * [in] receive or transmit direction
956 * [in] Identifier type
958 enum tf_identifier_type ident_type;
960 * [out] Allocated identifier
966 * tf_free_identifier parameter definition
968 struct tf_free_identifier_parms {
970 * [in] receive or transmit direction
974 * [in] Identifier type
976 enum tf_identifier_type ident_type;
983 * [out] Current refcnt after free
989 * tf_search_identifier parameter definition (experimental)
991 struct tf_search_identifier_parms {
993 * [in] receive or transmit direction
997 * [in] Identifier type
999 enum tf_identifier_type ident_type;
1001 * [in] Identifier data to search for
1005 * [out] Set if matching identifier found
1009 * [out] Current ref count after allocation
1015 * allocate identifier resource
1017 * TruFlow core will allocate a free id from the per identifier resource type
1018 * pool reserved for the session during tf_open(). No firmware is involved.
1020 * If shadow copy is enabled, the internal ref_cnt is set to 1 in the
1021 * shadow table for a newly allocated resource.
1023 * Returns success or failure code.
1025 int tf_alloc_identifier(struct tf *tfp,
1026 struct tf_alloc_identifier_parms *parms);
1029 * free identifier resource
1031 * TruFlow core will return an id back to the per identifier resource type pool
1032 * reserved for the session. No firmware is involved. During tf_close, the
1033 * complete pool is returned to the firmware.
1035 * additional operation (experimental)
1036 * Decrement reference count. Only release resource once refcnt goes to 0 if
1037 * shadow copy is enabled.
1039 * Returns success or failure code.
1041 int tf_free_identifier(struct tf *tfp,
1042 struct tf_free_identifier_parms *parms);
1045 * Search identifier resource (experimental)
1047 * If the shadow copy is enabled search_id is used to search for a matching
1048 * entry in the shadow table. The shadow table consists of an array of
1049 * reference counts indexed by identifier. If a matching entry is found hit is
1050 * set to TRUE, refcnt is increased by 1 and returned. Otherwise, hit is
1051 * set to false and refcnt is set to 0.
1053 * TODO: we may need a per table internal shadow copy enable flag to stage
1054 * the shadow table implementation. We do not need the shadow table for other
1055 * tables at this time so we may only want to enable the identifier shadow.
1057 * TODO: remove this pseudocode below added to show that if search fails
1058 * we shouldn't allocate a new entry but return.
1060 * identifier alloc (search_en=1)
1061 * if (ident is allocated and ref_cnt >=1)
1062 * return ident - hit is set, incr refcnt
1067 int tf_search_identifier(struct tf *tfp,
1068 struct tf_search_identifier_parms *parms);
1071 * @page dram_table DRAM Table Scope Interface
1073 * @ref tf_alloc_tbl_scope
1075 * @ref tf_free_tbl_scope
1077 * If we allocate the EEM memory from the core, we need to store it in
1078 * the shared session data structure to make sure it can be freed later.
1079 * (for example if the PF goes away)
1081 * Current thought is that memory is allocated within core.
1085 * tf_alloc_tbl_scope_parms definition
1087 struct tf_alloc_tbl_scope_parms {
1089 * [in] All Maximum key size required.
1091 uint16_t rx_max_key_sz_in_bits;
1093 * [in] Maximum Action size required (includes inlined items)
1095 uint16_t rx_max_action_entry_sz_in_bits;
1097 * [in] Memory size in Megabytes
1098 * Total memory size allocated by user to be divided
1099 * up for actions, hash, counters. Only inline external actions.
1100 * Use this variable or the number of flows, do not set both.
1102 uint32_t rx_mem_size_in_mb;
1104 * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
1106 uint32_t rx_num_flows_in_k;
1108 * [in] SR2 only receive table access interface id
1110 uint32_t rx_tbl_if_id;
1112 * [in] All Maximum key size required.
1114 uint16_t tx_max_key_sz_in_bits;
1116 * [in] Maximum Action size required (includes inlined items)
1118 uint16_t tx_max_action_entry_sz_in_bits;
1120 * [in] Memory size in Megabytes
1121 * Total memory size allocated by user to be divided
1122 * up for actions, hash, counters. Only inline external actions.
1124 uint32_t tx_mem_size_in_mb;
1126 * [in] Number of flows * 1000
1128 uint32_t tx_num_flows_in_k;
1130 * [in] SR2 only receive table access interface id
1132 uint32_t tx_tbl_if_id;
1134 * [in] Flush pending HW cached flows every 1/10th of value
1135 * set in seconds, both idle and active flows are flushed
1136 * from the HW cache. If set to 0, this feature will be disabled.
1138 uint8_t hw_flow_cache_flush_timer;
1140 * [out] table scope identifier
1142 uint32_t tbl_scope_id;
1145 * tf_free_tbl_scope_parms definition
1147 struct tf_free_tbl_scope_parms {
1149 * [in] table scope identifier
1151 uint32_t tbl_scope_id;
1155 * tf_map_tbl_scope_parms definition
1157 struct tf_map_tbl_scope_parms {
1159 * [in] table scope identifier
1161 uint32_t tbl_scope_id;
1163 * [in] Which parifs are associated with this table scope. Bit 0
1164 * indicates parif 0.
1166 uint16_t parif_bitmask;
1170 * allocate a table scope
1172 * The scope is a software construct to identify an EEM table. This function will
1173 * divide the hash memory/buckets and records according to the device
1174 * device constraints based upon calculations using either the number of flows
1175 * requested or the size of memory indicated. Other parameters passed in
1176 * determine the configuration (maximum key size, maximum external action record
1179 * A single API is used to allocate a common table scope identifier in both
1180 * receive and transmit CFA. The scope identifier is common due to nature of
1181 * connection tracking sending notifications between RX and TX direction.
1183 * The receive and transmit table access identifiers specify which rings will
1184 * be used to initialize table DRAM. The application must ensure mutual
1185 * exclusivity of ring usage for table scope allocation and any table update
1188 * The hash table buckets, EM keys, and EM lookup results are stored in the
1189 * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The
1190 * hash table buckets are stored at the beginning of that memory.
1192 * NOTE: No EM internal setup is done here. On chip EM records are managed
1193 * internally by TruFlow core.
1195 * Returns success or failure code.
1197 int tf_alloc_tbl_scope(struct tf *tfp,
1198 struct tf_alloc_tbl_scope_parms *parms);
1201 * map a table scope (legacy device only Wh+/SR)
1203 * Map a table scope to one or more partition interfaces (parifs).
1204 * The parif can be remapped in the L2 context lookup for legacy devices. This
1205 * API allows a number of parifs to be mapped to the same table scope. On
1206 * legacy devices a table scope identifies one of 16 sets of EEM table base
1207 * addresses and is associated with a PF communication channel. The associated
1208 * PF must be configured for the table scope to operate.
1210 * An L2 context TCAM lookup returns a remapped parif value used to
1211 * index into the set of 16 parif_to_pf registers which are used to map to one
1212 * of the 16 table scopes. This API allows the user to map the parifs in the
1213 * mask to the previously allocated table scope (EEM table).
1215 * Returns success or failure code.
1217 int tf_map_tbl_scope(struct tf *tfp,
1218 struct tf_map_tbl_scope_parms *parms);
1220 * free a table scope
1222 * Firmware checks that the table scope ID is owned by the TruFlow
1223 * session, verifies that no references to this table scope remains
1224 * or Profile TCAM entries for either CFA (RX/TX) direction,
1225 * then frees the table scope ID.
1227 * Returns success or failure code.
1229 int tf_free_tbl_scope(struct tf *tfp,
1230 struct tf_free_tbl_scope_parms *parms);
1233 * @page tcam TCAM Access
1235 * @ref tf_search_tcam_entry
1237 * @ref tf_alloc_tcam_entry
1239 * @ref tf_set_tcam_entry
1241 * @ref tf_get_tcam_entry
1243 * @ref tf_free_tcam_entry
1245 #ifdef TF_TCAM_SHARED
1246 * @ref tf_move_tcam_shared_entries
1251 * tf_search_tcam_entry parameter definition (experimental)
1253 struct tf_search_tcam_entry_parms {
1255 * [in] receive or transmit direction
1259 * [in] TCAM table type
1261 enum tf_tcam_tbl_type tcam_tbl_type;
1263 * [in] Key data to match on
1267 * [in] key size in bits
1269 uint16_t key_sz_in_bits;
1271 * [in] Mask data to match on
1275 * [in] Priority of entry requested (definition TBD)
1279 * [in] Allocate on miss.
1283 * [out] Set if matching entry found
1287 * [out] Search result status (hit, miss, reject)
1289 enum tf_search_status search_status;
1291 * [out] Current refcnt after allocation
1295 * [in out] The result data from the search is copied here
1299 * [in out] result size in bits for the result data
1301 uint16_t result_sz_in_bits;
1309 * search TCAM entry (experimental)
1311 * Search for a TCAM entry
1313 * This function searches the shadow copy of the TCAM table for a matching
1314 * entry. Key and mask must match for hit to be set. Only TruFlow core data
1315 * is accessed. If shadow_copy is not enabled, an error is returned.
1319 * A hash is performed on the key/mask data and mapped to a shadow copy entry
1320 * where the full key/mask is populated. If the full key/mask matches the
1321 * entry, hit is set, ref_cnt is incremented, and search_status indicates what
1322 * action the caller can take regarding setting the entry.
1324 * search_status should be used as follows:
1325 * - On Miss, the caller should create a result and call tf_set_tcam_entry with
1328 * - On Reject, the hash table is full and the entry cannot be added.
1330 * - On Hit, the result data is returned to the caller. Additionally, the
1331 * ref_cnt is updated.
1333 * Also returns success or failure code.
1335 int tf_search_tcam_entry(struct tf *tfp,
1336 struct tf_search_tcam_entry_parms *parms);
1339 * tf_alloc_tcam_entry parameter definition
1341 struct tf_alloc_tcam_entry_parms {
1343 * [in] receive or transmit direction
1347 * [in] TCAM table type
1349 enum tf_tcam_tbl_type tcam_tbl_type;
1351 * [in] Enable search for matching entry
1353 uint8_t search_enable;
1355 * [in] Key data to match on (if search)
1359 * [in] key size in bits (if search)
1361 uint16_t key_sz_in_bits;
1363 * [in] Mask data to match on (if search)
1367 * [in] Priority of entry requested (definition TBD)
1371 * [out] If search, set if matching entry found
1375 * [out] Current refcnt after allocation
1379 * [out] Idx allocated
1386 * allocate TCAM entry
1388 * Allocate a TCAM entry - one of these types:
1395 * This function allocates a TCAM table record. This function
1396 * will attempt to allocate a TCAM table entry from the session
1397 * owned TCAM entries or search a shadow copy of the TCAM table for a
1398 * matching entry if search is enabled. Key, mask and result must match for
1399 * hit to be set. Only TruFlow core data is accessed.
1400 * A hash table to entry mapping is maintained for search purposes. If
1401 * search is not enabled, the first available free entry is returned based
1402 * on priority and alloc_cnt is set to 1. If search is enabled and a matching
1403 * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
1404 * RefCnt is also returned.
1406 * Also returns success or failure code.
1408 int tf_alloc_tcam_entry(struct tf *tfp,
1409 struct tf_alloc_tcam_entry_parms *parms);
1412 * tf_set_tcam_entry parameter definition
1414 struct tf_set_tcam_entry_parms {
1416 * [in] receive or transmit direction
1420 * [in] TCAM table type
1422 enum tf_tcam_tbl_type tcam_tbl_type;
1424 * [in] base index of the entry to program
1428 * [in] struct containing key
1432 * [in] struct containing mask fields
1436 * [in] key size in bits (if search)
1438 uint16_t key_sz_in_bits;
1440 * [in] struct containing result
1444 * [in] struct containing result size in bits
1446 uint16_t result_sz_in_bits;
1452 * Program a TCAM table entry for a TruFlow session.
1454 * If the entry has not been allocated, an error will be returned.
1456 * Returns success or failure code.
1458 int tf_set_tcam_entry(struct tf *tfp,
1459 struct tf_set_tcam_entry_parms *parms);
1462 * tf_get_tcam_entry parameter definition
1464 struct tf_get_tcam_entry_parms {
1466 * [in] receive or transmit direction
1470 * [in] TCAM table type
1472 enum tf_tcam_tbl_type tcam_tbl_type;
1474 * [in] index of the entry to get
1478 * [out] struct containing key
1482 * [out] struct containing mask fields
1486 * [in/out] key size in bits
1488 uint16_t key_sz_in_bits;
1490 * [out] struct containing result
1494 * [in/out] struct containing result size in bits
1496 uint16_t result_sz_in_bits;
1502 * Program a TCAM table entry for a TruFlow session.
1504 * If the entry has not been allocated, an error will be returned.
1506 * Returns success or failure code.
1508 int tf_get_tcam_entry(struct tf *tfp,
1509 struct tf_get_tcam_entry_parms *parms);
1512 * tf_free_tcam_entry parameter definition
1514 struct tf_free_tcam_entry_parms {
1516 * [in] receive or transmit direction
1520 * [in] TCAM table type
1522 enum tf_tcam_tbl_type tcam_tbl_type;
1524 * [in] Index to free
1528 * [out] reference count after free
1538 * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1539 * session. TCAM entry will be invalidated. All-ones mask.
1542 * WCTCAM profile id of 0 must be used to invalidate an entry.
1544 * Returns success or failure code.
1546 int tf_free_tcam_entry(struct tf *tfp,
1547 struct tf_free_tcam_entry_parms *parms);
1549 #ifdef TF_TCAM_SHARED
1551 * tf_move_tcam_shared_entries parameter definition
1553 struct tf_move_tcam_shared_entries_parms {
1555 * [in] receive or transmit direction
1559 * [in] TCAM table type
1561 enum tf_tcam_tbl_type tcam_tbl_type;
1567 * This API only affects the following TCAM pools within a shared session:
1569 * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
1570 * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
1572 * When called, all allocated entries from the high pool will be moved to
1573 * the low pool. Then the allocated entries in the high pool will be
1574 * cleared and freed.
1576 * This API is not supported on a non-shared session.
1578 * Returns success or failure code.
1580 int tf_move_tcam_shared_entries(struct tf *tfp,
1581 struct tf_move_tcam_shared_entries_parms *parms);
1583 #endif /* TF_TCAM_SHARED */
1585 * @page table Table Access
1587 * @ref tf_alloc_tbl_entry
1589 * @ref tf_free_tbl_entry
1591 * @ref tf_set_tbl_entry
1593 * @ref tf_get_tbl_entry
1595 * @ref tf_bulk_get_tbl_entry
1597 * @ref tf_get_shared_tbl_increment
1601 * tf_alloc_tbl_entry parameter definition
1603 struct tf_search_tbl_entry_parms {
1605 * [in] Receive or transmit direction
1609 * [in] Type of the allocation
1611 enum tf_tbl_type type;
1613 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1615 uint32_t tbl_scope_id;
1617 * [in] Result data to search for
1621 * [in] Result data size in bytes
1623 uint16_t result_sz_in_bytes;
1625 * [in] Allocate on miss.
1629 * [out] Set if matching entry found
1633 * [out] Search result status (hit, miss, reject)
1635 enum tf_search_status search_status;
1637 * [out] Current ref count after allocation
1641 * [out] Idx of allocated entry or found entry
1647 * search Table Entry (experimental)
1649 * This function searches the shadow copy of an index table for a matching
1650 * entry. The result data must match for hit to be set. Only TruFlow core
1651 * data is accessed. If shadow_copy is not enabled, an error is returned.
1655 * A hash is performed on the result data and mappe3d to a shadow copy entry
1656 * where the result is populated. If the result matches the entry, hit is set,
1657 * ref_cnt is incremented (if alloc), and the search status indicates what
1658 * action the caller can take regarding setting the entry.
1660 * search status should be used as follows:
1661 * - On MISS, the caller should set the result into the returned index.
1663 * - On REJECT, the caller should reject the flow since there are no resources.
1665 * - On Hit, the matching index is returned to the caller. Additionally, the
1666 * ref_cnt is updated.
1668 * Also returns success or failure code.
1670 int tf_search_tbl_entry(struct tf *tfp,
1671 struct tf_search_tbl_entry_parms *parms);
1674 * tf_alloc_tbl_entry parameter definition
1676 struct tf_alloc_tbl_entry_parms {
1678 * [in] Receive or transmit direction
1682 * [in] Type of the allocation
1684 enum tf_tbl_type type;
1686 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1688 uint32_t tbl_scope_id;
1690 * [in] Enable search for matching entry. If the table type is
1691 * internal the shadow copy will be searched before
1692 * alloc. Session must be configured with shadow copy enabled.
1694 uint8_t search_enable;
1696 * [in] Result data to search for (if search_enable)
1700 * [in] Result data size in bytes (if search_enable)
1702 uint16_t result_sz_in_bytes;
1704 * [out] If search_enable, set if matching entry found
1708 * [out] Current ref count after allocation (if search_enable)
1712 * [out] Idx of allocated entry or found entry (if search_enable)
1718 * allocate index table entries
1722 * Allocate an on chip index table entry or search for a matching
1723 * entry of the indicated type for this TruFlow session.
1725 * Allocates an index table record. This function will attempt to
1726 * allocate an entry or search an index table for a matching entry if
1727 * search is enabled (only the shadow copy of the table is accessed).
1729 * If search is not enabled, the first available free entry is
1730 * returned. If search is enabled and a matching entry to entry_data
1731 * is found hit is set to TRUE and success is returned.
1735 * These are used to allocate inlined action record memory.
1737 * Allocates an external index table action record.
1740 * Implementation of the internals of this function will be a stack with push
1743 * Returns success or failure code.
1745 int tf_alloc_tbl_entry(struct tf *tfp,
1746 struct tf_alloc_tbl_entry_parms *parms);
1749 * tf_free_tbl_entry parameter definition
1751 struct tf_free_tbl_entry_parms {
1753 * [in] Receive or transmit direction
1757 * [in] Type of the allocation type
1759 enum tf_tbl_type type;
1761 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1763 uint32_t tbl_scope_id;
1765 * [in] Index to free
1769 * [out] Reference count after free, only valid if session has been
1770 * created with shadow_copy.
1776 * free index table entry
1778 * Used to free a previously allocated table entry.
1782 * If session has shadow_copy enabled the shadow DB is searched and if
1783 * found the element ref_cnt is decremented. If ref_cnt goes to
1784 * zero then the element is returned to the session pool.
1786 * If the session does not have a shadow DB the element is free'ed and
1787 * given back to the session pool.
1791 * Free's an external index table action record.
1794 * Implementation of the internals of this function will be a stack with push
1797 * Returns success or failure code.
1799 int tf_free_tbl_entry(struct tf *tfp,
1800 struct tf_free_tbl_entry_parms *parms);
1803 * tf_set_tbl_entry parameter definition
1805 struct tf_set_tbl_entry_parms {
1807 * [in] Table scope identifier
1809 uint32_t tbl_scope_id;
1811 * [in] Receive or transmit direction
1815 * [in] Type of object to set
1817 enum tf_tbl_type type;
1825 uint16_t data_sz_in_bytes;
1827 * [in] External memory channel type to use
1829 enum tf_ext_mem_chan_type chan_type;
1831 * [in] Entry index to write to
1837 * set index table entry
1839 * Used to insert an application programmed index table entry into a
1840 * previous allocated table location. A shadow copy of the table
1841 * is maintained (if enabled) (only for internal objects)
1843 * Returns success or failure code.
1845 int tf_set_tbl_entry(struct tf *tfp,
1846 struct tf_set_tbl_entry_parms *parms);
1849 * tf_get_shared_tbl_increment parameter definition
1851 struct tf_get_shared_tbl_increment_parms {
1853 * [in] Receive or transmit direction
1857 * [in] Type of object to set
1859 enum tf_tbl_type type;
1861 * [out] Value to increment by for resource type
1863 uint32_t increment_cnt;
1867 * tf_get_shared_tbl_increment
1869 * This API is currently only required for use in the shared
1870 * session for Thor (p58) actions. An increment count is returned per
1871 * type to indicate how much to increment the start by for each
1872 * entry (see tf_resource_info)
1874 * Returns success or failure code.
1876 int tf_get_shared_tbl_increment(struct tf *tfp,
1877 struct tf_get_shared_tbl_increment_parms *parms);
1880 * tf_get_tbl_entry parameter definition
1882 struct tf_get_tbl_entry_parms {
1884 * [in] Receive or transmit direction
1888 * [in] Type of object to get
1890 enum tf_tbl_type type;
1898 uint16_t data_sz_in_bytes;
1900 * [in] External memory channel type to use
1902 enum tf_ext_mem_chan_type chan_type;
1904 * [in] Entry index to read
1910 * get index table entry
1912 * Used to retrieve a previous set index table entry.
1914 * Reads and compares with the shadow table copy (if enabled) (only
1915 * for internal objects).
1917 * Returns success or failure code. Failure will be returned if the
1918 * provided data buffer is too small for the data type requested.
1920 int tf_get_tbl_entry(struct tf *tfp,
1921 struct tf_get_tbl_entry_parms *parms);
1924 * tf_bulk_get_tbl_entry parameter definition
1926 struct tf_bulk_get_tbl_entry_parms {
1928 * [in] Receive or transmit direction
1932 * [in] Type of object to get
1934 enum tf_tbl_type type;
1936 * [in] Starting index to read from
1938 uint32_t starting_idx;
1940 * [in] Number of sequential entries
1942 uint16_t num_entries;
1944 * [in] Size of the single entry
1946 uint16_t entry_sz_in_bytes;
1948 * [out] Host physical address, where the data
1949 * will be copied to by the firmware.
1950 * Use tfp_calloc() API and mem_pa
1951 * variable of the tfp_calloc_parms
1952 * structure for the physical address.
1954 uint64_t physical_mem_addr;
1956 * [in] External memory channel type to use
1958 enum tf_ext_mem_chan_type chan_type;
1962 * Bulk get index table entry
1964 * Used to retrieve a set of index table entries.
1966 * Entries within the range may not have been allocated using
1967 * tf_alloc_tbl_entry() at the time of access. But the range must
1968 * be within the bounds determined from tf_open_session() for the
1969 * given table type. Currently, this is only used for collecting statistics.
1971 * Returns success or failure code. Failure will be returned if the
1972 * provided data buffer is too small for the data type requested.
1974 int tf_bulk_get_tbl_entry(struct tf *tfp,
1975 struct tf_bulk_get_tbl_entry_parms *parms);
1978 * @page exact_match Exact Match Table
1980 * @ref tf_insert_em_entry
1982 * @ref tf_delete_em_entry
1984 * @ref tf_search_em_entry
1988 * tf_insert_em_entry parameter definition
1990 struct tf_insert_em_entry_parms {
1992 * [in] receive or transmit direction
1996 * [in] internal or external
2000 * [in] ID of table scope to use (external only)
2002 uint32_t tbl_scope_id;
2004 * [in] ptr to structure containing key fields
2008 * [in] key bit length
2010 uint16_t key_sz_in_bits;
2012 * [in] ptr to structure containing result field
2016 * [out] result size in bits
2018 uint16_t em_record_sz_in_bits;
2020 * [in] duplicate check flag
2024 * [in] External memory channel type to use
2026 enum tf_ext_mem_chan_type chan_type;
2028 * [out] Flow handle value for the inserted entry. This is encoded
2029 * as the entries[4]:bucket[2]:hashId[1]:hash[14]
2031 uint64_t flow_handle;
2033 * [out] Flow id is returned as null (internal)
2034 * Flow id is the GFID value for the inserted entry (external)
2035 * This is the value written to the BD and useful information for mark.
2040 * tf_delete_em_entry parameter definition
2042 struct tf_delete_em_entry_parms {
2044 * [in] receive or transmit direction
2048 * [in] internal or external
2052 * [in] ID of table scope to use (external only)
2054 uint32_t tbl_scope_id;
2056 * [out] The index of the entry
2060 * [in] External memory channel type to use
2062 enum tf_ext_mem_chan_type chan_type;
2064 * [in] structure containing flow delete handle information
2066 uint64_t flow_handle;
2069 * tf_move_em_entry parameter definition
2071 struct tf_move_em_entry_parms {
2073 * [in] receive or transmit direction
2077 * [in] internal or external
2081 * [in] ID of table scope to use (external only)
2083 uint32_t tbl_scope_id;
2085 * [in] ID of table interface to use (SR2 only)
2089 * [in] epoch group IDs of entry to delete
2090 * 2 element array with 2 ids. (SR2 only)
2094 * [out] The index of the entry
2098 * [in] External memory channel type to use
2100 enum tf_ext_mem_chan_type chan_type;
2102 * [in] The index of the new EM record
2106 * [in] structure containing flow delete handle information
2108 uint64_t flow_handle;
2111 * tf_search_em_entry parameter definition
2113 struct tf_search_em_entry_parms {
2115 * [in] receive or transmit direction
2119 * [in] internal or external
2123 * [in] ID of table scope to use (external only)
2125 uint32_t tbl_scope_id;
2127 * [in] ptr to structure containing key fields
2131 * [in] key bit length
2133 uint16_t key_sz_in_bits;
2135 * [in/out] ptr to structure containing EM record fields
2139 * [out] result size in bits
2141 uint16_t em_record_sz_in_bits;
2143 * [in] External memory channel type to use
2145 enum tf_ext_mem_chan_type chan_type;
2147 * [in] ptr to structure containing flow delete handle
2149 uint64_t flow_handle;
2153 * insert em hash entry in internal table memory
2157 * This API inserts an exact match entry into internal EM table memory
2158 * of the specified direction.
2160 * Note: The EM record is managed within the TruFlow core and not the
2163 * Shadow copy of internal record table an association with hash and 1,2, or 4
2164 * associated buckets
2167 * This API inserts an exact match entry into DRAM EM table memory of the
2168 * specified direction and table scope.
2170 * The insertion of duplicate entries in an EM table is not permitted. If a
2171 * TruFlow application can guarantee that it will never insert duplicates, it
2172 * can disable duplicate checking by passing a zero value in the dup_check
2173 * parameter to this API. This will optimize performance. Otherwise, the
2174 * TruFlow library will enforce protection against inserting duplicate entries.
2176 * Flow handle is defined in this document:
2178 * https://docs.google.com
2179 * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
2181 * Returns success or busy code.
2184 int tf_insert_em_entry(struct tf *tfp,
2185 struct tf_insert_em_entry_parms *parms);
2188 * delete em hash entry table memory
2192 * This API deletes an exact match entry from internal EM table memory of the
2193 * specified direction. If a valid flow ptr is passed in then that takes
2194 * precedence over the pointer to the complete key passed in.
2199 * This API deletes an exact match entry from EM table memory of the specified
2200 * direction and table scope. If a valid flow handle is passed in then that
2201 * takes precedence over the pointer to the complete key passed in.
2203 * The TruFlow library may release a dynamic bucket when an entry is deleted.
2206 * Returns success or not found code
2210 int tf_delete_em_entry(struct tf *tfp,
2211 struct tf_delete_em_entry_parms *parms);
2214 * search em hash entry table memory
2218 * This API looks up an EM entry in table memory with the specified EM
2219 * key or flow (flow takes precedence) and direction.
2221 * The status will be one of: success or entry not found. If the lookup
2222 * succeeds, a pointer to the matching entry and the result record associated
2223 * with the matching entry will be provided.
2225 * If flow_handle is set, search shadow copy.
2227 * Otherwise, query the fw with key to get result.
2231 * This API looks up an EM entry in table memory with the specified EM
2232 * key or flow_handle (flow takes precedence), direction and table scope.
2234 * The status will be one of: success or entry not found. If the lookup
2235 * succeeds, a pointer to the matching entry and the result record associated
2236 * with the matching entry will be provided.
2238 * Returns success or not found code
2241 int tf_search_em_entry(struct tf *tfp,
2242 struct tf_search_em_entry_parms *parms);
2245 * @page global Global Configuration
2247 * @ref tf_set_global_cfg
2249 * @ref tf_get_global_cfg
2252 * Tunnel Encapsulation Offsets
2254 enum tf_tunnel_encap_offsets {
2256 TF_TUNNEL_ENCAP_NAT,
2257 TF_TUNNEL_ENCAP_MPLS,
2258 TF_TUNNEL_ENCAP_VXLAN,
2259 TF_TUNNEL_ENCAP_GENEVE,
2260 TF_TUNNEL_ENCAP_NVGRE,
2261 TF_TUNNEL_ENCAP_GRE,
2262 TF_TUNNEL_ENCAP_FULL_GENERIC
2265 * Global Configuration Table Types
2267 enum tf_global_config_type {
2268 TF_TUNNEL_ENCAP, /**< Tunnel Encap Config(TECT) */
2269 TF_ACTION_BLOCK, /**< Action Block Config(ABCR) */
2270 TF_COUNTER_CFG, /**< Counter Configuration (CNTRS_CTRL) */
2271 TF_GLOBAL_CFG_TYPE_MAX
2275 * tf_global_cfg parameter definition
2277 struct tf_global_cfg_parms {
2279 * [in] receive or transmit direction
2283 * [in] Global config type
2285 enum tf_global_config_type type;
2287 * [in] Offset @ the type
2291 * [in/out] Value of the configuration
2292 * set - Read, Modify and Write
2293 * get - Read the full configuration
2297 * [in] Configuration mask
2298 * set - Read, Modify with mask and Write
2301 uint8_t *config_mask;
2303 * [in] struct containing size
2305 uint16_t config_sz_in_bytes;
2309 * Get global configuration
2311 * Retrieve the configuration
2313 * Returns success or failure code.
2315 int tf_get_global_cfg(struct tf *tfp,
2316 struct tf_global_cfg_parms *parms);
2319 * Update the global configuration table
2321 * Read, modify write the value.
2323 * Returns success or failure code.
2325 int tf_set_global_cfg(struct tf *tfp,
2326 struct tf_global_cfg_parms *parms);
2329 * @page if_tbl Interface Table Access
2331 * @ref tf_set_if_tbl_entry
2333 * @ref tf_get_if_tbl_entry
2335 * @ref tf_restore_if_tbl_entry
2338 * Enumeration of TruFlow interface table types.
2340 enum tf_if_tbl_type {
2341 /** Default Profile L2 Context Entry */
2342 TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
2343 /** Default Profile TCAM/Lookup Action Record Pointer Table */
2344 TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
2345 /** Error Profile TCAM Miss Action Record Pointer Table */
2346 TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
2347 /** Default Error Profile TCAM Miss Action Record Pointer Table */
2348 TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
2349 /** Ingress lookup table */
2351 /** VNIC/SVIF Properties Table */
2352 TF_IF_TBL_TYPE_VSPT,
2357 * tf_set_if_tbl_entry parameter definition
2359 struct tf_set_if_tbl_entry_parms {
2361 * [in] Receive or transmit direction
2365 * [in] Type of object to set
2367 enum tf_if_tbl_type type;
2375 uint16_t data_sz_in_bytes;
2377 * [in] Interface to write
2383 * set interface table entry
2385 * Used to set an interface table. This API is used for managing tables indexed
2386 * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
2388 * Returns success or failure code.
2390 int tf_set_if_tbl_entry(struct tf *tfp,
2391 struct tf_set_if_tbl_entry_parms *parms);
2394 * tf_get_if_tbl_entry parameter definition
2396 struct tf_get_if_tbl_entry_parms {
2398 * [in] Receive or transmit direction
2402 * [in] Type of table to get
2404 enum tf_if_tbl_type type;
2412 uint16_t data_sz_in_bytes;
2414 * [in] Entry index to read
2420 * get interface table entry
2422 * Used to retrieve an interface table entry.
2424 * Reads the interface table entry value
2426 * Returns success or failure code. Failure will be returned if the
2427 * provided data buffer is too small for the data type requested.
2429 int tf_get_if_tbl_entry(struct tf *tfp,
2430 struct tf_get_if_tbl_entry_parms *parms);
2432 #endif /* _TF_CORE_H_ */