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 /** CFA phase 4 fix formatted table(layout) ID definition
13 CFA_P4_TBL_L2CTXT_TCAM = 0,
14 CFA_P4_TBL_L2CTXT_REMAP,
16 CFA_P4_TBL_PROF_TCAM_REMAP,
18 CFA_P4_TBL_WC_TCAM_REC,
19 CFA_P4_TBL_WC_TCAM_REMAP,
22 CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT,
23 CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
24 CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
25 CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR,
29 #define CFA_P4_PROF_MAX_KEYS 4
30 enum cfa_p4_mac_sel_mode {
31 CFA_P4_MAC_SEL_MODE_FIRST = 0,
32 CFA_P4_MAC_SEL_MODE_LOWEST = 1,
35 struct cfa_p4_prof_key_cfg {
36 uint8_t mac_sel[CFA_P4_PROF_MAX_KEYS];
37 #define CFA_P4_PROF_MAC_SEL_DMAC0 (1 << 0)
38 #define CFA_P4_PROF_MAC_SEL_T_MAC0 (1 << 1)
39 #define CFA_P4_PROF_MAC_SEL_OUTERMOST_MAC0 (1 << 2)
40 #define CFA_P4_PROF_MAC_SEL_DMAC1 (1 << 3)
41 #define CFA_P4_PROF_MAC_SEL_T_MAC1 (1 << 4)
42 #define CFA_P4_PROF_MAC_OUTERMOST_MAC1 (1 << 5)
44 enum cfa_p4_mac_sel_mode mode;
48 * CFA action layout definition
51 #define CFA_P4_ACTION_MAX_LAYOUT_SIZE 184
54 * Action object template structure
56 * Template structure presents data fields that are necessary to know
57 * at the beginning of Action Builder (AB) processing. Like before the
58 * AB compilation. One such example could be a template that is
59 * flexible in size (Encap Record) and the presence of these fields
60 * allows for determining the template size as well as where the
61 * fields are located in the record.
63 * The template may also present fields that are not made visible to
64 * the caller by way of the action fields.
66 * Template fields also allow for additional checking on user visible
67 * fields. One such example could be the encap pointer behavior on a
68 * CFA_P4_ACT_OBJ_TYPE_ACT or CFA_P4_ACT_OBJ_TYPE_ACT_SRAM.
70 struct cfa_p4_action_template {
71 /** Action Object type
73 * Controls the type of the Action Template
76 /** Select this type to build an Action Record Object
78 CFA_P4_ACT_OBJ_TYPE_ACT,
79 /** Select this type to build an Action Statistics
82 CFA_P4_ACT_OBJ_TYPE_STAT,
83 /** Select this type to build a SRAM Action Record
86 CFA_P4_ACT_OBJ_TYPE_ACT_SRAM,
87 /** Select this type to build a SRAM Action
88 * Encapsulation Object.
90 CFA_P4_ACT_OBJ_TYPE_ENCAP_SRAM,
91 /** Select this type to build a SRAM Action Modify
92 * Object, with IPv4 capability.
94 /* In case of Stingray the term Modify is used for the 'NAT
95 * action'. Action builder is leveraged to fill in the NAT
96 * object which then can be referenced by the action
99 CFA_P4_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
100 /** Select this type to build a SRAM Action Source
103 /* In case of Stingray this is not a 'pure' action record.
104 * Action builder is leveraged to full in the Source Property
105 * object which can then be referenced by the action
108 CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM,
109 /** Select this type to build a SRAM Action Statistics
112 CFA_P4_ACT_OBJ_TYPE_STAT_SRAM,
117 * Controls the internals of the Action Template
120 * (obj_type == CFA_P4_ACT_OBJ_TYPE_ACT)
123 * Stat and encap are always inline for EEM as table scope
124 * allocation does not allow for separate Stats allocation,
125 * but has the xx_inline flags as to be forward compatible
126 * with Stingray 2, always treated as TRUE.
129 /** Set to CFA_HCAPI_TRUE to enable statistics
132 /** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
136 /** Set to CFA_HCAPI_TRUE to enable encapsulation
138 uint8_t encap_enable;
139 /** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
141 uint8_t encap_inline;
146 * Controls the type of the Modify Action the template is
149 * modify is valid when:
150 * (obj_type == CFA_P4_ACT_OBJ_TYPE_MODIFY_SRAM)
153 /** Set to enable Modify of Source IPv4 Address
155 CFA_P4_MR_REPLACE_SOURCE_IPV4 = 0,
156 /** Set to enable Modify of Destination IPv4 Address
158 CFA_P4_MR_REPLACE_DEST_IPV4
162 * Controls the type of encapsulation the template is
165 * encap is valid when:
166 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_ACT) &&
167 * act.encap_enable) ||
168 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM)
171 /* Direction is required as Stingray Encap on RX is
172 * limited to l2 and VTAG only.
174 /** Receive or Transmit direction
177 /** Set to CFA_HCAPI_TRUE to enable L2 capability in the
181 /** vtag controls the Encap Vector - VTAG Encoding, 4 bits
184 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
186 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
187 * set 1 VLAN Tag. Action Template compile adds
188 * the following field to the action object
190 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
191 * set 2 VLAN Tags. Action Template compile adds
192 * the following fields to the action object
193 * ::TF_ER_VLAN1 and ::TF_ER_VLAN2
196 enum { CFA_P4_ACT_ENCAP_VTAGS_PUSH_0 = 0,
197 CFA_P4_ACT_ENCAP_VTAGS_PUSH_1,
198 CFA_P4_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
201 * The remaining fields are NOT supported when
202 * direction is RX and ((obj_type ==
203 * CFA_P4_ACT_OBJ_TYPE_ACT) && act.encap_enable).
204 * ab_compile_layout will perform the checking and
205 * skip remaining fields.
207 /** L3 Encap controls the Encap Vector - L3 Encoding,
208 * 3 bits. Defines the type of L3 Encapsulation the
209 * template is describing.
211 * <li> CFA_P4_ACT_ENCAP_L3_NONE, default, no L3
212 * Encapsulation processing.
213 * <li> CFA_P4_ACT_ENCAP_L3_IPV4, enables L3 IPv4
215 * <li> CFA_P4_ACT_ENCAP_L3_IPV6, enables L3 IPv6
217 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
218 * 8847 Encapsulation.
219 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
220 * 8848 Encapsulation.
224 /** Set to disable any L3 encapsulation
225 * processing, default
227 CFA_P4_ACT_ENCAP_L3_NONE = 0,
228 /** Set to enable L3 IPv4 encapsulation
230 CFA_P4_ACT_ENCAP_L3_IPV4 = 4,
231 /** Set to enable L3 IPv6 encapsulation
233 CFA_P4_ACT_ENCAP_L3_IPV6 = 5,
234 /** Set to enable L3 MPLS 8847 encapsulation
236 CFA_P4_ACT_ENCAP_L3_MPLS_8847 = 6,
237 /** Set to enable L3 MPLS 8848 encapsulation
239 CFA_P4_ACT_ENCAP_L3_MPLS_8848 = 7
242 #define CFA_P4_ACT_ENCAP_MAX_MPLS_LABELS 8
243 /** 1-8 labels, valid when
244 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8847) ||
245 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8848)
247 * MAX number of MPLS Labels 8.
249 uint8_t l3_num_mpls_labels;
251 /** Set to CFA_HCAPI_TRUE to enable L4 capability in the
254 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
255 * ::TF_EN_UDP_DST_PORT to the template.
259 /** Tunnel Encap controls the Encap Vector - Tunnel
260 * Encap, 3 bits. Defines the type of Tunnel
261 * encapsulation the template is describing
263 * <li> CFA_P4_ACT_ENCAP_TNL_NONE, default, no Tunnel
264 * Encapsulation processing.
265 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL
266 * <li> CFA_P4_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
267 * l4_enable set to CFA_P4_TRUE;
268 * <li> CFA_P4_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
269 * set to CFA_P4_TRUE;
270 * <li> CFA_P4_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
271 * l4_enable set to CFA_HCAPI_FALSE.
272 * <li> CFA_P4_ACT_ENCAP_TNL_GRE.NOTE: only valid if
273 * l4_enable set to CFA_HCAPI_FALSE.
274 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
275 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
279 /** Set to disable Tunnel header encapsulation
280 * processing, default
282 CFA_P4_ACT_ENCAP_TNL_NONE = 0,
283 /** Set to enable Tunnel Generic Full header
286 CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL,
287 /** Set to enable VXLAN header encapsulation
289 CFA_P4_ACT_ENCAP_TNL_VXLAN,
290 /** Set to enable NGE (VXLAN2) header encapsulation
292 CFA_P4_ACT_ENCAP_TNL_NGE,
293 /** Set to enable NVGRE header encapsulation
295 CFA_P4_ACT_ENCAP_TNL_NVGRE,
296 /** Set to enable GRE header encapsulation
298 CFA_P4_ACT_ENCAP_TNL_GRE,
299 /** Set to enable Generic header after Tunnel
302 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
303 /** Set to enable Generic header after Tunnel
306 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
309 /** Number of bytes of generic tunnel header,
311 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL) ||
312 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
313 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
315 uint8_t tnl_generic_size;
316 /** Number of 32b words of nge options,
318 * (tnl == CFA_P4_ACT_ENCAP_TNL_NGE)
320 uint8_t tnl_nge_op_len;
321 /* Currently not planned */
323 /* uint8_t custom_enable; */
328 * Enumeration of SRAM entry types, used for allocation of
329 * fixed SRAM entities. The memory model for CFA HCAPI
330 * determines if an SRAM entry type is supported.
332 enum cfa_p4_action_sram_entry_type {
333 /* NOTE: Any additions to this enum must be reflected on FW
337 /** SRAM Action Record */
338 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FULL_ACTION,
340 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_0_ACTION,
341 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_1_ACTION,
342 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_2_ACTION,
343 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_3_ACTION,
344 CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_4_ACTION,
346 /** SRAM Action Encap 8 Bytes */
347 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
348 /** SRAM Action Encap 16 Bytes */
349 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
350 /** SRAM Action Encap 64 Bytes */
351 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
353 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_SRC,
354 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_DEST,
356 /** SRAM Action Modify IPv4 Source */
357 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
358 /** SRAM Action Modify IPv4 Destination */
359 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
361 /** SRAM Action Source Properties SMAC */
362 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
363 /** SRAM Action Source Properties SMAC IPv4 */
364 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV4,
365 /** SRAM Action Source Properties SMAC IPv6 */
366 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV6,
367 /** SRAM Action Statistics 64 Bits */
368 CFA_P4_ACTION_SRAM_ENTRY_TYPE_STATS_64,
369 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MAX
373 * SRAM Action Record structure holding either an action index or an
376 union cfa_p4_action_sram_act_record {
377 /** SRAM Action idx specifies the offset of the SRAM
378 * element within its SRAM Entry Type block. This
379 * index can be written into i.e. an L2 Context. Use
380 * this type for all SRAM Action Record types except
381 * SRAM Full Action records. Use act_ptr instead.
384 /** SRAM Full Action is special in that it needs an
385 * action record pointer. This pointer can be written
386 * into i.e. a Wildcard TCAM entry.
392 * cfa_p4_action_param parameter definition
394 struct cfa_p4_action_param {
396 * [in] receive or transmit direction
400 * [in] type of the sram allocation type
402 enum cfa_p4_action_sram_entry_type type;
404 * [in] action record to set. The 'type' specified lists the
405 * record definition to use in the passed in record.
407 union cfa_p4_action_sram_act_record record;
409 * [in] number of elements in act_data
413 * [in] ptr to array of action data
419 * EEM Key entry sizes
421 #define CFA_P4_EEM_KEY_MAX_SIZE 52
422 #define CFA_P4_EEM_KEY_RECORD_SIZE 64
427 struct cfa_p4_eem_entry_hdr {
430 * The header is made up of two words,
431 * this is the first word. This field has multiple
432 * subfields, there is no suitable single name for
433 * it so just going with word1.
435 #define CFA_P4_EEM_ENTRY_VALID_SHIFT 31
436 #define CFA_P4_EEM_ENTRY_VALID_MASK 0x80000000
437 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_SHIFT 30
438 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_MASK 0x40000000
439 #define CFA_P4_EEM_ENTRY_STRENGTH_SHIFT 28
440 #define CFA_P4_EEM_ENTRY_STRENGTH_MASK 0x30000000
441 #define CFA_P4_EEM_ENTRY_RESERVED_SHIFT 17
442 #define CFA_P4_EEM_ENTRY_RESERVED_MASK 0x0FFE0000
443 #define CFA_P4_EEM_ENTRY_KEY_SIZE_SHIFT 8
444 #define CFA_P4_EEM_ENTRY_KEY_SIZE_MASK 0x0001FF00
445 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_SHIFT 3
446 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_MASK 0x000000F8
447 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_SHIFT 2
448 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_MASK 0x00000004
449 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_SHIFT 1
450 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_MASK 0x00000002
451 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_SHIFT 0
452 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_MASK 0x00000001
456 * cfa_p4_eem_key_entry
458 struct cfa_p4_eem_64b_entry {
459 /** Key is 448 bits - 56 bytes */
460 uint8_t key[CFA_P4_EEM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
461 /** Header is 8 bytes long */
462 struct cfa_p4_eem_entry_hdr hdr;
465 #endif /* _CFA_HW_P4_H_ */