From 6c7d05d9bba9e1d0a992a637ddee5d9fbea8f9db Mon Sep 17 00:00:00 2001 From: Sanath Kumar Gampa Date: Tue, 1 Nov 2022 15:01:56 +0530 Subject: [PATCH] nvethernet: Address review comments on HSI changes Bug 3590939 Change-Id: Id7bf154880a8f566a9807a3c3c7c210766d48c03 Signed-off-by: Sanath Kumar Gampa Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801131 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2806411 GVS: Gerrit_Virtual_Submit Tested-by: Revanth Kumar Uppala Reviewed-by: Revanth Kumar Uppala Reviewed-by: Bhadram Varka Reviewed-by: Mohan Thadikamalla Reviewed-by: Narayan Reddy Reviewed-by: Bitan Biswas --- .../ethernet/nvidia/nvethernet/ether_linux.c | 4 +- .../net/ethernet/nvidia/nvethernet/sysfs.c | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 70d53e7e..14477c14 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -146,7 +146,7 @@ static irqreturn_t ether_common_isr_thread(int irq, void *data) /* Called from ether_hsi_work */ if (osi_core->hsi.report_err && irq == 0) { osi_core->hsi.report_err = OSI_DISABLE; - for (i = 0; i < HSI_MAX_MAC_ERROR_CODE; i++) { + for (i = 0; i < OSI_HSI_MAX_MAC_ERROR_CODE; i++) { if (osi_core->hsi.err_code[i] > 0) { error_report.error_code = osi_core->hsi.err_code[i]; @@ -189,7 +189,7 @@ static irqreturn_t ether_common_isr_thread(int irq, void *data) /* Called from interrupt handler */ if (osi_core->hsi.report_err && irq != 0) { - for (i = 0; i < HSI_MAX_MAC_ERROR_CODE; i++) { + for (i = 0; i < OSI_HSI_MAX_MAC_ERROR_CODE; i++) { if (osi_core->hsi.err_code[i] > 0 && osi_core->hsi.report_count_err[i] == OSI_ENABLE) { error_report.error_code = diff --git a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c index 4576eeb9..a3ea1c9e 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/sysfs.c +++ b/drivers/net/ethernet/nvidia/nvethernet/sysfs.c @@ -519,6 +519,17 @@ static ssize_t hsi_enable_store(struct device *dev, } else { osi_core->hsi.enabled = OSI_ENABLE; dev_info(pdata->dev, "HSI Enabled\n"); +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + + ret = hsierrrpt_reg_cb(ip_type[osi_core->mac], inst_id, + hsi_inject_err_fsi, pdata); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback registration failed: %d", + ret); + } +#endif } } else if (strncmp(buf, "disable", 7) == OSI_NONE) { ioctl_data.arg1_u32 = OSI_DISABLE; @@ -529,6 +540,16 @@ static ssize_t hsi_enable_store(struct device *dev, } else { osi_core->hsi.enabled = OSI_DISABLE; dev_info(pdata->dev, "HSI Disabled\n"); +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + + ret = hsierrrpt_dereg_cb(ip_type[osi_core->mac], inst_id); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback deregistration failed: %d", + ret); + } +#endif } } else { dev_err(pdata->dev, @@ -3278,6 +3299,20 @@ int ether_sysfs_register(struct ether_priv_data *pdata) if (ret < 0) return ret; #endif + +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) && defined(HSI_SUPPORT) + if (osi_core->use_virtualization == OSI_ENABLE) { + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + ret = hsierrrpt_reg_cb(ip_type[osi_core->mac], inst_id, + hsi_inject_err_fsi, pdata); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback registration failed: %d", + ret); + return ret; + } + } +#endif /* Create nvethernet sysfs group under /sys/devices// */ return sysfs_create_group(&dev->kobj, ðer_attribute_group); } @@ -3288,6 +3323,18 @@ void ether_sysfs_unregister(struct ether_priv_data *pdata) #ifdef CONFIG_DEBUG_FS ether_remove_debugfs(pdata); +#endif +#if (IS_ENABLED(CONFIG_TEGRA_HSIERRRPTINJ)) && defined(HSI_SUPPORT) + if (osi_core->use_virtualization == OSI_ENABLE) { + if (osi_core->instance_id == OSI_INSTANCE_ID_EQOS) + inst_id = 0; + + ret = hsierrrpt_dereg_cb(ip_type[osi_core->mac], inst_id); + if (ret != 0) { + dev_err(pdata->dev, "Err inj callback deregistration failed: %d", + ret); + } + } #endif /* Remove nvethernet sysfs group under /sys/devices// */ sysfs_remove_group(&dev->kobj, ðer_attribute_group);