1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT)
2 * Microsemi Ocelot Switch driver
3 * Copyright (c) 2019 Microsemi Corporation
6 #ifndef _OCELOT_VCAP_H_
7 #define _OCELOT_VCAP_H_
9 #include <soc/mscc/ocelot.h>
11 /* =================================================================
13 * =================================================================
23 #define OCELOT_NUM_VCAP_BLOCKS __VCAP_COUNT
26 u16 tg_width
; /* Type-group width (in bits) */
27 u16 sw_count
; /* Sub word count */
28 u16 entry_count
; /* Entry count */
29 u16 entry_words
; /* Number of entry words */
30 u16 entry_width
; /* Entry width (in bits) */
31 u16 action_count
; /* Action count */
32 u16 action_words
; /* Number of action words */
33 u16 action_width
; /* Action width (in bits) */
34 u16 action_type_width
; /* Action type width (in bits) */
36 u16 width
; /* Action type width (in bits) */
37 u16 count
; /* Action type sub word count */
39 u16 counter_words
; /* Number of counter words */
40 u16 counter_width
; /* Counter width (in bits) */
42 enum ocelot_target target
;
44 const struct vcap_field
*keys
;
45 const struct vcap_field
*actions
;
48 /* VCAP Type-Group values */
49 #define VCAP_TG_NONE 0 /* Entry is invalid */
50 #define VCAP_TG_FULL 1 /* Full entry */
51 #define VCAP_TG_HALF 2 /* Half entry */
52 #define VCAP_TG_QUARTER 3 /* Quarter entry */
54 #define VCAP_CORE_UPDATE_CTRL_UPDATE_CMD(x) (((x) << 22) & GENMASK(24, 22))
55 #define VCAP_CORE_UPDATE_CTRL_UPDATE_CMD_M GENMASK(24, 22)
56 #define VCAP_CORE_UPDATE_CTRL_UPDATE_CMD_X(x) (((x) & GENMASK(24, 22)) >> 22)
57 #define VCAP_CORE_UPDATE_CTRL_UPDATE_ENTRY_DIS BIT(21)
58 #define VCAP_CORE_UPDATE_CTRL_UPDATE_ACTION_DIS BIT(20)
59 #define VCAP_CORE_UPDATE_CTRL_UPDATE_CNT_DIS BIT(19)
60 #define VCAP_CORE_UPDATE_CTRL_UPDATE_ADDR(x) (((x) << 3) & GENMASK(18, 3))
61 #define VCAP_CORE_UPDATE_CTRL_UPDATE_ADDR_M GENMASK(18, 3)
62 #define VCAP_CORE_UPDATE_CTRL_UPDATE_ADDR_X(x) (((x) & GENMASK(18, 3)) >> 3)
63 #define VCAP_CORE_UPDATE_CTRL_UPDATE_SHOT BIT(2)
64 #define VCAP_CORE_UPDATE_CTRL_CLEAR_CACHE BIT(1)
65 #define VCAP_CORE_UPDATE_CTRL_MV_TRAFFIC_IGN BIT(0)
67 #define VCAP_CORE_MV_CFG_MV_NUM_POS(x) (((x) << 16) & GENMASK(31, 16))
68 #define VCAP_CORE_MV_CFG_MV_NUM_POS_M GENMASK(31, 16)
69 #define VCAP_CORE_MV_CFG_MV_NUM_POS_X(x) (((x) & GENMASK(31, 16)) >> 16)
70 #define VCAP_CORE_MV_CFG_MV_SIZE(x) ((x) & GENMASK(15, 0))
71 #define VCAP_CORE_MV_CFG_MV_SIZE_M GENMASK(15, 0)
73 #define VCAP_CACHE_ENTRY_DAT_RSZ 0x4
75 #define VCAP_CACHE_MASK_DAT_RSZ 0x4
77 #define VCAP_CACHE_ACTION_DAT_RSZ 0x4
79 #define VCAP_CACHE_CNT_DAT_RSZ 0x4
81 #define VCAP_STICKY_VCAP_ROW_DELETED_STICKY BIT(0)
83 #define TCAM_BIST_CTRL_TCAM_BIST BIT(1)
84 #define TCAM_BIST_CTRL_TCAM_INIT BIT(0)
86 #define TCAM_BIST_CFG_TCAM_BIST_SOE_ENA BIT(8)
87 #define TCAM_BIST_CFG_TCAM_HCG_DIS BIT(7)
88 #define TCAM_BIST_CFG_TCAM_CG_DIS BIT(6)
89 #define TCAM_BIST_CFG_TCAM_BIAS(x) ((x) & GENMASK(5, 0))
90 #define TCAM_BIST_CFG_TCAM_BIAS_M GENMASK(5, 0)
92 #define TCAM_BIST_STAT_BIST_RT_ERR BIT(15)
93 #define TCAM_BIST_STAT_BIST_PENC_ERR BIT(14)
94 #define TCAM_BIST_STAT_BIST_COMP_ERR BIT(13)
95 #define TCAM_BIST_STAT_BIST_ADDR_ERR BIT(12)
96 #define TCAM_BIST_STAT_BIST_BL1E_ERR BIT(11)
97 #define TCAM_BIST_STAT_BIST_BL1_ERR BIT(10)
98 #define TCAM_BIST_STAT_BIST_BL0E_ERR BIT(9)
99 #define TCAM_BIST_STAT_BIST_BL0_ERR BIT(8)
100 #define TCAM_BIST_STAT_BIST_PH1_ERR BIT(7)
101 #define TCAM_BIST_STAT_BIST_PH0_ERR BIT(6)
102 #define TCAM_BIST_STAT_BIST_PV1_ERR BIT(5)
103 #define TCAM_BIST_STAT_BIST_PV0_ERR BIT(4)
104 #define TCAM_BIST_STAT_BIST_RUN BIT(3)
105 #define TCAM_BIST_STAT_BIST_ERR BIT(2)
106 #define TCAM_BIST_STAT_BIST_BUSY BIT(1)
107 #define TCAM_BIST_STAT_TCAM_RDY BIT(0)
109 /* =================================================================
111 * =================================================================
114 /* IS2 half key types */
115 #define IS2_TYPE_ETYPE 0
116 #define IS2_TYPE_LLC 1
117 #define IS2_TYPE_SNAP 2
118 #define IS2_TYPE_ARP 3
119 #define IS2_TYPE_IP_UDP_TCP 4
120 #define IS2_TYPE_IP_OTHER 5
121 #define IS2_TYPE_IPV6 6
122 #define IS2_TYPE_OAM 7
123 #define IS2_TYPE_SMAC_SIP6 8
124 #define IS2_TYPE_ANY 100 /* Pseudo type */
126 /* IS2 half key type mask for matching any IP */
127 #define IS2_TYPE_MASK_IP_ANY 0xe
130 IS2_ACTION_TYPE_NORMAL
,
131 IS2_ACTION_TYPE_SMAC_SIP
,
135 /* IS2 MASK_MODE values */
136 #define IS2_ACT_MASK_MODE_NONE 0
137 #define IS2_ACT_MASK_MODE_FILTER 1
138 #define IS2_ACT_MASK_MODE_POLICY 2
139 #define IS2_ACT_MASK_MODE_REDIR 3
141 /* IS2 REW_OP values */
142 #define IS2_ACT_REW_OP_NONE 0
143 #define IS2_ACT_REW_OP_PTP_ONE 2
144 #define IS2_ACT_REW_OP_PTP_TWO 3
145 #define IS2_ACT_REW_OP_SPECIAL 8
146 #define IS2_ACT_REW_OP_PTP_ORG 9
147 #define IS2_ACT_REW_OP_PTP_ONE_SUB_DELAY_1 (IS2_ACT_REW_OP_PTP_ONE | (1 << 3))
148 #define IS2_ACT_REW_OP_PTP_ONE_SUB_DELAY_2 (IS2_ACT_REW_OP_PTP_ONE | (2 << 3))
149 #define IS2_ACT_REW_OP_PTP_ONE_ADD_DELAY (IS2_ACT_REW_OP_PTP_ONE | (1 << 5))
150 #define IS2_ACT_REW_OP_PTP_ONE_ADD_SUB BIT(7)
152 #define VCAP_PORT_WIDTH 4
154 /* IS2 quarter key - SMAC_SIP4 */
155 #define IS2_QKO_IGR_PORT 0
156 #define IS2_QKL_IGR_PORT VCAP_PORT_WIDTH
157 #define IS2_QKO_L2_SMAC (IS2_QKO_IGR_PORT + IS2_QKL_IGR_PORT)
158 #define IS2_QKL_L2_SMAC 48
159 #define IS2_QKO_L3_IP4_SIP (IS2_QKO_L2_SMAC + IS2_QKL_L2_SMAC)
160 #define IS2_QKL_L3_IP4_SIP 32
162 enum vcap_is2_half_key_field
{
168 VCAP_IS2_HK_IGR_PORT_MASK
,
170 VCAP_IS2_HK_HOST_MATCH
,
173 VCAP_IS2_HK_VLAN_TAGGED
,
177 /* MAC_ETYPE / MAC_LLC / MAC_SNAP / OAM common */
180 /* MAC_ETYPE (TYPE=000) */
181 VCAP_IS2_HK_MAC_ETYPE_ETYPE
,
182 VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD0
,
183 VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD1
,
184 VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD2
,
185 /* MAC_LLC (TYPE=001) */
186 VCAP_IS2_HK_MAC_LLC_DMAC
,
187 VCAP_IS2_HK_MAC_LLC_SMAC
,
188 VCAP_IS2_HK_MAC_LLC_L2_LLC
,
189 /* MAC_SNAP (TYPE=010) */
190 VCAP_IS2_HK_MAC_SNAP_SMAC
,
191 VCAP_IS2_HK_MAC_SNAP_DMAC
,
192 VCAP_IS2_HK_MAC_SNAP_L2_SNAP
,
193 /* MAC_ARP (TYPE=011) */
194 VCAP_IS2_HK_MAC_ARP_SMAC
,
195 VCAP_IS2_HK_MAC_ARP_ADDR_SPACE_OK
,
196 VCAP_IS2_HK_MAC_ARP_PROTO_SPACE_OK
,
197 VCAP_IS2_HK_MAC_ARP_LEN_OK
,
198 VCAP_IS2_HK_MAC_ARP_TARGET_MATCH
,
199 VCAP_IS2_HK_MAC_ARP_SENDER_MATCH
,
200 VCAP_IS2_HK_MAC_ARP_OPCODE_UNKNOWN
,
201 VCAP_IS2_HK_MAC_ARP_OPCODE
,
202 VCAP_IS2_HK_MAC_ARP_L3_IP4_DIP
,
203 VCAP_IS2_HK_MAC_ARP_L3_IP4_SIP
,
204 VCAP_IS2_HK_MAC_ARP_DIP_EQ_SIP
,
205 /* IP4_TCP_UDP / IP4_OTHER common */
207 VCAP_IS2_HK_L3_FRAGMENT
,
208 VCAP_IS2_HK_L3_FRAG_OFS_GT0
,
209 VCAP_IS2_HK_L3_OPTIONS
,
210 VCAP_IS2_HK_IP4_L3_TTL_GT0
,
212 VCAP_IS2_HK_L3_IP4_DIP
,
213 VCAP_IS2_HK_L3_IP4_SIP
,
214 VCAP_IS2_HK_DIP_EQ_SIP
,
215 /* IP4_TCP_UDP (TYPE=100) */
217 VCAP_IS2_HK_L4_SPORT
,
218 VCAP_IS2_HK_L4_DPORT
,
220 VCAP_IS2_HK_L4_SPORT_EQ_DPORT
,
221 VCAP_IS2_HK_L4_SEQUENCE_EQ0
,
228 VCAP_IS2_HK_L4_1588_DOM
,
229 VCAP_IS2_HK_L4_1588_VER
,
230 /* IP4_OTHER (TYPE=101) */
231 VCAP_IS2_HK_IP4_L3_PROTO
,
232 VCAP_IS2_HK_L3_PAYLOAD
,
233 /* IP6_STD (TYPE=110) */
234 VCAP_IS2_HK_IP6_L3_TTL_GT0
,
235 VCAP_IS2_HK_IP6_L3_PROTO
,
236 VCAP_IS2_HK_L3_IP6_SIP
,
238 VCAP_IS2_HK_OAM_MEL_FLAGS
,
240 VCAP_IS2_HK_OAM_OPCODE
,
241 VCAP_IS2_HK_OAM_FLAGS
,
242 VCAP_IS2_HK_OAM_MEPID
,
243 VCAP_IS2_HK_OAM_CCM_CNTS_EQ0
,
244 VCAP_IS2_HK_OAM_IS_Y1731
,
252 enum vcap_is2_action_field
{
253 VCAP_IS2_ACT_HIT_ME_ONCE
,
254 VCAP_IS2_ACT_CPU_COPY_ENA
,
255 VCAP_IS2_ACT_CPU_QU_NUM
,
256 VCAP_IS2_ACT_MASK_MODE
,
257 VCAP_IS2_ACT_MIRROR_ENA
,
258 VCAP_IS2_ACT_LRN_DIS
,
259 VCAP_IS2_ACT_POLICE_ENA
,
260 VCAP_IS2_ACT_POLICE_IDX
,
261 VCAP_IS2_ACT_POLICE_VCAP_ONLY
,
262 VCAP_IS2_ACT_PORT_MASK
,
264 VCAP_IS2_ACT_SMAC_REPLACE_ENA
,
267 VCAP_IS2_ACT_HIT_CNT
,
270 /* =================================================================
272 * =================================================================
275 /* IS1 half key types */
276 #define IS1_TYPE_S1_NORMAL 0
277 #define IS1_TYPE_S1_5TUPLE_IP4 1
279 /* IS1 full key types */
280 #define IS1_TYPE_S1_NORMAL_IP6 0
281 #define IS1_TYPE_S1_7TUPLE 1
282 #define IS2_TYPE_S1_5TUPLE_IP6 2
285 IS1_ACTION_TYPE_NORMAL
,
289 enum vcap_is1_half_key_field
{
292 VCAP_IS1_HK_IGR_PORT_MASK
,
294 VCAP_IS1_HK_OAM_Y1731
,
298 VCAP_IS1_HK_VLAN_TAGGED
,
299 VCAP_IS1_HK_VLAN_DBL_TAGGED
,
304 /* Specific Fields for IS1 Half Key S1_NORMAL */
306 VCAP_IS1_HK_ETYPE_LEN
,
310 VCAP_IS1_HK_L3_FRAGMENT
,
311 VCAP_IS1_HK_L3_FRAG_OFS_GT0
,
312 VCAP_IS1_HK_L3_OPTIONS
,
314 VCAP_IS1_HK_L3_IP4_SIP
,
317 VCAP_IS1_HK_L4_SPORT
,
319 /* Specific Fields for IS1 Half Key S1_5TUPLE_IP4 */
320 VCAP_IS1_HK_IP4_INNER_TPID
,
321 VCAP_IS1_HK_IP4_INNER_VID
,
322 VCAP_IS1_HK_IP4_INNER_DEI
,
323 VCAP_IS1_HK_IP4_INNER_PCP
,
325 VCAP_IS1_HK_IP4_L3_FRAGMENT
,
326 VCAP_IS1_HK_IP4_L3_FRAG_OFS_GT0
,
327 VCAP_IS1_HK_IP4_L3_OPTIONS
,
328 VCAP_IS1_HK_IP4_L3_DSCP
,
329 VCAP_IS1_HK_IP4_L3_IP4_DIP
,
330 VCAP_IS1_HK_IP4_L3_IP4_SIP
,
331 VCAP_IS1_HK_IP4_L3_PROTO
,
332 VCAP_IS1_HK_IP4_TCP_UDP
,
334 VCAP_IS1_HK_IP4_L4_RNG
,
335 VCAP_IS1_HK_IP4_IP_PAYLOAD_S1_5TUPLE
,
338 enum vcap_is1_action_field
{
339 VCAP_IS1_ACT_DSCP_ENA
,
340 VCAP_IS1_ACT_DSCP_VAL
,
341 VCAP_IS1_ACT_QOS_ENA
,
342 VCAP_IS1_ACT_QOS_VAL
,
345 VCAP_IS1_ACT_PAG_OVERRIDE_MASK
,
346 VCAP_IS1_ACT_PAG_VAL
,
348 VCAP_IS1_ACT_VID_REPLACE_ENA
,
349 VCAP_IS1_ACT_VID_ADD_VAL
,
350 VCAP_IS1_ACT_FID_SEL
,
351 VCAP_IS1_ACT_FID_VAL
,
352 VCAP_IS1_ACT_PCP_DEI_ENA
,
353 VCAP_IS1_ACT_PCP_VAL
,
354 VCAP_IS1_ACT_DEI_VAL
,
355 VCAP_IS1_ACT_VLAN_POP_CNT_ENA
,
356 VCAP_IS1_ACT_VLAN_POP_CNT
,
357 VCAP_IS1_ACT_CUSTOM_ACE_TYPE_ENA
,
358 VCAP_IS1_ACT_HIT_STICKY
,
361 /* =================================================================
363 * =================================================================
367 ES0_ACTION_TYPE_NORMAL
,
371 enum vcap_es0_key_field
{
382 enum vcap_es0_action_field
{
383 VCAP_ES0_ACT_PUSH_OUTER_TAG
,
384 VCAP_ES0_ACT_PUSH_INNER_TAG
,
385 VCAP_ES0_ACT_TAG_A_TPID_SEL
,
386 VCAP_ES0_ACT_TAG_A_VID_SEL
,
387 VCAP_ES0_ACT_TAG_A_PCP_SEL
,
388 VCAP_ES0_ACT_TAG_A_DEI_SEL
,
389 VCAP_ES0_ACT_TAG_B_TPID_SEL
,
390 VCAP_ES0_ACT_TAG_B_VID_SEL
,
391 VCAP_ES0_ACT_TAG_B_PCP_SEL
,
392 VCAP_ES0_ACT_TAG_B_DEI_SEL
,
393 VCAP_ES0_ACT_VID_A_VAL
,
394 VCAP_ES0_ACT_PCP_A_VAL
,
395 VCAP_ES0_ACT_DEI_A_VAL
,
396 VCAP_ES0_ACT_VID_B_VAL
,
397 VCAP_ES0_ACT_PCP_B_VAL
,
398 VCAP_ES0_ACT_DEI_B_VAL
,
400 VCAP_ES0_ACT_HIT_STICKY
,
403 #endif /* _OCELOT_VCAP_H_ */