From 306f33d38e8d4e80478f489bdf1d4b4dcfcaa573 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Uppala Date: Fri, 23 Jun 2023 15:51:43 +0530 Subject: [PATCH] nvethernet: Read instance_id irrespective of macsec. Issue: MGBE0 ASID is getting programmed for all the MAC instances which inturn causing the data transfer failures.Macsec is not enable and hence instance_id is not getting updated to the corresponding mac instance number and hence all mac instance_id's are initialized with 0. Since ASID programming is based on mac instance_id, all MACs are programmed with MGBE0 MAC instance id. Fix: Moved reading of instance_id from DT out of macsec_probe and hence the instance_id gets updated irrespective of MAC sec enable/disable. Bug 4124937 Change-Id: I500ed8d3db402995488260af99ad190217ff6dd2 Signed-off-by: Revanth Kumar Uppala Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2925252 Reviewed-by: Narayan Reddy Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- .../net/ethernet/nvidia/nvethernet/ether_linux.c | 11 +++++++++++ drivers/net/ethernet/nvidia/nvethernet/macsec.c | 15 +++------------ drivers/net/ethernet/nvidia/nvethernet/macsec.h | 2 -- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 6139e0d5..8044d9ce 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -6176,6 +6176,17 @@ static int ether_parse_dt(struct ether_priv_data *pdata) osi_core->hsi.err_count_threshold = OSI_HSI_ERR_COUNT_THRESHOLD; #endif + /* Only for orin, Read instance id for the interface, default 0 */ + if (osi_core->mac_ver > OSI_EQOS_MAC_5_00 || + osi_core->mac == OSI_MAC_HW_MGBE) { + ret = of_property_read_u32(np, "nvidia,instance_id", &osi_core->instance_id); + if (ret != 0) { + dev_info(dev, + "DT instance_id missing, setting default to MGBE0\n"); + osi_core->instance_id = 0; + } + } + exit: return ret; } diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.c b/drivers/net/ethernet/nvidia/nvethernet/macsec.c index cfcbfbb2..0be566e2 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/macsec.c +++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.c @@ -1374,16 +1374,6 @@ int macsec_probe(struct ether_priv_data *pdata) mutex_init(&pdata->macsec_pdata->lock); - /* Read MAC instance id and used in TZ api's */ - ret = of_property_read_u32(np, "nvidia,instance_id", &macsec_pdata->id); - if (ret != 0) { - dev_info(dev, - "DT instance_id missing, setting default to MGBE0\n"); - macsec_pdata->id = 0; - } - - osi_core->instance_id = macsec_pdata->id; - /* Get OSI MACsec ops */ if (osi_init_macsec_ops(osi_core) != 0) { dev_err(dev, "osi_init_macsec_ops failed\n"); @@ -1513,7 +1503,7 @@ static int macsec_tz_kt_config(struct ether_priv_data *pdata, goto failure; } nla_put_u32(msg, NV_MACSEC_TZ_KT_RESET_INSTANCE_ID, - macsec_pdata->id); + pdata->osi_core->instance_id); nla_nest_end(msg, nest); } @@ -1531,7 +1521,8 @@ static int macsec_tz_kt_config(struct ether_priv_data *pdata, ret = EINVAL; goto failure; } - nla_put_u32(msg, NV_MACSEC_TZ_INSTANCE_ID, macsec_pdata->id); + nla_put_u32(msg, NV_MACSEC_TZ_INSTANCE_ID, + pdata->osi_core->instance_id); nla_put_u8(msg, NV_MACSEC_TZ_ATTR_CTRL, kt_config->table_config.ctlr_sel); nla_put_u8(msg, NV_MACSEC_TZ_ATTR_RW, diff --git a/drivers/net/ethernet/nvidia/nvethernet/macsec.h b/drivers/net/ethernet/nvidia/nvethernet/macsec.h index 2151ead5..6cdb828a 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/macsec.h +++ b/drivers/net/ethernet/nvidia/nvethernet/macsec.h @@ -243,8 +243,6 @@ struct macsec_priv_data { unsigned short next_supp_idx; /** macsec mutex lock */ struct mutex lock; - /** macsec hw instance id */ - unsigned int id; /** Macsec enable flag in DT */ unsigned int is_macsec_enabled_in_dt; /** Context family name */