diff --git a/include/macsec.h b/include/macsec.h deleted file mode 100644 index 620e254..0000000 --- a/include/macsec.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef MACSEC_H -#define MACSEC_H - -#include - -/** - * @addtogroup MACsec AMAP - * - * @brief MACsec controller register offsets - * @{ - */ -#define GCM_KEYTABLE_CONFIG 0x0000 -#define GCM_KEYTABLE_DATA(x) (0x0004 + (x * 4)) -#define RX_ICV_ERR_CNTRL 0x4000 -#define INTERRUPT_COMMON_SR 0x4004 -#define TX_IMR 0x4008 -#define TX_ISR 0x400C -#ifdef NET24 -#define RX_IMR 0x4040 -#define RX_ISR 0x4044 -#else -#define RX_IMR 0x4048 -#define RX_ISR 0x404C -#endif /* NET24 */ -#ifdef NET30 -#define INTERRUPT_MASK1_0 0x40A0 -#define TX_SC_PN_EXHAUSTED_STATUS0_0 0x4024 -#define TX_SC_PN_EXHAUSTED_STATUS1_0 0x4028 -#define TX_SC_PN_THRESHOLD_STATUS0_0 0x4018 -#define TX_SC_PN_THRESHOLD_STATUS1_0 0x401C -#define TX_SC_ERROR_INTERRUPT_STATUS_0 0x402C -#define RX_SC_PN_EXHAUSTED_STATUS0_0 0x405C -#define RX_SC_PN_EXHAUSTED_STATUS1_0 0x4060 -#define RX_SC_REPLAY_ERROR_STATUS0_0 0x4090 -#define RX_SC_REPLAY_ERROR_STATUS1_0 0x4094 -#endif -#define STATS_CONFIG 0x9000 -#ifdef NET30 -#define STATS_CONTROL_0 0x900C -#define TX_PKTS_UNTG_LO_0 0x9010 -#define TX_PKTS_UNTG_HI_0 0x9014 -#define TX_OCTETS_PRTCTD_LO_0 0x9018 -#define TX_OCTETS_PRTCTD_HI_0 0x901C -#define TX_PKTS_TOO_LONG_LO_0 0x9020 -#define TX_PKTS_TOO_LONG_HI_0 0x9024 -#define TX_PKTS_PROTECTED_SCx_LO_0(x) (0x9028 + (x * 8)) -#define TX_PKTS_PROTECTED_SCx_HI_0(x) (0x902C + (x * 8)) -#define RX_PKTS_NOTG_LO_0 0x90B0 -#define RX_PKTS_NOTG_HI_0 0x90B4 -#define RX_PKTS_UNTG_LO_0 0x90A8 -#define RX_PKTS_UNTG_HI_0 0x90AC -#define RX_PKTS_BADTAG_LO_0 0x90B8 -#define RX_PKTS_BADTAG_HI_0 0x90BC -#define RX_PKTS_NOSA_LO_0 0x90C0 -#define RX_PKTS_NOSA_HI_0 0x90C4 -#define RX_PKTS_NOSAERROR_LO_0 0x90C8 -#define RX_PKTS_NOSAERROR_HI_0 0x90CC -#define RX_PKTS_OVRRUN_LO_0 0x90D0 -#define RX_PKTS_OVRRUN_HI_0 0x90D4 -#define RX_OCTETS_VLDTD_LO_0 0x90D8 -#define RX_OCTETS_VLDTD_HI_0 0x90DC -#define RX_PKTS_LATE_SCx_LO_0(x) (0x90E0 + (x * 8)) -#define RX_PKTS_LATE_SCx_HI_0(x) (0x90E4 + (x * 8)) -#define RX_PKTS_NOTVALID_SCx_LO_0(x) (0x9160 + (x * 8)) -#define RX_PKTS_NOTVALID_SCx_HI_0(x) (0x9164 + (x * 8)) -#define RX_PKTS_OK_SCx_LO_0(x) (0x91E0 + (x * 8)) -#define RX_PKTS_OK_SCx_HI_0(x) (0x91E4 + (x * 8)) - -#define TX_INPKTS_CRCIN_NOTVALID_LO_0 0x9260 -#define TX_INPKTS_CRCIN_NOTVALID_HI_0 0x9264 -#define RX_INPKTS_CRCIN_NOTVALID_LO_0 0x9268 -#define RX_INPKTS_CRCIN_NOTVALID_HI_0 0x926C - - -#endif -#define MACSEC_CONTROL0 0xD000 -#define MACSEC_LUT_CONFIG 0xD004 -#define MACSEC_LUT_DATA(x) (0xD008 + (x * 4)) -#ifndef NET24 -#define TX_BYP_LUT_VALID 0xD024 -#define TX_SCI_LUT_VALID 0xD028 -#define RX_BYP_LUT_VALID 0xD02C -#define RX_SCI_LUT_VALID 0xD030 -#endif /* NET24 */ -#ifdef NET24 -#define COMMON_IMR 0xD024 -#define COMMON_ISR 0xD028 -#else -#define COMMON_IMR 0xD054 -#define COMMON_ISR 0xD058 -#endif /* NET24 */ -#ifdef NET30 -#define TX_SC_KEY_INVALID_STS0_0 0XD064 -#define TX_SC_KEY_INVALID_STS1_0 0XD068 -#define RX_SC_KEY_INVALID_STS0_0 0XD080 -#define RX_SC_KEY_INVALID_STS1_0 0XD084 - -#define TX_DEBUG_CONTROL_0 0xD098 -#define TX_DEBUG_TRIGGER_EN_0 0xD09C -#define TX_DEBUG_STATUS_0 0xD0C4 -#define DEBUG_BUF_CONFIG_0 0xD0C8 -#define DEBUG_BUF_DATA_0(x) (0xD0CC + (x * 4)) -#define RX_DEBUG_CONTROL_0 0xD0DC -#define RX_DEBUG_TRIGGER_EN_0 0xD0E0 -#define RX_DEBUG_STATUS_0 0xD0F8 - -#endif /* NET30 */ -#define MACSEC_CONTROL1 0xE000 -#define GCM_AES_CNTRL 0xE004 -#define TX_MTU_LEN 0xE008 -#define TX_SOT_DELAY 0xE010 -#define RX_MTU_LEN 0xE014 -#define RX_SOT_DELAY 0xE01C -#ifdef NET30 -#define MACSEC_TX_DVLAN_CONTROL_0 0xE00C -#define MACSEC_RX_DVLAN_CONTROL_0 0xE018 -#endif -/** @} */ - -/** - * @addtogroup GCM_KEYTABLE_CONFIG register - * - * @brief Bit definitions of GCM_KEYTABLE_CONFIG register - * @{ - */ -#define KT_CONFIG_UPDATE OSI_BIT(31) -#define KT_CONFIG_CTLR_SEL OSI_BIT(25) -#define KT_CONFIG_RW OSI_BIT(24) -#define KT_CONFIG_INDEX_MASK (OSI_BIT(4) | OSI_BIT(3) | OSI_BIT(2) |\ - OSI_BIT(1) | OSI_BIT(0)) -#define KT_ENTRY_VALID OSI_BIT(0) -/** @} */ - -/** - * @addtogroup GCM_KEYTABLE_DATA registers - * - * @brief Bit definitions of GCM_KEYTABLE_DATA register & helpful macros - * @{ - */ -#define KT_ENTRY_VALID OSI_BIT(0) -#define MACSEC_KT_DATA_REG_CNT 13 -#define MACSEC_KT_DATA_REG_SAK_CNT 8 -#define MACSEC_KT_DATA_REG_H_CNT 4 -/** @} */ - -/** - * @addtogroup MACSEC_LUT_CONFIG register - * - * @brief Bit definitions of MACSEC_LUT_CONFIG register - * @{ - */ -#define LUT_CONFIG_UPDATE OSI_BIT(31) -#define LUT_CONFIG_CTLR_SEL OSI_BIT(25) -#define LUT_CONFIG_RW OSI_BIT(24) -#define LUT_CONFIG_LUT_SEL_MASK (OSI_BIT(18) | OSI_BIT(17) |\ - OSI_BIT(16)) -#define LUT_CONFIG_LUT_SEL_SHIFT 16 -#define LUT_CONFIG_INDEX_MASK (OSI_BIT(4) | OSI_BIT(3) | OSI_BIT(2) |\ - OSI_BIT(1) | OSI_BIT(0)) -/** @} */ -/** - * @addtogroup INTERRUPT_COMMON_STATUS register - * - * @brief Bit definitions of MACSEC_INTERRUPT_COMMON_STATUS register - * @{ - */ -#ifdef NET30 -#define COMMON_SR_SFTY_ERR OSI_BIT(2) -#endif -#define COMMON_SR_RX OSI_BIT(1) -#define COMMON_SR_TX OSI_BIT(0) -/** @} */ - -/** - * @addtogroup MACSEC_CONTROL0 register - * - * @brief Bit definitions of MACSEC_CONTROL0 register - * @{ - */ -#define TX_LKUP_MISS_NS_INTR OSI_BIT(24) -#define RX_LKUP_MISS_NS_INTR OSI_BIT(23) -#define VALIDATE_FRAMES_MASK (OSI_BIT(22) | OSI_BIT(21)) -#define VALIDATE_FRAMES_DIS 0x0 -#define VALIDATE_FRAMES_STRICT OSI_BIT(22) -#define VALIDATE_FRAMES_CHECK OSI_BIT(21) -#define RX_REPLAY_PROT_EN OSI_BIT(20) -#define RX_LKUP_MISS_BYPASS OSI_BIT(19) -#ifndef NET30 -#define RX_SCI_LUT_EN OSI_BIT(18) -#define RX_BYP_LUT_EN OSI_BIT(17) -#endif -#define RX_EN OSI_BIT(16) -#define TX_LKUP_MISS_BYPASS OSI_BIT(3) -#ifndef NET30 -#define TX_SCI_LUT_EN OSI_BIT(2) -#define TX_BYP_LUT_EN OSI_BIT(1) -#endif -#define TX_EN OSI_BIT(0) -/** @} */ - -/** - * @addtogroup MACSEC_CONTROL1 register - * - * @brief Bit definitions of MACSEC_CONTROL1 register - * @{ - */ -#define LOOPBACK_MODE_EN OSI_BIT(31) -#define RX_MTU_CHECK_EN OSI_BIT(16) -#define TX_LUT_PRIO_BYP OSI_BIT(2) -#define TX_MTU_CHECK_EN OSI_BIT(0) -/** @} */ - -/** - * @addtogroup GCM_AES_CNTRL register - * - * @brief Bit definitions of GCM_AES_CNTRL register - * @{ - */ -#define RX_AES_MODE_MASK (OSI_BIT(17) | OSI_BIT(16)) -#define RX_AES_MODE_AES128 0x0 -#define RX_AES_MODE_AES256 OSI_BIT(17) -#define TX_AES_MODE_MASK (OSI_BIT(1) | OSI_BIT(0)) -#define TX_AES_MODE_AES128 0x0 -#define TX_AES_MODE_AES256 OSI_BIT(1) -/** @} */ - -/** - * @addtogroup COMMON_IMR register - * - * @brief Bit definitions of MACSEC_INTERRUPT_MASK register - * @{ - */ -#define SECURE_REG_VIOL_INT_EN OSI_BIT(31) -#define RX_UNINIT_KEY_SLOT_INT_EN OSI_BIT(17) -#define RX_LKUP_MISS_INT_EN OSI_BIT(16) -#define TX_UNINIT_KEY_SLOT_INT_EN OSI_BIT(1) -#define TX_LKUP_MISS_INT_EN OSI_BIT(0) -/** @} */ - -/** - * @addtogroup TX_IMR register - * - * @brief Bit definitions of TX_INTERRUPT_MASK register - * @{ - */ -#ifdef NET30 -#define TX_DBG_BUF_CAPTURE_DONE_INT_EN OSI_BIT(22) -#else -#define TX_SFTY_ERR_CORR_INT_EN OSI_BIT(26) -#define TX_SFTY_ERR_UNCORR_INT_EN OSI_BIT(25) -#define TX_DBG_BUF_CAPTURE_DONE_INT_EN OSI_BIT(2) -#endif -#define TX_MTU_CHECK_FAIL_INT_EN OSI_BIT(19) -#define TX_AES_GCM_BUF_OVF_INT_EN OSI_BIT(18) -#define TX_SC_AN_NOT_VALID_INT_EN OSI_BIT(17) -#define TX_MAC_CRC_ERROR_INT_EN OSI_BIT(16) -#define TX_PN_EXHAUSTED_INT_EN OSI_BIT(1) -#define TX_PN_THRSHLD_RCHD_INT_EN OSI_BIT(0) -/** @} */ - -/** - * @addtogroup RX_IMR register - * - * @brief Bit definitions of RX_INTERRUPT_MASK register - * @{ - */ -#ifdef NET30 -#define RX_DBG_BUF_CAPTURE_DONE_INT_EN OSI_BIT(22) -#else -#define RX_SFTY_ERR_CORR_INT_EN OSI_BIT(26) -#define RX_SFTY_ERR_UNCORR_INT_EN OSI_BIT(25) -#define RX_SC_AN_NOT_VALID_INT_EN OSI_BIT(17) -#define RX_DBG_BUF_CAPTURE_DONE_INT_EN OSI_BIT(2) -#endif -#define RX_ICV_ERROR_INT_EN OSI_BIT(21) -#define RX_REPLAY_ERROR_INT_EN OSI_BIT(20) -#define RX_MTU_CHECK_FAIL_INT_EN OSI_BIT(19) -#define RX_AES_GCM_BUF_OVF_INT_EN OSI_BIT(18) -#define RX_MAC_CRC_ERROR_INT_EN OSI_BIT(16) -#define RX_PN_EXHAUSTED_INT_EN OSI_BIT(1) -#ifdef NET24 -#define RX_PN_THRSHLD_RCHD_INT_EN OSI_BIT(0) -#endif /* NET24 */ -/** @} */ - -/** - * @addtogroup INTERRUPT_MASK1_0 register - * - * @brief Bit definitions of INTERRUPT_MASK1_0 register - * @{ - */ -#define SFTY_ERR_UNCORR_INT_EN OSI_BIT(0) -/** @} */ - -/** - * @addtogroup COMMON_ISR register - * - * @brief Bit definitions of MACSEC_INTERRUPT_STATUS register - * @{ - */ -#define SECURE_REG_VIOL OSI_BIT(31) -#define RX_UNINIT_KEY_SLOT OSI_BIT(17) -#define RX_LKUP_MISS OSI_BIT(16) -#define TX_UNINIT_KEY_SLOT OSI_BIT(1) -#define TX_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup TX_ISR register - * - * @brief Bit definitions of TX_INTERRUPT_STATUS register - * @{ - */ -#ifdef NET30 -#define TX_DBG_BUF_CAPTURE_DONE OSI_BIT(22) -#else -#define TX_SFTY_ERR_CORR OSI_BIT(26) -#define TX_SFTY_ERR_UNCORR OSI_BIT(25) -#define TX_DBG_BUF_CAPTURE_DONE OSI_BIT(2) -#endif -#define TX_MTU_CHECK_FAIL OSI_BIT(19) -#define TX_AES_GCM_BUF_OVF OSI_BIT(18) -#define TX_SC_AN_NOT_VALID OSI_BIT(17) -#define TX_MAC_CRC_ERROR OSI_BIT(16) -#define TX_PN_EXHAUSTED OSI_BIT(1) -#define TX_PN_THRSHLD_RCHD OSI_BIT(0) -/** @} */ - -/** - * @addtogroup RX_ISR register - * - * @brief Bit definitions of RX_INTERRUPT_STATUS register - * @{ - */ -#ifdef NET30 -#define RX_DBG_BUF_CAPTURE_DONE OSI_BIT(22) -#else -#define RX_SFTY_ERR_CORR OSI_BIT(26) -#define RX_SFTY_ERR_UNCORR OSI_BIT(25) -#define RX_SC_AN_NOT_VALID OSI_BIT(17) -#define RX_DBG_BUF_CAPTURE_DONE OSI_BIT(2) -#endif -#define RX_ICV_ERROR OSI_BIT(21) -#define RX_REPLAY_ERROR OSI_BIT(20) -#define RX_MTU_CHECK_FAIL OSI_BIT(19) -#define RX_AES_GCM_BUF_OVF OSI_BIT(18) -#define RX_MAC_CRC_ERROR OSI_BIT(16) -#define RX_PN_EXHAUSTED OSI_BIT(1) -#ifdef NET24 -#define RX_PN_THRSHLD_RCHD OSI_BIT(0) -#endif /* NET24 */ -/** @} */ - -/** - * @addtogroup STATS_CONTROL_0 register - * - * @brief Bit definitions of STATS_CONTROL_0 register - * @{ - */ -#ifdef NET30 -#define STATS_CONTROL0_RD_CPY OSI_BIT(3) -#define STATS_CONTROL0_TK_CPY OSI_BIT(2) -#define STATS_CONTROL0_CNT_RL_OVR_CPY OSI_BIT(1) -#define STATS_CONTROL0_CNT_CLR OSI_BIT(0) -#endif /* NET30 */ -/** @} */ - -/** - * @addtogroup DEBUG_BUF_CONFIG_0 register - * - * @brief Bit definitions of DEBUG_BUF_CONFIG_0 register - * @{ - */ -#define DEBUG_BUF_CONFIG_0_UPDATE OSI_BIT(31) -#define DEBUG_BUF_CONFIG_0_CTLR_SEL OSI_BIT(25) -#define DEBUG_BUF_CONFIG_0_RW OSI_BIT(24) -#define DEBUG_BUF_CONFIG_0_IDX_MASK (OSI_BIT(0) | OSI_BIT(1) | \ - OSI_BIT(2) | OSI_BIT(3)) -/** @} */ - -/** - * @addtogroup TX_DEBUG_TRIGGER_EN_0 register - * - * @brief Bit definitions of TX_DEBUG_TRIGGER_EN_0 register - * @{ - */ -#define TX_DBG_CAPTURE OSI_BIT(10) -#define TX_DBG_ICV_CORRUPT OSI_BIT(9) -#define TX_DBG_CRC_CORRUPT OSI_BIT(8) -#define TX_DBG_DATA_MATCH OSI_BIT(7) -#define TX_DBG_LKUP_MATCH OSI_BIT(6) -#define TX_DBG_CRCOUT_MATCH OSI_BIT(5) -#define TX_DBG_CRCIN_MATCH OSI_BIT(4) -#define TX_DBG_ICV_MATCH OSI_BIT(3) -#define TX_DBG_KEY_NOT_VALID OSI_BIT(2) -#define TX_DBG_AN_NOT_VALID OSI_BIT(1) -#define TX_DBG_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup TX_DEBUG_STATUS_0 register - * - * @brief Bit definitions of TX_DEBUG_STATUS_0 register - * @{ - */ -#define TX_DBG_STS_CAPTURE OSI_BIT(10) -#define TX_DBG_STS_ICV_CORRUPT OSI_BIT(9) -#define TX_DBG_STS_CRC_CORRUPT OSI_BIT(8) -#define TX_DBG_STS_DATA_MATCH OSI_BIT(7) -#define TX_DBG_STS_LKUP_MATCH OSI_BIT(6) -#define TX_DBG_STS_CRCOUT_MATCH OSI_BIT(5) -#define TX_DBG_STS_CRCIN_MATCH OSI_BIT(4) -#define TX_DBG_STS_ICV_MATCH OSI_BIT(3) -#define TX_DBG_STS_KEY_NOT_VALID OSI_BIT(2) -#define TX_DBG_STS_AN_NOT_VALID OSI_BIT(1) -#define TX_DBG_STS_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup RX_DEBUG_TRIGGER_EN_0 register - * - * @brief Bit definitions of RX_DEBUG_TRIGGER_EN_0 register - * @{ - */ -#define RX_DBG_CAPTURE OSI_BIT(10) -#define RX_DBG_ICV_ERROR OSI_BIT(9) -#define RX_DBG_CRC_CORRUPT OSI_BIT(8) -#define RX_DBG_DATA_MATCH OSI_BIT(7) -#define RX_DBG_BYP_LKUP_MATCH OSI_BIT(6) -#define RX_DBG_CRCOUT_MATCH OSI_BIT(5) -#define RX_DBG_CRCIN_MATCH OSI_BIT(4) -#define RX_DBG_REPLAY_ERR OSI_BIT(3) -#define RX_DBG_KEY_NOT_VALID OSI_BIT(2) -#define RX_DBG_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup RX_DEBUG_STATUS_0 register - * - * @brief Bit definitions of RX_DEBUG_STATUS_0 register - * @{ - */ -#define RX_DBG_STS_CAPTURE OSI_BIT(10) -#define RX_DBG_STS_ICV_ERROR OSI_BIT(9) -#define RX_DBG_STS_CRC_CORRUPT OSI_BIT(8) -#define RX_DBG_STS_DATA_MATCH OSI_BIT(7) -#define RX_DBG_STS_BYP_LKUP_MATCH OSI_BIT(6) -#define RX_DBG_STS_CRCOUT_MATCH OSI_BIT(5) -#define RX_DBG_STS_CRCIN_MATCH OSI_BIT(4) -#define RX_DBG_STS_REPLAY_ERR OSI_BIT(3) -#define RX_DBG_STS_KEY_NOT_VALID OSI_BIT(2) -#define RX_DBG_STS_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup TX_DEBUG_STATUS_0 register - * - * @brief Bit definitions of TX_DEBUG_STATUS_0 register - * @{ - */ -#define TX_DBG_STS_CAPTURE OSI_BIT(10) -#define TX_DBG_STS_ICV_CORRUPT OSI_BIT(9) -#define TX_DBG_STS_CRC_CORRUPT OSI_BIT(8) -#define TX_DBG_STS_DATA_MATCH OSI_BIT(7) -#define TX_DBG_STS_LKUP_MATCH OSI_BIT(6) -#define TX_DBG_STS_CRCOUT_MATCH OSI_BIT(5) -#define TX_DBG_STS_CRCIN_MATCH OSI_BIT(4) -#define TX_DBG_STS_ICV_MATCH OSI_BIT(3) -#define TX_DBG_STS_KEY_NOT_VALID OSI_BIT(2) -#define TX_DBG_STS_AN_NOT_VALID OSI_BIT(1) -#define TX_DBG_STS_LKUP_MISS OSI_BIT(0) -/** @} */ - -/** - * @addtogroup TX_DEBUG_CONTROL_0 register - * - * @brief Bit definitions of TX_DEBUG_CONTROL_0 register - * @{ - */ -#define TX_DEBUG_CONTROL_0_START_CAP OSI_BIT(31) -/** @} */ - -/** - * @addtogroup RX_DEBUG_CONTROL_0 register - * - * @brief Bit definitions of RX_DEBUG_CONTROL_0 register - * @{ - */ -#define RX_DEBUG_CONTROL_0_START_CAP OSI_BIT(31) -/** @} */ - -#define MTU_LENGTH_MASK 0xFFFF -/* MACsec sectag + ICV + 2B ethertype adds upto 34B */ -#define MACSEC_TAG_ICV_LEN 34 -/* Add 8B for double VLAN tags (4B each), - * 14B for L2 SA/DA/ethertype, TODO - as per IAS SA/DA is ignored from length - * 4B for FCS - */ -#define MTU_ADDONS (8 + 14 + 4) -#define DVLAN_TAG_ETHERTYPE 0x88A8 -#ifndef NET24 -/** - * @addtogroup TX/RX_BYP/SCI_LUT_VALID register - * - * @brief Bit definitions of LUT_VALID registers - * @{ - */ -#define TX_BYP_LUT_VALID_ENTRY(x) OSI_BIT(x) -#define TX_BYP_LUT_VALID_NONE 0x0 -#define TX_SCI_LUT_VALID_ENTRY(x) OSI_BIT(x) -#define TX_SCI_LUT_VALID_NONE 0x0 -#define RX_BYP_LUT_VALID_ENTRY(x) OSI_BIT(x) -#define RX_BYP_LUT_VALID_NONE 0x0 -#define RX_SCI_LUT_VALID_ENTRY(x) OSI_BIT(x) -#define RX_SCI_LUT_VALID_NONE 0x0 -/** @} */ -#endif /* NET24 */ - -/** - * @addtogroup TX/RX LUT bit fields in LUT_DATA registers - * - * @brief Helper macros for LUT data programming - * @{ - */ -#define MACSEC_LUT_DATA_REG_CNT 7 -/* Bit Offsets for LUT DATA[x] registers for various lookup field masks */ -/* DA mask bits in LUT_DATA[1] register */ -#define LUT_DA_BYTE0_INACTIVE OSI_BIT(16) -#define LUT_DA_BYTE1_INACTIVE OSI_BIT(17) -#define LUT_DA_BYTE2_INACTIVE OSI_BIT(18) -#define LUT_DA_BYTE3_INACTIVE OSI_BIT(19) -#define LUT_DA_BYTE4_INACTIVE OSI_BIT(20) -#define LUT_DA_BYTE5_INACTIVE OSI_BIT(21) -/* SA mask bits in LUT_DATA[3] register */ -#define LUT_SA_BYTE0_INACTIVE OSI_BIT(6) -#define LUT_SA_BYTE1_INACTIVE OSI_BIT(7) -#define LUT_SA_BYTE2_INACTIVE OSI_BIT(8) -#define LUT_SA_BYTE3_INACTIVE OSI_BIT(9) -#define LUT_SA_BYTE4_INACTIVE OSI_BIT(10) -#define LUT_SA_BYTE5_INACTIVE OSI_BIT(11) -/* Ether type mask in LUT_DATA[3] register */ -#define LUT_ETHTYPE_INACTIVE OSI_BIT(28) -/* VLAN PCP mask in LUT_DATA[4] register */ -#define LUT_VLAN_PCP_INACTIVE OSI_BIT(0) -/* VLAN ID mask in LUT_DATA[4] register */ -#define LUT_VLAN_ID_INACTIVE OSI_BIT(13) -/* VLAN mask in LUT_DATA[4] register */ -#define LUT_VLAN_ACTIVE OSI_BIT(14) -/* Byte pattern masks in LUT_DATA[4] register */ -#define LUT_BYTE0_PATTERN_INACTIVE OSI_BIT(29) -/* Byte pattern masks in LUT_DATA[5] register */ -#define LUT_BYTE1_PATTERN_INACTIVE OSI_BIT(12) -#define LUT_BYTE2_PATTERN_INACTIVE OSI_BIT(27) -/* Byte pattern masks in LUT_DATA[6] register */ -#define LUT_BYTE3_PATTERN_INACTIVE OSI_BIT(10) -/* Preemptible packet in LUT_DATA[6] register */ -#define LUT_PREEMPT OSI_BIT(11) -/* Preempt mask in LUT_DATA[6] register */ -#define LUT_PREEMPT_INACTIVE OSI_BIT(12) -/* Controlled port mask in LUT_DATA[6] register */ -#define LUT_CONTROLLED_PORT OSI_BIT(13) -#ifdef NET30 -/* DVLAN packet in LUT_DATA[6] register */ -#define BYP_LUT_DVLAN_PKT OSI_BIT(14) -/* DVLAN outer/inner tag select in LUT_DATA[6] register */ -#define BYP_LUT_DVLAN_OUTER_INNER_TAG_SEL OSI_BIT(15) -#else -/* BYP LUT entry valid in LUT_DATA[6] register */ -#define BYP_LUT_ENTRY_VALID OSI_BIT(14) -#endif /* NET30 */ -/* AN valid bits for SCI LUT in LUT_DATA[6] register */ -#define LUT_AN0_VALID OSI_BIT(13) -#define LUT_AN1_VALID OSI_BIT(14) -#define LUT_AN2_VALID OSI_BIT(15) -#define LUT_AN3_VALID OSI_BIT(16) -#ifdef NET30 -/* DVLAN packet in LUT_DATA[6] register */ -#define TX_SCI_LUT_DVLAN_PKT OSI_BIT(21) -/* DVLAN outer/inner tag select in LUT_DATA[6] register */ -#define TX_SCI_LUT_DVLAN_OUTER_INNER_TAG_SEL OSI_BIT(22) -#else -/* SCI LUT entry valid in LUT_DATA[6] register */ -#define TX_SCI_LUT_ENTRY_VALID OSI_BIT(21) -#endif /* NET30 */ -/* SA State LUT entry valid in LUT_DATA[0] register */ -#define SA_STATE_LUT_ENTRY_VALID OSI_BIT(0) - -/* Rx LUT macros */ -/* Preemptible packet in LUT_DATA[2] register for Rx SCI */ -#define RX_SCI_LUT_PREEMPT OSI_BIT(8) -/* Preempt mask in LUT_DATA[2] register for Rx SCI */ -#define RX_SCI_LUT_PREEMPT_INACTIVE OSI_BIT(9) -#ifndef NET30 -/* Rx SCI LUT entry valid in LUT_DATA[2] register */ -#define RX_SCI_LUT_ENTRY_VALID OSI_BIT(14) -#endif /* NET30 */ -/* TODO - Invalidate the valid bits for above LUT_ENTRY_VALIDs in write path */ -/** @} */ - -////////////////////////////////////////////////////////////////////////// - /* MACsec OSI data structures */ -////////////////////////////////////////////////////////////////////////// - -/** - * @addtogroup TX/RX BYP/SCI LUT INPUT macros - * - * @brief Helper macros for LUT input programming - * @{ - */ -//TODO - Aggregate all the macros inlined in the struct itself -/** @} */ - -/** - * @brief MACsec secure channel basic information - */ -struct osi_macsec_sc_info { - /** Secure channel identifier */ -#define SCI_LEN 8 - unsigned char sci[SCI_LEN]; - /** Secure association key */ -#define KEY_LEN_128 16 -#define KEY_LEN_256 32 - unsigned char sak[KEY_LEN_128]; - /** current AN */ - unsigned char curr_an; - /** Next PN to use for the current AN */ - unsigned int next_pn; - /** == BELOW FIELDS ARE FILLED BY OSI LAYER == */ - /** bitmap of valid AN */ -#define AN0_VALID OSI_BIT(0) -#define AN1_VALID OSI_BIT(1) -#define AN2_VALID OSI_BIT(2) -#define AN3_VALID OSI_BIT(3) - unsigned int an_valid; - /** SC LUT index */ - unsigned int sc_idx_start; -}; - -/** - * @brief MACsec HW controller LUT's overall status - */ -struct osi_macsec_lut_status { - /** List of max SC's supported */ -#define MAX_NUM_SC 8 -#define MAX_NUM_SA 4 - struct osi_macsec_sc_info sc_info[MAX_NUM_SC]; - /** next available BYP LUT index */ - unsigned int next_byp_idx; - /** next available SC LUT index */ - unsigned int next_sc_idx; -}; - -/** - * @brief MACsec SA State LUT entry outputs structure - */ -struct sa_state_outputs { - /** Next PN to use */ - unsigned int next_pn; - /** Lowest PN to use */ - unsigned int lowest_pn; -}; - -/** - * @brief MACsec SC State LUT entry outputs structure - */ -struct sc_state_outputs { - /** Current AN to use */ -#define CURR_AN_MAX 3 /* 0-3 */ - unsigned int curr_an; -}; - -/** - * @brief MACsec SC Param LUT entry outputs structure - */ -struct sc_param_outputs { - /** Key index start */ -#define KEY_INDEX_MAX 31 /* 0-31 */ - unsigned int key_index_start; - /** PN max for given AN, after which HW will roll over to next AN */ -#define PN_MAX_DEFAULT 0xFFFFFFFF - unsigned int pn_max; - /** PN threshold to trigger irq when threshold is reached */ -#define PN_THRESHOLD_DEFAULT 0xC0000000 - unsigned int pn_threshold; - /** PN window */ - unsigned int pn_window; - /** SC identifier */ - unsigned char sci[SCI_LEN]; - /** Default TCI value V=1, ES=0, SC = 1 */ -#define TCI_DEFAULT 0x1 - /** TCI 3 bits V=0, ES=0, SC=1 */ - unsigned char tci; -#define VLAN_IN_CLEAR_DEFAULT 0x0 - /** vlan in clear config */ - unsigned char vlan_in_clear; -}; - -/** - * @brief MACsec SCI LUT entry outputs structure - */ -struct sci_lut_outputs { - /** SC index to use */ -#define SC_INDEX_MAX 15 /* 0-15 */ - unsigned int sc_index; - /** SC identifier */ - unsigned char sci[SCI_LEN]; - /** AN's valid */ - unsigned int an_valid; -}; - -/** - * @brief MACsec BYP/SCI LUT entry inputs structure - */ -struct lut_inputs { - /** MAC DA to compare */ - unsigned char da[OSI_ETH_ALEN]; - /** MAC SA to compare */ - unsigned char sa[OSI_ETH_ALEN]; - /** Ethertype to compare */ -#define ETHTYPE_LEN 2 - unsigned char ethtype[ETHTYPE_LEN]; - /** 4-Byte pattern to compare */ -#define LUT_BYTE_PATTERN_MAX 4 - unsigned char byte_pattern[LUT_BYTE_PATTERN_MAX]; - /** Offset for 4-Byte pattern to compare */ -#define LUT_BYTE_PATTERN_MAX_OFFSET 63 /* 0-63 */ - unsigned int byte_pattern_offset[LUT_BYTE_PATTERN_MAX]; - /** VLAN PCP to compare */ -#define VLAN_PCP_MAX 7 /* 0-7 */ - unsigned int vlan_pcp; - /** VLAN ID to compare */ -#define VLAN_ID_MAX 4095 /* 1-4095 */ - unsigned int vlan_id; -}; - -/** - * @brief MACsec LUT config data structure - */ -struct macsec_table_config { - /** Controller select - * 0 - Tx - * 1 - Rx - */ -#define CTLR_SEL_TX 0U -#define CTLR_SEL_RX 1U -#define CTLR_SEL_MAX 1U -#define NUM_CTLR 2U - unsigned short ctlr_sel; - /** Read or write operation select - * 0 - Read - * 1 - Write - */ -#define LUT_READ 0U -#define LUT_WRITE 1U -#define RW_MAX 1U - unsigned short rw; - /** Table entry index */ -#define TABLE_INDEX_MAX 31U /* 0-31 */ -#define BYP_LUT_MAX_INDEX TABLE_INDEX_MAX -#define SC_LUT_MAX_INDEX 15U -#define SA_LUT_MAX_INDEX TABLE_INDEX_MAX - unsigned short index; -}; - -/** - * @brief MACsec LUT config data structure - */ -struct osi_macsec_lut_config { - /** Generic table config */ - struct macsec_table_config table_config; - /** LUT select */ -#define LUT_SEL_BYPASS 0U -#define LUT_SEL_SCI 1U -#define LUT_SEL_SC_PARAM 2U -#define LUT_SEL_SC_STATE 3U -#define LUT_SEL_SA_STATE 4U -#define LUT_SEL_MAX 4U /* 0-4 */ - unsigned short lut_sel; - /** flag - encoding various valid bits for above fields */ - unsigned int flags; -//LUT input fields flags bit offsets -#define LUT_FLAGS_DA_BYTE0_VALID OSI_BIT(0) -#define LUT_FLAGS_DA_BYTE1_VALID OSI_BIT(1) -#define LUT_FLAGS_DA_BYTE2_VALID OSI_BIT(2) -#define LUT_FLAGS_DA_BYTE3_VALID OSI_BIT(3) -#define LUT_FLAGS_DA_BYTE4_VALID OSI_BIT(4) -#define LUT_FLAGS_DA_BYTE5_VALID OSI_BIT(5) -#define LUT_FLAGS_DA_VALID (OSI_BIT(0) | OSI_BIT(1) | OSI_BIT(2) |\ - OSI_BIT(3) | OSI_BIT(4) | OSI_BIT(5)) -#define LUT_FLAGS_SA_BYTE0_VALID OSI_BIT(6) -#define LUT_FLAGS_SA_BYTE1_VALID OSI_BIT(7) -#define LUT_FLAGS_SA_BYTE2_VALID OSI_BIT(8) -#define LUT_FLAGS_SA_BYTE3_VALID OSI_BIT(9) -#define LUT_FLAGS_SA_BYTE4_VALID OSI_BIT(10) -#define LUT_FLAGS_SA_BYTE5_VALID OSI_BIT(11) -#define LUT_FLAGS_SA_VALID (OSI_BIT(6) | OSI_BIT(7) | OSI_BIT(8) |\ - OSI_BIT(9) | OSI_BIT(10) | OSI_BIT(11)) -#define LUT_FLAGS_ETHTYPE_VALID OSI_BIT(12) -#define LUT_FLAGS_VLAN_PCP_VALID OSI_BIT(13) -#define LUT_FLAGS_VLAN_ID_VALID OSI_BIT(14) -#define LUT_FLAGS_VLAN_VALID OSI_BIT(15) -#define LUT_FLAGS_BYTE0_PATTERN_VALID OSI_BIT(16) -#define LUT_FLAGS_BYTE1_PATTERN_VALID OSI_BIT(17) -#define LUT_FLAGS_BYTE2_PATTERN_VALID OSI_BIT(18) -#define LUT_FLAGS_BYTE3_PATTERN_VALID OSI_BIT(19) -#define LUT_FLAGS_PREEMPT OSI_BIT(20) -#define LUT_FLAGS_PREEMPT_VALID OSI_BIT(21) -#define LUT_FLAGS_CONTROLLED_PORT OSI_BIT(22) -#define LUT_FLAGS_DVLAN_PKT OSI_BIT(23) -#define LUT_FLAGS_DVLAN_OUTER_INNER_TAG_SEL OSI_BIT(24) -#define LUT_FLAGS_ENTRY_VALID OSI_BIT(31) - /** LUT inputs */ - struct lut_inputs lut_in; - /** SCI LUT outputs */ - struct sci_lut_outputs sci_lut_out; - /** SC Param outputs */ - struct sc_param_outputs sc_param_out; - /** SC State outputs */ - struct sc_state_outputs sc_state_out; - /** SA State outputs */ - struct sa_state_outputs sa_state_out; -}; - -/** - * @brief MACsec KT entry structure - */ -struct kt_entry { - /** SAK key - max 256bit */ - unsigned char sak[KEY_LEN_256]; - /** H-key */ - unsigned char h[KEY_LEN_128]; -}; - -/** - * @brief MACsec KT config data structure - */ -struct osi_macsec_kt_config { - /** Generic table config */ - struct macsec_table_config table_config; - /** KT entry */ - struct kt_entry entry; - /** flag - encoding various valid bits */ - unsigned int flags; -}; - -/** - * @brief MACsec Debug buffer data structure - */ -struct osi_macsec_dbg_buf_config { - /** Controller select - * 0 - Tx - * 1 - Rx - */ - unsigned short ctlr_sel; - /** Read or write operation select - * 0 - Read - * 1 - Write - */ -#define DBG_TBL_READ LUT_READ -#define DBG_TBL_WRITE LUT_WRITE - unsigned short rw; - /* Num of Tx debug buffers */ -#define TX_DBG_BUF_IDX_MAX 12U - /* Num of Rx debug buffers */ -#define RX_DBG_BUF_IDX_MAX 13U -#define DBG_BUF_IDX_MAX RX_DBG_BUF_IDX_MAX - /** debug data buffer */ - unsigned int dbg_buf[4]; - /** flag - encoding various debug event bits */ -#define TX_DBG_LKUP_MISS_EVT OSI_BIT(0) -#define TX_DBG_AN_NOT_VALID_EVT OSI_BIT(1) -#define TX_DBG_KEY_NOT_VALID_EVT OSI_BIT(2) -#define TX_DBG_CRC_CORRUPT_EVT OSI_BIT(3) -#define TX_DBG_ICV_CORRUPT_EVT OSI_BIT(4) -#define TX_DBG_CAPTURE_EVT OSI_BIT(5) -#define RX_DBG_LKUP_MISS_EVT OSI_BIT(6) -#define RX_DBG_KEY_NOT_VALID_EVT OSI_BIT(7) -#define RX_DBG_REPLAY_ERR_EVT OSI_BIT(8) -#define RX_DBG_CRC_CORRUPT_EVT OSI_BIT(9) -#define RX_DBG_ICV_ERROR_EVT OSI_BIT(10) -#define RX_DBG_CAPTURE_EVT OSI_BIT(11) - unsigned int flags; - /** debug buffer index */ - unsigned int index; -}; - -/** - * @brief MACsec core operations structure - */ -struct macsec_core_ops { - /** macsec init */ - int (*init)(struct osi_core_priv_data *const osi_core); - /** macsec de-init */ - void (*deinit)(struct osi_core_priv_data *const osi_core); - /** NS irq handler */ - void (*handle_ns_irq)(struct osi_core_priv_data *const osi_core); - /** S irq handler */ - void (*handle_s_irq)(struct osi_core_priv_data *const osi_core); - /** macsec lut config */ - int (*lut_config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_lut_config *const lut_config); - /** macsec kt config */ - int (*kt_config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config); - /** macsec loopback config */ - int (*loopback_config)(struct osi_core_priv_data *const osi_core, - unsigned int enable); - /** macsec enable */ - int (*macsec_en)(struct osi_core_priv_data *const osi_core, - unsigned int enable); - /** macsec config SA in HW LUT */ - int (*config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr); - /** macsec read mmc counters */ - void (*read_mmc)(struct osi_core_priv_data *const osi_core); - /** macsec debug buffer config */ - int (*dbg_buf_config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_dbg_buf_config *const dbg_buf_config); - /** macsec debug buffer config */ - int (*dbg_events_config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_dbg_buf_config *const dbg_buf_config); - -}; - -////////////////////////////////////////////////////////////////////////// - /* OSI interface API prototypes */ -////////////////////////////////////////////////////////////////////////// - -/** - * @brief initializing the macsec core operations - * - * @param[in] osi_core: OSI core private data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_init_macsec_ops(struct osi_core_priv_data *const osi_core); - -/** - * @brief initialize the macsec controller - * - * @param[in] osi_core: OSI core private data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_init(struct osi_core_priv_data *const osi_core); - -/** - * @brief De-initialize the macsec controller - * - * @param[in] osi_core: OSI core private data structure. - * - */ -void osi_macsec_deinit(struct osi_core_priv_data *const osi_core); - -/** - * @brief Non-secure irq handler - * - * @param[in] osi_core: OSI core private data structure. - * - * @retval None - */ -void osi_macsec_ns_isr(struct osi_core_priv_data *const osi_core); - -/** - * @brief Secure irq handler - * - * @param[in] osi_core: OSI core private data structure. - * - * @retval None - */ -void osi_macsec_s_isr(struct osi_core_priv_data *const osi_core); - -/** - * @brief MACsec Lookup table config - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] lut_config: OSI macsec LUT config data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_lut_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_lut_config *const lut_confg); - -/** - * @brief MACsec key table config - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] kt_config: OSI macsec KT config data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_kt_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config); - -/** - * @brief MACsec Loopback config - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] enable: Loopback enable/disable flag. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_loopback(struct osi_core_priv_data *const osi_core, - unsigned int enable); - -/** - * @brief MACsec Enable - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] enable: macsec controller Tx/Rx enable/disable flag. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_en(struct osi_core_priv_data *const osi_core, - unsigned int enable); - -/** - * @brief MACsec update secure channel/association in controller - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] tx_sa: Pointer to osi_macsec_sc_info struct for the tx SA. - * @param[in] enable: flag to indicate enable/disable for the Tx SA. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr); - -/** - * @brief MACsec read statistics counters - * - * @param[in] osi_core: OSI core private data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_read_mmc(struct osi_core_priv_data *const osi_core); - -/** - * @brief MACsec debug buffer config - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] dbg_buf_config: OSI macsec debug buffer config data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_dbg_buf_config( - struct osi_core_priv_data *const osi_core, - struct osi_macsec_dbg_buf_config *const dbg_buf_config); - -/** - * @brief MACsec debug events config - * - * @param[in] osi_core: OSI core private data structure. - * @param[in] dbg_buf_config: OSI macsec debug buffer config data structure. - * - * @retval 0 on success - * @retval -1 on failure - */ -int osi_macsec_dbg_events_config( - struct osi_core_priv_data *const osi_core, - struct osi_macsec_dbg_buf_config *const dbg_buf_config); - -#endif /* MACSEC_H */ diff --git a/include/mmc.h b/include/mmc.h index 672b1ea..438f8bf 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -580,6 +580,7 @@ struct osi_xtra_stat_counters { nveu64_t link_disconnect_count; }; +#ifdef MACSEC_SUPPORT /** * @brief The structure hold macsec statistics counters */ @@ -624,5 +625,5 @@ struct osi_macsec_mmc_counters { /** This counter provides the number of out octets protected */ unsigned long long tx_octets_protected; }; - -#endif +#endif /* MACSEC_SUPPORT */ +#endif /* INCLUDED_MMC_H */ \ No newline at end of file diff --git a/include/osi_core.h b/include/osi_core.h index 4667252..247f297 100644 --- a/include/osi_core.h +++ b/include/osi_core.h @@ -953,6 +953,12 @@ struct osd_core_ops { void (*msleep)(nveu32_t msec); /** ivcsend callback*/ nve32_t (*ivc_send)(void *priv, void *data, nveu32_t len); +#ifdef MACSEC_SUPPORT + /** Program macsec key table through Trust Zone callback */ + int (*macsec_tz_kt_config)(void *priv, unsigned char cmd, + void *const kt_config, + void *const genl_info); +#endif /* MACSEC_SUPPORT */ }; #ifdef MACSEC_SUPPORT diff --git a/include/osi_macsec.h b/include/osi_macsec.h index c5c015c..f9769f5 100644 --- a/include/osi_macsec.h +++ b/include/osi_macsec.h @@ -162,7 +162,9 @@ * 4B for FCS */ +/* macsec tz key config cmd */ #define MACSEC_CMD_TZ_CONFIG 0x1 +/* macsec tz key table entries reset cmd */ #define MACSEC_CMD_TZ_KT_RESET 0x2 /** @@ -356,7 +358,8 @@ struct osi_macsec_dbg_buf_config { */ struct macsec_core_ops { /** macsec init */ - int (*init)(struct osi_core_priv_data *const osi_core); + int (*init)(struct osi_core_priv_data *const osi_core, + void *const genl_info); /** macsec de-init */ int (*deinit)(struct osi_core_priv_data *const osi_core); /** NS irq handler */ @@ -368,7 +371,8 @@ struct macsec_core_ops { struct osi_macsec_lut_config *const lut_config); /** macsec kt config */ int (*kt_config)(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config); + struct osi_macsec_kt_config *const kt_config, + void *const genl_info); /** macsec cipher config */ int (*cipher_config)(struct osi_core_priv_data *const osi_core, unsigned int cipher); @@ -381,7 +385,8 @@ struct macsec_core_ops { /** macsec config SA in HW LUT */ int (*config)(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr); + unsigned int enable, unsigned short ctlr, + void *const genl_info); /** macsec read mmc counters */ void (*read_mmc)(struct osi_core_priv_data *const osi_core); /** macsec debug buffer config */ @@ -440,6 +445,7 @@ int osi_init_macsec_ops(struct osi_core_priv_data *const osi_core); * set BYP LUT entries for MKPDU and BC packets * * @param[in] osi_core: OSI core private data structure. + * @param[in] genl_info: Pointer to netlink genl_info data structure. * * @pre * - MACSEC should be out of reset and clocks are enabled @@ -464,7 +470,9 @@ int osi_init_macsec_ops(struct osi_core_priv_data *const osi_core); * @retval 0 on success * @retval -1 on failure */ -int osi_macsec_init(struct osi_core_priv_data *const osi_core); +int osi_macsec_init(struct osi_core_priv_data *const osi_core, + void *const genl_info); + /** * @brief De-initialize the macsec controller @@ -511,12 +519,14 @@ int osi_macsec_lut_config(struct osi_core_priv_data *const osi_core, * * @param[in] osi_core: OSI core private data structure. * @param[in] kt_config: OSI macsec KT config data structure. + * @param[in] genl_info: Pointer to netlink genl_info data structure. * * @retval 0 on success * @retval -1 on failure */ int osi_macsec_kt_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config); + struct osi_macsec_kt_config *const kt_config, + void *const genl_info); /** * @brief MACsec Loopback config @@ -546,16 +556,17 @@ int osi_macsec_en(struct osi_core_priv_data *const osi_core, * @brief MACsec update secure channel/association in controller * * @param[in] osi_core: OSI core private data structure. - * @param[in] tx_sa: Pointer to osi_macsec_sc_info struct for the tx SA. + * @param[in] sc: Pointer to osi_macsec_sc_info struct for the tx SA. * @param[in] enable: flag to indicate enable/disable for the Tx SA. - * @param[in] enable: Pointer to netlink message. + * @param[in] genl_info: Pointer to netlink genl_info data structure. * * @retval 0 on success * @retval -1 on failure */ int osi_macsec_config(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr); + unsigned int enable, unsigned short ctlr, + void *const genl_info); /** * @brief MACsec read statistics counters diff --git a/osi/core/macsec.c b/osi/core/macsec.c index d2e8c23..02fd2eb 100644 --- a/osi/core/macsec.c +++ b/osi/core/macsec.c @@ -20,7 +20,9 @@ * DEALINGS IN THE SOFTWARE. */ +#ifdef MACSEC_KEY_PROGRAM #include +#endif #include #include #include "macsec.h" @@ -539,6 +541,7 @@ int macsec_enable(struct osi_core_priv_data *osi_core, unsigned int enable) return 0; } +#ifdef MACSEC_KEY_PROGRAM /** * @brief poll_for_kt_update - Query the status of a KT update. * @@ -656,7 +659,8 @@ static int kt_key_write(struct osi_core_priv_data *const osi_core, } static int macsec_kt_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config) + struct osi_macsec_kt_config *const kt_config, + void *const genl_info) { int ret = 0; unsigned int kt_config_reg = 0; @@ -720,6 +724,16 @@ static int macsec_kt_config(struct osi_core_priv_data *const osi_core, return ret; } +#else +static int macsec_kt_config(struct osi_core_priv_data *const osi_core, + struct osi_macsec_kt_config *const kt_config, + void *const genl_info) +{ + return osi_core->osd_ops.macsec_tz_kt_config(osi_core, + MACSEC_CMD_TZ_CONFIG, kt_config, genl_info); +} +#endif /* MACSEC_KEY_PROGRAM */ + /** * @brief poll_for_lut_update - Query the status of a LUT update. * @@ -2191,7 +2205,9 @@ static int macsec_loopback_config(struct osi_core_priv_data *const osi_core, static int clear_lut(struct osi_core_priv_data *const osi_core) { struct osi_macsec_lut_config lut_config = {0}; +#ifdef MACSEC_KEY_PROGRAM struct osi_macsec_kt_config kt_config = {0}; +#endif struct macsec_table_config *table_config = &lut_config.table_config; int i, j; int ret = 0; @@ -2285,6 +2301,7 @@ static int clear_lut(struct osi_core_priv_data *const osi_core) } } +#ifdef MACSEC_KEY_PROGRAM /* Key table */ table_config = &kt_config.table_config; table_config->rw = LUT_WRITE; @@ -2292,7 +2309,7 @@ static int clear_lut(struct osi_core_priv_data *const osi_core) table_config->ctlr_sel = i; for (j = 0; j <= TABLE_INDEX_MAX; j++) { table_config->index = j; - ret = macsec_kt_config(osi_core, &kt_config); + ret = macsec_kt_config(osi_core, &kt_config, OSI_NULL); if (ret < 0) { pr_err("Error clearing KT CTLR:INDEX: %d:%d\n", i, j); @@ -2300,6 +2317,7 @@ static int clear_lut(struct osi_core_priv_data *const osi_core) } } } +#endif /* MACSEC_KEY_PROGRAM */ return ret; } @@ -2315,10 +2333,14 @@ static int macsec_deinit(struct osi_core_priv_data *const osi_core) return 0; } -static int macsec_init(struct osi_core_priv_data *const osi_core) +static int macsec_init(struct osi_core_priv_data *const osi_core, + void *const genl_info) { unsigned int val = 0; struct osi_macsec_lut_config lut_config = {0}; +#ifndef MACSEC_KEY_PROGRAM + struct osd_core_ops *osd_ops = &osi_core->osd_ops; +#endif struct macsec_table_config *table_config = &lut_config.table_config; /* Store MAC address in reverse, per HW design */ unsigned char mac_da_mkpdu[OSI_ETH_ALEN] = {0x3, 0x0, 0x0, @@ -2408,25 +2430,28 @@ static int macsec_init(struct osi_core_priv_data *const osi_core) pr_err("Write COMMON_IMR: 0x%x\n", val); osi_writela(osi_core, val, addr + COMMON_IMR); - /* 4. TODO - Route safety intr to LIC */ - val = osi_readla(osi_core, addr + INTERRUPT_MASK1_0); - pr_err("Read INTERRUPT_MASK1_0: 0x%x\n", val); - val |= SFTY_ERR_UNCORR_INT_EN; - pr_err("Write INTERRUPT_MASK1_0: 0x%x\n", val); - osi_writela(osi_core, val, addr + INTERRUPT_MASK1_0); - - /* 5. Set AES mode + /* 4. Set AES mode * Default power on reset is AES-GCM128, leave it. */ - /* 6. Invalidate LUT entries */ + /* 5. Invalidate LUT entries */ ret = clear_lut(osi_core); if (ret < 0) { pr_err("Invalidating all LUT's failed\n"); return ret; } +#ifndef MACSEC_KEY_PROGRAM + /* clear KT entries */ + ret = osd_ops->macsec_tz_kt_config(osi_core, + MACSEC_CMD_TZ_KT_RESET, + OSI_NULL, genl_info); + if (ret < 0) { + pr_err("TZ key config failed %d\n", ret); + goto exit; + } +#endif /* !MACSEC_KEY_PROGRAM */ - /* 7. Set default BYP for MKPDU/BC packets */ + /* 6. Set default BYP for MKPDU/BC packets */ table_config->rw = LUT_WRITE; lut_config.lut_sel = LUT_SEL_BYPASS; lut_config.flags |= (LUT_FLAGS_DA_VALID | @@ -2491,7 +2516,7 @@ static struct osi_macsec_sc_info *find_existing_sc( static int del_upd_sc(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *existing_sc, struct osi_macsec_sc_info *const sc, - unsigned short ctlr) + unsigned short ctlr, void *const genl_info) { struct osi_macsec_lut_config lut_config = {0}; struct osi_macsec_kt_config kt_config = {0}; @@ -2554,7 +2579,7 @@ static int del_upd_sc(struct osi_core_priv_data *const osi_core, /* Each SC has MAX_NUM_SA's supported in HW */ table_config->index = (existing_sc->sc_idx_start * MAX_NUM_SA) + sc->curr_an; - ret = macsec_kt_config(osi_core, &kt_config); + ret = macsec_kt_config(osi_core, &kt_config, genl_info); if (ret < 0) { pr_err("%s: Failed to del SAK", __func__); goto err_kt; @@ -2578,13 +2603,15 @@ err_sci: static int add_upd_sc(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, - unsigned short ctlr) + unsigned short ctlr, void *const genl_info) { struct osi_macsec_lut_config lut_config = {0}; struct osi_macsec_kt_config kt_config = {0}; struct macsec_table_config *table_config; int ret, i; -#if 1 /* HKEY GENERATION */ + +#ifdef MACSEC_KEY_PROGRAM + /* HKEY GENERATION */ /* TODO - Move this to OSD */ struct crypto_cipher *tfm; unsigned char hkey[KEY_LEN_128]; @@ -2603,7 +2630,7 @@ static int add_upd_sc(struct osi_core_priv_data *const osi_core, } pr_err("\n"); crypto_free_cipher(tfm); -#endif /* HKEY GENERATION */ +#endif /* MACSEC_KEY_PROGRAM */ /* 1. Key LUT */ table_config = &kt_config.table_config; @@ -2613,12 +2640,19 @@ static int add_upd_sc(struct osi_core_priv_data *const osi_core, table_config->index = (sc->sc_idx_start * MAX_NUM_SA) + sc->curr_an; kt_config.flags |= LUT_FLAGS_ENTRY_VALID; +#ifdef MACSEC_KEY_PROGRAM /* Program in reverse order as per HW design */ for (i = 0; i < KEY_LEN_128; i++) { kt_config.entry.sak[i] = sc->sak[KEY_LEN_128 - 1 - i]; kt_config.entry.h[i] = hkey[KEY_LEN_128 - 1 - i]; } - ret = macsec_kt_config(osi_core, &kt_config); +#else + for (i = 0; i < KEY_LEN_128; i++) { + kt_config.entry.sak[i] = sc->sak[i]; + } +#endif /* MACSEC_KEY_PROGRAM */ + + ret = macsec_kt_config(osi_core, &kt_config, genl_info); if (ret < 0) { pr_err("%s: Failed to set SAK", __func__); return -1; @@ -2711,7 +2745,8 @@ err_sa_state: static int macsec_config(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr) + unsigned int enable, unsigned short ctlr, + void *const genl_info) { struct osi_macsec_sc_info *existing_sc = OSI_NULL, *new_sc = OSI_NULL; struct osi_macsec_sc_info tmp_sc; @@ -2773,7 +2808,7 @@ static int macsec_config(struct osi_core_priv_data *const osi_core, } pr_err(""); - if (add_upd_sc(osi_core, new_sc, ctlr) != OSI_NONE) { + if (add_upd_sc(osi_core, new_sc, ctlr, genl_info) != OSI_NONE) { pr_err("%s: failed to add new SC", __func__); /* TODO - remove new_sc from lut_status[] ? * not needed for now, as next_sc_idx is not @@ -2794,7 +2829,7 @@ static int macsec_config(struct osi_core_priv_data *const osi_core, pr_err("%s: Updating existing SC", __func__); if (enable == OSI_DISABLE) { pr_err("%s: Deleting existing SA", __func__); - if (del_upd_sc(osi_core, existing_sc, sc, ctlr) != + if (del_upd_sc(osi_core, existing_sc, sc, ctlr, genl_info) != OSI_NONE) { pr_err("%s: failed to del SA", __func__); return -1; @@ -2837,7 +2872,8 @@ static int macsec_config(struct osi_core_priv_data *const osi_core, } pr_err(""); - if (add_upd_sc(osi_core, tmp_sc_p, ctlr) != OSI_NONE) { + if (add_upd_sc(osi_core, tmp_sc_p, ctlr, genl_info) != + OSI_NONE) { pr_err("%s: failed to add new SA", __func__); /* TODO - remove new_sc from lut_status[] ? * not needed for now, as next_sc_idx is not @@ -2845,10 +2881,10 @@ static int macsec_config(struct osi_core_priv_data *const osi_core, */ return -1; } else { - /* Update lut status */ - lut_status->next_sc_idx++; - pr_err("%s: Added new SA ctlr: %u", - __func__, ctlr); + pr_err("%s: Updated new SC ctlr: %u " + "nxt_sc_idx: %u", + __func__, ctlr, + lut_status->next_sc_idx); /* Now commit the changes */ *existing_sc = *tmp_sc_p; return 0; @@ -2877,7 +2913,8 @@ static struct osi_macsec_lut_status lut_status[NUM_CTLR]; int osi_init_macsec_ops(struct osi_core_priv_data *const osi_core) { - if (osi_core->macsec_base == OSI_NULL) { + if (osi_core->macsec_base == OSI_NULL || + osi_core->osd_ops.macsec_tz_kt_config == OSI_NULL) { return -1; } else { osi_core->macsec_ops = &macsec_ops; @@ -2886,11 +2923,12 @@ int osi_init_macsec_ops(struct osi_core_priv_data *const osi_core) } } -int osi_macsec_init(struct osi_core_priv_data *const osi_core) +int osi_macsec_init(struct osi_core_priv_data *const osi_core, + void *const genl_info) { if (osi_core != OSI_NULL && osi_core->macsec_ops != OSI_NULL && osi_core->macsec_ops->init != OSI_NULL) { - return osi_core->macsec_ops->init(osi_core); + return osi_core->macsec_ops->init(osi_core, genl_info); } return -1; @@ -2933,12 +2971,14 @@ int osi_macsec_lut_config(struct osi_core_priv_data *const osi_core, } int osi_macsec_kt_config(struct osi_core_priv_data *const osi_core, - struct osi_macsec_kt_config *const kt_config) + struct osi_macsec_kt_config *const kt_config, + void *const genl_info) { if (osi_core != OSI_NULL && osi_core->macsec_ops != OSI_NULL && osi_core->macsec_ops->kt_config != OSI_NULL && kt_config != OSI_NULL) { - return osi_core->macsec_ops->kt_config(osi_core, kt_config); + return osi_core->macsec_ops->kt_config(osi_core, kt_config, + genl_info); } return -1; @@ -2975,7 +3015,8 @@ int osi_macsec_en(struct osi_core_priv_data *const osi_core, int osi_macsec_config(struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, - unsigned int enable, unsigned short ctlr) + unsigned int enable, unsigned short ctlr, + void *const genl_info) { if ((enable != OSI_ENABLE && enable != OSI_DISABLE) || (ctlr != CTLR_SEL_TX && ctlr != CTLR_SEL_RX)) { @@ -2985,7 +3026,7 @@ int osi_macsec_config(struct osi_core_priv_data *const osi_core, if (osi_core != OSI_NULL && osi_core->macsec_ops != OSI_NULL && osi_core->macsec_ops->config != OSI_NULL && sc != OSI_NULL) { return osi_core->macsec_ops->config(osi_core, sc, - enable, ctlr); + enable, ctlr, genl_info); } return -1;