wlan: Debug ROC if pConfig->debugP2pRemainOnChannel is set.

Added debug messages at start and cancel of remain on channel request
if pConfig->debugP2pRemainOnChannel configuration flag is set in
WCNSS_qcom_cfg.ini file. This helps in debugging ROC related issues.

CRs-Fixed: 600438
Change-Id: Id2905594513253ad0b26b24668e18e925e41c710
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index 81b7f27..a58ed13 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -101,7 +101,7 @@
                                   tANI_BOOLEAN actionSendSuccess );
 
 static void hdd_sendMgmtFrameOverMonitorIface( hdd_adapter_t *pMonAdapter,
-                                               tANI_U32 nFrameLength, 
+                                               tANI_U32 nFrameLength,
                                                tANI_U8* pbFrames,
                                                tANI_U8 frameType );
 
@@ -154,8 +154,11 @@
           "%s: No Rem on channel pending for which Rsp is received", __func__);
        return eHAL_STATUS_SUCCESS;
     }
-
-    hddLog( LOG1, "Received remain on channel rsp");
+    hddLog( VOS_TRACE_LEVEL_INFO,
+            "Received ROC rsp (request type %d, channel %d, cookie %llu",
+            pRemainChanCtx->rem_on_chan_request,
+            pRemainChanCtx->chan.center_freq,
+            pRemainChanCtx->cookie);
 
     cfgState->remain_on_chan_ctx = NULL;
     if( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request &&
@@ -163,7 +166,7 @@
     {
         if( cfgState->buf )
         {
-           hddLog( LOGP, 
+           hddLog( LOGE,
                    "%s: We need to receive yet an ack from one of tx packet",
                    __func__);
         }
@@ -220,7 +223,9 @@
 
     if(cfgState->remain_on_chan_ctx != NULL)
     {
-        hddLog( LOG1, "Cancel Existing Remain on Channel");
+        hddLog(VOS_TRACE_LEVEL_INFO,
+               "Cancel Existing ROC (cookie=%llu)",
+                cfgState->remain_on_chan_ctx->cookie);
 
         /* Wait till remain on channel ready indication before issuing cancel 
          * remain on channel request, otherwise if remain on channel not 
@@ -288,7 +293,8 @@
         }
         else
         {
-           hddLog( LOG1, "Cannot Cancel Existing Remain on Channel");
+           hddLog(VOS_TRACE_LEVEL_DEBUG,
+                   "Cannot Cancel Existing Remain on Channel");
            status = -EBUSY;
         }
      }
@@ -308,17 +314,20 @@
     hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
     hdd_remain_on_chan_ctx_t *pRemainChanCtx;
     hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
+
     hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
                                  __func__,pAdapter->device_mode);
-
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
-    hddLog( LOG1,
-        "chan(hw_val)0x%x chan(centerfreq) %d chan type 0x%x, duration %d",
-        chan->hw_value, chan->center_freq, channel_type, duration );
+    hddLog(VOS_TRACE_LEVEL_INFO,
+           "chan(hw_val)0x%x chan(centerfreq) %d chan type 0x%x, dur %d,"
+           " request type %d, cookie %llu",
+           chan->hw_value, chan->center_freq, channel_type, duration,
+           request_type, *cookie);
 #else
-    hddLog( LOG1,
-        "chan(hw_val)0x%x chan(centerfreq) %d, duration %d",
-        chan->hw_value, chan->center_freq, duration );
+     hddLog(VOS_TRACE_LEVEL_INFO,
+            "chan(hw_val)0x%x chan(centerfreq) %d, duration %d"
+            " reuest type %d, cookie %llu", chan->hw_value, chan->center_freq,
+            duration, request_type, *cookie );
 #endif
     //Cancel existing remain On Channel if any
     wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
@@ -374,16 +383,21 @@
         tANI_U8 sessionId = pAdapter->sessionId;
         //call sme API to start remain on channel.
         sme_RemainOnChannel(
-                       WLAN_HDD_GET_HAL_CTX(pAdapter), sessionId,
-                       chan->hw_value, duration,
-                       wlan_hdd_remain_on_channel_callback, pAdapter,
-                       (tANI_U8)(request_type == REMAIN_ON_CHANNEL_REQUEST)? TRUE:FALSE);
+             WLAN_HDD_GET_HAL_CTX(pAdapter), sessionId,
+             chan->hw_value, duration,
+             wlan_hdd_remain_on_channel_callback, pAdapter,
+             (tANI_U8)(request_type == REMAIN_ON_CHANNEL_REQUEST)? TRUE:FALSE);
 
         if( REMAIN_ON_CHANNEL_REQUEST == request_type)
         {
-            sme_RegisterMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
-                                   sessionId, (SIR_MAC_MGMT_FRAME << 2) |
-                                  (SIR_MAC_MGMT_PROBE_REQ << 4), NULL, 0 );
+            if( eHAL_STATUS_SUCCESS != sme_RegisterMgmtFrame(
+                                      WLAN_HDD_GET_HAL_CTX(pAdapter),
+                                      sessionId, (SIR_MAC_MGMT_FRAME << 2) |
+                                      (SIR_MAC_MGMT_PROBE_REQ << 4), NULL, 0 ))
+            {
+                hddLog(VOS_TRACE_LEVEL_ERROR,
+                       "sme_RegisterMgmtFrame returned fail");
+            }
         }
 
     }
@@ -455,8 +469,6 @@
     hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
     hdd_remain_on_chan_ctx_t* pRemainChanCtx = cfgState->remain_on_chan_ctx;
 
-    hddLog( LOG1, "Ready on chan ind");
-
     if( pRemainChanCtx != NULL )
     {
         // Removing READY_EVENT_PROPOGATE_TIME from current time which gives
@@ -485,6 +497,8 @@
             complete(&pAdapter->offchannel_tx_event);
         }
 #endif
+        hddLog( VOS_TRACE_LEVEL_INFO, "Ready on chan ind (cookie=%llu)",
+                pRemainChanCtx->cookie);
         complete(&pAdapter->rem_on_chan_ready_event);
     }
     else
@@ -510,8 +524,6 @@
     hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
     int status;
 
-    hddLog( LOG1, "Cancel remain on channel req");
-
     status = wlan_hdd_validate_context(pHddCtx);
 
     if (0 != status)
@@ -520,6 +532,8 @@
                    "%s: HDD context is not valid", __func__);
         return status;
     }
+    hddLog( LOG1, "Cancel remain on channel req (cookie = %llu)", cookie);
+
     /* FIXME cancel currently running remain on chan.
      * Need to check cookie and cancel accordingly
      */
@@ -813,11 +827,16 @@
            (cfgState->current_freq == chan->center_freq)
           )
         {
-            hddLog(LOG1,"action frame: extending the wait time");
             extendedWait = (tANI_U16)wait;
+            hddLog(VOS_TRACE_LEVEL_INFO,
+                   "action frame: extending the wait time %u",
+                   wait);
             goto send_frame;
         }
 
+        hddLog(VOS_TRACE_LEVEL_INFO,
+               "action frame: Request ROC for wait time %u", wait);
+
         INIT_COMPLETION(pAdapter->offchannel_tx_event);
 
         status = wlan_hdd_request_remain_on_channel(wiphy, dev,
@@ -906,16 +925,16 @@
                 (buf[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET] == WLAN_HDD_PUBLIC_ACTION_FRAME))
         {
             actionFrmType = buf[WLAN_HDD_PUBLIC_ACTION_FRAME_TYPE_OFFSET];
-            hddLog(LOG1, "Tx Action Frame %u", actionFrmType);
+            hddLog(LOG1, "Tx Action Frame %u.", actionFrmType);
             if (actionFrmType == WLAN_HDD_PROV_DIS_REQ)
             {
                 cfgState->actionFrmState = HDD_PD_REQ_ACK_PENDING;
-                hddLog(LOG1, "%s: HDD_PD_REQ_ACK_PENDING", __func__);
+                hddLog(LOG1, "%s: HDD_PD_REQ_ACK_PENDING.", __func__);
             }
             else if (actionFrmType == WLAN_HDD_GO_NEG_REQ)
             {
                 cfgState->actionFrmState = HDD_GO_NEG_REQ_ACK_PENDING;
-                hddLog(LOG1, "%s: HDD_GO_NEG_REQ_ACK_PENDING", __func__);
+                hddLog(LOG1, "%s: HDD_GO_NEG_REQ_ACK_PENDING.", __func__);
             }
         }
 #ifdef WLAN_FEATURE_11W
diff --git a/CORE/MAC/src/pe/lim/limApi.c b/CORE/MAC/src/pe/lim/limApi.c
index c7ac83b..ce207db 100644
--- a/CORE/MAC/src/pe/lim/limApi.c
+++ b/CORE/MAC/src/pe/lim/limApi.c
@@ -633,6 +633,15 @@
        return eSIR_FAILURE;
    }
 #endif
+   if (eSIR_SUCCESS !=
+       wlan_cfgGetInt(pMac, WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL,
+                      (tANI_U32 *)&pMac->lim.gDebugP2pRemainOnChannel))
+    {
+        limLog( pMac, LOGE,
+                "%s: Couldn't get WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL value",
+                 __func__);
+        pMac->lim.gDebugP2pRemainOnChannel = 0;
+   }
    return eSIR_SUCCESS;
 }
 
diff --git a/CORE/MAC/src/pe/lim/limP2P.c b/CORE/MAC/src/pe/lim/limP2P.c
index bd20e07..ae92a9b 100644
--- a/CORE/MAC/src/pe/lim/limP2P.c
+++ b/CORE/MAC/src/pe/lim/limP2P.c
@@ -286,7 +286,7 @@
                                         MsgRemainonChannel,
                                         REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME) )
             {
-                limLog( pMac, LOG1,
+                limLog( pMac, LOGE,
                         "%s: Successfully sent 2nd Marker frame "
                         "seq num = %d on start ROC", __func__,
                         pMac->lim.remOnChnSeqNum);
@@ -556,16 +556,6 @@
                   "%s: remain on channel Timer Start Failed", __func__);
         goto error;
     }
-
-    if (eSIR_SUCCESS !=
-        wlan_cfgGetInt(pMac, WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL,
-                       (tANI_U32 *)&pMac->lim.gDebugP2pRemainOnChannel))
-    {
-        limLog( pMac, LOGE,
-                "%s: Couldn't get WNI_CFG_DEBUG_P2P_REMAIN_ON_CHANNEL value",
-                 __func__);
-        pMac->lim.gDebugP2pRemainOnChannel = 0;
-    }
     if (pMac->lim.gDebugP2pRemainOnChannel)
     {
         pMac->lim.remOnChnSeqNum++;
@@ -573,7 +563,7 @@
                                      pMac, MsgRemainonChannel,
                                      REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME) )
         {
-            limLog( pMac, LOG1,
+            limLog( pMac, LOGE,
                     "%s: Successfully sent 1st marker frame with seq num = %d"
                     " on start ROC", __func__, pMac->lim.remOnChnSeqNum);
         }
@@ -678,7 +668,7 @@
                                       pMac,
                                       REMAIN_ON_CHANNEL_SECOND_MARKER_FRAME))
         {
-            limLog( pMac, LOG1,
+            limLog( pMac, LOGE,
                     "%s: Successfully sent 2nd marker frame with seq num=%d"
                     " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
         }
@@ -723,7 +713,7 @@
                                         pMac,
                                         REMAIN_ON_CHANNEL_FIRST_MARKER_FRAME))
         {
-            limLog( pMac, LOG1,
+            limLog( pMac, LOGE,
                     "%s: Successfully sent 1st marker frame with seqnum = %d"
                     " on cancel ROC", __func__, pMac->lim.remOnChnSeqNum);
         }
@@ -806,6 +796,8 @@
         return;
     }
 
+    limLog( pMac, LOG1, "Remain on channel rsp with status %d", status);
+
     //Incase of the Remain on Channel Failure Case
     //Cleanup Everything
     if(eHAL_STATUS_FAILURE == status)
@@ -836,7 +828,7 @@
     }
 
     /* Post the meessage to Sme */
-    limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status, 
+    limSendSmeRsp(pMac, eWNI_SME_REMAIN_ON_CHN_RSP, status,
                   MsgRemainonChannel->sessionId, 0);
 
     vos_mem_free(pMac->lim.gpLimRemainOnChanReq);
@@ -848,6 +840,8 @@
      * indicaiton confirmation with status failure */
     if (pMac->lim.mgmtFrameSessionId != 0xff)
     {
+       limLog(pMac, LOGE,
+              FL("Remain on channel expired, Action frame status failure"));
        limP2PActionCnf(pMac, 0);
     }
 
@@ -962,6 +956,9 @@
 
 eHalStatus limP2PActionCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
 {
+    limLog(pMac, LOG1,
+              FL(" %s txCompleteSuccess %d, Session Id %d"),
+              __func__, txCompleteSuccess, pMac->lim.mgmtFrameSessionId);
     if (pMac->lim.mgmtFrameSessionId != 0xff)
     {
         /* The session entry might be invalid(0xff) action confirmation received after
@@ -1341,6 +1338,7 @@
     {
         //TODO check for state and take appropriate actions
         limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
+        limLog( pMac, LOG1, FL("Abort ROC !!!" ));
         limProcessRemainOnChnTimeout(pMac);
     }
     return;
diff --git a/CORE/SME/src/p2p/p2p_Api.c b/CORE/SME/src/p2p/p2p_Api.c
index 78f6b9d..16a9854 100644
--- a/CORE/SME/src/p2p/p2p_Api.c
+++ b/CORE/SME/src/p2p/p2p_Api.c
@@ -776,7 +776,13 @@
 #endif
     } while(0);
   
-    smsLog(pMac, LOGW, "exiting function %s", __func__);
+    smsLog(pMac, LOGW, "%s: status %d",
+#ifdef WLAN_FEATURE_P2P_INTERNAL
+           " for reason = %d" __func__, status, reason
+#else
+           __func__, status
+#endif
+    );
   
     return(status);
 }
@@ -1070,7 +1076,8 @@
    tpAniSirGlobal pMac = PMAC_STRUCT( p2pContext->hHal );
 
    p2pContext->PeerFound = TRUE;
-   smsLog( pMac, LOGE, "%s Calling remain on channel ", __func__);
+   smsLog( pMac, LOGE, "%s Calling remain on channel to Resend Action Frame ",
+           __func__);
    status = p2pRemainOnChannel( pMac, p2pContext->SMEsessionId, p2pContext->P2PListenChannel/*pScanResult->BssDescriptor.channelId*/, P2P_REMAIN_ON_CHAN_TIMEOUT_LOW,
                                     NULL, NULL, TRUE, eP2PRemainOnChnReasonSendFrame);
    if(status != eHAL_STATUS_SUCCESS)