1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
15 * The Table module provides processing of Internal TF table types.
19 * Table scope control block content
24 uint32_t max_entries_supported;
25 uint16_t key_entry_size;
26 uint16_t record_entry_size;
27 uint16_t efc_entry_size;
30 /** Invalid table scope id */
31 #define TF_TBL_SCOPE_INVALID 0xffffffff
34 * Table Scope Control Block
36 * Holds private data for a table scope. Only one instance of a table
37 * scope with Internal EM is supported.
39 struct tf_tbl_scope_cb {
40 uint32_t tbl_scope_id;
41 /** The pf or parent pf of the vf used for table scope creation
45 struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
46 struct tf_em_caps em_caps[TF_DIR_MAX];
47 struct stack ext_act_pool[TF_DIR_MAX];
48 uint32_t *ext_act_pool_mem[TF_DIR_MAX];
52 * Table configuration parameters
54 struct tf_tbl_cfg_parms {
56 * Number of table types in each of the configuration arrays
58 uint16_t num_elements;
60 * Table Type element configuration array
62 struct tf_rm_element_cfg *cfg;
64 * Shadow table type configuration array
66 struct tf_shadow_tbl_cfg *shadow_cfg;
68 * Boolean controlling the request shadow copy.
72 * Session resource allocations
74 struct tf_session_resources *resources;
78 * Table allocation parameters
80 struct tf_tbl_alloc_parms {
82 * [in] Receive or transmit direction
86 * [in] Type of the allocation
88 enum tf_tbl_type type;
90 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
92 uint32_t tbl_scope_id;
94 * [out] Idx of allocated entry or found entry (if search_enable)
100 * Table free parameters
102 struct tf_tbl_free_parms {
104 * [in] Receive or transmit direction
108 * [in] Type of the allocation type
110 enum tf_tbl_type type;
112 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
114 uint32_t tbl_scope_id;
120 * [out] Reference count after free, only valid if session has been
121 * created with shadow_copy.
127 * Table allocate search parameters
129 struct tf_tbl_alloc_search_parms {
131 * [in] Receive or transmit direction
135 * [in] Type of the allocation
137 enum tf_tbl_type type;
139 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
141 uint32_t tbl_scope_id;
143 * [in] Result data to search for
147 * [in] Result data size in bytes
149 uint16_t result_sz_in_bytes;
151 * [in] Whether or not to allocate on MISS, 1 is allocate.
155 * [out] If search_enable, set if matching entry found
159 * [out] The status of the search (REJECT, MISS, HIT)
161 enum tf_search_status search_status;
163 * [out] Current ref count after allocation
167 * [out] Idx of allocated entry or found entry
173 * Table set parameters
175 struct tf_tbl_set_parms {
177 * [in] Receive or transmit direction
181 * [in] Type of object to set
183 enum tf_tbl_type type;
185 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
187 uint32_t tbl_scope_id;
195 uint16_t data_sz_in_bytes;
197 * [in] Entry index to write to
203 * Table get parameters
205 struct tf_tbl_get_parms {
207 * [in] Receive or transmit direction
211 * [in] Type of object to get
213 enum tf_tbl_type type;
221 uint16_t data_sz_in_bytes;
223 * [in] Entry index to read
229 * Table get bulk parameters
231 struct tf_tbl_get_bulk_parms {
233 * [in] Receive or transmit direction
237 * [in] Type of object to get
239 enum tf_tbl_type type;
241 * [in] Starting index to read from
243 uint32_t starting_idx;
245 * [in] Number of sequential entries
247 uint16_t num_entries;
249 * [in] Size of the single entry
251 uint16_t entry_sz_in_bytes;
253 * [out] Host physical address, where the data
254 * will be copied to by the firmware.
255 * Use tfp_calloc() API and mem_pa
256 * variable of the tfp_calloc_parms
257 * structure for the physical address.
259 uint64_t physical_mem_addr;
273 * @ref tf_tbl_alloc_search
279 * @ref tf_tbl_bulk_get
283 * Initializes the Table module with the requested DBs. Must be
284 * invoked as the first thing before any of the access functions.
287 * Pointer to TF handle, used for HCAPI communication
290 * Pointer to Table configuration parameters
293 * - (0) if successful.
294 * - (-EINVAL) on failure.
296 int tf_tbl_bind(struct tf *tfp,
297 struct tf_tbl_cfg_parms *parms);
300 * Cleans up the private DBs and releases all the data.
303 * Pointer to TF handle, used for HCAPI communication
306 * Pointer to parameters
309 * - (0) if successful.
310 * - (-EINVAL) on failure.
312 int tf_tbl_unbind(struct tf *tfp);
315 * Allocates the requested table type from the internal RM DB.
318 * Pointer to TF handle, used for HCAPI communication
321 * Pointer to Table allocation parameters
324 * - (0) if successful.
325 * - (-EINVAL) on failure.
327 int tf_tbl_alloc(struct tf *tfp,
328 struct tf_tbl_alloc_parms *parms);
331 * Free's the requested table type and returns it to the DB. If shadow
332 * DB is enabled its searched first and if found the element refcount
333 * is decremented. If refcount goes to 0 then its returned to the
337 * Pointer to TF handle, used for HCAPI communication
340 * Pointer to Table free parameters
343 * - (0) if successful.
344 * - (-EINVAL) on failure.
346 int tf_tbl_free(struct tf *tfp,
347 struct tf_tbl_free_parms *parms);
350 * Supported if Shadow DB is configured. Searches the Shadow DB for
351 * any matching element. If found the refcount in the shadow DB is
352 * updated accordingly. If not found a new element is allocated and
353 * installed into the shadow DB.
356 * Pointer to TF handle, used for HCAPI communication
359 * Pointer to parameters
362 * - (0) if successful.
363 * - (-EINVAL) on failure.
365 int tf_tbl_alloc_search(struct tf *tfp,
366 struct tf_tbl_alloc_search_parms *parms);
369 * Configures the requested element by sending a firmware request which
370 * then installs it into the device internal structures.
373 * Pointer to TF handle, used for HCAPI communication
376 * Pointer to Table set parameters
379 * - (0) if successful.
380 * - (-EINVAL) on failure.
382 int tf_tbl_set(struct tf *tfp,
383 struct tf_tbl_set_parms *parms);
386 * Retrieves the requested element by sending a firmware request to get
390 * Pointer to TF handle, used for HCAPI communication
393 * Pointer to Table get parameters
396 * - (0) if successful.
397 * - (-EINVAL) on failure.
399 int tf_tbl_get(struct tf *tfp,
400 struct tf_tbl_get_parms *parms);
403 * Retrieves bulk block of elements by sending a firmware request to
407 * Pointer to TF handle, used for HCAPI communication
410 * Pointer to Table get bulk parameters
413 * - (0) if successful.
414 * - (-EINVAL) on failure.
416 int tf_tbl_bulk_get(struct tf *tfp,
417 struct tf_tbl_get_bulk_parms *parms);
419 #endif /* TF_TBL_TYPE_H */