wlan: Fix for DUT not sending 11k beacon report

This is a regression issue caused by CCX Upload change, in
which if the CCX upload is defined DUT alway sends beacon report
to upper layer (wpa_supplicant) even though the beacon request
initiated by 11k RRM. There is no run time check done to differenciate
who triggered beacon request, as CCX, 11k and upload approach uses
RRM scanning as a common code.

The fix for this issue is to difference which module initiated
beacon request based on the message source and forward the beacon report
to that module.

Change-Id: Ie502843c5db8f0f7398d875493c9568a405fac82
CRs-Fixed: 611034
diff --git a/CORE/MAC/src/pe/include/rrmGlobal.h b/CORE/MAC/src/pe/include/rrmGlobal.h
index de8eda0..6b466c1 100644
--- a/CORE/MAC/src/pe/include/rrmGlobal.h
+++ b/CORE/MAC/src/pe/include/rrmGlobal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -51,10 +51,6 @@
 
   \brief Definitions for SME APIs
 
-   Copyright 2008 (c) Qualcomm, Incorporated.  All Rights Reserved.
-
-   Qualcomm Confidential and Proprietary.
-
   ========================================================================*/
 
 typedef enum eRrmRetStatus
@@ -65,6 +61,12 @@
     eRRM_FAILURE
 } tRrmRetStatus;
 
+typedef enum eRrmMsgReqSource
+{
+    eRRM_MSG_SOURCE_DRV         = 1, /* for both 11k and legacy ccx */
+    eRRM_MSG_SOURCE_CCX_UPLOAD  = 2, /* ccx upload approach */
+} tRrmMsgReqSource;
+
 typedef struct sSirChannelInfo
 {
    tANI_U8 regulatoryClass;
@@ -84,6 +86,7 @@
    tAniSSID     ssId;              //May be wilcard.
    tANI_U16      uDialogToken;
    tSirChannelList channelList; //From AP channel report.
+   tRrmMsgReqSource msgSource;
 } tSirBeaconReportReqInd, * tpSirBeaconReportReqInd;
 
 
diff --git a/CORE/MAC/src/pe/rrm/rrmApi.c b/CORE/MAC/src/pe/rrm/rrmApi.c
index ad7b629..786d490 100644
--- a/CORE/MAC/src/pe/rrm/rrmApi.c
+++ b/CORE/MAC/src/pe/rrm/rrmApi.c
@@ -650,6 +650,7 @@
    pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
    pSmeBcnReportReq->length = sizeof( tSirBeaconReportReqInd );
    pSmeBcnReportReq->uDialogToken = pBeaconReq->measurement_token;
+   pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_DRV;
    pSmeBcnReportReq->randomizationInterval = SYS_TU_TO_MS (pBeaconReq->measurement_request.Beacon.randomization);
    pSmeBcnReportReq->channelInfo.regulatoryClass = pBeaconReq->measurement_request.Beacon.regClass;
    pSmeBcnReportReq->channelInfo.channelNum = pBeaconReq->measurement_request.Beacon.channel;
diff --git a/CORE/SME/inc/smeRrmInternal.h b/CORE/SME/inc/smeRrmInternal.h
index ce27bee..419666d 100644
--- a/CORE/SME/inc/smeRrmInternal.h
+++ b/CORE/SME/inc/smeRrmInternal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -51,10 +51,6 @@
   
   \brief prototype for SME RRM APIs
   
-   Copyright 2008 (c) Qualcomm, Incorporated.  All Rights Reserved.
-   
-   Qualcomm Confidential and Proprietary.
-  
   ========================================================================*/
 
 /* $Header$ */
@@ -122,6 +118,7 @@
 #if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
    tCsrCcxBeaconReq  ccxBcnReqInfo;
 #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
+   tRrmMsgReqSource msgSource;
 }tRrmSMEContext, *tpRrmSMEContext; 
 
 typedef struct sRrmNeighborReq
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index a6e4a28..75641a5 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -47,8 +47,6 @@
   
     Implementation for the Common Roaming interfaces.
   
-    Copyright (C) 2008 Qualcomm, Incorporated
-  
  
    ========================================================================== */
 /*===========================================================================
@@ -12671,7 +12669,7 @@
                 // Insert the CCKM IE into the join request
 #ifdef FEATURE_WLAN_CCX_UPLOAD
                 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
-                palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
+                vos_mem_copy((void *) (wpaRsnIE),
                      pSession->suppCckmIeInfo.cckmIe, ieLen);
 #else
                 ieLen = csrConstructCcxCckmIe( pMac,
@@ -15171,18 +15169,18 @@
    eHalStatus          status = eHAL_STATUS_SUCCESS;
    tAniGetTsmStatsReq *pMsg = NULL;
 
-   status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
-   if ( !HAL_STATUS_SUCCESS(status) )
+   pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
+   if (NULL == pMsg)
    {
       smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
-      return status;
+      return eHAL_STATUS_FAILED_ALLOC;
    }
    // need to initiate a stats request to PE
    pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
    pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
    pMsg->staId = staId;
    pMsg->tid = tid;
-   palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
+   vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
    pMsg->tsmStatsCallback = callback;
    pMsg->pDevContext = pContext;
    pMsg->pVosContext = pVosContext;
@@ -16893,7 +16891,7 @@
         csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
 
         // Save the bssid from the received response
-        palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
+        vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
         csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
     }
 #endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
diff --git a/CORE/SME/src/rrm/sme_rrm.c b/CORE/SME/src/rrm/sme_rrm.c
index c5fa15f..6f9c704 100644
--- a/CORE/SME/src/rrm/sme_rrm.c
+++ b/CORE/SME/src/rrm/sme_rrm.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -45,10 +45,6 @@
   
   \brief implementation for SME RRM APIs
   
-   Copyright 2008 (c) Qualcomm, Incorporated.  All Rights Reserved.
-   
-   Qualcomm Confidential and Proprietary.
-  
   ========================================================================*/
 
 /* $Header$ */
@@ -433,7 +429,7 @@
        pBcnReport->flag = (measurementDone << 1)|((pCurResult)?true:false);
 
        smsLog(pMac, LOG1, "SME Sending BcnRep to HDD numBss(%d)"
-               " msgCounter(%d) bssCounter(%d)",
+               " msgCounter(%d) bssCounter(%d) flag(%d)",
                 pBcnReport->numBss, msgCounter, bssCounter, pBcnReport->flag);
 
        roamInfo.pCcxBcnReportRsp = pBcnReport;
@@ -545,15 +541,18 @@
       if( measurementDone )
       {
 #if defined(FEATURE_WLAN_CCX_UPLOAD)
-         status = sme_CcxSendBeaconReqScanResults(pMac,
+         if (eRRM_MSG_SOURCE_CCX_UPLOAD == pSmeRrmContext->msgSource)
+         {
+             status = sme_CcxSendBeaconReqScanResults(pMac,
                                                   sessionId,
                                                   chanList[0],
                                                   NULL,
                                                   measurementDone,
                                                   0);
-#else
-         status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0);
+         }
+         else
 #endif /*FEATURE_WLAN_CCX_UPLOAD*/
+             status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0);
       }
       return status;
    }
@@ -561,7 +560,21 @@
    pScanResult = sme_ScanResultGetFirst(pMac, pResult);
 
    if( NULL == pScanResult && measurementDone )
-      status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0 );
+   {
+#if defined(FEATURE_WLAN_CCX_UPLOAD)
+       if (eRRM_MSG_SOURCE_CCX_UPLOAD == pSmeRrmContext->msgSource)
+       {
+           status = sme_CcxSendBeaconReqScanResults(pMac,
+                                                 sessionId,
+                                                 chanList[0],
+                                                 NULL,
+                                                 measurementDone,
+                                                 0);
+       }
+       else
+#endif /*FEATURE_WLAN_CCX_UPLOAD*/
+           status = sme_RrmSendBeaconReportXmitInd( pMac, NULL, measurementDone, 0 );
+   }
 
    counter=0;
    while (pScanResult)
@@ -577,18 +590,21 @@
    {
           smsLog(pMac, LOG1, " Number of BSS Desc with RRM Scan %d ", counter);
 #if defined(FEATURE_WLAN_CCX_UPLOAD)
-       status = sme_CcxSendBeaconReqScanResults(pMac,
+         if (eRRM_MSG_SOURCE_CCX_UPLOAD == pSmeRrmContext->msgSource)
+         {
+             status = sme_CcxSendBeaconReqScanResults(pMac,
                                                 sessionId,
                                                 chanList[0],
                                                 pScanResultsArr,
                                                 measurementDone,
                                                 counter);
-#else
-       status = sme_RrmSendBeaconReportXmitInd( pMac,
+         }
+         else
+#endif /*FEATURE_WLAN_CCX_UPLOAD*/
+             status = sme_RrmSendBeaconReportXmitInd( pMac,
                                                 pScanResultsArr,
                                                 measurementDone,
                                                 counter);
-#endif /*FEATURE_WLAN_CCX_UPLOAD*/
    }
    sme_ScanResultPurge(pMac, pResult); 
 
@@ -881,6 +897,7 @@
    pSmeRrmContext->regClass = pBeaconReq->channelInfo.regulatoryClass;
          pSmeRrmContext->randnIntvl = VOS_MAX( pBeaconReq->randomizationInterval, pSmeRrmContext->rrmConfig.maxRandnInterval );
          pSmeRrmContext->currentIndex = 0;
+   pSmeRrmContext->msgSource = pBeaconReq->msgSource;
    vos_mem_copy((tANI_U8*)&pSmeRrmContext->measMode, (tANI_U8*)&pBeaconReq->fMeasurementtype, SIR_CCX_MAX_MEAS_IE_REQS);
    vos_mem_copy((tANI_U8*)&pSmeRrmContext->duration, (tANI_U8*)&pBeaconReq->measurementDuration, SIR_CCX_MAX_MEAS_IE_REQS);
 
diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c
index 91ce6f6..b4be20e 100644
--- a/CORE/SME/src/sme_common/sme_Api.c
+++ b/CORE/SME/src/sme_common/sme_Api.c
@@ -45,10 +45,6 @@
 
   \brief Definitions for SME APIs
 
-   Copyright 2008 (c) Qualcomm, Incorporated.  All Rights Reserved.
-
-   Qualcomm Confidential and Proprietary.
-
   ========================================================================*/
 
 /*===========================================================================
@@ -1788,6 +1784,7 @@
    vos_mem_copy( pSmeBcnReportReq->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
    pSmeBcnReportReq->channelInfo.channelNum = 255;
    pSmeBcnReportReq->channelList.numChannels = pCcxBcnReq->numBcnReqIe;
+   pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_CCX_UPLOAD;
 
    for (counter = 0; counter < pCcxBcnReq->numBcnReqIe; counter++)
    {
diff --git a/CORE/SYS/legacy/src/utils/src/parserApi.c b/CORE/SYS/legacy/src/utils/src/parserApi.c
index 89589a3..e281f2a 100644
--- a/CORE/SYS/legacy/src/utils/src/parserApi.c
+++ b/CORE/SYS/legacy/src/utils/src/parserApi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -39,7 +39,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 /*
- * Airgo Networks, Inc proprietary. All rights reserved.
  * This file parserApi.cc contains the code for parsing
  * 802.11 messages.
  * Author:        Pierre Vandwalle
@@ -3432,7 +3431,7 @@
     {
         //CCX Tx Power
         pBeaconStruct->ccxTxPwr.present = 1;
-        palCopyMemory( pMac->hHdd, &pBeaconStruct->ccxTxPwr,
+        vos_mem_copy(&pBeaconStruct->ccxTxPwr,
                                    &pBeacon->CCXTxmitPower,
                                    sizeof(tDot11fIECCXTxmitPower));
     }
@@ -4169,7 +4168,7 @@
         {
             pDot11f->present  = 1;
             pDot11f->num_data = pCCKMie->cckmIEdata[ idx + 1 ] - 4; // Dont include OUI
-            palCopyMemory( pMac->hHdd, pDot11f->data,
+            vos_mem_copy(pDot11f->data,
                            pCCKMie->cckmIEdata + idx + 2 + 4,    // EID, len, OUI
                            pCCKMie->cckmIEdata[ idx + 1 ] - 4 ); // Skip OUI
         }
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index 382dcb6..0c4e315 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -10276,7 +10276,7 @@
   if ( eWLAN_PAL_TRUE == pBSSSes->bAssocReqQueued )
   {
     WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
-              "s: Association sequence for this BSS exists but currently queued. macBSSID " MAC_ADDRESS_STR, 
+              "%s: Association sequence for this BSS exists but currently queued. macBSSID " MAC_ADDRESS_STR,
               __func__, MAC_ADDR_ARRAY(pwdiTSMParams->wdiTsmStatsParamsInfo.bssid));
 
     wdiStatus = WDI_QueueAssocRequest( pWDICtx, pBSSSes, pEventData);