1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Marvell OcteonTx2 RVU Admin Function driver
4 * Copyright (C) 2018 Marvell International Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
27 enum npc_kpu_la_ltype {
30 NPC_LT_LA_IH_NIX_ETHER,
34 NPC_LT_LA_HIGIG2_ETHER,
35 NPC_LT_LA_IH_NIX_HIGIG2_ETHER,
36 NPC_LT_LA_CUSTOM_L2_90B_ETHER,
37 NPC_LT_LA_CH_LEN_90B_ETHER,
39 NPC_LT_LA_CUSTOM_L2_24B_ETHER,
40 NPC_LT_LA_CUSTOM0 = 0xE,
41 NPC_LT_LA_CUSTOM1 = 0xF,
44 enum npc_kpu_lb_ltype {
58 NPC_LT_LB_CUSTOM0 = 0xE,
59 NPC_LT_LB_CUSTOM1 = 0xF,
62 enum npc_kpu_lc_ltype {
74 NPC_LT_LC_CUSTOM0 = 0xE,
75 NPC_LT_LC_CUSTOM1 = 0xF,
78 /* Don't modify Ltypes upto SCTP, otherwise it will
79 * effect flow tag calculation and thus RSS.
81 enum npc_kpu_ld_ltype {
94 NPC_LT_LD_TU_MPLS_IN_NSH,
95 NPC_LT_LD_TU_MPLS_IN_IP,
98 enum npc_kpu_le_ltype {
106 NPC_LT_LE_TU_MPLS_IN_GRE,
107 NPC_LT_LE_TU_NSH_IN_GRE,
108 NPC_LT_LE_TU_MPLS_IN_UDP,
109 NPC_LT_LE_CUSTOM0 = 0xE,
110 NPC_LT_LE_CUSTOM1 = 0xF,
113 enum npc_kpu_lf_ltype {
114 NPC_LT_LF_TU_ETHER = 1,
116 NPC_LT_LF_TU_MPLS_IN_VXLANGPE,
117 NPC_LT_LF_TU_NSH_IN_VXLANGPE,
118 NPC_LT_LF_TU_MPLS_IN_NSH,
119 NPC_LT_LF_TU_3RD_NSH,
120 NPC_LT_LF_CUSTOM0 = 0xE,
121 NPC_LT_LF_CUSTOM1 = 0xF,
124 enum npc_kpu_lg_ltype {
128 NPC_LT_LG_TU_ETHER_IN_NSH,
129 NPC_LT_LG_CUSTOM0 = 0xE,
130 NPC_LT_LG_CUSTOM1 = 0xF,
133 /* Don't modify Ltypes upto SCTP, otherwise it will
134 * effect flow tag calculation and thus RSS.
136 enum npc_kpu_lh_ltype {
137 NPC_LT_LH_TU_TCP = 1,
142 NPC_LT_LH_TU_IGMP = 8,
145 NPC_LT_LH_CUSTOM0 = 0xE,
146 NPC_LT_LH_CUSTOM1 = 0xF,
149 /* NPC port kind defines how the incoming or outgoing packets
150 * are processed. NPC accepts packets from up to 64 pkinds.
151 * Software assigns pkind for each incoming port such as CGX
152 * Ethernet interfaces, LBK interfaces, etc.
154 #define NPC_UNRESERVED_PKIND_COUNT NPC_RX_VLAN_EXDSA_PKIND
156 enum npc_pkind_type {
157 NPC_RX_LBK_PKIND = 0ULL,
158 NPC_RX_VLAN_EXDSA_PKIND = 56ULL,
159 NPC_RX_CHLEN24B_PKIND = 57ULL,
160 NPC_RX_CPT_HDR_PKIND,
161 NPC_RX_CHLEN90B_PKIND,
165 NPC_TX_DEF_PKIND, /* NIX-TX PKIND */
168 /* list of known and supported fields in packet header and
169 * fields present in key structure.
194 NPC_HEADER_FIELDS_MAX,
195 NPC_CHAN = NPC_HEADER_FIELDS_MAX, /* Valid when Rx */
196 NPC_PF_FUNC, /* Valid when Tx */
208 /* Ethertype for untagged frame */
210 /* Ethertype for single tagged frame */
212 /* Ethertype for double tagged frame */
214 /* outer vlan tci for single tagged frame */
216 /* outer vlan tci for double tagged frame */
218 /* other header fields programmed to extract but not of our interest */
223 struct npc_kpu_profile_cam {
234 struct npc_kpu_profile_action {
254 struct npc_kpu_profile {
257 struct npc_kpu_profile_cam *cam;
258 struct npc_kpu_profile_action *action;
261 /* NPC KPU register formats */
263 #if defined(__BIG_ENDIAN_BITFIELD)
278 struct npc_kpu_action0 {
279 #if defined(__BIG_ENDIAN_BITFIELD)
287 u64 capture_ltype : 4;
288 u64 capture_flags : 8;
290 u64 var_len_offset : 8;
291 u64 var_len_mask : 8;
292 u64 var_len_right : 1;
293 u64 var_len_shift : 3;
295 u64 var_len_shift : 3;
296 u64 var_len_right : 1;
297 u64 var_len_mask : 8;
298 u64 var_len_offset : 8;
300 u64 capture_flags : 8;
301 u64 capture_ltype : 4;
312 struct npc_kpu_action1 {
313 #if defined(__BIG_ENDIAN_BITFIELD)
330 struct npc_kpu_pkind_cpi_def {
331 #if defined(__BIG_ENDIAN_BITFIELD)
362 struct nix_rx_action {
363 #if defined(__BIG_ENDIAN_BITFIELD)
380 /* NPC_AF_INTFX_KEX_CFG field masks */
381 #define NPC_PARSE_NIBBLE GENMASK_ULL(30, 0)
383 /* NPC_PARSE_KEX_S nibble definitions for each field */
384 #define NPC_PARSE_NIBBLE_CHAN GENMASK_ULL(2, 0)
385 #define NPC_PARSE_NIBBLE_ERRLEV BIT_ULL(3)
386 #define NPC_PARSE_NIBBLE_ERRCODE GENMASK_ULL(5, 4)
387 #define NPC_PARSE_NIBBLE_L2L3_BCAST BIT_ULL(6)
388 #define NPC_PARSE_NIBBLE_LA_FLAGS GENMASK_ULL(8, 7)
389 #define NPC_PARSE_NIBBLE_LA_LTYPE BIT_ULL(9)
390 #define NPC_PARSE_NIBBLE_LB_FLAGS GENMASK_ULL(11, 10)
391 #define NPC_PARSE_NIBBLE_LB_LTYPE BIT_ULL(12)
392 #define NPC_PARSE_NIBBLE_LC_FLAGS GENMASK_ULL(14, 13)
393 #define NPC_PARSE_NIBBLE_LC_LTYPE BIT_ULL(15)
394 #define NPC_PARSE_NIBBLE_LD_FLAGS GENMASK_ULL(17, 16)
395 #define NPC_PARSE_NIBBLE_LD_LTYPE BIT_ULL(18)
396 #define NPC_PARSE_NIBBLE_LE_FLAGS GENMASK_ULL(20, 19)
397 #define NPC_PARSE_NIBBLE_LE_LTYPE BIT_ULL(21)
398 #define NPC_PARSE_NIBBLE_LF_FLAGS GENMASK_ULL(23, 22)
399 #define NPC_PARSE_NIBBLE_LF_LTYPE BIT_ULL(24)
400 #define NPC_PARSE_NIBBLE_LG_FLAGS GENMASK_ULL(26, 25)
401 #define NPC_PARSE_NIBBLE_LG_LTYPE BIT_ULL(27)
402 #define NPC_PARSE_NIBBLE_LH_FLAGS GENMASK_ULL(29, 28)
403 #define NPC_PARSE_NIBBLE_LH_LTYPE BIT_ULL(30)
405 struct nix_tx_action {
406 #if defined(__BIG_ENDIAN_BITFIELD)
421 /* NIX Receive Vtag Action Structure */
422 #define RX_VTAG0_VALID_BIT BIT_ULL(15)
423 #define RX_VTAG0_TYPE_MASK GENMASK_ULL(14, 12)
424 #define RX_VTAG0_LID_MASK GENMASK_ULL(10, 8)
425 #define RX_VTAG0_RELPTR_MASK GENMASK_ULL(7, 0)
426 #define RX_VTAG1_VALID_BIT BIT_ULL(47)
427 #define RX_VTAG1_TYPE_MASK GENMASK_ULL(46, 44)
428 #define RX_VTAG1_LID_MASK GENMASK_ULL(42, 40)
429 #define RX_VTAG1_RELPTR_MASK GENMASK_ULL(39, 32)
431 /* NIX Transmit Vtag Action Structure */
432 #define TX_VTAG0_DEF_MASK GENMASK_ULL(25, 16)
433 #define TX_VTAG0_OP_MASK GENMASK_ULL(13, 12)
434 #define TX_VTAG0_LID_MASK GENMASK_ULL(10, 8)
435 #define TX_VTAG0_RELPTR_MASK GENMASK_ULL(7, 0)
436 #define TX_VTAG1_DEF_MASK GENMASK_ULL(57, 48)
437 #define TX_VTAG1_OP_MASK GENMASK_ULL(45, 44)
438 #define TX_VTAG1_LID_MASK GENMASK_ULL(42, 40)
439 #define TX_VTAG1_RELPTR_MASK GENMASK_ULL(39, 32)
441 /* NPC MCAM reserved entry index per nixlf */
442 #define NIXLF_UCAST_ENTRY 0
443 #define NIXLF_BCAST_ENTRY 1
444 #define NIXLF_ALLMULTI_ENTRY 2
445 #define NIXLF_PROMISC_ENTRY 3
447 struct npc_coalesced_kpu_prfl {
448 #define NPC_SIGN 0x00666f727063706e
449 #define NPC_PRFL_NAME "npc_prfls_array"
450 #define NPC_NAME_LEN 32
451 __le64 signature; /* "npcprof\0" (8 bytes/ASCII characters) */
452 u8 name[NPC_NAME_LEN]; /* KPU Profile name */
453 u64 version; /* KPU firmware/profile version */
454 u8 num_prfl; /* No of NPC profiles. */
458 struct npc_mcam_kex {
459 /* MKEX Profle Header */
460 u64 mkex_sign; /* "mcam-kex-profile" (8 bytes/ASCII characters) */
461 u8 name[MKEX_NAME_LEN]; /* MKEX Profile name */
462 u64 cpu_model; /* Format as profiled by CPU hardware */
463 u64 kpu_version; /* KPU firmware/profile version */
464 u64 reserved; /* Reserved for extension */
466 /* MKEX Profle Data */
467 u64 keyx_cfg[NPC_MAX_INTF]; /* NPC_AF_INTF(0..1)_KEX_CFG */
468 /* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */
469 u64 kex_ld_flags[NPC_MAX_LD];
470 /* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */
471 u64 intf_lid_lt_ld[NPC_MAX_INTF][NPC_MAX_LID][NPC_MAX_LT][NPC_MAX_LD];
472 /* NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG */
473 u64 intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL];
476 struct npc_kpu_fwdata {
479 * struct npc_kpu_profile_cam[entries];
480 * struct npc_kpu_profile_action[entries];
491 struct npc_lt_def_ipsec {
499 struct npc_lt_def_apad {
506 struct npc_lt_def_color {
514 struct npc_lt_def_et {
522 struct npc_lt_def_cfg {
523 struct npc_lt_def rx_ol2;
524 struct npc_lt_def rx_oip4;
525 struct npc_lt_def rx_iip4;
526 struct npc_lt_def rx_oip6;
527 struct npc_lt_def rx_iip6;
528 struct npc_lt_def rx_otcp;
529 struct npc_lt_def rx_itcp;
530 struct npc_lt_def rx_oudp;
531 struct npc_lt_def rx_iudp;
532 struct npc_lt_def rx_osctp;
533 struct npc_lt_def rx_isctp;
534 struct npc_lt_def_ipsec rx_ipsec[2];
535 struct npc_lt_def pck_ol2;
536 struct npc_lt_def pck_oip4;
537 struct npc_lt_def pck_oip6;
538 struct npc_lt_def pck_iip4;
539 struct npc_lt_def_apad rx_apad0;
540 struct npc_lt_def_apad rx_apad1;
541 struct npc_lt_def_color ovlan;
542 struct npc_lt_def_color ivlan;
543 struct npc_lt_def_color rx_gen0_color;
544 struct npc_lt_def_color rx_gen1_color;
545 struct npc_lt_def_et rx_et[2];
548 /* Loadable KPU profile firmware data */
549 struct npc_kpu_profile_fwdata {
550 #define KPU_SIGN 0x00666f727075706b
551 #define KPU_NAME_LEN 32
552 /** Maximum number of custom KPU entries supported by the built-in profile. */
553 #define KPU_MAX_CST_ENT 2
554 /* KPU Profle Header */
555 __le64 signature; /* "kpuprof\0" (8 bytes/ASCII characters) */
556 u8 name[KPU_NAME_LEN]; /* KPU Profile name */
557 __le64 version; /* KPU profile version */
561 /* Default MKEX profile to be used with this KPU profile. May be
562 * overridden with mkex_profile module parameter. Format is same as for
563 * the MKEX profile to streamline processing.
565 struct npc_mcam_kex mkex;
566 /* LTYPE values for specific HW offloaded protocols. */
567 struct npc_lt_def_cfg lt_def;
568 /* Dynamically sized data:
569 * Custom KPU CAM and ACTION configuration entries.
570 * struct npc_kpu_fwdata kpu[kpus];
575 struct rvu_npc_mcam_rule {
576 struct flow_msg packet;
577 struct flow_msg mask;
580 struct nix_tx_action tx_action;
581 struct nix_rx_action rx_action;
584 struct list_head list;