[BugFix][API-1252]check fw reinit status&when checked reinit count not 0 do down/up

Only Configure

Affected branch:MR3.0-xx && GSW3.0

Affected module:wifi

Is it addected on both ZXIC and MTK: only MTK

Self-test: Yes

Doc Update: YES

Change-Id: I091941772da7b8b74c2e348016540816c68846be
diff --git a/lib/liblynq-wifi6/libwifi6.c b/lib/liblynq-wifi6/libwifi6.c
index 3f0ad4d..3657a6f 100755
--- a/lib/liblynq-wifi6/libwifi6.c
+++ b/lib/liblynq-wifi6/libwifi6.c
@@ -653,6 +653,65 @@
     }
 }
 
+/*
+eg: wl counters info
+sh-3.2# wl counters
+counters_version 30
+datalen 1648
+Slice_index: 0
+reinitreason_counts: 0(0) 1(0) 2(3) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(2) 15(0) 16(0) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0)
+reinit 0 reset 2 pciereset 0 cfgrestore 0 dma_hang 0 ampdu_wds 0
+
+check reinit status
+return 0 ===> fw did wl reinit cmd
+*/
+static int check_current_reinit_info()
+{
+    FILE *fp;
+    int ret;
+    char lynq_cmd_ret[MAX_RET]={0};
+    char * dest;
+    char destid[3]={0};
+    if((fp=popen("wl counters","r"))==NULL)
+    {
+        perror("popen error!");
+        return -1;
+    }
+    if((fread(lynq_cmd_ret,sizeof(lynq_cmd_ret),1,fp))<0)
+    {
+        perror("fread fail!");
+        if(pclose(fp) == -1)
+        {
+           perror("close fp file faild");
+        }
+        return -1;
+    }
+    dest = strstr(lynq_cmd_ret,"reinit ");
+    if(dest != NULL)
+    {
+        dest +=strlen("reinit ");
+        RLOGD("current get dest str is %s",dest);
+        memcpy(destid,dest,2);
+        ret = atoi(destid);
+        RLOGD("get current wl counters cmd return counts is %d",ret);
+        if( ret != 0 )
+        {
+            RLOGD("current fw did run cmd wl reinit");
+            if( pclose(fp) == -1 )
+            {
+                perror("close fp file faild");
+            }
+            return 0;
+        }
+    }
+    if( pclose(fp) == -1 )
+    {
+       perror("close fp file faild");
+    }
+    RLOGD("current fw didn't run cmd wl reinit,dest ptr is NULL");
+    return -1;
+}
+
 static void APTmpWatcherThreadProc() {
 
     int i = 0;
@@ -664,6 +723,16 @@
     {
         sleep(1);
         i++;
+        if ( (i % 30) == 0 )
+        {
+            if ( check_current_reinit_info() == 0 )
+            {
+                system("wl reset_cnts");
+                system("wl down");
+                system("wl up");
+                RLOGD("APTmpWatcherThreadProc:check fw did reinit cmd,do down/up reset");
+            }
+        }
         if ( i == delytime )
         {
             if( lynq_connected_ap_sta_status() == 0 )      //o --->no sta device connect this ap