1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2020 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,
27 #define CFA_P4_PROF_MAX_KEYS 4
28 enum cfa_p4_mac_sel_mode {
29 CFA_P4_MAC_SEL_MODE_FIRST = 0,
30 CFA_P4_MAC_SEL_MODE_LOWEST = 1,
33 struct cfa_p4_prof_key_cfg {
34 uint8_t mac_sel[CFA_P4_PROF_MAX_KEYS];
35 #define CFA_P4_PROF_MAC_SEL_DMAC0 (1 << 0)
36 #define CFA_P4_PROF_MAC_SEL_T_MAC0 (1 << 1)
37 #define CFA_P4_PROF_MAC_SEL_OUTERMOST_MAC0 (1 << 2)
38 #define CFA_P4_PROF_MAC_SEL_DMAC1 (1 << 3)
39 #define CFA_P4_PROF_MAC_SEL_T_MAC1 (1 << 4)
40 #define CFA_P4_PROF_MAC_OUTERMOST_MAC1 (1 << 5)
42 enum cfa_p4_mac_sel_mode mode;
46 * CFA action layout definition
49 #define CFA_P4_ACTION_MAX_LAYOUT_SIZE 184
52 * Action object template structure
54 * Template structure presents data fields that are necessary to know
55 * at the beginning of Action Builder (AB) processing. Like before the
56 * AB compilation. One such example could be a template that is
57 * flexible in size (Encap Record) and the presence of these fields
58 * allows for determining the template size as well as where the
59 * fields are located in the record.
61 * The template may also present fields that are not made visible to
62 * the caller by way of the action fields.
64 * Template fields also allow for additional checking on user visible
65 * fields. One such example could be the encap pointer behavior on a
66 * CFA_P4_ACT_OBJ_TYPE_ACT or CFA_P4_ACT_OBJ_TYPE_ACT_SRAM.
68 struct cfa_p4_action_template {
69 /** Action Object type
71 * Controls the type of the Action Template
74 /** Select this type to build an Action Record Object
76 CFA_P4_ACT_OBJ_TYPE_ACT,
77 /** Select this type to build an Action Statistics
80 CFA_P4_ACT_OBJ_TYPE_STAT,
81 /** Select this type to build a SRAM Action Record
84 CFA_P4_ACT_OBJ_TYPE_ACT_SRAM,
85 /** Select this type to build a SRAM Action
86 * Encapsulation Object.
88 CFA_P4_ACT_OBJ_TYPE_ENCAP_SRAM,
89 /** Select this type to build a SRAM Action Modify
90 * Object, with IPv4 capability.
92 /* In case of Stingray the term Modify is used for the 'NAT
93 * action'. Action builder is leveraged to fill in the NAT
94 * object which then can be referenced by the action
97 CFA_P4_ACT_OBJ_TYPE_MODIFY_IPV4_SRAM,
98 /** Select this type to build a SRAM Action Source
101 /* In case of Stingray this is not a 'pure' action record.
102 * Action builder is leveraged to full in the Source Property
103 * object which can then be referenced by the action
106 CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM,
107 /** Select this type to build a SRAM Action Statistics
110 CFA_P4_ACT_OBJ_TYPE_STAT_SRAM,
115 * Controls the internals of the Action Template
118 * (obj_type == CFA_P4_ACT_OBJ_TYPE_ACT)
121 * Stat and encap are always inline for EEM as table scope
122 * allocation does not allow for separate Stats allocation,
123 * but has the xx_inline flags as to be forward compatible
124 * with Stingray 2, always treated as TRUE.
127 /** Set to CFA_HCAPI_TRUE to enable statistics
130 /** Set to CFA_HCAPI_TRUE to enable statistics to be inlined
134 /** Set to CFA_HCAPI_TRUE to enable encapsulation
136 uint8_t encap_enable;
137 /** Set to CFA_HCAPI_TRUE to enable encapsulation to be inlined
139 uint8_t encap_inline;
144 * Controls the type of the Modify Action the template is
147 * modify is valid when:
148 * (obj_type == CFA_P4_ACT_OBJ_TYPE_MODIFY_SRAM)
151 /** Set to enable Modify of Source IPv4 Address
153 CFA_P4_MR_REPLACE_SOURCE_IPV4 = 0,
154 /** Set to enable Modify of Destination IPv4 Address
156 CFA_P4_MR_REPLACE_DEST_IPV4
160 * Controls the type of encapsulation the template is
163 * encap is valid when:
164 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_ACT) &&
165 * act.encap_enable) ||
166 * ((obj_type == CFA_P4_ACT_OBJ_TYPE_SRC_PROP_SRAM)
169 /* Direction is required as Stingray Encap on RX is
170 * limited to l2 and VTAG only.
172 /** Receive or Transmit direction
175 /** Set to CFA_HCAPI_TRUE to enable L2 capability in the
179 /** vtag controls the Encap Vector - VTAG Encoding, 4 bits
182 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_0, default, no VLAN
184 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_1, adds capability to
185 * set 1 VLAN Tag. Action Template compile adds
186 * the following field to the action object
188 * <li> CFA_P4_ACT_ENCAP_VTAGS_PUSH_2, adds capability to
189 * set 2 VLAN Tags. Action Template compile adds
190 * the following fields to the action object
191 * ::TF_ER_VLAN1 and ::TF_ER_VLAN2
194 enum { CFA_P4_ACT_ENCAP_VTAGS_PUSH_0 = 0,
195 CFA_P4_ACT_ENCAP_VTAGS_PUSH_1,
196 CFA_P4_ACT_ENCAP_VTAGS_PUSH_2 } vtag;
199 * The remaining fields are NOT supported when
200 * direction is RX and ((obj_type ==
201 * CFA_P4_ACT_OBJ_TYPE_ACT) && act.encap_enable).
202 * ab_compile_layout will perform the checking and
203 * skip remaining fields.
205 /** L3 Encap controls the Encap Vector - L3 Encoding,
206 * 3 bits. Defines the type of L3 Encapsulation the
207 * template is describing.
209 * <li> CFA_P4_ACT_ENCAP_L3_NONE, default, no L3
210 * Encapsulation processing.
211 * <li> CFA_P4_ACT_ENCAP_L3_IPV4, enables L3 IPv4
213 * <li> CFA_P4_ACT_ENCAP_L3_IPV6, enables L3 IPv6
215 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8847, enables L3 MPLS
216 * 8847 Encapsulation.
217 * <li> CFA_P4_ACT_ENCAP_L3_MPLS_8848, enables L3 MPLS
218 * 8848 Encapsulation.
222 /** Set to disable any L3 encapsulation
223 * processing, default
225 CFA_P4_ACT_ENCAP_L3_NONE = 0,
226 /** Set to enable L3 IPv4 encapsulation
228 CFA_P4_ACT_ENCAP_L3_IPV4 = 4,
229 /** Set to enable L3 IPv6 encapsulation
231 CFA_P4_ACT_ENCAP_L3_IPV6 = 5,
232 /** Set to enable L3 MPLS 8847 encapsulation
234 CFA_P4_ACT_ENCAP_L3_MPLS_8847 = 6,
235 /** Set to enable L3 MPLS 8848 encapsulation
237 CFA_P4_ACT_ENCAP_L3_MPLS_8848 = 7
240 #define CFA_P4_ACT_ENCAP_MAX_MPLS_LABELS 8
241 /** 1-8 labels, valid when
242 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8847) ||
243 * (l3 == CFA_P4_ACT_ENCAP_L3_MPLS_8848)
245 * MAX number of MPLS Labels 8.
247 uint8_t l3_num_mpls_labels;
249 /** Set to CFA_HCAPI_TRUE to enable L4 capability in the
252 * CFA_HCAPI_TRUE adds ::TF_EN_UDP_SRC_PORT and
253 * ::TF_EN_UDP_DST_PORT to the template.
257 /** Tunnel Encap controls the Encap Vector - Tunnel
258 * Encap, 3 bits. Defines the type of Tunnel
259 * encapsulation the template is describing
261 * <li> CFA_P4_ACT_ENCAP_TNL_NONE, default, no Tunnel
262 * Encapsulation processing.
263 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL
264 * <li> CFA_P4_ACT_ENCAP_TNL_VXLAN. NOTE: Expects
265 * l4_enable set to CFA_P4_TRUE;
266 * <li> CFA_P4_ACT_ENCAP_TNL_NGE. NOTE: Expects l4_enable
267 * set to CFA_P4_TRUE;
268 * <li> CFA_P4_ACT_ENCAP_TNL_NVGRE. NOTE: only valid if
269 * l4_enable set to CFA_HCAPI_FALSE.
270 * <li> CFA_P4_ACT_ENCAP_TNL_GRE.NOTE: only valid if
271 * l4_enable set to CFA_HCAPI_FALSE.
272 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4
273 * <li> CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
277 /** Set to disable Tunnel header encapsulation
278 * processing, default
280 CFA_P4_ACT_ENCAP_TNL_NONE = 0,
281 /** Set to enable Tunnel Generic Full header
284 CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL,
285 /** Set to enable VXLAN header encapsulation
287 CFA_P4_ACT_ENCAP_TNL_VXLAN,
288 /** Set to enable NGE (VXLAN2) header encapsulation
290 CFA_P4_ACT_ENCAP_TNL_NGE,
291 /** Set to enable NVGRE header encapsulation
293 CFA_P4_ACT_ENCAP_TNL_NVGRE,
294 /** Set to enable GRE header encapsulation
296 CFA_P4_ACT_ENCAP_TNL_GRE,
297 /** Set to enable Generic header after Tunnel
300 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4,
301 /** Set to enable Generic header after Tunnel
304 CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL
307 /** Number of bytes of generic tunnel header,
309 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_FULL) ||
310 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TL4) ||
311 * (tnl == CFA_P4_ACT_ENCAP_TNL_GENERIC_AFTER_TNL)
313 uint8_t tnl_generic_size;
314 /** Number of 32b words of nge options,
316 * (tnl == CFA_P4_ACT_ENCAP_TNL_NGE)
318 uint8_t tnl_nge_op_len;
319 /* Currently not planned */
321 /* uint8_t custom_enable; */
326 * Enumeration of SRAM entry types, used for allocation of
327 * fixed SRAM entities. The memory model for CFA HCAPI
328 * determines if an SRAM entry type is supported.
330 enum cfa_p4_action_sram_entry_type {
331 /* NOTE: Any additions to this enum must be reflected on FW
335 /** SRAM Action Record */
336 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ACT,
337 /** SRAM Action Encap 8 Bytes */
338 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
339 /** SRAM Action Encap 16 Bytes */
340 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
341 /** SRAM Action Encap 64 Bytes */
342 CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
343 /** SRAM Action Modify IPv4 Source */
344 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
345 /** SRAM Action Modify IPv4 Destination */
346 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
347 /** SRAM Action Source Properties SMAC */
348 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
349 /** SRAM Action Source Properties SMAC IPv4 */
350 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV4,
351 /** SRAM Action Source Properties SMAC IPv6 */
352 CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC_IPV6,
353 /** SRAM Action Statistics 64 Bits */
354 CFA_P4_ACTION_SRAM_ENTRY_TYPE_STATS_64,
355 CFA_P4_ACTION_SRAM_ENTRY_TYPE_MAX
359 * SRAM Action Record structure holding either an action index or an
362 union cfa_p4_action_sram_act_record {
363 /** SRAM Action idx specifies the offset of the SRAM
364 * element within its SRAM Entry Type block. This
365 * index can be written into i.e. an L2 Context. Use
366 * this type for all SRAM Action Record types except
367 * SRAM Full Action records. Use act_ptr instead.
370 /** SRAM Full Action is special in that it needs an
371 * action record pointer. This pointer can be written
372 * into i.e. a Wildcard TCAM entry.
378 * cfa_p4_action_param parameter definition
380 struct cfa_p4_action_param {
382 * [in] receive or transmit direction
386 * [in] type of the sram allocation type
388 enum cfa_p4_action_sram_entry_type type;
390 * [in] action record to set. The 'type' specified lists the
391 * record definition to use in the passed in record.
393 union cfa_p4_action_sram_act_record record;
395 * [in] number of elements in act_data
399 * [in] ptr to array of action data
405 * EEM Key entry sizes
407 #define CFA_P4_EEM_KEY_MAX_SIZE 52
408 #define CFA_P4_EEM_KEY_RECORD_SIZE 64
413 struct cfa_p4_eem_entry_hdr {
416 * The header is made up of two words,
417 * this is the first word. This field has multiple
418 * subfields, there is no suitable single name for
419 * it so just going with word1.
421 #define CFA_P4_EEM_ENTRY_VALID_SHIFT 31
422 #define CFA_P4_EEM_ENTRY_VALID_MASK 0x80000000
423 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_SHIFT 30
424 #define CFA_P4_EEM_ENTRY_L1_CACHEABLE_MASK 0x40000000
425 #define CFA_P4_EEM_ENTRY_STRENGTH_SHIFT 28
426 #define CFA_P4_EEM_ENTRY_STRENGTH_MASK 0x30000000
427 #define CFA_P4_EEM_ENTRY_RESERVED_SHIFT 17
428 #define CFA_P4_EEM_ENTRY_RESERVED_MASK 0x0FFE0000
429 #define CFA_P4_EEM_ENTRY_KEY_SIZE_SHIFT 8
430 #define CFA_P4_EEM_ENTRY_KEY_SIZE_MASK 0x0001FF00
431 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_SHIFT 3
432 #define CFA_P4_EEM_ENTRY_ACT_REC_SIZE_MASK 0x000000F8
433 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_SHIFT 2
434 #define CFA_P4_EEM_ENTRY_ACT_REC_INT_MASK 0x00000004
435 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_SHIFT 1
436 #define CFA_P4_EEM_ENTRY_EXT_FLOW_CTR_MASK 0x00000002
437 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_SHIFT 0
438 #define CFA_P4_EEM_ENTRY_ACT_PTR_MSB_MASK 0x00000001
442 * cfa_p4_eem_key_entry
444 struct cfa_p4_eem_64b_entry {
445 /** Key is 448 bits - 56 bytes */
446 uint8_t key[CFA_P4_EEM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
447 /** Header is 8 bytes long */
448 struct cfa_p4_eem_entry_hdr hdr;
451 #endif /* _CFA_HW_P4_H_ */