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