#include <linux/xarray.h>
#include <linux/bitfield.h>
+#include "rvu.h"
+#include "npc.h"
+#include "npc_profile.h"
+#include "rvu_npc_hash.h"
+#include "rvu_npc.h"
#include "cn20k/npc.h"
#include "cn20k/reg.h"
-#include "rvu_npc.h"
static struct npc_priv_t npc_priv = {
.num_banks = MAX_NUM_BANKS,
[NPC_MCAM_KEY_X4] = "X4",
};
+#define KEX_EXTR_CFG(bytesm1, hdr_ofs, ena, key_ofs) \
+ (((bytesm1) << 16) | ((hdr_ofs) << 8) | ((ena) << 7) | \
+ ((key_ofs) & 0x3F))
+
+static struct npc_mcam_kex_extr npc_mkex_extr_default = {
+ .mkex_sign = MKEX_SIGN,
+ .name = "default",
+ .kpu_version = NPC_KPU_PROFILE_VER,
+ .keyx_cfg = {
+ /* nibble: LA..LE (ltype only) + Error code + Channel */
+ [NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_DYN << 32) |
+ NPC_PARSE_NIBBLE_INTF_RX |
+ NPC_PARSE_NIBBLE_ERRCODE,
+
+ /* nibble: LA..LE (ltype only) */
+ [NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) |
+ NPC_PARSE_NIBBLE_INTF_TX,
+ },
+ .intf_extr_lid = {
+ /* Default RX MCAM KEX profile */
+ [NIX_INTF_RX] = { NPC_LID_LA, NPC_LID_LA, NPC_LID_LB, NPC_LID_LB,
+ NPC_LID_LC, NPC_LID_LC, NPC_LID_LD },
+ [NIX_INTF_TX] = { NPC_LID_LA, NPC_LID_LA, NPC_LID_LB, NPC_LID_LB,
+ NPC_LID_LC, NPC_LID_LD },
+ },
+ .intf_extr_lt = {
+ /* Default RX MCAM KEX profile */
+ [NIX_INTF_RX] = {
+ [0] = {
+ /* Layer A: Ethernet: */
+ [NPC_LT_LA_ETHER] =
+ /* DMAC: 6 bytes, KW1[63:15] */
+ KEX_EXTR_CFG(0x05, 0x0, 0x1,
+ NPC_KEXOF_DMAC + 1),
+ [NPC_LT_LA_CPT_HDR] =
+ /* DMAC: 6 bytes, KW1[63:15] */
+ KEX_EXTR_CFG(0x05, 0x0, 0x1,
+ NPC_KEXOF_DMAC + 1),
+ },
+ [1] = {
+ /* Layer A: Ethernet: */
+ [NPC_LT_LA_ETHER] =
+ /* Ethertype: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0xc, 0x1, 0x6),
+ [NPC_LT_LA_CPT_HDR] =
+ /* Ethertype: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0xc, 0x1, 0x6),
+ },
+ [2] = {
+ /* Layer B: Single VLAN (CTAG) */
+ [NPC_LT_LB_CTAG] =
+ /* CTAG VLAN: 2 bytes, KW1[15:0] */
+ KEX_EXTR_CFG(0x01, 0x2, 0x1, 0x8),
+ /* Layer B: Stacked VLAN (STAG|QinQ) */
+ [NPC_LT_LB_STAG_QINQ] =
+ /* Outer VLAN: 2 bytes, KW1[15:0] */
+ KEX_EXTR_CFG(0x01, 0x2, 0x1, 0x8),
+ [NPC_LT_LB_FDSA] =
+ /* SWITCH PORT: 1 byte, KW1[7:0] */
+ KEX_EXTR_CFG(0x0, 0x1, 0x1, 0x8),
+ },
+ [3] = {
+ [NPC_LT_LB_CTAG] =
+ /* Ethertype: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0x4, 0x1, 0x6),
+ [NPC_LT_LB_STAG_QINQ] =
+ /* Ethertype: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0x8, 0x1, 0x6),
+ [NPC_LT_LB_FDSA] =
+ /* Ethertype: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0x4, 0x1, 0x6),
+ },
+ [4] = {
+ /* Layer C: IPv4 */
+ [NPC_LT_LC_IP] =
+ /* SIP+DIP: 8 bytes, KW3[7:0], KW2[63:8] */
+ KEX_EXTR_CFG(0x07, 0xc, 0x1, 0x11),
+ /* Layer C: IPv6 */
+ [NPC_LT_LC_IP6] =
+ /* Everything up to SADDR: 8 bytes, KW3[7:0],
+ * KW2[63:8]
+ */
+ KEX_EXTR_CFG(0x07, 0x0, 0x1, 0x11),
+ },
+ [5] = {
+ [NPC_LT_LC_IP] =
+ /* TOS: 1 byte, KW2[7:0] */
+ KEX_EXTR_CFG(0x0, 0x1, 0x1, 0x10),
+ },
+ [6] = {
+ /* Layer D:UDP */
+ [NPC_LT_LD_UDP] =
+ /* SPORT+DPORT: 4 bytes, KW3[39:8] */
+ KEX_EXTR_CFG(0x3, 0x0, 0x1, 0x19),
+ /* Layer D:TCP */
+ [NPC_LT_LD_TCP] =
+ /* SPORT+DPORT: 4 bytes, KW3[39:8] */
+ KEX_EXTR_CFG(0x3, 0x0, 0x1, 0x19),
+ },
+ },
+ /* Default TX MCAM KEX profile */
+ [NIX_INTF_TX] = {
+ [0] = {
+ /* Layer A: NIX_INST_HDR_S + Ethernet */
+ /* NIX appends 8 bytes of NIX_INST_HDR_S at the
+ * start of each TX packet supplied to NPC.
+ */
+ [NPC_LT_LA_IH_NIX_ETHER] =
+ /* PF_FUNC: 2B , KW0 [47:32] */
+ KEX_EXTR_CFG(0x01, 0x0, 0x1, 0x4),
+ /* Layer A: HiGig2: */
+ [NPC_LT_LA_IH_NIX_HIGIG2_ETHER] =
+ /* PF_FUNC: 2B , KW0 [47:32] */
+ KEX_EXTR_CFG(0x01, 0x0, 0x1, 0x4),
+ },
+ [1] = {
+ [NPC_LT_LA_IH_NIX_ETHER] =
+ /* SQ_ID 3 bytes, KW1[63:16] */
+ KEX_EXTR_CFG(0x02, 0x02, 0x1, 0xa),
+ [NPC_LT_LA_IH_NIX_HIGIG2_ETHER] =
+ /* VID: 2 bytes, KW1[31:16] */
+ KEX_EXTR_CFG(0x01, 0x10, 0x1, 0xa),
+ },
+ [2] = {
+ /* Layer B: Single VLAN (CTAG) */
+ [NPC_LT_LB_CTAG] =
+ /* CTAG VLAN[2..3] KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0x2, 0x1, 0x6),
+ /* Layer B: Stacked VLAN (STAG|QinQ) */
+ [NPC_LT_LB_STAG_QINQ] =
+ /* Outer VLAN: 2 bytes, KW0[63:48] */
+ KEX_EXTR_CFG(0x01, 0x2, 0x1, 0x6),
+ },
+ [3] = {
+ [NPC_LT_LB_CTAG] =
+ /* CTAG VLAN[2..3] KW1[15:0] */
+ KEX_EXTR_CFG(0x01, 0x4, 0x1, 0x8),
+ [NPC_LT_LB_STAG_QINQ] =
+ /* Outer VLAN: 2 Bytes, KW1[15:0] */
+ KEX_EXTR_CFG(0x01, 0x8, 0x1, 0x8),
+ },
+ [4] = {
+ /* Layer C: IPv4 */
+ [NPC_LT_LC_IP] =
+ /* SIP+DIP: 8 bytes, KW2[63:0] */
+ KEX_EXTR_CFG(0x07, 0xc, 0x1, 0x10),
+ /* Layer C: IPv6 */
+ [NPC_LT_LC_IP6] =
+ /* Everything up to SADDR: 8 bytes, KW2[63:0] */
+ KEX_EXTR_CFG(0x07, 0x0, 0x1, 0x10),
+ },
+ [5] = {
+ /* Layer D:UDP */
+ [NPC_LT_LD_UDP] =
+ /* SPORT+DPORT: 4 bytes, KW3[31:0] */
+ KEX_EXTR_CFG(0x3, 0x0, 0x1, 0x18),
+ /* Layer D:TCP */
+ [NPC_LT_LD_TCP] =
+ /* SPORT+DPORT: 4 bytes, KW3[31:0] */
+ KEX_EXTR_CFG(0x3, 0x0, 0x1, 0x18),
+ },
+ },
+ },
+};
+
+struct npc_mcam_kex_extr *npc_mkex_extr_default_get(void)
+{
+ return &npc_mkex_extr_default;
+}
+
static void npc_config_kpmcam(struct rvu *rvu, int blkaddr,
const struct npc_kpu_profile_cam *kpucam,
int kpm, int entry)
0, 0, 0, 0, \
}
-static struct npc_kpu_profile_action ikpu_action_entries[] = {
+static struct npc_kpu_profile_action ikpu_action_entries[] __maybe_unused = {
{
NPC_ERRLEV_RE, NPC_EC_NOERR,
12, 16, 20, 0, 0,
},
};
-static struct npc_kpu_profile_cam kpu1_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu1_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu2_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu2_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu3_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu3_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu4_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu4_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu5_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu5_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu6_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu6_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu7_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu7_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu8_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu8_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu9_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu9_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu10_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu10_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu11_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu11_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu12_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu12_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu13_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu13_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu14_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu14_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu15_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu15_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_cam kpu16_cam_entries[] = {
+static struct npc_kpu_profile_cam kpu16_cam_entries[] __maybe_unused = {
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
NPC_KPU_NOP_CAM,
},
};
-static struct npc_kpu_profile_action kpu1_action_entries[] = {
+static struct npc_kpu_profile_action kpu1_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu2_action_entries[] = {
+static struct npc_kpu_profile_action kpu2_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu3_action_entries[] = {
+static struct npc_kpu_profile_action kpu3_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu4_action_entries[] = {
+static struct npc_kpu_profile_action kpu4_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu5_action_entries[] = {
+static struct npc_kpu_profile_action kpu5_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu6_action_entries[] = {
+static struct npc_kpu_profile_action kpu6_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu7_action_entries[] = {
+static struct npc_kpu_profile_action kpu7_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu8_action_entries[] = {
+static struct npc_kpu_profile_action kpu8_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu9_action_entries[] = {
+static struct npc_kpu_profile_action kpu9_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu10_action_entries[] = {
+static struct npc_kpu_profile_action kpu10_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu11_action_entries[] = {
+static struct npc_kpu_profile_action kpu11_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu12_action_entries[] = {
+static struct npc_kpu_profile_action kpu12_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu13_action_entries[] = {
+static struct npc_kpu_profile_action kpu13_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu14_action_entries[] = {
+static struct npc_kpu_profile_action kpu14_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu15_action_entries[] = {
+static struct npc_kpu_profile_action kpu15_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile_action kpu16_action_entries[] = {
+static struct npc_kpu_profile_action kpu16_action_entries[] __maybe_unused = {
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
NPC_KPU_NOP_ACTION,
},
};
-static struct npc_kpu_profile npc_kpu_profiles[] = {
+static struct npc_kpu_profile npc_kpu_profiles[] __maybe_unused = {
{
ARRAY_SIZE(kpu1_cam_entries),
ARRAY_SIZE(kpu1_action_entries),
},
};
-static struct npc_lt_def_cfg npc_lt_defaults = {
+static struct npc_lt_def_cfg npc_lt_defaults __maybe_unused = {
.rx_ol2 = {
.lid = NPC_LID_LA,
.ltype_match = NPC_LT_LA_ETHER,
},
};
-static struct npc_mcam_kex npc_mkex_default = {
+static struct npc_mcam_kex npc_mkex_default __maybe_unused = {
.mkex_sign = MKEX_SIGN,
.name = "default",
.kpu_version = NPC_KPU_PROFILE_VER,