Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2023 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _CPFL_ACTIONS_H_
6 : : #define _CPFL_ACTIONS_H_
7 : :
8 : : #include "base/idpf_osdep.h"
9 : :
10 : : #pragma pack(1)
11 : :
12 : : union cpfl_action_set {
13 : : uint32_t data;
14 : :
15 : : struct {
16 : : uint32_t val : 24;
17 : : uint32_t idx : 4;
18 : : uint32_t tag : 1;
19 : : uint32_t prec : 3;
20 : : } set_24b_a;
21 : :
22 : : struct {
23 : : uint32_t val : 24;
24 : : uint32_t idx : 3;
25 : : uint32_t tag : 2;
26 : : uint32_t prec : 3;
27 : : } set_24b_b;
28 : :
29 : : struct {
30 : : uint32_t val : 16;
31 : : uint32_t idx : 4;
32 : : uint32_t unused : 6;
33 : : uint32_t tag : 3;
34 : : uint32_t prec : 3;
35 : : } set_16b;
36 : :
37 : : struct {
38 : : uint32_t val_a : 8;
39 : : uint32_t val_b : 8;
40 : : uint32_t idx_a : 4;
41 : : uint32_t idx_b : 4;
42 : : uint32_t tag : 5;
43 : : uint32_t prec : 3;
44 : : } set_8b;
45 : :
46 : : struct {
47 : : uint32_t val : 10;
48 : : uint32_t ena : 10;
49 : : uint32_t idx : 4;
50 : : uint32_t tag : 5;
51 : : uint32_t prec : 3;
52 : : } set_1b;
53 : :
54 : : struct {
55 : : uint32_t val : 24;
56 : : uint32_t tag : 5;
57 : : uint32_t prec : 3;
58 : : } nop;
59 : :
60 : : struct {
61 : : uint32_t val : 24;
62 : : uint32_t tag : 5;
63 : : uint32_t prec : 3;
64 : : } chained_24b;
65 : :
66 : : struct {
67 : : uint32_t val : 24;
68 : : uint32_t tag : 5;
69 : : uint32_t prec : 3;
70 : : } aux_flags;
71 : : };
72 : :
73 : : struct cpfl_action_set_ext {
74 : : #define CPFL_ACTION_SET_EXT_CNT 2
75 : : union cpfl_action_set acts[CPFL_ACTION_SET_EXT_CNT];
76 : : };
77 : :
78 : : #pragma pack()
79 : :
80 : : /**
81 : : * cpfl_act_nop - Encode a NOP action
82 : : */
83 : : static inline union cpfl_action_set
84 : : cpfl_act_nop(void)
85 : : {
86 : : union cpfl_action_set act;
87 : :
88 : : act.data = 0;
89 : : return act;
90 : : }
91 : :
92 : : /**
93 : : * cpfl_is_nop_action - Indicate if an action set is a NOP
94 : : */
95 : : static inline bool
96 : : cpfl_is_nop_action(union cpfl_action_set *act)
97 : : {
98 : : return act->data == cpfl_act_nop().data;
99 : : }
100 : :
101 : : #define CPFL_MAKE_MASK32(b, s) ((((uint32_t)1 << (b)) - 1) << (s))
102 : :
103 : : #define CPFL_ACT_PREC_MAX 7
104 : : #define CPFL_ACT_PREC_S 29
105 : : #define CPFL_ACT_PREC_M CPFL_MAKE_MASK32(3, CPFL_ACT_PREC_S)
106 : : #define CPFL_ACT_PREC_SET(p) \
107 : : (((uint32_t)(p) << CPFL_ACT_PREC_S) & CPFL_ACT_PREC_M)
108 : : #define CPFL_ACT_PREC_CHECK(p) ((p) > 0 && (p) <= CPFL_ACT_PREC_MAX)
109 : :
110 : : #define CPFL_METADATA_ID_CNT 32 /* Max number of metadata IDs */
111 : : #define CPFL_METADATA_STRUCT_MAX_SZ 128 /* Max metadata size per ID */
112 : :
113 : : /*******************************************************************************
114 : : * 1-Bit Actions
115 : : ******************************************************************************/
116 : : #define CPFL_ACT_1B_OP_S 24
117 : : #define CPFL_ACT_1B_OP_M CPFL_MAKE_MASK32(5, CPFL_ACT_1B_OP_S)
118 : : #define CPFL_ACT_1B_OP ((uint32_t)(0x01) << CPFL_ACT_1B_OP_S)
119 : :
120 : : #define CPFL_ACT_1B_VAL_S 0
121 : : #define CPFL_ACT_1B_VAL_M CPFL_MAKE_MASK32(10, CPFL_ACT_1B_VAL_S)
122 : : #define CPFL_ACT_1B_EN_S 10
123 : : #define CPFL_ACT_1B_EN_M CPFL_MAKE_MASK32(10, CPFL_ACT_1B_EN_S)
124 : : #define CPFL_ACT_1B_INDEX_S 20
125 : : #define CPFL_ACT_1B_INDEX_M CPFL_MAKE_MASK32(4, CPFL_ACT_1B_INDEX_S)
126 : :
127 : : /* 1-bit actions currently uses only INDEX of 0 */
128 : : #define CPFL_ACT_MAKE_1B(prec, en, val) \
129 : : ((CPFL_ACT_PREC_SET(prec)) | CPFL_ACT_1B_OP | \
130 : : ((((uint32_t)0) << CPFL_ACT_1B_INDEX_S) & CPFL_ACT_1B_INDEX_M) | \
131 : : (((uint32_t)(en) << CPFL_ACT_1B_EN_S) & CPFL_ACT_1B_EN_M) | \
132 : : (((uint32_t)(val) << CPFL_ACT_1B_VAL_S) & CPFL_ACT_1B_VAL_M))
133 : :
134 : : enum cpfl_act_1b_op {
135 : : CPFL_ACT_1B_OP_DROP = 0x01,
136 : : CPFL_ACT_1B_OP_HDR_SPLIT = 0x02,
137 : : CPFL_ACT_1B_OP_DIR_CHANGE = 0x04,
138 : : CPFL_ACT_1B_OP_DEFER_DROP = 0x08,
139 : : CPFL_ACT_1B_OP_ORIG_MIR_MD = 0x80
140 : : };
141 : :
142 : : #define CPFL_ACT_1B_COMMIT_MODE_S 4
143 : : #define CPFL_ACT_1B_COMMIT_MODE_M \
144 : : CPFL_MAKE_MASK32(3, CPFL_ACT_1B_COMMIT_MODE_S)
145 : :
146 : : /**
147 : : * cpfl_act_commit_mode - action commit mode for certain action classes
148 : : */
149 : : enum cpfl_act_commit_mode {
150 : : /* Action processing for the initial classification pass */
151 : : CPFL_ACT_COMMIT_ALL = 0, /* Commit all actions */
152 : : CPFL_ACT_COMMIT_PRE_MOD = 1, /* Commit only pre-modify actions*/
153 : : CPFL_ACT_COMMIT_NONE = 2, /* Commit no action */
154 : : /* Action processing for deferred actions in a recirculation pass */
155 : : CPFL_ACT_COMMIT_RECIR_ALL = 4, /* Commit all actions */
156 : : CPFL_ACT_COMMIT_RECIR_PRE_MOD = 5, /* Commit only pre-modify actions*/
157 : : CPFL_ACT_COMMIT_RECIR_NONE = 6 /* Commit no action */
158 : : };
159 : :
160 : : /*******************************************************************************
161 : : * 8-Bit Actions
162 : : ******************************************************************************/
163 : : #define CPFL_ACT_OP_8B_S 24
164 : : #define CPFL_ACT_OP_8B_M CPFL_MAKE_MASK32(5, CPFL_ACT_OP_8B_S)
165 : : #define CPFL_ACT_OP_8B ((uint32_t)(0x02) << CPFL_ACT_OP_8B_S)
166 : :
167 : : #define CPFL_ACT_8B_A_VAL_S 0
168 : : #define CPFL_ACT_8B_A_VAL_M CPFL_MAKE_MASK32(8, CPFL_ACT_8B_A_VAL_S)
169 : : #define CPFL_ACT_8B_A_INDEX_S 16
170 : : #define CPFL_ACT_8B_A_INDEX_M CPFL_MAKE_MASK32(4, CPFL_ACT_8B_A_INDEX_S)
171 : :
172 : : #define CPFL_ACT_8B_B_VAL_S 8
173 : : #define CPFL_ACT_8B_B_VAL_M CPFL_MAKE_MASK32(8, CPFL_ACT_8B_B_VAL_S)
174 : : #define CPFL_ACT_8B_B_INDEX_S 20
175 : : #define CPFL_ACT_8B_B_INDEX_M CPFL_MAKE_MASK32(4, CPFL_ACT_8B_B_INDEX_S)
176 : :
177 : : /* Unless combining two 8-bit actions into an action set, both A and B fields
178 : : * must be the same,
179 : : */
180 : : #define CPFL_ACT_MAKE_8B(prec, idx, val) \
181 : : ((CPFL_ACT_PREC_SET(prec)) | CPFL_ACT_OP_8B | \
182 : : (((idx) << CPFL_ACT_8B_A_INDEX_S) & CPFL_ACT_8B_A_INDEX_M) | \
183 : : (((idx) << CPFL_ACT_8B_B_INDEX_S) & CPFL_ACT_8B_B_INDEX_M) | \
184 : : (((val) << CPFL_ACT_8B_A_VAL_S) & CPFL_ACT_8B_A_VAL_M) | \
185 : : (((val) << CPFL_ACT_8B_B_VAL_S) & CPFL_ACT_8B_B_VAL_M))
186 : :
187 : : /* 8-Bit Action Indices */
188 : : #define CPFL_ACT_8B_INDEX_MOD_META 9
189 : :
190 : : /* 8-Bit Action Miscellaneous */
191 : : #define CPFL_ACT_8B_MOD_META_PROF_CNT 16
192 : : #define CPFL_ACT_8B_MOD_META_VALID 0x80
193 : :
194 : : /*******************************************************************************
195 : : * 16-Bit Actions
196 : : ******************************************************************************/
197 : : #define CPFL_ACT_OP_16B_S 26
198 : : #define CPFL_ACT_OP_16B_M CPFL_MAKE_MASK32(3, CPFL_ACT_OP_16B_S)
199 : : #define CPFL_ACT_OP_16B ((uint32_t)0x1 << CPFL_ACT_OP_16B_S)
200 : :
201 : : #define CPFL_ACT_16B_INDEX_S 16
202 : : #define CPFL_ACT_16B_INDEX_M CPFL_MAKE_MASK32(4, CPFL_ACT_16B_INDEX_S)
203 : : #define CPFL_ACT_16B_VAL_S 0
204 : : #define CPFL_ACT_16B_VAL_M CPFL_MAKE_MASK32(16, CPFL_ACT_16B_VAL_S)
205 : :
206 : : #define CPFL_ACT_MAKE_16B(prec, idx, val) \
207 : : ((CPFL_ACT_PREC_SET(prec)) | CPFL_ACT_OP_16B | \
208 : : (((uint32_t)(idx) << CPFL_ACT_16B_INDEX_S) & CPFL_ACT_16B_INDEX_M) | \
209 : : (((uint32_t)(val) << CPFL_ACT_16B_VAL_S) & CPFL_ACT_16B_VAL_M))
210 : :
211 : : /* 16-Bit Action Indices */
212 : : #define CPFL_ACT_16B_INDEX_COUNT_SET 0
213 : : #define CPFL_ACT_16B_INDEX_SET_MCAST_IDX 1
214 : : #define CPFL_ACT_16B_INDEX_SET_VSI 2
215 : : #define CPFL_ACT_16B_INDEX_DEL_MD 4
216 : : #define CPFL_ACT_16B_INDEX_MOD_VSI_LIST 5
217 : :
218 : : /* 16-Bit Action Miscellaneous */
219 : : #define CPFL_ACT_16B_COUNT_SET_CNT 2048 /* TODO: Value from NSL */
220 : : #define CPFL_ACT_16B_SET_VSI_SLOTS 2
221 : : #define CPFL_ACT_16B_FWD_VSI_CNT 1032 /* TODO: Value from NSL */
222 : : #define CPFL_ACT_16B_FWD_VSI_LIST_CNT 256
223 : : #define CPFL_ACT_16B_MOD_VSI_LIST_CNT 1024
224 : : #define CPFL_ACT_16B_FWD_PORT_CNT 4
225 : : #define CPFL_ACT_16B_DEL_MD_MID_CNT 32
226 : : #define CPFL_ACT_16B_MOD_VSI_LIST_SLOTS 4
227 : :
228 : : /* 16-Bit SET_MCAST_IDX Action */
229 : : #define CPFL_ACT_16B_SET_MCAST_VALID ((uint32_t)1 << 15)
230 : :
231 : : /* 16-Bit SET_VSI Action Variants */
232 : : #define CPFL_ACT_16B_SET_VSI_VAL_S 0
233 : : #define CPFL_ACT_16B_SET_VSI_VAL_M \
234 : : CPFL_MAKE_MASK32(11, CPFL_ACT_16B_SET_VSI_VAL_S)
235 : : #define CPFL_ACT_16B_SET_VSI_PE_S 11
236 : : #define CPFL_ACT_16B_SET_VSI_PE_M \
237 : : CPFL_MAKE_MASK32(2, CPFL_ACT_16B_SET_VSI_PE_S)
238 : : #define CPFL_ACT_16B_SET_VSI_TYPE_S 14
239 : : #define CPFL_ACT_16B_SET_VSI_TYPE_M \
240 : : CPFL_MAKE_MASK32(2, CPFL_ACT_16B_SET_VSI_TYPE_S)
241 : :
242 : : /* 16-Bit DEL_MD Action */
243 : : #define CPFL_ACT_16B_DEL_MD_0_S 0
244 : : #define CPFL_ACT_16B_DEL_MD_1_S 5
245 : :
246 : : /* 16-Bit MOD_VSI_LIST Actions */
247 : : #define CPFL_ACT_16B_MOD_VSI_LIST_ID_S 0
248 : : #define CPFL_ACT_16B_MOD_VSI_LIST_ID_M \
249 : : CPFL_MAKE_MASK32(10, CPFL_ACT_16B_MOD_VSI_LIST_ID_S)
250 : : #define CPFL_ACT_16B_MOD_VSI_LIST_OP_S 14
251 : : #define CPFL_ACT_16B_MOD_VSI_LIST_OP_M \
252 : : CPFL_MAKE_MASK32(2, CPFL_ACT_16B_MOD_VSI_LIST_OP_S)
253 : : #define CPFL_MAKE_16B_MOD_VSI_LIST(op, id) \
254 : : ((((uint32_t)(op) << CPFL_ACT_16B_MOD_VSI_LIST_OP_S) & \
255 : : CPFL_ACT_16B_MOD_VSI_LIST_OP_M) | \
256 : : (((uint32_t)(id) << CPFL_ACT_16B_MOD_VSI_LIST_ID_S) & \
257 : : CPFL_ACT_16B_MOD_VSI_LIST_ID_M))
258 : :
259 : : #define CPFL_ACT_16B_MAKE_SET_VSI(type, pe, val) \
260 : : ((((uint32_t)(type) << CPFL_ACT_16B_SET_VSI_TYPE_S) & \
261 : : CPFL_ACT_16B_SET_VSI_TYPE_M) | \
262 : : (((uint32_t)(pe) << CPFL_ACT_16B_SET_VSI_PE_S) & \
263 : : CPFL_ACT_16B_SET_VSI_PE_M) | \
264 : : (((uint32_t)(val) << CPFL_ACT_16B_SET_VSI_VAL_S) & \
265 : : CPFL_ACT_16B_SET_VSI_VAL_M))
266 : :
267 : : enum cpfl_prot_eng {
268 : : CPFL_PE_LAN = 0,
269 : : CPFL_PE_RDMA,
270 : : CPFL_PE_CRT
271 : : };
272 : :
273 : : enum cpfl_act_fwd_type {
274 : : CPFL_ACT_FWD_VSI,
275 : : CPFL_ACT_FWD_VSI_LIST,
276 : : CPFL_ACT_FWD_PORT
277 : : };
278 : :
279 : : /*******************************************************************************
280 : : * 24-Bit Actions
281 : : ******************************************************************************/
282 : : /* Group A */
283 : : #define CPFL_ACT_OP_24B_A_S 28
284 : : #define CPFL_ACT_OP_24B_A_M CPFL_MAKE_MASK32(1, CPFL_ACT_OP_24B_A_S)
285 : : #define CPFL_ACT_24B_A_INDEX_S 24
286 : : #define CPFL_ACT_24B_A_INDEX_M CPFL_MAKE_MASK32(4, CPFL_ACT_24B_A_INDEX_S)
287 : : #define CPFL_ACT_24B_A_VAL_S 0
288 : : #define CPFL_ACT_24B_A_VAL_M CPFL_MAKE_MASK32(24, CPFL_ACT_24B_A_VAL_S)
289 : :
290 : : #define CPFL_ACT_OP_24B_A ((uint32_t)1 << CPFL_ACT_OP_24B_A_S)
291 : :
292 : : #define CPFL_ACT_MAKE_24B_A(prec, idx, val) \
293 : : ((CPFL_ACT_PREC_SET(prec)) | CPFL_ACT_OP_24B_A | \
294 : : (((uint32_t)(idx) << CPFL_ACT_24B_A_INDEX_S) & CPFL_ACT_24B_A_INDEX_M) | \
295 : : (((uint32_t)(val) << CPFL_ACT_24B_A_VAL_S) & CPFL_ACT_24B_A_VAL_M))
296 : :
297 : : #define CPFL_ACT_24B_INDEX_MOD_ADDR 0
298 : : #define CPFL_ACT_24B_INDEX_MIRROR_FIRST 1
299 : : #define CPFL_ACT_24B_INDEX_COUNT 2
300 : : #define CPFL_ACT_24B_INDEX_SET_Q 8
301 : : #define CPFL_ACT_24B_INDEX_MOD_PROFILE 9
302 : : #define CPFL_ACT_24B_INDEX_METER 10
303 : :
304 : : #define CPFL_ACT_24B_COUNT_SLOTS 6
305 : : #define CPFL_ACT_24B_METER_SLOTS 6
306 : :
307 : : #define CPFL_ACT_24B_MOD_ADDR_CNT (16 * 1024 * 1024)
308 : : #define CPFL_ACT_24B_COUNT_ID_CNT ((uint32_t)1 << 24)
309 : : #define CPFL_ACT_24B_SET_Q_CNT (12 * 1024)
310 : : #define CPFL_ACT_24B_SET_Q_Q_RGN_BITS 3
311 : :
312 : : /* 24-Bit SET_Q Action */
313 : : #define CPFL_ACT_24B_SET_Q_Q_S 0
314 : : #define CPFL_ACT_24B_SET_Q_Q_M \
315 : : CPFL_MAKE_MASK32(14, CPFL_ACT_24B_SET_Q_Q_S)
316 : : #define CPFL_ACT_24B_SET_Q_Q_RGN_S 14
317 : : #define CPFL_ACT_24B_SET_Q_Q_RGN_M \
318 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_SET_Q_Q_RGN_S)
319 : : #define CPFL_ACT_24B_SET_Q_IMPLICIT_VSI_DIS CPFL_MAKE_MASK32(1, 17)
320 : : #define CPFL_ACT_24B_SET_Q_DST_PE_S 21
321 : : #define CPFL_ACT_24B_SET_Q_DST_PE_M \
322 : : CPFL_MAKE_MASK32(2, CPFL_ACT_24B_SET_Q_DST_PE_S)
323 : : #define CPFL_ACT_24B_SET_Q_VALID CPFL_MAKE_MASK32(1, 23)
324 : :
325 : : /* 24-Bit MOD_PROFILE Action */
326 : : enum cpfl_act_mod_profile_hint {
327 : : CPFL_ACT_MOD_PROFILE_NO_ADDR = 0, /* No associated MOD_ADDR action */
328 : : CPFL_ACT_MOD_PROFILE_PREFETCH_128B, /* Prefetch 128B using MOD_ADDR */
329 : : CPFL_ACT_MOD_PROFILE_PREFETCH_256B, /* Prefetch 256B using MOD_ADDR */
330 : : };
331 : :
332 : : #define CPFL_ACT_24B_MOD_PROFILE_PROF_S 0
333 : : #define CPFL_ACT_24B_MOD_PROFILE_PROF_M \
334 : : CPFL_MAKE_MASK32(11, CPFL_ACT_24B_MOD_PROFILE_PROF_S)
335 : : #define CPFL_ACT_24B_MOD_PROFILE_XTLN_IDX_S 12
336 : : #define CPFL_ACT_24B_MOD_PROFILE_XTLN_IDX_M \
337 : : CPFL_MAKE_MASK32(2, CPFL_ACT_24B_MOD_PROFILE_XTLN_IDX_S)
338 : : #define CPFL_ACT_24B_MOD_PROFILE_HINT_S 14
339 : : #define CPFL_ACT_24B_MOD_PROFILE_HINT_M \
340 : : CPFL_MAKE_MASK32(2, CPFL_ACT_24B_MOD_PROFILE_HINT_S)
341 : : #define CPFL_ACT_24B_MOD_PROFILE_APPEND_ACT_BUS ((uint32_t)1 << 16)
342 : : #define CPFL_ACT_24B_MOD_PROFILE_SET_MISS_PREPEND ((uint32_t)1 << 17)
343 : : #define CPFL_ACT_24B_MOD_PROFILE_VALID ((uint32_t)1 << 23)
344 : :
345 : : #define CPFL_ACT_24B_MOD_PROFILE_PTYPE_XLTN_INDEXES 4
346 : : #define CPFL_ACT_24B_MOD_PROFILE_PROF_CNT 2048
347 : :
348 : : /* 24-Bit METER Actions */
349 : : #define CPFL_ACT_24B_METER_INDEX_S 0
350 : : #define CPFL_ACT_24B_METER_INDEX_M \
351 : : CPFL_MAKE_MASK32(20, CPFL_ACT_24B_METER_INDEX_S)
352 : : #define CPFL_ACT_24B_METER_BANK_S 20
353 : : #define CPFL_ACT_24B_METER_BANK_M \
354 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_METER_BANK_S)
355 : : #define CPFL_ACT_24B_METER_VALID ((uint32_t)1 << 23)
356 : :
357 : : #define CPFL_ACT_24B_METER_BANK_CNT 6
358 : : #define CPFL_ACT_24B_METER_INDEX_CNT ((uint32_t)1 << 20)
359 : :
360 : : /* Group B */
361 : : #define CPFL_ACT_OP_24B_B_S 27
362 : : #define CPFL_ACT_OP_24B_B_M CPFL_MAKE_MASK32(2, CPFL_ACT_OP_24B_B_S)
363 : : #define CPFL_ACT_24B_B_INDEX_S 24
364 : : #define CPFL_ACT_24B_B_INDEX_M \
365 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_B_INDEX_S)
366 : : #define CPFL_ACT_24B_B_VAL_S 0
367 : : #define CPFL_ACT_24B_B_VAL_M CPFL_MAKE_MASK32(24, CPFL_ACT_24B_B_VAL_S)
368 : :
369 : : #define CPFL_ACT_OP_24B_B ((uint32_t)1 << CPFL_ACT_OP_24B_B_S)
370 : :
371 : : #define CPFL_ACT_MAKE_24B_B(prec, idx, val) \
372 : : ((CPFL_ACT_PREC_SET(prec)) | CPFL_ACT_OP_24B_B | \
373 : : (((uint32_t)(idx) << CPFL_ACT_24B_B_INDEX_S) & CPFL_ACT_24B_B_INDEX_M) | \
374 : : (((uint32_t)(val) << CPFL_ACT_24B_B_VAL_S) & CPFL_ACT_24B_B_VAL_M))
375 : :
376 : : #define CPFL_ACT_24B_INDEX_SET_MD 0
377 : : #define CPFL_ACT_24B_INDEX_RANGE_CHECK 6
378 : : #define CPFL_ACT_24B_SET_MD_SLOTS 6
379 : :
380 : : /* Set/Add/Delete Metadata Actions - SET_MD[0-5], DEL_MD */
381 : : /* 8-Bit SET_MD */
382 : : #define CPFL_ACT_24B_SET_MD8_VAL_S 0
383 : : #define CPFL_ACT_24B_SET_MD8_VAL_M \
384 : : CPFL_MAKE_MASK32(8, CPFL_ACT_24B_SET_MD8_VAL_S)
385 : : #define CPFL_ACT_24B_SET_MD8_MASK_S 8
386 : : #define CPFL_ACT_24B_SET_MD8_MASK_M \
387 : : CPFL_MAKE_MASK32(8, CPFL_ACT_24B_SET_MD8_MASK_S)
388 : : #define CPFL_ACT_24B_SET_MD8_OFFSET_S 16
389 : : #define CPFL_ACT_24B_SET_MD8_OFFSET_M \
390 : : CPFL_MAKE_MASK32(4, CPFL_ACT_24B_SET_MD8_OFFSET_S)
391 : : #define CPFL_ACT_24B_SET_MD8_TYPE_ID_S 20
392 : : #define CPFL_ACT_24B_SET_MD8_TYPE_ID_M \
393 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_SET_MD8_TYPE_ID_S)
394 : : /* 16-Bit SET_MD */
395 : : #define CPFL_ACT_24B_SET_MD16_VAL_S 0
396 : : #define CPFL_ACT_24B_SET_MD16_VAL_M \
397 : : CPFL_MAKE_MASK32(16, CPFL_ACT_24B_SET_MD16_VAL_S)
398 : : #define CPFL_ACT_24B_SET_MD16_MASK_L_S 16 /* For chained action */
399 : : #define CPFL_ACT_24B_SET_MD16_MASK_L_M \
400 : : CPFL_MAKE_MASK32(8, CPFL_ACT_24B_SET_MD16_MASK_L_S)
401 : : #define CPFL_ACT_24B_SET_MD16_MASK_H_SR 8
402 : : #define CPFL_ACT_24B_SET_MD16_MASK_H_M 0xff
403 : : #define CPFL_ACT_24B_SET_MD16_OFFSET_S 16
404 : : #define CPFL_ACT_24B_SET_MD16_OFFSET_M \
405 : : CPFL_MAKE_MASK32(4, CPFL_ACT_24B_SET_MD16_OFFSET_S)
406 : : #define CPFL_ACT_24B_SET_MD16_TYPE_ID_S 20
407 : : #define CPFL_ACT_24B_SET_MD16_TYPE_ID_M \
408 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_SET_MD16_TYPE_ID_S)
409 : : #define CPFL_ACT_24B_SET_MD16 ((uint32_t)1 << 23)
410 : :
411 : : #define CPFL_ACT_24B_SET_MD32_VAL_L_M CPFL_MAKE_MASK32(24, 0)
412 : :
413 : : #define CPFL_ACT_24B_SET_MD8_OFFSET_MAX 15
414 : : #define CPFL_ACT_24B_SET_MD8_TYPE_ID_MAX 7
415 : : #define CPFL_ACT_24B_SET_MD16_OFFSET_MAX 15
416 : : #define CPFL_ACT_24B_SET_MD16_TYPE_ID_MAX 7
417 : :
418 : : /* RANGE_CHECK Action */
419 : : enum cpfl_rule_act_rc_mode {
420 : : CPFL_RULE_ACT_RC_1_RANGE = 0,
421 : : CPFL_RULE_ACT_RC_2_RANGES = 1,
422 : : CPFL_RULE_ACT_RC_4_RANGES = 2,
423 : : CPFL_RULE_ACT_RC_8_RANGES = 3
424 : : };
425 : :
426 : : #define CPFL_ACT_24B_RC_TBL_IDX_S 0
427 : : #define CPFL_ACT_24B_RC_TBL_IDX_M \
428 : : CPFL_MAKE_MASK32(13, CPFL_ACT_24B_RC_TBL_IDX_S)
429 : : #define CPFL_ACT_24B_RC_START_BANK_S 13
430 : : #define CPFL_ACT_24B_RC_START_BANK_M \
431 : : CPFL_MAKE_MASK32(3, CPFL_ACT_24B_RC_START_BANK_S)
432 : : #define CPFL_ACT_24B_RC_MODE_S 16
433 : : #define CPFL_ACT_24B_RC_MODE_M \
434 : : CPFL_MAKE_MASK32(2, CPFL_ACT_24B_RC_MODE_S)
435 : : #define CPFL_ACT_24B_RC_XTRACT_PROF_S 18
436 : : #define CPFL_ACT_24B_RC_XTRACT_PROF_M \
437 : : CPFL_MAKE_MASK32(6, CPFL_ACT_24B_RC_XTRACT_PROF_S)
438 : :
439 : : #define CPFL_ACT_24B_RC_TBL_INDEX_CNT (8 * 1024)
440 : : #define CPFL_ACT_24B_RC_BANK_CNT 8
441 : : #define CPFL_ACT_24B_RC_XTRACT_PROF_CNT 64
442 : :
443 : : /*******************************************************************************
444 : : * 24-Bit Chained Auxiliary Actions
445 : : ******************************************************************************/
446 : :
447 : : /* TODO: HAS is being updated. Revise the order of chained and base action
448 : : * when the HAS has it finalized.
449 : : */
450 : : /**
451 : : * 24-Bit Chained SET_MD Actions
452 : : *
453 : : * Chained SET_MD actions consume two consecutive action sets. The first one is
454 : : * the chained AUX action set. The second one is the base/parent action set.
455 : : * Chained SET_MD actions can add and/or update metadata structure with IDs from
456 : : * 0 to 31 while the non-chained SET_MD variants can only update existing meta-
457 : : * data IDs below 16.
458 : : */
459 : :
460 : : #define CPFL_ACT_24B_SET_MD_AUX_OFFSET_S 8
461 : : #define CPFL_ACT_24B_SET_MD_AUX_OFFSET_M \
462 : : CPFL_MAKE_MASK32(7, CPFL_ACT_24B_SET_MD_AUX_OFFSET_S)
463 : : #define CPFL_ACT_24B_SET_MD_AUX_ADD ((uint32_t)1 << 15)
464 : : #define CPFL_ACT_24B_SET_MD_AUX_TYPE_ID_S 16
465 : : #define CPFL_ACT_24B_SET_MD_AUX_TYPE_ID_M \
466 : : CPFL_MAKE_MASK32(5, CPFL_ACT_24B_SET_MD_AUX_TYPE_ID_S)
467 : : #define CPFL_ACT_24B_SET_MD_AUX_DATA_S 0
468 : : #define CPFL_ACT_24B_SET_MD_AUX_DATA_M \
469 : : CPFL_MAKE_MASK32(8, CPFL_ACT_24B_SET_MD_AUX_DATA_S)
470 : :
471 : : #define CPFL_ACT_24B_SET_MD_AUX_16B_MASK_H_S 0
472 : : #define CPFL_ACT_24B_SET_MD_AUX_16B_MASK_H_M \
473 : : CPFL_MAKE_MASK32(8, CPFL_ACT_24B_SET_MD_AUX_16B_MASK_H_S)
474 : : #define CPFL_ACT_24B_SET_MD_AUX_32B_VAL_H_SR 24 /* Upper 8 bits of MD32 */
475 : : #define CPFL_ACT_24B_SET_MD_AUX_32B_VAL_H_M 0xff
476 : :
477 : : #define CPFL_ACT_TYPE_CHAIN_DATA_S 29
478 : : #define CPFL_ACT_TYPE_CHAIN_DATA_M \
479 : : CPFL_MAKE_MASK32(3, CPFL_ACT_TYPE_CHAIN_DATA_S)
480 : : #define CPFL_ACT_TYPE_CHAIN_DATA ((uint32_t)1 << CPFL_ACT_TYPE_CHAIN_DATA_S)
481 : :
482 : : #define CPFL_ACT_24B_SET_MD_OP_S 21
483 : : #define CPFL_ACT_24B_SET_MD_OP_8B ((uint32_t)0 << CPFL_ACT_24B_SET_MD_OP_S)
484 : : #define CPFL_ACT_24B_SET_MD_OP_16B ((uint32_t)1 << CPFL_ACT_24B_SET_MD_OP_S)
485 : : #define CPFL_ACT_24B_SET_MD_OP_32B ((uint32_t)2 << CPFL_ACT_24B_SET_MD_OP_S)
486 : :
487 : : #define CPFL_ACT_24B_SET_MD_AUX_MAKE(op, mid, off, data) \
488 : : (CPFL_ACT_TYPE_CHAIN_DATA | (op) | \
489 : : (((uint32_t)(mid) << CPFL_ACT_24B_SET_MD_AUX_TYPE_ID_S) & \
490 : : CPFL_ACT_24B_SET_MD_AUX_TYPE_ID_M) | \
491 : : (((uint32_t)(off) << CPFL_ACT_24B_SET_MD_AUX_OFFSET_S) & \
492 : : CPFL_ACT_24B_SET_MD_AUX_OFFSET_M) | \
493 : : (((uint32_t)(data) << CPFL_ACT_24B_SET_MD_AUX_DATA_S) & \
494 : : CPFL_ACT_24B_SET_MD_AUX_DATA_M))
495 : :
496 : : /*******************************************************************************
497 : : * 1-Bit Action Factory
498 : : ******************************************************************************/
499 : :
500 : : /**
501 : : * cpfl_act_drop - Encode a 1-bit DROP action
502 : : *
503 : : * The DROP action has precedence over the DEFER_DOP action.
504 : : * Affect of ACT_COMMIT action on the DROP action:
505 : : * - CPFL_ACT_COMMIT_ALL: Packet is dropped.
506 : : * - CPFL_ACT_COMMIT_PRE_MOD or CPFL_ACT_COMMIT_NONE: Packet is not dropped.
507 : : * - CPFL_ACT_COMMIT_RECIR_ALL: Packet is dropped. Recirculation is canceled.
508 : : * - CPFL_ACT_COMMIT_RECIR_PRE_MOD or CPFL_ACT_COMMIT_RECIR_NONE: Packet is not
509 : : * dropped. Recirculation continues.
510 : : *
511 : : * Once a DROP action is set, it cannot be reverted during the classification
512 : : * process of a network packet.
513 : : */
514 : : static inline union cpfl_action_set
515 : : cpfl_act_drop(uint8_t prec)
516 : : {
517 : : union cpfl_action_set a;
518 : :
519 [ # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec))
520 : : return cpfl_act_nop();
521 : 0 : a.data = CPFL_ACT_MAKE_1B(prec, CPFL_ACT_1B_OP_DROP, 1);
522 : 0 : return a;
523 : : }
524 : :
525 : : /**
526 : : * cpfl_act_set_commit_mode - Encode a 1-bit ACT_COMMIT action
527 : : * An ACT_COMMIT action specifies if and when all actions are committed.
528 : : */
529 : : static inline union cpfl_action_set
530 : : cpfl_act_set_commit_mode(uint8_t prec, enum cpfl_act_commit_mode mode)
531 : : {
532 : : union cpfl_action_set a;
533 : :
534 [ # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec))
535 : : return cpfl_act_nop();
536 : 0 : a.data = CPFL_ACT_MAKE_1B(prec, CPFL_ACT_1B_COMMIT_MODE_M,
537 : : (uint32_t)mode << CPFL_ACT_1B_COMMIT_MODE_S);
538 : 0 : return a;
539 : : }
540 : :
541 : : /*******************************************************************************
542 : : * 8-Bit Action Factory
543 : : ******************************************************************************/
544 : :
545 : : /**
546 : : * cpfl_act_mod_meta - Encode an 8-bit MOD_META action
547 : : */
548 : : static inline union cpfl_action_set
549 : : cpfl_act_mod_meta(uint8_t prec, uint8_t prof)
550 : : {
551 : : union cpfl_action_set a;
552 : :
553 : : if (!CPFL_ACT_PREC_CHECK(prec) || prof >= CPFL_ACT_8B_MOD_META_PROF_CNT)
554 : : return cpfl_act_nop();
555 : :
556 : : a.data = CPFL_ACT_MAKE_8B(prec, CPFL_ACT_8B_INDEX_MOD_META,
557 : : CPFL_ACT_8B_MOD_META_VALID | prof);
558 : :
559 : : return a;
560 : : }
561 : :
562 : : /*******************************************************************************
563 : : * 16-Bit Action Factory
564 : : ******************************************************************************/
565 : :
566 : : /**
567 : : * cpfl_act_fwd_vsi - Encode a 16-bit SET_VSI action (forward to a VSI)
568 : : *
569 : : * This encodes the "Forward to Single VSI" variant of SET_VSI action.
570 : : * SEM can use both SET_VSI action slots. The other classification blocks can
571 : : * only use slot 0.
572 : : */
573 : : static inline union cpfl_action_set
574 : : cpfl_act_fwd_vsi(uint8_t slot, uint8_t prec, enum cpfl_prot_eng pe, uint16_t vsi)
575 : : {
576 : : union cpfl_action_set a;
577 : : uint32_t val;
578 : :
579 [ # # # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec) || slot >= CPFL_ACT_16B_SET_VSI_SLOTS ||
580 : : vsi >= CPFL_ACT_16B_FWD_VSI_CNT)
581 : : return cpfl_act_nop();
582 : :
583 : 0 : val = CPFL_ACT_16B_MAKE_SET_VSI(CPFL_ACT_FWD_VSI, pe, vsi);
584 : 0 : a.data = CPFL_ACT_MAKE_16B(prec, CPFL_ACT_16B_INDEX_SET_VSI + slot,
585 : : val);
586 : :
587 : 0 : return a;
588 : : }
589 : :
590 : : /**
591 : : * cpfl_act_fwd_port - Encode a 16-bit SET_VSI action (forward to a port)
592 : : *
593 : : * This encodes the "Forward to a port" variant of SET_VSI action.
594 : : * SEM can use both SET_VSI action slots. The other classification blocks can
595 : : * only use slot 0.
596 : : */
597 : : static inline union cpfl_action_set
598 : : cpfl_act_fwd_port(uint8_t slot, uint8_t prec, enum cpfl_prot_eng pe, uint8_t port)
599 : : {
600 : : union cpfl_action_set a;
601 : : uint32_t val;
602 : :
603 [ # # # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec) || slot >= CPFL_ACT_16B_SET_VSI_SLOTS ||
604 : : port >= CPFL_ACT_16B_FWD_PORT_CNT)
605 : : return cpfl_act_nop();
606 : :
607 : 0 : val = CPFL_ACT_16B_MAKE_SET_VSI(CPFL_ACT_FWD_PORT, pe, port);
608 : 0 : a.data = CPFL_ACT_MAKE_16B(prec, CPFL_ACT_16B_INDEX_SET_VSI + slot,
609 : : val);
610 : :
611 : 0 : return a;
612 : : }
613 : :
614 : : /*******************************************************************************
615 : : * 24-Bit Action Factory
616 : : ******************************************************************************/
617 : :
618 : : /**
619 : : * cpfl_act_mod_addr - Encode a 24-bit MOD_ADDR action
620 : : *
621 : : * This MOD_ADDR specifies the index of the MOD content entry an accompanying
622 : : * MOD_PROFILE action uses. Some MOD_PROFILE actions may need to use extra
623 : : * information from a Modify content entry, and requires an accompanying
624 : : * MOD_ADDR action.
625 : : */
626 : : static inline union cpfl_action_set
627 : : cpfl_act_mod_addr(uint8_t prec, uint32_t mod_addr)
628 : : {
629 : : union cpfl_action_set a;
630 : :
631 [ # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec) || mod_addr >= CPFL_ACT_24B_MOD_ADDR_CNT)
632 : : return cpfl_act_nop();
633 : :
634 : 0 : a.data = CPFL_ACT_MAKE_24B_A(prec, CPFL_ACT_24B_INDEX_MOD_ADDR,
635 : : mod_addr);
636 : :
637 : 0 : return a;
638 : : }
639 : :
640 : : /**
641 : : * cpfl_act_set_hash_queue - Encode a 24-bit SET_Q action (one queue variant)
642 : : *
643 : : * This action is a "Forward to a single queue" variant of the SET_Q action.
644 : : *
645 : : * SEM performs Implicit VSI for SET_Q action when "no_impliciti_vsi" is false.
646 : : * WCM and LEM never perform Implicit VSI for SET_Q actions.
647 : : */
648 : : static inline union cpfl_action_set
649 : : cpfl_act_set_hash_queue(uint8_t prec, enum cpfl_prot_eng pe, uint16_t q,
650 : : bool no_implicit_vsi)
651 : : {
652 : : union cpfl_action_set a;
653 : : uint32_t val;
654 : :
655 [ # # # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec) || q >= CPFL_ACT_24B_SET_Q_CNT)
656 : : return cpfl_act_nop();
657 : :
658 : 0 : val = CPFL_ACT_24B_SET_Q_VALID | (uint32_t)q |
659 : : (((uint32_t)pe << CPFL_ACT_24B_SET_Q_DST_PE_S) &
660 : : CPFL_ACT_24B_SET_Q_DST_PE_M);
661 : : if (no_implicit_vsi)
662 : : val |= CPFL_ACT_24B_SET_Q_IMPLICIT_VSI_DIS;
663 : 0 : a.data = CPFL_ACT_MAKE_24B_A(prec, CPFL_ACT_24B_INDEX_SET_Q, val);
664 : :
665 : 0 : return a;
666 : : }
667 : :
668 : : /**
669 : : * cpfl_act_set_hash_queue_region - Encode a 24-bit SET_Q action (queue region)
670 : : *
671 : : * This action is a "Forward to a queue region" variant of the SET_Q action.
672 : : *
673 : : * SEM performs Implicit VSI for SET_Q action when "no_impliciti_vsi" is false.
674 : : * WCM and LEM never perform Implicit VSI for SET_Q actions.
675 : : */
676 : : static inline union cpfl_action_set
677 : : cpfl_act_set_hash_queue_region(uint8_t prec, enum cpfl_prot_eng pe, uint16_t q_base,
678 : : uint8_t q_rgn_bits, bool no_implicit_vsi)
679 : : {
680 : : union cpfl_action_set a;
681 : : uint32_t val;
682 : :
683 [ # # ]: 0 : if (!CPFL_ACT_PREC_CHECK(prec) || q_base >= CPFL_ACT_24B_SET_Q_CNT ||
684 [ # # ]: 0 : q_rgn_bits > CPFL_ACT_24B_SET_Q_Q_RGN_BITS)
685 : : return cpfl_act_nop();
686 : :
687 : 0 : val = CPFL_ACT_24B_SET_Q_VALID | (uint32_t)q_base |
688 : 0 : ((uint32_t)q_rgn_bits << CPFL_ACT_24B_SET_Q_Q_RGN_S) |
689 : : (((uint32_t)pe << CPFL_ACT_24B_SET_Q_DST_PE_S) &
690 : : CPFL_ACT_24B_SET_Q_DST_PE_M);
691 : : if (no_implicit_vsi)
692 : : val |= CPFL_ACT_24B_SET_Q_IMPLICIT_VSI_DIS;
693 : 0 : a.data = CPFL_ACT_MAKE_24B_A(prec, CPFL_ACT_24B_INDEX_SET_Q, val);
694 : :
695 : 0 : return a;
696 : : }
697 : :
698 : : /**
699 : : * cpfl_act_mod_profile - Encode a 24-bit MOD_PROFILE action
700 : : *
701 : : * This action specifies a Modify profile to use for modifying the network
702 : : * packet being classified. In addition, it also provides a hint to whether
703 : : * or not an accompanied MOD_ADDR action is expected and should be prefetched.
704 : : *
705 : : * There is only one MOD_PROFILE action slot. If multiple classification blocks
706 : : * emit this action, the precedence value and auxiliary precedence value will be
707 : : * used to select one with higher precedence.
708 : : */
709 : : static inline union cpfl_action_set
710 : : cpfl_act_mod_profile(uint8_t prec, uint16_t prof, uint8_t ptype_xltn_idx, bool append_act_bus,
711 : : bool miss_prepend, enum cpfl_act_mod_profile_hint hint)
712 : : {
713 : : union cpfl_action_set a;
714 : : uint32_t val;
715 : :
716 : : if (!CPFL_ACT_PREC_CHECK(prec) ||
717 [ # # ]: 0 : prof >= CPFL_ACT_24B_MOD_PROFILE_PROF_CNT ||
718 : : ptype_xltn_idx >= CPFL_ACT_24B_MOD_PROFILE_PTYPE_XLTN_INDEXES)
719 : : return cpfl_act_nop();
720 : :
721 : : val = CPFL_ACT_24B_MOD_PROFILE_VALID |
722 : : (((uint32_t)hint << CPFL_ACT_24B_MOD_PROFILE_HINT_S) &
723 : : CPFL_ACT_24B_MOD_PROFILE_HINT_M) |
724 : : (((uint32_t)ptype_xltn_idx << CPFL_ACT_24B_MOD_PROFILE_XTLN_IDX_S) &
725 : 0 : CPFL_ACT_24B_MOD_PROFILE_XTLN_IDX_M) |
726 : : ((uint32_t)prof << CPFL_ACT_24B_MOD_PROFILE_PROF_S);
727 : : if (append_act_bus)
728 : : val |= CPFL_ACT_24B_MOD_PROFILE_APPEND_ACT_BUS;
729 : : if (miss_prepend)
730 : : val |= CPFL_ACT_24B_MOD_PROFILE_SET_MISS_PREPEND;
731 : :
732 : 0 : a.data = CPFL_ACT_MAKE_24B_A(prec, CPFL_ACT_24B_INDEX_MOD_PROFILE, val);
733 : :
734 : 0 : return a;
735 : : }
736 : :
737 : : /**
738 : : * cpfl_act_meter - Encode a 24-bit METER action
739 : : *
740 : : * Return NOP if any given input parameter is invalid.
741 : : *
742 : : * A bank can only be used by one of the METER action slots. If multiple METER
743 : : * actions select the same bank, the action with the highest action slot wins.
744 : : * In Policer mode, METER actions at the higher indexes have precedence over
745 : : * ones at lower indexes.
746 : : */
747 : : static inline union cpfl_action_set
748 : : cpfl_act_meter(uint8_t slot, uint8_t prec, uint32_t idx, uint8_t bank)
749 : : {
750 : : union cpfl_action_set a;
751 : : uint32_t val;
752 : :
753 : : if (!CPFL_ACT_PREC_CHECK(prec) || slot >= CPFL_ACT_24B_METER_SLOTS ||
754 : : idx >= CPFL_ACT_24B_METER_INDEX_CNT ||
755 : : bank >= CPFL_ACT_24B_METER_BANK_CNT)
756 : : return cpfl_act_nop();
757 : :
758 : : val = CPFL_ACT_24B_METER_VALID |
759 : : (uint32_t)idx << CPFL_ACT_24B_METER_INDEX_S |
760 : : (uint32_t)bank << CPFL_ACT_24B_METER_BANK_S;
761 : : a.data = CPFL_ACT_MAKE_24B_A(prec, CPFL_ACT_24B_INDEX_METER + slot,
762 : : val);
763 : :
764 : : return a;
765 : : }
766 : :
767 : : /**
768 : : * cpfl_act_set_md8 - Encode a 24-bit SET_MD/8 action for an action slot
769 : : *
770 : : * This SET_MD action sets/updates a byte of a given metadata ID structure
771 : : * using one of the SET_MD action slots. This action variant can only set
772 : : * one the first 16 bytes of any of the first 7 metadata types.
773 : : */
774 : : static inline union cpfl_action_set
775 : : cpfl_act_set_md8(uint8_t slot, uint8_t prec, uint8_t mid, uint8_t off, uint8_t val, uint8_t mask)
776 : : {
777 : : union cpfl_action_set a;
778 : : uint32_t tmp;
779 : :
780 : : if (!CPFL_ACT_PREC_CHECK(prec) || slot >= CPFL_ACT_24B_SET_MD_SLOTS ||
781 : : mid > CPFL_ACT_24B_SET_MD8_TYPE_ID_MAX ||
782 : : off > CPFL_ACT_24B_SET_MD8_OFFSET_MAX)
783 : : return cpfl_act_nop();
784 : :
785 : : tmp = ((uint32_t)mid << CPFL_ACT_24B_SET_MD8_TYPE_ID_S) |
786 : : ((uint32_t)off << CPFL_ACT_24B_SET_MD8_OFFSET_S) |
787 : : ((uint32_t)mask << CPFL_ACT_24B_SET_MD8_MASK_S) |
788 : : ((uint32_t)val << CPFL_ACT_24B_SET_MD8_VAL_S);
789 : : a.data = CPFL_ACT_MAKE_24B_B(prec, CPFL_ACT_24B_INDEX_SET_MD + slot,
790 : : tmp);
791 : :
792 : : return a;
793 : : }
794 : :
795 : : /**
796 : : * cpfl_act_set_md16 - Encode a 24-bit SET_MD/16 action for an action slot
797 : : *
798 : : * This SET_MD action sets/updates a word of a given metadata ID structure
799 : : * using one of the SET_MD action slots. This action variant can only set
800 : : * one the first 16 words of any of the first 7 metadata types.
801 : : */
802 : : static inline union cpfl_action_set
803 : : cpfl_act_set_md16(uint8_t slot, uint8_t prec, uint8_t mid, uint8_t word_off, uint16_t val)
804 : : {
805 : : union cpfl_action_set a;
806 : : uint32_t tmp;
807 : :
808 : : if (!CPFL_ACT_PREC_CHECK(prec) || slot >= CPFL_ACT_24B_SET_MD_SLOTS ||
809 : : mid > CPFL_ACT_24B_SET_MD16_TYPE_ID_MAX ||
810 : : word_off > CPFL_ACT_24B_SET_MD16_OFFSET_MAX)
811 : : return cpfl_act_nop();
812 : :
813 : : tmp = ((uint32_t)CPFL_ACT_24B_SET_MD16) |
814 : : ((uint32_t)mid << CPFL_ACT_24B_SET_MD16_TYPE_ID_S) |
815 : : ((uint32_t)word_off << CPFL_ACT_24B_SET_MD16_OFFSET_S) |
816 : : ((uint32_t)val << CPFL_ACT_24B_SET_MD16_VAL_S);
817 : : a.data = CPFL_ACT_MAKE_24B_B(prec, CPFL_ACT_24B_INDEX_SET_MD + slot,
818 : : tmp);
819 : :
820 : : return a;
821 : : }
822 : :
823 : : /**
824 : : * cpfl_act_set_md32_ext - Encode a 24-bit SET_MD/32 action for an action slot
825 : : *
826 : : * This SET_MD action sets/updates a dword of a given metadata ID structure
827 : : * using one of the SET_MD action slots. This action is made up of 2 chained
828 : : * action sets. The chained action set is the first. The base/parent action
829 : : * sets is the second.
830 : : */
831 : : static inline void
832 : : cpfl_act_set_md32_ext(struct cpfl_action_set_ext *ext, uint8_t slot, uint8_t prec, uint8_t mid,
833 : : uint8_t off, uint32_t val)
834 : : {
835 : : if (slot >= CPFL_ACT_24B_SET_MD_SLOTS || !CPFL_ACT_PREC_CHECK(prec) ||
836 : : mid >= CPFL_METADATA_ID_CNT ||
837 : : (off + sizeof(uint32_t)) > CPFL_METADATA_STRUCT_MAX_SZ) {
838 : : ext->acts[0] = cpfl_act_nop();
839 : : ext->acts[1] = cpfl_act_nop();
840 : : } else {
841 : : uint32_t tmp;
842 : :
843 : : /* Chained action set comes first */
844 : : tmp = val >> CPFL_ACT_24B_SET_MD_AUX_32B_VAL_H_SR;
845 : : ext->acts[0].data =
846 : : CPFL_ACT_24B_SET_MD_AUX_MAKE(CPFL_ACT_24B_SET_MD_OP_32B,
847 : : mid, off, tmp);
848 : :
849 : : /* Lower 24 bits of value */
850 : : tmp = val & CPFL_ACT_24B_SET_MD32_VAL_L_M;
851 : : ext->acts[1].data =
852 : : CPFL_ACT_MAKE_24B_B(prec,
853 : : CPFL_ACT_24B_INDEX_SET_MD + slot,
854 : : tmp);
855 : : }
856 : : }
857 : :
858 : : #endif /* _CPFL_ACTIONS_H_ */
|