1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
6 #include <rte_common.h>
8 #include "cfa_resource_types.h"
10 #include "tf_identifier.h"
14 #include "tf_if_tbl.h"
16 #include "tf_msg_common.h"
18 #define TF_DEV_P58_PARIF_MAX 16
19 #define TF_DEV_P58_PF_MASK 0xfUL
21 /* For print alignment, make all entries 8 chars in this table */
22 const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
23 [CFA_RESOURCE_TYPE_P58_METER] = "meter ",
24 [CFA_RESOURCE_TYPE_P58_SRAM_BANK_0] = "sram_bk0",
25 [CFA_RESOURCE_TYPE_P58_SRAM_BANK_1] = "sram_bk1",
26 [CFA_RESOURCE_TYPE_P58_SRAM_BANK_2] = "sram_bk2",
27 [CFA_RESOURCE_TYPE_P58_SRAM_BANK_3] = "sram_bk3",
28 [CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH] = "l2ctx_hi",
29 [CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW] = "l2ctx_lo",
30 [CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH] = "l2ctr_hi",
31 [CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW] = "l2ctr_lo",
32 [CFA_RESOURCE_TYPE_P58_PROF_FUNC] = "prf_func",
33 [CFA_RESOURCE_TYPE_P58_PROF_TCAM] = "prf_tcam",
34 [CFA_RESOURCE_TYPE_P58_EM_PROF_ID] = "em_prof ",
35 [CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID] = "wc_prof ",
36 [CFA_RESOURCE_TYPE_P58_EM_REC] = "em_rec ",
37 [CFA_RESOURCE_TYPE_P58_WC_TCAM] = "wc_tcam ",
38 [CFA_RESOURCE_TYPE_P58_METER_PROF] = "mtr_prof",
39 [CFA_RESOURCE_TYPE_P58_MIRROR] = "mirror ",
40 [CFA_RESOURCE_TYPE_P58_EM_FKB] = "em_fkb ",
41 [CFA_RESOURCE_TYPE_P58_WC_FKB] = "wc_fkb ",
42 [CFA_RESOURCE_TYPE_P58_VEB_TCAM] = "veb ",
46 * Device specific function that retrieves the MAX number of HCAPI
47 * types the device supports.
50 * Pointer to TF handle
53 * Pointer to the MAX number of HCAPI types supported
56 * - (0) if successful.
57 * - (-EINVAL) on failure.
60 tf_dev_p58_get_max_types(struct tf *tfp,
63 if (max_types == NULL || tfp == NULL)
66 *max_types = CFA_RESOURCE_TYPE_P58_LAST + 1;
71 * Device specific function that retrieves a human readable
72 * string to identify a CFA resource type.
75 * Pointer to TF handle
78 * HCAPI CFA resource id
84 * - (0) if successful.
85 * - (-EINVAL) on failure.
88 tf_dev_p58_get_resource_str(struct tf *tfp __rte_unused,
90 const char **resource_str)
92 if (resource_str == NULL)
95 if (resource_id > CFA_RESOURCE_TYPE_P58_LAST)
98 *resource_str = tf_resource_str_p58[resource_id];
104 * Device specific function that retrieves the WC TCAM slices the
108 * Pointer to TF handle
111 * Pointer to the WC TCAM slice size
113 * [out] num_slices_per_row
114 * Pointer to the WC TCAM row slice configuration
117 * - (0) if successful.
118 * - (-EINVAL) on failure.
121 tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused,
122 enum tf_tcam_tbl_type type,
124 uint16_t *num_slices_per_row)
126 #define CFA_P58_WC_TCAM_SLICES_PER_ROW 2
127 #define CFA_P58_WC_TCAM_SLICE_SIZE 12
129 if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
130 *num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW;
131 if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE)
134 *num_slices_per_row = 1;
135 } else { /* for other type of tcam */
136 *num_slices_per_row = 1;
142 static int tf_dev_p58_get_mailbox(void)
147 static int tf_dev_p58_word_align(uint16_t size)
149 return ((((size) + 63) >> 6) * 8);
153 * Truflow P58 device specific functions
155 const struct tf_dev_ops tf_dev_ops_p58_init = {
156 .tf_dev_get_max_types = tf_dev_p58_get_max_types,
157 .tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
158 .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
159 .tf_dev_alloc_ident = NULL,
160 .tf_dev_free_ident = NULL,
161 .tf_dev_search_ident = NULL,
162 .tf_dev_alloc_ext_tbl = NULL,
163 .tf_dev_alloc_tbl = NULL,
164 .tf_dev_free_ext_tbl = NULL,
165 .tf_dev_free_tbl = NULL,
166 .tf_dev_alloc_search_tbl = NULL,
167 .tf_dev_set_tbl = NULL,
168 .tf_dev_set_ext_tbl = NULL,
169 .tf_dev_get_tbl = NULL,
170 .tf_dev_get_bulk_tbl = NULL,
171 .tf_dev_alloc_tcam = NULL,
172 .tf_dev_free_tcam = NULL,
173 .tf_dev_alloc_search_tcam = NULL,
174 .tf_dev_set_tcam = NULL,
175 .tf_dev_get_tcam = NULL,
176 .tf_dev_insert_int_em_entry = NULL,
177 .tf_dev_delete_int_em_entry = NULL,
178 .tf_dev_insert_ext_em_entry = NULL,
179 .tf_dev_delete_ext_em_entry = NULL,
180 .tf_dev_alloc_tbl_scope = NULL,
181 .tf_dev_map_tbl_scope = NULL,
182 .tf_dev_map_parif = NULL,
183 .tf_dev_free_tbl_scope = NULL,
184 .tf_dev_set_if_tbl = NULL,
185 .tf_dev_get_if_tbl = NULL,
186 .tf_dev_set_global_cfg = NULL,
187 .tf_dev_get_global_cfg = NULL,
188 .tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
189 .tf_dev_word_align = NULL,
193 * Truflow P58 device specific functions
195 const struct tf_dev_ops tf_dev_ops_p58 = {
196 .tf_dev_get_max_types = tf_dev_p58_get_max_types,
197 .tf_dev_get_resource_str = tf_dev_p58_get_resource_str,
198 .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info,
199 .tf_dev_alloc_ident = tf_ident_alloc,
200 .tf_dev_free_ident = tf_ident_free,
201 .tf_dev_search_ident = tf_ident_search,
202 .tf_dev_alloc_tbl = tf_tbl_alloc,
203 .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
204 .tf_dev_free_tbl = tf_tbl_free,
205 .tf_dev_free_ext_tbl = tf_tbl_ext_free,
206 .tf_dev_alloc_search_tbl = tf_tbl_alloc_search,
207 .tf_dev_set_tbl = tf_tbl_set,
208 .tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
209 .tf_dev_get_tbl = tf_tbl_get,
210 .tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
211 .tf_dev_alloc_tcam = tf_tcam_alloc,
212 .tf_dev_free_tcam = tf_tcam_free,
213 .tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
214 .tf_dev_set_tcam = tf_tcam_set,
215 .tf_dev_get_tcam = tf_tcam_get,
216 .tf_dev_insert_int_em_entry = tf_em_hash_insert_int_entry,
217 .tf_dev_delete_int_em_entry = tf_em_hash_delete_int_entry,
218 .tf_dev_insert_ext_em_entry = NULL,
219 .tf_dev_delete_ext_em_entry = NULL,
220 .tf_dev_alloc_tbl_scope = NULL,
221 .tf_dev_map_tbl_scope = NULL,
222 .tf_dev_map_parif = NULL,
223 .tf_dev_free_tbl_scope = NULL,
224 .tf_dev_set_if_tbl = tf_if_tbl_set,
225 .tf_dev_get_if_tbl = tf_if_tbl_get,
226 .tf_dev_set_global_cfg = tf_global_cfg_set,
227 .tf_dev_get_global_cfg = tf_global_cfg_get,
228 .tf_dev_get_mailbox = tf_dev_p58_get_mailbox,
229 .tf_dev_word_align = tf_dev_p58_word_align,