osi:macsec: Separate lut_status for each IP

Issue: If macsec is created on EQOS and then created on MGBE, we are
over writing the lut_status of EQOS with MGBE lut_status.

Fix: Create different lut_status structure in osi_core so that each
IP will have its own lut_status structure.

Bug 3587231

Change-Id: I826c3d210ed18350140f1cbcb41b748550f92844
Signed-off-by: Sanath Kumar Gampa <sgampa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2690839
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sanath Kumar Gampa
2022-03-31 19:28:27 +05:30
committed by Bhadram Varka
parent 0ffef9743a
commit f238abc016
3 changed files with 59 additions and 50 deletions

View File

@@ -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 */

View File

@@ -25,6 +25,7 @@
#include <osi_core.h>
#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 */

View File

@@ -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;
}