Update to SDK_2.7.25-RC13

        rm -rf *
        cp -prf ~/marvel/kernel.rc13/* .
        git add -Af .
        git commit

Change-Id: I8af78675ba0575de3d62ae19514a847dc2461c03
diff --git a/arch/arm/mach-feroceon-kw2/include/mach/system.h b/arch/arm/mach-feroceon-kw2/include/mach/system.h
index b0e8e4c..99d4c0b 100755
--- a/arch/arm/mach-feroceon-kw2/include/mach/system.h
+++ b/arch/arm/mach-feroceon-kw2/include/mach/system.h
@@ -31,7 +31,7 @@
 	cpu_do_idle();
 }
 
-#define UPON_SDK_VERSION "uPON_2.7.25_RC11"
+#define UPON_SDK_VERSION "uPON_2.7.25_RC13"
 
 #ifdef __BIG_ENDIAN
 #define MV_ARM_32BIT_LE(X) ((((X)&0xff)<<24) |                       \
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuAlloc.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuAlloc.c
index 5442fac..07b9ca5 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuAlloc.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuAlloc.c
@@ -721,7 +721,7 @@
                "DEBUG: (%s:%d) release All T-Conts buffers, tpm_deactive_tcont\n", __FILE_DESC__, __LINE__);
 #endif /* MV_GPON_DEBUG_PRINT */
 
-    printk("TCONT flush, FreeAllBuffers\n");
+    //printk("TCONT flush, FreeAllBuffers\n");
     status = onuGponWqTcontFlush(tcontNum);
     if (status != MV_OK)
     {
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuApi.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuApi.c
index 4122161..2a99b3b 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuApi.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuApi.c
@@ -177,13 +177,13 @@
         return rcode;
     }
 
-  rcode = onuGponSrvcRangingRandomInit();
+  /*rcode = onuGponSrvcRangingRandomInit();
   if (rcode != MV_OK)
   {
     mvPonPrint(PON_PRINT_ERROR, PON_API_MODULE,
                "ERROR: (%s:%d) onuGponRangingRandomInit", __FILE_DESC__, __LINE__);
     return rcode;
-  }
+  }*/
 
   if (disabled == MV_TRUE)
   {
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuInit.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuInit.c
index 5fef02d..b8cf3b7 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuInit.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuInit.c
@@ -275,6 +275,7 @@
   MV_U32    equalizationDelay;
   MV_U32    constDelay;
   MV_U32    snForRandomSeed;
+  MV_U32    randomRange[2];
   MV_U8     sn[8];
 
 
@@ -313,10 +314,20 @@
     return(rcode);
   }
 
+  rcode = onuGponSrvcRangingRandomInit();
+  if (rcode != MV_OK)
+  {
+    mvPonPrint(PON_PRINT_ERROR, PON_INIT_MODULE,
+                       "ERROR: (%s:%d) onuGponRangingRandomInit", __FILE_DESC__, __LINE__);
+    return (rcode);
+  }
+
+  get_random_bytes((void*)randomRange, sizeof(randomRange));
+
   /* Update two last bytes of Serial Number -Help Asic generate Random numbers
      for S/N Request answer delay */
   onuGponDbSerialNumGet(sn);
-  snForRandomSeed = sn[7] + (MV_U32)(sn[6] << 8);
+  snForRandomSeed = (MV_U32)(randomRange[1] & 0xFF) + (MV_U32)((randomRange[0] & 0xFF) << 8);
   rcode = mvOnuGponMacSerialNumberSet(snForRandomSeed);
   if (rcode != MV_OK)
   {
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngr.h b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngr.h
index d63cf1d..876cf5b 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngr.h
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngr.h
@@ -78,7 +78,7 @@
 

 /* Include Files

 ------------------------------------------------------------------------------*/

- 

+

 /* Definitions

 ------------------------------------------------------------------------------*/ 

 /* Disable Message disable/Enable Options */

@@ -90,8 +90,8 @@
 #define TIMER_T01_EXPIRE            (1)

 #define TIMER_T02_EXPIRE            (2)

 #define TIMER_PEE_EXPIRE            (3)

-                                   

-/* stats sub types */              

+

+/* stats sub types */

 #define STATS_ACCMULATE             (1)

 #define STATS_RESET                 (2)

 #define STATS_SHOW                  (3)

@@ -150,6 +150,7 @@
 /* State Machine Functions */

 void      onuGponPonMngPloamProcess(MV_U8 onuId, MV_U8 msgId, MV_U8 *msgData);

 

+void 	  onuGponPonMngRandomDelayGen4SN_Equ(void);

 void      onuGponPonMngIsrNotExpected(MV_U8 onuId, MV_U8 msgId, MV_U8 *msgData);

 void      onuGponPonMngOverheadMsg(MV_U8 onuId, MV_U8 msgId, MV_U8 *msgData);

 void      onuGponPonMngSerialNumberMaskMsg(MV_U8 onuId, MV_U8 msgId, MV_U8 *msgData);

diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngrStateMachine.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngrStateMachine.c
index f645b34..3661623 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngrStateMachine.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuMngrStateMachine.c
@@ -83,6 +83,8 @@
 /* Local Constant
 ------------------------------------------------------------------------------*/
 #define __FILE_DESC__ "mv_pon/core/gpon/gponOnuStateMachine.c"
+#define CLEAR_BUFFER_EN   (1)
+#define CLEAR_BUFFER_DIS  (0)
 
 /* Global Variables
 ------------------------------------------------------------------------------*/
@@ -94,6 +96,9 @@
 DISABLESTATSETFUNC g_onuGponDisableFunc = NULL;
 MV_BOOL            g_periodicTimerState = MV_FALSE;
 MV_U32             g_overheadPreAssignDelayForPopup = 0;
+MV_U32			   randomRange[2];
+MV_U32			   randomVal;
+
 /* Export Functions
 ------------------------------------------------------------------------------*/
 extern MV_STATUS onuGponAllocIdMacAdd(MV_U32 allocId, MV_U32 tcontId);
@@ -101,8 +106,8 @@
 /* Local Functions
 ------------------------------------------------------------------------------*/
 MV_STATUS onuGponPonMngrUpdateState(MV_U32 newState);
-MV_STATUS onuGponPonMngClearOnuInfo(void);
-MV_STATUS onuGponPonMngClearOnuBuffers(void);
+MV_STATUS onuGponPonMngClearOnuInfo(MV_U32 flag);
+MV_STATUS onuGponPonMngClearOnuBuffers(MV_U32 flag);
 MV_STATUS onuGponPonMngClearOnuTconts(void);
 MV_STATUS onuGponPonMngClearOnuPorts(void);
 MV_STATUS onuGponPonMngClearOnuId(void);
@@ -240,17 +245,20 @@
 **
 **  DESCRIPTION: The function reset onu buffers to its default state
 **
-**  PARAMETERS:  None
+**  PARAMETERS:  MV_U32 flag
 **
 **  OUTPUTS:     None
 **
 **  RETURNS:     MV_OK or error
 **
 *******************************************************************************/
-MV_STATUS onuGponPonMngClearOnuBuffers(void)
+MV_STATUS onuGponPonMngClearOnuBuffers(MV_U32 flag)
 {
    MV_STATUS rcode;
 
+   if (flag != CLEAR_BUFFER_EN)
+     return(MV_OK);
+
    rcode = onuGponAllocIdFreeAllBuffers();
    if (rcode != MV_OK)
    {
@@ -269,14 +277,14 @@
 **  DESCRIPTION: The function reset onu information to its default state:
 **               asic & application
 **
-**  PARAMETERS:  None
+**  PARAMETERS:  MV_U32 flag
 **
 **  OUTPUTS:     None
 **
 **  RETURNS:     MV_OK or error
 **
 *******************************************************************************/
-MV_STATUS onuGponPonMngClearOnuInfo(void)
+MV_STATUS onuGponPonMngClearOnuInfo(MV_U32 flag)
 {
   MV_STATUS rcode;
 
@@ -294,7 +302,7 @@
                "ERROR: (%s:%d) onuGponPonMngClearOnuTconts\n", __FILE_DESC__, __LINE__);    return(rcode);
   }
 
-  rcode = onuGponPonMngClearOnuBuffers();
+  rcode = onuGponPonMngClearOnuBuffers(flag);
   if (rcode != MV_OK)
   {
     mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
@@ -580,6 +588,37 @@
 
 /*******************************************************************************
 **
+**  onuGponPonMngRandomDelayGen4SN_Equ
+**  ____________________________________________________________________________
+**
+**  DESCRIPTION: The function is called by PM task to generate random number
+**
+**  PARAMETERS:  None
+**
+**  OUTPUTS:     None
+**
+**  RETURNS:     None
+**
+*******************************************************************************/
+void onuGponPonMngRandomDelayGen4SN_Equ(void)
+{
+  static MV_U8 randomIndex = 0;
+  MV_U8 randomLeft;
+  MV_U8 randomRight;
+
+  randomIndex++;
+
+  if (randomIndex > 24) randomIndex = 0;
+
+  randomLeft  = randomIndex;
+  randomRight = 24 - randomIndex;
+
+  get_random_bytes((void*)randomRange, sizeof(randomRange));
+  randomVal = (((randomRange[0] >> randomLeft) & 0xDF) ^ ((randomRange[1] >> randomRight) & 0xDF));
+}
+
+/*******************************************************************************
+**
 **  onuGponPonMngOverheadMsg
 **  ____________________________________________________________________________
 **
@@ -617,7 +656,6 @@
   MV_U32    extendedPreambleOperSize;
   MV_BOOL   extendedBurstOverride;
   MV_BOOL   delimiterOverride;
-  MV_U32    randomRange[2];
 
 #ifdef MV_GPON_PERFORMANCE_CHECK
   S_GponPerformanceCheckNode *tmpPmCheckNode = &(g_GponPmCheck.pmCheckNode[PON_OVERHEAD_PLOAM_PERFORMANCE]);
@@ -697,7 +735,6 @@
       onuGponDbDelimiterSet (ONU_GPON_DELM_BYTE_02, (MV_U32)delimiterByte_02);
       onuGponDbDelimiterSet (ONU_GPON_DELM_BYTE_03, (MV_U32)delimiterByte_03);
       onuGponDbDelimiterSizeSet (GPON_TX_DELIMITER_DS);
-
     }
     else
     {
@@ -707,7 +744,6 @@
       onuGponDbDelimiterSet (ONU_GPON_DELM_BYTE_01, (delimiter & 0xFF));
       onuGponDbDelimiterSet (ONU_GPON_DELM_BYTE_02, (delimiter >> 8)& 0xFF);
       onuGponDbDelimiterSet (ONU_GPON_DELM_BYTE_03, (delimiter >> 16)& 0xFF);
-
     }
 
     mvOnuGponMacTxDelimiterSet(delimiter, GPON_TX_DELIMITER_DS);
@@ -746,10 +782,7 @@
       finalDelay        = M_ONU_GPON_RANG_MSG_FINAL_DELAY(preAssignDelayTemp);
       equalizationDelay = M_ONU_GPON_RANG_MSG_EQUAL_DELAY(preAssignDelayTemp);
 
-      /* update asic */
-      get_random_bytes((void*)randomRange, sizeof(randomRange));
-
-      equalizationDelay += ((randomRange[0] & 0x7F) + (randomRange[1] & 0x3F) + 24) * 32;
+      equalizationDelay += randomVal * 32;
 
       rcode = mvOnuGponMacRxEqualizationDelaySet(equalizationDelay);
       if (rcode != MV_OK)
@@ -761,7 +794,7 @@
       }
 
       /* update asic */
-      finalDelay |= (MV_U32)GPON_TX_FINAL_DELAY_FD;
+      finalDelay += (MV_U32)GPON_TX_FINAL_DELAY_FD;
 
       rcode = mvOnuGponMacTxFinalDelaySet(finalDelay);
       if (rcode != MV_OK)
@@ -772,6 +805,14 @@
         return;
       }
 
+	    rcode = onuGponPonMngrUpdateState((MV_U32)ONU_GPON_03_SERIAL_NUM);
+      if (rcode != MV_OK)
+      {
+        mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
+                   "ERROR: (%s:%d) onuGponPonMngrUpdateState(3)\n", __FILE_DESC__, __LINE__);
+        return;
+      }
+
       /* update database */
       onuGponDbEqualizationDelaySet(preAssignDelay);
 
@@ -796,13 +837,13 @@
 
   /* Before changing state check SN_Mask VALUE and serialNumberMaskDefaultStateFlag mode.
   ** Add Support for HW and SW state machine */
-  rcode = onuGponPonMngrUpdateState((MV_U32)ONU_GPON_03_SERIAL_NUM);
-  if (rcode != MV_OK)
-  {
-    mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
-               "ERROR: (%s:%d) onuGponPonMngrUpdateState(3)\n", __FILE_DESC__, __LINE__);
-    return;
-  }
+  //rcode = onuGponPonMngrUpdateState((MV_U32)ONU_GPON_03_SERIAL_NUM);
+  //if (rcode != MV_OK)
+  //{
+  //  mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
+  //             "ERROR: (%s:%d) onuGponPonMngrUpdateState(3)\n", __FILE_DESC__, __LINE__);
+  //  return;
+  //}
 
 #ifdef MV_GPON_PERFORMANCE_CHECK
   asicOntGlbRegReadNoCheck(mvAsicReg_GPON_GEN_MICRO_SEC_CNT,
@@ -1372,7 +1413,7 @@
 
   /* clear onu information */
   /* ===================== */
-  rcode = onuGponPonMngClearOnuInfo();
+  rcode = onuGponPonMngClearOnuInfo(CLEAR_BUFFER_EN);
   if (rcode != MV_OK)
   {
     mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
@@ -1468,7 +1509,7 @@
 
 		/* clear onu information */
 		/* ===================== */
-		rcode = onuGponPonMngClearOnuInfo();
+		rcode = onuGponPonMngClearOnuInfo(CLEAR_BUFFER_EN);
 		if (rcode != MV_OK) {
 			mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
 					   "ERROR: (%s:%d) DISABLE: onuGponPonMngClearOnuInfo\n", __FILE_DESC__, __LINE__);
@@ -2619,6 +2660,16 @@
              "DEBUG: (%s:%d) TIMER TO1 Expired, state(%d)\n", __FILE_DESC__, __LINE__, onuGponDbOnuStateGet());
 #endif /* MV_GPON_DEBUG_PRINT */
 
+  /* clear onu information */
+  /* ===================== */
+  rcode = onuGponPonMngClearOnuInfo(CLEAR_BUFFER_EN);
+  if (rcode != MV_OK)
+  {
+    mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
+               "ERROR: (%s:%d) onuGponPonMngClearOnuInfo\n", __FILE_DESC__, __LINE__);
+    return;
+  }
+
   /* state handling */
   /* ============== */
   rcode = onuGponPonMngrUpdateState((MV_U32)ONU_GPON_02_STANDBY);
@@ -2629,16 +2680,6 @@
     return;
   }
 
-  /* clear onu information */
-  /* ===================== */
-  rcode = onuGponPonMngClearOnuInfo();
-  if (rcode != MV_OK)
-  {
-    mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
-               "ERROR: (%s:%d) onuGponPonMngClearOnuInfo\n", __FILE_DESC__, __LINE__);
-    return;
-  }
-
   /* alarm handling */
   /* ============== */
   onuGponAlarmSet(ONU_GPON_ALARM_SUF, ONU_GPON_ALARM_ON);
@@ -2704,7 +2745,7 @@
 
   /* clear onu information */
   /* ===================== */
-  rcode = onuGponPonMngClearOnuInfo();
+  rcode = onuGponPonMngClearOnuInfo(CLEAR_BUFFER_EN);
   if (rcode != MV_OK)
   {
     mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
@@ -2888,7 +2929,7 @@
 
     /* clear onu information */
     /* ===================== */
-    rcode = onuGponPonMngClearOnuInfo();
+    rcode = onuGponPonMngClearOnuInfo(CLEAR_BUFFER_EN);
     if (rcode != MV_OK)
     {
       mvPonPrint(PON_PRINT_ERROR, PON_SM_MODULE,
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuPm.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuPm.c
index a0eae0b..4c78db0 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuPm.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuPm.c
@@ -208,6 +208,7 @@
   S_RxBip8Pm inBip8Pm;
   unsigned long flags;
 
+	onuGponPonMngRandomDelayGen4SN_Equ();
   onuGponPmCountersAdd();
   onuGponPmRxBip8PmGet(&inBip8Pm);
   spin_lock_irqsave(&onuPonIrqLock, flags);
diff --git a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuSrvc.c b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuSrvc.c
index 044f589..2fbebb1 100755
--- a/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuSrvc.c
+++ b/arch/arm/plat-feroceon/mv_drivers_lsp/mv_pon/core/gpon/gponOnuSrvc.c
@@ -1084,6 +1084,7 @@
 

   for (tmp_size=0; tmp_size<5; tmp_size++) 

   {

+    printk("INFO: input - type 0x%x code 0x%x, value 0x%x\n", randomType, randomCode, randomInternalDelayKey[tmp_size]);      

     add_input_randomness(randomType, randomCode, randomInternalDelayKey[tmp_size]);

   }

 

@@ -1304,12 +1305,12 @@
     MV_STATUS rcode;

 

     if (tcont != 0xFF)

-	rcode = queue_work(gponTcontFlushWq.ponWq, (struct work_struct *)&gponTcontCleanWork[tcont]);

+    	rcode = queue_work(gponTcontFlushWq.ponWq, (struct work_struct *)&gponTcontCleanWork[tcont]);

     else

         rcode = queue_work(gponTcontFlushWq.ponWq, (struct work_struct *)&gponTcontCleanAllWork);

 

     if(rcode == 0)

-	return(MV_ERROR);

+    	return(MV_ERROR);

 

     return(MV_OK);

 }

@@ -1336,7 +1337,7 @@
     rcode = queue_work(gponTcontFlushWq.ponWq, (struct work_struct *)&gponTcontActiveWork[tcont]);

     if(rcode == 0)

         return(MV_ERROR);

-

+    

     return(MV_OK);

 }

 

@@ -1373,12 +1374,12 @@
 	{

 	   onuGponTcontFlushState[tcont] = TCONT_FLUSH_BLOCKING_STATE;

 	   tpm_deactive_tcont(tcont);

-	   printk("TCONT (%d) CLEAN_EVENT\n", tcont);

+	   //printk("TCONT (%d) CLEAN_EVENT\n", tcont);

 	   onuGponTcontFlushState[tcont] = TCONT_FLUSH_READY_STATE;

 	}

 	else

 	{

-	   printk("Received TCONT_CLEAN_EVENT while in T-CONT(%d) state(%s)\n", tcont, stateText[onuGponTcontFlushState[tcont]]);

+	    //printk("Received TCONT_CLEAN_EVENT while in T-CONT(%d) state(%s)\n", tcont, stateText[onuGponTcontFlushState[tcont]]);

 	}

     }

 

@@ -1392,12 +1393,12 @@
 	    {

 	       onuGponTcontFlushState[tcont] = TCONT_FLUSH_BLOCKING_STATE;

 	       tpm_deactive_tcont(tcont);

-	       printk("TCONT (%d) CLEAN_EVENT\n", tcont);

+	       //printk("TCONT (%d) CLEAN_EVENT\n", tcont);

 	       onuGponTcontFlushState[tcont] = TCONT_FLUSH_READY_STATE;

 	    }

 	    else

 	    {

-	       printk("Received TCONT_CLEAN_EVENT while in T-CONT(%d) state(%s)\n", tcont, stateText[onuGponTcontFlushState[tcont]]);

+		//printk("Received TCONT_CLEAN_EVENT while in T-CONT(%d) state(%s)\n", tcont, stateText[onuGponTcontFlushState[tcont]]);

 	    }

 	}

     }

@@ -1410,11 +1411,11 @@
        {

           onuGponTcontFlushState[tcont] = TCONT_FLUSH_RUNNING_STATE;

           tpm_active_tcont(tcont);

-          printk("TCONT (%d) ACTIVE_EVENT\n", tcont);

+          //printk("TCONT (%d) ACTIVE_EVENT\n", tcont);

        }

        else

        {

-           printk("Received TCONT_ACTIVE_EVENT while in T-CONT state(%s)\n", stateText[onuGponTcontFlushState[tcont]]);

+           //printk("Received TCONT_ACTIVE_EVENT while in T-CONT state(%s)\n", stateText[onuGponTcontFlushState[tcont]]);

        }

     }