wlan: IBSS Support

The current code does not work when we start the driver in ad-mode
mode.The following changes are in the driver to support IBSS.
1.Register Broadcast station ID to TL after HDD gets the indication
IBSS started.
2. New API introduced in TL to update the BSSID for the station.
3.The BA Activity check timer was handle for IBSS case as well.
4.IBSS Peer Management specific changes to support multiple peers
joining the group.

Change-Id: I83122840f418dd5678d444c0107c4fa22b3b35f1
CRs-Fixed: 477796
diff --git a/CORE/HDD/inc/wlan_hdd_assoc.h b/CORE/HDD/inc/wlan_hdd_assoc.h
index 9136810..b056d28 100644
--- a/CORE/HDD/inc/wlan_hdd_assoc.h
+++ b/CORE/HDD/inc/wlan_hdd_assoc.h
@@ -52,6 +52,7 @@
 #define TKIP_COUNTER_MEASURE_STOPED  0 
 /* Timeout (in ms) for Link to Up before Registering Station */
 #define ASSOC_LINKUP_TIMEOUT 60
+#define IBSS_BROADCAST_STAID 1
 typedef enum 
 {
    /** Not associated in Infra or participating in an IBSS / Ad-hoc network.*/
diff --git a/CORE/HDD/inc/wlan_hdd_cfg.h b/CORE/HDD/inc/wlan_hdd_cfg.h
index 2451677..22a9752 100644
--- a/CORE/HDD/inc/wlan_hdd_cfg.h
+++ b/CORE/HDD/inc/wlan_hdd_cfg.h
@@ -1695,6 +1695,19 @@
 #define CFG_LIST_OF_NON_DFS_COUNTRY_CODE                    "gListOfNonDfsCountryCode"
 #define CFG_LIST_OF_NON_DFS_COUNTRY_CODE_DEFAULT            "JO,MA"
 
+/*
+ * IBSS Operating Channels for 2.4G and 5GHz channels
+ */
+#define CFG_IBSS_ADHOC_CHANNEL_5GHZ_NAME          "gAdHocChannel5G"
+#define CFG_IBSS_ADHOC_CHANNEL_5GHZ_MIN           ( 36 )
+#define CFG_IBSS_ADHOC_CHANNEL_5GHZ_MAX           ( 165 )
+#define CFG_IBSS_ADHOC_CHANNEL_5GHZ_DEFAULT       ( 44 )
+
+#define CFG_IBSS_ADHOC_CHANNEL_24GHZ_NAME         "gAdHocChannel24G"
+#define CFG_IBSS_ADHOC_CHANNEL_24GHZ_MIN          ( 1 )
+#define CFG_IBSS_ADHOC_CHANNEL_24GHZ_MAX          ( 14 )
+#define CFG_IBSS_ADHOC_CHANNEL_24GHZ_DEFAULT      ( 6 )
+
 /*--------------------------------------------------------------------------- 
   Type declarations
   -------------------------------------------------------------------------*/ 
@@ -1778,6 +1791,8 @@
    v_BOOL_t      fIsShortPreamble;
    v_BOOL_t      fIsAutoIbssBssid;
    v_MACADDR_t   IbssBssid;
+   v_U32_t       AdHocChannel5G;
+   v_U32_t       AdHocChannel24G;
    
    v_U8_t        intfAddrMask;
    v_MACADDR_t   intfMacAddr[VOS_MAX_CONCURRENCY_PERSONA];
diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h
index acd6649..769db3e 100644
--- a/CORE/HDD/inc/wlan_hdd_main.h
+++ b/CORE/HDD/inc/wlan_hdd_main.h
@@ -411,7 +411,8 @@
    WLAN_HDD_P2P_GO,
    WLAN_HDD_MONITOR,
    WLAN_HDD_FTM,
-   WLAN_HDD_P2P_DEVICE
+   WLAN_HDD_IBSS,
+   WLAN_HDD_P2P_DEVICE,
 }device_mode_t;
 
 typedef enum rem_on_channel_request_type
diff --git a/CORE/HDD/inc/wlan_hdd_tx_rx.h b/CORE/HDD/inc/wlan_hdd_tx_rx.h
index efd8e22..2b2782c 100644
--- a/CORE/HDD/inc/wlan_hdd_tx_rx.h
+++ b/CORE/HDD/inc/wlan_hdd_tx_rx.h
@@ -254,4 +254,14 @@
   ===========================================================================*/
 void hdd_mon_tx_work_queue(struct work_struct *work);
 
+/**============================================================================
+  @brief hdd_Ibss_GetStaId() - Get the StationID using the Peer Mac address
+  @param pHddStaCtx : [in] pointer to HDD Station Context
+  pMacAddress [in]  pointer to Peer Mac address
+  staID [out]  pointer to Station Index
+  @return    : VOS_STATUS_SUCCESS/VOS_STATUS_E_FAILURE
+  ===========================================================================*/
+VOS_STATUS hdd_Ibss_GetStaId(hdd_station_ctx_t *pHddStaCtx,
+                                  v_MACADDR_t *pMacAddress, v_U8_t *staId);
+
 #endif    // end #if !defined( WLAN_HDD_TX_RX_H )
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index 03a8f1d..54ceacf 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -39,32 +39,29 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+
 /**========================================================================
 
   \file  wlan_hdd_assoc.c
   \brief WLAN Host Device Driver implementation
-               
-   Copyright 2008 (c) Qualcomm, Incorporated.  All Rights Reserved.
-   
-   Qualcomm Confidential and Proprietary.
-  
+
   ========================================================================*/
-/**========================================================================= 
-                       EDIT HISTORY FOR FILE 
-   
-   
-  This section contains comments describing changes made to the module. 
-  Notice that changes are listed in reverse chronological order. 
-   
-   
-  $Header:$   $DateTime: $ $Author: $ 
-   
-   
-  when        who    what, where, why 
+/**=========================================================================
+                       EDIT HISTORY FOR FILE
+
+
+  This section contains comments describing changes made to the module.
+  Notice that changes are listed in reverse chronological order.
+
+
+  $Header:$   $DateTime: $ $Author: $
+
+
+  when        who    what, where, why
   --------    ---    --------------------------------------------------------
-  05/06/09     Shailender     Created module. 
+  05/06/09     Shailender     Created module.
   ==========================================================================*/
-  
+
 #include "wlan_hdd_includes.h"
 #include <aniGlobal.h>
 #include "dot11f.h"
@@ -84,7 +81,7 @@
 
 v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
 
-struct ether_addr 
+struct ether_addr
 {
     u_char  ether_addr_octet[6];
 };
@@ -113,7 +110,7 @@
 v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
 #endif
 
-#if defined(WLAN_FEATURE_VOWIFI_11R) 
+#if defined(WLAN_FEATURE_VOWIFI_11R)
 // Offset where the EID-Len-IE, start.
 #define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
 #define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
@@ -141,37 +138,37 @@
 // returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
 // returns the connection state.  Can specify NULL if you dont' want to get the actual state.
 
-static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx, 
-                                    eConnectionState *pConnState ) 
+static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
+                                    eConnectionState *pConnState )
 {
-   v_BOOL_t fConnected; 
+   v_BOOL_t fConnected;
    eConnectionState connState;
-    
+
    // get the connection state.
    connState = pHddStaCtx->conn_info.connState;
-   // Set the fConnected return variable based on the Connected State.  
+   // Set the fConnected return variable based on the Connected State.
    if ( eConnectionState_Associated == connState ||
         eConnectionState_IbssConnected == connState )
    {
       fConnected = VOS_TRUE;
    }
-   else 
+   else
    {
       fConnected = VOS_FALSE;
    }
-    
+
    if ( pConnState )
    {
       *pConnState = connState;
    }
-  
+
    return( fConnected );
 }
 
 v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
 {
    return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
-}  
+}
 
 //TODO - Not used anyhwere. Can be removed.
 #if 0
@@ -180,80 +177,80 @@
 {
    v_BOOL_t fConnectedInfra = FALSE;
    eConnectionState connState;
-   
+
    if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
-   {   
-      if ( eConnectionState_Associated == connState ) 
+   {
+      if ( eConnectionState_Associated == connState )
       {
          fConnectedInfra = TRUE;
-      }   
+      }
    }
-   
+
    return( fConnectedInfra );
 }
 #endif
-    
+
 static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
 {
     v_BOOL_t fConnected = VOS_FALSE;
-    
+
     fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
-  
-    if ( pConnectedCipherAlgo ) 
+
+    if ( pConnectedCipherAlgo )
     {
         *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
     }
-    
+
     return( fConnected );
 }
- 
+
 inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
 {
     v_BOOL_t fConnected = VOS_FALSE;
-    
+
     fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
-  
-    if ( pConnectedBssType ) 
+
+    if ( pConnectedBssType )
     {
         *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
     }
-    
+
     return( fConnected );
 }
 
 static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
 {
-   switch( csrRoamBssType ) 
+   switch( csrRoamBssType )
    {
       case eCSR_BSS_TYPE_INFRASTRUCTURE:
           pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
          break;
-                     
+
       case eCSR_BSS_TYPE_IBSS:
       case eCSR_BSS_TYPE_START_IBSS:
           pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
          break;
-           
-      /** We will never set the BssType to 'any' when attempting a connection 
+
+      /** We will never set the BssType to 'any' when attempting a connection
             so CSR should never send this back to us.*/
-      case eCSR_BSS_TYPE_ANY:                      
+      case eCSR_BSS_TYPE_ANY:
       default:
          VOS_ASSERT( 0 );
-         break;      
-   }                     
-    
+         break;
+   }
+
 }
 
 void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
 {
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
    eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
- 
+
    VOS_ASSERT( pRoamInfo );
-   
-   if ( pRoamInfo )   
+
+   if ( pRoamInfo )
    {
-      // Save the BSSID for the connection...  
+      // Save the BSSID for the connection...
       if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
       {
           VOS_ASSERT( pRoamInfo->pBssDesc );
@@ -269,9 +266,9 @@
           }
       }
       else if ( eCSR_BSS_TYPE_IBSS == eBssType )
-      {   
+      {
          vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
-      }   
+      }
       else
       {
          // can't happen.  We need a valid IBSS or Infra setting in the BSSDescription
@@ -302,11 +299,11 @@
           // Save the ssid for the connection
           vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
       }
-   }   
-      
+   }
+
    // save the connected BssType
-   hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );  
-   
+   hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
+
 }
 
 #if defined(WLAN_FEATURE_VOWIFI_11R)
@@ -321,15 +318,15 @@
  * For FT, this consists of the Reassoc Rsp FTIEs.
  * This is the Assoc Response.
  */
-static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter, 
+static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
                 tCsrRoamInfo *pCsrRoamInfo)
 {
     union iwreq_data wrqu;
     char *buff;
     unsigned int len = 0;
     u8 *pFTAssocRsp = NULL;
-    
-    if (pCsrRoamInfo->nAssocRspLength == 0) 
+
+    if (pCsrRoamInfo->nAssocRspLength == 0)
     {
         hddLog(LOGE,
             "%s: pCsrRoamInfo->nAssocRspLength=%d",
@@ -337,11 +334,11 @@
         return;
     }
 
-    pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength + 
+    pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
         pCsrRoamInfo->nAssocReqLength);
-    if (pFTAssocRsp == NULL) 
+    if (pFTAssocRsp == NULL)
     {
-        hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__); 
+        hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
         return;
     }
 
@@ -353,22 +350,22 @@
 
     // We need to send the IEs to the supplicant.
     buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
-    if (buff == NULL) 
+    if (buff == NULL)
     {
-        hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__); 
+        hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
         return;
     }
 
     // Send the Assoc Resp, the supplicant needs this for initial Auth.
     len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
-    wrqu.data.length = len; 
+    wrqu.data.length = len;
     memset(buff, 0, IW_GENERIC_IE_MAX);
-    memcpy(buff, pFTAssocRsp, len); 
+    memcpy(buff, pFTAssocRsp, len);
     wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
 
     kfree(buff);
 }
-#endif /* WLAN_FEATURE_VOWIFI_11R */ 
+#endif /* WLAN_FEATURE_VOWIFI_11R */
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
 
@@ -454,7 +451,7 @@
     }
     vos_mem_zero(buff, IW_CUSTOM_MAX);
 
-    // Sme needs to send the RIC IEs first 
+    // Sme needs to send the RIC IEs first
     str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
     sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
             (IW_CUSTOM_MAX - str_len), &ric_ies_length );
@@ -499,14 +496,14 @@
  *
  * The current (new AP) channel information is passed in.
  */
-static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter, 
+static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
                 tCsrRoamInfo *pCsrRoamInfo)
 {
     union iwreq_data wrqu;
     tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
-     
 
-    if (descriptor == NULL) 
+
+    if (descriptor == NULL)
     {
         hddLog(LOGE,
             "%s: pCsrRoamInfo->pBssDesc=%p\n",
@@ -541,9 +538,9 @@
         return;
     }
     pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
-    if (pBeaconIes == NULL) 
+    if (pBeaconIes == NULL)
     {
-        hddLog(LOGE, "%s: Beacon IEs is NULL", __func__); 
+        hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
         return;
     }
 
@@ -552,15 +549,15 @@
         (unsigned int)pBeaconIes[0],
         (unsigned int)pBeaconIes[1]);
     hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
-    
+
    // We need to send the IEs to the supplicant.
     buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
-    if (buff == NULL) 
+    if (buff == NULL)
     {
-        hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__); 
+        hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
         return;
     }
-    vos_mem_zero(buff, IW_CUSTOM_MAX); 
+    vos_mem_zero(buff, IW_CUSTOM_MAX);
 
     strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
     currentLen = strLen + 1;
@@ -568,7 +565,7 @@
     totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
     do
     {
-        /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event 
+        /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
          * max size and send it to supplicant. Changes are done in supplicant to handle this */
         vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
         currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
@@ -577,7 +574,7 @@
         totalIeLen -= currentLen;
         wrqu.data.length = strLen + 1 + currentLen;
         if (totalIeLen)
-          buff[strLen] = 1;   // This tells supplicant more chunks are pending 
+          buff[strLen] = 1;   // This tells supplicant more chunks are pending
         else
           buff[strLen] = 0;   // For last chunk of beacon IE to supplicant
 
@@ -598,17 +595,17 @@
     char *msg;
     int type = -1;
 
-#if defined (WLAN_FEATURE_VOWIFI_11R) 
-    // Added to find the auth type on the fly at run time 
-    // rather than with cfg to see if FT is enabled 
-    hdd_wext_state_t  *pWextState =  WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);   
+#if defined (WLAN_FEATURE_VOWIFI_11R)
+    // Added to find the auth type on the fly at run time
+    // rather than with cfg to see if FT is enabled
+    hdd_wext_state_t  *pWextState =  WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
     tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
 #endif
- 
+
     memset(&wrqu, '\0', sizeof(wrqu));
-    wrqu.ap_addr.sa_family = ARPHRD_ETHER; 
+    wrqu.ap_addr.sa_family = ARPHRD_ETHER;
     we_event = SIOCGIWAP;
-   
+
     if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
     {
         memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
@@ -647,7 +644,7 @@
 #ifdef WLAN_FEATURE_VOWIFI_11R
         // Send FT Keys to the supplicant when FT is enabled
         if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
-            (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN) 
+            (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
 #ifdef FEATURE_WLAN_CCX
             || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
             (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
@@ -686,9 +683,9 @@
         wireless_send_event(dev, we_event, &wrqu, msg);
 #ifdef FEATURE_WLAN_CCX
         if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
-        {        
-            if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) || 
-                (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) ) 
+        {
+            if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
+                (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
             hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
         }
 #endif
@@ -712,7 +709,7 @@
 
    // Set not-connected state
    pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
-   hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );  
+   hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
 
    vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
 }
@@ -746,7 +743,7 @@
     // Sanity check
     if(dev == NULL)
     {
-        hddLog(VOS_TRACE_LEVEL_INFO_HIGH, 
+        hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
           "%s: net_dev is released return", __func__);
         return eHAL_STATUS_FAILURE;
     }
@@ -754,7 +751,7 @@
     // notify apps that we can't pass traffic anymore
     netif_tx_disable(dev);
     netif_carrier_off(dev);
-    
+
     INIT_COMPLETION(pAdapter->disconnect_comp_var);
     hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
     /* If only STA mode is on */
@@ -773,8 +770,8 @@
             driver so not sending the status of the connection to supplicant*/
         if(pHddCtx->isLoadUnloadInProgress != TRUE)
         {
-            hddLog(VOS_TRACE_LEVEL_INFO_HIGH, 
-                    "%s: sent disconnected event to nl80211", 
+            hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
+                    "%s: sent disconnected event to nl80211",
                     __func__);
 #ifdef WLAN_FEATURE_P2P_DEBUG
             if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
@@ -801,7 +798,7 @@
             }
             else
             {
-                cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL); 
+                cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
             }
 
             //If the Device Mode is Station
@@ -809,14 +806,14 @@
             //Enable BMPS
 
             // In case of JB, as Change-Iface may or maynot be called for p2p0
-            // Enable BMPS/IMPS in case P2P_CLIENT disconnected   
+            // Enable BMPS/IMPS in case P2P_CLIENT disconnected
             if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
                 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
                 (vos_concurrent_sessions_running()))
             {
                //Enable BMPS only of other Session is P2P Client
                hdd_context_t *pHddCtx = NULL;
-               v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );    
+               v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
 
                if (NULL != pVosContext)
                {
@@ -847,7 +844,7 @@
             }
         }
     }
-    
+
 
     //We should clear all sta register with TL, for now, only one.
     vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
@@ -894,23 +891,27 @@
    v_BOOL_t  fConnected;
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
    hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
-   
+
+   if ( NULL == pBssDesc)
+   {
+       return VOS_STATUS_E_FAILURE;
+   }
    // Get the Station ID from the one saved during the assocation.
    staDesc.ucSTAId = staId;
 
    if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
-   { 
-      staDesc.wSTAType = WLAN_STA_INFRA;
-      
-      // grab the bssid from the connection info in the adapter structure and hand that 
-      // over to TL when registering. 
-      vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) ); 
-   }
-   else 
    {
-      // for an IBSS 'connect', setup the Station Descriptor for TL.   
+      staDesc.wSTAType = WLAN_STA_INFRA;
+
+      // grab the bssid from the connection info in the adapter structure and hand that
+      // over to TL when registering.
+      vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
+   }
+   else
+   {
+      // for an IBSS 'connect', setup the Station Descriptor for TL.
       staDesc.wSTAType = WLAN_STA_IBSS;
-      
+
       // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
       // in infrastructure, they are the same (BSSID is the MAC address of the AP).  So,
       // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
@@ -918,7 +919,7 @@
       vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
       vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
    }
-      
+
    vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
 
    // set the QoS field appropriately
@@ -957,12 +958,12 @@
        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
                  "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
    }
-  
+
    else
    {
-      /* For other encryption modes replay check is 
+      /* For other encryption modes replay check is
          not needed */
-        staDesc.ucIsReplayCheckValid = VOS_FALSE; 
+        staDesc.ucIsReplayCheckValid = VOS_FALSE;
         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
                  "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
    }
@@ -987,58 +988,59 @@
    staDesc.ucSwFrameTXXlation = 1;
    staDesc.ucSwFrameRXXlation = 1;
    staDesc.ucAddRmvLLC = 1;
-   VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d", 
+   VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
               staDesc.ucQosEnabled );
    // Initialize signatures and state
    staDesc.ucUcastSig  = pRoamInfo->ucastSig;
    staDesc.ucBcastSig  = pRoamInfo->bcastSig;
    staDesc.ucInitState = pRoamInfo->fAuthRequired ?
       WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
-   // Register the Station with TL...      
+   // Register the Station with TL...
    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
-   vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext, 
-                                         hdd_rx_packet_cbk, 
-                                         hdd_tx_complete_cbk, 
+   vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
+                                         hdd_rx_packet_cbk,
+                                         hdd_tx_complete_cbk,
                                          hdd_tx_fetch_packet_cbk, &staDesc,
                                          pBssDesc->rssi );
-   
+
    if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
    {
-      VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, 
+      VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
                  "WLANTL_RegisterSTAClient() failed to register.  Status= %d [0x%08lX]",
                  vosStatus, vosStatus );
-      return vosStatus;      
-   }                                            
+      return vosStatus;
+   }
 
-   // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver, 
-   // then go to 'authenticated'.  For all other authentication types (those that do 
+   // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
+   // then go to 'authenticated'.  For all other authentication types (those that do
    // not require upper layer authentication) we can put TL directly into 'authenticated'
    // state.
-   
-   VOS_ASSERT( fConnected );
-  
+
+   if (staDesc.wSTAType != WLAN_STA_IBSS)
+      VOS_ASSERT( fConnected );
+
    if ( !pRoamInfo->fAuthRequired )
    {
       VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
                  "open/shared auth StaId= %d.  Changing TL state to AUTHENTICATED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
-   
+
       // Connections that do not need Upper layer auth, transition TL directly
-      // to 'Authenticated' state.      
-      vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId, 
+      // to 'Authenticated' state.
+      vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
                                          WLANTL_STA_AUTHENTICATED );
-  
+
       pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
-   }                                            
+   }
    else
    {
       VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
                  "ULA auth StaId= %d.  Changing TL state to CONNECTED at Join time", pHddStaCtx->conn_info.staId[ 0 ] );
-   
-      vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId, 
+
+      vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
                                          WLANTL_STA_CONNECTED );
 
       pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
-   }      
+   }
    return( vosStatus );
 }
 
@@ -1095,8 +1097,8 @@
     kfree(rspRsnIe);
 }
 
-static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, 
-                                                    tANI_U32 roamId, eRoamCmdStatus roamStatus,                                                
+static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
+                                                    tANI_U32 roamId, eRoamCmdStatus roamStatus,
                                                     eCsrRoamResult roamResult )
 {
     struct net_device *dev = pAdapter->dev;
@@ -1109,7 +1111,7 @@
     int ft_carrier_on = FALSE;
 #endif
     int status;
- 
+
     if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
     {
         hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
@@ -1132,23 +1134,23 @@
         hdd_SendAssociationEvent(dev,pRoamInfo);
 
 
-        // Initialize the Linkup event completion variable 
+        // Initialize the Linkup event completion variable
         INIT_COMPLETION(pAdapter->linkup_event_var);
 
         /*
            Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
            packet to go up to the application, device activation has to be ensured for proper queue mapping by the
-           kernel. we have registered net device notifier for device change notification. With this we will come to 
+           kernel. we have registered net device notifier for device change notification. With this we will come to
            know that the device is getting activated properly.
            */
 #if  defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
         if (pHddStaCtx->ft_carrier_on == FALSE)
         {
 #endif
-            // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable       
+            // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
             pAdapter->isLinkUpSvcNeeded = TRUE;
 
-            // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable       
+            // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
             pAdapter->isLinkUpSvcNeeded = TRUE;
 
             // Switch on the Carrier to activate the device
@@ -1157,7 +1159,7 @@
             // Wait for the Link to up to ensure all the queues are set properly by the kernel
             status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
                                                    msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
-            if(!status) 
+            if(!status)
             {
                 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
             }
@@ -1166,7 +1168,7 @@
             pAdapter->isLinkUpSvcNeeded = FALSE;
 #if  defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
         }
-        else { 
+        else {
             pHddStaCtx->ft_carrier_on = FALSE;
             ft_carrier_on = TRUE;
         }
@@ -1205,9 +1207,9 @@
             {
 
                 //Association Response
-                pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength + 
+                pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
                                     pRoamInfo->nAssocReqLength);
-                if (pFTAssocRsp != NULL) 
+                if (pFTAssocRsp != NULL)
                 {
                     // pFTAssocRsp needs to point to the IEs
                     pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
@@ -1223,9 +1225,9 @@
                 }
 
                 //Association Request
-                pFTAssocReq = (u8 *)(pRoamInfo->pbFrames + 
+                pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
                                      pRoamInfo->nBeaconLength);
-                if (pFTAssocReq != NULL) 
+                if (pFTAssocReq != NULL)
                 {
                     if(!ft_carrier_on)
                     {
@@ -1322,7 +1324,7 @@
             //Reassoc successfully
             if( pRoamInfo->fAuthRequired )
             {
-                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ], 
+                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
                         WLANTL_STA_CONNECTED );
                 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
             }
@@ -1331,7 +1333,7 @@
                 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
                           "%s: staId: %d Changing TL state to AUTHENTICATED",
                           __func__, pHddStaCtx->conn_info.staId[ 0 ] );
-                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ], 
+                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
                         WLANTL_STA_AUTHENTICATED );
                 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
             }
@@ -1354,8 +1356,8 @@
 #endif
         // Start the Queue
         netif_tx_wake_all_queues(dev);
-    }  
-    else 
+    }
+    else
     {
         hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
 
@@ -1385,7 +1387,7 @@
         //Enable BMPS
 
         // In case of JB, as Change-Iface may or maynot be called for p2p0
-        // Enable BMPS/IMPS in case P2P_CLIENT disconnected   
+        // Enable BMPS/IMPS in case P2P_CLIENT disconnected
         if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
             (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
             (vos_concurrent_sessions_running()))
@@ -1460,7 +1462,7 @@
 
         netif_tx_disable(dev);
         netif_carrier_off(dev);
-        
+
         if (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode)
         {
             /* Association failed; Reset the country code information
@@ -1474,13 +1476,13 @@
 
 /**============================================================================
  *
-  @brief roamRoamIbssIndicationHandler() - Here we update the status of the 
+  @brief roamRoamIbssIndicationHandler() - Here we update the status of the
   Ibss when we receive information that we have started/joined an ibss session
   We always return SUCCESS.
-  
+
   ===========================================================================*/
-static eHalStatus roamRoamIbssIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, 
-   tANI_U32 roamId, eRoamCmdStatus roamStatus,                                                
+static eHalStatus roamRoamIbssIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
+   tANI_U32 roamId, eRoamCmdStatus roamStatus,
    eCsrRoamResult roamResult )
 {
    switch( roamResult )
@@ -1489,27 +1491,35 @@
       case eCSR_ROAM_RESULT_IBSS_STARTED:
       case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
       {
+         hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
+         v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
          // we should have a pRoamInfo on this callback...
          VOS_ASSERT( pRoamInfo );
-        
-         // When IBSS Started comes from CSR, we need to move connection state to 
+
+         // When IBSS Started comes from CSR, we need to move connection state to
          // IBSS Disconnected (meaning no peers are in the IBSS).
          hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssDisconnected );
+         pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
+         hdd_roamRegisterSTA (pAdapter, pRoamInfo,
+                      IBSS_BROADCAST_STAID,
+                      &broadcastMacAddr, pRoamInfo->pBssDesc);
 
+         netif_carrier_on(pAdapter->dev);
+         netif_tx_start_all_queues(pAdapter->dev);
          break;
       }
-      
+
       case eCSR_ROAM_RESULT_IBSS_START_FAILED:
       {
          VOS_ASSERT( pRoamInfo );
-         
+
          break;
       }
-      
+
       default:
          break;
-   }   
-   
+   }
+
     return( eHAL_STATUS_SUCCESS );
 }
 
@@ -1518,36 +1528,36 @@
   @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
   This information is passed to iwconfig later. The peer that joined
   last is passed as information to iwconfig.
-  If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we 
+  If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
   return FALSE.
-  
+
   ===========================================================================*/
 static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
 {
    int fSuccess = FALSE;
    int idx = 0;
-   
+
    for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
    {
       if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
       {
          pHddStaCtx->conn_info.staId[ idx ] = staId;
-      
+
          vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
-         
+
          fSuccess = TRUE;
          break;
       }
    }
-   
-   return( fSuccess );   
+
+   return( fSuccess );
 }
 /**============================================================================
  *
   @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
-  If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we 
+  If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
   return FALSE.
-  
+
   ===========================================================================*/
 static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
 {
@@ -1555,7 +1565,7 @@
    int idx = 0;
    v_U8_t  valid_idx   = 0;
    v_U8_t  del_idx   = 0;
-   
+
    for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
    {
       if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
@@ -1570,7 +1580,7 @@
       }
       else
       {
-         if (pHddStaCtx->conn_info.staId[idx] != 0) 
+         if (pHddStaCtx->conn_info.staId[idx] != 0)
          {
             valid_idx = idx;
          }
@@ -1598,9 +1608,9 @@
 
 /**============================================================================
  *
-  @brief roamIbssConnectHandler() : We update the status of the IBSS to 
+  @brief roamIbssConnectHandler() : We update the status of the IBSS to
   connected in this function.
-  
+
   ===========================================================================*/
 static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
 {
@@ -1623,10 +1633,10 @@
 /**============================================================================
  *
   @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
-  
+
   ===========================================================================*/
-static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, 
-                                                 tANI_U32 roamId, eRoamCmdStatus roamStatus,                                                
+static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
+                                                 tANI_U32 roamId, eRoamCmdStatus roamStatus,
                                                  eCsrRoamResult roamResult )
 {
    eCsrEncryptionType connectedCipherAlgo;
@@ -1636,7 +1646,7 @@
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
    ENTER();
    // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
-   // then go to 'authenticated'.  For all other authentication types (those that do 
+   // then go to 'authenticated'.  For all other authentication types (those that do
    // not require upper layer authentication) we can put TL directly into 'authenticated'
    // state.
 
@@ -1651,12 +1661,12 @@
       {
          VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
                     "Key set for StaId= %d.  Changing TL state to AUTHENTICATED", pHddStaCtx->conn_info.staId[ 0 ] );
-                    
-         // Connections that do not need Upper layer authentication, transition TL 
+
+         // Connections that do not need Upper layer authentication, transition TL
          // to 'Authenticated' state after the keys are set.
-         vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ], 
+         vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
                                             WLANTL_STA_AUTHENTICATED );
- 
+
          pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
       }
       else
@@ -1664,7 +1674,7 @@
          vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
                                              pHddStaCtx->conn_info.staId[ 0 ]);
       }
-      
+
       pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
    }
    else
@@ -1672,7 +1682,7 @@
       // possible disassoc after issuing set key and waiting set key complete
       pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
    }
-   
+
    EXIT();
    return( eHAL_STATUS_SUCCESS );
 }
@@ -1680,9 +1690,9 @@
  *
   @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
   ===========================================================================*/
-static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, 
+static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
                                                  tANI_U32 roamId, eRoamCmdStatus roamStatus,                                                                              eCsrRoamResult roamResult )
-{   
+{
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
 
    if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
@@ -1700,37 +1710,37 @@
                                     msg.src_addr.sa_data[3],
                                     msg.src_addr.sa_data[4],
                                     msg.src_addr.sa_data[5]);
-  
+
       if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
          msg.flags = IW_MICFAILURE_GROUP;
-      else 
+      else
          msg.flags = IW_MICFAILURE_PAIRWISE;
       memset(&wreq, 0, sizeof(wreq));
       wreq.data.length = sizeof(msg);
       wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
       /* inform mic failure to nl80211 */
-      cfg80211_michael_mic_failure(pAdapter->dev, 
+      cfg80211_michael_mic_failure(pAdapter->dev,
               pRoamInfo->u.pMICFailureInfo->taMacAddr,
               ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
                NL80211_KEYTYPE_GROUP :
                NL80211_KEYTYPE_PAIRWISE),
-              pRoamInfo->u.pMICFailureInfo->keyId, 
-              pRoamInfo->u.pMICFailureInfo->TSC, 
+              pRoamInfo->u.pMICFailureInfo->keyId,
+              pRoamInfo->u.pMICFailureInfo->TSC,
               GFP_KERNEL);
-      
+
    }
-   
+
    return( eHAL_STATUS_SUCCESS );
 }
 
 /**============================================================================
  *
-  @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is 
+  @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
   updated regularly here in this function.
-  
+
   ===========================================================================*/
-static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, 
-   tANI_U32 roamId, eRoamCmdStatus roamStatus,                                                
+static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
+   tANI_U32 roamId, eRoamCmdStatus roamStatus,
    eCsrRoamResult roamResult )
 {
    VOS_STATUS vosStatus;
@@ -1740,13 +1750,15 @@
    {
       case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
       {
-         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+         hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
+
+         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
                     "IBSS New Peer indication from SME "
-                    "with peerMac %2x-%2x-%2x-%2x-%2x-%2x  and  stationID= %d",
-                    pRoamInfo->peerMac[0], pRoamInfo->peerMac[1], pRoamInfo->peerMac[2],
-                    pRoamInfo->peerMac[3], pRoamInfo->peerMac[4], pRoamInfo->peerMac[5], 
+                    "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
+                    MAC_ADDR_ARRAY(pRoamInfo->peerMac),
+                    MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
                     pRoamInfo->staId );
-         
+
          if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
          {
             VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
@@ -1756,7 +1768,11 @@
 
          pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
 
-         // Register the Station with TL for the new peer. 
+         pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
+         WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
+                      IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
+
+         // Register the Station with TL for the new peer.
          vosStatus = hdd_roamRegisterSTA( pAdapter,
                                           pRoamInfo,
                                           pRoamInfo->staId,
@@ -1768,28 +1784,36 @@
                "Cannot register STA with TL for IBSS.  Failed with vosStatus = %d [%08lX]",
                vosStatus, vosStatus );
          }
-         
+
          netif_carrier_on(pAdapter->dev);
          netif_tx_start_all_queues(pAdapter->dev);
          break;
       }
-         
+
       case eCSR_ROAM_RESULT_IBSS_CONNECT:
       {
-      
+
          roamIbssConnectHandler( pAdapter, pRoamInfo );
-         
+
          break;
-      }   
+      }
       case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
       {
+         hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
 
-         if ( !roamRemoveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId ) )
+         if ( !roamRemoveIbssStation( pHddStaCtx, pRoamInfo->staId ) )
          {
             VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
                     "IBSS peer departed by cannot find peer in our registration table with TL" );
          }
 
+         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
+                    "IBSS Peer Departed from SME "
+                    "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
+                    MAC_ADDR_ARRAY(pRoamInfo->peerMac),
+                    MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
+                    pRoamInfo->staId );
+
          hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
 
          pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
@@ -1798,11 +1822,13 @@
       }
       case eCSR_ROAM_RESULT_IBSS_INACTIVE:
       {
+          VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
+                    "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
          // Stop only when we are inactive
          netif_tx_disable(pAdapter->dev);
          netif_carrier_off(pAdapter->dev);
          hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
-         
+
          // Send the bssid address to the wext.
          hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
          // clean up data path
@@ -1811,9 +1837,9 @@
       }
       default:
          break;
-   
+
    }
-   
+
    return( eHAL_STATUS_SUCCESS );
 }
 
@@ -1823,13 +1849,13 @@
   @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
   TL the new STA. This is called as part of ADD_STA in the TDLS setup
   Return: VOS_STATUS
-  
+
   ===========================================================================*/
 VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
                                     tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
 {
     hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
-    v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;  
+    v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
     VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
     WLAN_STADescType staDesc = {0};
     eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
@@ -1837,7 +1863,7 @@
 
     fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
     if (!fConnected) {
-        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, 
+        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                      "%s not connected. ignored", __func__);
         return VOS_FALSE;
     }
@@ -1849,7 +1875,7 @@
     staDesc.ucSTAId = staId ;
 
     staDesc.wSTAType = WLAN_STA_TDLS ;
-      
+
     vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
                                          sizeof(tSirMacAddr) );
 
@@ -1868,7 +1894,7 @@
     VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
                "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
 
-    /* 
+    /*
      * UMA is ready we inform TL  to do frame translation.
      */
     staDesc.ucSwFrameTXXlation = 1;
@@ -1880,7 +1906,7 @@
 
     /* tdls Direct Link do not need bcastSig */
     staDesc.ucBcastSig  = 0 ;
-    
+
 #ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
     if(staDesc.ucProtectedFrame)
         staDesc.ucIsReplayCheckValid = VOS_TRUE;
@@ -1890,20 +1916,20 @@
 
     staDesc.ucInitState = WLANTL_STA_AUTHENTICATED ;
 
-   /* Register the Station with TL...  */    
-    vosStatus = WLANTL_RegisterSTAClient( pVosContext, 
-                                          hdd_rx_packet_cbk, 
-                                          hdd_tx_complete_cbk, 
+   /* Register the Station with TL...  */
+    vosStatus = WLANTL_RegisterSTAClient( pVosContext,
+                                          hdd_rx_packet_cbk,
+                                          hdd_tx_complete_cbk,
                                           hdd_tx_fetch_packet_cbk, &staDesc, 0 );
-   
+
     if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
     {
-        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, 
+        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                      "%s: WLANTL_RegisterSTAClient() failed to register.  \
                             Status= %d [0x%08lX]", __func__, vosStatus, vosStatus );
-         return vosStatus;      
-    }                                            
-    
+         return vosStatus;
+    }
+
     return( vosStatus );
 }
 
@@ -1928,10 +1954,10 @@
  * TDLS client is deleted.
  */
 
-eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter, 
-                                             tCsrRoamInfo *pRoamInfo, 
+eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
+                                             tCsrRoamInfo *pRoamInfo,
                                               tANI_U32 roamId,
-                                                eRoamCmdStatus roamStatus, 
+                                                eRoamCmdStatus roamStatus,
                                                   eCsrRoamResult roamResult)
 {
     hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
@@ -2120,7 +2146,7 @@
 }
 #endif
 
-eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, 
+eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
                                 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
 {
     eHalStatus halStatus = eHAL_STATUS_SUCCESS;
@@ -2130,8 +2156,8 @@
     VOS_STATUS status = VOS_STATUS_SUCCESS;
 
     VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
-            "CSR Callback: status= %d result= %d roamID=%ld", 
-                    roamStatus, roamResult, roamId ); 
+            "CSR Callback: status= %d result= %d roamID=%ld",
+                    roamStatus, roamResult, roamId );
 
     /*Sanity check*/
     if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
@@ -2160,11 +2186,11 @@
                 complete(&pAdapter->session_open_comp_var);
             }
             break;
-            
+
 #if  defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
             /* We did pre-auth,then we attempted a 11r or ccx reassoc.
              * reassoc failed due to failure, timeout, reject from ap
-             * in any case tell the OS, our carrier is off and mark 
+             * in any case tell the OS, our carrier is off and mark
              * interface down */
         case eCSR_ROAM_FT_REASSOC_FAILED:
             hddLog(LOG1, FL("Reassoc Failed\n"));
@@ -2177,9 +2203,9 @@
             break;
 
         case eCSR_ROAM_FT_START:
-            // When we roam for CCX and 11r, we dont want the 
+            // When we roam for CCX and 11r, we dont want the
             // OS to be informed that the link is down. So mark
-            // the link ready for ft_start. After this the 
+            // the link ready for ft_start. After this the
             // eCSR_ROAM_SHOULD_ROAM will be received.
             // Where in we will not mark the link down
             // Also we want to stop tx at this point when we will be
@@ -2256,7 +2282,7 @@
                     hdd_conf_mcastbcast_filter((WLAN_HDD_GET_CTX(pAdapter)), FALSE);
                     (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
                 }
-#ifdef WLAN_FEATURE_PACKET_FILTERING    
+#ifdef WLAN_FEATURE_PACKET_FILTERING
                 if (pHddCtx->cfg_ini->isMcAddrListFilter)
                 {
                     /*Multicast addr filtering is enabled*/
@@ -2286,7 +2312,7 @@
             VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
                     "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
             if (  (roamResult != eCSR_ROAM_RESULT_ASSOCIATED)
-               && (   (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) 
+               && (   (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
                    || (pWextState->roamProfile.EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)
                   )
                && (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
@@ -2307,7 +2333,7 @@
 
             break;
         case eCSR_ROAM_ASSOCIATION_FAILURE:
-            halStatus = hdd_AssociationCompletionHandler( pAdapter, 
+            halStatus = hdd_AssociationCompletionHandler( pAdapter,
                     pRoamInfo, roamId, roamStatus, roamResult );
             break;
         case eCSR_ROAM_IBSS_IND:
@@ -2316,7 +2342,7 @@
 
         case eCSR_ROAM_CONNECT_STATUS_UPDATE:
             halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
-            break;            
+            break;
 
         case eCSR_ROAM_MIC_ERROR_IND:
             halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
@@ -2332,7 +2358,7 @@
 #endif
 #if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
         case eCSR_ROAM_PMK_NOTIFY:
-           if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType) 
+           if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
            {
                /* Notify the supplicant of a new candidate */
                halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
@@ -2376,32 +2402,32 @@
     }
     return( halStatus );
 }
-eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4]) 
+eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
 {
     eCsrAuthType auth_type;
     // is the auth type supported?
-    if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0) 
+    if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_RSN;
-    } else 
-    if (memcmp(auth_suite , ccpRSNOui02, 4) == 0) 
+    } else
+    if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_RSN_PSK;
-    } else 
+    } else
 #ifdef WLAN_FEATURE_VOWIFI_11R
-    if (memcmp(auth_suite , ccpRSNOui04, 4) == 0) 
+    if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
     {
         // Check for 11r FT Authentication with PSK
         auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
-    } else 
-    if (memcmp(auth_suite , ccpRSNOui03, 4) == 0) 
+    } else
+    if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
     {
         // Check for 11R FT Authentication with 802.1X
         auth_type = eCSR_AUTH_TYPE_FT_RSN;
-    } else 
+    } else
 #endif
 #ifdef FEATURE_WLAN_CCX
-    if (memcmp(auth_suite , ccpRSNOui06, 4) == 0) 
+    if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
     } else
@@ -2412,70 +2438,70 @@
         auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
     } else
 #endif
-    { 
+    {
         auth_type = eCSR_AUTH_TYPE_UNKNOWN;
     }
     return auth_type;
-} 
+}
 
-eCsrAuthType 
-hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4]) 
+eCsrAuthType
+hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
 {
     eCsrAuthType auth_type;
     // is the auth type supported?
-    if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0) 
+    if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_WPA;
-    } else 
-    if (memcmp(auth_suite , ccpWpaOui02, 4) == 0) 
+    } else
+    if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_WPA_PSK;
-    } else 
+    } else
 #ifdef FEATURE_WLAN_CCX
-    if (memcmp(auth_suite , ccpWpaOui06, 4) == 0) 
+    if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
     {
         auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
-    } else 
+    } else
 #endif /* FEATURE_WLAN_CCX */
-    { 
+    {
         auth_type = eCSR_AUTH_TYPE_UNKNOWN;
     }
     hddLog(LOG1, FL("auth_type: %d"), auth_type);
     return auth_type;
 }
 
-eCsrEncryptionType 
+eCsrEncryptionType
 hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
 {
     eCsrEncryptionType cipher_type;
     // is the cipher type supported?
-    if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0) 
+    if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_AES;
-    } 
-    else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0) 
+    }
+    else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
-    } 
-    else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0) 
+    }
+    else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_NONE;
-    } 
-    else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0) 
+    }
+    else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
-    } 
-    else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0) 
-    {        
-        cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; 
-    } 
-    else 
-    { 
+    }
+    else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
+    {
+        cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
+    }
+    else
+    {
         cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
     }
     hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
     return cipher_type;
-} 
+}
 /* To find if the MAC address is NULL */
 static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
 {
@@ -2490,57 +2516,57 @@
     return TRUE;
 } /****** end hdd_IsMACAddrNULL() ******/
 
-eCsrEncryptionType 
+eCsrEncryptionType
 hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
 {
     eCsrEncryptionType cipher_type;
     // is the cipher type supported?
-    if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0) 
+    if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_AES;
-    } else 
-    if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0) 
+    } else
+    if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
-    } else 
-    if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0) 
+    } else
+    if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_NONE;
-    } else 
-    if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0) 
+    } else
+    if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
     {
         cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
-    } else 
-    if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0) 
+    } else
+    if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
     {
-        cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; 
-    } else 
-    { 
+        cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
+    } else
+    {
         cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
     }
     hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
     return cipher_type;
-} 
+}
 
-static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter, 
-                struct ether_addr *pBssid, 
-                eCsrEncryptionType *pEncryptType, 
-                eCsrEncryptionType *mcEncryptType, 
-                eCsrAuthType *pAuthType, 
+static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
+                struct ether_addr *pBssid,
+                eCsrEncryptionType *pEncryptType,
+                eCsrEncryptionType *mcEncryptType,
+                eCsrAuthType *pAuthType,
 #ifdef WLAN_FEATURE_11W
                 u_int8_t *pMfpRequired,
                 u_int8_t *pMfpCapable,
 #endif
-                u_int16_t gen_ie_len, 
-                u_int8_t *gen_ie) 
+                u_int16_t gen_ie_len,
+                u_int8_t *gen_ie)
 {
     tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
-    eHalStatus result; 
-    tDot11fIERSN dot11RSNIE; 
-    tDot11fIEWPA dot11WPAIE; 
-    tANI_U32 i; 
-    tANI_U8 *pRsnIe; 
-    tANI_U16 RSNIeLen; 
+    eHalStatus result;
+    tDot11fIERSN dot11RSNIE;
+    tDot11fIEWPA dot11WPAIE;
+    tANI_U32 i;
+    tANI_U8 *pRsnIe;
+    tANI_U16 RSNIeLen;
     tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
 
     /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
@@ -2549,52 +2575,52 @@
     memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
 
     // Validity checks
-    if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||  
-            (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) ) 
+    if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
+            (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
         return -EINVAL;
     // Type check
-    if ( gen_ie[0] ==  DOT11F_EID_RSN) 
-    {         
+    if ( gen_ie[0] ==  DOT11F_EID_RSN)
+    {
         // Validity checks
-        if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||  
+        if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
                 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
         {
             return -EINVAL;
         }
-        // Skip past the EID byte and length byte  
-        pRsnIe = gen_ie + 2; 
-        RSNIeLen = gen_ie_len - 2; 
-        // Unpack the RSN IE 
-        dot11fUnpackIeRSN((tpAniSirGlobal) halHandle, 
-                            pRsnIe, 
-                            RSNIeLen, 
+        // Skip past the EID byte and length byte
+        pRsnIe = gen_ie + 2;
+        RSNIeLen = gen_ie_len - 2;
+        // Unpack the RSN IE
+        dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
+                            pRsnIe,
+                            RSNIeLen,
                             &dot11RSNIE);
-        // Copy out the encryption and authentication types 
-        hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"), 
+        // Copy out the encryption and authentication types
+        hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
                 __func__, dot11RSNIE.pwise_cipher_suite_count );
-        hddLog(LOG1, FL("%s: authentication suite count: %d"), 
+        hddLog(LOG1, FL("%s: authentication suite count: %d"),
                 __func__, dot11RSNIE.akm_suite_count);
-        /*Here we have followed the apple base code, 
+        /*Here we have followed the apple base code,
           but probably I suspect we can do something different*/
         //dot11RSNIE.akm_suite_count
-        // Just translate the FIRST one 
-        *pAuthType =  hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]); 
-        //dot11RSNIE.pwise_cipher_suite_count 
-        *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);                     
-        //dot11RSNIE.gp_cipher_suite_count 
-        *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);                     
+        // Just translate the FIRST one
+        *pAuthType =  hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
+        //dot11RSNIE.pwise_cipher_suite_count
+        *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
+        //dot11RSNIE.gp_cipher_suite_count
+        *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
 #ifdef WLAN_FEATURE_11W
         *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
         *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
 #endif
         // Set the PMKSA ID Cache for this interface
-        for (i=0; i<dot11RSNIE.pmkid_count; i++) 
+        for (i=0; i<dot11RSNIE.pmkid_count; i++)
         {
-            if ( pBssid == NULL) 
+            if ( pBssid == NULL)
             {
                 break;
             }
-            if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid))) 
+            if ( hdd_IsMACAddrNULL( (u_char *) pBssid , sizeof( (char *) pBssid)))
             {
                 break;
             }
@@ -2606,11 +2632,11 @@
                             CSR_RSN_PMKID_SIZE);
         }
         // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
-        hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."), 
+        hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
                                                                             __func__, i );
         // Finally set the PMKSA ID Cache in CSR
         result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
-                                        PMKIDCache, 
+                                        PMKIDCache,
                                         dot11RSNIE.pmkid_count );
     }
     else if (gen_ie[0] == DOT11F_EID_WPA)
@@ -2622,9 +2648,9 @@
             return -EINVAL;
         }
         // Skip past the EID byte and length byte - and four byte WiFi OUI
-        pRsnIe = gen_ie + 2 + 4; 
-        RSNIeLen = gen_ie_len - (2 + 4); 
-        // Unpack the WPA IE 
+        pRsnIe = gen_ie + 2 + 4;
+        RSNIeLen = gen_ie_len - (2 + 4);
+        // Unpack the WPA IE
         dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
                             pRsnIe,
                             RSNIeLen,
@@ -2645,7 +2671,7 @@
     else
     {
         hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
-        return -EINVAL; 
+        return -EINVAL;
     }
     return 0;
 }
@@ -2668,7 +2694,7 @@
     if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
     {
         //continue
-    } 
+    }
     else
     {
         return 0;
@@ -2691,7 +2717,7 @@
         // Now copy over all the security attributes you have parsed out
         pWextState->roamProfile.EncryptionType.numEntries = 1;
         pWextState->roamProfile.mcEncryptionType.numEntries = 1;
-        
+
         pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
         pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
 
@@ -2709,10 +2735,10 @@
     tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
     hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
     ENTER();
-    
+
     pRoamProfile->AuthType.numEntries = 1;
     hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
-      
+
     switch( pHddStaCtx->conn_info.authType)
     {
        case eCSR_AUTH_TYPE_OPEN_SYSTEM:
@@ -2720,59 +2746,59 @@
        case eCSR_AUTH_TYPE_CCKM_WPA:
        case eCSR_AUTH_TYPE_CCKM_RSN:
 #endif
-        if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {           
-           
+        if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
+
            pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
-        } else 
+        } else
         if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
-           
+
 #ifdef FEATURE_WLAN_CCX
-            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) && 
-                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) 
-                 == IW_AUTH_KEY_MGMT_802_1X)) { 
+            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
+                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
+                 == IW_AUTH_KEY_MGMT_802_1X)) {
                 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
-                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;   
-            } else 
-            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) { 
+                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
+            } else
+            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
                 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
-                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;   
+                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
             } else
 #endif
             if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
                     == IW_AUTH_KEY_MGMT_802_1X) {
-               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;   
-            } else 
+               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
+            } else
             if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
                     == IW_AUTH_KEY_MGMT_PSK) {
                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
-            } else {     
+            } else {
                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
-            }    
+            }
         }
         if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
 #ifdef FEATURE_WLAN_CCX
-            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) && 
-                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) 
-                 == IW_AUTH_KEY_MGMT_802_1X)) { 
+            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
+                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
+                 == IW_AUTH_KEY_MGMT_802_1X)) {
                 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
-                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;   
+                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
             } else
-            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) { 
+            if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
                 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
-                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;   
+                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
             } else
 #endif
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
-            if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) && 
-                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) 
+            if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
+                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
                  == IW_AUTH_KEY_MGMT_802_1X)) {
-               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;   
+               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
             }else
-            if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) && 
+            if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
                 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
                  == IW_AUTH_KEY_MGMT_PSK)) {
-               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;   
+               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
             } else
 #endif
 
@@ -2782,54 +2808,54 @@
             } else
 #endif
 
-            if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) 
+            if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
                     == IW_AUTH_KEY_MGMT_802_1X) {
-               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;   
-            } else 
+               pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
+            } else
             if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
                     == IW_AUTH_KEY_MGMT_PSK) {
                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
-            } else {             
+            } else {
                pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
-            }    
+            }
         }
-        break;     
-         
+        break;
+
        case eCSR_AUTH_TYPE_SHARED_KEY:
-         
-          pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;  
+
+          pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
           break;
         default:
-         
+
 #ifdef FEATURE_WLAN_CCX
-           hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__); 
+           hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
 #endif /* FEATURE_WLAN_CCX */
            pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
            break;
     }
-   
+
     hddLog( LOG1, "%s Set roam Authtype to %d",
             __func__, pWextState->roamProfile.AuthType.authType[0]);
-   
+
    EXIT();
     return 0;
 }
 
 /**---------------------------------------------------------------------------
-  
-  \brief iw_set_essid() - 
+
+  \brief iw_set_essid() -
    This function sets the ssid received from wpa_supplicant
-   to the CSR roam profile. 
-   
+   to the CSR roam profile.
+
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
 
-int iw_set_essid(struct net_device *dev, 
+int iw_set_essid(struct net_device *dev,
                         struct iw_request_info *info,
                         union iwreq_data *wrqu, char *extra)
 {
@@ -2842,9 +2868,9 @@
     eCsrAuthType RSNAuthType;
     tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
     hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
- 
-    pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); 
-    
+
+    pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
+
     ENTER();
 
     if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
@@ -2861,13 +2887,13 @@
     if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
         return -EINVAL;
     pRoamProfile = &pWextState->roamProfile;
-    if (pRoamProfile) 
+    if (pRoamProfile)
     {
         if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
              ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
         {
             VOS_STATUS vosStatus;
-            // need to issue a disconnect to CSR. 
+            // need to issue a disconnect to CSR.
             INIT_COMPLETION(pAdapter->disconnect_comp_var);
             vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
 
@@ -2877,14 +2903,14 @@
         }
     }
     /** wpa_supplicant 0.8.x, wext driver uses */
-    else 
+    else
     {
         return -EINVAL;
     }
     /** wpa_supplicant 0.8.x, wext driver uses */
-    /** when cfg80211 defined, wpa_supplicant wext driver uses 
-      zero-length, null-string ssid for force disconnection. 
-      after disconnection (if previously connected) and cleaning ssid, 
+    /** when cfg80211 defined, wpa_supplicant wext driver uses
+      zero-length, null-string ssid for force disconnection.
+      after disconnection (if previously connected) and cleaning ssid,
       driver MUST return success */
     if ( 0 == wrqu->essid.length ) {
         return 0;
@@ -2897,14 +2923,14 @@
        pWextState->roamProfile.uapsd_mask = 0;
     }
     pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
-     
+
     pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
-   
-    vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId)); 
+
+    vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
     vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
     if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
         IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
-   
+
         //set gen ie
         hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
 
@@ -2968,33 +2994,33 @@
     // Disable auto BMPS entry by PMC until DHCP is done
     sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
 
-    pWextState->roamProfile.csrPersona = pAdapter->device_mode; 
+    pWextState->roamProfile.csrPersona = pAdapter->device_mode;
     (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
     status = sme_RoamConnect( hHal,pAdapter->sessionId, &(pWextState->roamProfile),&roamId);
-    pRoamProfile->ChannelInfo.ChannelList = NULL; 
+    pRoamProfile->ChannelInfo.ChannelList = NULL;
     pRoamProfile->ChannelInfo.numOfChannels = 0;
 
     EXIT();
     return status;
 }
 /**---------------------------------------------------------------------------
-  
-  \brief iw_get_essid() - 
+
+  \brief iw_get_essid() -
    This function returns the essid to the wpa_supplicant.
-   
+
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
-int iw_get_essid(struct net_device *dev, 
+int iw_get_essid(struct net_device *dev,
                        struct iw_request_info *info,
                        struct iw_point *dwrq, char *extra)
 {
    hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
-   hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); 
+   hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
    ENTER();
 
@@ -3016,27 +3042,27 @@
    return 0;
 }
 /**---------------------------------------------------------------------------
-  
-  \brief iw_set_auth() - 
+
+  \brief iw_set_auth() -
    This function sets the auth type received from the wpa_supplicant.
-   
+
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
 int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
                         union iwreq_data *wrqu,char *extra)
 {
    hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
-   hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); 
+   hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
    hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
    tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
-   eCsrEncryptionType mcEncryptionType;   
+   eCsrEncryptionType mcEncryptionType;
    eCsrEncryptionType ucEncryptionType;
-   
+
    ENTER();
 
    if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
@@ -3049,88 +3075,88 @@
    switch(wrqu->param.flags & IW_AUTH_INDEX)
    {
       case IW_AUTH_WPA_VERSION:
-        
+
          pWextState->wpaVersion = wrqu->param.value;
-       
+
          break;
-   
+
    case IW_AUTH_CIPHER_PAIRWISE:
    {
-      if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {            
+      if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
          ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
-      }           
+      }
       else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
          ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
-      }            
+      }
       else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
          ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
-      }    
-            
+      }
+
      else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
-           
-         if( (IW_AUTH_KEY_MGMT_802_1X 
-                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)  ) 
+
+         if( (IW_AUTH_KEY_MGMT_802_1X
+                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)  )
                  && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
                 /*Dynamic WEP key*/
-             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;     
+             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
          else
                 /*Static WEP key*/
-             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;              
-      }      
+             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
+      }
       else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
-           
-         if( ( IW_AUTH_KEY_MGMT_802_1X 
-                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) ) 
+
+         if( ( IW_AUTH_KEY_MGMT_802_1X
+                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
                  && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
                   /*Dynamic WEP key*/
             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
          else
                 /*Static WEP key*/
             ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
-               
+
          }
          else {
-           
+
                hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
-                      __func__, wrqu->param.value); 
+                      __func__, wrqu->param.value);
                return -EINVAL;
          }
-       
+
          pRoamProfile->EncryptionType.numEntries = 1;
          pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
-      }     
+      }
       break;
       case IW_AUTH_CIPHER_GROUP:
-      {            
+      {
           if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
             mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
       }
-        
+
       else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
              mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
       }
-        
-      else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {              
+
+      else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
               mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
       }
-        
+
       else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
-           
-         if( ( IW_AUTH_KEY_MGMT_802_1X 
-                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) 
-                 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))  
-                                            
+
+         if( ( IW_AUTH_KEY_MGMT_802_1X
+                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
+                 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
+
             mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
-            
-         else            
-               mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; 
+
+         else
+               mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
       }
-        
-      else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) 
-      {     
+
+      else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
+      {
              /*Dynamic WEP keys won't work with shared keys*/
-         if( ( IW_AUTH_KEY_MGMT_802_1X 
-                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) 
+         if( ( IW_AUTH_KEY_MGMT_802_1X
+                     == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
                  && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
          {
             mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
@@ -3141,12 +3167,12 @@
          }
       }
       else {
-           
+
           hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
-                 __func__, wrqu->param.value); 
+                 __func__, wrqu->param.value);
           return -EINVAL;
        }
-              
+
          pRoamProfile->mcEncryptionType.numEntries = 1;
          pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
       }
@@ -3156,9 +3182,9 @@
       {
            /*Save the auth algo here and set auth type to SME Roam profile
                 in the iw_set_ap_address*/
-          if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)    
+          if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
              pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
-          
+
           else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
              pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
 
@@ -3177,9 +3203,9 @@
          if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
             //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
             hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
-            /* Set the CCKM bit in authKeyMgmt */ 
-            /* Right now, this breaks all ref to authKeyMgmt because our 
-             * code doesn't realize it is a "bitfield" 
+            /* Set the CCKM bit in authKeyMgmt */
+            /* Right now, this breaks all ref to authKeyMgmt because our
+             * code doesn't realize it is a "bitfield"
              */
             pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
             /*Set the key management to 802.1X*/
@@ -3230,34 +3256,34 @@
       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
       case IW_AUTH_ROAMING_CONTROL:
       case IW_AUTH_PRIVACY_INVOKED:
-         
+
       default:
-         
+
          hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
                wrqu->param.flags & IW_AUTH_INDEX);
       break;
    }
-   
+
    EXIT();
    return 0;
 }
 /**---------------------------------------------------------------------------
- 
-  \brief iw_get_auth() - 
+
+  \brief iw_get_auth() -
    This function returns the auth type to the wpa_supplicant.
-   
+
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
 int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
                          union iwreq_data *wrqu,char *extra)
 {
     hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
-    hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); 
+    hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
     tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
     ENTER();
 
@@ -3344,7 +3370,7 @@
         }
    }
 
-    if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) 
+    if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
     {
         switch(pRoamProfile->negotiatedMCEncryptionType)
         {
@@ -3377,17 +3403,17 @@
     return 0;
 }
 /**---------------------------------------------------------------------------
-  
-  \brief iw_set_ap_address() - 
-   This function calls the sme_RoamConnect function to associate 
+
+  \brief iw_set_ap_address() -
+   This function calls the sme_RoamConnect function to associate
    to the AP with the specified BSSID received from the wpa_supplicant.
-   
+
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
 int iw_set_ap_address(struct net_device *dev,
         struct iw_request_info *info,
@@ -3401,19 +3427,19 @@
           pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
     vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
     EXIT();
-   
+
     return 0;
 }
 /**---------------------------------------------------------------------------
-  
-  \brief iw_get_ap_address() - 
+
+  \brief iw_get_ap_address() -
    This function returns the BSSID to the wpa_supplicant
   \param  - dev - Pointer to the net device.
               - info - Pointer to the iw_request_info.
               - wrqu - Pointer to the iwreq_data.
-              - extra - Pointer to the data.        
+              - extra - Pointer to the data.
   \return - 0 for success, non zero for failure
-  
+
   --------------------------------------------------------------------------*/
 int iw_get_ap_address(struct net_device *dev,
                              struct iw_request_info *info,
diff --git a/CORE/HDD/src/wlan_hdd_cfg.c b/CORE/HDD/src/wlan_hdd_cfg.c
index 57b1c57..f7fcfa5 100644
--- a/CORE/HDD/src/wlan_hdd_cfg.c
+++ b/CORE/HDD/src/wlan_hdd_cfg.c
@@ -2140,6 +2140,21 @@
               CFG_ANDRIOD_POWER_SAVE_MIN,
               CFG_ANDRIOD_POWER_SAVE_MAX),
 
+REG_VARIABLE( CFG_IBSS_ADHOC_CHANNEL_5GHZ_NAME, WLAN_PARAM_Integer,
+              hdd_config_t, AdHocChannel5G,
+              VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+              CFG_IBSS_ADHOC_CHANNEL_5GHZ_DEFAULT,
+              CFG_IBSS_ADHOC_CHANNEL_5GHZ_MIN,
+              CFG_IBSS_ADHOC_CHANNEL_5GHZ_MAX),
+
+REG_VARIABLE( CFG_IBSS_ADHOC_CHANNEL_24GHZ_NAME, WLAN_PARAM_Integer,
+              hdd_config_t, AdHocChannel24G,
+              VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+              CFG_IBSS_ADHOC_CHANNEL_24GHZ_DEFAULT,
+              CFG_IBSS_ADHOC_CHANNEL_24GHZ_MIN,
+              CFG_IBSS_ADHOC_CHANNEL_24GHZ_MAX),
+
+
 #ifdef WLAN_FEATURE_11AC
 REG_VARIABLE( CFG_VHT_SU_BEAMFORMEE_CAP_FEATURE, WLAN_PARAM_Integer,
              hdd_config_t, enableTxBF,
@@ -3760,7 +3775,8 @@
     smeConfig.csrConfig.enableTxBF = pConfig->enableTxBF;
     smeConfig.csrConfig.txBFCsnValue = pConfig->txBFCsnValue;
 #endif
-   smeConfig.csrConfig.AdHocChannel5G            = 44;
+   smeConfig.csrConfig.AdHocChannel5G            = pConfig->AdHocChannel5G;
+   smeConfig.csrConfig.AdHocChannel24            = pConfig->AdHocChannel24G;
    smeConfig.csrConfig.ProprietaryRatesEnabled   = 0;
    smeConfig.csrConfig.HeartbeatThresh50         = 40;
    smeConfig.csrConfig.bandCapability            = pConfig->nBandCapability;
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 55f8af2..bd7d516 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -2550,6 +2550,7 @@
                 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
                 pRoamProfile->phyMode =
                     hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
+                pAdapter->device_mode = WLAN_HDD_IBSS;
                 wdev->iftype = type;
                 break;
 
diff --git a/CORE/HDD/src/wlan_hdd_tx_rx.c b/CORE/HDD/src/wlan_hdd_tx_rx.c
index 63d617d..36b0011 100644
--- a/CORE/HDD/src/wlan_hdd_tx_rx.c
+++ b/CORE/HDD/src/wlan_hdd_tx_rx.c
@@ -539,13 +539,41 @@
    v_SIZE_t pktListSize = 0;
    hdd_adapter_t *pAdapter =  WLAN_HDD_GET_PRIV_PTR(dev);
    v_BOOL_t granted;
-
+   v_U8_t STAId = WLAN_MAX_STA_COUNT;
    hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
    
    v_BOOL_t txSuspended = VOS_FALSE;
 
    ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled;
 
+   if (WLAN_HDD_IBSS == pAdapter->device_mode)
+   {
+      v_MACADDR_t *pDestMacAddress = (v_MACADDR_t*)skb->data;
+
+      STAId = *(v_U8_t *)(((v_U8_t *)(skb->data)) - 1);
+
+      if ((STAId == HDD_WLAN_INVALID_STA_ID) &&
+          (vos_is_macaddr_broadcast( pDestMacAddress ) ||
+           vos_is_macaddr_group(pDestMacAddress)))
+      {
+         STAId = IBSS_BROADCAST_STAID;
+         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_LOW,
+                 "%s: BC/MC packet", __func__);
+      }
+      else if (STAId == HDD_WLAN_INVALID_STA_ID)
+      {
+         VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
+                   "%s: Received Unicast frame with invalid staID", __func__);
+         ++pAdapter->stats.tx_dropped;
+         ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped;
+         kfree_skb(skb);
+         return NETDEV_TX_OK;
+      }
+   }
+   else
+   {
+      STAId = pHddStaCtx->conn_info.staId[0];
+   }
    //Get TL AC corresponding to Qdisc queue index/AC.
    ac = hdd_QdiscAcToTlAC[skb->queue_mapping];
 
@@ -567,10 +595,13 @@
     *occurs very frequently in low traffic cases */
    if((pAdapter->wmm_tx_queue[ac].count + 1) % 10 == 0)
    {
-           /* Use the following debug statement during Engineering Debugging.There are chance that this will lead to a Watchdog Bark
+      /* Use the following debug statement during Engineering Debugging.There are chance that this will lead to a Watchdog Bark
             * if it is in the mainline code and if the log level is enabled by someone for debugging
            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s:Queue is Filling up.Inform TL again about pending packets", __func__);*/
-           WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, pHddStaCtx->conn_info.staId[0], ac );
+
+       WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
+                              STAId, ac
+                             );
    }
    //If we have already reached the max queue size, disable the TX queue
    if ( pAdapter->wmm_tx_queue[ac].count == pAdapter->wmm_tx_queue[ac].max_size)
@@ -632,13 +663,13 @@
    {
       status = hdd_wmm_acquire_access( pAdapter, ac, &granted );
    }
-
    if ( granted && ( pktListSize == 1 ))
    {
       //Let TL know we have a packet to send for this AC
       //VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s:Indicating Packet to TL", __func__);
-      status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, pHddStaCtx->conn_info.staId[0], ac );      
-
+      status = WLANTL_STAPktPending(
+                                  (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
+                                   STAId, ac );
       if ( !VOS_IS_STATUS_SUCCESS( status ) )
       {
          VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "%s: Failed to signal TL for AC=%d", __func__, ac );
@@ -662,6 +693,32 @@
 }
 
 /**============================================================================
+  @brief hdd_Ibss_GetStaId() - Get the StationID using the Peer Mac address
+
+  @param pHddStaCtx : [in] pointer to HDD Station Context
+  pMacAddress [in]  pointer to Peer Mac address
+  staID [out]  pointer to Station Index
+  @return    : VOS_STATUS_SUCCESS/VOS_STATUS_E_FAILURE
+  ===========================================================================*/
+
+VOS_STATUS hdd_Ibss_GetStaId(hdd_station_ctx_t *pHddStaCtx, v_MACADDR_t *pMacAddress, v_U8_t *staId)
+{
+    v_U8_t idx;
+
+    for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
+    {
+        if (vos_mem_compare(&pHddStaCtx->conn_info.peerMacAddress[ idx ],
+                pMacAddress, sizeof(v_MACADDR_t)))
+        {
+            *staId = pHddStaCtx->conn_info.staId[idx];
+            return VOS_STATUS_SUCCESS;
+        }
+    }
+
+    return VOS_STATUS_E_FAILURE;
+}
+
+/**============================================================================
   @brief hdd_tx_timeout() - Function called by OS if there is any
   timeout during transmission. Since HDD simply enqueues packet
   and returns control to OS right away, this would never be invoked
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 6a49ea8..a02d390 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -1110,6 +1110,7 @@
         // Set the phymode correctly for IBSS.
         pConfig  = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
         pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
+        pAdapter->device_mode = WLAN_HDD_IBSS;
         wdev->iftype = NL80211_IFTYPE_ADHOC;
         break;
     case IW_MODE_INFRA:
diff --git a/CORE/HDD/src/wlan_hdd_wmm.c b/CORE/HDD/src/wlan_hdd_wmm.c
index 5992c6e..6d21411 100644
--- a/CORE/HDD/src/wlan_hdd_wmm.c
+++ b/CORE/HDD/src/wlan_hdd_wmm.c
@@ -1808,18 +1808,34 @@
 v_U16_t hdd_wmm_select_queue(struct net_device * dev, struct sk_buff *skb)
 {
    WLANTL_ACEnumType ac;
-   sme_QosWmmUpType up = 0;
+   sme_QosWmmUpType up = SME_QOS_WMM_UP_BE;
    v_USHORT_t queueIndex;
-
    hdd_adapter_t *pAdapter =  WLAN_HDD_GET_PRIV_PTR(dev);
 
+   /*Get the Station ID*/
+   if (WLAN_HDD_IBSS == pAdapter->device_mode)
+   {
+       v_U8_t *pSTAId = (v_U8_t *)(((v_U8_t *)(skb->data)) - 1);
+       v_MACADDR_t *pDestMacAddress = (v_MACADDR_t*)skb->data;
+
+       if ( VOS_STATUS_SUCCESS !=
+            hdd_Ibss_GetStaId(&pAdapter->sessionCtx.station,
+                               pDestMacAddress, pSTAId))
+       {
+          VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+                "%s: Failed to find right station pDestMacAddress: "
+                MAC_ADDRESS_STR , MAC_ADDR_ARRAY(pDestMacAddress),__func__);
+          *pSTAId = HDD_WLAN_INVALID_STA_ID;
+          goto done;
+       }
+   }
    // if we don't want QoS or the AP doesn't support Qos
    // All traffic will get equal opportuniy to transmit data frames.
    if( hdd_wmm_is_active(pAdapter) ) {
       /* Get the user priority from IP header & corresponding AC */
       hdd_wmm_classify_pkt (pAdapter, skb, &ac, &up);
    }
-
+done:
    skb->priority = up;
    queueIndex = hddLinuxUpToAcMap[skb->priority];
 
diff --git a/CORE/MAC/src/pe/lim/limIbssPeerMgmt.c b/CORE/MAC/src/pe/lim/limIbssPeerMgmt.c
index e58eb0f..86dc642 100644
--- a/CORE/MAC/src/pe/lim/limIbssPeerMgmt.c
+++ b/CORE/MAC/src/pe/lim/limIbssPeerMgmt.c
@@ -1383,11 +1383,16 @@
 
     sirCopyMacAddr(currentBssId,psessionEntry->bssId);
 
+    limLog(pMac, LOG1, FL("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" MAC_ADDRESS_STR ),
+                                  MAC_ADDR_ARRAY(currentBssId), MAC_ADDR_ARRAY(pHdr->bssId));
     /* Check for IBSS Coalescing only if Beacon is from different BSS */
     if ( !palEqualMemory( pMac->hHdd, currentBssId, pHdr->bssId, sizeof( tSirMacAddr ) ) )
     {
         if (! fTsfLater) // No Coalescing happened.
+        {
+            PELOGW(limLog(pMac, LOGW, FL("No Coalescing happened"));)
             return eSIR_LIM_IGNORE_BEACON;
+        }
         /*
          * IBSS Coalescing happened.
          * save the received beacon, and delete the current BSS. The rest of the
@@ -1396,6 +1401,8 @@
         pMac->lim.gLimIbssCoalescingHappened = true;
         PELOGW(limLog(pMac, LOGW, FL("IBSS Coalescing happened"));)
         ibss_coalesce_save(pMac, pHdr, pBeacon);
+        limLog(pMac, LOGW, FL("Delete BSSID :" MAC_ADDRESS_STR ),
+                                  MAC_ADDR_ARRAY(currentBssId));
         ibss_bss_delete(pMac,psessionEntry);
         return eSIR_SUCCESS;
     }
@@ -1551,7 +1558,7 @@
 
                     (void) limDelSta(pMac, pStaDs, false /*asynchronous*/,psessionEntry);
                     limDeleteDphHashEntry(pMac, pStaDs->staAddr, peerIdx,psessionEntry);
-
+                    limReleasePeerIdx(pMac, peerIdx, psessionEntry);
                     //Send indication.
                     ibss_status_chg_notify( pMac, pTempNode->peerMacAddr, staIndex, 
                                             ucUcastSig, ucBcastSig,
diff --git a/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c b/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
index a72acf9..6f42da6 100644
--- a/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
+++ b/CORE/MAC/src/pe/lim/limLinkMonitoringAlgo.c
@@ -39,8 +39,9 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+
+
 /*
- * Airgo Networks, Inc proprietary. All rights reserved.
  * This file limLinkMonitoringAlgo.cc contains the code for
  * Link monitoring algorithm on AP and heart beat failure
  * handling on STA.
@@ -131,6 +132,9 @@
         case HAL_DEL_STA_REASON_CODE_KEEP_ALIVE:
         case HAL_DEL_STA_REASON_CODE_TIM_BASED:
              PELOGE(limLog(pMac, LOGE, FL(" Deleting station: staId = %d, reasonCode = %d"), pMsg->staId, pMsg->reasonCode);)
+             if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
+                 return;
+
              pStaDs = dphLookupAssocId(pMac, pMsg->staId, &pMsg->assocId, &psessionEntry->dph.dphHashTable);
 
              if (!pStaDs)
diff --git a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
index 7f48472..0bdcdec 100644
--- a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
@@ -2540,7 +2540,8 @@
         schEdcaProfileUpdate(pMac, psessionEntry);
         //TBD-RAJESH limInitPreauthList should re removed for IBSS also ?????
        //limInitPreAuthList(pMac);
-        limInitPeerIdxpool(pMac,psessionEntry);
+        if (0 == psessionEntry->freePeerIdxHead)
+            limInitPeerIdxpool(pMac,psessionEntry);
         // Create timers used by LIM
 #ifdef FIXME_GEN6  //following code may not be required, as limCreateTimers is now invoked from limInitialize (peStart)
         if (!pMac->lim.gLimTimersCreated)
diff --git a/CORE/TL/inc/wlan_qct_tl.h b/CORE/TL/inc/wlan_qct_tl.h
index c26f0c1..a40ce48 100644
--- a/CORE/TL/inc/wlan_qct_tl.h
+++ b/CORE/TL/inc/wlan_qct_tl.h
@@ -2621,4 +2621,45 @@
   v_PVOID_t       pvosGCtx
 );
 
+/*==========================================================================
+  FUNCTION   WLANTL_UpdateSTABssIdforIBSS
+
+  DESCRIPTION
+    HDD will call this API to update the BSSID for this Station.
+
+  DEPENDENCIES
+    The HDD Should registered the staID with TL before calling this function.
+
+  PARAMETERS
+
+    IN
+    pvosGCtx:    Pointer to the global vos context; a handle to TL's
+                    or WDA's control block can be extracted from its context
+    IN
+    ucSTAId       The Station ID for Bssid to be updated
+    IN
+    pBssid          BSSID to be updated
+
+  RETURN VALUE
+      The result code associated with performing the operation
+
+      VOS_STATUS_E_INVAL:  Input parameters are invalid
+      VOS_STATUS_E_FAULT:  Station ID is outside array boundaries or pointer to
+                           TL cb is NULL ; access would cause a page fault
+      VOS_STATUS_E_EXISTS: Station was not registered
+      VOS_STATUS_SUCCESS:  Everything is good :)
+
+    SIDE EFFECTS
+============================================================================*/
+
+VOS_STATUS
+WLANTL_UpdateSTABssIdforIBSS
+(
+  v_PVOID_t             pvosGCtx,
+  v_U8_t                ucSTAId,
+  v_U8_t               *pBssid
+);
+
+
+
 #endif /* #ifndef WLAN_QCT_WLANTL_H */
diff --git a/CORE/TL/src/wlan_qct_tl.c b/CORE/TL/src/wlan_qct_tl.c
index 5237837..46a1539 100644
--- a/CORE/TL/src/wlan_qct_tl.c
+++ b/CORE/TL/src/wlan_qct_tl.c
@@ -1815,6 +1815,93 @@
   return VOS_STATUS_SUCCESS;
 }/* WLANTL_GetSTAState */
 
+/*==========================================================================
+  FUNCTION   WLANTL_UpdateSTABssIdforIBSS
+
+  DESCRIPTION
+    HDD will call this API to update the BSSID for this Station.
+
+  DEPENDENCIES
+    The HDD Should registered the staID with TL before calling this function.
+
+  PARAMETERS
+
+    IN
+    pvosGCtx:    Pointer to the global vos context; a handle to TL's
+                    or WDA's control block can be extracted from its context
+    IN
+    ucSTAId       The Station ID for Bssid to be updated
+    IN
+    pBssid          BSSID to be updated
+
+  RETURN VALUE
+      The result code associated with performing the operation
+
+      VOS_STATUS_E_INVAL:  Input parameters are invalid
+      VOS_STATUS_E_FAULT:  Station ID is outside array boundaries or pointer to
+                           TL cb is NULL ; access would cause a page fault
+      VOS_STATUS_E_EXISTS: Station was not registered
+      VOS_STATUS_SUCCESS:  Everything is good :)
+
+    SIDE EFFECTS
+============================================================================*/
+
+
+VOS_STATUS
+WLANTL_UpdateSTABssIdforIBSS
+(
+  v_PVOID_t             pvosGCtx,
+  v_U8_t                ucSTAId,
+  v_U8_t               *pBssid
+)
+{
+  WLANTL_CbType*  pTLCb = NULL;
+  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
+
+  /*------------------------------------------------------------------------
+    Sanity check
+   ------------------------------------------------------------------------*/
+  if ( WLANTL_STA_ID_INVALID( ucSTAId ) )
+  {
+    TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
+             "WLAN TL:Invalid station id requested %s", __func__));
+    return VOS_STATUS_E_FAULT;
+  }
+
+  /*------------------------------------------------------------------------
+    Extract TL control block and check existance
+   ------------------------------------------------------------------------*/
+  pTLCb = VOS_GET_TL_CB(pvosGCtx);
+  if ( NULL == pTLCb )
+  {
+    TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
+         "WLAN TL:Invalid TL pointer from pvosGCtx %s", __func__));
+    return VOS_STATUS_E_FAULT;
+  }
+
+  if ( NULL == pTLCb->atlSTAClients[ucSTAId] )
+  {
+        TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
+            "WLAN TL:Client Memory was not allocated on %s", __func__));
+        return VOS_STATUS_E_FAILURE;
+  }
+
+  if ( 0 == pTLCb->atlSTAClients[ucSTAId]->ucExists )
+  {
+    TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_WARN,
+     "WLAN TL:Station was not previously registered %s", __func__));
+    return VOS_STATUS_E_EXISTS;
+  }
+
+  /*------------------------------------------------------------------------
+    Update the IBSS BSSID
+   ------------------------------------------------------------------------*/
+  vos_mem_copy( &pTLCb->atlSTAClients[ucSTAId]->wSTADesc.vBSSIDforIBSS,
+                                     pBssid, sizeof(v_MACADDR_t));
+
+  return VOS_STATUS_SUCCESS;
+}
+
 /*===========================================================================
 
   FUNCTION    WLANTL_STAPktPending
diff --git a/CORE/VOSS/inc/vos_types.h b/CORE/VOSS/inc/vos_types.h
index 58669cf..1758d55 100644
--- a/CORE/VOSS/inc/vos_types.h
+++ b/CORE/VOSS/inc/vos_types.h
@@ -168,6 +168,7 @@
     VOS_P2P_GO_MODE,
     VOS_MONITOR_MODE,
     VOS_FTM_MODE = 5,
+    VOS_IBSS_MODE,
     VOS_MAX_NO_OF_MODE
 
 } tVOS_CON_MODE;
diff --git a/CORE/WDA/src/wlan_qct_wda.c b/CORE/WDA/src/wlan_qct_wda.c
index 7550e0a..99d93a7 100644
--- a/CORE/WDA/src/wlan_qct_wda.c
+++ b/CORE/WDA/src/wlan_qct_wda.c
@@ -4725,7 +4725,9 @@
     * and in AP mode start BA activity check timer after BSS start */
    if( ((linkStateParams->state == eSIR_LINK_POSTASSOC_STATE) &&
          status == WDI_STATUS_SUCCESS) ||  ((status == WDI_STATUS_SUCCESS) &&
-       (linkStateParams->state == eSIR_LINK_AP_STATE)) )
+       (linkStateParams->state == eSIR_LINK_AP_STATE)) ||
+       ((status == WDI_STATUS_SUCCESS) &&
+       (linkStateParams->state == eSIR_LINK_IBSS_STATE)))
    {
       WDA_START_TIMER(&pWDA->wdaTimers.baActivityChkTmr);
    }