From 43be5f0f6c36e23d6f51c1f1f55ebcec920cc453 Mon Sep 17 00:00:00 2001
From: Jason Liu <jason.hui.liu@nxp.com>
Date: Thu, 2 Jan 2020 12:46:37 +0800
Subject: [PATCH] LF-697 net: ethernet: freescale: sdk_fman: fix the build
 warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The patch fixes the build warnings by adding the comments 'fall through' to avoid the build warnings
The patch also initializes the value pgid_val to avoid the warning: ‘pgid_val’ may be used uninitialized
The patch should not and will not have any function impact.

drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c: In function ‘ValidateNextEngineParams’:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c:1681:51: warning: this statement may fall through [-Wimplicit-fallthrough=]
In file included from drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c:40:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c: In function ‘GetGenHdrCode’:
drivers/net/ethernet/freescale/sdk_fman/inc/error_ext.h:446:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
In file included from drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c:40:
drivers/net/ethernet/freescale/sdk_fman/inc/error_ext.h:446:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c:255:13: note: here
  255 |             case (HEADER_TYPE_ETH):
      |             ^~~~
In file included from drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c:40:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c:278:13: note: here
  278 |             case (HEADER_TYPE_MINENCAP):
      |             ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c: In function ‘BuildHmct’:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c:673:32: warning: this statement may fall through [-Wimplicit-fallthrough=]
  673 |                         tmpReg = HMCD_INSRT_UDP_LITE;
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c:674:21: note: here
  674 |                     case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
      |                     ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c: In function ‘FM_PORT_Config’:
arch/arm64/include/asm/io.h:36:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
   36 | #define __raw_writel __raw_writel
drivers/net/ethernet/freescale/sdk_fman/src/inc/types_linux.h:99:25: note: in expansion of macro ‘__raw_writel’
   99 | #define out_be32(a, v)  __raw_writel(__cpu_to_be32(v), a)
      |                         ^~~~~~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/src/inc/types_linux.h:121:37: note: in expansion of macro ‘out_be32’
  121 | #define WRITE_UINT32(arg, data)     out_be32(&(arg), data)//*(volatile unsigned int *)(&(arg)) = (data)
      |                                     ^~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:2404:13: note: in expansion of macro ‘WRITE_UINT32’
 2404 |             WRITE_UINT32( p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp,
      |             ^~~~~~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:2407:9: note: here
 2407 |         case (e_FM_PORT_TYPE_TX_10G):
      |         ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:2435:60: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2435 |             p_FmPort->p_FmPortDriverParam->noScatherGather =
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:2438:9: note: here
 2438 |         case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
      |         ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c: In function ‘FM_PORT_ModifyCounter’:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:4268:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
 4268 |             if ((p_FmPort->portType == e_FM_PORT_TYPE_RX)
      |                ^
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:4273:9: note: here
 4273 |         case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
      |         ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c: In function ‘SetPcd’:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:1396:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1396 |                 tmpReg = NIA_KG_CC_EN;
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c:1397:13: note: here
 1397 |             case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
      |             ^~~~
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c: In function ‘FM_GetCounter’:
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c:4804:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
 4804 |             if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 4) ||
      |                ^
drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c:4810:9: note: here
 4810 |         case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
      |         ^~~~
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c: In function ‘fm_get_counter’:
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c:1803:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
 1803 |   if (p_fm->p_FmStateStruct->revInfo.majorRev >= 6)
      |      ^
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c:1806:2: note: here
 1806 |  case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
      |  ^~~~
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c: In function ‘compat_copy_fm_pcd_cc_next_engine’:
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c:378:33: warning: this statement may fall through [-Wimplicit-fallthrough=]
  378 |                 param->manip_id = compat_pcd_id2ptr(compat_param->manip_id);
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c:379:13: note: here
  379 |             default:
      |             ^~~~~~~
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c:405:40: warning: this statement may fall through [-Wimplicit-fallthrough=]
  405 |                 compat_param->manip_id = compat_pcd_ptr2id(param->manip_id);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c:406:13: note: here
  406 |             default:
      |             ^~~~~~~
In file included from drivers/net/ethernet/mscc/ocelot.h:21,
                 from drivers/net/ethernet/mscc/ocelot_tsn.c:12:
drivers/net/ethernet/mscc/ocelot_tsn.c: In function ‘ocelot_seq_gen_set’:
include/soc/mscc/ocelot.h:499:48: warning: ‘pgid_val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  499 | #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
      |                                                ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/mscc/ocelot_tsn.c:755:5: note: ‘pgid_val’ was declared here
  755 |  u8 pgid_val, fwdport;

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
Cc: Madalin Bucur <madalin.bucur@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c   | 1 +
 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c   | 4 ++++
 .../net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c    | 1 +
 .../net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c    | 5 +++++
 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c          | 3 +++
 .../freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c         | 2 ++
 .../net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c    | 3 +++
 drivers/net/ethernet/mscc/ocelot_tsn.c                               | 2 +-
 8 files changed, 20 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_cc.c
@@ -1679,6 +1679,7 @@ t_Error ValidateNextEngineParams(
 
         case (e_FM_PCD_HASH):
             p_FmPcdCcNextEngineParams->nextEngine = e_FM_PCD_CC;
+            /* fall through */
         case (e_FM_PCD_CC):
             if (!p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)
                 RETURN_ERROR(MAJOR, E_NULL_POINTER,
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_kg.c
@@ -198,6 +198,7 @@ static uint8_t GetGenHdrCode(e_NetHeader
         {
             case (HEADER_TYPE_NONE):
                 ASSERT_COND(FALSE);
+		/* Else fall through */
             case (HEADER_TYPE_ETH):
                 return KG_SCH_GEN_ETH;
             case (HEADER_TYPE_LLC_SNAP):
@@ -252,6 +253,7 @@ static uint8_t GetGenHdrCode(e_NetHeader
         {
             case (HEADER_TYPE_NONE):
                 ASSERT_COND(FALSE);
+		/* Else fall through */
             case (HEADER_TYPE_ETH):
                 return KG_SCH_GEN_ETH_NO_V;
             case (HEADER_TYPE_LLC_SNAP):
@@ -269,12 +271,14 @@ static uint8_t GetGenHdrCode(e_NetHeader
                     REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));
                 return 0;
             case (HEADER_TYPE_IPv4):
+		/* fall through */
             case (HEADER_TYPE_IPv6):
                 if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE) || (hdrIndex == e_FM_PCD_HDR_INDEX_1))
                     return KG_SCH_GEN_L3_NO_V;
                 if ((hdrIndex == e_FM_PCD_HDR_INDEX_2) || (hdrIndex == e_FM_PCD_HDR_INDEX_LAST))
                     return KG_SCH_GEN_IP2_NO_V;
                 REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));
+		/* fall through */
             case (HEADER_TYPE_MINENCAP):
                 return KG_SCH_GEN_IP2_NO_V;
             case (HEADER_TYPE_USER_DEFINED_L3):
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Pcd/fm_manip.c
@@ -671,6 +671,7 @@ static t_Error BuildHmct(t_FmPcdManip *p
                         break;
                     case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP_LITE):
                         tmpReg = HMCD_INSRT_UDP_LITE;
+			/* fall through */
                     case (e_FM_PCD_MANIP_INSRT_BY_HDR_UDP):
                         tmpReg |= (uint32_t)(HMCD_OPCODE_UDP_INSRT)
                                 << HMCD_OC_SHIFT;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Port/fm_port.c
@@ -1394,6 +1394,7 @@ static t_Error SetPcd(t_FmPort *p_FmPort
             case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC):
             case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_CC_AND_PLCR):
                 tmpReg = NIA_KG_CC_EN;
+                /* fall through */
             case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG):
             case (e_FM_PORT_PCD_SUPPORT_PRS_AND_KG_AND_PLCR):
                 if (p_PcdParams->p_KgParams->directScheme)
@@ -2404,6 +2405,8 @@ t_Handle FM_PORT_Config(t_FmPortParams *
             WRITE_UINT32( p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp,
                          tmpReg);
 #endif /* FM_WRONG_RESET_VALUES_ERRATA_FMAN_A005127 */
+
+            /* fall through */
         case (e_FM_PORT_TYPE_TX_10G):
                 tmpReg =
                         GET_UINT32(p_FmPort->p_FmPortBmiRegs->txPortBmiRegs.fmbm_tfp);
@@ -2435,6 +2438,7 @@ t_Handle FM_PORT_Config(t_FmPortParams *
             p_FmPort->p_FmPortDriverParam->noScatherGather =
                     DEFAULT_PORT_noScatherGather;
 #endif /* (DPAA_VERSION >= 11) */
+            /* fall through */
         case (e_FM_PORT_TYPE_OH_HOST_COMMAND):
             p_FmPort->p_FmPortDriverParam->deqPrefetchOption =
                     DEFAULT_PORT_deqPrefetchOption_HC;
@@ -4270,6 +4274,7 @@ t_Error FM_PORT_ModifyCounter(t_Handle h
                 RETURN_ERROR(
                         MINOR, E_INVALID_STATE,
                         ("Requested counter is not available for Rx ports"));
+            /* fall through */
         case (e_FM_PORT_COUNTERS_ENQ_TOTAL):
             bmiCounter = FALSE;
             break;
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
@@ -4800,6 +4800,7 @@ uint32_t FM_GetCounter(t_Handle h_Fm, e_
     {
         case (e_FM_COUNTERS_DEQ_1):
         case (e_FM_COUNTERS_DEQ_2):
+            /* fall through */
         case (e_FM_COUNTERS_DEQ_3):
             if ((p_Fm->p_FmStateStruct->revInfo.majorRev == 4) ||
                 (p_Fm->p_FmStateStruct->revInfo.majorRev >= 6))
@@ -4807,12 +4808,14 @@ uint32_t FM_GetCounter(t_Handle h_Fm, e_
                 REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Requested counter not supported"));
                 return 0;
             }
+            /* fall through */
         case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
         case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
         case (e_FM_COUNTERS_DEQ_0):
         case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
         case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
         case (e_FM_COUNTERS_DEQ_FROM_FD):
+            /* fall through */
         case (e_FM_COUNTERS_DEQ_CONFIRM):
             if (!(GET_UINT32(p_Fm->p_FmQmiRegs->fmqm_gc) & QMI_CFG_EN_COUNTERS))
             {
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_ioctls_fm_compat.c
@@ -376,6 +376,7 @@ static inline void compat_copy_fm_pcd_cc
             case e_IOC_FM_PCD_DONE:
             case e_IOC_FM_PCD_PLCR:
                 param->manip_id = compat_pcd_id2ptr(compat_param->manip_id);
+		/* fall through */
             default:
                 memcpy(&param->params, &compat_param->params, sizeof(param->params));
         }
@@ -403,6 +404,7 @@ static inline void compat_copy_fm_pcd_cc
             case e_IOC_FM_PCD_DONE:
             case e_IOC_FM_PCD_PLCR:
                 compat_param->manip_id = compat_pcd_ptr2id(param->manip_id);
+		/* fall through */
             default:
                 memcpy(&compat_param->params, &param->params, sizeof(compat_param->params));
         }
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_sysfs_fm.c
@@ -1799,16 +1799,19 @@ int fm_get_counter(void *h_fm, e_FmCount
 	switch (cnt_e) {
 	case (e_FM_COUNTERS_DEQ_1):
 	case (e_FM_COUNTERS_DEQ_2):
+		/* fall through */
 	case (e_FM_COUNTERS_DEQ_3):
 		if (p_fm->p_FmStateStruct->revInfo.majorRev >= 6)
 			return -EINVAL; /* counter not available */
 
+		/* Else fall through */
 	case (e_FM_COUNTERS_ENQ_TOTAL_FRAME):
 	case (e_FM_COUNTERS_DEQ_TOTAL_FRAME):
 	case (e_FM_COUNTERS_DEQ_0):
 	case (e_FM_COUNTERS_DEQ_FROM_DEFAULT):
 	case (e_FM_COUNTERS_DEQ_FROM_CONTEXT):
 	case (e_FM_COUNTERS_DEQ_FROM_FD):
+		/* fall through */
 	case (e_FM_COUNTERS_DEQ_CONFIRM):
 		if (!(ioread32be(&p_fm->p_FmQmiRegs->fmqm_gc) &
 			QMI_CFG_EN_COUNTERS))
--- a/drivers/net/ethernet/mscc/ocelot_tsn.c
+++ b/drivers/net/ethernet/mscc/ocelot_tsn.c
@@ -752,7 +752,7 @@ static int streamid_multi_forward_set(st
 	u32 bucket;
 	u32 val;
 	int m, n, i;
-	u8 pgid_val, fwdport;
+	u8 pgid_val = 0, fwdport;
 	u32 dst_idx;
 
 	m_index = index / 4;
