xref: /dpdk/drivers/net/bnxt/tf_ulp/ulp_alloc_tbl.h (revision 83f916bddb17f2bed168a1093ff898a08cd3008b)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2023 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _ULP_ALLOC_TBL_H_
7 #define _ULP_ALLOC_TBL_H_
8 
9 #include "bitalloc.h"
10 
11 /* Structure to pass the allocator table values across APIs */
12 struct ulp_allocator_tbl_entry {
13 	const char	*alloc_tbl_name;
14 	uint16_t	num_entries;
15 	struct bitalloc	*ulp_bitalloc;
16 };
17 
18 /* Forward declaration */
19 struct bnxt_ulp_mapper_data;
20 struct ulp_flow_db_res_params;
21 
22 /*
23  * Initialize the allocator table list
24  *
25  * ulp_ctx [in] - Pointer to the ulp context
26  * mapper_data [in] Pointer to the mapper data and the generic table is
27  * part of it
28  *
29  * returns 0 on success
30  */
31 int32_t
32 ulp_allocator_tbl_list_init(struct bnxt_ulp_context *ulp_ctx,
33 			    struct bnxt_ulp_mapper_data *mapper_data);
34 
35 /*
36  * Free the allocator table list
37  *
38  * mapper_data [in] Pointer to the mapper data and the generic table is
39  * part of it
40  *
41  * returns 0 on success
42  */
43 int32_t
44 ulp_allocator_tbl_list_deinit(struct bnxt_ulp_mapper_data *mapper_data);
45 
46 /*
47  * allocate a index from allocator
48  *
49  * mapper_data [in] Pointer to the mapper data and the allocator table is
50  * part of it
51  *
52  * returns index on success or negative number on failure
53  */
54 int32_t
55 ulp_allocator_tbl_list_alloc(struct bnxt_ulp_mapper_data *mapper_data,
56 			     uint32_t res_sub_type, uint32_t dir,
57 			     int32_t *alloc_id);
58 
59 /*
60  * free a index in allocator
61  *
62  * mapper_data [in] Pointer to the mapper data and the allocator table is
63  * part of it
64  *
65  * returns error
66  */
67 int32_t
68 ulp_allocator_tbl_list_free(struct bnxt_ulp_mapper_data *mapper_data,
69 			    uint32_t res_sub_type, uint32_t dir,
70 			    int32_t index);
71 #endif /* _ULP_ALLOC_TBL_H_ */
72