From bda2364844bc1eba35efbadcd0709453d6d6faef Mon Sep 17 00:00:00 2001 From: Mohan Thadikamalla Date: Tue, 21 Jul 2020 11:53:04 +0530 Subject: [PATCH] =?UTF-8?q?osi:=20core:=20Fix=C2=A0eqos=5Fconfig=5Ftscr=20?= =?UTF-8?q?code=20complexity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: The nvethernetrm eqos_config_tscr function code complexity is more than the PLC process required to target 10. Fix: Update eqos_config_tscr function to meet PLC code complexity target. Bug 200634728 Change-Id: I774e94c9a6893e01e2bd6e935ae34c96be8e0f38 Signed-off-by: Mohan Thadikamalla Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2382806 (cherry picked from commit a37d9984606a6e9eb99aff59858276ef7d5ca1c8) Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/2448831 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Bhadram Varka Reviewed-by: Narayan Reddy Reviewed-by: Rakesh Goyal Reviewed-by: Bitan Biswas Reviewed-by: mobile promotions Tested-by: Rakesh Goyal Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- osi/core/eqos_core.c | 105 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/osi/core/eqos_core.c b/osi/core/eqos_core.c index e26be6c..5d300af 100644 --- a/osi/core/eqos_core.c +++ b/osi/core/eqos_core.c @@ -2834,60 +2834,63 @@ static int eqos_adjust_mactime(struct osi_core_priv_data *const osi_core, */ static void eqos_config_tscr(void *addr, const unsigned int ptp_filter) { - unsigned int mac_tcr = 0; + unsigned int mac_tcr = 0U, i = 0U, temp = 0U; - if (ptp_filter != OSI_DISABLE) { - mac_tcr = (OSI_MAC_TCR_TSENA | - OSI_MAC_TCR_TSCFUPDT | - OSI_MAC_TCR_TSCTRLSSR); - - if ((ptp_filter & OSI_MAC_TCR_SNAPTYPSEL_1) == - OSI_MAC_TCR_SNAPTYPSEL_1) { - mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_1; - } - if ((ptp_filter & OSI_MAC_TCR_SNAPTYPSEL_2) == - OSI_MAC_TCR_SNAPTYPSEL_2) { - mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_2; - } - if ((ptp_filter & OSI_MAC_TCR_SNAPTYPSEL_3) == - OSI_MAC_TCR_SNAPTYPSEL_3) { - mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_3; - } - if ((ptp_filter & OSI_MAC_TCR_TSIPV4ENA) == - OSI_MAC_TCR_TSIPV4ENA) { - mac_tcr |= OSI_MAC_TCR_TSIPV4ENA; - } - if ((ptp_filter & OSI_MAC_TCR_TSIPV6ENA) == - OSI_MAC_TCR_TSIPV6ENA) { - mac_tcr |= OSI_MAC_TCR_TSIPV6ENA; - } - if ((ptp_filter & OSI_MAC_TCR_TSEVENTENA) == - OSI_MAC_TCR_TSEVENTENA) { - mac_tcr |= OSI_MAC_TCR_TSEVENTENA; - } - if ((ptp_filter & OSI_MAC_TCR_TSMASTERENA) == - OSI_MAC_TCR_TSMASTERENA) { - mac_tcr |= OSI_MAC_TCR_TSMASTERENA; - } - if ((ptp_filter & OSI_MAC_TCR_TSVER2ENA) == - OSI_MAC_TCR_TSVER2ENA) { - mac_tcr |= OSI_MAC_TCR_TSVER2ENA; - } - if ((ptp_filter & OSI_MAC_TCR_TSIPENA) == - OSI_MAC_TCR_TSIPENA) { - mac_tcr |= OSI_MAC_TCR_TSIPENA; - } - if ((ptp_filter & OSI_MAC_TCR_AV8021ASMEN) == - OSI_MAC_TCR_AV8021ASMEN) { - mac_tcr |= OSI_MAC_TCR_AV8021ASMEN; - } - if ((ptp_filter & OSI_MAC_TCR_TSENALL) == - OSI_MAC_TCR_TSENALL) { - mac_tcr |= OSI_MAC_TCR_TSENALL; - } - } else { + if (ptp_filter == OSI_DISABLE) { /* Disabling the MAC time stamping */ mac_tcr = OSI_DISABLE; + eqos_core_safety_writel(mac_tcr, + (unsigned char *)addr + EQOS_MAC_TCR, + EQOS_MAC_TCR_IDX); + return; + } + + mac_tcr = (OSI_MAC_TCR_TSENA | + OSI_MAC_TCR_TSCFUPDT | + OSI_MAC_TCR_TSCTRLSSR); + + for (i = 0U; i < 32U; i++) { + temp = ptp_filter & OSI_BIT(i); + + switch (temp) { + case OSI_MAC_TCR_SNAPTYPSEL_1: + mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_1; + break; + case OSI_MAC_TCR_SNAPTYPSEL_2: + mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_2; + break; + case OSI_MAC_TCR_SNAPTYPSEL_3: + mac_tcr |= OSI_MAC_TCR_SNAPTYPSEL_3; + break; + case OSI_MAC_TCR_TSIPV4ENA: + mac_tcr |= OSI_MAC_TCR_TSIPV4ENA; + break; + case OSI_MAC_TCR_TSIPV6ENA: + mac_tcr |= OSI_MAC_TCR_TSIPV6ENA; + break; + case OSI_MAC_TCR_TSEVENTENA: + mac_tcr |= OSI_MAC_TCR_TSEVENTENA; + break; + case OSI_MAC_TCR_TSMASTERENA: + mac_tcr |= OSI_MAC_TCR_TSMASTERENA; + break; + case OSI_MAC_TCR_TSVER2ENA: + mac_tcr |= OSI_MAC_TCR_TSVER2ENA; + break; + case OSI_MAC_TCR_TSIPENA: + mac_tcr |= OSI_MAC_TCR_TSIPENA; + break; + case OSI_MAC_TCR_AV8021ASMEN: + mac_tcr |= OSI_MAC_TCR_AV8021ASMEN; + break; + case OSI_MAC_TCR_TSENALL: + mac_tcr |= OSI_MAC_TCR_TSENALL; + break; + default: + /* To avoid MISRA violation */ + mac_tcr |= mac_tcr; + break; + } } eqos_core_safety_writel(mac_tcr, (unsigned char *)addr + EQOS_MAC_TCR,