Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2021-2023 Broadcom
3 : : * All rights reserved.
4 : : */
5 : :
6 : : #include "hcapi_cfa_defs.h"
7 : :
8 : : #include "cfa_tcam_mgr.h"
9 : : #include "cfa_tcam_mgr_p58.h"
10 : : #include "cfa_tcam_mgr_device.h"
11 : : #include "cfa_resource_types.h"
12 : : #include "tfp.h"
13 : : #include "assert.h"
14 : : #include "tf_util.h"
15 : :
16 : : /*
17 : : * Sizings of the TCAMs on P5
18 : : */
19 : :
20 : : #define MAX_ROW_WIDTH 96
21 : : #define MAX_RESULT_SIZE 8
22 : :
23 : : #if MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE
24 : : #error MAX_ROW_WIDTH > CFA_TCAM_MGR_MAX_KEY_SIZE
25 : : #endif
26 : :
27 : : /*
28 : : * TCAM definitions
29 : : *
30 : : * These define the TCAMs in HW.
31 : : *
32 : : * Note: Set xxx_TCAM_[R|T]X_NUM_ROWS to zero if a TCAM is either not supported
33 : : * by HW or not supported by TCAM Manager.
34 : : */
35 : :
36 : : /** L2 Context TCAM */
37 : : #define L2_CTXT_TCAM_RX_MAX_SLICES 1
38 : : #define L2_CTXT_TCAM_RX_ROW_WIDTH TF_BITS2BYTES_64B_WORD_ALIGN(214)
39 : : #define L2_CTXT_TCAM_RX_NUM_ROWS 1024
40 : : #define L2_CTXT_TCAM_RX_MAX_ENTRIES (L2_CTXT_TCAM_RX_MAX_SLICES * \
41 : : L2_CTXT_TCAM_RX_NUM_ROWS)
42 : : #define L2_CTXT_TCAM_RX_RESULT_SIZE 8
43 : :
44 : : #define L2_CTXT_TCAM_TX_MAX_SLICES L2_CTXT_TCAM_RX_MAX_SLICES
45 : : #define L2_CTXT_TCAM_TX_ROW_WIDTH L2_CTXT_TCAM_RX_ROW_WIDTH
46 : : #define L2_CTXT_TCAM_TX_NUM_ROWS L2_CTXT_TCAM_RX_NUM_ROWS
47 : : #define L2_CTXT_TCAM_TX_MAX_ENTRIES L2_CTXT_TCAM_RX_MAX_ENTRIES
48 : : #define L2_CTXT_TCAM_TX_RESULT_SIZE L2_CTXT_TCAM_RX_RESULT_SIZE
49 : :
50 : : /** Profile TCAM */
51 : : #define PROF_TCAM_RX_MAX_SLICES 1
52 : : #define PROF_TCAM_RX_ROW_WIDTH TF_BITS2BYTES_64B_WORD_ALIGN(94)
53 : : #define PROF_TCAM_RX_NUM_ROWS 256
54 : : #define PROF_TCAM_RX_MAX_ENTRIES (PROF_TCAM_RX_MAX_SLICES * \
55 : : PROF_TCAM_RX_NUM_ROWS)
56 : : #define PROF_TCAM_RX_RESULT_SIZE 8
57 : :
58 : : #define PROF_TCAM_TX_MAX_SLICES PROF_TCAM_RX_MAX_SLICES
59 : : #define PROF_TCAM_TX_ROW_WIDTH PROF_TCAM_RX_ROW_WIDTH
60 : : #define PROF_TCAM_TX_NUM_ROWS PROF_TCAM_RX_NUM_ROWS
61 : : #define PROF_TCAM_TX_MAX_ENTRIES PROF_TCAM_RX_MAX_ENTRIES
62 : : #define PROF_TCAM_TX_RESULT_SIZE PROF_TCAM_RX_RESULT_SIZE
63 : :
64 : : /** Wildcard TCAM */
65 : : #define WC_TCAM_RX_MAX_SLICES 4
66 : : /* 162 bits per slice */
67 : : #define WC_TCAM_RX_ROW_WIDTH (TF_BITS2BYTES_64B_WORD_ALIGN(162) * \
68 : : WC_TCAM_RX_MAX_SLICES)
69 : : #define WC_TCAM_RX_NUM_ROWS 2048
70 : : #define WC_TCAM_RX_MAX_ENTRIES (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)
71 : : #define WC_TCAM_RX_RESULT_SIZE 8
72 : :
73 : : #define WC_TCAM_TX_MAX_SLICES WC_TCAM_RX_MAX_SLICES
74 : : #define WC_TCAM_TX_ROW_WIDTH WC_TCAM_RX_ROW_WIDTH
75 : : #define WC_TCAM_TX_NUM_ROWS WC_TCAM_RX_NUM_ROWS
76 : : #define WC_TCAM_TX_MAX_ENTRIES WC_TCAM_RX_MAX_ENTRIES
77 : : #define WC_TCAM_TX_RESULT_SIZE WC_TCAM_RX_RESULT_SIZE
78 : :
79 : : /** Source Properties TCAM */
80 : : #define SP_TCAM_RX_MAX_SLICES 1
81 : : #define SP_TCAM_RX_ROW_WIDTH TF_BITS2BYTES_64B_WORD_ALIGN(89)
82 : : #define SP_TCAM_RX_NUM_ROWS 0
83 : : #define SP_TCAM_RX_MAX_ENTRIES (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)
84 : : #define SP_TCAM_RX_RESULT_SIZE 8
85 : :
86 : : #define SP_TCAM_TX_MAX_SLICES SP_TCAM_RX_MAX_SLICES
87 : : #define SP_TCAM_TX_ROW_WIDTH SP_TCAM_RX_ROW_WIDTH
88 : : #define SP_TCAM_TX_NUM_ROWS SP_TCAM_RX_NUM_ROWS
89 : : #define SP_TCAM_TX_MAX_ENTRIES SP_TCAM_RX_MAX_ENTRIES
90 : : #define SP_TCAM_TX_RESULT_SIZE SP_TCAM_RX_RESULT_SIZE
91 : :
92 : : /** Connection Tracking Rule TCAM */
93 : : #define CT_RULE_TCAM_RX_MAX_SLICES 1
94 : : #define CT_RULE_TCAM_RX_ROW_WIDTH TF_BITS2BYTES_64B_WORD_ALIGN(16)
95 : : #define CT_RULE_TCAM_RX_NUM_ROWS 0
96 : : #define CT_RULE_TCAM_RX_MAX_ENTRIES (CT_RULE_TCAM_RX_MAX_SLICES * \
97 : : CT_RULE_TCAM_RX_NUM_ROWS)
98 : : #define CT_RULE_TCAM_RX_RESULT_SIZE 8
99 : :
100 : : #define CT_RULE_TCAM_TX_MAX_SLICES CT_RULE_TCAM_RX_MAX_SLICES
101 : : #define CT_RULE_TCAM_TX_ROW_WIDTH CT_RULE_TCAM_RX_ROW_WIDTH
102 : : #define CT_RULE_TCAM_TX_NUM_ROWS CT_RULE_TCAM_RX_NUM_ROWS
103 : : #define CT_RULE_TCAM_TX_MAX_ENTRIES CT_RULE_TCAM_RX_MAX_ENTRIES
104 : : #define CT_RULE_TCAM_TX_RESULT_SIZE CT_RULE_TCAM_RX_RESULT_SIZE
105 : :
106 : : /** Virtual Edge Bridge TCAM */
107 : : #define VEB_TCAM_RX_MAX_SLICES 1
108 : : #define VEB_TCAM_RX_ROW_WIDTH TF_BITS2BYTES_WORD_ALIGN(79)
109 : : /* Tx only */
110 : : #define VEB_TCAM_RX_NUM_ROWS 0
111 : : #define VEB_TCAM_RX_MAX_ENTRIES (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)
112 : : #define VEB_TCAM_RX_RESULT_SIZE 8
113 : :
114 : : #define VEB_TCAM_TX_MAX_SLICES VEB_TCAM_RX_MAX_SLICES
115 : : #define VEB_TCAM_TX_ROW_WIDTH VEB_TCAM_RX_ROW_WIDTH
116 : : #define VEB_TCAM_TX_NUM_ROWS 1024
117 : : #define VEB_TCAM_TX_MAX_ENTRIES (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)
118 : : #define VEB_TCAM_TX_RESULT_SIZE VEB_TCAM_RX_RESULT_SIZE
119 : :
120 : : /* Declare the table rows for each table here. If new tables are added to the
121 : : * enum tf_tcam_tbl_type, then new declarations will be needed here.
122 : : *
123 : : * The numeric suffix of the structure type indicates how many slices a
124 : : * particular TCAM supports.
125 : : *
126 : : * Array sizes have 1 added to avoid zero length arrays.
127 : : */
128 : :
129 : : static struct cfa_tcam_mgr_table_rows_1
130 : : cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_RX_NUM_ROWS + 1];
131 : : static struct cfa_tcam_mgr_table_rows_1
132 : : cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[TF_TCAM_MAX_SESSIONS][L2_CTXT_TCAM_TX_NUM_ROWS + 1];
133 : : static struct cfa_tcam_mgr_table_rows_1
134 : : cfa_tcam_mgr_table_rows_PROF_TCAM_RX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_RX_NUM_ROWS + 1];
135 : : static struct cfa_tcam_mgr_table_rows_1
136 : : cfa_tcam_mgr_table_rows_PROF_TCAM_TX[TF_TCAM_MAX_SESSIONS][PROF_TCAM_TX_NUM_ROWS + 1];
137 : : static struct cfa_tcam_mgr_table_rows_4
138 : : cfa_tcam_mgr_table_rows_WC_TCAM_RX[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];
139 : : static struct cfa_tcam_mgr_table_rows_4
140 : : cfa_tcam_mgr_table_rows_WC_TCAM_TX[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];
141 : : static struct cfa_tcam_mgr_table_rows_1
142 : : cfa_tcam_mgr_table_rows_SP_TCAM_RX[TF_TCAM_MAX_SESSIONS][SP_TCAM_RX_NUM_ROWS + 1];
143 : : static struct cfa_tcam_mgr_table_rows_1
144 : : cfa_tcam_mgr_table_rows_SP_TCAM_TX[TF_TCAM_MAX_SESSIONS][SP_TCAM_TX_NUM_ROWS + 1];
145 : : static struct cfa_tcam_mgr_table_rows_1
146 : : cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_RX_NUM_ROWS + 1];
147 : : static struct cfa_tcam_mgr_table_rows_1
148 : : cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[TF_TCAM_MAX_SESSIONS][CT_RULE_TCAM_TX_NUM_ROWS + 1];
149 : : static struct cfa_tcam_mgr_table_rows_1
150 : : cfa_tcam_mgr_table_rows_VEB_TCAM_RX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_RX_NUM_ROWS + 1];
151 : : static struct cfa_tcam_mgr_table_rows_1
152 : : cfa_tcam_mgr_table_rows_VEB_TCAM_TX[TF_TCAM_MAX_SESSIONS][VEB_TCAM_TX_NUM_ROWS + 1];
153 : : static struct cfa_tcam_mgr_table_rows_4
154 : : cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];
155 : : static struct cfa_tcam_mgr_table_rows_4
156 : : cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_RX_NUM_ROWS + 1];
157 : : static struct cfa_tcam_mgr_table_rows_4
158 : : cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];
159 : : static struct cfa_tcam_mgr_table_rows_4
160 : : cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[TF_TCAM_MAX_SESSIONS][WC_TCAM_TX_NUM_ROWS + 1];
161 : :
162 : : struct cfa_tcam_mgr_table_data
163 : : cfa_tcam_mgr_tables_p58[TF_DIR_MAX][CFA_TCAM_MGR_TBL_TYPE_MAX] = {
164 : : { /* RX */
165 : : { /* High AFM */
166 : : .max_slices = L2_CTXT_TCAM_RX_MAX_SLICES,
167 : : .row_width = L2_CTXT_TCAM_RX_ROW_WIDTH,
168 : : .num_rows = 0,
169 : : .start_row = 0,
170 : : .end_row = 0,
171 : : .max_entries = 0,
172 : : .result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,
173 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,
174 : : },
175 : : { /* High APPS */
176 : : .max_slices = L2_CTXT_TCAM_RX_MAX_SLICES,
177 : : .row_width = L2_CTXT_TCAM_RX_ROW_WIDTH,
178 : : .num_rows = L2_CTXT_TCAM_RX_NUM_ROWS,
179 : : .start_row = 0,
180 : : .end_row = (L2_CTXT_TCAM_RX_NUM_ROWS / 2) - 1,
181 : : .max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),
182 : : .result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,
183 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,
184 : : },
185 : : { /* Low AFM */
186 : : .max_slices = L2_CTXT_TCAM_RX_MAX_SLICES,
187 : : .row_width = L2_CTXT_TCAM_RX_ROW_WIDTH,
188 : : .num_rows = 0,
189 : : .start_row = 0,
190 : : .end_row = 0,
191 : : .max_entries = 0,
192 : : .result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,
193 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,
194 : : },
195 : : { /* Low APPS */
196 : : .max_slices = L2_CTXT_TCAM_RX_MAX_SLICES,
197 : : .row_width = L2_CTXT_TCAM_RX_ROW_WIDTH,
198 : : .num_rows = L2_CTXT_TCAM_RX_NUM_ROWS,
199 : : .start_row = (L2_CTXT_TCAM_RX_NUM_ROWS / 2),
200 : : .end_row = L2_CTXT_TCAM_RX_NUM_ROWS - 1,
201 : : .max_entries = (L2_CTXT_TCAM_RX_MAX_ENTRIES / 2),
202 : : .result_size = L2_CTXT_TCAM_RX_RESULT_SIZE,
203 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,
204 : : },
205 : : { /* AFM */
206 : : .max_slices = PROF_TCAM_RX_MAX_SLICES,
207 : : .row_width = PROF_TCAM_RX_ROW_WIDTH,
208 : : .num_rows = 0,
209 : : .start_row = 0,
210 : : .end_row = 0,
211 : : .max_entries = 0,
212 : : .result_size = PROF_TCAM_RX_RESULT_SIZE,
213 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_PROF_TCAM,
214 : : },
215 : : { /* APPS */
216 : : .max_slices = PROF_TCAM_RX_MAX_SLICES,
217 : : .row_width = PROF_TCAM_RX_ROW_WIDTH,
218 : : .num_rows = PROF_TCAM_RX_NUM_ROWS,
219 : : .start_row = 0,
220 : : .end_row = PROF_TCAM_RX_NUM_ROWS - 1,
221 : : .max_entries = PROF_TCAM_RX_MAX_ENTRIES,
222 : : .result_size = PROF_TCAM_RX_RESULT_SIZE,
223 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_PROF_TCAM,
224 : : },
225 : : { /* AFM */
226 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
227 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
228 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
229 : : .start_row = 0,
230 : : .end_row = 0,
231 : : .max_entries = 0,
232 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
233 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
234 : : },
235 : : { /* APPS */
236 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
237 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
238 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
239 : : .start_row = 0,
240 : : .end_row = WC_TCAM_RX_NUM_ROWS - 1,
241 : : .max_entries = WC_TCAM_RX_MAX_ENTRIES,
242 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
243 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
244 : : },
245 : : { /* AFM */
246 : : .max_slices = SP_TCAM_RX_MAX_SLICES,
247 : : .row_width = SP_TCAM_RX_ROW_WIDTH,
248 : : .num_rows = 0,
249 : : .start_row = 0,
250 : : .end_row = 0,
251 : : .max_entries = 0,
252 : : .result_size = SP_TCAM_RX_RESULT_SIZE,
253 : : },
254 : : { /* APPS */
255 : : .max_slices = SP_TCAM_RX_MAX_SLICES,
256 : : .row_width = SP_TCAM_RX_ROW_WIDTH,
257 : : .num_rows = SP_TCAM_RX_NUM_ROWS,
258 : : .start_row = 0,
259 : : .end_row = SP_TCAM_RX_NUM_ROWS - 1,
260 : : .max_entries = SP_TCAM_RX_MAX_ENTRIES,
261 : : .result_size = SP_TCAM_RX_RESULT_SIZE,
262 : : },
263 : : { /* AFM */
264 : : .max_slices = CT_RULE_TCAM_RX_MAX_SLICES,
265 : : .row_width = CT_RULE_TCAM_RX_ROW_WIDTH,
266 : : .num_rows = CT_RULE_TCAM_RX_NUM_ROWS,
267 : : .start_row = 0,
268 : : .end_row = 0,
269 : : .max_entries = 0,
270 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
271 : : },
272 : : { /* APPS */
273 : : .max_slices = CT_RULE_TCAM_RX_MAX_SLICES,
274 : : .row_width = CT_RULE_TCAM_RX_ROW_WIDTH,
275 : : .num_rows = CT_RULE_TCAM_RX_NUM_ROWS,
276 : : .start_row = 0,
277 : : #if CT_RULE_TCAM_RX_NUM_ROWS > 0
278 : : .end_row = CT_RULE_TCAM_RX_NUM_ROWS - 1,
279 : : #else
280 : : .end_row = CT_RULE_TCAM_RX_NUM_ROWS,
281 : : #endif
282 : : .max_entries = CT_RULE_TCAM_RX_MAX_ENTRIES,
283 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
284 : : },
285 : : { /* AFM */
286 : : .max_slices = VEB_TCAM_RX_MAX_SLICES,
287 : : .row_width = VEB_TCAM_RX_ROW_WIDTH,
288 : : .num_rows = VEB_TCAM_RX_NUM_ROWS,
289 : : .start_row = 0,
290 : : .end_row = 0,
291 : : .max_entries = 0,
292 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
293 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_VEB_TCAM,
294 : : },
295 : : { /* APPS */
296 : : .max_slices = VEB_TCAM_RX_MAX_SLICES,
297 : : .row_width = VEB_TCAM_RX_ROW_WIDTH,
298 : : .num_rows = VEB_TCAM_RX_NUM_ROWS,
299 : : .start_row = 0,
300 : : #if VEB_TCAM_RX_NUM_ROWS > 0
301 : : .end_row = VEB_TCAM_RX_NUM_ROWS - 1,
302 : : #else
303 : : .end_row = VEB_TCAM_RX_NUM_ROWS,
304 : : #endif
305 : : .max_entries = VEB_TCAM_RX_MAX_ENTRIES,
306 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
307 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_VEB_TCAM,
308 : : },
309 : : { /* AFM */
310 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
311 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
312 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
313 : : .start_row = 0,
314 : : .end_row = 0,
315 : : .max_entries = 0,
316 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
317 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
318 : : },
319 : : { /* APPS */
320 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
321 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
322 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
323 : : .start_row = 0,
324 : : .end_row = WC_TCAM_RX_NUM_ROWS - 1,
325 : : .max_entries = WC_TCAM_RX_MAX_ENTRIES,
326 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
327 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
328 : : },
329 : : { /* AFM */
330 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
331 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
332 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
333 : : .start_row = 0,
334 : : .end_row = 0,
335 : : .max_entries = 0,
336 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
337 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
338 : : },
339 : : { /* APPS */
340 : : .max_slices = WC_TCAM_RX_MAX_SLICES,
341 : : .row_width = WC_TCAM_RX_ROW_WIDTH,
342 : : .num_rows = WC_TCAM_RX_NUM_ROWS,
343 : : .start_row = 0,
344 : : .end_row = WC_TCAM_RX_NUM_ROWS - 1,
345 : : .max_entries = WC_TCAM_RX_MAX_ENTRIES,
346 : : .result_size = WC_TCAM_RX_RESULT_SIZE,
347 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
348 : : },
349 : : },
350 : : { /* TX */
351 : : { /* AFM */
352 : : .max_slices = L2_CTXT_TCAM_TX_MAX_SLICES,
353 : : .row_width = L2_CTXT_TCAM_TX_ROW_WIDTH,
354 : : .num_rows = L2_CTXT_TCAM_TX_NUM_ROWS,
355 : : .start_row = 0,
356 : : .end_row = 0,
357 : : .max_entries = 0,
358 : : .result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,
359 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,
360 : : },
361 : : { /* APPS */
362 : : .max_slices = L2_CTXT_TCAM_TX_MAX_SLICES,
363 : : .row_width = L2_CTXT_TCAM_TX_ROW_WIDTH,
364 : : .num_rows = L2_CTXT_TCAM_TX_NUM_ROWS,
365 : : .start_row = 0,
366 : : .end_row = (L2_CTXT_TCAM_TX_NUM_ROWS / 2) - 1,
367 : : .max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),
368 : : .result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,
369 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH,
370 : : },
371 : : { /* AFM */
372 : : .max_slices = L2_CTXT_TCAM_TX_MAX_SLICES,
373 : : .row_width = L2_CTXT_TCAM_TX_ROW_WIDTH,
374 : : .num_rows = L2_CTXT_TCAM_TX_NUM_ROWS,
375 : : .start_row = 0,
376 : : .end_row = 0,
377 : : .max_entries = 0,
378 : : .result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,
379 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,
380 : : },
381 : : { /* APPS */
382 : : .max_slices = L2_CTXT_TCAM_TX_MAX_SLICES,
383 : : .row_width = L2_CTXT_TCAM_TX_ROW_WIDTH,
384 : : .num_rows = L2_CTXT_TCAM_TX_NUM_ROWS,
385 : : .start_row = (L2_CTXT_TCAM_TX_NUM_ROWS / 2),
386 : : .end_row = L2_CTXT_TCAM_TX_NUM_ROWS - 1,
387 : : .max_entries = (L2_CTXT_TCAM_TX_MAX_ENTRIES / 2),
388 : : .result_size = L2_CTXT_TCAM_TX_RESULT_SIZE,
389 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW,
390 : : },
391 : : { /* AFM */
392 : : .max_slices = PROF_TCAM_TX_MAX_SLICES,
393 : : .row_width = PROF_TCAM_TX_ROW_WIDTH,
394 : : .num_rows = PROF_TCAM_TX_NUM_ROWS,
395 : : .start_row = 0,
396 : : .end_row = 0,
397 : : .max_entries = 0,
398 : : .result_size = PROF_TCAM_TX_RESULT_SIZE,
399 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_PROF_TCAM,
400 : : },
401 : : { /* APPS */
402 : : .max_slices = PROF_TCAM_TX_MAX_SLICES,
403 : : .row_width = PROF_TCAM_TX_ROW_WIDTH,
404 : : .num_rows = PROF_TCAM_TX_NUM_ROWS,
405 : : .start_row = 0,
406 : : .end_row = PROF_TCAM_TX_NUM_ROWS - 1,
407 : : .max_entries = PROF_TCAM_TX_MAX_ENTRIES,
408 : : .result_size = PROF_TCAM_TX_RESULT_SIZE,
409 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_PROF_TCAM,
410 : : },
411 : : { /* AFM */
412 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
413 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
414 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
415 : : .start_row = 0,
416 : : .end_row = 0,
417 : : .max_entries = 0,
418 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
419 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
420 : : },
421 : : { /* APPS */
422 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
423 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
424 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
425 : : .start_row = 0,
426 : : .end_row = WC_TCAM_TX_NUM_ROWS - 1,
427 : : .max_entries = WC_TCAM_TX_MAX_ENTRIES,
428 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
429 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
430 : : },
431 : : { /* AFM */
432 : : .max_slices = SP_TCAM_TX_MAX_SLICES,
433 : : .row_width = SP_TCAM_TX_ROW_WIDTH,
434 : : .num_rows = SP_TCAM_TX_NUM_ROWS,
435 : : .start_row = 0,
436 : : .end_row = 0,
437 : : .max_entries = 0,
438 : : .result_size = SP_TCAM_TX_RESULT_SIZE,
439 : : },
440 : : { /* APPS */
441 : : .max_slices = SP_TCAM_TX_MAX_SLICES,
442 : : .row_width = SP_TCAM_TX_ROW_WIDTH,
443 : : .num_rows = SP_TCAM_TX_NUM_ROWS,
444 : : .start_row = 0,
445 : : .end_row = SP_TCAM_TX_NUM_ROWS - 1,
446 : : .max_entries = SP_TCAM_TX_MAX_ENTRIES,
447 : : .result_size = SP_TCAM_TX_RESULT_SIZE,
448 : : },
449 : : { /* AFM */
450 : : .max_slices = CT_RULE_TCAM_TX_MAX_SLICES,
451 : : .row_width = CT_RULE_TCAM_TX_ROW_WIDTH,
452 : : .num_rows = CT_RULE_TCAM_TX_NUM_ROWS,
453 : : .start_row = 0,
454 : : .end_row = 0,
455 : : .max_entries = 0,
456 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
457 : : },
458 : : { /* APPS */
459 : : .max_slices = CT_RULE_TCAM_TX_MAX_SLICES,
460 : : .row_width = CT_RULE_TCAM_TX_ROW_WIDTH,
461 : : .num_rows = CT_RULE_TCAM_TX_NUM_ROWS,
462 : : .start_row = 0,
463 : : #if CT_RULE_TCAM_TX_NUM_ROWS > 0
464 : : .end_row = CT_RULE_TCAM_TX_NUM_ROWS - 1,
465 : : #else
466 : : .end_row = CT_RULE_TCAM_TX_NUM_ROWS,
467 : : #endif
468 : : .max_entries = CT_RULE_TCAM_TX_MAX_ENTRIES,
469 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
470 : : },
471 : : { /* AFM */
472 : : .max_slices = VEB_TCAM_TX_MAX_SLICES,
473 : : .row_width = VEB_TCAM_TX_ROW_WIDTH,
474 : : .num_rows = VEB_TCAM_TX_NUM_ROWS,
475 : : .start_row = 0,
476 : : .end_row = 0,
477 : : .max_entries = 0,
478 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
479 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_VEB_TCAM,
480 : : },
481 : : { /* APPS */
482 : : .max_slices = VEB_TCAM_TX_MAX_SLICES,
483 : : .row_width = VEB_TCAM_TX_ROW_WIDTH,
484 : : .num_rows = VEB_TCAM_TX_NUM_ROWS,
485 : : .start_row = 0,
486 : : .end_row = VEB_TCAM_TX_NUM_ROWS - 1,
487 : : .max_entries = VEB_TCAM_TX_MAX_ENTRIES,
488 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
489 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_VEB_TCAM,
490 : : },
491 : : { /* AFM */
492 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
493 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
494 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
495 : : .start_row = 0,
496 : : .end_row = 0,
497 : : .max_entries = 0,
498 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
499 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
500 : : },
501 : : { /* APPS */
502 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
503 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
504 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
505 : : .start_row = 0,
506 : : .end_row = WC_TCAM_TX_NUM_ROWS - 1,
507 : : .max_entries = WC_TCAM_TX_MAX_ENTRIES,
508 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
509 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
510 : : },
511 : : { /* AFM */
512 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
513 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
514 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
515 : : .start_row = 0,
516 : : .end_row = 0,
517 : : .max_entries = 0,
518 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
519 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
520 : : },
521 : : { /* APPS */
522 : : .max_slices = WC_TCAM_TX_MAX_SLICES,
523 : : .row_width = WC_TCAM_TX_ROW_WIDTH,
524 : : .num_rows = WC_TCAM_TX_NUM_ROWS,
525 : : .start_row = 0,
526 : : .end_row = WC_TCAM_TX_NUM_ROWS - 1,
527 : : .max_entries = WC_TCAM_TX_MAX_ENTRIES,
528 : : .result_size = WC_TCAM_TX_RESULT_SIZE,
529 : : .hcapi_type = CFA_RESOURCE_TYPE_P58_WC_TCAM,
530 : : },
531 : : },
532 : : };
533 : :
534 : : static struct cfa_tcam_mgr_entry_data entry_data_p58[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];
535 : :
536 : : static struct sbmp session_bmp_p58[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];
537 : :
538 : : int
539 : 0 : cfa_tcam_mgr_sess_table_get_p58(int sess_idx, struct sbmp **session_bmp)
540 : : {
541 : 0 : *session_bmp = session_bmp_p58[sess_idx];
542 : 0 : return 0;
543 : : }
544 : :
545 : : int
546 : 0 : cfa_tcam_mgr_init_p58(int sess_idx, struct cfa_tcam_mgr_entry_data **global_entry_data)
547 : : {
548 : : int max_row_width = 0;
549 : : int max_result_size = 0;
550 : : int dir, type;
551 : :
552 : 0 : *global_entry_data = entry_data_p58[sess_idx];
553 : :
554 : 0 : memcpy(&cfa_tcam_mgr_tables[sess_idx],
555 : : &cfa_tcam_mgr_tables_p58,
556 : : sizeof(cfa_tcam_mgr_tables[sess_idx]));
557 : :
558 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
559 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =
560 : : (struct cfa_tcam_mgr_table_rows_0 *)
561 : 0 : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];
562 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
563 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =
564 : : (struct cfa_tcam_mgr_table_rows_0 *)
565 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];
566 : :
567 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
568 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM].tcam_rows =
569 : : (struct cfa_tcam_mgr_table_rows_0 *)
570 : 0 : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];
571 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
572 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS].tcam_rows =
573 : : (struct cfa_tcam_mgr_table_rows_0 *)
574 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];
575 : :
576 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
577 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =
578 : : (struct cfa_tcam_mgr_table_rows_0 *)
579 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];
580 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
581 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =
582 : : (struct cfa_tcam_mgr_table_rows_0 *)
583 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_RX[sess_idx];
584 : :
585 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
586 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM].tcam_rows =
587 : : (struct cfa_tcam_mgr_table_rows_0 *)
588 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];
589 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
590 : 0 : [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS].tcam_rows =
591 : : (struct cfa_tcam_mgr_table_rows_0 *)
592 : : &cfa_tcam_mgr_table_rows_L2_CTXT_TCAM_TX[sess_idx];
593 : :
594 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
595 : 0 : [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =
596 : : (struct cfa_tcam_mgr_table_rows_0 *)
597 : 0 : &cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];
598 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
599 : 0 : [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =
600 : : (struct cfa_tcam_mgr_table_rows_0 *)
601 : : &cfa_tcam_mgr_table_rows_PROF_TCAM_RX[sess_idx];
602 : :
603 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
604 : 0 : [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM].tcam_rows =
605 : : (struct cfa_tcam_mgr_table_rows_0 *)
606 : 0 : &cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];
607 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
608 : 0 : [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS].tcam_rows =
609 : : (struct cfa_tcam_mgr_table_rows_0 *)
610 : : &cfa_tcam_mgr_table_rows_PROF_TCAM_TX[sess_idx];
611 : :
612 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
613 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =
614 : : (struct cfa_tcam_mgr_table_rows_0 *)
615 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];
616 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
617 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =
618 : : (struct cfa_tcam_mgr_table_rows_0 *)
619 : : &cfa_tcam_mgr_table_rows_WC_TCAM_RX[sess_idx];
620 : :
621 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
622 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM].tcam_rows =
623 : : (struct cfa_tcam_mgr_table_rows_0 *)
624 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];
625 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
626 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS].tcam_rows =
627 : : (struct cfa_tcam_mgr_table_rows_0 *)
628 : : &cfa_tcam_mgr_table_rows_WC_TCAM_TX[sess_idx];
629 : :
630 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
631 : 0 : [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =
632 : : (struct cfa_tcam_mgr_table_rows_0 *)
633 : 0 : &cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];
634 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
635 : 0 : [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =
636 : : (struct cfa_tcam_mgr_table_rows_0 *)
637 : : &cfa_tcam_mgr_table_rows_SP_TCAM_RX[sess_idx];
638 : :
639 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
640 : 0 : [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM].tcam_rows =
641 : : (struct cfa_tcam_mgr_table_rows_0 *)
642 : 0 : &cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];
643 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
644 : 0 : [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS].tcam_rows =
645 : : (struct cfa_tcam_mgr_table_rows_0 *)
646 : : &cfa_tcam_mgr_table_rows_SP_TCAM_TX[sess_idx];
647 : :
648 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
649 : 0 : [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =
650 : : (struct cfa_tcam_mgr_table_rows_0 *)
651 : 0 : &cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];
652 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
653 : 0 : [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =
654 : : (struct cfa_tcam_mgr_table_rows_0 *)
655 : : &cfa_tcam_mgr_table_rows_CT_RULE_TCAM_RX[sess_idx];
656 : :
657 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
658 : 0 : [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM].tcam_rows =
659 : : (struct cfa_tcam_mgr_table_rows_0 *)
660 : 0 : &cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];
661 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
662 : 0 : [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS].tcam_rows =
663 : : (struct cfa_tcam_mgr_table_rows_0 *)
664 : : &cfa_tcam_mgr_table_rows_CT_RULE_TCAM_TX[sess_idx];
665 : :
666 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
667 : 0 : [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =
668 : : (struct cfa_tcam_mgr_table_rows_0 *)
669 : 0 : &cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];
670 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
671 : 0 : [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =
672 : : (struct cfa_tcam_mgr_table_rows_0 *)
673 : : &cfa_tcam_mgr_table_rows_VEB_TCAM_RX[sess_idx];
674 : :
675 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
676 : 0 : [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM].tcam_rows =
677 : : (struct cfa_tcam_mgr_table_rows_0 *)
678 : 0 : &cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];
679 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
680 : 0 : [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS].tcam_rows =
681 : : (struct cfa_tcam_mgr_table_rows_0 *)
682 : : &cfa_tcam_mgr_table_rows_VEB_TCAM_TX[sess_idx];
683 : :
684 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
685 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =
686 : : (struct cfa_tcam_mgr_table_rows_0 *)
687 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];
688 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
689 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =
690 : : (struct cfa_tcam_mgr_table_rows_0 *)
691 : : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];
692 : :
693 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
694 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =
695 : : (struct cfa_tcam_mgr_table_rows_0 *)
696 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];
697 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
698 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =
699 : : (struct cfa_tcam_mgr_table_rows_0 *)
700 : : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];
701 : :
702 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
703 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =
704 : : (struct cfa_tcam_mgr_table_rows_0 *)
705 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];
706 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
707 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =
708 : : (struct cfa_tcam_mgr_table_rows_0 *)
709 : : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];
710 : :
711 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
712 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =
713 : : (struct cfa_tcam_mgr_table_rows_0 *)
714 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];
715 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
716 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =
717 : : (struct cfa_tcam_mgr_table_rows_0 *)
718 : : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];
719 : :
720 [ # # ]: 0 : for (dir = 0; dir < TF_DIR_MAX; dir++) {
721 [ # # ]: 0 : for (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {
722 : 0 : if (cfa_tcam_mgr_tables[sess_idx][dir][type].row_width >
723 : : max_row_width)
724 : : max_row_width =
725 : : cfa_tcam_mgr_tables[sess_idx][dir][type].row_width;
726 : 0 : if (cfa_tcam_mgr_tables[sess_idx][dir][type].result_size >
727 : : max_result_size)
728 : : max_result_size =
729 : : cfa_tcam_mgr_tables[sess_idx][dir][type].result_size;
730 : : }
731 : : }
732 : :
733 [ # # ]: 0 : if (max_row_width != MAX_ROW_WIDTH) {
734 : 0 : CFA_TCAM_MGR_LOG(ERR,
735 : : "MAX_ROW_WIDTH (%d) does not match actual "
736 : : "value (%d).\n",
737 : : MAX_ROW_WIDTH,
738 : : max_row_width);
739 : 0 : return -CFA_TCAM_MGR_ERR_CODE(INVAL);
740 : : }
741 [ # # ]: 0 : if (max_result_size != MAX_RESULT_SIZE) {
742 : 0 : CFA_TCAM_MGR_LOG(ERR,
743 : : "MAX_RESULT_SIZE (%d) does not match actual "
744 : : "value (%d).\n",
745 : : MAX_RESULT_SIZE,
746 : : max_result_size);
747 : 0 : return -CFA_TCAM_MGR_ERR_CODE(INVAL);
748 : : }
749 : : return 0;
750 : : }
751 : :
752 : : /* HW OP declarations begin here */
753 : :
754 : : struct cfa_tcam_mgr_TCAM_row_data {
755 : : int key_size;
756 : : int result_size;
757 : : uint8_t key[MAX_ROW_WIDTH];
758 : : uint8_t mask[MAX_ROW_WIDTH];
759 : : uint8_t result[MAX_RESULT_SIZE];
760 : : };
761 : :
762 : : /* These macros are only needed to avoid exceeding 80 columns */
763 : : #define L2_CTXT_RX_MAX_ROWS \
764 : : (L2_CTXT_TCAM_RX_MAX_SLICES * L2_CTXT_TCAM_RX_NUM_ROWS)
765 : : #define PROF_RX_MAX_ROWS (PROF_TCAM_RX_MAX_SLICES * PROF_TCAM_RX_NUM_ROWS)
766 : : #define WC_RX_MAX_ROWS (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)
767 : : #define SP_RX_MAX_ROWS (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)
768 : : #define CT_RULE_RX_MAX_ROWS \
769 : : (CT_RULE_TCAM_RX_MAX_SLICES * CT_RULE_TCAM_RX_NUM_ROWS)
770 : : #define VEB_RX_MAX_ROWS (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)
771 : :
772 : : #define L2_CTXT_TX_MAX_ROWS \
773 : : (L2_CTXT_TCAM_TX_MAX_SLICES * L2_CTXT_TCAM_TX_NUM_ROWS)
774 : : #define PROF_TX_MAX_ROWS (PROF_TCAM_TX_MAX_SLICES * PROF_TCAM_TX_NUM_ROWS)
775 : : #define WC_TX_MAX_ROWS (WC_TCAM_TX_MAX_SLICES * WC_TCAM_TX_NUM_ROWS)
776 : : #define SP_TX_MAX_ROWS (SP_TCAM_TX_MAX_SLICES * SP_TCAM_TX_NUM_ROWS)
777 : : #define CT_RULE_TX_MAX_ROWS \
778 : : (CT_RULE_TCAM_TX_MAX_SLICES * CT_RULE_TCAM_TX_NUM_ROWS)
779 : : #define VEB_TX_MAX_ROWS (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)
780 : :
781 : : static int cfa_tcam_mgr_max_rows[TF_TCAM_TBL_TYPE_MAX] = {
782 : : L2_CTXT_RX_MAX_ROWS,
783 : : L2_CTXT_RX_MAX_ROWS,
784 : : PROF_RX_MAX_ROWS,
785 : : WC_RX_MAX_ROWS,
786 : : SP_RX_MAX_ROWS,
787 : : CT_RULE_RX_MAX_ROWS,
788 : : VEB_RX_MAX_ROWS,
789 : : WC_RX_MAX_ROWS,
790 : : WC_RX_MAX_ROWS
791 : : };
792 : :
793 : : static struct cfa_tcam_mgr_TCAM_row_data
794 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_RX_MAX_ROWS];
795 : : static struct cfa_tcam_mgr_TCAM_row_data
796 : : cfa_tcam_mgr_PROF_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][PROF_RX_MAX_ROWS];
797 : : static struct cfa_tcam_mgr_TCAM_row_data
798 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];
799 : : static struct cfa_tcam_mgr_TCAM_row_data
800 : : cfa_tcam_mgr_SP_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][SP_RX_MAX_ROWS];
801 : : static struct cfa_tcam_mgr_TCAM_row_data
802 : : cfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_RX_MAX_ROWS];
803 : : static struct cfa_tcam_mgr_TCAM_row_data
804 : : cfa_tcam_mgr_VEB_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][VEB_RX_MAX_ROWS];
805 : : static struct cfa_tcam_mgr_TCAM_row_data
806 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];
807 : :
808 : : static struct cfa_tcam_mgr_TCAM_row_data
809 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_TX_MAX_ROWS];
810 : : static struct cfa_tcam_mgr_TCAM_row_data
811 : : cfa_tcam_mgr_PROF_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][PROF_TX_MAX_ROWS];
812 : : static struct cfa_tcam_mgr_TCAM_row_data
813 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];
814 : : static struct cfa_tcam_mgr_TCAM_row_data
815 : : cfa_tcam_mgr_SP_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][SP_TX_MAX_ROWS];
816 : : static struct cfa_tcam_mgr_TCAM_row_data
817 : : cfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_TX_MAX_ROWS];
818 : : static struct cfa_tcam_mgr_TCAM_row_data
819 : : cfa_tcam_mgr_VEB_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][VEB_TX_MAX_ROWS];
820 : : static struct cfa_tcam_mgr_TCAM_row_data
821 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];
822 : :
823 : : static struct cfa_tcam_mgr_TCAM_row_data *
824 : : row_tables[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX] = {
825 : : {
826 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],
827 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],
828 : : cfa_tcam_mgr_PROF_TCAM_RX_row_data[0],
829 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
830 : : cfa_tcam_mgr_SP_TCAM_RX_row_data[0],
831 : : cfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[0],
832 : : cfa_tcam_mgr_VEB_TCAM_RX_row_data[0],
833 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
834 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
835 : : },
836 : : {
837 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],
838 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],
839 : : cfa_tcam_mgr_PROF_TCAM_TX_row_data[0],
840 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
841 : : cfa_tcam_mgr_SP_TCAM_TX_row_data[0],
842 : : cfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[0],
843 : : cfa_tcam_mgr_VEB_TCAM_TX_row_data[0],
844 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
845 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
846 : : }
847 : : };
848 : :
849 : : static int cfa_tcam_mgr_get_max_rows(enum tf_tcam_tbl_type type)
850 : : {
851 : 0 : if (type >= TF_TCAM_TBL_TYPE_MAX)
852 : 0 : assert(0);
853 : : else
854 : 0 : return cfa_tcam_mgr_max_rows[type];
855 : : }
856 : :
857 : 0 : static int cfa_tcam_mgr_hwop_set(int sess_idx,
858 : : struct cfa_tcam_mgr_set_parms *parms, int row,
859 : : int slice, int max_slices)
860 : : {
861 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
862 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
863 : 0 : this_table = row_tables[parms->dir]
864 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
865 : 0 : this_table += (sess_idx *
866 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
867 : 0 : this_row = &this_table[row * max_slices + slice];
868 : 0 : this_row->key_size = parms->key_size;
869 [ # # ]: 0 : memcpy(&this_row->key, parms->key, parms->key_size);
870 : 0 : memcpy(&this_row->mask, parms->mask, parms->key_size);
871 : 0 : this_row->result_size = parms->result_size;
872 [ # # ]: 0 : if (parms->result != ((void *)0))
873 : 0 : memcpy(&this_row->result, parms->result, parms->result_size);
874 : 0 : return 0;
875 : : };
876 : :
877 : 0 : static int cfa_tcam_mgr_hwop_get(int sess_idx,
878 : : struct cfa_tcam_mgr_get_parms *parms, int row,
879 : : int slice, int max_slices)
880 : : {
881 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
882 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
883 : 0 : this_table = row_tables[parms->dir]
884 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
885 : 0 : this_table += (sess_idx *
886 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
887 : 0 : this_row = &this_table[row * max_slices + slice];
888 : 0 : parms->key_size = this_row->key_size;
889 : 0 : parms->result_size = this_row->result_size;
890 [ # # ]: 0 : if (parms->key != ((void *)0))
891 : 0 : memcpy(parms->key, &this_row->key, parms->key_size);
892 [ # # ]: 0 : if (parms->mask != ((void *)0))
893 : 0 : memcpy(parms->mask, &this_row->mask, parms->key_size);
894 [ # # ]: 0 : if (parms->result != ((void *)0))
895 : 0 : memcpy(parms->result, &this_row->result, parms->result_size);
896 : 0 : return 0;
897 : : };
898 : :
899 : 0 : static int cfa_tcam_mgr_hwop_free(int sess_idx,
900 : : struct cfa_tcam_mgr_free_parms *parms,
901 : : int row, int slice, int max_slices)
902 : : {
903 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
904 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
905 : 0 : this_table = row_tables[parms->dir]
906 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
907 : 0 : this_table += (sess_idx *
908 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
909 : 0 : this_row = &this_table[row * max_slices + slice];
910 : 0 : memset(&this_row->key, 0, sizeof(this_row->key));
911 : 0 : memset(&this_row->mask, 0, sizeof(this_row->mask));
912 : 0 : memset(&this_row->result, 0, sizeof(this_row->result));
913 : 0 : this_row->key_size = 0;
914 : 0 : this_row->result_size = 0;
915 : 0 : return 0;
916 : : };
917 : :
918 : 0 : int cfa_tcam_mgr_hwops_get_funcs_p58(struct cfa_tcam_mgr_hwops_funcs
919 : : *hwop_funcs)
920 : : {
921 : 0 : hwop_funcs->set = cfa_tcam_mgr_hwop_set;
922 : 0 : hwop_funcs->get = cfa_tcam_mgr_hwop_get;
923 : 0 : hwop_funcs->free = cfa_tcam_mgr_hwop_free;
924 : 0 : return 0;
925 : : }
|