Commit 42006910 authored by Stanislaw Kardach's avatar Stanislaw Kardach Committed by David S. Miller

octeontx2-af: cleanup KPU config data

Refactor KPU related NPC code gathering all configuration data in a
structured format and putting it in one place (npc_profile.h).
This increases readability and makes it easier to extend the profile
configuration (as opposed to jumping between multiple header and source
files).

To do this:
* Gather all KPU profile related data into a single adapter struct.
* Convert the built-in MKEX definition to a structured one to streamline
  the MKEX loading.
* Convert LT default register configuration into a structure, keeping
  default protocol settings in same file where identifiers for those
  protocols are defined.
* Add a single point for KPU profile loading, so that its source may
  change in the future once proper interfaces for loading such config
  are in place.
Signed-off-by: default avatarStanislaw Kardach <skardach@marvell.com>
Acked-by: default avatarSunil Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 450f0b97
...@@ -296,6 +296,9 @@ struct nix_rx_action { ...@@ -296,6 +296,9 @@ struct nix_rx_action {
#endif #endif
}; };
/* NPC_AF_INTFX_KEX_CFG field masks */
#define NPC_PARSE_NIBBLE GENMASK_ULL(30, 0)
/* NIX Receive Vtag Action Structure */ /* NIX Receive Vtag Action Structure */
#define VTAG0_VALID_BIT BIT_ULL(15) #define VTAG0_VALID_BIT BIT_ULL(15)
#define VTAG0_TYPE_MASK GENMASK_ULL(14, 12) #define VTAG0_TYPE_MASK GENMASK_ULL(14, 12)
...@@ -320,4 +323,37 @@ struct npc_mcam_kex { ...@@ -320,4 +323,37 @@ struct npc_mcam_kex {
u64 intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL]; u64 intf_ld_flags[NPC_MAX_INTF][NPC_MAX_LD][NPC_MAX_LFL];
} __packed; } __packed;
struct npc_lt_def {
u8 ltype_mask;
u8 ltype_match;
u8 lid;
};
struct npc_lt_def_ipsec {
u8 ltype_mask;
u8 ltype_match;
u8 lid;
u8 spi_offset;
u8 spi_nz;
};
struct npc_lt_def_cfg {
struct npc_lt_def rx_ol2;
struct npc_lt_def rx_oip4;
struct npc_lt_def rx_iip4;
struct npc_lt_def rx_oip6;
struct npc_lt_def rx_iip6;
struct npc_lt_def rx_otcp;
struct npc_lt_def rx_itcp;
struct npc_lt_def rx_oudp;
struct npc_lt_def rx_iudp;
struct npc_lt_def rx_osctp;
struct npc_lt_def rx_isctp;
struct npc_lt_def_ipsec rx_ipsec[2];
struct npc_lt_def pck_ol2;
struct npc_lt_def pck_oip4;
struct npc_lt_def pck_oip6;
struct npc_lt_def pck_iip4;
};
#endif /* NPC_H */ #endif /* NPC_H */
...@@ -140,6 +140,12 @@ ...@@ -140,6 +140,12 @@
#define NPC_DSA_EXTEND 0x1000 #define NPC_DSA_EXTEND 0x1000
#define NPC_DSA_EDSA 0x8000 #define NPC_DSA_EDSA 0x8000
#define NPC_KEXOF_DMAC 8
#define MKEX_SIGN 0x19bbfdbd15f /* strtoull of "mkexprof" with base:36 */
#define KEX_LD_CFG(bytesm1, hdr_ofs, ena, flags_ena, key_ofs) \
(((bytesm1) << 16) | ((hdr_ofs) << 8) | ((ena) << 7) | \
((flags_ena) << 6) | ((key_ofs) & 0x3F))
enum npc_kpu_parser_state { enum npc_kpu_parser_state {
NPC_S_NA = 0, NPC_S_NA = 0,
NPC_S_KPU1_ETHER, NPC_S_KPU1_ETHER,
...@@ -13114,4 +13120,152 @@ static const struct npc_kpu_profile npc_kpu_profiles[] = { ...@@ -13114,4 +13120,152 @@ static const struct npc_kpu_profile npc_kpu_profiles[] = {
}, },
}; };
static const struct npc_lt_def_cfg npc_lt_defaults = {
.rx_ol2 = {
.lid = NPC_LID_LA,
.ltype_match = NPC_LT_LA_ETHER,
.ltype_mask = 0x0F,
},
.rx_oip4 = {
.lid = NPC_LID_LC,
.ltype_match = NPC_LT_LC_IP,
.ltype_mask = 0x0E,
},
.rx_iip4 = {
.lid = NPC_LID_LG,
.ltype_match = NPC_LT_LG_TU_IP,
.ltype_mask = 0x0F,
},
.rx_oip6 = {
.lid = NPC_LID_LC,
.ltype_match = NPC_LT_LC_IP6,
.ltype_mask = 0x0E,
},
.rx_iip6 = {
.lid = NPC_LID_LG,
.ltype_match = NPC_LT_LG_TU_IP6,
.ltype_mask = 0x0F,
},
.rx_otcp = {
.lid = NPC_LID_LD,
.ltype_match = NPC_LT_LD_TCP,
.ltype_mask = 0x0F,
},
.rx_itcp = {
.lid = NPC_LID_LH,
.ltype_match = NPC_LT_LH_TU_TCP,
.ltype_mask = 0x0F,
},
.rx_oudp = {
.lid = NPC_LID_LD,
.ltype_match = NPC_LT_LD_UDP,
.ltype_mask = 0x0F,
},
.rx_iudp = {
.lid = NPC_LID_LH,
.ltype_match = NPC_LT_LH_TU_UDP,
.ltype_mask = 0x0F,
},
.rx_osctp = {
.lid = NPC_LID_LD,
.ltype_match = NPC_LT_LD_SCTP,
.ltype_mask = 0x0F,
},
.rx_isctp = {
.lid = NPC_LID_LH,
.ltype_match = NPC_LT_LH_TU_SCTP,
.ltype_mask = 0x0F,
},
.rx_ipsec = {
{
.lid = NPC_LID_LD,
.ltype_match = NPC_LT_LD_ESP,
.ltype_mask = 0x0F,
},
{
.spi_offset = 8,
.lid = NPC_LID_LH,
.ltype_match = NPC_LT_LH_TU_ESP,
.ltype_mask = 0x0F,
},
},
.pck_ol2 = {
.lid = NPC_LID_LA,
.ltype_match = NPC_LT_LA_ETHER,
.ltype_mask = 0x0F,
},
.pck_oip4 = {
.lid = NPC_LID_LC,
.ltype_match = NPC_LT_LC_IP,
.ltype_mask = 0x0E,
},
.pck_iip4 = {
.lid = NPC_LID_LG,
.ltype_match = NPC_LT_LG_TU_IP,
.ltype_mask = 0x0F,
},
};
static const struct npc_mcam_kex npc_mkex_default = {
.mkex_sign = MKEX_SIGN,
.name = "default",
.kpu_version = NPC_KPU_PROFILE_VER,
.keyx_cfg = {
/* nibble: LA..LE (ltype only) + Channel */
[NIX_INTF_RX] = ((u64)NPC_MCAM_KEY_X2 << 32) | 0x49247,
[NIX_INTF_TX] = ((u64)NPC_MCAM_KEY_X2 << 32) | ((1ULL << 19) - 1),
},
.intf_lid_lt_ld = {
/* Default RX MCAM KEX profile */
[NIX_INTF_RX] = {
[NPC_LID_LA] = {
/* Layer A: Ethernet: */
[NPC_LT_LA_ETHER] = {
/* DMAC: 6 bytes, KW1[47:0] */
KEX_LD_CFG(0x05, 0x0, 0x1, 0x0, NPC_KEXOF_DMAC),
/* Ethertype: 2 bytes, KW0[47:32] */
KEX_LD_CFG(0x01, 0xc, 0x1, 0x0, 0x4),
},
},
[NPC_LID_LB] = {
/* Layer B: Single VLAN (CTAG) */
/* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */
[NPC_LT_LB_CTAG] = {
KEX_LD_CFG(0x03, 0x0, 0x1, 0x0, 0x4),
},
/* Layer B: Stacked VLAN (STAG|QinQ) */
[NPC_LT_LB_STAG_QINQ] = {
/* CTAG VLAN[2..3] + Ethertype, 4 bytes, KW0[63:32] */
KEX_LD_CFG(0x03, 0x4, 0x1, 0x0, 0x4),
},
},
[NPC_LID_LC] = {
/* Layer C: IPv4 */
[NPC_LT_LC_IP] = {
/* SIP+DIP: 8 bytes, KW2[63:0] */
KEX_LD_CFG(0x07, 0xc, 0x1, 0x0, 0x10),
/* TOS: 1 byte, KW1[63:56] */
KEX_LD_CFG(0x0, 0x1, 0x1, 0x0, 0xf),
},
},
[NPC_LID_LD] = {
/* Layer D:UDP */
[NPC_LT_LD_UDP] = {
/* SPORT: 2 bytes, KW3[15:0] */
KEX_LD_CFG(0x1, 0x0, 0x1, 0x0, 0x18),
/* DPORT: 2 bytes, KW3[31:16] */
KEX_LD_CFG(0x1, 0x2, 0x1, 0x0, 0x1a),
},
/* Layer D:TCP */
[NPC_LT_LD_TCP] = {
/* SPORT: 2 bytes, KW3[15:0] */
KEX_LD_CFG(0x1, 0x0, 0x1, 0x0, 0x18),
/* DPORT: 2 bytes, KW3[31:16] */
KEX_LD_CFG(0x1, 0x2, 0x1, 0x0, 0x1a),
},
},
},
},
};
#endif /* NPC_PROFILE_H */ #endif /* NPC_PROFILE_H */
...@@ -291,6 +291,20 @@ struct rvu_fwdata { ...@@ -291,6 +291,20 @@ struct rvu_fwdata {
struct ptp; struct ptp;
/* KPU profile adapter structure gathering all KPU configuration data and abstracting out the
* source where it came from.
*/
struct npc_kpu_profile_adapter {
const char *name;
u64 version;
const struct npc_lt_def_cfg *lt_def;
const struct npc_kpu_profile_action *ikpu; /* array[pkinds] */
const struct npc_kpu_profile *kpu; /* array[kpus] */
const struct npc_mcam_kex *mkex;
size_t pkinds;
size_t kpus;
};
struct rvu { struct rvu {
void __iomem *afreg_base; void __iomem *afreg_base;
void __iomem *pfreg_base; void __iomem *pfreg_base;
...@@ -339,6 +353,9 @@ struct rvu { ...@@ -339,6 +353,9 @@ struct rvu {
/* Firmware data */ /* Firmware data */
struct rvu_fwdata *fwdata; struct rvu_fwdata *fwdata;
/* NPC KPU data */
struct npc_kpu_profile_adapter kpu;
struct ptp *ptp; struct ptp *ptp;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
...@@ -3112,6 +3112,7 @@ static int nix_aq_init(struct rvu *rvu, struct rvu_block *block) ...@@ -3112,6 +3112,7 @@ static int nix_aq_init(struct rvu *rvu, struct rvu_block *block)
int rvu_nix_init(struct rvu *rvu) int rvu_nix_init(struct rvu *rvu)
{ {
const struct npc_lt_def_cfg *ltdefs;
struct rvu_hwinfo *hw = rvu->hw; struct rvu_hwinfo *hw = rvu->hw;
struct rvu_block *block; struct rvu_block *block;
int blkaddr, err; int blkaddr, err;
...@@ -3142,6 +3143,7 @@ int rvu_nix_init(struct rvu *rvu) ...@@ -3142,6 +3143,7 @@ int rvu_nix_init(struct rvu *rvu)
rvu_write64(rvu, blkaddr, NIX_AF_SQM_DBG_CTL_STATUS, cfg); rvu_write64(rvu, blkaddr, NIX_AF_SQM_DBG_CTL_STATUS, cfg);
} }
ltdefs = rvu->kpu.lt_def;
/* Calibrate X2P bus to check if CGX/LBK links are fine */ /* Calibrate X2P bus to check if CGX/LBK links are fine */
err = nix_calibrate_x2p(rvu, blkaddr); err = nix_calibrate_x2p(rvu, blkaddr);
if (err) if (err)
...@@ -3189,28 +3191,38 @@ int rvu_nix_init(struct rvu *rvu) ...@@ -3189,28 +3191,38 @@ int rvu_nix_init(struct rvu *rvu)
* and validate length and checksums. * and validate length and checksums.
*/ */
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OL2, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OL2,
(NPC_LID_LA << 8) | (NPC_LT_LA_ETHER << 4) | 0x0F); (ltdefs->rx_ol2.lid << 8) | (ltdefs->rx_ol2.ltype_match << 4) |
ltdefs->rx_ol2.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP4, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP4,
(NPC_LID_LC << 8) | (NPC_LT_LC_IP << 4) | 0x0F); (ltdefs->rx_oip4.lid << 8) | (ltdefs->rx_oip4.ltype_match << 4) |
ltdefs->rx_oip4.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP4, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP4,
(NPC_LID_LG << 8) | (NPC_LT_LG_TU_IP << 4) | 0x0F); (ltdefs->rx_iip4.lid << 8) | (ltdefs->rx_iip4.ltype_match << 4) |
ltdefs->rx_iip4.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP6, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OIP6,
(NPC_LID_LC << 8) | (NPC_LT_LC_IP6 << 4) | 0x0F); (ltdefs->rx_oip6.lid << 8) | (ltdefs->rx_oip6.ltype_match << 4) |
ltdefs->rx_oip6.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP6, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IIP6,
(NPC_LID_LG << 8) | (NPC_LT_LG_TU_IP6 << 4) | 0x0F); (ltdefs->rx_iip6.lid << 8) | (ltdefs->rx_iip6.ltype_match << 4) |
ltdefs->rx_iip6.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OTCP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OTCP,
(NPC_LID_LD << 8) | (NPC_LT_LD_TCP << 4) | 0x0F); (ltdefs->rx_otcp.lid << 8) | (ltdefs->rx_otcp.ltype_match << 4) |
ltdefs->rx_otcp.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ITCP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ITCP,
(NPC_LID_LH << 8) | (NPC_LT_LH_TU_TCP << 4) | 0x0F); (ltdefs->rx_itcp.lid << 8) | (ltdefs->rx_itcp.ltype_match << 4) |
ltdefs->rx_itcp.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OUDP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OUDP,
(NPC_LID_LD << 8) | (NPC_LT_LD_UDP << 4) | 0x0F); (ltdefs->rx_oudp.lid << 8) | (ltdefs->rx_oudp.ltype_match << 4) |
ltdefs->rx_oudp.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IUDP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_IUDP,
(NPC_LID_LH << 8) | (NPC_LT_LH_TU_UDP << 4) | 0x0F); (ltdefs->rx_iudp.lid << 8) | (ltdefs->rx_iudp.ltype_match << 4) |
ltdefs->rx_iudp.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OSCTP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_OSCTP,
(NPC_LID_LD << 8) | (NPC_LT_LD_SCTP << 4) | 0x0F); (ltdefs->rx_osctp.lid << 8) | (ltdefs->rx_osctp.ltype_match << 4) |
ltdefs->rx_osctp.ltype_mask);
rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ISCTP, rvu_write64(rvu, blkaddr, NIX_AF_RX_DEF_ISCTP,
(NPC_LID_LH << 8) | (NPC_LT_LH_TU_SCTP << 4) | (ltdefs->rx_isctp.lid << 8) | (ltdefs->rx_isctp.ltype_match << 4) |
0x0F); ltdefs->rx_isctp.ltype_mask);
err = nix_rx_flowkey_alg_cfg(rvu, blkaddr); err = nix_rx_flowkey_alg_cfg(rvu, blkaddr);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment