net/bnxt: add TF register and unregister
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 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/hcapi_cfa.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
25 #define TF_KILOBYTE  1024
26 #define TF_MEGABYTE  (1024 * 1024)
27
28 /**
29  * direction
30  */
31 enum tf_dir {
32         TF_DIR_RX,  /**< Receive */
33         TF_DIR_TX,  /**< Transmit */
34         TF_DIR_MAX
35 };
36
37 /**
38  * memory choice
39  */
40 enum tf_mem {
41         TF_MEM_INTERNAL, /**< Internal */
42         TF_MEM_EXTERNAL, /**< External */
43         TF_MEM_MAX
44 };
45
46 /**
47  * EEM record AR helper
48  *
49  * Helper to handle the Action Record Pointer in the EEM Record Entry.
50  *
51  * Convert absolute offset to action record pointer in EEM record entry
52  * Convert action record pointer in EEM record entry to absolute offset
53  */
54 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
55 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
56
57
58 /*
59  * Helper Macros
60  */
61 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
62
63 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
64
65 /**
66  * @page general General
67  *
68  * @ref tf_open_session
69  *
70  * @ref tf_attach_session
71  *
72  * @ref tf_close_session
73  */
74
75 /**
76  * Session Version defines
77  *
78  * The version controls the format of the tf_session and
79  * tf_session_info structure. This is to assure upgrade between
80  * versions can be supported.
81  */
82 #define TF_SESSION_VER_MAJOR  1   /**< Major Version */
83 #define TF_SESSION_VER_MINOR  0   /**< Minor Version */
84 #define TF_SESSION_VER_UPDATE 0   /**< Update Version */
85
86 /**
87  * Session Name
88  *
89  * Name of the TruFlow control channel interface.  Expects
90  * format to be RTE Name specific, i.e. rte_eth_dev_get_name_by_port()
91  */
92 #define TF_SESSION_NAME_MAX       64
93
94 #define TF_FW_SESSION_ID_INVALID  0xFF  /**< Invalid FW Session ID define */
95
96 /**
97  * Session Identifier
98  *
99  * Unique session identifier which includes PCIe bus info to
100  * distinguish the PF and session info to identify the associated
101  * TruFlow session. Session ID is constructed from the passed in
102  * ctrl_chan_name in tf_open_session() together with an allocated
103  * fw_session_id. Done by TruFlow on tf_open_session().
104  */
105 union tf_session_id {
106         uint32_t id;
107         struct {
108                 uint8_t domain;
109                 uint8_t bus;
110                 uint8_t device;
111                 uint8_t fw_session_id;
112         } internal;
113 };
114
115 /**
116  * Session Client Identifier
117  *
118  * Unique identifier for a client within a session. Session Client ID
119  * is constructed from the passed in session and a firmware allocated
120  * fw_session_client_id. Done by TruFlow on tf_open_session().
121  */
122 union tf_session_client_id {
123         uint16_t id;
124         struct {
125                 uint8_t fw_session_id;
126                 uint8_t fw_session_client_id;
127         } internal;
128 };
129
130 /**
131  * Session Version
132  *
133  * The version controls the format of the tf_session and
134  * tf_session_info structure. This is to assure upgrade between
135  * versions can be supported.
136  *
137  * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
138  */
139 struct tf_session_version {
140         uint8_t major;
141         uint8_t minor;
142         uint8_t update;
143 };
144
145 /**
146  * Session supported device types
147  */
148 enum tf_device_type {
149         TF_DEVICE_TYPE_WH = 0, /**< Whitney+  */
150         TF_DEVICE_TYPE_SR,     /**< Stingray  */
151         TF_DEVICE_TYPE_THOR,   /**< Thor      */
152         TF_DEVICE_TYPE_SR2,    /**< Stingray2 */
153         TF_DEVICE_TYPE_MAX     /**< Maximum   */
154 };
155
156 /**
157  * Identifier resource types
158  */
159 enum tf_identifier_type {
160         /**
161          *  The L2 Context is returned from the L2 Ctxt TCAM lookup
162          *  and can be used in WC TCAM or EM keys to virtualize further
163          *  lookups.
164          */
165         TF_IDENT_TYPE_L2_CTXT,
166         /**
167          *  The WC profile func is returned from the L2 Ctxt TCAM lookup
168          *  to enable virtualization of the profile TCAM.
169          */
170         TF_IDENT_TYPE_PROF_FUNC,
171         /**
172          *  The WC profile ID is included in the WC lookup key
173          *  to enable virtualization of the WC TCAM hardware.
174          */
175         TF_IDENT_TYPE_WC_PROF,
176         /**
177          *  The EM profile ID is included in the EM lookup key
178          *  to enable virtualization of the EM hardware. (not required for SR2
179          *  as it has table scope)
180          */
181         TF_IDENT_TYPE_EM_PROF,
182         /**
183          *  The L2 func is included in the ILT result and from recycling to
184          *  enable virtualization of further lookups.
185          */
186         TF_IDENT_TYPE_L2_FUNC,
187         TF_IDENT_TYPE_MAX
188 };
189
190 /**
191  * Enumeration of TruFlow table types. A table type is used to identify a
192  * resource object.
193  *
194  * NOTE: The table type TF_TBL_TYPE_EXT is unique in that it is
195  * the only table type that is connected with a table scope.
196  */
197 enum tf_tbl_type {
198         /* Internal */
199
200         /** Wh+/SR Action Record */
201         TF_TBL_TYPE_FULL_ACT_RECORD,
202         /** Wh+/SR/Th Multicast Groups */
203         TF_TBL_TYPE_MCAST_GROUPS,
204         /** Wh+/SR Action Encap 8 Bytes */
205         TF_TBL_TYPE_ACT_ENCAP_8B,
206         /** Wh+/SR Action Encap 16 Bytes */
207         TF_TBL_TYPE_ACT_ENCAP_16B,
208         /** Action Encap 32 Bytes */
209         TF_TBL_TYPE_ACT_ENCAP_32B,
210         /** Wh+/SR Action Encap 64 Bytes */
211         TF_TBL_TYPE_ACT_ENCAP_64B,
212         /** Action Source Properties SMAC */
213         TF_TBL_TYPE_ACT_SP_SMAC,
214         /** Wh+/SR Action Source Properties SMAC IPv4 */
215         TF_TBL_TYPE_ACT_SP_SMAC_IPV4,
216         /** Action Source Properties SMAC IPv6 */
217         TF_TBL_TYPE_ACT_SP_SMAC_IPV6,
218         /** Wh+/SR Action Statistics 64 Bits */
219         TF_TBL_TYPE_ACT_STATS_64,
220         /** Wh+/SR Action Modify L4 Src Port */
221         TF_TBL_TYPE_ACT_MODIFY_SPORT,
222         /** Wh+/SR Action Modify L4 Dest Port */
223         TF_TBL_TYPE_ACT_MODIFY_DPORT,
224         /** Wh+/SR Action Modify IPv4 Source */
225         TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
226         /** Wh+/SR Action _Modify L4 Dest Port */
227         TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
228         /** Meter Profiles */
229         TF_TBL_TYPE_METER_PROF,
230         /** Meter Instance */
231         TF_TBL_TYPE_METER_INST,
232         /** Mirror Config */
233         TF_TBL_TYPE_MIRROR_CONFIG,
234         /** UPAR */
235         TF_TBL_TYPE_UPAR,
236         /** SR2 Epoch 0 table */
237         TF_TBL_TYPE_EPOCH0,
238         /** SR2 Epoch 1 table  */
239         TF_TBL_TYPE_EPOCH1,
240         /** SR2 Metadata  */
241         TF_TBL_TYPE_METADATA,
242         /** SR2 CT State  */
243         TF_TBL_TYPE_CT_STATE,
244         /** SR2 Range Profile  */
245         TF_TBL_TYPE_RANGE_PROF,
246         /** SR2 Range Entry  */
247         TF_TBL_TYPE_RANGE_ENTRY,
248         /** SR2 LAG Entry  */
249         TF_TBL_TYPE_LAG,
250         /** SR2 VNIC/SVIF Table */
251         TF_TBL_TYPE_VNIC_SVIF,
252         /** Th/SR2 EM Flexible Key builder */
253         TF_TBL_TYPE_EM_FKB,
254         /** Th/SR2 WC Flexible Key builder */
255         TF_TBL_TYPE_WC_FKB,
256
257         /* External */
258
259         /**
260          * External table type - initially 1 poolsize entries.
261          * All External table types are associated with a table
262          * scope. Internal types are not.
263          */
264         TF_TBL_TYPE_EXT,
265         TF_TBL_TYPE_MAX
266 };
267
268 /**
269  * TCAM table type
270  */
271 enum tf_tcam_tbl_type {
272         /** L2 Context TCAM */
273         TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
274         /** Profile TCAM */
275         TF_TCAM_TBL_TYPE_PROF_TCAM,
276         /** Wildcard TCAM */
277         TF_TCAM_TBL_TYPE_WC_TCAM,
278         /** Source Properties TCAM */
279         TF_TCAM_TBL_TYPE_SP_TCAM,
280         /** Connection Tracking Rule TCAM */
281         TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
282         /** Virtual Edge Bridge TCAM */
283         TF_TCAM_TBL_TYPE_VEB_TCAM,
284         TF_TCAM_TBL_TYPE_MAX
285 };
286
287 /**
288  * EM Resources
289  * These defines are provisioned during
290  * tf_open_session()
291  */
292 enum tf_em_tbl_type {
293         /** The number of internal EM records for the session */
294         TF_EM_TBL_TYPE_EM_RECORD,
295         /** The number of table scopes reequested */
296         TF_EM_TBL_TYPE_TBL_SCOPE,
297         TF_EM_TBL_TYPE_MAX
298 };
299
300 /**
301  * TruFlow Session Information
302  *
303  * Structure defining a TruFlow Session, also known as a Management
304  * session. This structure is initialized at time of
305  * tf_open_session(). It is passed to all of the TruFlow APIs as way
306  * to prescribe and isolate resources between different TruFlow ULP
307  * Applications.
308  *
309  * Ownership of the elements is split between ULP and TruFlow. Please
310  * see the individual elements.
311  */
312 struct tf_session_info {
313         /**
314          * TrueFlow Version. Used to control the structure layout when
315          * sharing sessions. No guarantee that a secondary process
316          * would come from the same version of an executable.
317          * TruFlow initializes this variable on tf_open_session().
318          *
319          * Owner:  TruFlow
320          * Access: TruFlow
321          */
322         struct tf_session_version ver;
323         /**
324          * will be STAILQ_ENTRY(tf_session_info) next
325          *
326          * Owner:  ULP
327          * Access: ULP
328          */
329         void                 *next;
330         /**
331          * Session ID is a unique identifier for the session. TruFlow
332          * initializes this variable during tf_open_session()
333          * processing.
334          *
335          * Owner:  TruFlow
336          * Access: Truflow & ULP
337          */
338         union tf_session_id   session_id;
339         /**
340          * Protects access to core_data. Lock is initialized and owned
341          * by ULP. TruFlow can access the core_data without checking
342          * the lock.
343          *
344          * Owner:  ULP
345          * Access: ULP
346          */
347         uint8_t               spin_lock;
348         /**
349          * The core_data holds the TruFlow tf_session data
350          * structure. This memory is allocated and owned by TruFlow on
351          * tf_open_session().
352          *
353          * TruFlow uses this memory for session management control
354          * until the session is closed by ULP. Access control is done
355          * by the spin_lock which ULP controls ahead of TruFlow API
356          * calls.
357          *
358          * Please see tf_open_session_parms for specification details
359          * on this variable.
360          *
361          * Owner:  TruFlow
362          * Access: TruFlow
363          */
364         void                 *core_data;
365         /**
366          * The core_data_sz_bytes specifies the size of core_data in
367          * bytes.
368          *
369          * The size is set by TruFlow on tf_open_session().
370          *
371          * Please see tf_open_session_parms for specification details
372          * on this variable.
373          *
374          * Owner:  TruFlow
375          * Access: TruFlow
376          */
377         uint32_t              core_data_sz_bytes;
378 };
379
380 /**
381  * TruFlow handle
382  *
383  * Contains a pointer to the session info. Allocated by ULP and passed
384  * to TruFlow using tf_open_session(). TruFlow will populate the
385  * session info at that time. A TruFlow Session can be used by more
386  * than one PF/VF by using the tf_open_session().
387  *
388  * It is expected that ULP allocates this memory as shared memory.
389  *
390  * NOTE: This struct must be within the BNXT PMD struct bnxt
391  *       (bp). This allows use of container_of() to get access to the PMD.
392  */
393 struct tf {
394         struct tf_session_info *session;
395 };
396
397 /**
398  * Identifier resource definition
399  */
400 struct tf_identifier_resources {
401         /**
402          * Array of TF Identifiers where each entry is expected to be
403          * set to the requested resource number of that specific type.
404          * The index used is tf_identifier_type.
405          */
406         uint16_t cnt[TF_IDENT_TYPE_MAX];
407 };
408
409 /**
410  * Table type resource definition
411  */
412 struct tf_tbl_resources {
413         /**
414          * Array of TF Table types where each entry is expected to be
415          * set to the requeste resource number of that specific
416          * type. The index used is tf_tbl_type.
417          */
418         uint16_t cnt[TF_TBL_TYPE_MAX];
419 };
420
421 /**
422  * TCAM type resource definition
423  */
424 struct tf_tcam_resources {
425         /**
426          * Array of TF TCAM types where each entry is expected to be
427          * set to the requested resource number of that specific
428          * type. The index used is tf_tcam_tbl_type.
429          */
430         uint16_t cnt[TF_TCAM_TBL_TYPE_MAX];
431 };
432
433 /**
434  * EM type resource definition
435  */
436 struct tf_em_resources {
437         /**
438          * Array of TF EM table types where each entry is expected to
439          * be set to the requested resource number of that specific
440          * type. The index used is tf_em_tbl_type.
441          */
442         uint16_t cnt[TF_EM_TBL_TYPE_MAX];
443 };
444
445 /**
446  * tf_session_resources parameter definition.
447  */
448 struct tf_session_resources {
449         /**
450          * [in] Requested Identifier Resources
451          *
452          * Number of identifier resources requested for the
453          * session.
454          */
455         struct tf_identifier_resources ident_cnt[TF_DIR_MAX];
456         /**
457          * [in] Requested Index Table resource counts
458          *
459          * The number of index table resources requested for the
460          * session.
461          */
462         struct tf_tbl_resources tbl_cnt[TF_DIR_MAX];
463         /**
464          * [in] Requested TCAM Table resource counts
465          *
466          * The number of TCAM table resources requested for the
467          * session.
468          */
469
470         struct tf_tcam_resources tcam_cnt[TF_DIR_MAX];
471         /**
472          * [in] Requested EM resource counts
473          *
474          * The number of internal EM table resources requested for the
475          * session.
476          */
477         struct tf_em_resources em_cnt[TF_DIR_MAX];
478 };
479
480 /**
481  * tf_open_session parameters definition.
482  */
483 struct tf_open_session_parms {
484         /**
485          * [in] ctrl_chan_name
486          *
487          * String containing name of control channel interface to be
488          * used for this session to communicate with firmware.
489          *
490          * The ctrl_chan_name can be looked up by using
491          * rte_eth_dev_get_name_by_port() within the ULP.
492          *
493          * ctrl_chan_name will be used as part of a name for any
494          * shared memory allocation.
495          */
496         char ctrl_chan_name[TF_SESSION_NAME_MAX];
497         /**
498          * [in] shadow_copy
499          *
500          * Boolean controlling the use and availability of shadow
501          * copy. Shadow copy will allow the TruFlow to keep track of
502          * resource content on the firmware side without having to
503          * query firmware. Additional private session core_data will
504          * be allocated if this boolean is set to 'true', default
505          * 'false'.
506          *
507          * Size of memory depends on the NVM Resource settings for the
508          * control channel.
509          */
510         bool shadow_copy;
511         /**
512          * [in/out] session_id
513          *
514          * Session_id is unique per session.
515          *
516          * Session_id is composed of domain, bus, device and
517          * fw_session_id. The construction is done by parsing the
518          * ctrl_chan_name together with allocation of a fw_session_id.
519          *
520          * The session_id allows a session to be shared between devices.
521          */
522         union tf_session_id session_id;
523         /**
524          * [in/out] session_client_id
525          *
526          * Session_client_id is unique per client.
527          *
528          * Session_client_id is composed of session_id and the
529          * fw_session_client_id fw_session_id. The construction is
530          * done by parsing the ctrl_chan_name together with allocation
531          * of a fw_session_client_id during tf_open_session().
532          *
533          * A reference count will be incremented in the session on
534          * which a client is created.
535          *
536          * A session can first be closed if there is one Session
537          * Client left. Session Clients should closed using
538          * tf_close_session().
539          */
540         union tf_session_client_id session_client_id;
541         /**
542          * [in] device type
543          *
544          * Device type for the session.
545          */
546         enum tf_device_type device_type;
547         /**
548          * [in] resources
549          *
550          * Resource allocation for the session.
551          */
552         struct tf_session_resources resources;
553 };
554
555 /**
556  * Opens a new TruFlow Session or session client.
557  *
558  * What gets created depends on the passed in tfp content. If the tfp
559  * does not have prior session data a new session with associated
560  * session client. If tfp has a session already a session client will
561  * be created. In both cases the session client is created using the
562  * provided ctrl_chan_name.
563  *
564  * In case of session creation TruFlow will allocate session specific
565  * memory, shared memory, to hold its session data. This data is
566  * private to TruFlow.
567  *
568  * No other TruFlow APIs will succeed unless this API is first called
569  * and succeeds.
570  *
571  * tf_open_session() returns a session id and session client id that
572  * is used on all other TF APIs.
573  *
574  * A Session or session client can be closed using tf_close_session().
575  *
576  * [in] tfp
577  *   Pointer to TF handle
578  *
579  * [in] parms
580  *   Pointer to open parameters
581  *
582  * Returns
583  *   - (0) if successful.
584  *   - (-EINVAL) on failure.
585  */
586 int tf_open_session(struct tf *tfp,
587                     struct tf_open_session_parms *parms);
588
589 /**
590  * Experimental
591  *
592  * tf_attach_session parameters definition.
593  */
594 struct tf_attach_session_parms {
595         /**
596          * [in] ctrl_chan_name
597          *
598          * String containing name of control channel interface to be
599          * used for this session to communicate with firmware.
600          *
601          * The ctrl_chan_name can be looked up by using
602          * rte_eth_dev_get_name_by_port() within the ULP.
603          *
604          * ctrl_chan_name will be used as part of a name for any
605          * shared memory allocation.
606          */
607         char ctrl_chan_name[TF_SESSION_NAME_MAX];
608
609         /**
610          * [in] attach_chan_name
611          *
612          * String containing name of attach channel interface to be
613          * used for this session.
614          *
615          * The attach_chan_name must be given to a 2nd process after
616          * the primary process has been created. This is the
617          * ctrl_chan_name of the primary process and is used to find
618          * the shared memory for the session that the attach is going
619          * to use.
620          */
621         char attach_chan_name[TF_SESSION_NAME_MAX];
622
623         /**
624          * [in] session_id
625          *
626          * Session_id is unique per session. For Attach the session_id
627          * should be the session_id that was returned on the first
628          * open.
629          *
630          * Session_id is composed of domain, bus, device and
631          * fw_session_id. The construction is done by parsing the
632          * ctrl_chan_name together with allocation of a fw_session_id
633          * during tf_open_session().
634          *
635          * A reference count will be incremented on attach. A session
636          * is first fully closed when reference count is zero by
637          * calling tf_close_session().
638          */
639         union tf_session_id session_id;
640 };
641
642 /**
643  * Experimental
644  *
645  * Allows a 2nd application instance to attach to an existing
646  * session. Used when a session is to be shared between two processes.
647  *
648  * Attach will increment a ref count as to manage the shared session data.
649  *
650  * [in] tfp
651  *   Pointer to TF handle
652  *
653  * [in] parms
654  *   Pointer to attach parameters
655  *
656  * Returns
657  *   - (0) if successful.
658  *   - (-EINVAL) on failure.
659  */
660 int tf_attach_session(struct tf *tfp,
661                       struct tf_attach_session_parms *parms);
662
663 /**
664  * Closes an existing session client or the session it self. The
665  * session client is default closed and if the session reference count
666  * is 0 then the session is closed as well.
667  *
668  * On session close all hardware and firmware state associated with
669  * the TruFlow application is cleaned up.
670  *
671  * The session client is extracted from the tfp. Thus tf_close_session()
672  * cannot close a session client on behalf of another function.
673  *
674  * Returns success or failure code.
675  */
676 int tf_close_session(struct tf *tfp);
677
678 /**
679  * @page  ident Identity Management
680  *
681  * @ref tf_alloc_identifier
682  *
683  * @ref tf_free_identifier
684  */
685 /**
686  * tf_alloc_identifier parameter definition
687  */
688 struct tf_alloc_identifier_parms {
689         /**
690          * [in]  receive or transmit direction
691          */
692         enum tf_dir dir;
693         /**
694          * [in] Identifier type
695          */
696         enum tf_identifier_type ident_type;
697         /**
698          * [out] Identifier allocated
699          */
700         uint16_t id;
701 };
702
703 /**
704  * tf_free_identifier parameter definition
705  */
706 struct tf_free_identifier_parms {
707         /**
708          * [in]  receive or transmit direction
709          */
710         enum tf_dir dir;
711         /**
712          * [in] Identifier type
713          */
714         enum tf_identifier_type ident_type;
715         /**
716          * [in] ID to free
717          */
718         uint16_t id;
719 };
720
721 /**
722  * allocate identifier resource
723  *
724  * TruFlow core will allocate a free id from the per identifier resource type
725  * pool reserved for the session during tf_open().  No firmware is involved.
726  *
727  * Returns success or failure code.
728  */
729 int tf_alloc_identifier(struct tf *tfp,
730                         struct tf_alloc_identifier_parms *parms);
731
732 /**
733  * free identifier resource
734  *
735  * TruFlow core will return an id back to the per identifier resource type pool
736  * reserved for the session.  No firmware is involved.  During tf_close, the
737  * complete pool is returned to the firmware.
738  *
739  * Returns success or failure code.
740  */
741 int tf_free_identifier(struct tf *tfp,
742                        struct tf_free_identifier_parms *parms);
743
744 /**
745  * @page dram_table DRAM Table Scope Interface
746  *
747  * @ref tf_alloc_tbl_scope
748  *
749  * @ref tf_free_tbl_scope
750  *
751  * If we allocate the EEM memory from the core, we need to store it in
752  * the shared session data structure to make sure it can be freed later.
753  * (for example if the PF goes away)
754  *
755  * Current thought is that memory is allocated within core.
756  */
757
758
759 /**
760  * tf_alloc_tbl_scope_parms definition
761  */
762 struct tf_alloc_tbl_scope_parms {
763         /**
764          * [in] All Maximum key size required.
765          */
766         uint16_t rx_max_key_sz_in_bits;
767         /**
768          * [in] Maximum Action size required (includes inlined items)
769          */
770         uint16_t rx_max_action_entry_sz_in_bits;
771         /**
772          * [in] Memory size in Megabytes
773          * Total memory size allocated by user to be divided
774          * up for actions, hash, counters.  Only inline external actions.
775          * Use this variable or the number of flows, do not set both.
776          */
777         uint32_t rx_mem_size_in_mb;
778         /**
779          * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0.
780          */
781         uint32_t rx_num_flows_in_k;
782         /**
783          * [in] SR2 only receive table access interface id
784          */
785         uint32_t rx_tbl_if_id;
786         /**
787          * [in] All Maximum key size required.
788          */
789         uint16_t tx_max_key_sz_in_bits;
790         /**
791          * [in] Maximum Action size required (includes inlined items)
792          */
793         uint16_t tx_max_action_entry_sz_in_bits;
794         /**
795          * [in] Memory size in Megabytes
796          * Total memory size allocated by user to be divided
797          * up for actions, hash, counters.  Only inline external actions.
798          */
799         uint32_t tx_mem_size_in_mb;
800         /**
801          * [in] Number of flows * 1000
802          */
803         uint32_t tx_num_flows_in_k;
804         /**
805          * [in] SR2 only receive table access interface id
806          */
807         uint32_t tx_tbl_if_id;
808         /**
809          * [in] Flush pending HW cached flows every 1/10th of value
810          * set in seconds, both idle and active flows are flushed
811          * from the HW cache. If set to 0, this feature will be disabled.
812          */
813         uint8_t hw_flow_cache_flush_timer;
814         /**
815          * [out] table scope identifier
816          */
817         uint32_t tbl_scope_id;
818 };
819
820 struct tf_free_tbl_scope_parms {
821         /**
822          * [in] table scope identifier
823          */
824         uint32_t tbl_scope_id;
825 };
826
827 /**
828  * allocate a table scope
829  *
830  * On SR2 Firmware will allocate a scope ID.  On other devices, the scope
831  * is a software construct to identify an EEM table.  This function will
832  * divide the hash memory/buckets and records according to the device
833  * device constraints based upon calculations using either the number of flows
834  * requested or the size of memory indicated.  Other parameters passed in
835  * determine the configuration (maximum key size, maximum external action record
836  * size.
837  *
838  * This API will allocate the table region in
839  * DRAM, program the PTU page table entries, and program the number of static
840  * buckets (if SR2) in the RX and TX CFAs.  Buckets are assumed to start at
841  * 0 in the EM memory for the scope.  Upon successful completion of this API,
842  * hash tables are fully initialized and ready for entries to be inserted.
843  *
844  * A single API is used to allocate a common table scope identifier in both
845  * receive and transmit CFA. The scope identifier is common due to nature of
846  * connection tracking sending notifications between RX and TX direction.
847  *
848  * The receive and transmit table access identifiers specify which rings will
849  * be used to initialize table DRAM.  The application must ensure mutual
850  * exclusivity of ring usage for table scope allocation and any table update
851  * operations.
852  *
853  * The hash table buckets, EM keys, and EM lookup results are stored in the
854  * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters.  The
855  * hash table buckets are stored at the beginning of that memory.
856  *
857  * NOTE:  No EM internal setup is done here. On chip EM records are managed
858  * internally by TruFlow core.
859  *
860  * Returns success or failure code.
861  */
862 int tf_alloc_tbl_scope(struct tf *tfp,
863                        struct tf_alloc_tbl_scope_parms *parms);
864
865
866 /**
867  * free a table scope
868  *
869  * Firmware checks that the table scope ID is owned by the TruFlow
870  * session, verifies that no references to this table scope remains
871  * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction,
872  * then frees the table scope ID.
873  *
874  * Returns success or failure code.
875  */
876 int tf_free_tbl_scope(struct tf *tfp,
877                       struct tf_free_tbl_scope_parms *parms);
878
879 /**
880  * @page tcam TCAM Access
881  *
882  * @ref tf_alloc_tcam_entry
883  *
884  * @ref tf_set_tcam_entry
885  *
886  * @ref tf_get_tcam_entry
887  *
888  * @ref tf_free_tcam_entry
889  */
890
891
892 /**
893  * tf_alloc_tcam_entry parameter definition
894  */
895 struct tf_alloc_tcam_entry_parms {
896         /**
897          * [in] receive or transmit direction
898          */
899         enum tf_dir dir;
900         /**
901          * [in] TCAM table type
902          */
903         enum tf_tcam_tbl_type tcam_tbl_type;
904         /**
905          * [in] Enable search for matching entry
906          */
907         uint8_t search_enable;
908         /**
909          * [in] Key data to match on (if search)
910          */
911         uint8_t *key;
912         /**
913          * [in] key size in bits (if search)
914          */
915         uint16_t key_sz_in_bits;
916         /**
917          * [in] Mask data to match on (if search)
918          */
919         uint8_t *mask;
920         /**
921          * [in] Priority of entry requested (definition TBD)
922          */
923         uint32_t priority;
924         /**
925          * [out] If search, set if matching entry found
926          */
927         uint8_t hit;
928         /**
929          * [out] Current refcnt after allocation
930          */
931         uint16_t ref_cnt;
932         /**
933          * [out] Idx allocated
934          *
935          */
936         uint16_t idx;
937 };
938
939 /**
940  * allocate TCAM entry
941  *
942  * Allocate a TCAM entry - one of these types:
943  *
944  * L2 Context
945  * Profile TCAM
946  * WC TCAM
947  * VEB TCAM
948  *
949  * This function allocates a TCAM table record.  This function
950  * will attempt to allocate a TCAM table entry from the session
951  * owned TCAM entries or search a shadow copy of the TCAM table for a
952  * matching entry if search is enabled.  Key, mask and result must match for
953  * hit to be set.  Only TruFlow core data is accessed.
954  * A hash table to entry mapping is maintained for search purposes.  If
955  * search is not enabled, the first available free entry is returned based
956  * on priority and alloc_cnt is set to 1.  If search is enabled and a matching
957  * entry to entry_data is found, hit is set to TRUE and alloc_cnt is set to 1.
958  * RefCnt is also returned.
959  *
960  * Also returns success or failure code.
961  */
962 int tf_alloc_tcam_entry(struct tf *tfp,
963                         struct tf_alloc_tcam_entry_parms *parms);
964
965 /**
966  * tf_set_tcam_entry parameter definition
967  */
968 struct  tf_set_tcam_entry_parms {
969         /**
970          * [in] receive or transmit direction
971          */
972         enum tf_dir dir;
973         /**
974          * [in] TCAM table type
975          */
976         enum tf_tcam_tbl_type tcam_tbl_type;
977         /**
978          * [in] base index of the entry to program
979          */
980         uint16_t idx;
981         /**
982          * [in] struct containing key
983          */
984         uint8_t *key;
985         /**
986          * [in] struct containing mask fields
987          */
988         uint8_t *mask;
989         /**
990          * [in] key size in bits (if search)
991          */
992         uint16_t key_sz_in_bits;
993         /**
994          * [in] struct containing result
995          */
996         uint8_t *result;
997         /**
998          * [in] struct containing result size in bits
999          */
1000         uint16_t result_sz_in_bits;
1001 };
1002
1003 /**
1004  * set TCAM entry
1005  *
1006  * Program a TCAM table entry for a TruFlow session.
1007  *
1008  * If the entry has not been allocated, an error will be returned.
1009  *
1010  * Returns success or failure code.
1011  */
1012 int tf_set_tcam_entry(struct tf *tfp,
1013                       struct tf_set_tcam_entry_parms *parms);
1014
1015 /**
1016  * tf_get_tcam_entry parameter definition
1017  */
1018 struct tf_get_tcam_entry_parms {
1019         /**
1020          * [in] receive or transmit direction
1021          */
1022         enum tf_dir dir;
1023         /**
1024          * [in] TCAM table type
1025          */
1026         enum tf_tcam_tbl_type  tcam_tbl_type;
1027         /**
1028          * [in] index of the entry to get
1029          */
1030         uint16_t idx;
1031         /**
1032          * [out] struct containing key
1033          */
1034         uint8_t *key;
1035         /**
1036          * [out] struct containing mask fields
1037          */
1038         uint8_t *mask;
1039         /**
1040          * [out] key size in bits
1041          */
1042         uint16_t key_sz_in_bits;
1043         /**
1044          * [out] struct containing result
1045          */
1046         uint8_t *result;
1047         /**
1048          * [out] struct containing result size in bits
1049          */
1050         uint16_t result_sz_in_bits;
1051 };
1052
1053 /**
1054  * get TCAM entry
1055  *
1056  * Program a TCAM table entry for a TruFlow session.
1057  *
1058  * If the entry has not been allocated, an error will be returned.
1059  *
1060  * Returns success or failure code.
1061  */
1062 int tf_get_tcam_entry(struct tf *tfp,
1063                       struct tf_get_tcam_entry_parms *parms);
1064
1065 /**
1066  * tf_free_tcam_entry parameter definition
1067  */
1068 struct tf_free_tcam_entry_parms {
1069         /**
1070          * [in] receive or transmit direction
1071          */
1072         enum tf_dir dir;
1073         /**
1074          * [in] TCAM table type
1075          */
1076         enum tf_tcam_tbl_type tcam_tbl_type;
1077         /**
1078          * [in] Index to free
1079          */
1080         uint16_t idx;
1081         /**
1082          * [out] reference count after free
1083          */
1084         uint16_t ref_cnt;
1085 };
1086
1087 /**
1088  * free TCAM entry
1089  *
1090  * Free TCAM entry.
1091  *
1092  * Firmware checks to ensure the TCAM entries are owned by the TruFlow
1093  * session.  TCAM entry will be invalidated.  All-ones mask.
1094  * writes to hw.
1095  *
1096  * WCTCAM profile id of 0 must be used to invalidate an entry.
1097  *
1098  * Returns success or failure code.
1099  */
1100 int tf_free_tcam_entry(struct tf *tfp,
1101                        struct tf_free_tcam_entry_parms *parms);
1102
1103 /**
1104  * @page table Table Access
1105  *
1106  * @ref tf_alloc_tbl_entry
1107  *
1108  * @ref tf_free_tbl_entry
1109  *
1110  * @ref tf_set_tbl_entry
1111  *
1112  * @ref tf_get_tbl_entry
1113  *
1114  * @ref tf_bulk_get_tbl_entry
1115  */
1116
1117 /**
1118  * tf_alloc_tbl_entry parameter definition
1119  */
1120 struct tf_alloc_tbl_entry_parms {
1121         /**
1122          * [in] Receive or transmit direction
1123          */
1124         enum tf_dir dir;
1125         /**
1126          * [in] Type of the allocation
1127          */
1128         enum tf_tbl_type type;
1129         /**
1130          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1131          */
1132         uint32_t tbl_scope_id;
1133         /**
1134          * [in] Enable search for matching entry. If the table type is
1135          * internal the shadow copy will be searched before
1136          * alloc. Session must be configured with shadow copy enabled.
1137          */
1138         uint8_t search_enable;
1139         /**
1140          * [in] Result data to search for (if search_enable)
1141          */
1142         uint8_t *result;
1143         /**
1144          * [in] Result data size in bytes (if search_enable)
1145          */
1146         uint16_t result_sz_in_bytes;
1147         /**
1148          * [out] If search_enable, set if matching entry found
1149          */
1150         uint8_t hit;
1151         /**
1152          * [out] Current ref count after allocation (if search_enable)
1153          */
1154         uint16_t ref_cnt;
1155         /**
1156          * [out] Idx of allocated entry or found entry (if search_enable)
1157          */
1158         uint32_t idx;
1159 };
1160
1161 /**
1162  * allocate index table entries
1163  *
1164  * Internal types:
1165  *
1166  * Allocate an on chip index table entry or search for a matching
1167  * entry of the indicated type for this TruFlow session.
1168  *
1169  * Allocates an index table record. This function will attempt to
1170  * allocate an entry or search an index table for a matching entry if
1171  * search is enabled (only the shadow copy of the table is accessed).
1172  *
1173  * If search is not enabled, the first available free entry is
1174  * returned. If search is enabled and a matching entry to entry_data
1175  * is found hit is set to TRUE and success is returned.
1176  *
1177  * External types:
1178  *
1179  * These are used to allocate inlined action record memory.
1180  *
1181  * Allocates an external index table action record.
1182  *
1183  * NOTE:
1184  * Implementation of the internals of this function will be a stack with push
1185  * and pop.
1186  *
1187  * Returns success or failure code.
1188  */
1189 int tf_alloc_tbl_entry(struct tf *tfp,
1190                        struct tf_alloc_tbl_entry_parms *parms);
1191
1192 /**
1193  * tf_free_tbl_entry parameter definition
1194  */
1195 struct tf_free_tbl_entry_parms {
1196         /**
1197          * [in] Receive or transmit direction
1198          */
1199         enum tf_dir dir;
1200         /**
1201          * [in] Type of the allocation type
1202          */
1203         enum tf_tbl_type type;
1204         /**
1205          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
1206          */
1207         uint32_t tbl_scope_id;
1208         /**
1209          * [in] Index to free
1210          */
1211         uint32_t idx;
1212         /**
1213          * [out] Reference count after free, only valid if session has been
1214          * created with shadow_copy.
1215          */
1216         uint16_t ref_cnt;
1217 };
1218
1219 /**
1220  * free index table entry
1221  *
1222  * Used to free a previously allocated table entry.
1223  *
1224  * Internal types:
1225  *
1226  * If session has shadow_copy enabled the shadow DB is searched and if
1227  * found the element ref_cnt is decremented. If ref_cnt goes to
1228  * zero then the element is returned to the session pool.
1229  *
1230  * If the session does not have a shadow DB the element is free'ed and
1231  * given back to the session pool.
1232  *
1233  * External types:
1234  *
1235  * Free's an external index table action record.
1236  *
1237  * NOTE:
1238  * Implementation of the internals of this function will be a stack with push
1239  * and pop.
1240  *
1241  * Returns success or failure code.
1242  */
1243 int tf_free_tbl_entry(struct tf *tfp,
1244                       struct tf_free_tbl_entry_parms *parms);
1245
1246 /**
1247  * tf_set_tbl_entry parameter definition
1248  */
1249 struct tf_set_tbl_entry_parms {
1250         /**
1251          * [in] Table scope identifier
1252          */
1253         uint32_t tbl_scope_id;
1254         /**
1255          * [in] Receive or transmit direction
1256          */
1257         enum tf_dir dir;
1258         /**
1259          * [in] Type of object to set
1260          */
1261         enum tf_tbl_type type;
1262         /**
1263          * [in] Entry data
1264          */
1265         uint8_t *data;
1266         /**
1267          * [in] Entry size
1268          */
1269         uint16_t data_sz_in_bytes;
1270         /**
1271          * [in] Entry index to write to
1272          */
1273         uint32_t idx;
1274 };
1275
1276 /**
1277  * set index table entry
1278  *
1279  * Used to insert an application programmed index table entry into a
1280  * previous allocated table location.  A shadow copy of the table
1281  * is maintained (if enabled) (only for internal objects)
1282  *
1283  * Returns success or failure code.
1284  */
1285 int tf_set_tbl_entry(struct tf *tfp,
1286                      struct tf_set_tbl_entry_parms *parms);
1287
1288 /**
1289  * tf_get_tbl_entry parameter definition
1290  */
1291 struct tf_get_tbl_entry_parms {
1292         /**
1293          * [in] Receive or transmit direction
1294          */
1295         enum tf_dir dir;
1296         /**
1297          * [in] Type of object to get
1298          */
1299         enum tf_tbl_type type;
1300         /**
1301          * [out] Entry data
1302          */
1303         uint8_t *data;
1304         /**
1305          * [in] Entry size
1306          */
1307         uint16_t data_sz_in_bytes;
1308         /**
1309          * [in] Entry index to read
1310          */
1311         uint32_t idx;
1312 };
1313
1314 /**
1315  * get index table entry
1316  *
1317  * Used to retrieve a previous set index table entry.
1318  *
1319  * Reads and compares with the shadow table copy (if enabled) (only
1320  * for internal objects).
1321  *
1322  * Returns success or failure code. Failure will be returned if the
1323  * provided data buffer is too small for the data type requested.
1324  */
1325 int tf_get_tbl_entry(struct tf *tfp,
1326                      struct tf_get_tbl_entry_parms *parms);
1327
1328 /**
1329  * tf_bulk_get_tbl_entry parameter definition
1330  */
1331 struct tf_bulk_get_tbl_entry_parms {
1332         /**
1333          * [in] Receive or transmit direction
1334          */
1335         enum tf_dir dir;
1336         /**
1337          * [in] Type of object to get
1338          */
1339         enum tf_tbl_type type;
1340         /**
1341          * [in] Starting index to read from
1342          */
1343         uint32_t starting_idx;
1344         /**
1345          * [in] Number of sequential entries
1346          */
1347         uint16_t num_entries;
1348         /**
1349          * [in] Size of the single entry
1350          */
1351         uint16_t entry_sz_in_bytes;
1352         /**
1353          * [out] Host physical address, where the data
1354          * will be copied to by the firmware.
1355          * Use tfp_calloc() API and mem_pa
1356          * variable of the tfp_calloc_parms
1357          * structure for the physical address.
1358          */
1359         uint64_t physical_mem_addr;
1360 };
1361
1362 /**
1363  * Bulk get index table entry
1364  *
1365  * Used to retrieve a previous set index table entry.
1366  *
1367  * Reads and compares with the shadow table copy (if enabled) (only
1368  * for internal objects).
1369  *
1370  * Returns success or failure code. Failure will be returned if the
1371  * provided data buffer is too small for the data type requested.
1372  */
1373 int tf_bulk_get_tbl_entry(struct tf *tfp,
1374                           struct tf_bulk_get_tbl_entry_parms *parms);
1375
1376 /**
1377  * @page exact_match Exact Match Table
1378  *
1379  * @ref tf_insert_em_entry
1380  *
1381  * @ref tf_delete_em_entry
1382  *
1383  * @ref tf_search_em_entry
1384  *
1385  */
1386 /**
1387  * tf_insert_em_entry parameter definition
1388  */
1389 struct tf_insert_em_entry_parms {
1390         /**
1391          * [in] receive or transmit direction
1392          */
1393         enum tf_dir dir;
1394         /**
1395          * [in] internal or external
1396          */
1397         enum tf_mem mem;
1398         /**
1399          * [in] ID of table scope to use (external only)
1400          */
1401         uint32_t tbl_scope_id;
1402         /**
1403          * [in] ID of table interface to use (SR2 only)
1404          */
1405         uint32_t tbl_if_id;
1406         /**
1407          * [in] ptr to structure containing key fields
1408          */
1409         uint8_t *key;
1410         /**
1411          * [in] key bit length
1412          */
1413         uint16_t key_sz_in_bits;
1414         /**
1415          * [in] ptr to structure containing result field
1416          */
1417         uint8_t *em_record;
1418         /**
1419          * [out] result size in bits
1420          */
1421         uint16_t em_record_sz_in_bits;
1422         /**
1423          * [in] duplicate check flag
1424          */
1425         uint8_t dup_check;
1426         /**
1427          * [out] Flow handle value for the inserted entry.  This is encoded
1428          * as the entries[4]:bucket[2]:hashId[1]:hash[14]
1429          */
1430         uint64_t flow_handle;
1431         /**
1432          * [out] Flow id is returned as null (internal)
1433          * Flow id is the GFID value for the inserted entry (external)
1434          * This is the value written to the BD and useful information for mark.
1435          */
1436         uint64_t flow_id;
1437 };
1438 /**
1439  * tf_delete_em_entry parameter definition
1440  */
1441 struct tf_delete_em_entry_parms {
1442         /**
1443          * [in] receive or transmit direction
1444          */
1445         enum tf_dir dir;
1446         /**
1447          * [in] internal or external
1448          */
1449         enum tf_mem mem;
1450         /**
1451          * [in] ID of table scope to use (external only)
1452          */
1453         uint32_t tbl_scope_id;
1454         /**
1455          * [in] ID of table interface to use (SR2 only)
1456          */
1457         uint32_t tbl_if_id;
1458         /**
1459          * [in] epoch group IDs of entry to delete
1460          * 2 element array with 2 ids. (SR2 only)
1461          */
1462         uint16_t *epochs;
1463         /**
1464          * [out] The index of the entry
1465          */
1466         uint16_t index;
1467         /**
1468          * [in] structure containing flow delete handle information
1469          */
1470         uint64_t flow_handle;
1471 };
1472 /**
1473  * tf_search_em_entry parameter definition
1474  */
1475 struct tf_search_em_entry_parms {
1476         /**
1477          * [in] receive or transmit direction
1478          */
1479         enum tf_dir dir;
1480         /**
1481          * [in] internal or external
1482          */
1483         enum tf_mem mem;
1484         /**
1485          * [in] ID of table scope to use (external only)
1486          */
1487         uint32_t tbl_scope_id;
1488         /**
1489          * [in] ID of table interface to use (SR2 only)
1490          */
1491         uint32_t tbl_if_id;
1492         /**
1493          * [in] ptr to structure containing key fields
1494          */
1495         uint8_t *key;
1496         /**
1497          * [in] key bit length
1498          */
1499         uint16_t key_sz_in_bits;
1500         /**
1501          * [in/out] ptr to structure containing EM record fields
1502          */
1503         uint8_t *em_record;
1504         /**
1505          * [out] result size in bits
1506          */
1507         uint16_t em_record_sz_in_bits;
1508         /**
1509          * [in] epoch group IDs of entry to lookup
1510          * 2 element array with 2 ids. (SR2 only)
1511          */
1512         uint16_t *epochs;
1513         /**
1514          * [in] ptr to structure containing flow delete handle
1515          */
1516         uint64_t flow_handle;
1517 };
1518
1519 /**
1520  * insert em hash entry in internal table memory
1521  *
1522  * Internal:
1523  *
1524  * This API inserts an exact match entry into internal EM table memory
1525  * of the specified direction.
1526  *
1527  * Note: The EM record is managed within the TruFlow core and not the
1528  * application.
1529  *
1530  * Shadow copy of internal record table an association with hash and 1,2, or 4
1531  * associated buckets
1532  *
1533  * External:
1534  * This API inserts an exact match entry into DRAM EM table memory of the
1535  * specified direction and table scope.
1536  *
1537  * When inserting an entry into an exact match table, the TruFlow library may
1538  * need to allocate a dynamic bucket for the entry (SR2 only).
1539  *
1540  * The insertion of duplicate entries in an EM table is not permitted.  If a
1541  * TruFlow application can guarantee that it will never insert duplicates, it
1542  * can disable duplicate checking by passing a zero value in the  dup_check
1543  * parameter to this API.  This will optimize performance. Otherwise, the
1544  * TruFlow library will enforce protection against inserting duplicate entries.
1545  *
1546  * Flow handle is defined in this document:
1547  *
1548  * https://docs.google.com
1549  * /document/d/1NESu7RpTN3jwxbokaPfYORQyChYRmJgs40wMIRe8_-Q/edit
1550  *
1551  * Returns success or busy code.
1552  *
1553  */
1554 int tf_insert_em_entry(struct tf *tfp,
1555                        struct tf_insert_em_entry_parms *parms);
1556
1557 /**
1558  * delete em hash entry table memory
1559  *
1560  * Internal:
1561  *
1562  * This API deletes an exact match entry from internal EM table memory of the
1563  * specified direction. If a valid flow ptr is passed in then that takes
1564  * precedence over the pointer to the complete key passed in.
1565  *
1566  *
1567  * External:
1568  *
1569  * This API deletes an exact match entry from EM table memory of the specified
1570  * direction and table scope. If a valid flow handle is passed in then that
1571  * takes precedence over the pointer to the complete key passed in.
1572  *
1573  * The TruFlow library may release a dynamic bucket when an entry is deleted.
1574  *
1575  *
1576  * Returns success or not found code
1577  *
1578  *
1579  */
1580 int tf_delete_em_entry(struct tf *tfp,
1581                        struct tf_delete_em_entry_parms *parms);
1582
1583 /**
1584  * search em hash entry table memory
1585  *
1586  * Internal:
1587
1588  * This API looks up an EM entry in table memory with the specified EM
1589  * key or flow (flow takes precedence) and direction.
1590  *
1591  * The status will be one of: success or entry not found.  If the lookup
1592  * succeeds, a pointer to the matching entry and the result record associated
1593  * with the matching entry will be provided.
1594  *
1595  * If flow_handle is set, search shadow copy.
1596  *
1597  * Otherwise, query the fw with key to get result.
1598  *
1599  * External:
1600  *
1601  * This API looks up an EM entry in table memory with the specified EM
1602  * key or flow_handle (flow takes precedence), direction and table scope.
1603  *
1604  * The status will be one of: success or entry not found.  If the lookup
1605  * succeeds, a pointer to the matching entry and the result record associated
1606  * with the matching entry will be provided.
1607  *
1608  * Returns success or not found code
1609  *
1610  */
1611 int tf_search_em_entry(struct tf *tfp,
1612                        struct tf_search_em_entry_parms *parms);
1613
1614 /**
1615  * @page if_tbl Interface Table Access
1616  *
1617  * @ref tf_set_if_tbl_entry
1618  *
1619  * @ref tf_get_if_tbl_entry
1620  *
1621  * @ref tf_restore_if_tbl_entry
1622  */
1623 /**
1624  * Enumeration of TruFlow interface table types.
1625  */
1626 enum tf_if_tbl_type {
1627         /** Default Profile L2 Context Entry */
1628         TF_IF_TBL_TYPE_PROF_SPIF_DFLT_L2_CTXT,
1629         /** Default Profile TCAM/Lookup Action Record Pointer Table */
1630         TF_IF_TBL_TYPE_PROF_PARIF_DFLT_ACT_REC_PTR,
1631         /** Error Profile TCAM Miss Action Record Pointer Table */
1632         TF_IF_TBL_TYPE_PROF_PARIF_ERR_ACT_REC_PTR,
1633         /** Default Error Profile TCAM Miss Action Record Pointer Table */
1634         TF_IF_TBL_TYPE_LKUP_PARIF_DFLT_ACT_REC_PTR,
1635         /** SR2 Ingress lookup table */
1636         TF_IF_TBL_TYPE_ILT,
1637         /** SR2 VNIC/SVIF Table */
1638         TF_IF_TBL_TYPE_VNIC_SVIF,
1639         TF_IF_TBL_TYPE_MAX
1640 };
1641
1642 /**
1643  * tf_set_if_tbl_entry parameter definition
1644  */
1645 struct tf_set_if_tbl_entry_parms {
1646         /**
1647          * [in] Receive or transmit direction
1648          */
1649         enum tf_dir dir;
1650         /**
1651          * [in] Type of object to set
1652          */
1653         enum tf_if_tbl_type type;
1654         /**
1655          * [in] Entry data
1656          */
1657         uint32_t *data;
1658         /**
1659          * [in] Entry size
1660          */
1661         uint16_t data_sz_in_bytes;
1662         /**
1663          * [in] Interface to write
1664          */
1665         uint32_t idx;
1666 };
1667
1668 /**
1669  * set interface table entry
1670  *
1671  * Used to set an interface table. This API is used for managing tables indexed
1672  * by SVIF/SPIF/PARIF interfaces. In current implementation only the value is
1673  * set.
1674  * Returns success or failure code.
1675  */
1676 int tf_set_if_tbl_entry(struct tf *tfp,
1677                         struct tf_set_if_tbl_entry_parms *parms);
1678
1679 /**
1680  * tf_get_if_tbl_entry parameter definition
1681  */
1682 struct tf_get_if_tbl_entry_parms {
1683         /**
1684          * [in] Receive or transmit direction
1685          */
1686         enum tf_dir dir;
1687         /**
1688          * [in] Type of table to get
1689          */
1690         enum tf_if_tbl_type type;
1691         /**
1692          * [out] Entry data
1693          */
1694         uint32_t *data;
1695         /**
1696          * [in] Entry size
1697          */
1698         uint16_t data_sz_in_bytes;
1699         /**
1700          * [in] Entry index to read
1701          */
1702         uint32_t idx;
1703 };
1704
1705 /**
1706  * get interface table entry
1707  *
1708  * Used to retrieve an interface table entry.
1709  *
1710  * Reads the interface table entry value
1711  *
1712  * Returns success or failure code. Failure will be returned if the
1713  * provided data buffer is too small for the data type requested.
1714  */
1715 int tf_get_if_tbl_entry(struct tf *tfp,
1716                         struct tf_get_if_tbl_entry_parms *parms);
1717
1718 #endif /* _TF_CORE_H_ */