From 593c8fc44c62d10f8e8a1e332a139c96256f906f Mon Sep 17 00:00:00 2001 From: Sanath Kumar Gampa Date: Fri, 25 Oct 2024 09:42:33 +0000 Subject: [PATCH] nvethernetrm: Add DA to SCI LUT with peer MACID Bug 4754899 Change-Id: I5c15770793d2f64fb54b565fd046ad9f9d7cb4bf Signed-off-by: Sanath Kumar Gampa Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/3237499 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Mahesh Patil Reviewed-by: svc-mobile-cert GVS: buildbot_gerritrpt Reviewed-by: Ashutosh Jha Reviewed-by: svcacv --- include/osi_core.h | 3 +++ osi/nvmacsecrm/macsec.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/osi_core.h b/include/osi_core.h index 02ef78d..8c73495 100644 --- a/include/osi_core.h +++ b/include/osi_core.h @@ -1334,6 +1334,9 @@ struct osi_macsec_sc_info { 2: Indicates offset as 50 */ nveu8_t conf_offset; + /** Peer MACID is stored + * valid values are from 0 to UINT8_MAX */ + nveu8_t peer_macid[OSI_ETH_ALEN]; }; /** diff --git a/osi/nvmacsecrm/macsec.c b/osi/nvmacsecrm/macsec.c index b180fcb..20f83e8 100644 --- a/osi/nvmacsecrm/macsec.c +++ b/osi/nvmacsecrm/macsec.c @@ -5627,6 +5627,7 @@ static nve32_t add_upd_sc(struct osi_core_priv_data *const osi_core, nve32_t ret = 0; nveu32_t i; nveu8_t error_mask = 0; + const nveu8_t zero_mac[OSI_ETH_ALEN] = {0U}; #ifdef MACSEC_KEY_PROGRAM struct osi_macsec_kt_config kt_config = {0}; #endif /* MACSEC_KEY_PROGRAM */ @@ -5709,6 +5710,12 @@ static nve32_t add_upd_sc(struct osi_core_priv_data *const osi_core, /* Extract the mac sa from the SCI itself */ copy_rev_order(lut_config.lut_in.sa, sc->sci, OSI_ETH_ALEN); lut_config.flags |= OSI_LUT_FLAGS_SA_VALID; + /* Update peer MACID in DA of tx SCI_LUT */ + copy_rev_order(lut_config.lut_in.da, sc->peer_macid, OSI_ETH_ALEN); + if (osi_macsec_memcmp(&sc->peer_macid[0], zero_mac, + (nve32_t)OSI_ETH_ALEN) != OSI_NONE_SIGNED) { + lut_config.flags |= OSI_LUT_FLAGS_DA_VALID; + } lut_config.sci_lut_out.sc_index = sc->sc_idx_start; for (i = 0; i < OSI_SCI_LEN; i++) { lut_config.sci_lut_out.sci[i] = sc->sci[OSI_SCI_LEN - 1U - i]; @@ -5859,6 +5866,8 @@ static nve32_t add_new_sc(struct osi_core_priv_data *const osi_core, } new_sc = &lut_status_ptr->sc_info[avail_sc_idx]; memcpy_sci_sak_hkey(new_sc, sc); + (void)osi_macsec_memcpy(new_sc->peer_macid, sc->peer_macid, + OSI_ETH_ALEN); new_sc->curr_an = sc->curr_an; new_sc->next_pn = sc->next_pn; new_sc->pn_window = sc->pn_window; @@ -5984,6 +5993,9 @@ static nve32_t macsec_configure(struct osi_core_priv_data *const osi_core, */ *tmp_sc_p = *existing_sc; memcpy_sci_sak_hkey(tmp_sc_p, sc); + (void)osi_macsec_memcpy(tmp_sc_p->peer_macid, + sc->peer_macid, + OSI_ETH_ALEN); tmp_sc_p->curr_an = sc->curr_an; tmp_sc_p->next_pn = sc->next_pn; tmp_sc_p->pn_window = sc->pn_window;