Introduce macsec hardware offload for cn10k platform
Subsystems (4)
Subbaraya Sundeep
maintainerv2 cover Introduce macsec hardware offload for cn10k platform
CN10K-B and CNF10K-B variaints of CN10K silicon has macsec block(MCS) to encrypt and decrypt packets at MAC/hardware level. This block is a global resource with hardware resources like SecYs, SCs and SAs and is in between NIX block and RPM LMAC. CN10K-B silicon has only one MCS block which receives packets from all LMACS whereas CNF10K-B has seven MCS blocks for seven LMACs. Both MCS blocks are similar in operation except for few register offsets and some configurations require writing to different registers. This patchset introduces macsec hardware offloading support. AF driver manages hardware resources and PF driver consumes them when macsec hardware offloading is needed.
Patch 1 adds basic pci driver for both CN10K-B and CNF10K-B silicons and initializes hardware block.
Patches 2 and 3 adds mailboxes to init, reset and manage resources of the MCS block
Patch 4 adds a low priority rule in MCS TCAM so that the traffic which do not need macsec processing can be sent/received Patch 5 adds macsec stats collection support
Patch 6 adds interrupt handling support and any event in which AF consumer is interested can be notified via mbox notification Patch 7 adds debugfs support which helps in debugging packet path
Patch 8 introduces macsec hardware offload feature for PF netdev driver.
v2 changes:
Fix build error by changing #ifdef CONFIG_MACSEC to #if IS_ENABLED(CONFIG_MACSEC)
Thanks,
Sundeep
Geetha sowjanya (7):
octeontx2-af: cn10k: Introduce driver for macsec block.
octeontx2-af: cn10k: mcs: Add mailboxes for port related operations
octeontx2-af: cn10k: mcs: Manage the MCS block hardware resources
octeontx2-af: cn10k: mcs: Install a default TCAM for normal traffic
octeontx2-af: cn10k: mcs: Support for stats collection
octeontx2-af: cn10k: mcs: Handle MCS block interrupts
octeontx2-af: cn10k: mcs: Add debugfs support
Subbaraya Sundeep (1):
octeontx2-pf: mcs: Introduce MACSEC hardware offloading
drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 471 +++++- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 1601 +++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 246 +++ .../ethernet/marvell/octeontx2/af/mcs_cnf10kb.c | 214 +++ .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 1102 +++++++++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 888 +++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 20 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 21 + .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 346 ++++ .../net/ethernet/marvell/octeontx2/nic/Makefile | 1 + .../ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 1668 ++++++++++++++++++++ .../ethernet/marvell/octeontx2/nic/otx2_common.c | 1 + .../ethernet/marvell/octeontx2/nic/otx2_common.h | 90 ++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 16 + 15 files changed, 6680 insertions(+), 7 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 1/8 octeontx2-af: cn10k: Introduce driver for macsec block.
From: Geetha sowjanya <[email protected]>
CN10K-B and CNF10K-B has macsec block(MCS) to encrypt and decrypt packets at MAC level. This block is a global resource with hardware resources like SecYs, SCs and SAs and is in between NIX block and RPM LMAC. CN10K-B silicon has only one MCS block which receives packets from all LMACS whereas CNF10K-B has seven MCS blocks for seven LMACs. Both MCS blocks are similar in operation except for few register offsets and some configurations require writing to different registers. Those differences between IPs are handled using separate ops. This patch adds basic driver and does the initial hardware calibration and parser configuration.
--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 368 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 92 ++++++ .../ethernet/marvell/octeontx2/af/mcs_cnf10kb.c | 65 ++++ .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 78 +++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 52 +++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 14 + drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 8 + 8 files changed, 678 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -11,4 +11,4 @@ rvu_mbox-y := mbox.o rvu_trace.o rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \ rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \ - rvu_sdp.o rvu_npc_hash.o + rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o
drivers/net/ethernet/marvell/octeontx2/af/mcs.c new file +368 -0
368 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs.h new file +92 -0
92 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c new file +65 -0
65 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h new file +78 -0
78 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c new file +52 -0
52 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +14 -0
@@ -16,6 +16,7 @@#include "rvu.h" #include "rvu_reg.h" #include "ptp.h" +#include "mcs.h" #include "rvu_trace.h" #include "rvu_npc_hash.h"
@@ -1159,6 +1160,12 @@ static int rvu_setup_hw_resources(struct rvu *rvu)rvu_program_channels (rvu); + err =rvu_mcs_init (rvu); +if (err) { +dev_err (rvu->dev,"%s: Failed to initialize mcs\n" , __func__); + goto nix_err; + } +return 0 ; nix_err:
@@ -3354,12 +3361,18 @@ static int __init rvu_init_module(void)if (err <0 ) goto ptp_err; + err =pci_register_driver (&mcs_driver); +if (err <0 ) + goto mcs_err; + err =pci_register_driver (&rvu_driver);if (err <0 ) goto rvu_err;return 0 ; rvu_err: +pci_unregister_driver (&mcs_driver); +mcs_err:pci_unregister_driver (&ptp_driver); ptp_err:pci_unregister_driver (&cgx_driver);
@@ -3370,6 +3383,7 @@ static int __init rvu_init_module(void) static void __exit rvu_cleanup_module(void) {pci_unregister_driver (&rvu_driver); +pci_unregister_driver (&mcs_driver);pci_unregister_driver (&ptp_driver);pci_unregister_driver (&cgx_driver); }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8 -0
@@ -25,6 +25,8 @@/* Subsystem Device ID */ #define PCI_SUBSYS_DEVID_96XX 0xB200#define PCI_SUBSYS_DEVID_CN10K_A 0xB900 +#define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00 +#define PCI_SUBSYS_DEVID_CN10K_B 0xBD00/* PCI BAR nos */ #define PCI_AF_REG_BAR_NUM 0
@@ -497,6 +499,8 @@ struct rvu {struct ptp *ptp; +int mcs_blk_cnt; +#ifdef CONFIG_DEBUG_FS struct rvu_debugfs rvu_dbg;#endif
@@ -868,4 +872,8 @@ void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);int rvu_npc_set_parse_mode (struct rvu *rvu,u16 pcifunc,u64 mode,u8 dir,u64 pkind,u8 var_len_off,u8 var_len_off_mask,u8 shift_dir); + +/* CN10K MCS */ +int rvu_mcs_init (struct rvu *rvu); +#endif /* RVU_H */
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 2/8 octeontx2-af: cn10k: mcs: Add mailboxes for port related operations
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
There are set of configurations to be done at MCS port level like bringing port out of reset, making port as operational or bypass. This patch adds all the port related mailbox message handlers so that AF consumers can use them.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 111 +++++++++++++++++- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 94 +++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 10 ++ .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 36 ++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 129 ++++++++++++++++++++- 5 files changed, 376 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +108 -3
@@ -293,9 +293,21 @@ M(NIX_BANDPROF_ALLOC, 0x801d, nix_bandprof_alloc, nix_bandprof_alloc_req, \M (NIX_BANDPROF_FREE ,0x801e , nix_bandprof_free, nix_bandprof_free_req, \ msg_rsp) \M (NIX_BANDPROF_GET_HWINFO ,0x801f , nix_bandprof_get_hwinfo, msg_req, \ - nix_bandprof_get_hwinfo_rsp) - -/* Messages initiated by AF (range 0xC00 - 0xDFF) */ + nix_bandprof_get_hwinfo_rsp) \ +/* MCS mbox IDs (range 0xA000 - 0xBFFF) */ \ +M (MCS_SET_ACTIVE_LMAC ,0xa00a , mcs_set_active_lmac, mcs_set_active_lmac, \ + msg_rsp) \ +M(MCS_GET_HW_INFO, 0xa00b, mcs_get_hw_info, msg_req, mcs_hw_info) \ +M(MCS_SET_LMAC_MODE, 0xa013, mcs_set_lmac_mode, mcs_set_lmac_mode, msg_rsp) \ +M(MCS_PORT_RESET, 0xa018, mcs_port_reset, mcs_port_reset_req, msg_rsp) \ +M(MCS_PORT_CFG_SET, 0xa019, mcs_port_cfg_set, mcs_port_cfg_set_req, msg_rsp)\ +M (MCS_PORT_CFG_GET ,0xa020 , mcs_port_cfg_get, mcs_port_cfg_get_req, \ + mcs_port_cfg_get_rsp) \ +M (MCS_CUSTOM_TAG_CFG_GET ,0xa021 , mcs_custom_tag_cfg_get, \ + mcs_custom_tag_cfg_get_req, \ + mcs_custom_tag_cfg_get_rsp) + +/* Messages initiated by AF (range 0xC00 - 0xEFF) */#define MBOX_UP_CGX_MESSAGES \ M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, msg_rsp)
@@ -1657,4 +1669,97 @@ enum cgx_af_status { LMAC_AF_ERR_EXACT_MATCH_TBL_LOOK_UP_FAILED = -1110, }; +enum mcs_direction { +MCS_RX , +MCS_TX , +}; + +struct mcs_hw_info { +struct mbox_msghdr hdr; +u8 num_mcs_blks;/* Number of MCS blocks */ +u8 tcam_entries;/* RX/TX Tcam entries per mcs block */ +u8 secy_entries;/* RX/TX SECY entries per mcs block */ +u8 sc_entries;/* RX/TX SC CAM entries per mcs block */ +u8 sa_entries;/* PN table entries = SA entries */ +u64 rsvd[16 ]; +}; + +struct mcs_set_active_lmac { +struct mbox_msghdr hdr; +u32 lmac_bmap;/* bitmap of active lmac per mcs block */ +u8 mcs_id; +u16 chan_base;/* MCS channel base */ +u64 rsvd; +}; + +struct mcs_set_lmac_mode { +struct mbox_msghdr hdr; +u8 mode;/* 1:Bypass 0:Operational */ +u8 lmac_id; +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_port_reset_req { +struct mbox_msghdr hdr; +u8 reset; +u8 mcs_id; +u8 port_id; +u64 rsvd; +}; + +struct mcs_port_cfg_set_req { +struct mbox_msghdr hdr; +u8 cstm_tag_rel_mode_sel; +u8 custom_hdr_enb; +u8 fifo_skid; +u8 port_mode; +u8 port_id; +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_port_cfg_get_req { +struct mbox_msghdr hdr; +u8 port_id; +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_port_cfg_get_rsp { +struct mbox_msghdr hdr; +u8 cstm_tag_rel_mode_sel; +u8 custom_hdr_enb; +u8 fifo_skid; +u8 port_mode; +u8 port_id; +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_custom_tag_cfg_get_req { +struct mbox_msghdr hdr; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_custom_tag_cfg_get_rsp { +struct mbox_msghdr hdr; +u16 cstm_etype[8 ]; +u8 cstm_indx[8 ]; +u8 cstm_etype_en; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +/* MCS mailbox error codes +* Range 1201 - 1300. +*/ +enum mcs_af_status { +MCS_AF_ERR_INVALID_MCSID =-1201 , +MCS_AF_ERR_NOT_MAPPED =-1202 , +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +94 -0
100 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs.h +10 -0
@@ -17,6 +17,10 @@#define MCS_ID_MASK 0x7 +#define MCS_PORT_MODE_MASK 0x3 +#define MCS_PORT_FIFO_SKID_MASK 0x3F +#define MCS_MAX_CUSTOM_TAGS 0x8 +/* Reserved resources for default bypass entry */ #define MCS_RSRC_RSVD_CNT 1
@@ -79,6 +83,12 @@ int mcs_set_lmac_channels(int mcs_id, u16 base);int mcs_install_flowid_bypass_entry (struct mcs *mcs);void mcs_set_lmac_mode (struct mcs *mcs,int lmac_id,u8 mode); +void mcs_reset_port (struct mcs *mcs,u8 port_id,u8 reset); +void mcs_set_port_cfg (struct mcs *mcs,struct mcs_port_cfg_set_req *req); +void mcs_get_port_cfg (struct mcs *mcs,struct mcs_port_cfg_get_req *req, +struct mcs_port_cfg_get_rsp *rsp); +void mcs_get_custom_tag_cfg (struct mcs *mcs,struct mcs_custom_tag_cfg_get_req *req, +struct mcs_custom_tag_cfg_get_rsp *rsp);/* CN10K-B APIs */ void cn10kb_mcs_set_hw_capabilities (struct mcs *mcs);
drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h +36 -0
@@ -11,6 +11,15 @@/* Registers */ #define MCSX_IP_MODE 0x900c8ull +#define MCSX_MCS_TOP_SLAVE_PORT_RESET (a) ({ \ + u64 offset; \ + \ + offset = 0x408ull; \ + if (mcs->hw->mcs_blks > 1) \ + offset = 0xa28ull; \ + offset += (a) * 0x8ull; \ + offset; }) +#define MCSX_MCS_TOP_SLAVE_CHANNEL_CFG (a) ({ \ u64 offset; \
@@ -29,6 +38,23 @@ offset =0x60000ull ; \ offset; }) +#define MCSX_MIL_RX_LMACX_CFG (a) ({ \ + u64 offset; \ + \ + offset = 0x900a8ull; \ + if (mcs->hw->mcs_blks > 1) \ + offset = 0x700a8ull; \ + offset += (a) * 0x800ull; \ + offset; }) + +#define MCSX_HIL_GLOBAL ({ \ + u64 offset; \ + \ + offset = 0xc0000ull; \ + if (mcs->hw->mcs_blks > 1) \ + offset = 0xa0000ull; \ + offset; }) +#define MCSX_LINK_LMACX_CFG (a) ({ \ u64 offset; \ \
@@ -61,6 +87,16 @@/* PEX registers */ #define MCSX_PEX_RX_SLAVE_VLAN_CFGX (a) (0x3b58ull + (a) * 0x8ull)#define MCSX_PEX_TX_SLAVE_VLAN_CFGX (a) (0x46f8ull + (a) * 0x8ull) +#define MCSX_PEX_TX_SLAVE_CUSTOM_TAG_REL_MODE_SEL (a) (0x788ull + (a) * 0x8ull) +#define MCSX_PEX_TX_SLAVE_PORT_CONFIG (a) (0x4738ull + (a) * 0x8ull) + +#define MCSX_PEX_RX_SLAVE_PEX_CONFIGURATION ({ \ + u64 offset; \ + \ + offset = 0x3b50ull; \ + if (mcs->hw->mcs_blks > 1) \ + offset = 0x4c0ull; \ + offset; })/* CNF10K-B */ #define MCSX_PEX_RX_SLAVE_CUSTOM_TAGX (a) (0x4c8ull + (a) * 0x8ull)
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +128 -1
146 lines not on this page · raw message
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 3/8 octeontx2-af: cn10k: mcs: Manage the MCS block hardware resources
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
To establish a macsec connection association netdev driver needs hardware resources like SecY, TCAM flows, SCs and SAs. This patch manages allocating, freeing and configuring those resources. AF consumers can request resources and configure them via these mailbox messages. AF can allocate until it runs out of hardware resources.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 211 ++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 447 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 59 ++- .../ethernet/marvell/octeontx2/af/mcs_cnf10kb.c | 55 +++ .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 385 ++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 374 +++++++++++++++++ 6 files changed, 1530 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +211 -0
@@ -295,10 +295,38 @@ M(NIX_BANDPROF_FREE, 0x801e, nix_bandprof_free, nix_bandprof_free_req, \M (NIX_BANDPROF_GET_HWINFO ,0x801f , nix_bandprof_get_hwinfo, msg_req, \ nix_bandprof_get_hwinfo_rsp) \ /* MCS mbox IDs (range 0xA000 - 0xBFFF) */ \ +M (MCS_ALLOC_RESOURCES ,0xa000 , mcs_alloc_resources, mcs_alloc_rsrc_req, \ + mcs_alloc_rsrc_rsp) \ +M(MCS_FREE_RESOURCES, 0xa001, mcs_free_resources, mcs_free_rsrc_req, msg_rsp) \ +M (MCS_FLOWID_ENTRY_WRITE ,0xa002 , mcs_flowid_entry_write, mcs_flowid_entry_write_req, \ + msg_rsp) \ +M (MCS_SECY_PLCY_WRITE ,0xa003 , mcs_secy_plcy_write, mcs_secy_plcy_write_req, \ + msg_rsp) \ +M (MCS_RX_SC_CAM_WRITE ,0xa004 , mcs_rx_sc_cam_write, mcs_rx_sc_cam_write_req, \ + msg_rsp) \ +M (MCS_SA_PLCY_WRITE ,0xa005 , mcs_sa_plcy_write, mcs_sa_plcy_write_req, \ + msg_rsp) \ +M (MCS_TX_SC_SA_MAP_WRITE ,0xa006 , mcs_tx_sc_sa_map_write, mcs_tx_sc_sa_map, \ + msg_rsp) \ +M (MCS_RX_SC_SA_MAP_WRITE ,0xa007 , mcs_rx_sc_sa_map_write, mcs_rx_sc_sa_map, \ + msg_rsp) \ +M (MCS_FLOWID_ENA_ENTRY ,0xa008 , mcs_flowid_ena_entry, mcs_flowid_ena_dis_entry, \ + msg_rsp) \ +M (MCS_PN_TABLE_WRITE ,0xa009 , mcs_pn_table_write, mcs_pn_table_write_req, \ + msg_rsp) \M (MCS_SET_ACTIVE_LMAC ,0xa00a , mcs_set_active_lmac, mcs_set_active_lmac, \ msg_rsp) \ M(MCS_GET_HW_INFO, 0xa00b, mcs_get_hw_info, msg_req, mcs_hw_info) \ M(MCS_SET_LMAC_MODE, 0xa013, mcs_set_lmac_mode, mcs_set_lmac_mode, msg_rsp) \ +M (MCS_SET_PN_THRESHOLD ,0xa014 , mcs_set_pn_threshold, mcs_set_pn_threshold, \ + msg_rsp) \ +M (MCS_ALLOC_CTRL_PKT_RULE ,0xa015 , mcs_alloc_ctrl_pkt_rule, \ + mcs_alloc_ctrl_pkt_rule_req, \ + mcs_alloc_ctrl_pkt_rule_rsp) \ +M (MCS_FREE_CTRL_PKT_RULE ,0xa016 , mcs_free_ctrl_pkt_rule, \ + mcs_free_ctrl_pkt_rule_req, msg_rsp) \ +M (MCS_CTRL_PKT_RULE_WRITE ,0xa017 , mcs_ctrl_pkt_rule_write, \ + mcs_ctrl_pkt_rule_write_req, msg_rsp) \ M(MCS_PORT_RESET, 0xa018, mcs_port_reset, mcs_port_reset_req, msg_rsp) \ M(MCS_PORT_CFG_SET, 0xa019, mcs_port_cfg_set, mcs_port_cfg_set_req, msg_rsp)\ M(MCS_PORT_CFG_GET, 0xa020, mcs_port_cfg_get, mcs_port_cfg_get_req, \
@@ -1674,6 +1702,133 @@ enum mcs_direction { MCS_TX, }; +enum mcs_rsrc_type { +MCS_RSRC_TYPE_FLOWID , +MCS_RSRC_TYPE_SECY , +MCS_RSRC_TYPE_SC , +MCS_RSRC_TYPE_SA , +}; + +struct mcs_alloc_rsrc_req { +struct mbox_msghdr hdr; +u8 rsrc_type; +u8 rsrc_cnt;/* Resources count */ +u8 mcs_id;/* MCS block ID */ +u8 dir;/* Macsec ingress or egress side */ +u8 all;/* Allocate all resource type one each */ +u64 rsvd; +}; + +struct mcs_alloc_rsrc_rsp { +struct mbox_msghdr hdr; +u8 flow_ids[128 ];/* Index of reserved entries */ +u8 secy_ids[128 ]; +u8 sc_ids[128 ]; +u8 sa_ids[256 ]; +u8 rsrc_type; +u8 rsrc_cnt;/* No of entries reserved */ +u8 mcs_id; +u8 dir; +u8 all; +u8 rsvd[256 ];/* reserved fields for future expansion */ +}; + +struct mcs_free_rsrc_req { +struct mbox_msghdr hdr; +u8 rsrc_id;/* Index of the entry to be freed */ +u8 rsrc_type; +u8 mcs_id; +u8 dir; +u8 all;/* Free all the cam resources */ +u64 rsvd; +}; + +struct mcs_flowid_entry_write_req { +struct mbox_msghdr hdr; +u64 data[4 ]; +u64 mask[4 ]; +u64 sci;/* CNF10K-B for tx_secy_mem_map */ +u8 flow_id; +u8 secy_id;/* secyid for which flowid is mapped */ +u8 sc_id;/* Valid if dir = MCS_TX, SC_CAM id mapped to flowid */ +u8 ena;/* Enable tcam entry */ +u8 ctrl_pkt; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_secy_plcy_write_req { +struct mbox_msghdr hdr; +u64 plcy; +u8 secy_id; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +/* RX SC_CAM mapping */ +struct mcs_rx_sc_cam_write_req { +struct mbox_msghdr hdr; +u64 sci;/* SCI */ +u64 secy_id;/* secy index mapped to SC */ +u8 sc_id;/* SC CAM entry index */ +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_sa_plcy_write_req { +struct mbox_msghdr hdr; +u64 plcy[2 ][9 ];/* Support 2 SA policy */ +u8 sa_index[2 ]; +u8 sa_cnt; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_tx_sc_sa_map { +struct mbox_msghdr hdr; +u8 sa_index0; +u8 sa_index1; +u8 rekey_ena; +u8 sa_index0_vld; +u8 sa_index1_vld; +u8 tx_sa_active; +u64 sectag_sci; +u8 sc_id;/* used as index for SA_MEM_MAP */ +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_rx_sc_sa_map { +struct mbox_msghdr hdr; +u8 sa_index; +u8 sa_in_use; +u8 sc_id; +u8 an;/* value range 0-3, sc_id + an used as index SA_MEM_MAP */ +u8 mcs_id; +u64 rsvd; +}; + +struct mcs_flowid_ena_dis_entry { +struct mbox_msghdr hdr; +u8 flow_id; +u8 ena; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_pn_table_write_req { +struct mbox_msghdr hdr; +u64 next_pn; +u8 pn_id; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; +struct mcs_hw_info {struct mbox_msghdr hdr;u8 num_mcs_blks;/* Number of MCS blocks */
@@ -1762,4 +1917,60 @@ enum mcs_af_status { MCS_AF_ERR_NOT_MAPPED = -1202, }; +struct mcs_set_pn_threshold { +struct mbox_msghdr hdr; +u64 threshold; +u8 xpn;/* '1' for setting xpn threshold */ +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +enum mcs_ctrl_pkt_rulew_type { +MCS_CTRL_PKT_RULE_TYPE_ETH , +MCS_CTRL_PKT_RULE_TYPE_DA , +MCS_CTRL_PKT_RULE_TYPE_RANGE , +MCS_CTRL_PKT_RULE_TYPE_COMBO , +MCS_CTRL_PKT_RULE_TYPE_MAC , +}; + +struct mcs_alloc_ctrl_pkt_rule_req { +struct mbox_msghdr hdr; +u8 rule_type; +u8 mcs_id;/* MCS block ID */ +u8 dir;/* Macsec ingress or egress side */ +u64 rsvd; +}; + +struct mcs_alloc_ctrl_pkt_rule_rsp { +struct mbox_msghdr hdr; +u8 rule_idx; +u8 rule_type; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_free_ctrl_pkt_rule_req { +struct mbox_msghdr hdr; +u8 rule_idx; +u8 rule_type; +u8 mcs_id; +u8 dir; +u8 all; +u64 rsvd; +}; + +struct mcs_ctrl_pkt_rule_write_req { +struct mbox_msghdr hdr; +u64 data0; +u64 data1; +u64 data2; +u8 rule_idx; +u8 rule_type; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +447 -0
477 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs.h +58 -1
104 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c +55 -0
64 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h +385 -0
395 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +374 -0
380 lines not on this page · raw message
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 4/8 octeontx2-af: cn10k: mcs: Install a default TCAM for normal traffic
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
Out of all the TCAM entries, reserve last TX and RX TCAM flow entry(low priority) so that normal traffic can be sent out and received. The traffic which needs macsec processing hits the high priority TCAM flows. Also install a FLR handler to free the allocated resources for PF/VF.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 45 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 23 +++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + 3 files changed, 69 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +45 -0
@@ -181,6 +181,51 @@ void mcs_flowid_entry_write(struct mcs *mcs, u64 *data, u64 *mask, int flow_id, } } +int mcs_install_flowid_bypass_entry (struct mcs *mcs) +{ +int flow_id, secy_id, reg_id; +struct secy_mem_map map; +u64 reg, plcy =0 ; + +/* Flow entry */ + flow_id = mcs->hw->tcam_entries -MCS_RSRC_RSVD_CNT ; +for (reg_id =0 ; reg_id <4 ; reg_id++) { + reg =MCSX_CPM_RX_SLAVE_FLOWID_TCAM_MASKX (reg_id, flow_id); +mcs_reg_write (mcs, reg,GENMASK_ULL (63 ,0 )); + } +for (reg_id =0 ; reg_id <4 ; reg_id++) { + reg =MCSX_CPM_TX_SLAVE_FLOWID_TCAM_MASKX (reg_id, flow_id); +mcs_reg_write (mcs, reg,GENMASK_ULL (63 ,0 )); + } +/* secy */ + secy_id = mcs->hw->secy_entries -MCS_RSRC_RSVD_CNT ; + +/* Set validate frames to NULL and enable control port */ + plcy =0x7ull ; +if (mcs->hw->mcs_blks >1 ) + plcy =BIT_ULL (0 ) |0x3ull <<4 ; +mcs_secy_plcy_write (mcs, plcy, secy_id,MCS_RX ); + +/* Enable control port and set mtu to max */ + plcy =BIT_ULL (0 ) |GENMASK_ULL (43 ,28 ); +if (mcs->hw->mcs_blks >1 ) + plcy =BIT_ULL (0 ) |GENMASK_ULL (63 ,48 ); +mcs_secy_plcy_write (mcs, plcy, secy_id,MCS_TX ); + +/* Map flowid to secy */ + map.secy = secy_id; + map.ctrl_pkt =0 ; + map.flow_id = flow_id; + mcs->mcs_ops->mcs_flowid_secy_map (mcs, &map,MCS_RX ); + map.sc = secy_id; + mcs->mcs_ops->mcs_flowid_secy_map (mcs, &map,MCS_TX ); + +/* Enable Flowid entry */ +mcs_ena_dis_flowid_entry (mcs, flow_id,MCS_RX , true); +mcs_ena_dis_flowid_entry (mcs, flow_id,MCS_TX , true); +return 0 ; +} +void mcs_clear_secy_plcy (struct mcs *mcs,int secy_id,int dir) {struct mcs_rsrc_map *map;
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +23 -0
@@ -133,6 +133,27 @@ int rvu_mbox_handler_mcs_custom_tag_cfg_get(struct rvu *rvu, struct mcs_custom_treturn 0 ; } +int rvu_mcs_flr_handler (struct rvu *rvu,u16 pcifunc) +{ +struct mcs *mcs; +int mcs_id; + +/* CNF10K-B mcs0-6 are mapped to RPM2-8*/ +if (rvu->mcs_blk_cnt >1 ) { +for (mcs_id =0 ; mcs_id < rvu->mcs_blk_cnt; mcs_id++) { + mcs =mcs_get_pdata (mcs_id); +mcs_free_all_rsrc (mcs,MCS_RX , pcifunc); +mcs_free_all_rsrc (mcs,MCS_TX , pcifunc); + } + }else { +/* CN10K-B has only one mcs block */ + mcs =mcs_get_pdata (0 ); +mcs_free_all_rsrc (mcs,MCS_RX , pcifunc); +mcs_free_all_rsrc (mcs,MCS_TX , pcifunc); + } +return 0 ; +} +int rvu_mbox_handler_mcs_flowid_ena_entry (struct rvu *rvu,struct mcs_flowid_ena_dis_entry *req,struct msg_rsp *rsp)
@@ -543,8 +564,10 @@ int rvu_mcs_init(struct rvu *rvu)rvu_mcs_set_lmac_bmap (rvu); } +/* Install default tcam bypass entry and set port to operational mode */ for (mcs_id =0 ; mcs_id < rvu->mcs_blk_cnt; mcs_id++) { mcs =mcs_get_pdata (mcs_id); +mcs_install_flowid_bypass_entry (mcs);for (lmac =0 ; lmac < mcs->hw->lmac_cnt; lmac++)mcs_set_lmac_mode (mcs, lmac,0 ); }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -875,5 +875,6 @@ int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir,/* CN10K MCS */ int rvu_mcs_init (struct rvu *rvu); +int rvu_mcs_flr_handler (struct rvu *rvu,u16 pcifunc);#endif /* RVU_H */
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 5/8 octeontx2-af: cn10k: mcs: Support for stats collection
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
Add mailbox messages to return the resource stats to the caller. Stats of SecY, SC and SAs as per the macsec standard, TCAM flow id hits/miss, mailbox to clear the stats are implemented.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 111 ++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 310 +++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 13 + .../ethernet/marvell/octeontx2/af/mcs_cnf10kb.c | 26 ++ .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 435 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 153 ++++++++ 6 files changed, 1048 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +111 -0
@@ -317,6 +317,15 @@ M(MCS_PN_TABLE_WRITE, 0xa009, mcs_pn_table_write, mcs_pn_table_write_req, \M (MCS_SET_ACTIVE_LMAC ,0xa00a , mcs_set_active_lmac, mcs_set_active_lmac, \ msg_rsp) \ M(MCS_GET_HW_INFO, 0xa00b, mcs_get_hw_info, msg_req, mcs_hw_info) \ +M (MCS_GET_FLOWID_STATS ,0xa00c , mcs_get_flowid_stats, mcs_stats_req, \ + mcs_flowid_stats) \ +M (MCS_GET_SECY_STATS ,0xa00d , mcs_get_secy_stats, mcs_stats_req, \ + mcs_secy_stats) \ +M(MCS_GET_SC_STATS, 0xa00e, mcs_get_sc_stats, mcs_stats_req, mcs_sc_stats) \ +M(MCS_GET_SA_STATS, 0xa00f, mcs_get_sa_stats, mcs_stats_req, mcs_sa_stats) \ +M (MCS_GET_PORT_STATS ,0xa010 , mcs_get_port_stats, mcs_stats_req, \ + mcs_port_stats) \ +M(MCS_CLEAR_STATS, 0xa011, mcs_clear_stats, mcs_clear_stats, msg_rsp) \ M(MCS_SET_LMAC_MODE, 0xa013, mcs_set_lmac_mode, mcs_set_lmac_mode, msg_rsp) \M (MCS_SET_PN_THRESHOLD ,0xa014 , mcs_set_pn_threshold, mcs_set_pn_threshold, \ msg_rsp) \
@@ -1973,4 +1982,106 @@ struct mcs_ctrl_pkt_rule_write_req {u64 rsvd; }; +struct mcs_stats_req { +struct mbox_msghdr hdr; +u8 id; +u8 mcs_id; +u8 dir; +u64 rsvd; +}; + +struct mcs_flowid_stats { +struct mbox_msghdr hdr; +u64 tcam_hit_cnt; +u64 rsvd; +}; + +struct mcs_secy_stats { +struct mbox_msghdr hdr; +u64 ctl_pkt_bcast_cnt; +u64 ctl_pkt_mcast_cnt; +u64 ctl_pkt_ucast_cnt; +u64 ctl_octet_cnt; +u64 unctl_pkt_bcast_cnt; +u64 unctl_pkt_mcast_cnt; +u64 unctl_pkt_ucast_cnt; +u64 unctl_octet_cnt; +/* Valid only for RX */ +u64 octet_decrypted_cnt; +u64 octet_validated_cnt; +u64 pkt_port_disabled_cnt; +u64 pkt_badtag_cnt; +u64 pkt_nosa_cnt; +u64 pkt_nosaerror_cnt; +u64 pkt_tagged_ctl_cnt; +u64 pkt_untaged_cnt; +u64 pkt_ctl_cnt;/* CN10K-B */ +u64 pkt_notag_cnt;/* CNF10K-B */ +/* Valid only for TX */ +u64 octet_encrypted_cnt; +u64 octet_protected_cnt; +u64 pkt_noactivesa_cnt; +u64 pkt_toolong_cnt; +u64 pkt_untagged_cnt; +u64 rsvd[4 ]; +}; + +struct mcs_port_stats { +struct mbox_msghdr hdr; +u64 tcam_miss_cnt; +u64 parser_err_cnt; +u64 preempt_err_cnt;/* CNF10K-B */ +u64 sectag_insert_err_cnt; +u64 rsvd[4 ]; +}; + +/* Only for CN10K-B */ +struct mcs_sa_stats { +struct mbox_msghdr hdr; +/* RX */ +u64 pkt_invalid_cnt; +u64 pkt_nosaerror_cnt; +u64 pkt_notvalid_cnt; +u64 pkt_ok_cnt; +u64 pkt_nosa_cnt; +/* TX */ +u64 pkt_encrypt_cnt; +u64 pkt_protected_cnt; +u64 rsvd[4 ]; +}; + +struct mcs_sc_stats { +struct mbox_msghdr hdr; +/* RX */ +u64 hit_cnt; +u64 pkt_invalid_cnt; +u64 pkt_late_cnt; +u64 pkt_notvalid_cnt; +u64 pkt_unchecked_cnt; +u64 pkt_delay_cnt;/* CNF10K-B */ +u64 pkt_ok_cnt;/* CNF10K-B */ +u64 octet_decrypt_cnt;/* CN10K-B */ +u64 octet_validate_cnt;/* CN10K-B */ +/* TX */ +u64 pkt_encrypt_cnt; +u64 pkt_protected_cnt; +u64 octet_encrypt_cnt;/* CN10K-B */ +u64 octet_protected_cnt;/* CN10K-B */ +u64 rsvd[4 ]; +}; + +struct mcs_clear_stats { +struct mbox_msghdr hdr; +#define MCS_FLOWID_STATS 0 +#define MCS_SECY_STATS 1 +#define MCS_SC_STATS 2 +#define MCS_SA_STATS 3 +#define MCS_PORT_STATS 4 +u8 type;/* FLOWID, SECY, SC, SA, PORT */ +u8 id;/* type = PORT, If id = FF(invalid) port no is derived from pcifunc */ +u8 mcs_id; +u8 dir; +u8 all;/* All resources stats mapped to PF are cleared */ +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +310 -0
328 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs.h +13 -0
@@ -85,6 +85,8 @@ struct mcs {u8 mcs_id;struct mcs_ops *mcs_ops;struct list_head mcs_list; +/* Lock for mcs stats */ +struct mutex stats_lock; };struct mcs_ops {
@@ -156,4 +158,15 @@ void cnf10kb_mcs_flowid_secy_map(struct mcs *mcs, struct secy_mem_map *map, intvoid cnf10kb_mcs_rx_sa_mem_map_write (struct mcs *mcs,struct mcs_rx_sc_sa_map *map);void cnf10kb_mcs_parser_cfg (struct mcs *mcs); +/* Stats APIs */ +void mcs_get_sc_stats (struct mcs *mcs,struct mcs_sc_stats *stats,int id,int dir); +void mcs_get_sa_stats (struct mcs *mcs,struct mcs_sa_stats *stats,int id,int dir); +void mcs_get_port_stats (struct mcs *mcs,struct mcs_port_stats *stats,int id,int dir); +void mcs_get_flowid_stats (struct mcs *mcs,struct mcs_flowid_stats *stats,int id,int dir); +void mcs_get_rx_secy_stats (struct mcs *mcs,struct mcs_secy_stats *stats,int id); +void mcs_get_tx_secy_stats (struct mcs *mcs,struct mcs_secy_stats *stats,int id); +void mcs_clear_stats (struct mcs *mcs,u8 type,u8 id,int dir); +int mcs_clear_all_stats (struct mcs *mcs,u16 pcifunc,int dir); +int mcs_set_force_clk_en (struct mcs *mcs,bool set); +#endif /* MCS_H */
drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c +26 -0
@@ -118,3 +118,29 @@ void cnf10kb_mcs_rx_sa_mem_map_write(struct mcs *mcs, struct mcs_rx_sc_sa_map *m reg =MCSX_CPM_RX_SLAVE_SA_MAP_MEMX ((4 * map->sc_id) + map->an);mcs_reg_write (mcs, reg, val); } + +int mcs_set_force_clk_en (struct mcs *mcs,bool set) +{ +unsigned long timeout = jiffies +usecs_to_jiffies (2000 ); +u64 val; + + val =mcs_reg_read (mcs,MCSX_MIL_GLOBAL ); + +if (set) { + val |=BIT_ULL (4 ); +mcs_reg_write (mcs,MCSX_MIL_GLOBAL , val); + +/* Poll till mcsx_mil_ip_gbl_status.mcs_ip_stats_ready value is 1 */ +while (!(mcs_reg_read (mcs,MCSX_MIL_IP_GBL_STATUS ) &BIT_ULL (0 ))) { +if (time_after (jiffies, timeout)) { +dev_err (mcs->dev,"MCS set force clk enable failed\n" ); +break ; + } + } + }else { + val &= ~BIT_ULL (4 ); +mcs_reg_write (mcs,MCSX_MIL_GLOBAL , val); + } + +return 0 ; +}
drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h +435 -0
445 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +153 -0
159 lines not on this page · raw message
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 6/8 octeontx2-af: cn10k: mcs: Handle MCS block interrupts
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
Hardware triggers an interrupt for events like PN wrap to zero, PN crosses set threshold. This interrupt is received by the MCS_AF. MCS AF then finds the PF/VF to which SA is mapped and notifies them using mcs_intr_notify mbox message.
PF/VF using mcs_intr_cfg mbox can configure the list of interrupts for which they want to receive the notification from AF.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 38 +++ drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 337 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/mcs.h | 74 +++++ .../ethernet/marvell/octeontx2/af/mcs_cnf10kb.c | 86 +++++- .../net/ethernet/marvell/octeontx2/af/mcs_reg.h | 168 ++++++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 159 ++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 6 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 8 + 8 files changed, 864 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +38 -0
@@ -326,6 +326,7 @@ M(MCS_GET_SA_STATS, 0xa00f, mcs_get_sa_stats, mcs_stats_req, mcs_sa_stats) \M (MCS_GET_PORT_STATS ,0xa010 , mcs_get_port_stats, mcs_stats_req, \ mcs_port_stats) \ M(MCS_CLEAR_STATS, 0xa011, mcs_clear_stats, mcs_clear_stats, msg_rsp) \ +M(MCS_INTR_CFG, 0xa012, mcs_intr_cfg, mcs_intr_cfg, msg_rsp) \ M(MCS_SET_LMAC_MODE, 0xa013, mcs_set_lmac_mode, mcs_set_lmac_mode, msg_rsp) \M (MCS_SET_PN_THRESHOLD ,0xa014 , mcs_set_pn_threshold, mcs_set_pn_threshold, \ msg_rsp) \
@@ -351,11 +352,15 @@ M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, msg_rsp)#define MBOX_UP_CPT_MESSAGES \ M(CPT_INST_LMTST, 0xD00, cpt_inst_lmtst, cpt_inst_lmtst_req, msg_rsp) +#define MBOX_UP_MCS_MESSAGES \ +M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, mcs_intr_info, msg_rsp) +enum { #define M(_name, _id, _1, _2, _3) MBOX_MSG_ ## _name = _id, MBOX_MESSAGES MBOX_UP_CGX_MESSAGES MBOX_UP_CPT_MESSAGES +MBOX_UP_MCS_MESSAGES#undef M };
@@ -2084,4 +2089,37 @@ struct mcs_clear_stats { u8 all; /* All resources stats mapped to PF are cleared */ }; +struct mcs_intr_cfg { +struct mbox_msghdr hdr; +#define MCS_CPM_RX_SECTAG_V_EQ1_INT BIT_ULL(0) +#define MCS_CPM_RX_SECTAG_E_EQ0_C_EQ1_INT BIT_ULL(1) +#define MCS_CPM_RX_SECTAG_SL_GTE48_INT BIT_ULL(2) +#define MCS_CPM_RX_SECTAG_ES_EQ1_SC_EQ1_INT BIT_ULL(3) +#define MCS_CPM_RX_SECTAG_SC_EQ1_SCB_EQ1_INT BIT_ULL(4) +#define MCS_CPM_RX_PACKET_XPN_EQ0_INT BIT_ULL(5) +#define MCS_CPM_RX_PN_THRESH_REACHED_INT BIT_ULL(6) +#define MCS_CPM_TX_PACKET_XPN_EQ0_INT BIT_ULL(7) +#define MCS_CPM_TX_PN_THRESH_REACHED_INT BIT_ULL(8) +#define MCS_CPM_TX_SA_NOT_VALID_INT BIT_ULL(9) +#define MCS_BBE_RX_DFIFO_OVERFLOW_INT BIT_ULL(10) +#define MCS_BBE_RX_PLFIFO_OVERFLOW_INT BIT_ULL(11) +#define MCS_BBE_TX_DFIFO_OVERFLOW_INT BIT_ULL(12) +#define MCS_BBE_TX_PLFIFO_OVERFLOW_INT BIT_ULL(13) +#define MCS_PAB_RX_CHAN_OVERFLOW_INT BIT_ULL(14) +#define MCS_PAB_TX_CHAN_OVERFLOW_INT BIT_ULL(15) +u64 intr_mask;/* Interrupt enable mask */ +u8 mcs_id; +u8 lmac_id; +u64 rsvd; +}; + +struct mcs_intr_info { +struct mbox_msghdr hdr; +u64 intr_mask; +int sa_id; +u8 mcs_id; +u8 lmac_id; +u64 rsvd; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +337 -0
355 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs.h +74 -0
107 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_cnf10kb.c +77 -9
98 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_reg.h +168 -0
178 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +159 -0
184 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +3 -3
@@ -24,8 +24,6 @@#define DRV_NAME "rvu_af"#define DRV_STRING "Marvell OcteonTX2 RVU Admin Function Driver" -static int rvu_get_hwvf (struct rvu *rvu,int pcifunc); -static void rvu_set_msix_offset (struct rvu *rvu,struct rvu_pfvf *pfvf,struct rvu_block *block,int lf); static void rvu_clear_msix_offset(struct rvu *rvu, struct rvu_pfvf *pfvf,
@@ -419,7 +417,7 @@ void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf) *hwvf = cfg &0xFFF ; } -static int rvu_get_hwvf (struct rvu *rvu,int pcifunc) +int rvu_get_hwvf (struct rvu *rvu,int pcifunc) {int pf, func;u64 cfg;
@@ -3300,6 +3298,7 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_hwsetup:rvu_cgx_exit (rvu);rvu_fwdata_exit (rvu); +rvu_mcs_exit (rvu);rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);rvu_clear_rvum_blk_revid (rvu);
@@ -3326,6 +3325,7 @@ static void rvu_remove(struct pci_dev *pdev)rvu_flr_wq_destroy (rvu);rvu_cgx_exit (rvu);rvu_fwdata_exit (rvu); +rvu_mcs_exit (rvu);rvu_mbox_destroy (&rvu->afpf_wq_info);rvu_disable_sriov (rvu);rvu_reset_all_blocks (rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8 -0
@@ -508,6 +508,12 @@ struct rvu {/* RVU switch implementation over NPC with DMAC rules */ struct rvu_switch rswitch; + +struct work_struct mcs_intr_work; +struct workqueue_struct *mcs_intr_wq; +struct list_head mcs_intrq_head; +/* mcs interrupt queue lock */ +spinlock_t mcs_intrq_lock; };static inline void rvu_write64 (struct rvu *rvu,u64 block,u64 offset,u64 val)
@@ -872,9 +878,11 @@ void rvu_switch_update_rules(struct rvu *rvu, u16 pcifunc);int rvu_npc_set_parse_mode (struct rvu *rvu,u16 pcifunc,u64 mode,u8 dir,u64 pkind,u8 var_len_off,u8 var_len_off_mask,u8 shift_dir); +int rvu_get_hwvf (struct rvu *rvu,int pcifunc);/* CN10K MCS */ int rvu_mcs_init (struct rvu *rvu);int rvu_mcs_flr_handler (struct rvu *rvu,u16 pcifunc); +void rvu_mcs_exit (struct rvu *rvu);#endif /* RVU_H */
Signature · 1 line
2.7.4
Jakub Kicinski
maintainerRe: [net-next PATCH v2 6/8] octeontx2-af: cn10k: mcs: Handle MCS block interrupts
Quoted 10 lines · On Wed, 28 Sep 2022 09:28:08 +0530 Subbaraya Sundeep wrote:
From: Geetha sowjanya <[email protected]>
Hardware triggers an interrupt for events like PN wrap to zero, PN crosses set threshold. This interrupt is received by the
MCS_AF. MCS AF then finds the PF/VF to which SA is mapped and notifies them usingmcs_intr_notifymbox message.PF/VF using
mcs_intr_cfgmbox can configure the list of interrupts for which they want to receive the notification from AF.
clang is still upset at a couple of patches here, for instance:
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c:102:6: warning: variable 'err' is uninitialized when used here [-Wuninitialized]
if (err)
^~~
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c:87:9: note: initialize the variable 'err' to silence this warning
int err, pf;
^
= 0Subbaraya Sundeep
maintainerPATCH v2 7/8 octeontx2-af: cn10k: mcs: Add debugfs support
In reply to Subbaraya SundeepFrom: Geetha sowjanya <[email protected]>
This patch adds debugfs entry to dump MCS secy, sc, sa, flowid and port stats. This helps in debugging the packet path and to figure out where exactly packet was dropped.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 346 +++++++++++++++++++++ 2 files changed, 350 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -64,6 +64,10 @@ struct rvu_debugfs {struct dentry *nix;struct dentry *npc;struct dentry *cpt; +struct dentry *mcs_root; +struct dentry *mcs; +struct dentry *mcs_rx; +struct dentry *mcs_tx;struct dump_ctx npa_aura_ctx;struct dump_ctx npa_pool_ctx;struct dump_ctx nix_cq_ctx;
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +346 -0
364 lines not on this page · raw message
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH v2 8/8 octeontx2-pf: mcs: Introduce MACSEC hardware offloading
In reply to Subbaraya SundeepThis patch introduces the macsec offload feature to cn10k
PF netdev driver. The macsec offload ops like adding, deleting and updating SecYs, SCs, SAs and stats are supported. XPN support will be added in later patches. Some stats use same counter in hardware which means based on the SecY mode the same counter represents different stat. Hence when SecY mode/policy is changed then snapshot of current stats are captured. Also there is no provision to specify the unique flow-id/SCI per packet to hardware hence different mac address needs to be set for macsec interfaces.
--- .../net/ethernet/marvell/octeontx2/nic/Makefile | 1 + .../ethernet/marvell/octeontx2/nic/cn10k_macsec.c | 1668 ++++++++++++++++++++ .../ethernet/marvell/octeontx2/nic/otx2_common.c | 1 + .../ethernet/marvell/octeontx2/nic/otx2_common.h | 90 ++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 16 + 5 files changed, 1776 insertions(+) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -0
@@ -13,5 +13,6 @@ rvu_nicvf-y := otx2_vf.o otx2_devlink.o rvu_nicpf-$(CONFIG_DCB) += otx2_dcbnl.o rvu_nicvf-$(CONFIG_DCB) += otx2_dcbnl.o +rvu_nicpf-$(CONFIG_MACSEC) += cn10k_macsec.o ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c new file +1668 -0
1,668 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +1 -0
@@ -1827,4 +1827,5 @@ otx2_mbox_up_handler_ ## _fn_name(struct otx2_nic *pfvf, \ } \ EXPORT_SYMBOL(otx2_mbox_up_handler_ ## _fn_name);MBOX_UP_CGX_MESSAGES +MBOX_UP_MCS_MESSAGES#undef M
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +90 -0
142 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +16 -0
@@ -858,6 +858,15 @@ static void otx2_handle_link_event(struct otx2_nic *pf) } } +int otx2_mbox_up_handler_mcs_intr_notify (struct otx2_nic *pf, +struct mcs_intr_info *event, +struct msg_rsp *rsp) +{ +cn10k_handle_mcs_event (pf, event); + +return 0 ; +} +int otx2_mbox_up_handler_cgx_link_event (struct otx2_nic *pf,struct cgx_link_info_msg *msg,struct msg_rsp *rsp)
@@ -917,6 +926,7 @@ static int otx2_process_mbox_msg_up(struct otx2_nic *pf,return err; \ }MBOX_UP_CGX_MESSAGES +MBOX_UP_MCS_MESSAGES#undef Mbreak ;default :
@@ -2765,6 +2775,10 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_ptp_destroy; + err =cn10k_mcs_init (pf); +if (err) + goto err_del_mcam_entries; +if (pf->flags &OTX2_FLAG_NTUPLE_SUPPORT ) netdev->hw_features |=NETIF_F_NTUPLE ;
@@ -2979,6 +2993,8 @@ static void otx2_remove(struct pci_dev *pdev)otx2_config_pause_frm (pf); } +cn10k_mcs_free (pf); +#ifdef CONFIG_DCB /* Disable PFC config */ if (pf->pfc_en) {
Signature · 1 line
2.7.4