net/bnxt: support Thor platform
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2021 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_CORE_H_
7 #define _TF_CORE_H_
8
9 #include <stdint.h>
10 #include <stdlib.h>
11 #include <stdbool.h>
12 #include <stdio.h>
13 #include "hcapi_cfa_defs.h"
14 #include "tf_project.h"
15
16 /**
17  * @file
18  *
19  * Truflow Core API Header File
20  */
21
22 /********** BEGIN Truflow Core DEFINITIONS **********/
23
24 #define TF_KILOBYTE  1024
25 #define TF_MEGABYTE  (1024 * 1024)
26
27 /**
28  * direction
29  */
30 enum tf_dir {
31         TF_DIR_RX,  /**< Receive */
32         TF_DIR_TX,  /**< Transmit */
33         TF_DIR_MAX
34 };
35
36 /**
37  * memory choice
38  */
39 enum tf_mem {
40         TF_MEM_INTERNAL, /**< Internal */
41         TF_MEM_EXTERNAL, /**< External */
42         TF_MEM_MAX
43 };
44
45 /**
46  * External memory control channel type
47  */
48 enum tf_ext_mem_chan_type {
49         /**
50          * Direct memory write(Wh+/SR)
51          */
52         TF_EXT_MEM_CHAN_TYPE_DIRECT = 0,
53         /**
54          * Ring interface MPC
55          */
56         TF_EXT_MEM_CHAN_TYPE_RING_IF,
57         /**
58          * Use HWRM message to firmware
59          */
60         TF_EXT_MEM_CHAN_TYPE_FW,
61         /**
62          * Use ring_if message to firmware
63          */
64         TF_EXT_MEM_CHAN_TYPE_RING_IF_FW,
65         TF_EXT_MEM_CHAN_TYPE_MAX
66 };
67
68 /**
69  * EEM record AR helper
70  *
71  * Helper to handle the Action Record Pointer in the EEM Record Entry.
72  *
73  * Convert absolute offset to action record pointer in EEM record entry
74  * Convert action record pointer in EEM record entry to absolute offset
75  */
76 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
77 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
78
79 /*
80  * Helper Macros
81  */
82 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
83
84 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
85
86 /**
87  * @page general General
88  *
89  * @ref tf_open_session
90  *
91  * @ref tf_attach_session
92  *
93  * @ref tf_close_session
94  */
95
96 /**
97  * Session Version defines
98  *
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.
102  */
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 */
106
107 /**
108  * Session Name
109  *
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()
112  */
113 #define TF_SESSION_NAME_MAX       64
114
115 #define TF_FW_SESSION_ID_INVALID  0xFF  /**< Invalid FW Session ID define */
116
117 /**
118  * Session Identifier
119  *
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().
125  */
126 union tf_session_id {
127         uint32_t id;
128         struct {
129                 uint8_t domain;
130                 uint8_t bus;
131                 uint8_t device;
132                 uint8_t fw_session_id;
133         } internal;
134 };
135
136 /**
137  * Session Client Identifier
138  *
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().
142  */
143 union tf_session_client_id {
144         uint16_t id;
145         struct {
146                 uint8_t fw_session_id;
147                 uint8_t fw_session_client_id;
148         } internal;
149 };
150
151 /**
152  * Session Version
153  *
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.
157  *
158  * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
159  */
160 struct tf_session_version {
161         uint8_t major;
162         uint8_t minor;
163         uint8_t update;
164 };
165
166 /**
167  * Session supported device types
168  */
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   */
174 };
175
176 /**
177  * Module types
178  */
179 enum tf_module_type {
180         /**
181          * Identifier module
182          */
183         TF_MODULE_TYPE_IDENTIFIER,
184         /**
185          * Table type module
186          */
187         TF_MODULE_TYPE_TABLE,
188         /**
189          * TCAM module
190          */
191         TF_MODULE_TYPE_TCAM,
192         /**
193          * EM module
194          */
195         TF_MODULE_TYPE_EM,
196         TF_MODULE_TYPE_MAX
197 };
198
199 /**
200  * Identifier resource types
201  */
202 enum tf_identifier_type {
203         /**
204          *  WH/SR/TH
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
207          *  lookups.
208          */
209         TF_IDENT_TYPE_L2_CTXT_HIGH,
210         /**
211          *  WH/SR/TH
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
214          *  lookups.
215          */
216         TF_IDENT_TYPE_L2_CTXT_LOW,
217         /**
218          *  WH/SR/TH
219          *  The WC profile func is returned from the L2 Ctxt TCAM lookup
220          *  to enable virtualization of the profile TCAM.
221          */
222         TF_IDENT_TYPE_PROF_FUNC,
223         /**
224          *  WH/SR/TH
225          *  The WC profile ID is included in the WC lookup key
226          *  to enable virtualization of the WC TCAM hardware.
227          */
228         TF_IDENT_TYPE_WC_PROF,
229         /**
230          *  WH/SR/TH
231          *  The EM profile ID is included in the EM lookup key
232          *  to enable virtualization of the EM hardware.
233          */
234         TF_IDENT_TYPE_EM_PROF,
235         /**
236          *  (Future)
237          *  The L2 func is included in the ILT result and from recycling to
238          *  enable virtualization of further lookups.
239          */
240         TF_IDENT_TYPE_L2_FUNC,
241         TF_IDENT_TYPE_MAX
242 };
243
244 /**
245  * Enumeration of TruFlow table types. A table type is used to identify a
246  * resource object.
247  *
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.
250  */
251 enum tf_tbl_type {
252         /* Internal */
253
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,
292         /** (Future) UPAR */
293         TF_TBL_TYPE_UPAR,
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 */
301         TF_TBL_TYPE_EM_FKB,
302         /** TH WC Flexible Key builder */
303         TF_TBL_TYPE_WC_FKB,
304
305         /* External */
306
307         /**
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.
312          */
313         TF_TBL_TYPE_EXT,
314         TF_TBL_TYPE_MAX
315 };
316
317 /** Enable Shared TCAM Management
318  *
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.
321  *
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.
324  *
325  *  Operation:
326  *
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.
331  *
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
335  *  session.
336  *
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.
344  *
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.
348  *
349  */
350 #define TF_TCAM_SHARED 1
351
352 /**
353  * TCAM table type
354  */
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,
360         /** Profile TCAM */
361         TF_TCAM_TBL_TYPE_PROF_TCAM,
362         /** Wildcard 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 */
376         TF_TCAM_TBL_TYPE_MAX
377 };
378
379 /**
380  * SEARCH STATUS
381  */
382 enum tf_search_status {
383         /** The entry was not found, but an idx was allocated if requested. */
384         MISS,
385         /** The entry was found, and the result/idx are valid */
386         HIT,
387         /** The entry was not found and the table is full */
388         REJECT
389 };
390
391 /**
392  * EM Resources
393  * These defines are provisioned during
394  * tf_open_session()
395  */
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,
401         TF_EM_TBL_TYPE_MAX
402 };
403
404 /**
405  * TruFlow Session Information
406  *
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
411  * Applications.
412  *
413  * Ownership of the elements is split between ULP and TruFlow. Please
414  * see the individual elements.
415  */
416 struct tf_session_info {
417         /**
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().
422          *
423          * Owner:  TruFlow
424          * Access: TruFlow
425          */
426         struct tf_session_version ver;
427         /**
428          * will be STAILQ_ENTRY(tf_session_info) next
429          *
430          * Owner:  ULP
431          * Access: ULP
432          */
433         void                 *next;
434         /**
435          * Session ID is a unique identifier for the session. TruFlow
436          * initializes this variable during tf_open_session()
437          * processing.
438          *
439          * Owner:  TruFlow
440          * Access: Truflow & ULP
441          */
442         union tf_session_id   session_id;
443         /**
444          * Protects access to core_data. Lock is initialized and owned
445          * by ULP. TruFlow can access the core_data without checking
446          * the lock.
447          *
448          * Owner:  ULP
449          * Access: ULP
450          */
451         uint8_t               spin_lock;
452         /**
453          * The core_data holds the TruFlow tf_session data
454          * structure. This memory is allocated and owned by TruFlow on
455          * tf_open_session().
456          *
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
460          * calls.
461          *
462          * Please see tf_open_session_parms for specification details
463          * on this variable.
464          *
465          * Owner:  TruFlow
466          * Access: TruFlow
467          */
468         void                 *core_data;
469         /**
470          * The core_data_sz_bytes specifies the size of core_data in
471          * bytes.
472          *
473          * The size is set by TruFlow on tf_open_session().
474          *
475          * Please see tf_open_session_parms for specification details
476          * on this variable.
477          *
478          * Owner:  TruFlow
479          * Access: TruFlow
480          */
481         uint32_t              core_data_sz_bytes;
482 };
483
484 /**
485  * TruFlow handle
486  *
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().
491  *
492  * It is expected that ULP allocates this memory as shared memory.
493  *
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.
496  */
497 struct tf {
498         struct tf_session_info *session;
499         /**
500          * the pointer to the parent bp struct
501          */
502         void *bp;
503 };
504
505 /**
506  * Identifier resource definition
507  */
508 struct tf_identifier_resources {
509         /**
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.
513          */
514         uint16_t cnt[TF_IDENT_TYPE_MAX];
515 };
516
517 /**
518  * Table type resource definition
519  */
520 struct tf_tbl_resources {
521         /**
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.
525          */
526         uint16_t cnt[TF_TBL_TYPE_MAX];
527 };
528
529 /**
530  * TCAM type resource definition
531  */
532 struct tf_tcam_resources {
533         /**
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.
537          */
538         uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
539 };
540
541 /**
542  * EM type resource definition
543  */
544 struct tf_em_resources {
545         /**
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.
549          */
550         uint16_t cnt[TF_EM_TBL_TYPE_MAX];
551 };
552
553 /**
554  * tf_session_resources parameter definition.
555  */
556 struct tf_session_resources {
557         /**
558          * [in] Requested Identifier Resources
559          *
560          * Number of identifier resources requested for the
561          * session.
562          */
563         struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
564         /**
565          * [in] Requested Index Table resource counts
566          *
567          * The number of index table resources requested for the
568          * session.
569          */
570         struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
571         /**
572          * [in] Requested TCAM Table resource counts
573          *
574          * The number of TCAM table resources requested for the
575          * session.
576          */
577
578         struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
579         /**
580          * [in] Requested EM resource counts
581          *
582          * The number of internal EM table resources requested for the
583          * session.
584          */
585         struct tf_em_resources em_cnt[TF_DIR_MAX];
586 };
587
588 /**
589  * tf_open_session parameters definition.
590  */
591 struct tf_open_session_parms {
592         /**
593          * [in] ctrl_chan_name
594          *
595          * String containing name of control channel interface to be
596          * used for this session to communicate with firmware.
597          *
598          * The ctrl_chan_name can be looked up by using
599          * rte_eth_dev_get_name_by_port() within the ULP.
600          *
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.
604          */
605         char ctrl_chan_name[TF_SESSION_NAME_MAX];
606         /**
607          * [in] shadow_copy
608          *
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
614          * 'false'.
615          *
616          * Size of memory depends on the NVM Resource settings for the
617          * control channel.
618          */
619         bool shadow_copy;
620         /**
621          * [in/out] session_id
622          *
623          * Session_id is unique per session.
624          *
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.
628          *
629          * The session_id allows a session to be shared between devices.
630          */
631         union tf_session_id session_id;
632         /**
633          * [in/out] session_client_id
634          *
635          * Session_client_id is unique per client.
636          *
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().
641          *
642          * A reference count will be incremented in the session on
643          * which a client is created.
644          *
645          * A session can first be closed if there is one Session
646          * Client left. Session Clients should closed using
647          * tf_close_session().
648          */
649         union tf_session_client_id session_client_id;
650         /**
651          * [in] device type
652          *
653          * Device type for the session.
654          */
655         enum tf_device_type device_type;
656         /**
657          * [in] resources
658          *
659          * Resource allocation for the session.
660          */
661         struct tf_session_resources resources;
662
663         /**
664          * [in] bp
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
667          * bnxt.
668          */
669         void *bp;
670
671         /**
672          * [out] shared_session_creator
673          *
674          * Indicates whether the application created the session if set.
675          * Otherwise the shared session already existed.  Just for information
676          * purposes.
677          */
678         int shared_session_creator;
679 };
680
681 /**
682  * Opens a new TruFlow Session or session client.
683  *
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.
688  *
689  * In case of session creation TruFlow will allocate session specific memory to
690  * hold its session data. This data is private to TruFlow.
691  *
692  * No other TruFlow APIs will succeed unless this API is first called
693  * and succeeds.
694  *
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.
697  *
698  * A Session or session client can be closed using tf_close_session().
699  *
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.
704  *
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.
712  *
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.
715  *
716  * Sessions remain open in the firmware until the last client of the session
717  * closes the session (tf_close_session()).
718  *
719  * [in] tfp
720  *   Pointer to TF handle
721  *
722  * [in] parms
723  *   Pointer to open parameters
724  *
725  * Returns
726  *   - (0) if successful.
727  *   - (-EINVAL) on failure.
728  */
729 int tf_open_session(struct tf *tfp,
730                     struct tf_open_session_parms *parms);
731
732 /**
733  * General internal resource info
734  *
735  * TODO: remove tf_rm_new_entry structure and use this structure
736  * internally.
737  */
738 struct tf_resource_info {
739         uint16_t start;
740         uint16_t stride;
741 };
742
743 /**
744  * Identifier resource definition
745  */
746 struct tf_identifier_resource_info {
747         /**
748          * Array of TF Identifiers. The index used is tf_identifier_type.
749          */
750         struct tf_resource_info info[TF_IDENT_TYPE_MAX];
751 };
752
753 /**
754  * Table type resource info definition
755  */
756 struct tf_tbl_resource_info {
757         /**
758          * Array of TF Table types. The index used is tf_tbl_type.
759          */
760         struct tf_resource_info info[TF_TBL_TYPE_MAX];
761 };
762
763 /**
764  * TCAM type resource definition
765  */
766 struct tf_tcam_resource_info {
767         /**
768          * Array of TF TCAM types. The index used is tf_tcam_tbl_type.
769          */
770         struct tf_resource_info info[TF_TCAM_TBL_TYPE_MAX];
771 };
772
773 /**
774  * EM type resource definition
775  */
776 struct tf_em_resource_info {
777         /**
778          * Array of TF EM table types. The index used is tf_em_tbl_type.
779          */
780         struct tf_resource_info info[TF_EM_TBL_TYPE_MAX];
781 };
782
783 /**
784  * tf_session_resources parameter definition.
785  */
786 struct tf_session_resource_info {
787         /**
788          * [in] Requested Identifier Resources
789          *
790          * Number of identifier resources requested for the
791          * session.
792          */
793         struct tf_identifier_resource_info ident[TF_DIR_MAX];
794         /**
795          * [in] Requested Index Table resource counts
796          *
797          * The number of index table resources requested for the
798          * session.
799          */
800         struct tf_tbl_resource_info tbl[TF_DIR_MAX];
801         /**
802          * [in] Requested TCAM Table resource counts
803          *
804          * The number of TCAM table resources requested for the
805          * session.
806          */
807
808         struct tf_tcam_resource_info tcam[TF_DIR_MAX];
809         /**
810          * [in] Requested EM resource counts
811          *
812          * The number of internal EM table resources requested for the
813          * session.
814          */
815         struct tf_em_resource_info em[TF_DIR_MAX];
816 };
817
818 /**
819  * tf_get_session_resources parameter definition.
820  */
821 struct tf_get_session_info_parms {
822         /**
823          * [out] the structure is used to return the information of
824          * allocated resources.
825          *
826          */
827         struct tf_session_resource_info session_info;
828 };
829
830 /** (experimental)
831  * Gets info about a TruFlow Session
832  *
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.
838  *
839  * [in] tfp
840  *   Pointer to TF handle
841  *
842  * [in] parms
843  *   Pointer to get parameters
844  *
845  * Returns
846  *   - (0) if successful.
847  *   - (-EINVAL) on failure.
848  */
849 int tf_get_session_info(struct tf *tfp,
850                         struct tf_get_session_info_parms *parms);
851 /**
852  * Experimental
853  *
854  * tf_attach_session parameters definition.
855  */
856 struct tf_attach_session_parms {
857         /**
858          * [in] ctrl_chan_name
859          *
860          * String containing name of control channel interface to be
861          * used for this session to communicate with firmware.
862          *
863          * The ctrl_chan_name can be looked up by using
864          * rte_eth_dev_get_name_by_port() within the ULP.
865          *
866          * ctrl_chan_name will be used as part of a name for any
867          * shared memory allocation.
868          */
869         char ctrl_chan_name[TF_SESSION_NAME_MAX];
870
871         /**
872          * [in] attach_chan_name
873          *
874          * String containing name of attach channel interface to be
875          * used for this session.
876          *
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
881          * to use.
882          */
883         char attach_chan_name[TF_SESSION_NAME_MAX];
884
885         /**
886          * [in] session_id
887          *
888          * Session_id is unique per session. For Attach the session_id
889          * should be the session_id that was returned on the first
890          * open.
891          *
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().
896          *
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().
900          */
901         union tf_session_id session_id;
902 };
903
904 /**
905  * Experimental
906  *
907  * Allows a 2nd application instance to attach to an existing
908  * session. Used when a session is to be shared between two processes.
909  *
910  * Attach will increment a ref count as to manage the shared session data.
911  *
912  * [in] tfp
913  *   Pointer to TF handle
914  *
915  * [in] parms
916  *   Pointer to attach parameters
917  *
918  * Returns
919  *   - (0) if successful.
920  *   - (-EINVAL) on failure.
921  */
922 int tf_attach_session(struct tf *tfp,
923                       struct tf_attach_session_parms *parms);
924
925 /**
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.
929  *
930  * On session close all hardware and firmware state associated with
931  * the TruFlow application is cleaned up.
932  *
933  * The session client is extracted from the tfp. Thus tf_close_session()
934  * cannot close a session client on behalf of another function.
935  *
936  * Returns success or failure code.
937  */
938 int tf_close_session(struct tf *tfp);
939
940 /**
941  * @page  ident Identity Management
942  *
943  * @ref tf_alloc_identifier
944  *
945  * @ref tf_free_identifier
946  */
947 /**
948  * tf_alloc_identifier parameter definition
949  */
950 struct tf_alloc_identifier_parms {
951         /**
952          * [in]  receive or transmit direction
953          */
954         enum tf_dir dir;
955         /**
956          * [in] Identifier type
957          */
958         enum tf_identifier_type ident_type;
959         /**
960          * [out] Allocated identifier
961          */
962         uint32_t id;
963 };
964
965 /**
966  * tf_free_identifier parameter definition
967  */
968 struct tf_free_identifier_parms {
969         /**
970          * [in]  receive or transmit direction
971          */
972         enum tf_dir dir;
973         /**
974          * [in] Identifier type
975          */
976         enum tf_identifier_type ident_type;
977         /**
978          * [in] ID to free
979          */
980         uint32_t id;
981         /**
982          * (experimental)
983          * [out] Current refcnt after free
984          */
985         uint32_t ref_cnt;
986 };
987
988 /**
989  * tf_search_identifier parameter definition (experimental)
990  */
991 struct tf_search_identifier_parms {
992         /**
993          * [in]  receive or transmit direction
994          */
995         enum tf_dir dir;
996         /**
997          * [in] Identifier type
998          */
999         enum tf_identifier_type ident_type;
1000         /**
1001          * [in] Identifier data to search for
1002          */
1003         uint32_t search_id;
1004         /**
1005          * [out] Set if matching identifier found
1006          */
1007         bool hit;
1008         /**
1009          * [out] Current ref count after allocation
1010          */
1011         uint32_t ref_cnt;
1012 };
1013
1014 /**
1015  * allocate identifier resource
1016  *
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.
1019  *
1020  * If shadow copy is enabled, the internal ref_cnt is set to 1 in the
1021  * shadow table for a newly allocated resource.
1022  *
1023  * Returns success or failure code.
1024  */
1025 int tf_alloc_identifier(struct tf *tfp,
1026                         struct tf_alloc_identifier_parms *parms);
1027
1028 /**
1029  * free identifier resource
1030  *
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.
1034  *
1035  * additional operation (experimental)
1036  * Decrement reference count.  Only release resource once refcnt goes to 0 if
1037  * shadow copy is enabled.
1038  *
1039  * Returns success or failure code.
1040  */
1041 int tf_free_identifier(struct tf *tfp,
1042                        struct tf_free_identifier_parms *parms);
1043
1044 /**
1045  * Search identifier resource (experimental)
1046  *
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.
1052  *
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.
1056  *
1057  * TODO: remove this pseudocode below added to show that if search fails
1058  * we shouldn't allocate a new entry but return.
1059  *
1060  * identifier alloc (search_en=1)
1061  * if (ident is allocated and ref_cnt >=1)
1062  *      return ident - hit is set, incr refcnt
1063  * else (not found)
1064  *      return
1065  *
1066  */
1067 int tf_search_identifier(struct tf *tfp,
1068                          struct tf_search_identifier_parms *parms);
1069
1070 /**
1071  * @page dram_table DRAM Table Scope Interface
1072  *
1073  * @ref tf_alloc_tbl_scope
1074  *
1075  * @ref tf_free_tbl_scope
1076  *
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)
1080  *
1081  * Current thought is that memory is allocated within core.
1082  */
1083
1084 /**
1085  * tf_alloc_tbl_scope_parms definition
1086  */
1087 struct tf_alloc_tbl_scope_parms {
1088         /**
1089          * [in] All Maximum key size required.
1090          */
1091         uint16_t rx_max_key_sz_in_bits;
1092         /**
1093          * [in] Maximum Action size required (includes inlined items)
1094          */
1095         uint16_t rx_max_action_entry_sz_in_bits;
1096         /**
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.
1101          */
1102         uint32_t rx_mem_size_in_mb;
1103         /**
1104          * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
1105          */
1106         uint32_t rx_num_flows_in_k;
1107         /**
1108          * [in] All Maximum key size required.
1109          */
1110         uint16_t tx_max_key_sz_in_bits;
1111         /**
1112          * [in] Maximum Action size required (includes inlined items)
1113          */
1114         uint16_t tx_max_action_entry_sz_in_bits;
1115         /**
1116          * [in] Memory size in Megabytes
1117          * Total memory size allocated by user to be divided
1118          * up for actions, hash, counters.  Only inline external actions.
1119          */
1120         uint32_t tx_mem_size_in_mb;
1121         /**
1122          * [in] Number of flows * 1000
1123          */
1124         uint32_t tx_num_flows_in_k;
1125         /**
1126          * [in] Flush pending HW cached flows every 1/10th of value
1127          * set in seconds, both idle and active flows are flushed
1128          * from the HW cache. If set to 0, this feature will be disabled.
1129          */
1130         uint8_t hw_flow_cache_flush_timer;
1131         /**
1132          * [out] table scope identifier
1133          */
1134         uint32_t tbl_scope_id;
1135 };
1136 /**
1137  * tf_free_tbl_scope_parms definition
1138  */
1139 struct tf_free_tbl_scope_parms {
1140         /**
1141          * [in] table scope identifier
1142          */
1143         uint32_t tbl_scope_id;
1144 };
1145
1146 /**
1147  * tf_map_tbl_scope_parms definition
1148  */
1149 struct tf_map_tbl_scope_parms {
1150         /**
1151          * [in] table scope identifier
1152          */
1153         uint32_t tbl_scope_id;
1154         /**
1155          * [in] Which parifs are associated with this table scope.  Bit 0
1156          *      indicates parif 0.
1157          */
1158         uint16_t parif_bitmask;
1159 };
1160
1161 /**
1162  * allocate a table scope
1163  *
1164  * The scope is a software construct to identify an EEM table.  This function will
1165  * divide the hash memory/buckets and records according to the device
1166  * device constraints based upon calculations using either the number of flows
1167  * requested or the size of memory indicated.  Other parameters passed in
1168  * determine the configuration (maximum key size, maximum external action record
1169  * size).
1170  *
1171  * A single API is used to allocate a common table scope identifier in both
1172  * receive and transmit CFA. The scope identifier is common due to nature of
1173  * connection tracking sending notifications between RX and TX direction.
1174  *
1175  * The receive and transmit table access identifiers specify which rings will
1176  * be used to initialize table DRAM.  The application must ensure mutual
1177  * exclusivity of ring usage for table scope allocation and any table update
1178  * operations.
1179  *
1180  * The hash table buckets, EM keys, and EM lookup results are stored in the
1181  * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters.  The
1182  * hash table buckets are stored at the beginning of that memory.
1183  *
1184  * NOTE:  No EM internal setup is done here. On chip EM records are managed
1185  * internally by TruFlow core.
1186  *
1187  * Returns success or failure code.
1188  */
1189 int tf_alloc_tbl_scope(struct tf *tfp,
1190                        struct tf_alloc_tbl_scope_parms *parms);
1191
1192 /**
1193  * map a table scope (legacy device only Wh+/SR)
1194  *
1195  * Map a table scope to one or more partition interfaces (parifs).
1196  * The parif can be remapped in the L2 context lookup for legacy devices.  This
1197  * API allows a number of parifs to be mapped to the same table scope.  On
1198  * legacy devices a table scope identifies one of 16 sets of EEM table base
1199  * addresses and is associated with a PF communication channel.  The associated
1200  * PF must be configured for the table scope to operate.
1201  *
1202  * An L2 context TCAM lookup returns a remapped parif value used to
1203  * index into the set of 16 parif_to_pf registers which are used to map to one
1204  * of the 16 table scopes.  This API allows the user to map the parifs in the
1205  * mask to the previously allocated table scope (EEM table).
1206
1207  * Returns success or failure code.
1208  */
1209 int tf_map_tbl_scope(struct tf *tfp,
1210                       struct tf_map_tbl_scope_parms *parms);
1211 /**
1212  * free a table scope
1213  *
1214  * Firmware checks that the table scope ID is owned by the TruFlow
1215  * session, verifies that no references to this table scope remains
1216  * or Profile TCAM entries for either CFA (RX/TX) direction,
1217  * then frees the table scope ID.
1218  *
1219  * Returns success or failure code.
1220  */
1221 int tf_free_tbl_scope(struct tf *tfp,
1222                       struct tf_free_tbl_scope_parms *parms);
1223
1224 /**
1225  * @page tcam TCAM Access
1226  *
1227  * @ref tf_search_tcam_entry
1228  *
1229  * @ref tf_alloc_tcam_entry
1230  *
1231  * @ref tf_set_tcam_entry
1232  *
1233  * @ref tf_get_tcam_entry
1234  *
1235  * @ref tf_free_tcam_entry
1236  *
1237 #ifdef TF_TCAM_SHARED
1238  * @ref tf_move_tcam_shared_entries
1239  *
1240  * @ref tf_clear_tcam_shared_entries
1241 #endif
1242  */
1243
1244 /**
1245  * tf_search_tcam_entry parameter definition (experimental)
1246  */
1247 struct tf_search_tcam_entry_parms {
1248         /**
1249          * [in] receive or transmit direction
1250          */
1251         enum tf_dir dir;
1252         /**
1253          * [in] TCAM table type
1254          */
1255         enum tf_tcam_tbl_type tcam_tbl_type;
1256         /**
1257          * [in] Key data to match on
1258          */
1259         uint8_t *key;
1260         /**
1261          * [in] key size in bits
1262          */
1263         uint16_t key_sz_in_bits;
1264         /**
1265          * [in] Mask data to match on
1266          */
1267         uint8_t *mask;
1268         /**
1269          * [in] Priority of entry requested (definition TBD)
1270          */
1271         uint32_t priority;
1272         /**
1273          * [in] Allocate on miss.
1274          */
1275         uint8_t alloc;
1276         /**
1277          * [out] Set if matching entry found
1278          */
1279         uint8_t hit;
1280         /**
1281          * [out] Search result status (hit, miss, reject)
1282          */
1283         enum tf_search_status search_status;
1284         /**
1285          * [out] Current refcnt after allocation
1286          */
1287         uint16_t ref_cnt;
1288         /**
1289          * [in out] The result data from the search is copied here
1290          */
1291         uint8_t *result;
1292         /**
1293          * [in out] result size in bits for the result data
1294          */
1295         uint16_t result_sz_in_bits;
1296         /**
1297          * [out] Index found
1298          */
1299         uint16_t idx;
1300 };
1301
1302 /**
1303  * search TCAM entry (experimental)
1304  *
1305  * Search for a TCAM entry
1306  *
1307  * This function searches the shadow copy of the TCAM table for a matching
1308  * entry.  Key and mask must match for hit to be set.  Only TruFlow core data
1309  * is accessed.  If shadow_copy is not enabled, an error is returned.
1310  *
1311  * Implementation:
1312  *
1313  * A hash is performed on the key/mask data and mapped to a shadow copy entry
1314  * where the full key/mask is populated.  If the full key/mask matches the
1315  * entry, hit is set, ref_cnt is incremented, and search_status indicates what
1316  * action the caller can take regarding setting the entry.
1317  *
1318  * search_status should be used as follows:
1319  * - On Miss, the caller should create a result and call tf_set_tcam_entry with
1320  * returned index.
1321  *
1322  * - On Reject, the hash table is full and the entry cannot be added.
1323  *
1324  * - On Hit, the result data is returned to the caller.  Additionally, the
1325  * ref_cnt is updated.
1326  *
1327  * Also returns success or failure code.
1328  */
1329 int tf_search_tcam_entry(struct tf *tfp,
1330                          struct tf_search_tcam_entry_parms *parms);
1331
1332 /**
1333  * tf_alloc_tcam_entry parameter definition
1334  */
1335 struct tf_alloc_tcam_entry_parms {
1336         /**
1337          * [in] receive or transmit direction
1338          */
1339         enum tf_dir dir;
1340         /**
1341          * [in] TCAM table type
1342          */
1343         enum tf_tcam_tbl_type tcam_tbl_type;
1344         /**
1345          * [in] Enable search for matching entry
1346          */
1347         uint8_t search_enable;
1348         /**
1349          * [in] Key data to match on (if search)
1350          */
1351         uint8_t *key;
1352         /**
1353          * [in] key size in bits (if search)
1354          */
1355         uint16_t key_sz_in_bits;
1356         /**
1357          * [in] Mask data to match on (if search)
1358          */
1359         uint8_t *mask;
1360         /**
1361          * [in] Priority of entry requested (definition TBD)
1362          */
1363         uint32_t priority;
1364         /**
1365          * [out] If search, set if matching entry found
1366          */
1367         uint8_t hit;
1368         /**
1369          * [out] Current refcnt after allocation
1370          */
1371         uint16_t ref_cnt;
1372         /**
1373          * [out] Idx allocated
1374          *
1375          */
1376         uint16_t idx;
1377 };
1378
1379 /**
1380  * allocate TCAM entry
1381  *
1382  * Allocate a TCAM entry - one of these types:
1383  *
1384  * L2 Context
1385  * Profile TCAM
1386  * WC TCAM
1387  * VEB TCAM
1388  *
1389  * This function allocates a TCAM table record.  This function
1390  * will attempt to allocate a TCAM table entry from the session
1391  * owned TCAM entries or search a shadow copy of the TCAM table for a
1392  * matching entry if search is enabled.  Key, mask and result must match for
1393  * hit to be set.  Only TruFlow core data is accessed.
1394  * A hash table to entry mapping is maintained for search purposes.  If
1395  * search is not enabled, the first available free entry is returned based
1396  * on priority and alloc_cnt is set to 1.  If search is enabled and a matching
1397  * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
1398  * RefCnt is also returned.
1399  *
1400  * Also returns success or failure code.
1401  */
1402 int tf_alloc_tcam_entry(struct tf *tfp,
1403                         struct tf_alloc_tcam_entry_parms *parms);
1404
1405 /**
1406  * tf_set_tcam_entry parameter definition
1407  */
1408 struct  tf_set_tcam_entry_parms {
1409         /**
1410          * [in] receive or transmit direction
1411          */
1412         enum tf_dir dir;
1413         /**
1414          * [in] TCAM table type
1415          */
1416         enum tf_tcam_tbl_type tcam_tbl_type;
1417         /**
1418          * [in] base index of the entry to program
1419          */
1420         uint16_t idx;
1421         /**
1422          * [in] struct containing key
1423          */
1424         uint8_t *key;
1425         /**
1426          * [in] struct containing mask fields
1427          */
1428         uint8_t *mask;
1429         /**
1430          * [in] key size in bits (if search)
1431          */
1432         uint16_t key_sz_in_bits;
1433         /**
1434          * [in] struct containing result
1435          */
1436         uint8_t *result;
1437         /**
1438          * [in] struct containing result size in bits
1439          */
1440         uint16_t result_sz_in_bits;
1441 };
1442
1443 /**
1444  * set TCAM entry
1445  *
1446  * Program a TCAM table entry for a TruFlow session.
1447  *
1448  * If the entry has not been allocated, an error will be returned.
1449  *
1450  * Returns success or failure code.
1451  */
1452 int tf_set_tcam_entry(struct tf *tfp,
1453                       struct tf_set_tcam_entry_parms *parms);
1454
1455 /**
1456  * tf_get_tcam_entry parameter definition
1457  */
1458 struct tf_get_tcam_entry_parms {
1459         /**
1460          * [in] receive or transmit direction
1461          */
1462         enum tf_dir dir;
1463         /**
1464          * [in] TCAM table type
1465          */
1466         enum tf_tcam_tbl_type  tcam_tbl_type;
1467         /**
1468          * [in] index of the entry to get
1469          */
1470         uint16_t idx;
1471         /**
1472          * [out] struct containing key
1473          */
1474         uint8_t *key;
1475         /**
1476          * [out] struct containing mask fields
1477          */
1478         uint8_t *mask;
1479         /**
1480          * [in/out] key size in bits
1481          */
1482         uint16_t key_sz_in_bits;
1483         /**
1484          * [out] struct containing result
1485          */
1486         uint8_t *result;
1487         /**
1488          * [in/out] struct containing result size in bits
1489          */
1490         uint16_t result_sz_in_bits;
1491 };
1492
1493 /**
1494  * get TCAM entry
1495  *
1496  * Program a TCAM table entry for a TruFlow session.
1497  *
1498  * If the entry has not been allocated, an error will be returned.
1499  *
1500  * Returns success or failure code.
1501  */
1502 int tf_get_tcam_entry(struct tf *tfp,
1503                       struct tf_get_tcam_entry_parms *parms);
1504
1505 /**
1506  * tf_free_tcam_entry parameter definition
1507  */
1508 struct tf_free_tcam_entry_parms {
1509         /**
1510          * [in] receive or transmit direction
1511          */
1512         enum tf_dir dir;
1513         /**
1514          * [in] TCAM table type
1515          */
1516         enum tf_tcam_tbl_type tcam_tbl_type;
1517         /**
1518          * [in] Index to free
1519          */
1520         uint16_t idx;
1521         /**
1522          * [out] reference count after free
1523          */
1524         uint16_t ref_cnt;
1525 };
1526
1527 /**
1528  * free TCAM entry
1529  *
1530  * Free TCAM entry.
1531  *
1532  * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1533  * session.  TCAM entry will be invalidated.  All-ones mask.
1534  * writes to hw.
1535  *
1536  * WCTCAM profile id of 0 must be used to invalidate an entry.
1537  *
1538  * Returns success or failure code.
1539  */
1540 int tf_free_tcam_entry(struct tf *tfp,
1541                        struct tf_free_tcam_entry_parms *parms);
1542
1543 #ifdef TF_TCAM_SHARED
1544 /**
1545  * tf_move_tcam_shared_entries parameter definition
1546  */
1547 struct tf_move_tcam_shared_entries_parms {
1548         /**
1549          * [in] receive or transmit direction
1550          */
1551         enum tf_dir dir;
1552         /**
1553          * [in] TCAM table type
1554          */
1555         enum tf_tcam_tbl_type tcam_tbl_type;
1556 };
1557
1558 /**
1559  * Move TCAM entries
1560  *
1561  * This API only affects the following TCAM pools within a shared session:
1562  *
1563  * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
1564  * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
1565  *
1566  * When called, all allocated entries from the high pool will be moved to
1567  * the low pool.  Then the allocated entries in the high pool will be
1568  * cleared and freed.
1569  *
1570  * This API is not supported on a non-shared session.
1571  *
1572  * Returns success or failure code.
1573  */
1574 int tf_move_tcam_shared_entries(struct tf *tfp,
1575                                 struct tf_move_tcam_shared_entries_parms *parms);
1576
1577 /**
1578  * tf_clear_tcam_shared_entries parameter definition
1579  */
1580 struct tf_clear_tcam_shared_entries_parms {
1581         /**
1582          * [in] receive or transmit direction
1583          */
1584         enum tf_dir dir;
1585         /**
1586          * [in] TCAM table type
1587          */
1588         enum tf_tcam_tbl_type tcam_tbl_type;
1589 };
1590
1591 /**
1592  * Clear TCAM shared entries pool
1593  *
1594  * This API only affects the following TCAM pools within a shared session:
1595  *
1596  * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
1597  * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
1598  *
1599  * When called, the indicated WC TCAM high or low pool will be cleared.
1600  *
1601  * This API is not supported on a non-shared session.
1602  *
1603  * Returns success or failure code.
1604  */
1605 int tf_clear_tcam_shared_entries(struct tf *tfp,
1606                               struct tf_clear_tcam_shared_entries_parms *parms);
1607
1608 #endif /* TF_TCAM_SHARED */
1609 /**
1610  * @page table Table Access
1611  *
1612  * @ref tf_alloc_tbl_entry
1613  *
1614  * @ref tf_free_tbl_entry
1615  *
1616  * @ref tf_set_tbl_entry
1617  *
1618  * @ref tf_get_tbl_entry
1619  *
1620  * @ref tf_bulk_get_tbl_entry
1621  *
1622  * @ref tf_get_shared_tbl_increment
1623  */
1624
1625 /**
1626  * tf_alloc_tbl_entry parameter definition
1627  */
1628 struct tf_search_tbl_entry_parms {
1629         /**
1630          * [in] Receive or transmit direction
1631          */
1632         enum tf_dir dir;
1633         /**
1634          * [in] Type of the allocation
1635          */
1636         enum tf_tbl_type type;
1637         /**
1638          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1639          */
1640         uint32_t tbl_scope_id;
1641         /**
1642          * [in] Result data to search for
1643          */
1644         uint8_t *result;
1645         /**
1646          * [in] Result data size in bytes
1647          */
1648         uint16_t result_sz_in_bytes;
1649         /**
1650          * [in] Allocate on miss.
1651          */
1652         uint8_t alloc;
1653         /**
1654          * [out] Set if matching entry found
1655          */
1656         uint8_t hit;
1657         /**
1658          * [out] Search result status (hit, miss, reject)
1659          */
1660         enum tf_search_status search_status;
1661         /**
1662          * [out] Current ref count after allocation
1663          */
1664         uint16_t ref_cnt;
1665         /**
1666          * [out] Idx of allocated entry or found entry
1667          */
1668         uint32_t idx;
1669 };
1670
1671 /**
1672  * search Table Entry (experimental)
1673  *
1674  * This function searches the shadow copy of an index table for a matching
1675  * entry.  The result data must match for hit to be set.  Only TruFlow core
1676  * data is accessed.  If shadow_copy is not enabled, an error is returned.
1677  *
1678  * Implementation:
1679  *
1680  * A hash is performed on the result data and mappe3d to a shadow copy entry
1681  * where the result is populated.  If the result matches the entry, hit is set,
1682  * ref_cnt is incremented (if alloc), and the search status indicates what
1683  * action the caller can take regarding setting the entry.
1684  *
1685  * search status should be used as follows:
1686  * - On MISS, the caller should set the result into the returned index.
1687  *
1688  * - On REJECT, the caller should reject the flow since there are no resources.
1689  *
1690  * - On Hit, the matching index is returned to the caller.  Additionally, the
1691  *   ref_cnt is updated.
1692  *
1693  * Also returns success or failure code.
1694  */
1695 int tf_search_tbl_entry(struct tf *tfp,
1696                         struct tf_search_tbl_entry_parms *parms);
1697
1698 /**
1699  * tf_alloc_tbl_entry parameter definition
1700  */
1701 struct tf_alloc_tbl_entry_parms {
1702         /**
1703          * [in] Receive or transmit direction
1704          */
1705         enum tf_dir dir;
1706         /**
1707          * [in] Type of the allocation
1708          */
1709         enum tf_tbl_type type;
1710         /**
1711          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1712          */
1713         uint32_t tbl_scope_id;
1714         /**
1715          * [in] Enable search for matching entry. If the table type is
1716          * internal the shadow copy will be searched before
1717          * alloc. Session must be configured with shadow copy enabled.
1718          */
1719         uint8_t search_enable;
1720         /**
1721          * [in] Result data to search for (if search_enable)
1722          */
1723         uint8_t *result;
1724         /**
1725          * [in] Result data size in bytes (if search_enable)
1726          */
1727         uint16_t result_sz_in_bytes;
1728         /**
1729          * [out] If search_enable, set if matching entry found
1730          */
1731         uint8_t hit;
1732         /**
1733          * [out] Current ref count after allocation (if search_enable)
1734          */
1735         uint16_t ref_cnt;
1736         /**
1737          * [out] Idx of allocated entry or found entry (if search_enable)
1738          */
1739         uint32_t idx;
1740 };
1741
1742 /**
1743  * allocate index table entries
1744  *
1745  * Internal types:
1746  *
1747  * Allocate an on chip index table entry or search for a matching
1748  * entry of the indicated type for this TruFlow session.
1749  *
1750  * Allocates an index table record. This function will attempt to
1751  * allocate an entry or search an index table for a matching entry if
1752  * search is enabled (only the shadow copy of the table is accessed).
1753  *
1754  * If search is not enabled, the first available free entry is
1755  * returned. If search is enabled and a matching entry to entry_data
1756  * is found hit is set to TRUE and success is returned.
1757  *
1758  * External types:
1759  *
1760  * These are used to allocate inlined action record memory.
1761  *
1762  * Allocates an external index table action record.
1763  *
1764  * NOTE:
1765  * Implementation of the internals of this function will be a stack with push
1766  * and pop.
1767  *
1768  * Returns success or failure code.
1769  */
1770 int tf_alloc_tbl_entry(struct tf *tfp,
1771                        struct tf_alloc_tbl_entry_parms *parms);
1772
1773 /**
1774  * tf_free_tbl_entry parameter definition
1775  */
1776 struct tf_free_tbl_entry_parms {
1777         /**
1778          * [in] Receive or transmit direction
1779          */
1780         enum tf_dir dir;
1781         /**
1782          * [in] Type of the allocation type
1783          */
1784         enum tf_tbl_type type;
1785         /**
1786          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1787          */
1788         uint32_t tbl_scope_id;
1789         /**
1790          * [in] Index to free
1791          */
1792         uint32_t idx;
1793         /**
1794          * [out] Reference count after free, only valid if session has been
1795          * created with shadow_copy.
1796          */
1797         uint16_t ref_cnt;
1798 };
1799
1800 /**
1801  * free index table entry
1802  *
1803  * Used to free a previously allocated table entry.
1804  *
1805  * Internal types:
1806  *
1807  * If session has shadow_copy enabled the shadow DB is searched and if
1808  * found the element ref_cnt is decremented. If ref_cnt goes to
1809  * zero then the element is returned to the session pool.
1810  *
1811  * If the session does not have a shadow DB the element is free'ed and
1812  * given back to the session pool.
1813  *
1814  * External types:
1815  *
1816  * Free's an external index table action record.
1817  *
1818  * NOTE:
1819  * Implementation of the internals of this function will be a stack with push
1820  * and pop.
1821  *
1822  * Returns success or failure code.
1823  */
1824 int tf_free_tbl_entry(struct tf *tfp,
1825                       struct tf_free_tbl_entry_parms *parms);
1826
1827 /**
1828  * tf_set_tbl_entry parameter definition
1829  */
1830 struct tf_set_tbl_entry_parms {
1831         /**
1832          * [in] Table scope identifier
1833          */
1834         uint32_t tbl_scope_id;
1835         /**
1836          * [in] Receive or transmit direction
1837          */
1838         enum tf_dir dir;
1839         /**
1840          * [in] Type of object to set
1841          */
1842         enum tf_tbl_type type;
1843         /**
1844          * [in] Entry data
1845          */
1846         uint8_t *data;
1847         /**
1848          * [in] Entry size
1849          */
1850         uint16_t data_sz_in_bytes;
1851         /**
1852          * [in] External memory channel type to use
1853          */
1854         enum tf_ext_mem_chan_type chan_type;
1855         /**
1856          * [in] Entry index to write to
1857          */
1858         uint32_t idx;
1859 };
1860
1861 /**
1862  * set index table entry
1863  *
1864  * Used to insert an application programmed index table entry into a
1865  * previous allocated table location.  A shadow copy of the table
1866  * is maintained (if enabled) (only for internal objects)
1867  *
1868  * Returns success or failure code.
1869  */
1870 int tf_set_tbl_entry(struct tf *tfp,
1871                      struct tf_set_tbl_entry_parms *parms);
1872
1873 /**
1874  * tf_get_shared_tbl_increment parameter definition
1875  */
1876 struct tf_get_shared_tbl_increment_parms {
1877         /**
1878          * [in] Receive or transmit direction
1879          */
1880         enum tf_dir dir;
1881         /**
1882          * [in] Type of object to set
1883          */
1884         enum tf_tbl_type type;
1885         /**
1886          * [out] Value to increment by for resource type
1887          */
1888         uint32_t increment_cnt;
1889 };
1890
1891 /**
1892  * tf_get_shared_tbl_increment
1893  *
1894  * This API is currently only required for use in the shared
1895  * session for Thor (p58) actions.  An increment count is returned per
1896  * type to indicate how much to increment the start by for each
1897  * entry (see tf_resource_info)
1898  *
1899  * Returns success or failure code.
1900  */
1901 int tf_get_shared_tbl_increment(struct tf *tfp,
1902                                 struct tf_get_shared_tbl_increment_parms *parms);
1903
1904 /**
1905  * tf_get_tbl_entry parameter definition
1906  */
1907 struct tf_get_tbl_entry_parms {
1908         /**
1909          * [in] Receive or transmit direction
1910          */
1911         enum tf_dir dir;
1912         /**
1913          * [in] Type of object to get
1914          */
1915         enum tf_tbl_type type;
1916         /**
1917          * [out] Entry data
1918          */
1919         uint8_t *data;
1920         /**
1921          * [in] Entry size
1922          */
1923         uint16_t data_sz_in_bytes;
1924         /**
1925          * [in] External memory channel type to use
1926          */
1927         enum tf_ext_mem_chan_type chan_type;
1928         /**
1929          * [in] Entry index to read
1930          */
1931         uint32_t idx;
1932 };
1933
1934 /**
1935  * get index table entry
1936  *
1937  * Used to retrieve a previous set index table entry.
1938  *
1939  * Reads and compares with the shadow table copy (if enabled) (only
1940  * for internal objects).
1941  *
1942  * Returns success or failure code. Failure will be returned if the
1943  * provided data buffer is too small for the data type requested.
1944  */
1945 int tf_get_tbl_entry(struct tf *tfp,
1946                      struct tf_get_tbl_entry_parms *parms);
1947
1948 /**
1949  * tf_bulk_get_tbl_entry parameter definition
1950  */
1951 struct tf_bulk_get_tbl_entry_parms {
1952         /**
1953          * [in] Receive or transmit direction
1954          */
1955         enum tf_dir dir;
1956         /**
1957          * [in] Type of object to get
1958          */
1959         enum tf_tbl_type type;
1960         /**
1961          * [in] Starting index to read from
1962          */
1963         uint32_t starting_idx;
1964         /**
1965          * [in] Number of sequential entries
1966          */
1967         uint16_t num_entries;
1968         /**
1969          * [in] Size of the single entry
1970          */
1971         uint16_t entry_sz_in_bytes;
1972         /**
1973          * [out] Host physical address, where the data
1974          * will be copied to by the firmware.
1975          * Use tfp_calloc() API and mem_pa
1976          * variable of the tfp_calloc_parms
1977          * structure for the physical address.
1978          */
1979         uint64_t physical_mem_addr;
1980         /**
1981          * [in] External memory channel type to use
1982          */
1983         enum tf_ext_mem_chan_type chan_type;
1984 };
1985
1986 /**
1987  * Bulk get index table entry
1988  *
1989  * Used to retrieve a set of index table entries.
1990  *
1991  * Entries within the range may not have been allocated using
1992  * tf_alloc_tbl_entry() at the time of access. But the range must
1993  * be within the bounds determined from tf_open_session() for the
1994  * given table type.  Currently, this is only used for collecting statistics.
1995  *
1996  * Returns success or failure code. Failure will be returned if the
1997  * provided data buffer is too small for the data type requested.
1998  */
1999 int tf_bulk_get_tbl_entry(struct tf *tfp,
2000                           struct tf_bulk_get_tbl_entry_parms *parms);
2001
2002 /**
2003  * @page exact_match Exact Match Table
2004  *
2005  * @ref tf_insert_em_entry
2006  *
2007  * @ref tf_delete_em_entry
2008  *
2009  * @ref tf_search_em_entry
2010  *
2011  */
2012 /**
2013  * tf_insert_em_entry parameter definition
2014  */
2015 struct tf_insert_em_entry_parms {
2016         /**
2017          * [in] receive or transmit direction
2018          */
2019         enum tf_dir dir;
2020         /**
2021          * [in] internal or external
2022          */
2023         enum tf_mem mem;
2024         /**
2025          * [in] ID of table scope to use (external only)
2026          */
2027         uint32_t tbl_scope_id;
2028         /**
2029          * [in] ptr to structure containing key fields
2030          */
2031         uint8_t *key;
2032         /**
2033          * [in] key bit length
2034          */
2035         uint16_t key_sz_in_bits;
2036         /**
2037          * [in] ptr to structure containing result field
2038          */
2039         uint8_t *em_record;
2040         /**
2041          * [out] result size in bits
2042          */
2043         uint16_t em_record_sz_in_bits;
2044         /**
2045          * [in] duplicate check flag
2046          */
2047         uint8_t dup_check;
2048         /**
2049          * [in] External memory channel type to use
2050          */
2051         enum tf_ext_mem_chan_type chan_type;
2052         /**
2053          * [out] Flow handle value for the inserted entry.  This is encoded
2054          * as the entries[4]:bucket[2]:hashId[1]:hash[14]
2055          */
2056         uint64_t flow_handle;
2057         /**
2058          * [out] Flow id is returned as null (internal)
2059          * Flow id is the GFID value for the inserted entry (external)
2060          * This is the value written to the BD and useful information for mark.
2061          */
2062         uint64_t flow_id;
2063 };
2064 /**
2065  * tf_delete_em_entry parameter definition
2066  */
2067 struct tf_delete_em_entry_parms {
2068         /**
2069          * [in] receive or transmit direction
2070          */
2071         enum tf_dir dir;
2072         /**
2073          * [in] internal or external
2074          */
2075         enum tf_mem mem;
2076         /**
2077          * [in] ID of table scope to use (external only)
2078          */
2079         uint32_t tbl_scope_id;
2080         /**
2081          * [out] The index of the entry
2082          */
2083         uint16_t index;
2084         /**
2085          * [in] External memory channel type to use
2086          */
2087         enum tf_ext_mem_chan_type chan_type;
2088         /**
2089          * [in] structure containing flow delete handle information
2090          */
2091         uint64_t flow_handle;
2092 };
2093 /**
2094  * tf_move_em_entry parameter definition
2095  */
2096 struct tf_move_em_entry_parms {
2097         /**
2098          * [in] receive or transmit direction
2099          */
2100         enum tf_dir dir;
2101         /**
2102          * [in] internal or external
2103          */
2104         enum tf_mem mem;
2105         /**
2106          * [in] ID of table scope to use (external only)
2107          */
2108         uint32_t tbl_scope_id;
2109         /**
2110          * [in] ID of table interface to use (SR2 only)
2111          */
2112         uint32_t tbl_if_id;
2113         /**
2114          * [in] epoch group IDs of entry to delete
2115          * 2 element array with 2 ids. (SR2 only)
2116          */
2117         uint16_t *epochs;
2118         /**
2119          * [out] The index of the entry
2120          */
2121         uint16_t index;
2122         /**
2123          * [in] External memory channel type to use
2124          */
2125         enum tf_ext_mem_chan_type chan_type;
2126         /**
2127          * [in] The index of the new EM record
2128          */
2129         uint32_t new_index;
2130         /**
2131          * [in] structure containing flow delete handle information
2132          */
2133         uint64_t flow_handle;
2134 };
2135 /**
2136  * tf_search_em_entry parameter definition (Future)
2137  */
2138 struct tf_search_em_entry_parms {
2139         /**
2140          * [in] receive or transmit direction
2141          */
2142         enum tf_dir dir;
2143         /**
2144          * [in] internal or external
2145          */
2146         enum tf_mem mem;
2147         /**
2148          * [in] ID of table scope to use (external only)
2149          */
2150         uint32_t tbl_scope_id;
2151         /**
2152          * [in] ptr to structure containing key fields
2153          */
2154         uint8_t *key;
2155         /**
2156          * [in] key bit length
2157          */
2158         uint16_t key_sz_in_bits;
2159         /**
2160          * [in/out] ptr to structure containing EM record fields
2161          */
2162         uint8_t *em_record;
2163         /**
2164          * [out] result size in bits
2165          */
2166         uint16_t em_record_sz_in_bits;
2167         /**
2168          * [in] External memory channel type to use
2169          */
2170         enum tf_ext_mem_chan_type chan_type;
2171         /**
2172          * [in] ptr to structure containing flow delete handle
2173          */
2174         uint64_t flow_handle;
2175 };
2176
2177 /**
2178  * insert em hash entry in internal table memory
2179  *
2180  * Internal:
2181  *
2182  * This API inserts an exact match entry into internal EM table memory
2183  * of the specified direction.
2184  *
2185  * Note: The EM record is managed within the TruFlow core and not the
2186  * application.
2187  *
2188  * Shadow copy of internal record table an association with hash and 1,2, or 4
2189  * associated buckets
2190  *
2191  * External:
2192  * This API inserts an exact match entry into DRAM EM table memory of the
2193  * specified direction and table scope.
2194  *
2195  * The insertion of duplicate entries in an EM table is not permitted.  If a
2196  * TruFlow application can guarantee that it will never insert duplicates, it
2197  * can disable duplicate checking by passing a zero value in the  dup_check
2198  * parameter to this API.  This will optimize performance. Otherwise, the
2199  * TruFlow library will enforce protection against inserting duplicate entries.
2200  *
2201  * Flow handle is defined in this document:
2202  *
2203  * https://docs.google.com
2204  * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
2205  *
2206  * Returns success or busy code.
2207  *
2208  */
2209 int tf_insert_em_entry(struct tf *tfp,
2210                        struct tf_insert_em_entry_parms *parms);
2211
2212 /**
2213  * delete em hash entry table memory
2214  *
2215  * Internal:
2216  *
2217  * This API deletes an exact match entry from internal EM table memory of the
2218  * specified direction. If a valid flow ptr is passed in then that takes
2219  * precedence over the pointer to the complete key passed in.
2220  *
2221  *
2222  * External:
2223  *
2224  * This API deletes an exact match entry from EM table memory of the specified
2225  * direction and table scope. If a valid flow handle is passed in then that
2226  * takes precedence over the pointer to the complete key passed in.
2227  *
2228  * The TruFlow library may release a dynamic bucket when an entry is deleted.
2229  *
2230  *
2231  * Returns success or not found code
2232  *
2233  *
2234  */
2235 int tf_delete_em_entry(struct tf *tfp,
2236                        struct tf_delete_em_entry_parms *parms);
2237
2238 /**
2239  * search em hash entry table memory (Future)
2240  *
2241  * Internal:
2242
2243  * This API looks up an EM entry in table memory with the specified EM
2244  * key or flow (flow takes precedence) and direction.
2245  *
2246  * The status will be one of: success or entry not found.  If the lookup
2247  * succeeds, a pointer to the matching entry and the result record associated
2248  * with the matching entry will be provided.
2249  *
2250  * If flow_handle is set, search shadow copy.
2251  *
2252  * Otherwise, query the fw with key to get result.
2253  *
2254  * External:
2255  *
2256  * This API looks up an EM entry in table memory with the specified EM
2257  * key or flow_handle (flow takes precedence), direction and table scope.
2258  *
2259  * The status will be one of: success or entry not found.  If the lookup
2260  * succeeds, a pointer to the matching entry and the result record associated
2261  * with the matching entry will be provided.
2262  *
2263  * Returns success or not found code
2264  *
2265  */
2266 int tf_search_em_entry(struct tf *tfp,
2267                        struct tf_search_em_entry_parms *parms);
2268
2269 /**
2270  * @page global Global Configuration
2271  *
2272  * @ref tf_set_global_cfg
2273  *
2274  * @ref tf_get_global_cfg
2275  */
2276 /**
2277  * Tunnel Encapsulation Offsets
2278  */
2279 enum tf_tunnel_encap_offsets {
2280         TF_TUNNEL_ENCAP_L2,
2281         TF_TUNNEL_ENCAP_NAT,
2282         TF_TUNNEL_ENCAP_MPLS,
2283         TF_TUNNEL_ENCAP_VXLAN,
2284         TF_TUNNEL_ENCAP_GENEVE,
2285         TF_TUNNEL_ENCAP_NVGRE,
2286         TF_TUNNEL_ENCAP_GRE,
2287         TF_TUNNEL_ENCAP_FULL_GENERIC
2288 };
2289 /**
2290  * Global Configuration Table Types
2291  */
2292 enum tf_global_config_type {
2293         TF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */
2294         TF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */
2295         TF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */
2296         TF_GLOBAL_CFG_TYPE_MAX
2297 };
2298
2299 /**
2300  * tf_global_cfg parameter definition
2301  */
2302 struct tf_global_cfg_parms {
2303         /**
2304          * [in] receive or transmit direction
2305          */
2306         enum tf_dir dir;
2307         /**
2308          * [in] Global config type
2309          */
2310         enum tf_global_config_type type;
2311         /**
2312          * [in] Offset @ the type
2313          */
2314         uint32_t offset;
2315         /**
2316          * [in/out] Value of the configuration
2317          * set - Read, Modify and Write
2318          * get - Read the full configuration
2319          */
2320         uint8_t *config;
2321         /**
2322          * [in] Configuration mask
2323          * set - Read, Modify with mask and Write
2324          * get - unused
2325          */
2326         uint8_t *config_mask;
2327         /**
2328          * [in] struct containing size
2329          */
2330         uint16_t config_sz_in_bytes;
2331 };
2332
2333 /**
2334  * Get global configuration
2335  *
2336  * Retrieve the configuration
2337  *
2338  * Returns success or failure code.
2339  */
2340 int tf_get_global_cfg(struct tf *tfp,
2341                       struct tf_global_cfg_parms *parms);
2342
2343 /**
2344  * Update the global configuration table
2345  *
2346  * Read, modify write the value.
2347  *
2348  * Returns success or failure code.
2349  */
2350 int tf_set_global_cfg(struct tf *tfp,
2351                       struct tf_global_cfg_parms *parms);
2352
2353 /**
2354  * @page if_tbl Interface Table Access
2355  *
2356  * @ref tf_set_if_tbl_entry
2357  *
2358  * @ref tf_get_if_tbl_entry
2359  *
2360  * @ref tf_restore_if_tbl_entry
2361  */
2362 /**
2363  * Enumeration of TruFlow interface table types.
2364  */
2365 enum tf_if_tbl_type {
2366         /** Default Profile L2 Context Entry */
2367         TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
2368         /** Default Profile TCAM/Lookup Action Record Pointer Table */
2369         TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
2370         /** Error Profile TCAM Miss Action Record Pointer Table */
2371         TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
2372         /** Default Error Profile TCAM Miss Action Record Pointer Table */
2373         TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
2374         /** Ingress lookup table */
2375         TF_IF_TBL_TYPE_ILT,
2376         /** VNIC/SVIF Properties Table */
2377         TF_IF_TBL_TYPE_VSPT,
2378         TF_IF_TBL_TYPE_MAX
2379 };
2380
2381 /**
2382  * tf_set_if_tbl_entry parameter definition
2383  */
2384 struct tf_set_if_tbl_entry_parms {
2385         /**
2386          * [in] Receive or transmit direction
2387          */
2388         enum tf_dir dir;
2389         /**
2390          * [in] Type of object to set
2391          */
2392         enum tf_if_tbl_type type;
2393         /**
2394          * [in] Entry data
2395          */
2396         uint8_t *data;
2397         /**
2398          * [in] Entry size
2399          */
2400         uint16_t data_sz_in_bytes;
2401         /**
2402          * [in] Interface to write
2403          */
2404         uint32_t idx;
2405 };
2406
2407 /**
2408  * set interface table entry
2409  *
2410  * Used to set an interface table. This API is used for managing tables indexed
2411  * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
2412  * set.
2413  * Returns success or failure code.
2414  */
2415 int tf_set_if_tbl_entry(struct tf *tfp,
2416                         struct tf_set_if_tbl_entry_parms *parms);
2417
2418 /**
2419  * tf_get_if_tbl_entry parameter definition
2420  */
2421 struct tf_get_if_tbl_entry_parms {
2422         /**
2423          * [in] Receive or transmit direction
2424          */
2425         enum tf_dir dir;
2426         /**
2427          * [in] Type of table to get
2428          */
2429         enum tf_if_tbl_type type;
2430         /**
2431          * [out] Entry data
2432          */
2433         uint8_t *data;
2434         /**
2435          * [in] Entry size
2436          */
2437         uint16_t data_sz_in_bytes;
2438         /**
2439          * [in] Entry index to read
2440          */
2441         uint32_t idx;
2442 };
2443
2444 /**
2445  * get interface table entry
2446  *
2447  * Used to retrieve an interface table entry.
2448  *
2449  * Reads the interface table entry value
2450  *
2451  * Returns success or failure code. Failure will be returned if the
2452  * provided data buffer is too small for the data type requested.
2453  */
2454 int tf_get_if_tbl_entry(struct tf *tfp,
2455                         struct tf_get_if_tbl_entry_parms *parms);
2456
2457 #endif /* _TF_CORE_H_ */