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 * offset [in] - The offset in bits where the data has to be set
105 * len [in] - The length of the data in bits to be set
106 * data [in] - pointer to the data to be used for setting the value.
107 * data_size [in] - length of the data pointer in bytes.
109 * returns 0 on success
112 ulp_mapper_gen_tbl_entry_data_set(struct ulp_mapper_gen_tbl_entry *entry,
113 uint32_t offset, uint32_t len, uint8_t *data,
117 * Get the data in the generic table entry
119 * entry [in] - generic table entry
120 * offset [in] - The offset in bits where the data has to get
121 * len [in] - The length of the data in bits to be get
122 * data [out] - pointer to the data to be used for setting the value.
123 * data_size [in] - The size of data in bytes
125 * returns 0 on success
128 ulp_mapper_gen_tbl_entry_data_get(struct ulp_mapper_gen_tbl_entry *entry,
129 uint32_t offset, uint32_t len, uint8_t *data,
133 * Free the generic table list entry
135 * ulp_ctx [in] - Pointer to the ulp context
136 * res [in] - Pointer to flow db resource entry
138 * returns 0 on success
141 ulp_mapper_gen_tbl_res_free(struct bnxt_ulp_context *ulp_ctx,
142 struct ulp_flow_db_res_params *res);
144 #endif /* _ULP_EN_TBL_H_ */