xref: /dpdk/drivers/net/bnxt/tf_core/tf_identifier.h (revision e6e8f03e5459f25153f1e4cd3e9ac30d3e473a61)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2023 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _TF_IDENTIFIER_H_
7 #define _TF_IDENTIFIER_H_
8 
9 #include "tf_core.h"
10 
11 /**
12  * The Identifier module provides processing of Identifiers.
13  */
14 
15 struct tf_ident_cfg_parms {
16 	/**
17 	 * [in] Number of identifier types in each of the
18 	 * configuration arrays
19 	 */
20 	uint16_t num_elements;
21 	/**
22 	 * [in] Identifier configuration array
23 	 */
24 	struct tf_rm_element_cfg *cfg;
25 	/**
26 	 * [in] Session resource allocations
27 	 */
28 	struct tf_session_resources *resources;
29 };
30 
31 /**
32  * Identifier allocation parameter definition
33  */
34 struct tf_ident_alloc_parms {
35 	/**
36 	 * [in] receive or transmit direction
37 	 */
38 	enum tf_dir dir;
39 	/**
40 	 * [in] Identifier type
41 	 */
42 	enum tf_identifier_type type;
43 	/**
44 	 * [out] Identifier allocated
45 	 */
46 	uint16_t *id;
47 };
48 
49 /**
50  * Identifier free parameter definition
51  */
52 struct tf_ident_free_parms {
53 	/**
54 	 * [in]	 receive or transmit direction
55 	 */
56 	enum tf_dir dir;
57 	/**
58 	 * [in] Identifier type
59 	 */
60 	enum tf_identifier_type type;
61 	/**
62 	 * [in] ID to free
63 	 */
64 	uint16_t id;
65 	/**
66 	 * (experimental)
67 	 * [out] Current refcnt after free
68 	 */
69 	uint32_t *ref_cnt;
70 };
71 
72 /**
73  * Identifier search parameter definition
74  */
75 struct tf_ident_search_parms {
76 	/**
77 	 * [in]  receive or transmit direction
78 	 */
79 	enum tf_dir dir;
80 	/**
81 	 * [in] Identifier type
82 	 */
83 	enum tf_identifier_type type;
84 	/**
85 	 * [in] Identifier data to search for
86 	 */
87 	uint16_t search_id;
88 	/**
89 	 * [out] Set if matching identifier found
90 	 */
91 	bool *hit;
92 	/**
93 	 * [out] Current ref count after allocation
94 	 */
95 	uint32_t *ref_cnt;
96 };
97 
98 /**
99  * Identifier database
100  *
101  * Identifier rm database
102  *
103  */
104 struct ident_rm_db {
105 	struct rm_db *ident_db[TF_DIR_MAX];
106 };
107 
108 /**
109  * @page ident Identity Management
110  *
111  * @ref tf_ident_bind
112  *
113  * @ref tf_ident_unbind
114  *
115  * @ref tf_ident_alloc
116  *
117  * @ref tf_ident_free
118  */
119 
120 /**
121  * Initializes the Identifier module with the requested DBs. Must be
122  * invoked as the first thing before any of the access functions.
123  *
124  * [in] tfp
125  *   Pointer to TF handle, used for HCAPI communication
126  *
127  * [in] parms
128  *   Pointer to parameters
129  *
130  * Returns
131  *   - (0) if successful.
132  *   - (-EINVAL) on failure.
133  */
134 int tf_ident_bind(struct tf *tfp,
135 		  struct tf_ident_cfg_parms *parms);
136 
137 /**
138  * Cleans up the private DBs and releases all the data.
139  *
140  * [in] tfp
141  *   Pointer to TF handle, used for HCAPI communication
142  *
143  * [in] parms
144  *   Pointer to parameters
145  *
146  * Returns
147  *   - (0) if successful.
148  *   - (-EINVAL) on failure.
149  */
150 int tf_ident_unbind(struct tf *tfp);
151 
152 /**
153  * Allocates a single identifier type.
154  *
155  * [in] tfp
156  *   Pointer to TF handle, used for HCAPI communication
157  *
158  * [in] parms
159  *   Pointer to parameters
160  *
161  * Returns
162  *   - (0) if successful.
163  *   - (-EINVAL) on failure.
164  */
165 int tf_ident_alloc(struct tf *tfp,
166 		   struct tf_ident_alloc_parms *parms);
167 
168 /**
169  * Free's a single identifier type.
170  *
171  * [in] tfp
172  *   Pointer to TF handle, used for HCAPI communication
173  *
174  * [in] parms
175  *   Pointer to parameters
176  *
177  * Returns
178  *   - (0) if successful.
179  *   - (-EINVAL) on failure.
180  */
181 int tf_ident_free(struct tf *tfp,
182 		  struct tf_ident_free_parms *parms);
183 
184 /**
185  * Search a single identifier type.
186  *
187  * [in] tfp
188  *   Pointer to TF handle, used for HCAPI communication
189  *
190  * [in] parms
191  *   Pointer to parameters
192  *
193  * Returns
194  *   - (0) if successful.
195  *   - (-EINVAL) on failure.
196  */
197 int tf_ident_search(struct tf *tfp,
198 		    struct tf_ident_search_parms *parms);
199 
200 /**
201  * Retrieves the allocated resource info
202  *
203  * [in] tfp
204  *   Pointer to TF handle, used for HCAPI communication
205  *
206  * [in] parms
207  *   Pointer to parameters
208  *
209  * Returns
210  *   - (0) if successful.
211  *   - (-EINVAL) on failure.
212  */
213 int tf_ident_get_resc_info(struct tf *tfp,
214 			   struct tf_identifier_resource_info *parms);
215 #endif /* _TF_IDENTIFIER_H_ */
216