1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2021 Broadcom
6 #ifndef _HCAPI_CFA_P4_H_
7 #define _HCAPI_CFA_P4_H_
9 #include "cfa_p40_hw.h"
11 /** CFA phase 4 fix formatted table(layout) ID definition
15 CFA_P4_TBL_L2CTXT_TCAM = 0,
16 CFA_P4_TBL_L2CTXT_REMAP,
18 CFA_P4_TBL_PROF_TCAM_REMAP,
20 CFA_P4_TBL_WC_TCAM_REC,
21 CFA_P4_TBL_WC_TCAM_REMAP,
24 CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT,
25 CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
26 CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
27 CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR,
31 #define CFA_P4_PROF_MAX_KEYS 4
32 enum cfa_p4_mac_sel_mode {
33 CFA_P4_MAC_SEL_MODE_FIRST = 0,
34 CFA_P4_MAC_SEL_MODE_LOWEST = 1,
37 struct cfa_p4_prof_key_cfg {
38 uint8_t mac_sel[CFA_P4_PROF_MAX_KEYS];
39 #define CFA_P4_PROF_MAC_SEL_DMAC0 (1 << 0)
40 #define CFA_P4_PROF_MAC_SEL_T_MAC0 (1 << 1)
41 #define CFA_P4_PROF_MAC_SEL_OUTERMOST_MAC0 (1 << 2)
42 #define CFA_P4_PROF_MAC_SEL_DMAC1 (1 << 3)
43 #define CFA_P4_PROF_MAC_SEL_T_MAC1 (1 << 4)
44 #define CFA_P4_PROF_MAC_OUTERMOST_MAC1 (1 << 5)
46 enum cfa_p4_mac_sel_mode mode;
50 * CFA action layout definition
53 #define CFA_P4_ACTION_MAX_LAYOUT_SIZE 184
56 * Action object template structure
58 * Template structure presents data fields that are necessary to know
59 * at the beginning of Action Builder (AB) processing. Like before the
60 * AB compilation. One such example could be a template that is
61 * flexible in size (Encap Record) and the presence of these fields
62 * allows for determining the template size as well as where the
63 * fields are located in the record.
65 * The template may also present fields that are not made visible to
66 * the caller by way of the action fields.
68 * Template fields also allow for additional checking on user visible
69 * fields. One such example could be the encap pointer behavior on a
70 * CFA_P4_ACT_OBJ_TYPE_ACT or CFA_P4_ACT_OBJ_TYPE_ACT_SRAM.
72 struct cfa_p4_action_template {
73 /** Action Object type
75 * Controls the type of the Action Template
78 /** Select this type to build an Action Record Object
80 CFA_P4_ACT_OBJ_TYPE_ACT,
81 /** Select this type to build an Action Statistics
84 CFA_P4_ACT_OBJ_TYPE_STAT,
85 /** Select this type to build a SRAM Action Record
88 CFA_P4_ACT_OBJ_TYPE_ACT_SRAM,
89 /** Select this type to build a SRAM Action
90 * Encapsulation Object.
92 CFA_P4_ACT_OBJ_TYPE_ENCAP_SRAM,
93 /** Select this type to build a SRAM Action Modify
94 * Object, with IPv4 capability.
96 /* In case of Stingray the term Modify is used for the 'NAT
97 * action'. Action builder is leveraged to fill in the NAT
98 * object which then can be referenced by the action
101 CFA_P4_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
102 /** Select this type to build a SRAM Action Source
105 /* In case of Stingray this is not a 'pure' action record.
106 * Action builder is leveraged to full in the Source Property
107 * object which can then be referenced by the action
110 CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM,
111 /** Select this type to build a SRAM Action Statistics
114 CFA_P4_ACT_OBJ_TYPE_STAT_SRAM,
119 * Controls the internals of the Action Template
122 * (obj_type == CFA_P4_ACT_OBJ_TYPE_ACT)
125 * Stat and encap are always inline for EEM as table scope
126 * allocation does not allow for separate Stats allocation,
127 * but has the xx_inline flags as to be forward compatible
128 * with Stingray 2, always treated as TRUE.
131 /** Set to CFA_HCAPI_TRUE to enable statistics
134 /** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
138 /** Set to CFA_HCAPI_TRUE to enable encapsulation
140 uint8_t encap_enable;
141 /** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
143 uint8_t encap_inline;
148 * Controls the type of the Modify Action the template is
151 * modify is valid when:
152 * (obj_type == CFA_P4_ACT_OBJ_TYPE_MODIFY_SRAM)
155 /** Set to enable Modify of Source IPv4 Address
157 CFA_P4_MR_REPLACE_SOURCE_IPV4 = 0,
158 /** Set to enable Modify of Destination IPv4 Address
160 CFA_P4_MR_REPLACE_DEST_IPV4
164 * Controls the type of encapsulation the template is
167 * encap is valid when:
168 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_ACT) &&
169 * act.encap_enable) ||
170 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM)
173 /* Direction is required as Stingray Encap on RX is
174 * limited to l2 and VTAG only.
176 /** Receive or Transmit direction
179 /** Set to CFA_HCAPI_TRUE to enable L2 capability in the
183 /** vtag controls the Encap Vector - VTAG Encoding, 4 bits
186 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
188 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
189 * set 1 VLAN Tag. Action Template compile adds
190 * the following field to the action object
192 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
193 * set 2 VLAN Tags. Action Template compile adds
194 * the following fields to the action object
195 * ::TF_ER_VLAN1 and ::TF_ER_VLAN2
198 enum { CFA_P4_ACT_ENCAP_VTAGS_PUSH_0 = 0,
199 CFA_P4_ACT_ENCAP_VTAGS_PUSH_1,
200 CFA_P4_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
203 * The remaining fields are NOT supported when
204 * direction is RX and ((obj_type ==
205 * CFA_P4_ACT_OBJ_TYPE_ACT) && act.encap_enable).
206 * ab_compile_layout will perform the checking and
207 * skip remaining fields.
209 /** L3 Encap controls the Encap Vector - L3 Encoding,
210 * 3 bits. Defines the type of L3 Encapsulation the
211 * template is describing.
213 * <li> CFA_P4_ACT_ENCAP_L3_NONE, default, no L3
214 * Encapsulation processing.
215 * <li> CFA_P4_ACT_ENCAP_L3_IPV4, enables L3 IPv4
217 * <li> CFA_P4_ACT_ENCAP_L3_IPV6, enables L3 IPv6
219 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
220 * 8847 Encapsulation.
221 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
222 * 8848 Encapsulation.
226 /** Set to disable any L3 encapsulation
227 * processing, default
229 CFA_P4_ACT_ENCAP_L3_NONE = 0,
230 /** Set to enable L3 IPv4 encapsulation
232 CFA_P4_ACT_ENCAP_L3_IPV4 = 4,
233 /** Set to enable L3 IPv6 encapsulation
235 CFA_P4_ACT_ENCAP_L3_IPV6 = 5,
236 /** Set to enable L3 MPLS 8847 encapsulation
238 CFA_P4_ACT_ENCAP_L3_MPLS_8847 = 6,
239 /** Set to enable L3 MPLS 8848 encapsulation
241 CFA_P4_ACT_ENCAP_L3_MPLS_8848 = 7
244 #define CFA_P4_ACT_ENCAP_MAX_MPLS_LABELS 8
245 /** 1-8 labels, valid when
246 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8847) ||
247 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8848)
249 * MAX number of MPLS Labels 8.
251 uint8_t l3_num_mpls_labels;
253 /** Set to CFA_HCAPI_TRUE to enable L4 capability in the
256 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
257 * ::TF_EN_UDP_DST_PORT to the template.
261 /** Tunnel Encap controls the Encap Vector - Tunnel
262 * Encap, 3 bits. Defines the type of Tunnel
263 * encapsulation the template is describing
265 * <li> CFA_P4_ACT_ENCAP_TNL_NONE, default, no Tunnel
266 * Encapsulation processing.
267 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL
268 * <li> CFA_P4_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
269 * l4_enable set to CFA_P4_TRUE;
270 * <li> CFA_P4_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
271 * set to CFA_P4_TRUE;
272 * <li> CFA_P4_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
273 * l4_enable set to CFA_HCAPI_FALSE.
274 * <li> CFA_P4_ACT_ENCAP_TNL_GRE.NOTE: only valid if
275 * l4_enable set to CFA_HCAPI_FALSE.
276 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
277 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
281 /** Set to disable Tunnel header encapsulation
282 * processing, default
284 CFA_P4_ACT_ENCAP_TNL_NONE = 0,
285 /** Set to enable Tunnel Generic Full header
288 CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL,
289 /** Set to enable VXLAN header encapsulation
291 CFA_P4_ACT_ENCAP_TNL_VXLAN,
292 /** Set to enable NGE (VXLAN2) header encapsulation
294 CFA_P4_ACT_ENCAP_TNL_NGE,
295 /** Set to enable NVGRE header encapsulation
297 CFA_P4_ACT_ENCAP_TNL_NVGRE,
298 /** Set to enable GRE header encapsulation
300 CFA_P4_ACT_ENCAP_TNL_GRE,
301 /** Set to enable Generic header after Tunnel
304 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
305 /** Set to enable Generic header after Tunnel
308 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
311 /** Number of bytes of generic tunnel header,
313 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL) ||
314 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
315 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
317 uint8_t tnl_generic_size;
318 /** Number of 32b words of nge options,
320 * (tnl == CFA_P4_ACT_ENCAP_TNL_NGE)
322 uint8_t tnl_nge_op_len;
323 /* Currently not planned */
325 /* uint8_t custom_enable; */
330 * Enumeration of SRAM entry types, used for allocation of
331 * fixed SRAM entities. The memory model for CFA HCAPI
332 * determines if an SRAM entry type is supported.
334 enum cfa_p4_action_sram_entry_type {
335 /* NOTE: Any additions to this enum must be reflected on FW
339 /** SRAM Action Record */
340 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FULL_ACTION,
342 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_0_ACTION,
343 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_1_ACTION,
344 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_2_ACTION,
345 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_3_ACTION,
346 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_4_ACTION,
348 /** SRAM Action Encap 8 Bytes */
349 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
350 /** SRAM Action Encap 16 Bytes */
351 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
352 /** SRAM Action Encap 64 Bytes */
353 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
355 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_SRC,
356 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_DEST,
358 /** SRAM Action Modify IPv4 Source */
359 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
360 /** SRAM Action Modify IPv4 Destination */
361 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
363 /** SRAM Action Source Properties SMAC */
364 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
365 /** SRAM Action Source Properties SMAC IPv4 */
366 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV4,
367 /** SRAM Action Source Properties SMAC IPv6 */
368 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV6,
369 /** SRAM Action Statistics 64 Bits */
370 CFA_P4_ACTION_SRAM_ENTRY_TYPE_STATS_64,
371 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MAX
375 * SRAM Action Record structure holding either an action index or an
378 union cfa_p4_action_sram_act_record {
379 /** SRAM Action idx specifies the offset of the SRAM
380 * element within its SRAM Entry Type block. This
381 * index can be written into i.e. an L2 Context. Use
382 * this type for all SRAM Action Record types except
383 * SRAM Full Action records. Use act_ptr instead.
386 /** SRAM Full Action is special in that it needs an
387 * action record pointer. This pointer can be written
388 * into i.e. a Wildcard TCAM entry.
394 * cfa_p4_action_param parameter definition
396 struct cfa_p4_action_param {
398 * [in] receive or transmit direction
402 * [in] type of the sram allocation type
404 enum cfa_p4_action_sram_entry_type type;
406 * [in] action record to set. The 'type' specified lists the
407 * record definition to use in the passed in record.
409 union cfa_p4_action_sram_act_record record;
411 * [in] number of elements in act_data
415 * [in] ptr to array of action data
421 * EEM Key entry sizes
423 #define CFA_P4_EEM_KEY_MAX_SIZE 52
424 #define CFA_P4_EEM_KEY_RECORD_SIZE 64
429 struct cfa_p4_eem_entry_hdr {
432 * The header is made up of two words,
433 * this is the first word. This field has multiple
434 * subfields, there is no suitable single name for
435 * it so just going with word1.
437 #define CFA_P4_EEM_ENTRY_VALID_SHIFT 31
438 #define CFA_P4_EEM_ENTRY_VALID_MASK 0x80000000
439 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_SHIFT 30
440 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_MASK 0x40000000
441 #define CFA_P4_EEM_ENTRY_STRENGTH_SHIFT 28
442 #define CFA_P4_EEM_ENTRY_STRENGTH_MASK 0x30000000
443 #define CFA_P4_EEM_ENTRY_RESERVED_SHIFT 17
444 #define CFA_P4_EEM_ENTRY_RESERVED_MASK 0x0FFE0000
445 #define CFA_P4_EEM_ENTRY_KEY_SIZE_SHIFT 8
446 #define CFA_P4_EEM_ENTRY_KEY_SIZE_MASK 0x0001FF00
447 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_SHIFT 3
448 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_MASK 0x000000F8
449 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_SHIFT 2
450 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_MASK 0x00000004
451 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_SHIFT 1
452 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_MASK 0x00000002
453 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_SHIFT 0
454 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_MASK 0x00000001
458 * cfa_p4_eem_key_entry
460 struct cfa_p4_eem_64b_entry {
461 /** Key is 448 bits - 56 bytes */
462 uint8_t key[CFA_P4_EEM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
463 /** Header is 8 bytes long */
464 struct cfa_p4_eem_entry_hdr hdr;
467 #endif /* _CFA_HW_P4_H_ */