diff --git a/include/osi_core.h b/include/osi_core.h index 40b95f4..e7b84ae 100644 --- a/include/osi_core.h +++ b/include/osi_core.h @@ -48,6 +48,21 @@ typedef my_uint16_t nveu16_t; typedef my_lint_64 nvel64_t; /** @} */ +#ifdef MACSEC_SUPPORT +/** + * @addtogroup MACSEC related helper MACROs + * + * @brief MACSEC generic helper MACROs + * @{ + */ +#define OSI_MAX_NUM_SC 8U +#define OSI_SCI_LEN 8U +#define OSI_KEY_LEN_128 16U +#define OSI_KEY_LEN_256 32U +#define OSI_NUM_CTLR 2U +/** @} */ +#endif /* MACSEC_SUPPORT */ + /** * @addtogroup PTP PTP related information * @@ -1104,6 +1119,46 @@ struct osd_core_ops { }; #ifdef MACSEC_SUPPORT +/** + * @brief MACSEC secure channel basic information + */ +struct osi_macsec_sc_info { + /** Secure channel identifier */ + nveu8_t sci[OSI_SCI_LEN]; + /** Secure association key */ + nveu8_t sak[OSI_KEY_LEN_128]; +#ifdef MACSEC_KEY_PROGRAM + /** Secure association key */ + nveu8_t hkey[OSI_KEY_LEN_128]; +#endif /* MACSEC_KEY_PROGRAM */ + /** current AN */ + nveu8_t curr_an; + /** Next PN to use for the current AN */ + nveu32_t next_pn; + /** Lowest PN to use for the current AN */ + nveu32_t lowest_pn; + /** bitmap of valid AN */ + nveu32_t an_valid; + /** PN window */ + nveu32_t pn_window; + /** SC LUT index */ + nveu32_t sc_idx_start; + /** flags - encoding various states of SA */ + nveu32_t flags; +}; + +/** + * @brief MACSEC HW controller LUT's global status + */ +struct osi_macsec_lut_status { + /** List of max SC's supported */ + struct osi_macsec_sc_info sc_info[OSI_MAX_NUM_SC]; + /** next available BYP LUT index */ + nveu16_t next_byp_idx; + /** number of active SCs */ + nveu32_t num_of_sc_used; +}; + /** * @brief MACsec interrupt stats structure. */ @@ -1323,7 +1378,7 @@ struct osi_core_priv_data { /** Instance of macsec interrupt stats structure */ struct osi_macsec_irq_stats macsec_irq_stats; /** Instance of macsec HW controller Tx/Rx LUT status */ - struct osi_macsec_lut_status *macsec_lut_status; + struct osi_macsec_lut_status macsec_lut_status[OSI_NUM_CTLR]; /** macsec mmc counters */ struct osi_macsec_mmc_counters macsec_mmc; /** MACSEC enabled state */ diff --git a/include/osi_macsec.h b/include/osi_macsec.h index af6efb2..8d35f33 100644 --- a/include/osi_macsec.h +++ b/include/osi_macsec.h @@ -25,6 +25,7 @@ #include +#ifdef MACSEC_SUPPORT ////////////////////////////////////////////////////////////////////////// /* MACSEC OSI data structures */ ////////////////////////////////////////////////////////////////////////// @@ -35,14 +36,10 @@ * @brief Helper macros for LUT programming * @{ */ -#define OSI_SCI_LEN 8U -#define OSI_KEY_LEN_128 16U -#define OSI_KEY_LEN_256 32U #define OSI_AN0_VALID OSI_BIT(0) #define OSI_AN1_VALID OSI_BIT(1) #define OSI_AN2_VALID OSI_BIT(2) #define OSI_AN3_VALID OSI_BIT(3) -#define OSI_MAX_NUM_SC 8U #define OSI_MAX_NUM_SA 4U #define OSI_CURR_AN_MAX 3 #define OSI_KEY_INDEX_MAX 31U @@ -108,7 +105,6 @@ #define OSI_CTLR_SEL_TX 0U #define OSI_CTLR_SEL_RX 1U #define OSI_CTLR_SEL_MAX 1U -#define OSI_NUM_CTLR 2U #define OSI_LUT_READ 0U #define OSI_LUT_WRITE 1U #define OSI_RW_MAX 1U @@ -272,46 +268,6 @@ struct osi_lut_inputs { nveu32_t vlan_id; }; -/** - * @brief MACSEC secure channel basic information - */ -struct osi_macsec_sc_info { - /** Secure channel identifier */ - nveu8_t sci[OSI_SCI_LEN]; - /** Secure association key */ - nveu8_t sak[OSI_KEY_LEN_128]; -#ifdef MACSEC_KEY_PROGRAM - /** Secure association key */ - nveu8_t hkey[OSI_KEY_LEN_128]; -#endif /* MACSEC_KEY_PROGRAM */ - /** current AN */ - nveu8_t curr_an; - /** Next PN to use for the current AN */ - nveu32_t next_pn; - /** Lowest PN to use for the current AN */ - nveu32_t lowest_pn; - /** bitmap of valid AN */ - nveu32_t an_valid; - /** PN window */ - nveu32_t pn_window; - /** SC LUT index */ - nveu32_t sc_idx_start; - /** flags - encoding various states of SA */ - nveu32_t flags; -}; - -/** - * @brief MACSEC HW controller LUT's global status - */ -struct osi_macsec_lut_status { - /** List of max SC's supported */ - struct osi_macsec_sc_info sc_info[OSI_MAX_NUM_SC]; - /** next available BYP LUT index */ - nveu16_t next_byp_idx; - /** number of active SCs */ - nveu32_t num_of_sc_used; -}; - /** * @brief MACSEC LUT config data structure */ @@ -1000,4 +956,5 @@ nve32_t osi_macsec_get_sc_lut_key_index( nve32_t osi_macsec_update_mtu(struct osi_core_priv_data *const osi_core, nveu32_t mtu); +#endif /* MACSEC_SUPPORT */ #endif /* INCLUDED_OSI_MACSEC_H */ diff --git a/osi/core/macsec.c b/osi/core/macsec.c index d8070f7..6d89ac0 100644 --- a/osi/core/macsec.c +++ b/osi/core/macsec.c @@ -2722,7 +2722,7 @@ exit: } static struct osi_macsec_sc_info *find_existing_sc( - const struct osi_core_priv_data *const osi_core, + struct osi_core_priv_data *const osi_core, struct osi_macsec_sc_info *const sc, nveu16_t ctlr) { @@ -3206,11 +3206,9 @@ static nve32_t config_macsec(struct osi_core_priv_data *const osi_core, * @brief if_ops - Static core interface operations for virtual * case */ - nve32_t osi_init_macsec_ops(struct osi_core_priv_data *const osi_core) { static struct osi_macsec_core_ops virt_macsec_ops; - static struct osi_macsec_lut_status lut_status[OSI_NUM_CTLR]; static struct osi_macsec_core_ops macsec_ops = { .init = macsec_init, .deinit = macsec_deinit, @@ -3240,7 +3238,6 @@ nve32_t osi_init_macsec_ops(struct osi_core_priv_data *const osi_core) } osi_core->macsec_ops = &macsec_ops; } - osi_core->macsec_lut_status = lut_status; return 0; }