1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2021 Broadcom
6 #ifndef _ULP_GEN_TBL_H_
7 #define _ULP_GEN_TBL_H_
9 /* Macros for reference count manipulation */
10 #define ULP_GEN_TBL_REF_CNT_INC(entry) {*(entry)->ref_count += 1; }
11 #define ULP_GEN_TBL_REF_CNT_DEC(entry) {*(entry)->ref_count -= 1; }
12 #define ULP_GEN_TBL_REF_CNT(entry) (*(entry)->ref_count)
14 #define ULP_GEN_TBL_FID_OFFSET 0
15 #define ULP_GEN_TBL_FID_SIZE_BITS 32
17 /* Structure to pass the generic table values across APIs */
18 struct ulp_mapper_gen_tbl_entry {
20 uint32_t byte_data_size;
22 enum bnxt_ulp_byte_order byte_order;
26 * Structure to store the generic tbl container
27 * The ref count and byte data contain list of "num_elem" elements.
28 * The size of each entry in byte_data is of size byte_data_size.
30 struct ulp_mapper_gen_tbl_cont {
32 uint32_t byte_data_size;
33 enum bnxt_ulp_byte_order byte_order;
34 /* Reference count to track number of users*/
36 /* First 4 bytes is either tcam_idx or fid and rest are identities */
40 /* Structure to store the generic tbl container */
41 struct ulp_mapper_gen_tbl_list {
42 struct ulp_mapper_gen_tbl_cont container;
43 uint32_t mem_data_size;
47 /* Forward declaration */
48 struct bnxt_ulp_mapper_data;
49 struct ulp_flow_db_res_params;
52 * Initialize the generic table list
54 * mapper_data [in] Pointer to the mapper data and the generic table is
57 * returns 0 on success
60 ulp_mapper_generic_tbl_list_init(struct bnxt_ulp_mapper_data *mapper_data);
63 * Free the generic table list
65 * mapper_data [in] Pointer to the mapper data and the generic table is
68 * returns 0 on success
71 ulp_mapper_generic_tbl_list_deinit(struct bnxt_ulp_mapper_data *mapper_data);
74 * Get the generic table list entry
76 * ulp_ctxt [in] - Ptr to ulp_context
77 * tbl_idx [in] - Table index to the generic table list
78 * key [in] - Key index to the table
79 * entry [out] - output will include the entry if found
81 * returns 0 on success.
84 ulp_mapper_gen_tbl_entry_get(struct bnxt_ulp_context *ulp,
87 struct ulp_mapper_gen_tbl_entry *entry);
90 * utility function to calculate the table idx
92 * res_sub_type [in] - Resource sub type
93 * dir [in] - direction
98 ulp_mapper_gen_tbl_idx_calculate(uint32_t res_sub_type, uint32_t dir);
101 * Set the data in the generic table entry
103 * entry [in] - generic table entry
104 * len [in] - The length of the data in bits to be set
105 * data [in] - pointer to the data to be used for setting the value.
106 * data_size [in] - length of the data pointer in bytes.
108 * returns 0 on success
111 ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry,
112 uint32_t len, uint8_t *data,
116 * Get the data in the generic table entry
118 * entry [in] - generic table entry
119 * offset [in] - The offset in bits where the data has to get
120 * len [in] - The length of the data in bits to be get
121 * data [out] - pointer to the data to be used for setting the value.
122 * data_size [in] - The size of data in bytes
124 * returns 0 on success
127 ulp_mapper_gen_tbl_entry_data_get(struct ulp_mapper_gen_tbl_entry *entry,
128 uint32_t offset, uint32_t len, uint8_t *data,
132 * Free the generic table list entry
134 * ulp_ctx [in] - Pointer to the ulp context
135 * res [in] - Pointer to flow db resource entry
137 * returns 0 on success
140 ulp_mapper_gen_tbl_res_free(struct bnxt_ulp_context *ulp_ctx,
141 struct ulp_flow_db_res_params *res);
143 #endif /* _ULP_EN_TBL_H_ */