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_p4.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 P4
18 : : */
19 : :
20 : : #define MAX_ROW_WIDTH 48
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_WORD_ALIGN(167)
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_WORD_ALIGN(81)
53 : : #define PROF_TCAM_RX_NUM_ROWS 1024
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 : : /* 82 bits per slice */
67 : : #define WC_TCAM_RX_ROW_WIDTH (TF_BITS2BYTES_WORD_ALIGN(82) * \
68 : : WC_TCAM_RX_MAX_SLICES)
69 : : #define WC_TCAM_RX_NUM_ROWS 256
70 : : #define WC_TCAM_RX_MAX_ENTRIES (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)
71 : : #define WC_TCAM_RX_RESULT_SIZE 4
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_WORD_ALIGN(89)
82 : : #define SP_TCAM_RX_NUM_ROWS 512
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_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(78)
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_p4[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 = L2_CTXT_TCAM_RX_NUM_ROWS,
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_P4_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_P4_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 = L2_CTXT_TCAM_RX_NUM_ROWS,
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_P4_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_P4_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 = PROF_TCAM_RX_NUM_ROWS,
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_P4_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_P4_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_P4_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_P4_WC_TCAM,
244 : : },
245 : : { /* AFM */
246 : : .max_slices = SP_TCAM_RX_MAX_SLICES,
247 : : .row_width = SP_TCAM_RX_ROW_WIDTH,
248 : : .num_rows = SP_TCAM_RX_NUM_ROWS,
249 : : .start_row = 0,
250 : : .end_row = 0,
251 : : .max_entries = 0,
252 : : .result_size = SP_TCAM_RX_RESULT_SIZE,
253 : : .hcapi_type = CFA_RESOURCE_TYPE_P4_SP_TCAM,
254 : : },
255 : : { /* APPS */
256 : : .max_slices = SP_TCAM_RX_MAX_SLICES,
257 : : .row_width = SP_TCAM_RX_ROW_WIDTH,
258 : : .num_rows = SP_TCAM_RX_NUM_ROWS,
259 : : .start_row = 0,
260 : : .end_row = SP_TCAM_RX_NUM_ROWS - 1,
261 : : .max_entries = SP_TCAM_RX_MAX_ENTRIES,
262 : : .result_size = SP_TCAM_RX_RESULT_SIZE,
263 : : .hcapi_type = CFA_RESOURCE_TYPE_P4_SP_TCAM,
264 : : },
265 : : { /* AFM */
266 : : .max_slices = CT_RULE_TCAM_RX_MAX_SLICES,
267 : : .row_width = CT_RULE_TCAM_RX_ROW_WIDTH,
268 : : .num_rows = CT_RULE_TCAM_RX_NUM_ROWS,
269 : : .start_row = 0,
270 : : .end_row = 0,
271 : : .max_entries = 0,
272 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
273 : : },
274 : : { /* APPS */
275 : : .max_slices = CT_RULE_TCAM_RX_MAX_SLICES,
276 : : .row_width = CT_RULE_TCAM_RX_ROW_WIDTH,
277 : : .num_rows = CT_RULE_TCAM_RX_NUM_ROWS,
278 : : .start_row = 0,
279 : : #if CT_RULE_TCAM_RX_NUM_ROWS > 0
280 : : .end_row = CT_RULE_TCAM_RX_NUM_ROWS - 1,
281 : : #else
282 : : .end_row = CT_RULE_TCAM_RX_NUM_ROWS,
283 : : #endif
284 : : .max_entries = CT_RULE_TCAM_RX_MAX_ENTRIES,
285 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
286 : : },
287 : : { /* AFM */
288 : : .max_slices = VEB_TCAM_RX_MAX_SLICES,
289 : : .row_width = VEB_TCAM_RX_ROW_WIDTH,
290 : : .num_rows = VEB_TCAM_RX_NUM_ROWS,
291 : : .start_row = 0,
292 : : .end_row = 0,
293 : : .max_entries = 0,
294 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
295 : : },
296 : : { /* APPS */
297 : : .max_slices = VEB_TCAM_RX_MAX_SLICES,
298 : : .row_width = VEB_TCAM_RX_ROW_WIDTH,
299 : : .num_rows = VEB_TCAM_RX_NUM_ROWS,
300 : : .start_row = 0,
301 : : #if VEB_TCAM_RX_NUM_ROWS > 0
302 : : .end_row = VEB_TCAM_RX_NUM_ROWS - 1,
303 : : #else
304 : : .end_row = VEB_TCAM_RX_NUM_ROWS,
305 : : #endif
306 : : .max_entries = VEB_TCAM_RX_MAX_ENTRIES,
307 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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_P4_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 : : .hcapi_type = CFA_RESOURCE_TYPE_P4_SP_TCAM,
440 : : },
441 : : { /* APPS */
442 : : .max_slices = SP_TCAM_TX_MAX_SLICES,
443 : : .row_width = SP_TCAM_TX_ROW_WIDTH,
444 : : .num_rows = SP_TCAM_TX_NUM_ROWS,
445 : : .start_row = 0,
446 : : .end_row = SP_TCAM_TX_NUM_ROWS - 1,
447 : : .max_entries = SP_TCAM_TX_MAX_ENTRIES,
448 : : .result_size = SP_TCAM_TX_RESULT_SIZE,
449 : : .hcapi_type = CFA_RESOURCE_TYPE_P4_SP_TCAM,
450 : : },
451 : : { /* AFM */
452 : : .max_slices = CT_RULE_TCAM_TX_MAX_SLICES,
453 : : .row_width = CT_RULE_TCAM_TX_ROW_WIDTH,
454 : : .num_rows = CT_RULE_TCAM_TX_NUM_ROWS,
455 : : .start_row = 0,
456 : : .end_row = 0,
457 : : .max_entries = 0,
458 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
459 : : },
460 : : { /* APPS */
461 : : .max_slices = CT_RULE_TCAM_TX_MAX_SLICES,
462 : : .row_width = CT_RULE_TCAM_TX_ROW_WIDTH,
463 : : .num_rows = CT_RULE_TCAM_TX_NUM_ROWS,
464 : : .start_row = 0,
465 : : #if CT_RULE_TCAM_TX_NUM_ROWS > 0
466 : : .end_row = CT_RULE_TCAM_TX_NUM_ROWS - 1,
467 : : #else
468 : : .end_row = CT_RULE_TCAM_TX_NUM_ROWS,
469 : : #endif
470 : : .max_entries = CT_RULE_TCAM_TX_MAX_ENTRIES,
471 : : .result_size = CT_RULE_TCAM_RX_RESULT_SIZE,
472 : : },
473 : : { /* AFM */
474 : : .max_slices = VEB_TCAM_TX_MAX_SLICES,
475 : : .row_width = VEB_TCAM_TX_ROW_WIDTH,
476 : : .num_rows = VEB_TCAM_TX_NUM_ROWS,
477 : : .start_row = 0,
478 : : .end_row = 0,
479 : : .max_entries = 0,
480 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
481 : : },
482 : : { /* APPS */
483 : : .max_slices = VEB_TCAM_TX_MAX_SLICES,
484 : : .row_width = VEB_TCAM_TX_ROW_WIDTH,
485 : : .num_rows = VEB_TCAM_TX_NUM_ROWS,
486 : : .start_row = 0,
487 : : .end_row = VEB_TCAM_TX_NUM_ROWS - 1,
488 : : .max_entries = VEB_TCAM_TX_MAX_ENTRIES,
489 : : .result_size = VEB_TCAM_RX_RESULT_SIZE,
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_P4_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_P4_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_P4_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_P4_WC_TCAM,
530 : : },
531 : : },
532 : : };
533 : :
534 : : static struct cfa_tcam_mgr_entry_data entry_data_p4[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];
535 : :
536 : : static struct sbmp session_bmp_p4[TF_TCAM_MAX_SESSIONS][TF_TCAM_MAX_ENTRIES];
537 : :
538 : : int
539 : 0 : cfa_tcam_mgr_sess_table_get_p4(int sess_idx, struct sbmp **session_bmp)
540 : : {
541 : 0 : *session_bmp = session_bmp_p4[sess_idx];
542 : 0 : return 0;
543 : : }
544 : :
545 : : int
546 : 0 : cfa_tcam_mgr_init_p4(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_p4[sess_idx];
553 : :
554 : 0 : memcpy(&cfa_tcam_mgr_tables[sess_idx],
555 : : &cfa_tcam_mgr_tables_p4,
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 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
684 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =
685 : : (struct cfa_tcam_mgr_table_rows_0 *)
686 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];
687 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
688 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =
689 : : (struct cfa_tcam_mgr_table_rows_0 *)
690 : : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_HIGH[sess_idx];
691 : :
692 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
693 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM].tcam_rows =
694 : : (struct cfa_tcam_mgr_table_rows_0 *)
695 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];
696 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
697 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS].tcam_rows =
698 : : (struct cfa_tcam_mgr_table_rows_0 *)
699 : : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_HIGH[sess_idx];
700 : :
701 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
702 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =
703 : : (struct cfa_tcam_mgr_table_rows_0 *)
704 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];
705 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_RX]
706 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =
707 : : (struct cfa_tcam_mgr_table_rows_0 *)
708 : : &cfa_tcam_mgr_table_rows_WC_TCAM_RX_LOW[sess_idx];
709 : :
710 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
711 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM].tcam_rows =
712 : : (struct cfa_tcam_mgr_table_rows_0 *)
713 : 0 : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];
714 : : cfa_tcam_mgr_tables[sess_idx][TF_DIR_TX]
715 : 0 : [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS].tcam_rows =
716 : : (struct cfa_tcam_mgr_table_rows_0 *)
717 : : &cfa_tcam_mgr_table_rows_WC_TCAM_TX_LOW[sess_idx];
718 : :
719 [ # # ]: 0 : for (dir = 0; dir < TF_DIR_MAX; dir++) {
720 [ # # ]: 0 : for (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {
721 : 0 : if (cfa_tcam_mgr_tables[sess_idx][dir][type].row_width >
722 : : max_row_width)
723 : : max_row_width =
724 : : cfa_tcam_mgr_tables[sess_idx][dir][type].row_width;
725 : 0 : if (cfa_tcam_mgr_tables[sess_idx][dir][type].result_size >
726 : : max_result_size)
727 : : max_result_size =
728 : : cfa_tcam_mgr_tables[sess_idx][dir][type].result_size;
729 : : }
730 : : }
731 : :
732 [ # # ]: 0 : if (max_row_width != MAX_ROW_WIDTH) {
733 : 0 : CFA_TCAM_MGR_LOG(ERR,
734 : : "MAX_ROW_WIDTH (%d) does not match actual "
735 : : "value (%d).\n",
736 : : MAX_ROW_WIDTH,
737 : : max_row_width);
738 : 0 : return -CFA_TCAM_MGR_ERR_CODE(INVAL);
739 : : }
740 [ # # ]: 0 : if (max_result_size != MAX_RESULT_SIZE) {
741 : 0 : CFA_TCAM_MGR_LOG(ERR,
742 : : "MAX_RESULT_SIZE (%d) does not match actual "
743 : : "value (%d).\n",
744 : : MAX_RESULT_SIZE,
745 : : max_result_size);
746 : 0 : return -CFA_TCAM_MGR_ERR_CODE(INVAL);
747 : : }
748 : : return 0;
749 : : }
750 : :
751 : : /* HW OP declarations begin here */
752 : : struct cfa_tcam_mgr_TCAM_row_data {
753 : : int key_size;
754 : : int result_size;
755 : : uint8_t key[MAX_ROW_WIDTH];
756 : : uint8_t mask[MAX_ROW_WIDTH];
757 : : uint8_t result[MAX_RESULT_SIZE];
758 : : };
759 : :
760 : : /* These macros are only needed to avoid exceeding 80 columns */
761 : : #define L2_CTXT_RX_MAX_ROWS \
762 : : (L2_CTXT_TCAM_RX_MAX_SLICES * L2_CTXT_TCAM_RX_NUM_ROWS)
763 : : #define PROF_RX_MAX_ROWS (PROF_TCAM_RX_MAX_SLICES * PROF_TCAM_RX_NUM_ROWS)
764 : : #define WC_RX_MAX_ROWS (WC_TCAM_RX_MAX_SLICES * WC_TCAM_RX_NUM_ROWS)
765 : : #define SP_RX_MAX_ROWS (SP_TCAM_RX_MAX_SLICES * SP_TCAM_RX_NUM_ROWS)
766 : : #define CT_RULE_RX_MAX_ROWS \
767 : : (CT_RULE_TCAM_RX_MAX_SLICES * CT_RULE_TCAM_RX_NUM_ROWS)
768 : : #define VEB_RX_MAX_ROWS (VEB_TCAM_RX_MAX_SLICES * VEB_TCAM_RX_NUM_ROWS)
769 : :
770 : : #define L2_CTXT_TX_MAX_ROWS \
771 : : (L2_CTXT_TCAM_TX_MAX_SLICES * L2_CTXT_TCAM_TX_NUM_ROWS)
772 : : #define PROF_TX_MAX_ROWS (PROF_TCAM_TX_MAX_SLICES * PROF_TCAM_TX_NUM_ROWS)
773 : : #define WC_TX_MAX_ROWS (WC_TCAM_TX_MAX_SLICES * WC_TCAM_TX_NUM_ROWS)
774 : : #define SP_TX_MAX_ROWS (SP_TCAM_TX_MAX_SLICES * SP_TCAM_TX_NUM_ROWS)
775 : : #define CT_RULE_TX_MAX_ROWS \
776 : : (CT_RULE_TCAM_TX_MAX_SLICES * CT_RULE_TCAM_TX_NUM_ROWS)
777 : : #define VEB_TX_MAX_ROWS (VEB_TCAM_TX_MAX_SLICES * VEB_TCAM_TX_NUM_ROWS)
778 : :
779 : : static int cfa_tcam_mgr_max_rows[TF_TCAM_TBL_TYPE_MAX] = {
780 : : L2_CTXT_RX_MAX_ROWS,
781 : : L2_CTXT_RX_MAX_ROWS,
782 : : PROF_RX_MAX_ROWS,
783 : : WC_RX_MAX_ROWS,
784 : : SP_RX_MAX_ROWS,
785 : : CT_RULE_RX_MAX_ROWS,
786 : : VEB_RX_MAX_ROWS,
787 : : WC_RX_MAX_ROWS,
788 : : WC_RX_MAX_ROWS
789 : : };
790 : : static struct cfa_tcam_mgr_TCAM_row_data
791 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_RX_MAX_ROWS];
792 : : static struct cfa_tcam_mgr_TCAM_row_data
793 : : cfa_tcam_mgr_PROF_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][PROF_RX_MAX_ROWS];
794 : : static struct cfa_tcam_mgr_TCAM_row_data
795 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];
796 : : static struct cfa_tcam_mgr_TCAM_row_data
797 : : cfa_tcam_mgr_SP_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][SP_RX_MAX_ROWS];
798 : : static struct cfa_tcam_mgr_TCAM_row_data
799 : : cfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_RX_MAX_ROWS];
800 : : static struct cfa_tcam_mgr_TCAM_row_data
801 : : cfa_tcam_mgr_VEB_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][VEB_RX_MAX_ROWS];
802 : : static struct cfa_tcam_mgr_TCAM_row_data
803 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[TF_TCAM_MAX_SESSIONS][WC_RX_MAX_ROWS];
804 : :
805 : : static struct cfa_tcam_mgr_TCAM_row_data
806 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][L2_CTXT_TX_MAX_ROWS];
807 : : static struct cfa_tcam_mgr_TCAM_row_data
808 : : cfa_tcam_mgr_PROF_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][PROF_TX_MAX_ROWS];
809 : : static struct cfa_tcam_mgr_TCAM_row_data
810 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];
811 : : static struct cfa_tcam_mgr_TCAM_row_data
812 : : cfa_tcam_mgr_SP_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][SP_TX_MAX_ROWS];
813 : : static struct cfa_tcam_mgr_TCAM_row_data
814 : : cfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][CT_RULE_TX_MAX_ROWS];
815 : : static struct cfa_tcam_mgr_TCAM_row_data
816 : : cfa_tcam_mgr_VEB_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][VEB_TX_MAX_ROWS];
817 : : static struct cfa_tcam_mgr_TCAM_row_data
818 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[TF_TCAM_MAX_SESSIONS][WC_TX_MAX_ROWS];
819 : :
820 : : static struct cfa_tcam_mgr_TCAM_row_data *
821 : : row_tables[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX] = {
822 : : {
823 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],
824 : : cfa_tcam_mgr_L2_CTXT_TCAM_RX_row_data[0],
825 : : cfa_tcam_mgr_PROF_TCAM_RX_row_data[0],
826 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
827 : : cfa_tcam_mgr_SP_TCAM_RX_row_data[0],
828 : : cfa_tcam_mgr_CT_RULE_TCAM_RX_row_data[0],
829 : : cfa_tcam_mgr_VEB_TCAM_RX_row_data[0],
830 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
831 : : cfa_tcam_mgr_WC_TCAM_RX_row_data[0],
832 : : },
833 : : {
834 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],
835 : : cfa_tcam_mgr_L2_CTXT_TCAM_TX_row_data[0],
836 : : cfa_tcam_mgr_PROF_TCAM_TX_row_data[0],
837 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
838 : : cfa_tcam_mgr_SP_TCAM_TX_row_data[0],
839 : : cfa_tcam_mgr_CT_RULE_TCAM_TX_row_data[0],
840 : : cfa_tcam_mgr_VEB_TCAM_TX_row_data[0],
841 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
842 : : cfa_tcam_mgr_WC_TCAM_TX_row_data[0],
843 : : }
844 : : };
845 : :
846 : : static int cfa_tcam_mgr_get_max_rows(enum tf_tcam_tbl_type type)
847 : : {
848 : 0 : if (type >= TF_TCAM_TBL_TYPE_MAX)
849 : 0 : assert(0);
850 : : else
851 : 0 : return cfa_tcam_mgr_max_rows[type];
852 : : }
853 : :
854 : 0 : static int cfa_tcam_mgr_hwop_set(int sess_idx,
855 : : struct cfa_tcam_mgr_set_parms *parms, int row,
856 : : int slice, int max_slices)
857 : : {
858 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
859 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
860 : 0 : this_table = row_tables[parms->dir]
861 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
862 : 0 : this_table += (sess_idx *
863 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
864 : 0 : this_row = &this_table[row * max_slices + slice];
865 : 0 : this_row->key_size = parms->key_size;
866 [ # # ]: 0 : memcpy(&this_row->key, parms->key, parms->key_size);
867 : 0 : memcpy(&this_row->mask, parms->mask, parms->key_size);
868 : 0 : this_row->result_size = parms->result_size;
869 [ # # ]: 0 : if (parms->result != ((void *)0))
870 : 0 : memcpy(&this_row->result, parms->result, parms->result_size);
871 : 0 : return 0;
872 : : };
873 : :
874 : 0 : static int cfa_tcam_mgr_hwop_get(int sess_idx,
875 : : struct cfa_tcam_mgr_get_parms *parms, int row,
876 : : int slice, int max_slices)
877 : : {
878 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
879 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
880 : 0 : this_table = row_tables[parms->dir]
881 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
882 : 0 : this_table += (sess_idx *
883 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
884 : 0 : this_row = &this_table[row * max_slices + slice];
885 : 0 : parms->key_size = this_row->key_size;
886 : 0 : parms->result_size = this_row->result_size;
887 [ # # ]: 0 : if (parms->key != ((void *)0))
888 : 0 : memcpy(parms->key, &this_row->key, parms->key_size);
889 [ # # ]: 0 : if (parms->mask != ((void *)0))
890 : 0 : memcpy(parms->mask, &this_row->mask, parms->key_size);
891 [ # # ]: 0 : if (parms->result != ((void *)0))
892 : 0 : memcpy(parms->result, &this_row->result, parms->result_size);
893 : 0 : return 0;
894 : : };
895 : :
896 : 0 : static int cfa_tcam_mgr_hwop_free(int sess_idx,
897 : : struct cfa_tcam_mgr_free_parms *parms,
898 : : int row, int slice, int max_slices)
899 : : {
900 : : struct cfa_tcam_mgr_TCAM_row_data *this_table;
901 : : struct cfa_tcam_mgr_TCAM_row_data *this_row;
902 : 0 : this_table = row_tables[parms->dir]
903 : 0 : [cfa_tcam_mgr_get_phys_table_type(parms->type)];
904 : 0 : this_table += (sess_idx *
905 [ # # ]: 0 : cfa_tcam_mgr_get_max_rows(cfa_tcam_mgr_get_phys_table_type(parms->type)));
906 : 0 : this_row = &this_table[row * max_slices + slice];
907 : 0 : memset(&this_row->key, 0, sizeof(this_row->key));
908 : 0 : memset(&this_row->mask, 0, sizeof(this_row->mask));
909 : 0 : memset(&this_row->result, 0, sizeof(this_row->result));
910 : 0 : this_row->key_size = 0;
911 : 0 : this_row->result_size = 0;
912 : 0 : return 0;
913 : : };
914 : :
915 : 0 : int cfa_tcam_mgr_hwops_get_funcs_p4(struct cfa_tcam_mgr_hwops_funcs *hwop_funcs)
916 : : {
917 : 0 : hwop_funcs->set = cfa_tcam_mgr_hwop_set;
918 : 0 : hwop_funcs->get = cfa_tcam_mgr_hwop_get;
919 : 0 : hwop_funcs->free = cfa_tcam_mgr_hwop_free;
920 : 0 : return 0;
921 : : }
|