xref: /dpdk/drivers/net/bnxt/tf_core/v3/tfc.h (revision ca827d42ad72f90d045716e688b539e53e31a7cc)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2022 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _TFC_H_
7 #define _TFC_H_
8 
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include "cfa_resources.h"
12 #include "cfa_types.h"
13 
14 /**
15  * @file
16  *
17  * @brief TFC (Truflow Core v3) API Header File
18  *
19  * @page TFCV3 Truflow Core v3
20  *
21  * These pages describe the APIs for Truflow Core v3.
22  *
23  * - @subpage Init
24  * - @subpage Resources
25  * - @subpage Session
26  * - @subpage GID
27  * - @subpage Identifiers
28  * - @subpage GIM
29  * - @subpage TCAM
30  * - @subpage TBM
31  * - @subpage EM
32  * - @subpage ACTCFA
33  * - @subpage TFCOV3
34  */
35 
36 /********** BEGIN Truflow Core v3 DEFINITIONS **********/
37 /* @cond temporary */
38 #define TFC_V3_RESOURCE_API_ENABLE 0
39 /* @endcond */
40 
41 /**
42  * TFC handle
43  */
44 struct tfc {
45 	/**
46 	 * Pointer to the private tfc object
47 	 */
48 	void *tfo;
49 	/**
50 	 * the pointer to the parent bp struct
51 	 */
52 	void *bp;
53 };
54 
55 /* API Guidance:
56  *
57  * 1.  If more than 5-6 parameters, please define structures
58  *
59  * 2.  Design structures that can be used with multiple APIs
60  *
61  * 3.  If items in structures are not to be used, these must
62  *     be documented in the API header IN DETAIL.
63  *
64  * 4.  Use defines in cfa_types.h where possible. These are shared
65  *     firmware types to avoid duplication. These types do
66  *     not represent the HWRM interface and may need to be mapped
67  *     to HWRM definitions.
68  *
69  * 5.  Resource types and subtypes are defined in cfa_resources.h
70  */
71 
72 /********** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **********/
73 /**
74  * @page Init Initialization and De-initialization APIs
75  *
76  * @ref tfc_open
77  *
78  * @ref tfc_close
79  */
80 /**
81  * Allocate the TFC state for this DPDK port/function. The TF
82  * object memory is allocated during this API call.
83  *
84  * @param[in] tfcp
85  *   Pointer to TFC handle
86  *
87  * @return
88  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
89  *
90  * @note This API will initialize only the software state.
91  */
92 int tfc_open(struct tfc *tfcp);
93 
94 /**
95  * De-allocate the TFC state for this DPDK port/function. The TF
96  * object memory is deallocated during this API call.
97  *
98  * @param[in] tfcp
99  *   Pointer to TFC handle
100  *
101  * @return
102  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
103  *
104  * @note This API will reset only the software state.
105  */
106 int tfc_close(struct tfc *tfcp);
107 
108 /**
109  * @page Resources
110  *
111  * @ref tfc_resource_types_query
112  */
113 
114 /**
115  * The maximum number of foreseeable resource types.
116  * Use cfa_resource_types enum internally.
117  */
118 #define TFC_MAX_RESOURCE_TYPES 32
119 
120 /**
121  * Supported resource information
122  */
123 struct tfc_resources {
124 	/** Resource subtype mask of valid resource types */
125 	uint32_t rtypes_mask;
126 	/** Maximum resource type number */
127 	uint8_t max_rtype;
128 	/** Array indexed by resource type indicating valid subtypes */
129 	uint32_t rsubtypes_mask[TFC_MAX_RESOURCE_TYPES];
130 };
131 
132 /**
133  * Get all supported CFA resource types for the device
134  *
135  * This API goes to the firmware to query all supported resource
136  * types and subtypes supported.
137  *
138  * @param[in] tfcp
139  *   Pointer to TFC handle
140  *
141  * @param[in,out] resources
142  *   Pointer to a structure containing information about the supported CFA device
143  *   resources.
144  *
145  * @return
146  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
147  */
148 int tfc_resource_types_query(struct tfc *tfcp, struct tfc_resources *resources);
149 
150 /**
151  * @page Session
152  *
153  * @ref tfc_session_id_alloc
154  *
155  * @ref tfc_session_fid_add
156  *
157  * @ref tfc_session_fid_rem
158  */
159 
160 /**
161  * Allocate a TFC session
162  *
163  * This API goes to the firmware to allocate a TFC session id and associate a
164  * forwarding function with the session.
165  *
166  * @param[in] tfcp
167  *   Pointer to TFC handle
168  *
169 - * @param[in] fid
170 - *   Function id to associated with the session
171 - *
172  * @param[out] sid
173  *   Pointer to the where the session id will be returned
174  *
175  * @return
176  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
177  */
178 int tfc_session_id_alloc(struct tfc *tfcp, uint16_t fid, uint16_t *sid);
179 
180 /**
181  * Associate a forwarding function with an existing TFC session
182  *
183  * @param[in] tfcp
184  *   Pointer to TFC handle
185  *
186  * @param[in] fid
187  *   Function id to associated with the session
188  *
189  * @param[in] sid
190  *   The session id to associate with
191  *
192  * @param[in,out] fid_cnt
193  *   The number of forwarding functions currently associated with the session
194  *
195  * @return
196  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
197  */
198 int tfc_session_fid_add(struct tfc *tfcp, uint16_t fid, uint16_t sid,
199 			uint16_t *fid_cnt);
200 /**
201  * Disassociate a forwarding function from an existing TFC session
202  *
203  * Once the last function has been removed from the session in the firmware
204  * the session is freed and all associated resources freed.
205  *
206  * @param[in] tfcp
207  *   Pointer to TFC handle
208  *
209  * @param[in] fid
210  *   Function id to associated with the session
211  *
212  * @param[in,out] fid_cnt
213  *   The number of forwarding functions currently associated with the session
214  *
215  * @returns
216  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
217  */
218 int tfc_session_fid_rem(struct tfc *tfcp, uint16_t fid, uint16_t *fid_cnt);
219 
220 /**
221  * @page GID Global Identifier
222  *
223  * @ref tfc_global_id_alloc
224  */
225 
226 /** Domain id range
227  */
228 enum tfc_domain_id {
229 	TFC_DOMAIN_ID_INVALID = 0,
230 	TFC_DOMAIN_ID_1,
231 	TFC_DOMAIN_ID_2,
232 	TFC_DOMAIN_ID_3,
233 	TFC_DOMAIN_ID_4,
234 	TFC_DOMAIN_ID_MAX = TFC_DOMAIN_ID_4
235 };
236 
237 /** Global id request definition
238  */
239 struct tfc_global_id_req {
240 	enum cfa_resource_type rtype; /**< Resource type */
241 	uint8_t rsubtype; /**< Resource subtype */
242 	enum cfa_dir dir; /**< Direction */
243 	uint16_t cnt; /**< Number of resources to allocate of this type */
244 };
245 
246 /** Global id resource definition
247  */
248 struct tfc_global_id {
249 	enum cfa_resource_type rtype; /**< Resource type */
250 	uint8_t rsubtype; /**< Resource subtype */
251 	enum cfa_dir dir; /**< Direction */
252 	uint16_t id; /**< Resource id */
253 };
254 
255 /**
256  * Allocate global TFC resources
257  *
258  * Some resources are not owned by a single session.  They are "global" in that
259  * they will be in use as long as any associated session exists.  Once all
260  * sessions/functions have been removed, all associated global ids are freed.
261  * There are currently up to 4 global id domain sets.
262  *
263  * TODO: REDUCE PARAMETERS WHEN IMPLEMENTING API
264  *
265  * @param[in] tfcp
266  *   Pointer to TFC handle
267  *
268  * @param[in] fid
269  *   FID - Function ID to be used
270  *
271  * @param[in] domain_id
272  *   The domain id to associate.
273  *
274  * @param[in] req_cnt
275  *   The number of total resource requests
276  *
277  * @param[in] glb_id_req
278  *   The list of global id requests
279  *
280  * @param[in,out] rsp_cnt
281  *   The number of items in the response buffer
282  *
283  * @param[out] glb_id_rsp
284  *   The number of items in the response buffer
285  *
286  * @param[in,out] first
287  *   This is the first domain request for the indicated domain id.
288  *
289  * @returns
290  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
291  */
292 int tfc_global_id_alloc(struct tfc *tfcp, uint16_t fid, enum tfc_domain_id domain_id,
293 			uint16_t req_cnt, const struct tfc_global_id_req *glb_id_req,
294 			struct tfc_global_id *glb_id_rsp, uint16_t *rsp_cnt,
295 			bool *first);
296 /**
297  * @page Identifiers
298  *
299  * @ref tfc_identifier_alloc
300  *
301  * @ref tfc_identifier_free
302  */
303 
304 /**
305  * Identifier resource structure
306  */
307 struct tfc_identifier_info {
308 	enum cfa_resource_subtype_ident rsubtype; /**< resource subtype */
309 	enum cfa_dir dir; /**< direction rx/tx */
310 	uint16_t id; /**< alloc/free index */
311 };
312 
313 /**
314  * allocate a TFC Identifier
315  *
316  * @param[in] tfcp
317  *   Pointer to TFC handle
318  *
319  * @param[in] fid
320  *   FID - Function ID to be used
321  *
322  * @param[in] tt
323  *   Track type - either track by session or by function
324  *
325  * @param[in, out] ident_info
326  *   All the information related to the requested identifier (subtype/dir) and
327  *   the returned identifier id.
328  *
329  * @returns
330  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
331  */
332 int tfc_identifier_alloc(struct tfc *tfcp, uint16_t fid,
333 			 enum cfa_track_type tt,
334 			 struct tfc_identifier_info *ident_info);
335 
336 /**
337  * free a TFC Identifier
338  *
339  * @param[in] tfcp
340  *   Pointer to TFC handle
341  *
342  * @param[in] fid
343  *   FID - Function ID to be used
344  *
345  * @param[in] ident_info
346  *   All the information related to the requested identifier (subtype/dir) and
347  *   the identifier id to free.
348  *
349  * @returns success or failure code.
350  */
351 int tfc_identifier_free(struct tfc *tfcp, uint16_t fid,
352 			const struct tfc_identifier_info *ident_info);
353 
354 /**
355  * @page GIM Index Table
356  *
357  * @ref tfc_idx_tbl_alloc
358  *
359  * @ref tfc_idx_tbl_alloc_set
360  *
361  * @ref tfc_idx_tbl_set
362  *
363  * @ref tfc_idx_tbl_get
364  *
365  * @ref tfc_idx_tbl_free
366  */
367 
368 /**
369  * Index table resource structure
370  */
371 struct tfc_idx_tbl_info {
372 	enum cfa_resource_subtype_idx_tbl rsubtype; /**< resource subtype */
373 	enum cfa_dir dir; /**< direction rx/tx */
374 	uint16_t id; /**< alloc/free index */
375 };
376 
377 /**
378  * allocate a TFC index table entry
379  *
380  * @param[in] tfcp
381  *   Pointer to TFC handle
382  *
383  * @param[in] fid
384  *   FID - Function ID to be used
385  *
386  * @param[in] tt
387  *   Track type - either track by session or by function
388  *
389  * @param[in,out] tbl_info
390  *   All the information related to the requested index table entry (subtype/dir)
391  *   and the returned id.
392  *
393  * @returns
394  *	 0 for SUCCESS, negative error value for FAILURE (errno.h)
395  */
396 int tfc_idx_tbl_alloc(struct tfc *tfcp, uint16_t fid,
397 		      enum cfa_track_type tt,
398 		      struct tfc_idx_tbl_info *tbl_info);
399 
400 /**
401  * allocate and set a TFC index table entry
402  *
403  * @param[in] tfcp
404  *   Pointer to TFC handle
405  *
406  * @param[in] fid
407  *   FID - Function ID to be used
408  *
409  * @param[in] tt
410  *   Track type - either track by session or by function
411  *
412  * @param[in,out] tbl_info
413  *   All the information related to the requested index table entry (subtype/dir)
414  *   and the returned id.
415  *
416  * @param[in] data
417  *   Pointer to the data to write to the entry.	The data is aligned correctly
418  *   in the buffer for writing to the hardware.
419  *
420  * @param[in] data_sz_in_bytes
421  *   The size of the entry in bytes for Thor2.
422  *
423  * @returns
424  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
425  */
426 int tfc_idx_tbl_alloc_set(struct tfc *tfcp, uint16_t fid,
427 			  enum cfa_track_type tt,
428 			  struct tfc_idx_tbl_info *tbl_info,
429 			  const uint32_t *data, uint8_t data_sz_in_bytes);
430 
431 /**
432  * Set a TFC index table entry
433  *
434  * @param[in] tfcp
435  *   Pointer to TFC handle
436  *
437  * @param[in] fid
438  *   FID - Function ID to be used
439  *
440  * @param[in] tbl_info
441  *   All the information related to the requested index table entry (subtype/dir)
442  *   including the id.
443  *
444  * @param[in] data
445  *   Pointer to the data to write to the entry.	The data is aligned correctly
446  *   in the buffer for writing to the hardware.
447  *
448  * @param[in] data_sz_in_bytes
449  *   The size of the entry in device sized bytes for Thor2.
450  *
451  * @returns
452  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
453  */
454 int tfc_idx_tbl_set(struct tfc *tfcp, uint16_t fid,
455 		    const struct tfc_idx_tbl_info *tbl_info,
456 		    const uint32_t *data, uint8_t data_sz_in_bytes);
457 
458 /**
459  * Get a TFC index table entry
460  *
461  * @param[in] tfcp
462  *   Pointer to TFC handle
463  *
464  * @param[in] fid
465  *   FID - Function ID to be used
466  *
467  * @param[in] tbl_info
468  *   All the information related to the requested index table entry (subtype/dir)
469  *   including the id.
470  *
471  * @param[in, out] data
472  *   Pointer to the data to read from the entry.
473  *
474  * @param[in,out] data_sz_in_bytes
475  *   The size of the entry in device sized bytes for Thor2. Input is the
476  *   size of the buffer, output is the actual size.
477  *
478  * @returns
479  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
480  */
481 int tfc_idx_tbl_get(struct tfc *tfcp, uint16_t fid,
482 		    const struct tfc_idx_tbl_info *tbl_info,
483 		    uint32_t *data, uint8_t *data_sz_in_bytes);
484 /**
485  * Free a TFC index table entry
486  *
487  * @param[in] tfcp
488  *   Pointer to TFC handle
489  *
490  * @param[in] fid
491  *   FID - Function ID to be used
492  *
493  * @param[in] tbl_info
494  *   All the information related to the requested index table entry (subtype/dir)
495  *   and the returned id.
496  *
497  * @returns
498  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
499  */
500 int tfc_idx_tbl_free(struct tfc *tfcp, uint16_t fid,
501 		     const struct tfc_idx_tbl_info *tbl_info);
502 
503 /**
504  * @page TCAM
505  *
506  * @ref tfc_tcam_alloc
507  *
508  * @ref tfc_tcam_alloc_set
509  *
510  * @ref tfc_tcam_set
511  *
512  * @ref tfc_tcam_get
513  *
514  * @ref tfc_tcam_free
515  */
516 /**
517  * Tcam table info structure
518  */
519 struct tfc_tcam_info {
520 	enum cfa_resource_subtype_tcam rsubtype; /**< resource subtype */
521 	enum cfa_dir dir; /**< direction rx/tx */
522 	uint16_t id; /**< alloc/free index */
523 };
524 
525 /**
526  * Tcam table resource structure
527  */
528 struct tfc_tcam_data {
529 	uint8_t *key; /**< tcam key */
530 	uint8_t *mask; /**< tcam mask */
531 	uint8_t *remap; /**< remap */
532 	uint8_t key_sz_in_bytes; /**< key size in bytes */
533 	uint8_t remap_sz_in_bytes; /**< remap size in bytes */
534 
535 };
536 
537 /**
538  * allocate a TFC TCAM entry
539  *
540  * @param[in] tfcp
541  *   Pointer to TFC handle
542  *
543  * @param[in] fid
544  *   FID - Function ID to be used
545  *
546  * @param[in] tt
547  *   Track type - either track by session or by function
548  *
549  * @param[in] priority
550  *   Priority - the priority of the tcam entry
551  *
552  * @param[in,out] tcam_info
553  *   All the information related to the requested index table entry (subtype/dir)
554  *   and the returned id.
555  *
556  * @param[in] key_sz_in_bytes
557  *   The size of the entry in bytes for Thor2.
558  *
559  * @returns
560  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
561  */
562 int tfc_tcam_alloc(struct tfc *tfcp, uint16_t fid,
563 		   enum cfa_track_type tt, uint16_t priority,
564 		   uint8_t key_sz_in_bytes,
565 		   struct tfc_tcam_info *tcam_info);
566 
567 /**
568  * allocate and set a TFC TCAM entry
569  *
570  * @param[in] tfcp
571  *   Pointer to TFC handle
572  *
573  * @param[in] tt
574  *   Track type - either track by session or by function
575  *
576  * @param[in] fid
577  *   FID - Function ID to be used
578  *
579  * @param[in] priority
580  *   Priority - the priority of the tcam entry
581  *
582  * @param[in,out] tcam_info
583  *   All the information related to the requested TCAM table entry (subtype/dir)
584  *   and the returned id.
585  *
586  * @param[in] tcam_data
587  *  Pointer to the tcam data, including tcam, mask, and remap,  to write to
588  *  the entry.  The data is aligned in the buffer for writing to the hardware.
589  *
590  * @returns
591  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
592  */
593 int tfc_tcam_alloc_set(struct tfc *tfcp, uint16_t fid,
594 		       enum cfa_track_type tt, uint16_t priority,
595 		       struct tfc_tcam_info *tcam_info,
596 		       const struct tfc_tcam_data *tcam_data);
597 
598 /**
599  * Set a TFC TCAM entry
600  *
601  * @param[in] tfcp
602  *   Pointer to TFC handle
603  *
604  * @param[in] fid
605  *   FID - Function ID to be used
606  *
607  * @param[in, out] tcam_info
608  *   All the information related to the requested index table entry (subtype/dir)
609  *   including the id.
610  *
611  * @param[in] tcam_data
612  *  Pointer to the tcam data, including tcam, mask, and remap,  to write to
613  *  the entry.  The data is aligned in the buffer for writing to the hardware.
614  *
615  * @returns
616  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
617  */
618 int tfc_tcam_set(struct tfc *tfcp, uint16_t fid,
619 		 const struct tfc_tcam_info *tcam_info,
620 		 const struct tfc_tcam_data *tcam_data);
621 
622 /**
623  * Get a TFC TCAM entry
624  *
625  * @param[in] tfcp
626  *   Pointer to TFC handle
627  *
628  * @param[in] fid
629  *   FID - Function ID to be used
630  *
631  * @param[in] tcam_info
632  *   All the information related to the requested TCAM entry (subtype/dir)
633  *   including the id.
634  *
635  * @param[in, out] tcam_data
636  *  Pointer to the tcam data, including tcam, mask, and remap,  to read from
637  *  the entry.  The data is aligned in the buffer for writing to the hardware.
638  *
639  * @returns
640  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
641  */
642 int tfc_tcam_get(struct tfc *tfcp, uint16_t fid,
643 		 const struct tfc_tcam_info *tcam_info,
644 		 struct tfc_tcam_data *tcam_data);
645 /**
646  * Free a TFC TCAM entry
647  *
648  * @param[in] tfcp
649  *   Pointer to TFC handle
650  *
651  * @param[in] fid
652  *   FID - Function ID to be used
653  *
654  * @param[in] tcam_info
655  *   All the information related to the requested tcam entry (subtype/dir)
656  *   and the id to be freed.
657  *
658  * @returns
659  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
660  */
661 int tfc_tcam_free(struct tfc *tfcp, uint16_t fid,
662 		  const struct tfc_tcam_info *tcam_info);
663 
664 /**
665  * @page TBM Table Scope
666  *
667  * @ref tfc_tbl_scope_qcaps
668  *
669  * @ref tfc_tbl_scope_size_query
670  *
671  * @ref tfc_tbl_scope_id_alloc
672  *
673  * @ref tfc_tbl_scope_mem_alloc
674  *
675  * @ref tfc_tbl_scope_mem_free
676  *
677  * @ref tfc_tbl_scope_cpm_alloc
678  *
679  * @ref tfc_tbl_scope_cpm_free
680  *
681  * @ref tfc_tbl_scope_fid_add
682  *
683  * @ref tfc_tbl_scope_fid_rem
684  *
685  * @ref tfc_tbl_scope_config_state_get
686  *
687  * tfc_tbl_scope_pfid_query (FUTURE shared table scope)
688  *
689  * tfc_tbl_scope_config_get (FUTURE shared table scope)
690  *
691  */
692 
693 /**
694  * tfc_tbl_scope_bucket_factor indicates a multiplier factor for determining the
695  * static and dynamic buckets counts.  The larger the factor, the more buckets
696  * will be allocated.
697  *
698  * This is necessary because flows will not hash so as to perfectly fill all the
699  * buckets.  It is necessary to add some allowance for not fully populated
700  * buckets.
701  */
702 enum tfc_tbl_scope_bucket_factor {
703 	TFC_TBL_SCOPE_BUCKET_FACTOR_1 = 1,
704 	TFC_TBL_SCOPE_BUCKET_FACTOR_2 = 2,
705 	TFC_TBL_SCOPE_BUCKET_FACTOR_4 = 4,
706 	TFC_TBL_SCOPE_BUCKET_FACTOR_8 = 8,
707 	TFC_TBL_SCOPE_BUCKET_FACTOR_16 = 16,
708 	TFC_TBL_SCOPE_BUCKET_FACTOR_32 = 32,
709 	TFC_TBL_SCOPE_BUCKET_FACTOR_64 = 64,
710 	TFC_TBL_SCOPE_BUCKET_FACTOR_MAX = TFC_TBL_SCOPE_BUCKET_FACTOR_64
711 };
712 
713 /**
714  * tfc_tbl_scope_size_query_parms contains the parameters for the
715  * tfc_tbl_scope_size_query API.
716  */
717 struct tfc_tbl_scope_size_query_parms {
718 	/**
719 	 * [in] If a shared table scope, dynamic buckets are disabled. This
720 	 * affects the calculation for static buckets in this function.
721 	 * Initially, if not shared, the size of the static bucket table should
722 	 * be double the number of flows supported. Numbers are validated
723 	 * against static_cnt and dynamic_cnt
724 	 */
725 	bool shared;
726 	/**
727 	 * [in] Direction indexed array indicating the number of flows.  Must be
728 	 * at least as large as the number entries that the buckets can point
729 	 * to.
730 	 */
731 	uint32_t flow_cnt[CFA_DIR_MAX];
732 	/**
733 	 * [in] tfc_tbl_scope_bucket_factor indicates a multiplier factor for
734 	 * determining the static and dynamic buckets counts.  The larger the
735 	 * factor, the more buckets will be allocated.
736 	 */
737 	enum tfc_tbl_scope_bucket_factor factor;
738 	/**
739 	 * [in] The number of pools each region of the table scope will be
740 	 * divided into.
741 	 */
742 	uint32_t max_pools;
743 	/**
744 	 * [in] Direction indexed array indicating the key size.
745 	 */
746 	uint16_t key_sz_in_bytes[CFA_DIR_MAX];
747 	/**
748 	 * [in] Direction indexed array indicating the action record size.  Must
749 	 * be a multiple of 32B lines on Thor2.
750 	 */
751 	uint16_t act_rec_sz_in_bytes[CFA_DIR_MAX];
752 	/**
753 	 * [out] Direction indexed array indicating the EM static bucket count
754 	 * expressed as: log2(static_bucket_count). For example if 1024 static
755 	 * buckets, 1024=2^10, so the value 10 would be returned.
756 	 */
757 	uint8_t static_bucket_cnt_exp[CFA_DIR_MAX];
758 	/**
759 	 * [out] Direction indexed array indicating the EM dynamic bucket count.
760 	 */
761 	uint32_t dynamic_bucket_cnt[CFA_DIR_MAX];
762 	/**
763 	 * [out] The number of minimum sized lkup records per direction.  In
764 	 * this usage, records are the minimum lookup memory allocation unit in
765 	 * a table scope.  This value is the total memory required for buckets
766 	 * and entries.
767 	 *
768 	 * Note: The EAS variously refers to these as words or cache-lines.
769 	 *
770 	 * For example, on Thor2 where each bucket consumes one record, if the
771 	 * key size is such that the LREC and key use 2 records, then the
772 	 * lkup_rec_cnt = the number of buckets + (2 * the number of flows).
773 	 */
774 	uint32_t lkup_rec_cnt[CFA_DIR_MAX];
775 	/**
776 	 * [out] The number of minimum sized action records per direction.
777 	 * Similar to the lkup_rec_cnt, records are the minimum action memory
778 	 * allocation unit in a table scope.
779 	 */
780 	uint32_t act_rec_cnt[CFA_DIR_MAX];
781 	/**
782 	 * [out] Direction indexed array indicating the size of each individual
783 	 * lookup record pool expressed as: log2(max_records/max_pools). For
784 	 * example if 1024 records and 2 pools 1024/2=512=2^9, so the value 9
785 	 * would be entered.
786 	 */
787 	uint8_t lkup_pool_sz_exp[CFA_DIR_MAX];
788 	/**
789 	 * [out] Direction indexed array indicating the size of each individual
790 	 * action record pool expressed as: log2(max_records/max_pools). For
791 	 * example if 1024 records and 2 pools 1024/2=512=2^9, so the value 9
792 	 * would be entered.
793 	 */
794 	uint8_t act_pool_sz_exp[CFA_DIR_MAX];
795 	/**
796 	 * [out] Direction indexed array indicating the offset in records from
797 	 * the start of the memory after the static buckets where the first
798 	 * lrec pool begins.
799 	 */
800 	uint32_t lkup_rec_start_offset[CFA_DIR_MAX];
801 };
802 
803 /**
804  * tfc_tbl_scope_mem_alloc_parms contains the parameters for allocating memory
805  * to be used by a table scope.
806  */
807 struct tfc_tbl_scope_mem_alloc_parms {
808 	/**
809 	 * [in] If a shared table scope, indicate whether this is the first
810 	 * if, the first, the table scope memory will be allocated.  Otherwise
811 	 * only the details of the configuration will be stored internally
812 	 * for use - i.e. act_rec_cnt/lkup_rec_cnt/lkup_rec_start_offset.
813 	 */
814 	bool first;
815 	/**
816 	 * [in] Direction indexed array indicating the EM static bucket count
817 	 * expressed as: log2(static_bucket_count). For example if 1024 static
818 	 * buckets, 1024=2^10, so the value 10 would be entered.
819 	 */
820 	uint8_t static_bucket_cnt_exp[CFA_DIR_MAX];
821 	/**
822 	 * [in] Direction indexed array indicating the EM dynamic bucket count.
823 	 */
824 	uint8_t dynamic_bucket_cnt[CFA_DIR_MAX];
825 	/**
826 	 * [in] The number of minimum sized lkup records per direction.	In this
827 	 * usage, records are the minimum lookup memory allocation unit in a
828 	 * table scope.	 This value is the total memory required for buckets and
829 	 * entries.
830 	 */
831 	uint32_t lkup_rec_cnt[CFA_DIR_MAX];
832 	/**
833 	 * [in] The number of minimum sized action records per direction.
834 	 * Similar to the lkup_rec_cnt, records are the minimum action memory
835 	 * allocation unit in a table scope.
836 	 */
837 	uint32_t act_rec_cnt[CFA_DIR_MAX];
838 	/**
839 	 * [in] The page size used for allocation. If running in the kernel
840 	 * driver, this may be as small as 1KB.	 For huge pages this may be more
841 	 * commonly 2MB.  Supported values include 4K, 8K, 64K, 2M, 8M and 1GB.
842 	 */
843 	uint32_t pbl_page_sz_in_bytes;
844 	/**
845 	 * [in] Indicates local application vs remote application table scope. A
846 	 * table scope can be created on a PF for it's own use or for use by
847 	 * other children.  These may or may not be shared table scopes.  Set
848 	 * local to false if calling API on behalf of a remote client VF.
849 	 * (alternatively, we could pass in the remote fid or the local fid).
850 	 */
851 	bool local;
852 	/**
853 	 * [in] The maximum number of pools supported.
854 	 */
855 	uint8_t max_pools;
856 	/**
857 	 * [in] Direction indexed array indicating the action table pool size
858 	 * expressed as: log2(act_pool_sz). For example if 1024 static
859 	 * buckets, 1024=2^10, so the value 10 would be entered.
860 	 */
861 	uint8_t act_pool_sz_exp[CFA_DIR_MAX];
862 	/**
863 	 * [in] Direction indexed array indicating the lookup table pool size
864 	 * expressed as: log2(lkup_pool_sz). For example if 1024 static
865 	 * buckets, 1024=2^10, so the value 10 would be entered.
866 	 */
867 	uint8_t lkup_pool_sz_exp[CFA_DIR_MAX];
868 	/**
869 	 * [in] Lookup table record start offset.  Offset in 32B records after
870 	 * the static buckets where the lookup records and dynamic bucket memory
871 	 * will begin.
872 	 */
873 	uint32_t lkup_rec_start_offset[CFA_DIR_MAX];
874 };
875 
876 /**
877  * Determine whether table scopes are supported in the hardware.
878  *
879  * @param[in] tfcp
880  *   Pointer to TFC handle
881  *
882  * @param[out] tbl_scope_capable
883  *   True if table scopes are supported in the firmware.
884  *
885  * @param[out] max_lkup_rec_cnt
886  *   The maximum number of lookup records in a table scope (optional)
887  *
888  * @param[out] max_act_rec_cnt
889  *   The maximum number of action records in a table scope (optional)
890  *
891  * @param[out] max_lkup_static_buckets_exp
892  *   The log2 of the maximum number of lookup static buckets in a table scope
893  *   (optional)
894  *
895  * @returns
896  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
897  */
898 int tfc_tbl_scope_qcaps(struct tfc *tfcp, bool *tbl_scope_capable,
899 			uint32_t *max_lkup_rec_cnt,
900 			uint32_t *max_act_rec_cnt,
901 			uint8_t	*max_lkup_static_buckets_exp);
902 
903 /**
904  * Determine table scope sizing
905  *
906  * @param[in] tfcp
907  *   Pointer to TFC handle
908  *
909  * @param[in,out] parms
910  *   The parameters used by this function.
911  *
912  * @returns
913  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
914  */
915 int tfc_tbl_scope_size_query(struct tfc *tfcp,
916 			     struct tfc_tbl_scope_size_query_parms *parms);
917 
918 /**
919  * Allocate a table scope
920  *
921  * @param[in] tfcp
922  *   Pointer to TFC handle
923  *
924  * @param[in] shared
925  *   Create a shared table scope.
926  *
927  * @param[in] app_type
928  *   The application type, TF or AFM
929  *
930  * @param[out] tsid
931  *   The allocated table scope ID.
932  *
933  * @param[in,out] first
934  *   True if the caller is the creator of this table scope.
935  *   If not shared, first is always set. (optional)
936  *
937  * @returns
938  *	 0 for SUCCESS, negative error value for FAILURE (errno.h)
939  */
940 int tfc_tbl_scope_id_alloc(struct tfc *tfcp, bool shared,
941 			   enum cfa_app_type app_type, uint8_t *tsid,
942 			   bool *first);
943 
944 /**
945  * Allocate memory for a table scope
946  *
947  * @param[in] tfcp
948  *   Pointer to TFC handle
949  *
950  * @param[in] tsid
951  *   Table scope identifier
952  *
953  * @param[in] fid
954  *   Function id requesting the memory allocation
955  *
956  * @param[in] parms
957  *   Memory allocation parameters
958  *
959  * @returns
960  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
961  */
962 int tfc_tbl_scope_mem_alloc(struct tfc *tfcp, uint16_t fid, uint8_t tsid,
963 			    struct tfc_tbl_scope_mem_alloc_parms *parms);
964 
965 /**
966  * Free memory for a table scope
967  *
968  * @param[in] tfcp
969  *   Pointer to TFC handle
970  *
971  * @param[in] fid
972  *   Function id for memory to free from the table scope. Set to INVALID_FID
973  *   by default. Populated when VF2PF mem_free message received from a VF
974  *   for a shared table scope.
975  *
976  * @param[in] tsid
977  *   Table scope identifier
978  *
979  * @returns
980  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
981  */
982 int tfc_tbl_scope_mem_free(struct tfc *tfcp, uint16_t fid, uint8_t tsid);
983 
984 /**
985  * tfc_tbl_scope_cpm_alloc_parms contains the parameters for allocating a
986  * CPM instance to be used by a table scope.
987  */
988 struct tfc_tbl_scope_cpm_alloc_parms {
989 	/**
990 	 * [in] Direction indexed array indicating the maximum number of lookup
991 	 * contiguous records.
992 	 */
993 	uint8_t lkup_max_contig_rec[CFA_DIR_MAX];
994 	/**
995 	 * [in] Direction indexed array indicating the maximum number of action
996 	 * contiguous records.
997 	 */
998 	uint8_t act_max_contig_rec[CFA_DIR_MAX];
999 	/**
1000 	 * [in] The maximum number of pools supported by the table scope.
1001 	 */
1002 	uint16_t max_pools;
1003 };
1004 /**
1005  * Allocate CFA Pool Manager (CPM) Instance
1006  *
1007  * @param[in] tfcp
1008  *   Pointer to TFC handle
1009  *
1010  * @param[in] cpm_parms
1011  *   Pointer to the CFA Pool Manager parameters
1012  *
1013  * @param[in] tsid
1014  *   Table scope identifier
1015  *
1016  * @returns
1017  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1018  */
1019 int tfc_tbl_scope_cpm_alloc(struct tfc *tfcp, uint8_t tsid,
1020 			    struct tfc_tbl_scope_cpm_alloc_parms *cpm_parms);
1021 
1022 /**
1023  * Free CPM Instance
1024  *
1025  * @param[in] tfcp
1026  *   Pointer to TFC handle
1027  *
1028  * @param[in] tsid
1029  *   Table scope identifier
1030  *
1031  * @returns
1032  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1033  */
1034 int tfc_tbl_scope_cpm_free(struct tfc *tfcp, uint8_t tsid);
1035 
1036 /**
1037  * Associate a forwarding function with an existing table scope
1038  *
1039  * @param[in] tfcp
1040  *   Pointer to TFC handle
1041  *
1042  * @param[in] fid
1043  *   Function id to associated with the table scope
1044  *
1045  * @param[in] tsid
1046  *   Table scope identifier
1047  *
1048  * @param[in,out] fid_cnt
1049  *   The number of forwarding functions currently associated with the table scope
1050  *
1051  * @return
1052  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1053  */
1054 int tfc_tbl_scope_fid_add(struct tfc *tfcp, uint16_t fid, uint8_t tsid,
1055 			  uint16_t *fid_cnt);
1056 
1057 /**
1058  * Disassociate a forwarding function from an existing TFC table scope
1059  *
1060  * Once the last function has been removed from the session in the firmware
1061  * the session is freed and all associated resources freed.
1062  *
1063  * @param[in] tfcp
1064  *   Pointer to TFC handle
1065  *
1066  * @param[in] fid
1067  *   Function id to associated with the table scope
1068  *
1069  * @param[in] tsid
1070  *   Table scope identifier
1071  *
1072  * @param[in,out] fid_cnt
1073  *   The number of forwarding functions currently associated with the session
1074  *
1075  * @returns
1076  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1077  */
1078 int tfc_tbl_scope_fid_rem(struct tfc *tfcp, uint16_t fid, uint8_t tsid,
1079 			  uint16_t *fid_cnt);
1080 
1081 /**
1082  * Pool allocation
1083  *
1084  * Allocate a pool ID and set it's size
1085  *
1086  * @param[in] tfcp
1087  *   Pointer to TFC handle
1088  *
1089  * @param[in] fid
1090  *   Function id allocating the pool
1091  *
1092  * @param[in] tsid
1093  *   Table scope identifier
1094  *
1095  * @param[in] region
1096  *   Pool region identifier
1097  *
1098  * @param[in] dir
1099  *   Direction
1100  *
1101  * @param[out] pool_sz_exp
1102  *   Pool size exponent
1103  *
1104  * @param[out] pool_id
1105  *   Used to return the allocated pool ID.
1106  *
1107  * @returns
1108  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1109  */
1110 int tfc_tbl_scope_pool_alloc(struct tfc *tfcp, uint16_t fid, uint8_t tsid,
1111 			     enum cfa_region_type region, enum cfa_dir dir,
1112 			     uint8_t *pool_sz_exp, uint16_t *pool_id);
1113 
1114 /**
1115  * Pool free
1116  *
1117  * Free a pool ID
1118  *
1119  * @param[in] tfcp
1120  *   Pointer to TFC handle
1121  *
1122  * @param[in] fid
1123  *   Function freeing the pool
1124  *
1125  * @param[in] tsid
1126  *   Table scope identifier
1127  *
1128  * @param[in] region
1129  *   Pool region identifier
1130  *
1131  * @param[in] dir
1132  *   Direction
1133  *
1134  * @param[in] pool_id
1135  *   Used to return the allocated pool ID.
1136  *
1137  * @returns
1138  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1139  */
1140 int tfc_tbl_scope_pool_free(struct tfc *tfcp, uint16_t fid, uint8_t tsid,
1141 			    enum cfa_region_type region, enum cfa_dir dir,
1142 			    uint16_t pool_id);
1143 
1144 /**
1145  * Get configured state
1146  *
1147  * This API is intended for DPDK applications where a single table scope is shared
1148  * across one or more DPDK instances. When one instance succeeds to allocate and
1149  * configure a table scope, it then sets the config for that table scope; while
1150  * other sessions polling and waiting for the shared table scope to be configured.
1151  *
1152  * @param[in] tfcp
1153  *   Pointer to TFC handle
1154  *
1155  * @param[in] tsid
1156  *   Table scope identifier
1157  *
1158  * @param[out] configured
1159  *   Used to return the allocated pool ID.
1160  *
1161  * @returns
1162  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1163  */
1164 int tfc_tbl_scope_config_state_get(struct tfc *tfcp, uint8_t tsid, bool *configured);
1165 
1166 /**
1167  * Table scope function reset
1168  *
1169  * Delete resources and EM entries associated with fid.
1170  *
1171  * @param[in] tfcp
1172  *   Pointer to TFC handle
1173  *
1174  * @param[in] fid
1175  *   Table scope identifier
1176  *
1177  * @returns
1178  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1179  */
1180 int tfc_tbl_scope_func_reset(struct tfc *tfcp, uint16_t fid);
1181 
1182 /**
1183  * @page EM Exact Match
1184  *
1185  * @ref tfc_em_insert
1186  *
1187  * @ref tfc_em_delete
1188  */
1189 
1190 /**
1191  * tfc_em_insert_parms contains the parameters for an EM insert.
1192  *
1193  */
1194 struct tfc_em_insert_parms {
1195 	/**
1196 	 * [in] Entry direction.
1197 	 */
1198 	enum cfa_dir dir;
1199 	/**
1200 	 * [in] Pointer to the combined lkup record and key data to be written.
1201 	 */
1202 	uint8_t *lkup_key_data;
1203 	/**
1204 	 * [in] The size of the entry to write in 32b words.
1205 	 */
1206 	uint16_t lkup_key_sz_words;
1207 	/**
1208 	 * [in] Thor only - The key data to be used to calculate the hash.
1209 	 */
1210 	const uint8_t *key_data;
1211 	/**
1212 	 * [in] Thor only - Size of key in bits.
1213 	 */
1214 	uint16_t key_sz_bits;
1215 	/**
1216 	 * [out] Will contain the entry flow handle a unique identifier.
1217 	 */
1218 	uint64_t *flow_handle;
1219 	/**
1220 	 * [in/out] Batch mode data
1221 	 */
1222 	struct tfc_mpc_batch_info_t *batch_info;
1223 };
1224 
1225 /**
1226  * Start MPC batching
1227  *
1228  * @param[in/out] batch_info
1229  *   Contains batch processing info
1230  *
1231  * @returns
1232  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1233  */
1234 int tfc_mpc_batch_start(struct tfc_mpc_batch_info_t *batch_info);
1235 
1236 /**
1237  * Ends MPC batching and returns the accumulated results
1238  *
1239  * @param[in/out] batch_info
1240  *   Contains batch processing info
1241  *
1242  * @returns
1243  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1244  */
1245 int tfc_mpc_batch_end(struct tfc *tfcp,
1246 		      struct tfc_mpc_batch_info_t *batch_info);
1247 
1248 /**
1249  * Checks to see if batching is active and other MPCs have been sent
1250  *
1251  * @param[in/out] batch_info
1252  *   Contains batch processing info
1253  *
1254  * @returns
1255  *   True is started and MPCs have been sent else False.
1256  */
1257 bool tfc_mpc_batch_started(struct tfc_mpc_batch_info_t *batch_info);
1258 
1259 /**
1260  * Insert an EM Entry
1261  *
1262  * @param[in] tfcp
1263  *   Pointer to TFC handle
1264  *
1265  * @param[in] tsid
1266  *   Table scope id
1267  *
1268  * @param[in,out] parms
1269  *
1270  * @returns
1271  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1272  *   Error codes -1 through -9 indicate an MPC error and the
1273  *   positive value of the error code maps directly on to the
1274  *   MPC error code. For example, if the value -8 is returned
1275  *   it indicates a CFA_BLD_MPC_EM_DUPLICATE error occurred.
1276  */
1277 int tfc_em_insert(struct tfc *tfcp, uint8_t tsid,
1278 		  struct tfc_em_insert_parms *parms);
1279 
1280 
1281 /**
1282  * tfc_em_delete_parms Contains args required to delete an EM Entry
1283  *
1284  * @param[in] tfcp
1285  *   Pointer to TFC handle
1286  *
1287  * @param[in] dir
1288  *   Direction (CFA_DIR_RX or CFA_DIR_TX)
1289  *
1290  * @param[in,out] flow_handle
1291  *   The flow handle returned to be used for flow deletion.
1292  *
1293  */
1294 struct tfc_em_delete_parms {
1295 	/**
1296 	 * [in] Entry direction.
1297 	 */
1298 	enum cfa_dir dir;
1299 	/**
1300 	 * [in] Flow handle of flow to delete
1301 	 */
1302 	uint64_t flow_handle;
1303 	/**
1304 	 * [in/out] Batch mode data
1305 	 */
1306 	struct tfc_mpc_batch_info_t *batch_info;
1307 };
1308 
1309 /**
1310  * Delete an EM Entry
1311  *
1312  * @param[in] tfcp
1313  *   Pointer to TFC handle
1314  *
1315  * @param[in,out] parms
1316  *
1317  * @returns
1318  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1319  *   Error codes -1 through -9 indicate an MPC error and the
1320  *   positive value of the error code maps directly on to the
1321  *   MPC error code. For example, if the value -8 is returned
1322  *   it indicates a CFA_BLD_MPC_EM_DUPLICATE error occurred.
1323  */
1324 int tfc_em_delete(struct tfc *tfcp, struct tfc_em_delete_parms *parms);
1325 
1326 
1327 /**
1328  * @page ACTCFA Action CFA Memory Management
1329  *
1330  * @ref tfc_act_alloc
1331  *
1332  * @ref tfc_act_set
1333  *
1334  * @ref tfc_act_get
1335  *
1336  * @ref tfc_act_free
1337  */
1338 /**
1339  * CMM resource structure
1340  */
1341 struct tfc_cmm_info {
1342 	enum cfa_resource_subtype_cmm rsubtype; /**< resource subtype */
1343 	enum cfa_dir dir; /**< direction rx/tx */
1344 	uint64_t act_handle; /**< alloc/free handle */
1345 };
1346 
1347 /**
1348  * CMM resource clear structure
1349  */
1350 struct tfc_cmm_clr {
1351 	bool clr; /**< flag for clear */
1352 	uint16_t offset_in_byte; /**< field offset in byte */
1353 	uint16_t sz_in_byte; /**<  field size in byte */
1354 };
1355 
1356 /**
1357  * Allocate an action CMM Resource
1358  *
1359  *
1360  * @param[in] tfcp
1361  *   Pointer to TFC handle
1362  *
1363  * @param[in] tsid
1364  *   Table scope identifier
1365  *
1366  * @param[in,out] cmm_info
1367  *   Pointer to cmm info
1368  *
1369  * @param[in] num_contig_rec
1370  *   Num contiguous records required.  Record size is 8B for Thor/32B for Thor2.
1371  *
1372  * @returns
1373  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1374  */
1375 int tfc_act_alloc(struct tfc *tfcp, uint8_t tsid,
1376 		  struct tfc_cmm_info *cmm_info, uint16_t num_contig_rec);
1377 
1378 /**
1379  * Set an action CMM resource
1380  *
1381  *
1382  * @param[in] tfcp
1383  *   Pointer to TFC handle
1384  *
1385  * @param[in/out] batch_info
1386  *   Batch mode data
1387  *
1388  * @param[in] cmm_info
1389  *   Pointer to cmm info.
1390  *
1391  * @param[in] data
1392  *   Data to be written.
1393  *
1394  * @param[in] data_sz_words
1395  *   Data buffer size in words. In 8B increments.
1396  *
1397  * @returns
1398  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1399  *   Error codes -1 through -9 indicate an MPC error and the
1400  *   positive value of the error code maps directly on to the
1401  *   MPC error code. For example, if the value -8 is returned
1402  *   it indicates a CFA_BLD_MPC_EM_DUPLICATE error occurred.
1403  */
1404 int tfc_act_set(struct tfc *tfcp,
1405 		struct tfc_mpc_batch_info_t *batch_info,
1406 		const struct tfc_cmm_info *cmm_info,
1407 		const uint8_t *data, uint16_t data_sz_words);
1408 
1409 /**
1410  * Get an action CMM resource
1411  *
1412  *
1413  * @param[in] tfcp
1414  *   Pointer to TFC handle
1415  *
1416  * @param[in/out] batch_info
1417  *   Batch mode data
1418  *
1419  * @param[in] cmm_info
1420  *   Pointer to cmm info
1421  *
1422  * @param[in] cmm_clr
1423  *   Pointer to cmm clr
1424  *
1425  * @param[in,out] host_address
1426  *   Data read. Must be word aligned, i.e. [1:0] must be 0. The address
1427  *   must be the ret_mem_virt2iova() version of the virt address.
1428  *
1429  * @param[in,out] data_sz_words
1430  *   Data buffer size in words.	Size could be 8/16/24/32/64B
1431  *
1432  * @returns
1433  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1434  *   Error codes -1 through -9 indicate an MPC error and the
1435  *   positive value of the error code maps directly on to the
1436  *   MPC error code. For example, if the value -8 is returned
1437  *   it indicates a CFA_BLD_MPC_EM_DUPLICATE error occurred.
1438  */
1439 int tfc_act_get(struct tfc *tfcp,
1440 		struct tfc_mpc_batch_info_t *batch_info,
1441 		const struct tfc_cmm_info *cmm_info,
1442 		struct tfc_cmm_clr *clr,
1443 		uint64_t *host_address,
1444 		uint16_t *data_sz_words);
1445 
1446 /**
1447  * Free a CMM Resource
1448  *
1449  * @param[in] tfcp
1450  *   Pointer to TFC handle
1451  *
1452  * @param[in] cmm_info
1453  *   CMM info
1454  *
1455  * @returns
1456  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1457  */
1458 int tfc_act_free(struct tfc *tfcp,
1459 		 const struct tfc_cmm_info *cmm_info);
1460 
1461 /**
1462  * @page IF Table
1463  *
1464  * @ref tfc_if_tbl_set
1465  *
1466  * @ref tfc_if_tbl_get
1467  */
1468 
1469 /**
1470  * IF table resource structure
1471  */
1472 struct tfc_if_tbl_info {
1473 	enum cfa_resource_subtype_if_tbl rsubtype; /**< resource subtype */
1474 	enum cfa_dir dir; /**< direction rx/tx */
1475 	uint16_t id; /**< index */
1476 };
1477 
1478 /**
1479  * Set a TFC if table entry
1480  *
1481  * @param[in] tfcp
1482  *   Pointer to TFC handle
1483  *
1484  * @param[in] fid
1485  *   FID - Function ID to be used
1486  *
1487  * @param[in] tbl_info
1488  *   All the information related to the requested index table entry (subtype/dir)
1489  *   including the id.
1490  *
1491  * @param[in] data
1492  *   Pointer to the data to write to the entry.	The data is aligned correctly
1493  *   in the buffer for writing to the hardware.
1494  *
1495  * @param[in] data_sz_in_bytes
1496  *   The size of the entry in device sized bytes for Thor2.
1497  *
1498  * @returns
1499  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1500  */
1501 int tfc_if_tbl_set(struct tfc *tfcp, uint16_t fid,
1502 		   const struct tfc_if_tbl_info *tbl_info,
1503 		   const uint8_t *data, uint8_t data_sz_in_bytes);
1504 
1505 /**
1506  * Get a TFC if table entry
1507  *
1508  * @param[in] tfcp
1509  *   Pointer to TFC handle
1510  *
1511  * @param[in] fid
1512  *   FID - Function ID to be used
1513  *
1514  * @param[in] tbl_info
1515  *   All the information related to the requested index table entry (subtype/dir)
1516  *   including the id.
1517  *
1518  * @param[in, out] data
1519  *   Pointer to the data to read from the entry.
1520  *
1521  * @param[in,out] data_sz_in_bytes
1522  *   The size of the entry in device sized bytes for Thor2. Input is the
1523  *   size of the buffer, output is the actual size.
1524  *
1525  * @returns
1526  *   0 for SUCCESS, negative error value for FAILURE (errno.h)
1527  */
1528 int tfc_if_tbl_get(struct tfc *tfcp, uint16_t fid,
1529 		   const struct tfc_if_tbl_info *tbl_info,
1530 		   uint8_t *data, uint8_t *data_sz_in_bytes);
1531 #endif /* _TFC_H_ */
1532