1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
5 #ifndef __OTX2_NPC_HW_H__
6 #define __OTX2_NPC_HW_H__
10 #define NPC_AF_CFG (0x0ull)
11 #define NPC_AF_ACTIVE_PC (0x10ull)
12 #define NPC_AF_CONST (0x20ull)
13 #define NPC_AF_CONST1 (0x30ull)
14 #define NPC_AF_BLK_RST (0x40ull)
15 #define NPC_AF_MCAM_SCRUB_CTL (0xa0ull)
16 #define NPC_AF_KCAM_SCRUB_CTL (0xb0ull)
17 #define NPC_AF_KPUX_CFG(a) \
18 (0x500ull | (uint64_t)(a) << 3)
19 #define NPC_AF_PCK_CFG (0x600ull)
20 #define NPC_AF_PCK_DEF_OL2 (0x610ull)
21 #define NPC_AF_PCK_DEF_OIP4 (0x620ull)
22 #define NPC_AF_PCK_DEF_OIP6 (0x630ull)
23 #define NPC_AF_PCK_DEF_IIP4 (0x640ull)
24 #define NPC_AF_KEX_LDATAX_FLAGS_CFG(a) \
25 (0x800ull | (uint64_t)(a) << 3)
26 #define NPC_AF_INTFX_KEX_CFG(a) \
27 (0x1010ull | (uint64_t)(a) << 8)
28 #define NPC_AF_PKINDX_ACTION0(a) \
29 (0x80000ull | (uint64_t)(a) << 6)
30 #define NPC_AF_PKINDX_ACTION1(a) \
31 (0x80008ull | (uint64_t)(a) << 6)
32 #define NPC_AF_PKINDX_CPI_DEFX(a, b) \
33 (0x80020ull | (uint64_t)(a) << 6 | (uint64_t)(b) << 3)
34 #define NPC_AF_CHLEN90B_PKIND (0x3bull)
35 #define NPC_AF_KPUX_ENTRYX_CAMX(a, b, c) \
36 (0x100000ull | (uint64_t)(a) << 14 | (uint64_t)(b) << 6 | \
38 #define NPC_AF_KPUX_ENTRYX_ACTION0(a, b) \
39 (0x100020ull | (uint64_t)(a) << 14 | (uint64_t)(b) << 6)
40 #define NPC_AF_KPUX_ENTRYX_ACTION1(a, b) \
41 (0x100028ull | (uint64_t)(a) << 14 | (uint64_t)(b) << 6)
42 #define NPC_AF_KPUX_ENTRY_DISX(a, b) \
43 (0x180000ull | (uint64_t)(a) << 6 | (uint64_t)(b) << 3)
44 #define NPC_AF_CPIX_CFG(a) \
45 (0x200000ull | (uint64_t)(a) << 3)
46 #define NPC_AF_INTFX_LIDX_LTX_LDX_CFG(a, b, c, d) \
47 (0x900000ull | (uint64_t)(a) << 16 | (uint64_t)(b) << 12 | \
48 (uint64_t)(c) << 5 | (uint64_t)(d) << 3)
49 #define NPC_AF_INTFX_LDATAX_FLAGSX_CFG(a, b, c) \
50 (0x980000ull | (uint64_t)(a) << 16 | (uint64_t)(b) << 12 | \
52 #define NPC_AF_MCAMEX_BANKX_CAMX_INTF(a, b, c) \
53 (0x1000000ull | (uint64_t)(a) << 10 | (uint64_t)(b) << 6 | \
55 #define NPC_AF_MCAMEX_BANKX_CAMX_W0(a, b, c) \
56 (0x1000010ull | (uint64_t)(a) << 10 | (uint64_t)(b) << 6 | \
58 #define NPC_AF_MCAMEX_BANKX_CAMX_W1(a, b, c) \
59 (0x1000020ull | (uint64_t)(a) << 10 | (uint64_t)(b) << 6 | \
61 #define NPC_AF_MCAMEX_BANKX_CFG(a, b) \
62 (0x1800000ull | (uint64_t)(a) << 8 | (uint64_t)(b) << 4)
63 #define NPC_AF_MCAMEX_BANKX_STAT_ACT(a, b) \
64 (0x1880000ull | (uint64_t)(a) << 8 | (uint64_t)(b) << 4)
65 #define NPC_AF_MATCH_STATX(a) \
66 (0x1880008ull | (uint64_t)(a) << 8)
67 #define NPC_AF_INTFX_MISS_STAT_ACT(a) \
68 (0x1880040ull + (uint64_t)(a) * 0x8)
69 #define NPC_AF_MCAMEX_BANKX_ACTION(a, b) \
70 (0x1900000ull | (uint64_t)(a) << 8 | (uint64_t)(b) << 4)
71 #define NPC_AF_MCAMEX_BANKX_TAG_ACT(a, b) \
72 (0x1900008ull | (uint64_t)(a) << 8 | (uint64_t)(b) << 4)
73 #define NPC_AF_INTFX_MISS_ACT(a) \
74 (0x1a00000ull | (uint64_t)(a) << 4)
75 #define NPC_AF_INTFX_MISS_TAG_ACT(a) \
76 (0x1b00008ull | (uint64_t)(a) << 4)
77 #define NPC_AF_MCAM_BANKX_HITX(a, b) \
78 (0x1c80000ull | (uint64_t)(a) << 8 | (uint64_t)(b) << 4)
79 #define NPC_AF_LKUP_CTL (0x2000000ull)
80 #define NPC_AF_LKUP_DATAX(a) \
81 (0x2000200ull | (uint64_t)(a) << 4)
82 #define NPC_AF_LKUP_RESULTX(a) \
83 (0x2000400ull | (uint64_t)(a) << 4)
84 #define NPC_AF_INTFX_STAT(a) \
85 (0x2000800ull | (uint64_t)(a) << 4)
86 #define NPC_AF_DBG_CTL (0x3000000ull)
87 #define NPC_AF_DBG_STATUS (0x3000010ull)
88 #define NPC_AF_KPUX_DBG(a) \
89 (0x3000020ull | (uint64_t)(a) << 8)
90 #define NPC_AF_IKPU_ERR_CTL (0x3000080ull)
91 #define NPC_AF_KPUX_ERR_CTL(a) \
92 (0x30000a0ull | (uint64_t)(a) << 8)
93 #define NPC_AF_MCAM_DBG (0x3001000ull)
94 #define NPC_AF_DBG_DATAX(a) \
95 (0x3001400ull | (uint64_t)(a) << 4)
96 #define NPC_AF_DBG_RESULTX(a) \
97 (0x3001800ull | (uint64_t)(a) << 4)
102 #define NPC_INTF_NIX0_RX (0x0ull)
103 #define NPC_INTF_NIX0_TX (0x1ull)
105 #define NPC_LKUPOP_PKT (0x0ull)
106 #define NPC_LKUPOP_KEY (0x1ull)
108 #define NPC_MCAM_KEY_X1 (0x0ull)
109 #define NPC_MCAM_KEY_X2 (0x1ull)
110 #define NPC_MCAM_KEY_X4 (0x2ull)
129 NPC_ERRLEV_ENUM_LAST = 16,
132 enum npc_kpu_err_code {
133 NPC_EC_NOERR = 0, /* has to be zero */
140 NPC_EC_L2_K3_ETYPE_UNK,
146 NPC_EC_IP_FRAG_OFFSET_1,
150 NPC_EC_TCP_FLAGS_FIN_ONLY,
151 NPC_EC_TCP_FLAGS_ZERO,
152 NPC_EC_TCP_FLAGS_RST_FIN,
153 NPC_EC_TCP_FLAGS_URG_SYN,
154 NPC_EC_TCP_FLAGS_RST_SYN,
155 NPC_EC_TCP_FLAGS_SYN_FIN,
163 NPC_EC_LAST /* has to be the last item */
179 enum npc_kpu_la_ltype {
182 NPC_LT_LA_IH_NIX_ETHER,
183 NPC_LT_LA_IH_8_ETHER,
184 NPC_LT_LA_IH_4_ETHER,
185 NPC_LT_LA_IH_2_ETHER,
186 NPC_LT_LA_HIGIG2_ETHER,
187 NPC_LT_LA_IH_NIX_HIGIG2_ETHER,
188 NPC_LT_LA_CH_LEN_90B_ETHER, /* Custom L2 header of length 90 bytes */
191 enum npc_kpu_lb_ltype {
202 NPC_LT_LB_EXDSA_VLAN,
205 enum npc_kpu_lc_ltype {
218 /* Don't modify Ltypes up to SCTP, otherwise it will
219 * effect flow tag calculation and thus RSS.
221 enum npc_kpu_ld_ltype {
232 NPC_LT_LD_TU_MPLS_IN_NSH,
233 NPC_LT_LD_TU_MPLS_IN_IP,
236 enum npc_kpu_le_ltype {
244 NPC_LT_LE_TU_MPLS_IN_GRE,
245 NPC_LT_LE_TU_NSH_IN_GRE,
246 NPC_LT_LE_TU_MPLS_IN_UDP,
249 enum npc_kpu_lf_ltype {
250 NPC_LT_LF_TU_ETHER = 1,
252 NPC_LT_LF_TU_MPLS_IN_VXLANGPE,
253 NPC_LT_LF_TU_NSH_IN_VXLANGPE,
254 NPC_LT_LF_TU_MPLS_IN_NSH,
255 NPC_LT_LF_TU_3RD_NSH,
258 enum npc_kpu_lg_ltype {
262 NPC_LT_LG_TU_ETHER_IN_NSH,
265 /* Don't modify Ltypes up to SCTP, otherwise it will
266 * effect flow tag calculation and thus RSS.
268 enum npc_kpu_lh_ltype {
269 NPC_LT_LH_TU_TCP = 1,
274 NPC_LT_LH_TU_IGMP = 8,
279 /* Structures definitions */
280 struct npc_kpu_profile_cam {
291 struct npc_kpu_profile_action {
297 uint8_t bypass_count;
311 struct npc_kpu_profile {
314 struct npc_kpu_profile_cam *cam;
315 struct npc_kpu_profile_action *action;
318 /* NPC KPU register formats */
320 uint64_t dp0_data : 16;
321 uint64_t dp1_data : 16;
322 uint64_t dp2_data : 16;
324 uint64_t rsvd_63_56 : 8;
327 struct npc_kpu_action0 {
328 uint64_t var_len_shift : 3;
329 uint64_t var_len_right : 1;
330 uint64_t var_len_mask : 8;
331 uint64_t var_len_offset : 8;
332 uint64_t ptr_advance : 8;
333 uint64_t capture_flags : 8;
334 uint64_t capture_ltype : 4;
335 uint64_t capture_lid : 3;
336 uint64_t rsvd_43 : 1;
337 uint64_t next_state : 8;
338 uint64_t parse_done : 1;
339 uint64_t capture_ena : 1;
340 uint64_t byp_count : 3;
341 uint64_t rsvd_63_57 : 7;
344 struct npc_kpu_action1 {
345 uint64_t dp0_offset : 8;
346 uint64_t dp1_offset : 8;
347 uint64_t dp2_offset : 8;
348 uint64_t errcode : 8;
350 uint64_t rsvd_63_36 : 28;
353 struct npc_kpu_pkind_cpi_def {
354 uint64_t cpi_base : 10;
355 uint64_t rsvd_11_10 : 2;
356 uint64_t add_shift : 3;
357 uint64_t rsvd_15 : 1;
358 uint64_t add_mask : 8;
359 uint64_t add_offset : 8;
360 uint64_t flags_mask : 8;
361 uint64_t flags_match : 8;
362 uint64_t ltype_mask : 4;
363 uint64_t ltype_match : 4;
365 uint64_t rsvd_62_59 : 4;
369 struct nix_rx_action {
371 uint64_t pf_func :16;
373 uint64_t match_id :16;
374 uint64_t flow_key_alg :5;
375 uint64_t rsvd_63_61 :3;
378 struct nix_tx_action {
380 uint64_t rsvd_11_4 :8;
382 uint64_t match_id :16;
383 uint64_t rsvd_63_48 :16;
386 /* NPC layer parse information structure */
387 struct npc_layer_info_s {
391 uint32_t rsvd_31_20 : 12;
394 /* NPC layer mcam search key extract structure */
395 struct npc_layer_kex_s {
398 uint16_t rsvd_15_12 : 4;
401 /* NPC mcam search key x1 structure */
402 struct npc_mcam_key_x1_s {
404 uint64_t rsvd_63_2 : 62;
405 uint64_t kw0 : 64; /* W1 */
407 uint64_t rsvd_191_176 : 16;
410 /* NPC mcam search key x2 structure */
411 struct npc_mcam_key_x2_s {
413 uint64_t rsvd_63_2 : 62;
414 uint64_t kw0 : 64; /* W1 */
415 uint64_t kw1 : 64; /* W2 */
416 uint64_t kw2 : 64; /* W3 */
418 uint64_t rsvd_319_288 : 32;
421 /* NPC mcam search key x4 structure */
422 struct npc_mcam_key_x4_s {
424 uint64_t rsvd_63_2 : 62;
425 uint64_t kw0 : 64; /* W1 */
426 uint64_t kw1 : 64; /* W2 */
427 uint64_t kw2 : 64; /* W3 */
428 uint64_t kw3 : 64; /* W4 */
429 uint64_t kw4 : 64; /* W5 */
430 uint64_t kw5 : 64; /* W6 */
431 uint64_t kw6 : 64; /* W7 */
434 /* NPC parse key extract structure */
435 struct npc_parse_kex_s {
438 uint64_t errcode : 8;
451 uint64_t rsvd_127_124 : 4;
454 /* NPC result structure */
455 struct npc_result_s {
460 uint64_t errcode : 8;
465 uint64_t eoh_ptr : 8;
466 uint64_t rsvd_63_44 : 20;
467 uint64_t action : 64; /* W1 */
468 uint64_t vtag_action : 64; /* W2 */
472 uint64_t rsvd_255_252 : 4;
476 uint64_t rsvd_319_316 : 4;
479 uint64_t rsvd_383_360 : 24;
482 #endif /* __OTX2_NPC_HW_H__ */