Merge branch 'master' of ssh://git.codeaurora.org:9222/external/wlan/prima
diff --git a/CORE/DXE/inc/wlan_qct_dxe.h b/CORE/DXE/inc/wlan_qct_dxe.h
index 14492be..1129b7a 100644
--- a/CORE/DXE/inc/wlan_qct_dxe.h
+++ b/CORE/DXE/inc/wlan_qct_dxe.h
@@ -123,7 +123,7 @@
        RX Frame Ready indication CB
 
   @  Parameters
-         pVoid         pAdaptor : Driver global control block pointer
+         pVoid         pAdapter : Driver global control block pointer
          palPacket     pRXFramePtr : Received Frame Pointer
          pVoid         userCtxt : DTS user contect pointer
 
@@ -140,7 +140,7 @@
       TX complete indication CB
 
   @  Parameters
-         pVoid      pAdaptor : Driver global control block pointer
+         pVoid      pAdapter : Driver global control block pointer
          void       pTXFramePtr : Completed TX Frame Pointer
          pVoid      userCtxt : DTS user contect pointer
 
@@ -157,7 +157,7 @@
        DXE Low resource indication CB
 
   @  Parameters
-      pVoid      pAdaptor : Driver global control block pointer
+      pVoid      pAdapter : Driver global control block pointer
       BOOL      lowResourceCondition : DXE low resource or not
       pVoid      userCtxt : DTS user contect pointer
 
@@ -196,7 +196,7 @@
       Allocate, DXE local control block, DXE descriptor pool, DXE descriptor control block pool
 
   @  Parameters
-      pVoid      pAdaptor : Driver global control block pointer
+      pVoid      pAdapter : Driver global control block pointer
 
   @  Return
       pVoid DXE local module control block pointer
diff --git a/CORE/DXE/src/wlan_qct_dxe.c b/CORE/DXE/src/wlan_qct_dxe.c
index 914b845..e9b872b 100644
--- a/CORE/DXE/src/wlan_qct_dxe.c
+++ b/CORE/DXE/src/wlan_qct_dxe.c
@@ -3968,7 +3968,7 @@
       Allocate, DXE local control block, DXE descriptor pool, DXE descriptor control block pool
 
   @  Parameters
-      pVoid      pAdaptor : Driver global control block pointer
+      pVoid      pAdapter : Driver global control block pointer
 
   @  Return
       pVoid DXE local module control block pointer
@@ -4873,6 +4873,11 @@
       dxeCtxt->setPowerStateCb(status, 
                                dxeCtxt->dxeChannel[WDTS_CHANNEL_TX_LOW_PRI].descBottomLocPhyAddr);
    }
+   else
+   {
+      HDXE_MSG(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_FATAL,
+            "%s State of DXE is WLANDXE_POWER_STATE_BMPS_PENDING, so cannot proceed", __func__);
+   }
    /* Free MSG buffer */
    wpalMemoryFree(msgPtr);
    HDXE_MSG(eWLAN_MODULE_DAL_DATA, eWLAN_PAL_TRACE_LEVEL_INFO_LOW,
diff --git a/CORE/HDD/inc/wlan_hdd_tdls.h b/CORE/HDD/inc/wlan_hdd_tdls.h
new file mode 100644
index 0000000..0a357e5
--- /dev/null
+++ b/CORE/HDD/inc/wlan_hdd_tdls.h
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2012 Qualcomm Atheros, Inc.
+* All Rights Reserved.
+* Qualcomm Atheros Confidential and Proprietary.
+*/
+
+#ifndef __HDD_TDSL_H
+#define __HDD_TDSL_H
+/**===========================================================================
+
+\file         wlan_hdd_tdls.h
+
+\brief       Linux HDD TDLS include file
+               Copyright 2012 (c) Qualcomm, Incorporated.
+               All Rights Reserved.
+               Qualcomm Confidential and Proprietary.
+
+==========================================================================*/
+
+#define MAX_NUM_TDLS_PEER	4
+
+extern int wlan_hdd_saveTdlsPeer(tCsrRoamInfo *pRoamInfo);
+
+extern int wlan_hdd_findTdlsPeer(tSirMacAddr peerMac);
+
+#endif // __HDD_TDSL_H
diff --git a/CORE/HDD/inc/wlan_hdd_tx_rx.h b/CORE/HDD/inc/wlan_hdd_tx_rx.h
index 669e216..07723f1 100644
--- a/CORE/HDD/inc/wlan_hdd_tx_rx.h
+++ b/CORE/HDD/inc/wlan_hdd_tx_rx.h
@@ -223,7 +223,7 @@
   @brief hdd_mon_tx_mgmt_pkt() - Transmit MGMT packet received on monitor 
                                  interface.
 
-  @param pAdapter: [in] SAP/P2P GO adaptor. 
+  @param pAdapter: [in] SAP/P2P GO adapter.
   ===========================================================================*/
 void hdd_mon_tx_mgmt_pkt(hdd_adapter_t* pAdapter);
 
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index b5df531..1e6a1f2 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -3206,7 +3206,7 @@
 
   \brief hdd_ResetCountryCodeAfterDisAssoc -
   This function reset the country code to default
-  \param  - pAdapter - Pointer to HDD adaptor
+  \param  - pAdapter - Pointer to HDD adapter
   \return - nothing
 
   --------------------------------------------------------------------------*/
diff --git a/CORE/HDD/src/wlan_hdd_cfg.c b/CORE/HDD/src/wlan_hdd_cfg.c
index 17bf72f..15d03d4 100644
--- a/CORE/HDD/src/wlan_hdd_cfg.c
+++ b/CORE/HDD/src/wlan_hdd_cfg.c
@@ -2635,7 +2635,6 @@
    }
    *len = 0;
 
-#ifdef VERSION_USING_STRPBRK
    while ( (s != NULL) && (*len < intArrayMaxLen) )
    {
       int val;
@@ -2650,24 +2649,6 @@
       if( s )
          s++;
    }
-#else
-   while( (*s != '\0')  && (*len < intArrayMaxLen) )
-   {
-      unsigned long val;
-      int rv;
-
-      rv = kstrtoul( s, 10, &val );
-      if (rv < 0)
-          return VOS_STATUS_E_INVAL;
-      if( val )
-      {
-         intArray[*len] = (tANI_U8) val;
-         *len += 1;
-      }
-      if( *s )
-         s++;
-   }
-#endif
 
    return VOS_STATUS_SUCCESS;
    
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 827d705..75262c2 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -5012,7 +5012,7 @@
     }
 
     //If Device Mode is Station Concurrent Sessions Exit BMps
-    //P2P Mode will be taken care in Open/close adaptor
+    //P2P Mode will be taken care in Open/close adapter
     if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
         (vos_concurrent_sessions_running()))
     {
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index ccca4e6..17b0f9b 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -549,7 +549,7 @@
             struct iw_michaelmicfailure msg;
             memset(&msg, '\0', sizeof(msg));
             msg.src_addr.sa_family = ARPHRD_ETHER;
-            memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(msg.src_addr.sa_data));
+            memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
             hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(msg.src_addr.sa_data));
             if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
              msg.flags = IW_MICFAILURE_GROUP;
@@ -578,7 +578,7 @@
         case eSAP_STA_REASSOC_EVENT:
             wrqu.addr.sa_family = ARPHRD_ETHER;
             memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac, 
-                sizeof(wrqu.addr.sa_data));
+                sizeof(v_MACADDR_t));
             hddLog(LOG1, " associated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data));
             we_event = IWEVREGISTERED;
             
@@ -656,7 +656,7 @@
             break;
         case eSAP_STA_DISASSOC_EVENT:
             memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
-                   sizeof(wrqu.addr.sa_data));
+                   sizeof(v_MACADDR_t));
             hddLog(LOG1, " disassociated "MAC_ADDRESS_STR"\n", MAC_ADDR_ARRAY(wrqu.addr.sa_data));
             if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
                 hddLog(LOG1," User initiated disassociation");
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index fd87a83..52d4e34 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -202,7 +202,7 @@
 
    if(NULL == pAdapter)
    {
-      hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adaptor Null Pointer", __func__);
+      hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__);
       VOS_ASSERT(0);
       return NOTIFY_DONE;
    }
diff --git a/CORE/HDD/src/wlan_hdd_softap_tx_rx.c b/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
index a6c0392..c87f42c 100644
--- a/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
+++ b/CORE/HDD/src/wlan_hdd_softap_tx_rx.c
@@ -1302,7 +1302,7 @@
                                        v_BOOL_t fWmmEnabled )
 {
    VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
-   WLAN_STADescType staDesc;   
+   WLAN_STADescType staDesc = {0};   
    hdd_context_t *pHddCtx = pAdapter->pHddCtx;
    hdd_adapter_t *pmonAdapter = NULL;
 
@@ -1410,6 +1410,8 @@
    staDesc.ucInitState = fAuthRequired ?
       WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
 
+   staDesc.ucIsReplayCheckValid = VOS_FALSE;
+
    // Register the Station with TL...      
    vosStatus = WLANTL_RegisterSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, 
                                          hdd_softap_rx_packet_cbk, 
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
new file mode 100644
index 0000000..a541cb8
--- /dev/null
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2012 Qualcomm Atheros, Inc.
+* All Rights Reserved.
+* Qualcomm Atheros Confidential and Proprietary.
+*/
+
+
+/**========================================================================
+
+  \file  wlan_hdd_tdls.c
+
+  \brief WLAN Host Device Driver implementation for P2P commands interface
+
+  Copyright 2012 (c) Qualcomm, Incorporated.  All Rights Reserved.
+
+  Qualcomm Confidential and Proprietary.
+
+  ========================================================================*/
+
+#include <wlan_hdd_includes.h>
+#include <wlan_hdd_hostapd.h>
+#include <net/cfg80211.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/etherdevice.h>
+#include <net/ieee80211_radiotap.h>
+#include "wlan_hdd_tdls.h"
+
+typedef struct hddTdlsPeerInfo {
+    tSirMacAddr peerMac;
+    tANI_U16  	staId ;
+} hddTdlsPInfo;
+
+static struct {
+    hddTdlsPInfo peer;
+} hddTdlsPTable[MAX_NUM_TDLS_PEER];
+
+int wlan_hdd_saveTdlsPeer(tCsrRoamInfo *pRoamInfo)
+{
+    int i;
+
+    for (i = 0; i < MAX_NUM_TDLS_PEER; i++) {
+       if (0 == hddTdlsPTable[i].peer.staId) break;
+
+    }
+
+    if (i < MAX_NUM_TDLS_PEER) {
+       vos_mem_copy( hddTdlsPTable[i].peer.peerMac, pRoamInfo->peerMac, 6 );
+       hddTdlsPTable[i].peer.staId = pRoamInfo->staId;
+       VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, 
+                     "saveTdlsPeer: saved staId %d", pRoamInfo->staId);
+       return i;
+    }
+
+    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, 
+		 "saveTdlsPeer: NOT saving staId %d", pRoamInfo->staId);
+    return -1;
+}
+
+int wlan_hdd_findTdlsPeer(tSirMacAddr peerMac)
+{
+    int i;
+
+    for (i = 0; i < MAX_NUM_TDLS_PEER; i++) {
+        if (VOS_TRUE == vos_mem_compare( peerMac, hddTdlsPTable[i].peer.peerMac, 6 ))
+	    break;
+    }
+
+    if (i < MAX_NUM_TDLS_PEER) {
+	VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, 
+                     "findTdlsPeer: found staId %d", hddTdlsPTable[i].peer.staId);
+	return hddTdlsPTable[i].peer.staId;
+    }
+
+    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, 
+		"findTdlsPeer: staId NOT found");
+    return -1;
+}
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 4c0d6dd..33b26a6 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -4085,7 +4085,7 @@
            }
            else
            {
-              printk(KERN_ERR"SAP adaptor not found to stop it!\n");
+              printk(KERN_ERR"SAP adapter not found to stop it!\n");
            }
 
            break;
@@ -5823,7 +5823,7 @@
     if (!uTotalSize)
     {
       VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-                "Invalid input parametery type : %d with no value at offset %d",
+                "Invalid input parameter type : %d with no value at offset %d",
                 ucType, nOffset);
       return VOS_STATUS_E_FAILURE;
     }
@@ -5854,7 +5854,7 @@
       break;
       default:
         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-                "Invalid input parametery type : %d with value: %d at offset %d",
+                "Invalid input parameter type : %d with value: %d at offset %d",
                 ucType, uValue,  nOffset);
       return VOS_STATUS_E_FAILURE;
     }
diff --git a/CORE/MAC/inc/qwlan_version.h b/CORE/MAC/inc/qwlan_version.h
index 0c062d8..a1ea02a 100644
--- a/CORE/MAC/inc/qwlan_version.h
+++ b/CORE/MAC/inc/qwlan_version.h
@@ -40,8 +40,8 @@
 #define QWLAN_VERSION_MINOR            2
 #define QWLAN_VERSION_PATCH            0
 #define QWLAN_VERSION_EXTRA            ""
-#define QWLAN_VERSION_BUILD            39
+#define QWLAN_VERSION_BUILD            40
 
-#define QWLAN_VERSIONSTR               "3.2.0.39"
+#define QWLAN_VERSIONSTR               "3.2.0.40"
 
 #endif /* QWLAN_VERSION_H */
diff --git a/CORE/MAC/inc/sirApi.h b/CORE/MAC/inc/sirApi.h
index 4d05d7a..f8bf4e8 100644
--- a/CORE/MAC/inc/sirApi.h
+++ b/CORE/MAC/inc/sirApi.h
@@ -2783,9 +2783,11 @@
     tANI_U32             bRssiThres2NegCross : 1;
     tANI_U32             bRssiThres3PosCross : 1;
     tANI_U32             bRssiThres3NegCross : 1;
-    tANI_U32             bReserved           : 26;
+    v_S7_t               avgRssi             : 8;
+    tANI_U32             bReserved           : 18;
 #else
-    tANI_U32             bReserved           : 26;
+    tANI_U32             bReserved           : 18;
+    v_S7_t               avgRssi             : 8;
     tANI_U32             bRssiThres3NegCross : 1;
     tANI_U32             bRssiThres3PosCross : 1;
     tANI_U32             bRssiThres2NegCross : 1;
diff --git a/CORE/MAC/inc/wniCfgAp.h b/CORE/MAC/inc/wniCfgAp.h
index cef2362..2e599b3 100644
--- a/CORE/MAC/inc/wniCfgAp.h
+++ b/CORE/MAC/inc/wniCfgAp.h
@@ -1459,11 +1459,11 @@
 #define WNI_CFG_EXT_HT_CAP_INFO_RESERVED2    12
 
 #define WNI_CFG_TX_BF_CAP_STAMIN    0
-#define WNI_CFG_TX_BF_CAP_STAMAX    2147483647
+#define WNI_CFG_TX_BF_CAP_STAMAX    4294967295
 #define WNI_CFG_TX_BF_CAP_STADEF    0
 
 #define WNI_CFG_TX_BF_CAP_APMIN    0
-#define WNI_CFG_TX_BF_CAP_APMAX    2147483647
+#define WNI_CFG_TX_BF_CAP_APMAX    4294967295
 #define WNI_CFG_TX_BF_CAP_APDEF    0
 
 #define WNI_CFG_AS_CAP_STAMIN    0
@@ -2088,11 +2088,11 @@
 #define WNI_CFG_WPS_REQUEST_TYPE_APDEF    3
 
 #define WNI_CFG_WPS_CFG_METHOD_STAMIN    0
-#define WNI_CFG_WPS_CFG_METHOD_STAMAX    2147483647
+#define WNI_CFG_WPS_CFG_METHOD_STAMAX    4294967295
 #define WNI_CFG_WPS_CFG_METHOD_STADEF    8
 
 #define WNI_CFG_WPS_CFG_METHOD_APMIN    0
-#define WNI_CFG_WPS_CFG_METHOD_APMAX    2147483647
+#define WNI_CFG_WPS_CFG_METHOD_APMAX    4294967295
 #define WNI_CFG_WPS_CFG_METHOD_APDEF    25952654
 
 #define WNI_CFG_WPS_PRIMARY_DEVICE_CATEGORY_STAMIN    0
@@ -2104,11 +2104,11 @@
 #define WNI_CFG_WPS_PRIMARY_DEVICE_CATEGORY_APDEF    6
 
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMIN    0
-#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMAX    2147483647
+#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMAX    4294967295
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STADEF    5304836
 
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_APMIN    0
-#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_APMAX    2147483647
+#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_APMAX    4294967295
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_APDEF    5304836
 
 #define WNI_CFG_WPS_DEVICE_SUB_CATEGORY_STAMIN    0
@@ -2136,11 +2136,11 @@
 #define WNI_CFG_WPS_CONFIGURATION_ERROR_APDEF    0
 
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMIN    0
-#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMAX    2147483647
+#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMAX    4294967295
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STADEF    0
 
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_APMIN    0
-#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_APMAX    2147483647
+#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_APMAX    4294967295
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_APDEF    0
 
 #define WNI_CFG_WPS_ASSOC_METHOD_STAMIN    0
diff --git a/CORE/MAC/inc/wniCfgAp.h.rej b/CORE/MAC/inc/wniCfgAp.h.rej
new file mode 100644
index 0000000..93c6e74
--- /dev/null
+++ b/CORE/MAC/inc/wniCfgAp.h.rej
@@ -0,0 +1,8 @@
+diff a/prima/CORE/MAC/inc/wniCfgAp.h b/prima/CORE/MAC/inc/wniCfgAp.h	(rejected hunks)
+@@ -1,4 +1,6 @@
+ /*
++ * Copyright (C) 2011-2012 Qualcomm Atheros, Inc. All Rights Reserved.
++ * Qualcomm Atheros Confidential and Proprietary.
+  * Copyright (C) 2007-2009 QUALCOMM Incorporated. All rights reserved. Proprietary and Confidential.
+  */
+ 
diff --git a/CORE/MAC/inc/wniCfgSta.h b/CORE/MAC/inc/wniCfgSta.h
index cf561b5..dc805a8 100644
--- a/CORE/MAC/inc/wniCfgSta.h
+++ b/CORE/MAC/inc/wniCfgSta.h
@@ -1036,7 +1036,7 @@
 #define WNI_CFG_EXT_HT_CAP_INFO_RESERVED2    12
 
 #define WNI_CFG_TX_BF_CAP_STAMIN    0
-#define WNI_CFG_TX_BF_CAP_STAMAX    2147483647
+#define WNI_CFG_TX_BF_CAP_STAMAX    4294967295
 #define WNI_CFG_TX_BF_CAP_STADEF    0
 
 #define WNI_CFG_AS_CAP_STAMIN    0
@@ -1405,7 +1405,7 @@
 #define WNI_CFG_WPS_REQUEST_TYPE_STADEF    0
 
 #define WNI_CFG_WPS_CFG_METHOD_STAMIN    0
-#define WNI_CFG_WPS_CFG_METHOD_STAMAX    2147483647
+#define WNI_CFG_WPS_CFG_METHOD_STAMAX    4294967295
 #define WNI_CFG_WPS_CFG_METHOD_STADEF    8
 
 #define WNI_CFG_WPS_PRIMARY_DEVICE_CATEGORY_STAMIN    0
@@ -1413,7 +1413,7 @@
 #define WNI_CFG_WPS_PRIMARY_DEVICE_CATEGORY_STADEF    1
 
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMIN    0
-#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMAX    2147483647
+#define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STAMAX    4294967295
 #define WNI_CFG_WPS_PIMARY_DEVICE_OUI_STADEF    5304836
 
 #define WNI_CFG_WPS_DEVICE_SUB_CATEGORY_STAMIN    0
@@ -1429,7 +1429,7 @@
 #define WNI_CFG_WPS_CONFIGURATION_ERROR_STADEF    0
 
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMIN    0
-#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMAX    2147483647
+#define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STAMAX    4294967295
 #define WNI_CFG_WPS_DEVICE_PASSWORD_ID_STADEF    0
 
 #define WNI_CFG_WPS_ASSOC_METHOD_STAMIN    0
diff --git a/CORE/MAC/inc/wniCfgSta.h.rej b/CORE/MAC/inc/wniCfgSta.h.rej
new file mode 100644
index 0000000..79e7544
--- /dev/null
+++ b/CORE/MAC/inc/wniCfgSta.h.rej
@@ -0,0 +1,8 @@
+diff a/prima/CORE/MAC/inc/wniCfgSta.h b/prima/CORE/MAC/inc/wniCfgSta.h	(rejected hunks)
+@@ -1,4 +1,6 @@
+ /*
++ * Copyright (C) 2011-2012 Qualcomm Atheros, Inc. All Rights Reserved.
++ * Qualcomm Atheros Confidential and Proprietary.
+  * Copyright (C) 2007-2009 QUALCOMM Incorporated. All rights reserved. Proprietary and Confidential.
+  */
+ 
diff --git a/CORE/MAC/src/cfg/cfgParamName.c b/CORE/MAC/src/cfg/cfgParamName.c
index bb22ace..7655ee6 100644
--- a/CORE/MAC/src/cfg/cfgParamName.c
+++ b/CORE/MAC/src/cfg/cfgParamName.c
@@ -33,301 +33,301 @@
 #include "cfgPriv.h"
 
 unsigned char *gCfgParamName[] = {
-	(unsigned char *)"STA_ID",
-	(unsigned char *)"CF_POLLABLE",
-	(unsigned char *)"CFP_PERIOD",
-	(unsigned char *)"CFP_MAX_DURATION",
-	(unsigned char *)"SSID",
-	(unsigned char *)"BEACON_INTERVAL",
-	(unsigned char *)"DTIM_PERIOD",
-	(unsigned char *)"WEP_KEY_LENGTH",
-	(unsigned char *)"WEP_DEFAULT_KEY_1",
-	(unsigned char *)"WEP_DEFAULT_KEY_2",
-	(unsigned char *)"WEP_DEFAULT_KEY_3",
-	(unsigned char *)"WEP_DEFAULT_KEY_4",
-	(unsigned char *)"WEP_DEFAULT_KEYID",
-	(unsigned char *)"EXCLUDE_UNENCRYPTED",
-	(unsigned char *)"RTS_THRESHOLD",
-	(unsigned char *)"SHORT_RETRY_LIMIT",
-	(unsigned char *)"LONG_RETRY_LIMIT",
-	(unsigned char *)"FRAGMENTATION_THRESHOLD",
-	(unsigned char *)"ACTIVE_MINIMUM_CHANNEL_TIME",
-	(unsigned char *)"ACTIVE_MAXIMUM_CHANNEL_TIME",
-	(unsigned char *)"PASSIVE_MINIMUM_CHANNEL_TIME",
-	(unsigned char *)"PASSIVE_MAXIMUM_CHANNEL_TIME",
-	(unsigned char *)"JOIN_FAILURE_TIMEOUT",
-	(unsigned char *)"AUTHENTICATE_FAILURE_TIMEOUT",
-	(unsigned char *)"AUTHENTICATE_RSP_TIMEOUT",
-	(unsigned char *)"ASSOCIATION_FAILURE_TIMEOUT",
-	(unsigned char *)"REASSOCIATION_FAILURE_TIMEOUT",
-	(unsigned char *)"RA_PERIODICITY_TIMEOUT_IN_PS",
-	(unsigned char *)"PS_ENABLE_BCN_FILTER",
-	(unsigned char *)"PS_ENABLE_HEART_BEAT",
-	(unsigned char *)"PS_ENABLE_RSSI_MONITOR",
-	(unsigned char *)"PS_DATA_INACTIVITY_TIMEOUT",
-	(unsigned char *)"RF_SETTLING_TIME_CLK",
-	(unsigned char *)"SUPPORTED_RATES_11B",
-	(unsigned char *)"SUPPORTED_RATES_11A",
-	(unsigned char *)"PHY_MODE",
-	(unsigned char *)"DOT11_MODE",
-	(unsigned char *)"OPERATIONAL_RATE_SET",
-	(unsigned char *)"EXTENDED_OPERATIONAL_RATE_SET",
-	(unsigned char *)"PROPRIETARY_OPERATIONAL_RATE_SET",
-	(unsigned char *)"BSSID",
-	(unsigned char *)"LISTEN_INTERVAL",
-	(unsigned char *)"VALID_CHANNEL_LIST",
-	(unsigned char *)"CURRENT_CHANNEL",
-	(unsigned char *)"DEFAULT_RATE_INDEX_5GHZ",
-	(unsigned char *)"DEFAULT_RATE_INDEX_24GHZ",
-	(unsigned char *)"RATE_ADAPTATION_TYPE",
-	(unsigned char *)"FIXED_RATE",
-	(unsigned char *)"FIXED_RATE_MULTICAST_24GHZ",
-	(unsigned char *)"FIXED_RATE_MULTICAST_5GHZ",
-	(unsigned char *)"RETRYRATE_POLICY",
-	(unsigned char *)"RETRYRATE_SECONDARY",
-	(unsigned char *)"RETRYRATE_TERTIARY",
-	(unsigned char *)"APSD_ENABLED",
-	(unsigned char *)"SHARED_KEY_AUTH_ENABLE",
-	(unsigned char *)"OPEN_SYSTEM_AUTH_ENABLE",
-	(unsigned char *)"AUTHENTICATION_TYPE",
-	(unsigned char *)"CF_POLL_REQUEST",
-	(unsigned char *)"PRIVACY_ENABLED",
-	(unsigned char *)"SHORT_PREAMBLE",
-	(unsigned char *)"SHORT_SLOT_TIME",
-	(unsigned char *)"ACCEPT_SHORT_SLOT_ASSOC_ONLY",
-	(unsigned char *)"QOS_ENABLED",
-	(unsigned char *)"HCF_ENABLED",
-	(unsigned char *)"RSN_ENABLED",
-	(unsigned char *)"BACKGROUND_SCAN_PERIOD",
-	(unsigned char *)"MAX_NUM_PRE_AUTH",
-	(unsigned char *)"PREAUTH_CLNUP_TIMEOUT",
-	(unsigned char *)"RELEASE_AID_TIMEOUT",
-	(unsigned char *)"HEART_BEAT_THRESHOLD",
-	(unsigned char *)"PROBE_AFTER_HB_FAIL_TIMEOUT",
-	(unsigned char *)"MANUFACTURER_OUI",
-	(unsigned char *)"MANUFACTURER_NAME",
-	(unsigned char *)"MODEL_NUMBER",
-	(unsigned char *)"MODEL_NAME",
-	(unsigned char *)"MANUFACTURER_PRODUCT_NAME",
-	(unsigned char *)"MANUFACTURER_PRODUCT_VERSION",
-	(unsigned char *)"11D_ENABLED",
-	(unsigned char *)"MAX_TX_POWER_2_4",
-	(unsigned char *)"MAX_TX_POWER_5",
-	(unsigned char *)"NETWORK_DENSITY",
-	(unsigned char *)"ADAPTIVE_THRESHOLD_ALGORITHM",
-	(unsigned char *)"CURRENT_TX_ANTENNA",
-	(unsigned char *)"CURRENT_RX_ANTENNA",
-	(unsigned char *)"CURRENT_TX_POWER_LEVEL",
-	(unsigned char *)"POWER_STATE_PER_CHAIN",
-	(unsigned char *)"NEW_BSS_FOUND_IND",
-	(unsigned char *)"PROPRIETARY_ANI_FEATURES_ENABLED",
-	(unsigned char *)"PROPRIETARY_RATES_ENABLED",
-	(unsigned char *)"AP_NODE_NAME",
-	(unsigned char *)"COUNTRY_CODE",
-	(unsigned char *)"11H_ENABLED",
-	(unsigned char *)"WT_CNF_TIMEOUT",
-	(unsigned char *)"KEEPALIVE_TIMEOUT",
-	(unsigned char *)"PROXIMITY",
-	(unsigned char *)"LOG_LEVEL",
-	(unsigned char *)"OLBC_DETECT_TIMEOUT",
-	(unsigned char *)"PROTECTION_ENABLED",
-	(unsigned char *)"11G_PROTECTION_ALWAYS",
-	(unsigned char *)"FORCE_POLICY_PROTECTION",
-	(unsigned char *)"11G_SHORT_PREAMBLE_ENABLED",
-	(unsigned char *)"11G_SHORT_SLOT_TIME_ENABLED",
-	(unsigned char *)"CAL_PERIOD",
-	(unsigned char *)"STATS_PERIOD",
-	(unsigned char *)"CAL_CONTROL",
-	(unsigned char *)"11G_ONLY_POLICY",
-	(unsigned char *)"PACKET_CLASSIFICATION",
-	(unsigned char *)"WME_ENABLED",
-	(unsigned char *)"ADDTS_RSP_TIMEOUT",
-	(unsigned char *)"MAX_SP_LENGTH",
-	(unsigned char *)"KEEP_ALIVE_STA_LIMIT_THRESHOLD",
-	(unsigned char *)"SEND_SINGLE_SSID_ALWAYS",
-	(unsigned char *)"WSM_ENABLED",
-	(unsigned char *)"PROP_CAPABILITY",
-	(unsigned char *)"EDCA_PROFILE",
-	(unsigned char *)"EDCA_ANI_ACBK_LOCAL",
-	(unsigned char *)"EDCA_ANI_ACBE_LOCAL",
-	(unsigned char *)"EDCA_ANI_ACVI_LOCAL",
-	(unsigned char *)"EDCA_ANI_ACVO_LOCAL",
-	(unsigned char *)"EDCA_ANI_ACBK",
-	(unsigned char *)"EDCA_ANI_ACBE",
-	(unsigned char *)"EDCA_ANI_ACVI",
-	(unsigned char *)"EDCA_ANI_ACVO",
-	(unsigned char *)"EDCA_WME_ACBK_LOCAL",
-	(unsigned char *)"EDCA_WME_ACBE_LOCAL",
-	(unsigned char *)"EDCA_WME_ACVI_LOCAL",
-	(unsigned char *)"EDCA_WME_ACVO_LOCAL",
-	(unsigned char *)"EDCA_WME_ACBK",
-	(unsigned char *)"EDCA_WME_ACBE",
-	(unsigned char *)"EDCA_WME_ACVI",
-	(unsigned char *)"EDCA_WME_ACVO",
-	(unsigned char *)"EDCA_TIT_DEMO_ACBK_LOCAL",
-	(unsigned char *)"EDCA_TIT_DEMO_ACBE_LOCAL",
-	(unsigned char *)"EDCA_TIT_DEMO_ACVI_LOCAL",
-	(unsigned char *)"EDCA_TIT_DEMO_ACVO_LOCAL",
-	(unsigned char *)"EDCA_TIT_DEMO_ACBK",
-	(unsigned char *)"EDCA_TIT_DEMO_ACBE",
-	(unsigned char *)"EDCA_TIT_DEMO_ACVI",
-	(unsigned char *)"EDCA_TIT_DEMO_ACVO",
-	(unsigned char *)"RDET_FLAG",
-	(unsigned char *)"RADAR_CHANNEL_LIST",
-	(unsigned char *)"LOCAL_POWER_CONSTRAINT",
-	(unsigned char *)"ADMIT_POLICY",
-	(unsigned char *)"ADMIT_BWFACTOR",
-	(unsigned char *)"MAX_CONSECUTIVE_BACKGROUND_SCAN_FAILURE",
-	(unsigned char *)"CHANNEL_BONDING_MODE",
-	(unsigned char *)"CB_SECONDARY_CHANNEL_STATE",
-	(unsigned char *)"DYNAMIC_THRESHOLD_ZERO",
-	(unsigned char *)"DYNAMIC_THRESHOLD_ONE",
-	(unsigned char *)"DYNAMIC_THRESHOLD_TWO",
-	(unsigned char *)"TRIG_STA_BK_SCAN",
-	(unsigned char *)"DYNAMIC_PROFILE_SWITCHING",
-	(unsigned char *)"SCAN_CONTROL_LIST",
-	(unsigned char *)"MIMO_ENABLED",
-	(unsigned char *)"BLOCK_ACK_ENABLED",
-	(unsigned char *)"BA_ACTIVITY_CHECK_TIMEOUT",
-	(unsigned char *)"HT_RX_STBC",
-	(unsigned char *)"HT_CAP_INFO",
-	(unsigned char *)"HT_AMPDU_PARAMS",
-	(unsigned char *)"SUPPORTED_MCS_SET",
-	(unsigned char *)"EXT_HT_CAP_INFO",
-	(unsigned char *)"TX_BF_CAP",
-	(unsigned char *)"AS_CAP",
-	(unsigned char *)"HT_INFO_FIELD1",
-	(unsigned char *)"HT_INFO_FIELD2",
-	(unsigned char *)"HT_INFO_FIELD3",
-	(unsigned char *)"BASIC_MCS_SET",
-	(unsigned char *)"CURRENT_MCS_SET",
-	(unsigned char *)"GREENFIELD_CAPABILITY",
-	(unsigned char *)"VHT_MAX_MPDU_LENGTH",
-	(unsigned char *)"VHT_SUPPORTED_CHAN_WIDTH_SET",
-	(unsigned char *)"VHT_LDPC_CODING_CAP",
-	(unsigned char *)"VHT_SHORT_GI_80MHZ",
-	(unsigned char *)"VHT_SHORT_GI_160_AND_80_PLUS_80MHZ",
-	(unsigned char *)"VHT_TXSTBC",
-	(unsigned char *)"VHT_RXSTBC",
-	(unsigned char *)"VHT_SU_BEAMFORMER_CAP",
-	(unsigned char *)"VHT_SU_BEAMFORMEE_CAP",
-	(unsigned char *)"VHT_CSN_BEAMFORMEE_ANT_SUPPORTED",
-	(unsigned char *)"VHT_NUM_SOUNDING_DIMENSIONS",
-	(unsigned char *)"VHT_MU_BEAMFORMER_CAP",
-	(unsigned char *)"VHT_MU_BEAMFORMEE_CAP",
-	(unsigned char *)"VHT_TXOP_PS",
-	(unsigned char *)"VHT_HTC_VHTC_CAP",
-	(unsigned char *)"VHT_AMPDU_LEN_EXPONENT",
-	(unsigned char *)"VHT_LINK_ADAPTATION_CAP",
-	(unsigned char *)"VHT_RX_ANT_PATTERN",
-	(unsigned char *)"VHT_TX_ANT_PATTERN",
-	(unsigned char *)"VHT_RX_MCS_MAP",
-	(unsigned char *)"VHT_TX_MCS_MAP",
-	(unsigned char *)"VHT_RX_HIGHEST_SUPPORTED_DATA_RATE",
-	(unsigned char *)"VHT_TX_HIGHEST_SUPPORTED_DATA_RATE",
-	(unsigned char *)"VHT_CHANNEL_WIDTH",
-	(unsigned char *)"VHT_CHANNEL_CENTER_FREQ_SEGMENT1",
-	(unsigned char *)"VHT_CHANNEL_CENTER_FREQ_SEGMENT2",
-	(unsigned char *)"VHT_BASIC_MCS_SET",
-	(unsigned char *)"VHT_MU_MIMO_CAP_STA_COUNT",
-	(unsigned char *)"VHT_SS_UNDER_UTIL",
-	(unsigned char *)"VHT_40MHZ_UTILIZATION",
-	(unsigned char *)"VHT_80MHZ_UTILIZATION",
-	(unsigned char *)"VHT_160MHZ_UTILIZATION",
-	(unsigned char *)"MAX_AMSDU_LENGTH",
-	(unsigned char *)"MPDU_DENSITY",
-	(unsigned char *)"NUM_BUFF_ADVERT",
-	(unsigned char *)"MAX_RX_AMPDU_FACTOR",
-	(unsigned char *)"SHORT_GI_20MHZ",
-	(unsigned char *)"SHORT_GI_40MHZ",
-	(unsigned char *)"RIFS_ENABLED",
-	(unsigned char *)"MAX_PS_POLL",
-	(unsigned char *)"NUM_BEACON_PER_RSSI_AVERAGE",
-	(unsigned char *)"RSSI_FILTER_PERIOD",
-	(unsigned char *)"FT_RSSI_FILTER_PERIOD",
-	(unsigned char *)"MIN_RSSI_THRESHOLD",
-	(unsigned char *)"NTH_BEACON_FILTER",
-	(unsigned char *)"BROADCAST_FRAME_FILTER_ENABLE",
-	(unsigned char *)"SCAN_IN_POWERSAVE",
-	(unsigned char *)"IGNORE_DTIM",
-	(unsigned char *)"WOWLAN_UCAST_PATTERN_FILTER_ENABLE",
-	(unsigned char *)"WOWLAN_CHANNEL_SWITCH_ENABLE",
-	(unsigned char *)"WOWLAN_DEAUTH_ENABLE",
-	(unsigned char *)"WOWLAN_DISASSOC_ENABLE",
-	(unsigned char *)"WOWLAN_MAX_MISSED_BEACON",
-	(unsigned char *)"WOWLAN_MAX_SLEEP_PERIOD",
-	(unsigned char *)"BA_TIMEOUT",
-	(unsigned char *)"BA_THRESHOLD_HIGH",
-	(unsigned char *)"MAX_BA_BUFFERS",
-	(unsigned char *)"MAX_BA_SESSIONS",
-	(unsigned char *)"BA_AUTO_SETUP",
-	(unsigned char *)"ADDBA_REQ_DECLINE",
-	(unsigned char *)"BG_SCAN_CHANNEL_LIST",
-	(unsigned char *)"MAX_MEDIUM_TIME",
-	(unsigned char *)"MAX_MPDUS_IN_AMPDU",
-	(unsigned char *)"IBSS_AUTO_BSSID",
-	(unsigned char *)"PROBE_REQ_ADDNIE_FLAG",
-	(unsigned char *)"PROBE_REQ_ADDNIE_DATA",
-	(unsigned char *)"PROBE_RSP_ADDNIE_FLAG",
-	(unsigned char *)"PROBE_RSP_ADDNIE_DATA1",
-	(unsigned char *)"PROBE_RSP_ADDNIE_DATA2",
-	(unsigned char *)"PROBE_RSP_ADDNIE_DATA3",
-	(unsigned char *)"ASSOC_RSP_ADDNIE_FLAG",
-	(unsigned char *)"ASSOC_RSP_ADDNIE_DATA",
-	(unsigned char *)"PROBE_REQ_ADDNP2PIE_FLAG",
-	(unsigned char *)"PROBE_REQ_ADDNP2PIE_DATA",
-	(unsigned char *)"PROBE_RSP_BCN_ADDNIE_FLAG",
-	(unsigned char *)"PROBE_RSP_BCN_ADDNIE_DATA",
-	(unsigned char *)"WPS_ENABLE",
-	(unsigned char *)"WPS_STATE",
-	(unsigned char *)"WPS_PROBE_REQ_FLAG",
-	(unsigned char *)"WPS_VERSION",
-	(unsigned char *)"WPS_REQUEST_TYPE",
-	(unsigned char *)"WPS_CFG_METHOD",
-	(unsigned char *)"WPS_UUID",
-	(unsigned char *)"WPS_PRIMARY_DEVICE_CATEGORY",
-	(unsigned char *)"WPS_PIMARY_DEVICE_OUI",
-	(unsigned char *)"WPS_DEVICE_SUB_CATEGORY",
-	(unsigned char *)"WPS_ASSOCIATION_STATE",
-	(unsigned char *)"WPS_CONFIGURATION_ERROR",
-	(unsigned char *)"WPS_DEVICE_PASSWORD_ID",
-	(unsigned char *)"WPS_ASSOC_METHOD",
-	(unsigned char *)"LOW_GAIN_OVERRIDE",
-	(unsigned char *)"ENABLE_PHY_AGC_LISTEN_MODE",
-	(unsigned char *)"RPE_POLLING_THRESHOLD",
-	(unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC0_REG",
-	(unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC1_REG",
-	(unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC2_REG",
-	(unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC3_REG",
-	(unsigned char *)"NO_OF_ONCHIP_REORDER_SESSIONS",
-	(unsigned char *)"SINGLE_TID_RC",
-	(unsigned char *)"RRM_ENABLED",
-	(unsigned char *)"RRM_OPERATING_CHAN_MAX",
-	(unsigned char *)"RRM_NON_OPERATING_CHAN_MAX",
-	(unsigned char *)"TX_PWR_CTRL_ENABLE",
-	(unsigned char *)"MCAST_BCAST_FILTER_SETTING",
-	(unsigned char *)"BTC_DHCP_BT_SLOTS_TO_BLOCK",
-	(unsigned char *)"DYNAMIC_PS_POLL_VALUE",
-	(unsigned char *)"PS_NULLDATA_AP_RESP_TIMEOUT",
-	(unsigned char *)"TELE_BCN_WAKEUP_EN",
-	(unsigned char *)"TELE_BCN_TRANS_LI",
-	(unsigned char *)"TELE_BCN_TRANS_LI_IDLE_BCNS",
-	(unsigned char *)"TELE_BCN_MAX_LI",
-	(unsigned char *)"TELE_BCN_MAX_LI_IDLE_BCNS",
-	(unsigned char *)"BTC_A2DP_DHCP_BT_SUB_INTERVALS",
-	(unsigned char *)"INFRA_STA_KEEP_ALIVE_PERIOD",
-	(unsigned char *)"ASSOC_STA_LIMIT",
-	(unsigned char *)"SAP_CHANNEL_SELECT_START_CHANNEL",
-	(unsigned char *)"SAP_CHANNEL_SELECT_END_CHANNEL",
-	(unsigned char *)"SAP_CHANNEL_SELECT_OPERATING_BAND",
-	(unsigned char *)"AP_DATA_AVAIL_POLL_PERIOD",
-	(unsigned char *)"ENABLE_CLOSE_LOOP",
-	(unsigned char *)"ENABLE_LTE_COEX",
-	(unsigned char *)"AP_KEEP_ALIVE_TIMEOUT",
-	(unsigned char *)"GO_KEEP_ALIVE_TIMEOUT",
-	(unsigned char *)"ENABLE_MC_ADDR_LIST",
-	(unsigned char *)"ENABLE_UC_FILTER",
-	(unsigned char *)"ENABLE_LPWR_IMG_TRANSITION",
+    (unsigned char *)"STA_ID",
+    (unsigned char *)"CF_POLLABLE",
+    (unsigned char *)"CFP_PERIOD",
+    (unsigned char *)"CFP_MAX_DURATION",
+    (unsigned char *)"SSID",
+    (unsigned char *)"BEACON_INTERVAL",
+    (unsigned char *)"DTIM_PERIOD",
+    (unsigned char *)"WEP_KEY_LENGTH",
+    (unsigned char *)"WEP_DEFAULT_KEY_1",
+    (unsigned char *)"WEP_DEFAULT_KEY_2",
+    (unsigned char *)"WEP_DEFAULT_KEY_3",
+    (unsigned char *)"WEP_DEFAULT_KEY_4",
+    (unsigned char *)"WEP_DEFAULT_KEYID",
+    (unsigned char *)"EXCLUDE_UNENCRYPTED",
+    (unsigned char *)"RTS_THRESHOLD",
+    (unsigned char *)"SHORT_RETRY_LIMIT",
+    (unsigned char *)"LONG_RETRY_LIMIT",
+    (unsigned char *)"FRAGMENTATION_THRESHOLD",
+    (unsigned char *)"ACTIVE_MINIMUM_CHANNEL_TIME",
+    (unsigned char *)"ACTIVE_MAXIMUM_CHANNEL_TIME",
+    (unsigned char *)"PASSIVE_MINIMUM_CHANNEL_TIME",
+    (unsigned char *)"PASSIVE_MAXIMUM_CHANNEL_TIME",
+    (unsigned char *)"JOIN_FAILURE_TIMEOUT",
+    (unsigned char *)"AUTHENTICATE_FAILURE_TIMEOUT",
+    (unsigned char *)"AUTHENTICATE_RSP_TIMEOUT",
+    (unsigned char *)"ASSOCIATION_FAILURE_TIMEOUT",
+    (unsigned char *)"REASSOCIATION_FAILURE_TIMEOUT",
+    (unsigned char *)"RA_PERIODICITY_TIMEOUT_IN_PS",
+    (unsigned char *)"PS_ENABLE_BCN_FILTER",
+    (unsigned char *)"PS_ENABLE_HEART_BEAT",
+    (unsigned char *)"PS_ENABLE_RSSI_MONITOR",
+    (unsigned char *)"PS_DATA_INACTIVITY_TIMEOUT",
+    (unsigned char *)"RF_SETTLING_TIME_CLK",
+    (unsigned char *)"SUPPORTED_RATES_11B",
+    (unsigned char *)"SUPPORTED_RATES_11A",
+    (unsigned char *)"PHY_MODE",
+    (unsigned char *)"DOT11_MODE",
+    (unsigned char *)"OPERATIONAL_RATE_SET",
+    (unsigned char *)"EXTENDED_OPERATIONAL_RATE_SET",
+    (unsigned char *)"PROPRIETARY_OPERATIONAL_RATE_SET",
+    (unsigned char *)"BSSID",
+    (unsigned char *)"LISTEN_INTERVAL",
+    (unsigned char *)"VALID_CHANNEL_LIST",
+    (unsigned char *)"CURRENT_CHANNEL",
+    (unsigned char *)"DEFAULT_RATE_INDEX_5GHZ",
+    (unsigned char *)"DEFAULT_RATE_INDEX_24GHZ",
+    (unsigned char *)"RATE_ADAPTATION_TYPE",
+    (unsigned char *)"FIXED_RATE",
+    (unsigned char *)"FIXED_RATE_MULTICAST_24GHZ",
+    (unsigned char *)"FIXED_RATE_MULTICAST_5GHZ",
+    (unsigned char *)"RETRYRATE_POLICY",
+    (unsigned char *)"RETRYRATE_SECONDARY",
+    (unsigned char *)"RETRYRATE_TERTIARY",
+    (unsigned char *)"APSD_ENABLED",
+    (unsigned char *)"SHARED_KEY_AUTH_ENABLE",
+    (unsigned char *)"OPEN_SYSTEM_AUTH_ENABLE",
+    (unsigned char *)"AUTHENTICATION_TYPE",
+    (unsigned char *)"CF_POLL_REQUEST",
+    (unsigned char *)"PRIVACY_ENABLED",
+    (unsigned char *)"SHORT_PREAMBLE",
+    (unsigned char *)"SHORT_SLOT_TIME",
+    (unsigned char *)"ACCEPT_SHORT_SLOT_ASSOC_ONLY",
+    (unsigned char *)"QOS_ENABLED",
+    (unsigned char *)"HCF_ENABLED",
+    (unsigned char *)"RSN_ENABLED",
+    (unsigned char *)"BACKGROUND_SCAN_PERIOD",
+    (unsigned char *)"MAX_NUM_PRE_AUTH",
+    (unsigned char *)"PREAUTH_CLNUP_TIMEOUT",
+    (unsigned char *)"RELEASE_AID_TIMEOUT",
+    (unsigned char *)"HEART_BEAT_THRESHOLD",
+    (unsigned char *)"PROBE_AFTER_HB_FAIL_TIMEOUT",
+    (unsigned char *)"MANUFACTURER_OUI",
+    (unsigned char *)"MANUFACTURER_NAME",
+    (unsigned char *)"MODEL_NUMBER",
+    (unsigned char *)"MODEL_NAME",
+    (unsigned char *)"MANUFACTURER_PRODUCT_NAME",
+    (unsigned char *)"MANUFACTURER_PRODUCT_VERSION",
+    (unsigned char *)"11D_ENABLED",
+    (unsigned char *)"MAX_TX_POWER_2_4",
+    (unsigned char *)"MAX_TX_POWER_5",
+    (unsigned char *)"NETWORK_DENSITY",
+    (unsigned char *)"ADAPTIVE_THRESHOLD_ALGORITHM",
+    (unsigned char *)"CURRENT_TX_ANTENNA",
+    (unsigned char *)"CURRENT_RX_ANTENNA",
+    (unsigned char *)"CURRENT_TX_POWER_LEVEL",
+    (unsigned char *)"POWER_STATE_PER_CHAIN",
+    (unsigned char *)"NEW_BSS_FOUND_IND",
+    (unsigned char *)"PROPRIETARY_ANI_FEATURES_ENABLED",
+    (unsigned char *)"PROPRIETARY_RATES_ENABLED",
+    (unsigned char *)"AP_NODE_NAME",
+    (unsigned char *)"COUNTRY_CODE",
+    (unsigned char *)"11H_ENABLED",
+    (unsigned char *)"WT_CNF_TIMEOUT",
+    (unsigned char *)"KEEPALIVE_TIMEOUT",
+    (unsigned char *)"PROXIMITY",
+    (unsigned char *)"LOG_LEVEL",
+    (unsigned char *)"OLBC_DETECT_TIMEOUT",
+    (unsigned char *)"PROTECTION_ENABLED",
+    (unsigned char *)"11G_PROTECTION_ALWAYS",
+    (unsigned char *)"FORCE_POLICY_PROTECTION",
+    (unsigned char *)"11G_SHORT_PREAMBLE_ENABLED",
+    (unsigned char *)"11G_SHORT_SLOT_TIME_ENABLED",
+    (unsigned char *)"CAL_PERIOD",
+    (unsigned char *)"STATS_PERIOD",
+    (unsigned char *)"CAL_CONTROL",
+    (unsigned char *)"11G_ONLY_POLICY",
+    (unsigned char *)"PACKET_CLASSIFICATION",
+    (unsigned char *)"WME_ENABLED",
+    (unsigned char *)"ADDTS_RSP_TIMEOUT",
+    (unsigned char *)"MAX_SP_LENGTH",
+    (unsigned char *)"KEEP_ALIVE_STA_LIMIT_THRESHOLD",
+    (unsigned char *)"SEND_SINGLE_SSID_ALWAYS",
+    (unsigned char *)"WSM_ENABLED",
+    (unsigned char *)"PROP_CAPABILITY",
+    (unsigned char *)"EDCA_PROFILE",
+    (unsigned char *)"EDCA_ANI_ACBK_LOCAL",
+    (unsigned char *)"EDCA_ANI_ACBE_LOCAL",
+    (unsigned char *)"EDCA_ANI_ACVI_LOCAL",
+    (unsigned char *)"EDCA_ANI_ACVO_LOCAL",
+    (unsigned char *)"EDCA_ANI_ACBK",
+    (unsigned char *)"EDCA_ANI_ACBE",
+    (unsigned char *)"EDCA_ANI_ACVI",
+    (unsigned char *)"EDCA_ANI_ACVO",
+    (unsigned char *)"EDCA_WME_ACBK_LOCAL",
+    (unsigned char *)"EDCA_WME_ACBE_LOCAL",
+    (unsigned char *)"EDCA_WME_ACVI_LOCAL",
+    (unsigned char *)"EDCA_WME_ACVO_LOCAL",
+    (unsigned char *)"EDCA_WME_ACBK",
+    (unsigned char *)"EDCA_WME_ACBE",
+    (unsigned char *)"EDCA_WME_ACVI",
+    (unsigned char *)"EDCA_WME_ACVO",
+    (unsigned char *)"EDCA_TIT_DEMO_ACBK_LOCAL",
+    (unsigned char *)"EDCA_TIT_DEMO_ACBE_LOCAL",
+    (unsigned char *)"EDCA_TIT_DEMO_ACVI_LOCAL",
+    (unsigned char *)"EDCA_TIT_DEMO_ACVO_LOCAL",
+    (unsigned char *)"EDCA_TIT_DEMO_ACBK",
+    (unsigned char *)"EDCA_TIT_DEMO_ACBE",
+    (unsigned char *)"EDCA_TIT_DEMO_ACVI",
+    (unsigned char *)"EDCA_TIT_DEMO_ACVO",
+    (unsigned char *)"RDET_FLAG",
+    (unsigned char *)"RADAR_CHANNEL_LIST",
+    (unsigned char *)"LOCAL_POWER_CONSTRAINT",
+    (unsigned char *)"ADMIT_POLICY",
+    (unsigned char *)"ADMIT_BWFACTOR",
+    (unsigned char *)"MAX_CONSECUTIVE_BACKGROUND_SCAN_FAILURE",
+    (unsigned char *)"CHANNEL_BONDING_MODE",
+    (unsigned char *)"CB_SECONDARY_CHANNEL_STATE",
+    (unsigned char *)"DYNAMIC_THRESHOLD_ZERO",
+    (unsigned char *)"DYNAMIC_THRESHOLD_ONE",
+    (unsigned char *)"DYNAMIC_THRESHOLD_TWO",
+    (unsigned char *)"TRIG_STA_BK_SCAN",
+    (unsigned char *)"DYNAMIC_PROFILE_SWITCHING",
+    (unsigned char *)"SCAN_CONTROL_LIST",
+    (unsigned char *)"MIMO_ENABLED",
+    (unsigned char *)"BLOCK_ACK_ENABLED",
+    (unsigned char *)"BA_ACTIVITY_CHECK_TIMEOUT",
+    (unsigned char *)"HT_RX_STBC",
+    (unsigned char *)"HT_CAP_INFO",
+    (unsigned char *)"HT_AMPDU_PARAMS",
+    (unsigned char *)"SUPPORTED_MCS_SET",
+    (unsigned char *)"EXT_HT_CAP_INFO",
+    (unsigned char *)"TX_BF_CAP",
+    (unsigned char *)"AS_CAP",
+    (unsigned char *)"HT_INFO_FIELD1",
+    (unsigned char *)"HT_INFO_FIELD2",
+    (unsigned char *)"HT_INFO_FIELD3",
+    (unsigned char *)"BASIC_MCS_SET",
+    (unsigned char *)"CURRENT_MCS_SET",
+    (unsigned char *)"GREENFIELD_CAPABILITY",
+    (unsigned char *)"VHT_MAX_MPDU_LENGTH",
+    (unsigned char *)"VHT_SUPPORTED_CHAN_WIDTH_SET",
+    (unsigned char *)"VHT_LDPC_CODING_CAP",
+    (unsigned char *)"VHT_SHORT_GI_80MHZ",
+    (unsigned char *)"VHT_SHORT_GI_160_AND_80_PLUS_80MHZ",
+    (unsigned char *)"VHT_TXSTBC",
+    (unsigned char *)"VHT_RXSTBC",
+    (unsigned char *)"VHT_SU_BEAMFORMER_CAP",
+    (unsigned char *)"VHT_SU_BEAMFORMEE_CAP",
+    (unsigned char *)"VHT_CSN_BEAMFORMEE_ANT_SUPPORTED",
+    (unsigned char *)"VHT_NUM_SOUNDING_DIMENSIONS",
+    (unsigned char *)"VHT_MU_BEAMFORMER_CAP",
+    (unsigned char *)"VHT_MU_BEAMFORMEE_CAP",
+    (unsigned char *)"VHT_TXOP_PS",
+    (unsigned char *)"VHT_HTC_VHTC_CAP",
+    (unsigned char *)"VHT_AMPDU_LEN_EXPONENT",
+    (unsigned char *)"VHT_LINK_ADAPTATION_CAP",
+    (unsigned char *)"VHT_RX_ANT_PATTERN",
+    (unsigned char *)"VHT_TX_ANT_PATTERN",
+    (unsigned char *)"VHT_RX_MCS_MAP",
+    (unsigned char *)"VHT_TX_MCS_MAP",
+    (unsigned char *)"VHT_RX_HIGHEST_SUPPORTED_DATA_RATE",
+    (unsigned char *)"VHT_TX_HIGHEST_SUPPORTED_DATA_RATE",
+    (unsigned char *)"VHT_CHANNEL_WIDTH",
+    (unsigned char *)"VHT_CHANNEL_CENTER_FREQ_SEGMENT1",
+    (unsigned char *)"VHT_CHANNEL_CENTER_FREQ_SEGMENT2",
+    (unsigned char *)"VHT_BASIC_MCS_SET",
+    (unsigned char *)"VHT_MU_MIMO_CAP_STA_COUNT",
+    (unsigned char *)"VHT_SS_UNDER_UTIL",
+    (unsigned char *)"VHT_40MHZ_UTILIZATION",
+    (unsigned char *)"VHT_80MHZ_UTILIZATION",
+    (unsigned char *)"VHT_160MHZ_UTILIZATION",
+    (unsigned char *)"MAX_AMSDU_LENGTH",
+    (unsigned char *)"MPDU_DENSITY",
+    (unsigned char *)"NUM_BUFF_ADVERT",
+    (unsigned char *)"MAX_RX_AMPDU_FACTOR",
+    (unsigned char *)"SHORT_GI_20MHZ",
+    (unsigned char *)"SHORT_GI_40MHZ",
+    (unsigned char *)"RIFS_ENABLED",
+    (unsigned char *)"MAX_PS_POLL",
+    (unsigned char *)"NUM_BEACON_PER_RSSI_AVERAGE",
+    (unsigned char *)"RSSI_FILTER_PERIOD",
+    (unsigned char *)"FT_RSSI_FILTER_PERIOD",
+    (unsigned char *)"MIN_RSSI_THRESHOLD",
+    (unsigned char *)"NTH_BEACON_FILTER",
+    (unsigned char *)"BROADCAST_FRAME_FILTER_ENABLE",
+    (unsigned char *)"SCAN_IN_POWERSAVE",
+    (unsigned char *)"IGNORE_DTIM",
+    (unsigned char *)"WOWLAN_UCAST_PATTERN_FILTER_ENABLE",
+    (unsigned char *)"WOWLAN_CHANNEL_SWITCH_ENABLE",
+    (unsigned char *)"WOWLAN_DEAUTH_ENABLE",
+    (unsigned char *)"WOWLAN_DISASSOC_ENABLE",
+    (unsigned char *)"WOWLAN_MAX_MISSED_BEACON",
+    (unsigned char *)"WOWLAN_MAX_SLEEP_PERIOD",
+    (unsigned char *)"BA_TIMEOUT",
+    (unsigned char *)"BA_THRESHOLD_HIGH",
+    (unsigned char *)"MAX_BA_BUFFERS",
+    (unsigned char *)"MAX_BA_SESSIONS",
+    (unsigned char *)"BA_AUTO_SETUP",
+    (unsigned char *)"ADDBA_REQ_DECLINE",
+    (unsigned char *)"BG_SCAN_CHANNEL_LIST",
+    (unsigned char *)"MAX_MEDIUM_TIME",
+    (unsigned char *)"MAX_MPDUS_IN_AMPDU",
+    (unsigned char *)"IBSS_AUTO_BSSID",
+    (unsigned char *)"PROBE_REQ_ADDNIE_FLAG",
+    (unsigned char *)"PROBE_REQ_ADDNIE_DATA",
+    (unsigned char *)"PROBE_RSP_ADDNIE_FLAG",
+    (unsigned char *)"PROBE_RSP_ADDNIE_DATA1",
+    (unsigned char *)"PROBE_RSP_ADDNIE_DATA2",
+    (unsigned char *)"PROBE_RSP_ADDNIE_DATA3",
+    (unsigned char *)"ASSOC_RSP_ADDNIE_FLAG",
+    (unsigned char *)"ASSOC_RSP_ADDNIE_DATA",
+    (unsigned char *)"PROBE_REQ_ADDNP2PIE_FLAG",
+    (unsigned char *)"PROBE_REQ_ADDNP2PIE_DATA",
+    (unsigned char *)"PROBE_RSP_BCN_ADDNIE_FLAG",
+    (unsigned char *)"PROBE_RSP_BCN_ADDNIE_DATA",
+    (unsigned char *)"WPS_ENABLE",
+    (unsigned char *)"WPS_STATE",
+    (unsigned char *)"WPS_PROBE_REQ_FLAG",
+    (unsigned char *)"WPS_VERSION",
+    (unsigned char *)"WPS_REQUEST_TYPE",
+    (unsigned char *)"WPS_CFG_METHOD",
+    (unsigned char *)"WPS_UUID",
+    (unsigned char *)"WPS_PRIMARY_DEVICE_CATEGORY",
+    (unsigned char *)"WPS_PIMARY_DEVICE_OUI",
+    (unsigned char *)"WPS_DEVICE_SUB_CATEGORY",
+    (unsigned char *)"WPS_ASSOCIATION_STATE",
+    (unsigned char *)"WPS_CONFIGURATION_ERROR",
+    (unsigned char *)"WPS_DEVICE_PASSWORD_ID",
+    (unsigned char *)"WPS_ASSOC_METHOD",
+    (unsigned char *)"LOW_GAIN_OVERRIDE",
+    (unsigned char *)"ENABLE_PHY_AGC_LISTEN_MODE",
+    (unsigned char *)"RPE_POLLING_THRESHOLD",
+    (unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC0_REG",
+    (unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC1_REG",
+    (unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC2_REG",
+    (unsigned char *)"RPE_AGING_THRESHOLD_FOR_AC3_REG",
+    (unsigned char *)"NO_OF_ONCHIP_REORDER_SESSIONS",
+    (unsigned char *)"SINGLE_TID_RC",
+    (unsigned char *)"RRM_ENABLED",
+    (unsigned char *)"RRM_OPERATING_CHAN_MAX",
+    (unsigned char *)"RRM_NON_OPERATING_CHAN_MAX",
+    (unsigned char *)"TX_PWR_CTRL_ENABLE",
+    (unsigned char *)"MCAST_BCAST_FILTER_SETTING",
+    (unsigned char *)"BTC_DHCP_BT_SLOTS_TO_BLOCK",
+    (unsigned char *)"DYNAMIC_PS_POLL_VALUE",
+    (unsigned char *)"PS_NULLDATA_AP_RESP_TIMEOUT",
+    (unsigned char *)"TELE_BCN_WAKEUP_EN",
+    (unsigned char *)"TELE_BCN_TRANS_LI",
+    (unsigned char *)"TELE_BCN_TRANS_LI_IDLE_BCNS",
+    (unsigned char *)"TELE_BCN_MAX_LI",
+    (unsigned char *)"TELE_BCN_MAX_LI_IDLE_BCNS",
+    (unsigned char *)"BTC_A2DP_DHCP_BT_SUB_INTERVALS",
+    (unsigned char *)"INFRA_STA_KEEP_ALIVE_PERIOD",
+    (unsigned char *)"ASSOC_STA_LIMIT",
+    (unsigned char *)"SAP_CHANNEL_SELECT_START_CHANNEL",
+    (unsigned char *)"SAP_CHANNEL_SELECT_END_CHANNEL",
+    (unsigned char *)"SAP_CHANNEL_SELECT_OPERATING_BAND",
+    (unsigned char *)"AP_DATA_AVAIL_POLL_PERIOD",
+    (unsigned char *)"ENABLE_CLOSE_LOOP",
+    (unsigned char *)"ENABLE_LTE_COEX",
+    (unsigned char *)"AP_KEEP_ALIVE_TIMEOUT",
+    (unsigned char *)"GO_KEEP_ALIVE_TIMEOUT",
+    (unsigned char *)"ENABLE_MC_ADDR_LIST",
+    (unsigned char *)"ENABLE_UC_FILTER",
+    (unsigned char *)"ENABLE_LPWR_IMG_TRANSITION",
 };
 
 
diff --git a/CORE/MAC/src/pe/include/schGlobal.h b/CORE/MAC/src/pe/include/schGlobal.h
index 1848b61..61f1ccf 100644
--- a/CORE/MAC/src/pe/include/schGlobal.h
+++ b/CORE/MAC/src/pe/include/schGlobal.h
@@ -55,7 +55,11 @@
 #define SCH_DIAG_RR_TIMEOUT_DELETE    0x1
 #define SCH_DIAG_RR_LOWER_RATE        0x2
 
-#define TIM_IE_SIZE 0x6
+#ifdef WLAN_SOFTAP_VSTA_FEATURE
+#define TIM_IE_SIZE 0xA
+#else
+#define TIM_IE_SIZE 0x7
+#endif
 
 // ----------------------- Beacon processing ------------------------
 
diff --git a/CORE/MAC/src/pe/lim/limFT.c b/CORE/MAC/src/pe/lim/limFT.c
index b5f9cc2..5b337be 100644
--- a/CORE/MAC/src/pe/lim/limFT.c
+++ b/CORE/MAC/src/pe/lim/limFT.c
@@ -1094,12 +1094,6 @@
             return;
     }
 
-    if (limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE, psessionEntry->bssId,
-                        psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
-    {
-            return;
-    }
-
     pMlmReassocReq->listenInterval = (tANI_U16) val;
 
     psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
diff --git a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
index 3b81802..848c776 100644
--- a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
@@ -2786,27 +2786,48 @@
 #ifdef WLAN_FEATURE_VOWIFI_11R
 /*------------------------------------------------------------------------------------------
  *
- * Function to handle WDA_ADD_BSS_RSP, in FT reassoc state.
+ * Function to handle callback after setting link state to post assoc.
  *
  *
  *------------------------------------------------------------------------------------------
  */
-static inline void
-limProcessStaMlmAddBssRspFT(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry)
+void limSetLinkStateForPostAssocCallback(tpAniSirGlobal pMac, void *msgParam )
 {
-    tpDphHashNode pStaDs    = NULL;
-    tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
-    tpAddStaParams pAddStaParams = NULL;
-    tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
-    tLimMlmReassocReq       *pMlmReassocReq;
     tLimMlmReassocCnf       mlmReassocCnf; // keep sme 
+    tSetLinkCbackParams * pCbackParams = (tSetLinkCbackParams *)msgParam;
+    tpPESession psessionEntry = NULL;
+    tpAddBssParams pAddBssParams = NULL;
+    tpDphHashNode pStaDs    = NULL;
+    tpAddStaParams pAddStaParams = NULL;
+    tLimMlmReassocReq * pMlmReassocReq = NULL;
+    tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
+
+    /* Sanity Checks */
+    if (pCbackParams == NULL)
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Invalid parameters\n"));)
+        goto end;
+    }
+
+    pAddBssParams = (tpAddBssParams)(pCbackParams->cbackDataPtr);
+
+    if (pAddBssParams == NULL)
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Invalid parameters\n"));)
+        goto end;
+    }
+
+    if((psessionEntry = peFindSessionBySessionId(pMac,pAddBssParams->sessionId))== NULL)
+    {
+        limLog( pMac, LOGE, FL( "Session Does not exist for given sessionId\n" ));
+            if( NULL != pAddBssParams )
+                palFreeMemory( pMac->hHdd, (void *) pAddBssParams );
+        goto end;
+    }
 
     pMlmReassocReq = (tLimMlmReassocReq *)(psessionEntry->pLimMlmReassocReq);
 
-    if ( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE != psessionEntry->limMlmState )
-    {
-        goto end;
-    }
+    limPrintMacAddr(pMac, pAddBssParams->bssId, LOGE);
 
     if ((pStaDs = dphAddHashEntry(pMac, pAddBssParams->bssId, DPH_STA_HASH_INDEX_PEER,
         &psessionEntry->dph.dphHashTable)) == NULL)
@@ -2816,16 +2837,6 @@
         limPrintMacAddr(pMac, pAddBssParams->staContext.staMac, LOGE);
         goto end;
     }
-
-    // Set the filter state to post assoc
-    if (limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE,
-            pAddBssParams->bssId, psessionEntry->selfMacAddr,
-            NULL, NULL) != eSIR_SUCCESS)
-    {
-        PELOGE(limLog(pMac, LOGE,  FL("Failed to set the LinkState\n"));)
-        goto end;
-    }
-
     // Prepare and send Reassociation request frame
     // start reassoc timer.
     pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
@@ -2966,6 +2977,15 @@
 
     // Lets save this for when we receive the Reassoc Rsp
     pMac->ft.ftPEContext.pAddStaReq = pAddStaParams;
+
+    if (pCbackParams != NULL)
+    {
+        if (pCbackParams->cbackDataPtr != NULL)
+        {
+            palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);        
+        }
+        palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);        
+    }
     return;
 
 end:
@@ -2974,6 +2994,82 @@
     {
         palFreeMemory( pMac->hHdd, (tANI_U8 *) pMlmReassocReq);
     }
+
+    if (pCbackParams != NULL)
+    {
+        if (pCbackParams->cbackDataPtr != NULL)
+        {
+            palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams->cbackDataPtr);        
+        }
+        palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParams);        
+    }
+
+    mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
+    mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
+    /* Update PE sessio Id*/
+    mlmReassocCnf.sessionId = psessionEntry->peSessionId;
+
+    limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
+}
+/*------------------------------------------------------------------------------------------
+ *
+ * Function to handle WDA_ADD_BSS_RSP, in FT reassoc state.
+ *
+ *
+ *------------------------------------------------------------------------------------------
+ */
+static inline void
+limProcessStaMlmAddBssRspFT(tpAniSirGlobal pMac, tpSirMsgQ limMsgQ, tpPESession psessionEntry)
+{
+    tSetLinkCbackParams * pCbackParam = NULL;
+    tAddBssParams * pAddBssCbackInfo = NULL;
+    tLimMlmReassocCnf       mlmReassocCnf;
+    tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
+
+    if ( eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE != psessionEntry->limMlmState )
+    {
+        goto end;
+    }
+
+    if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pCbackParam, sizeof( tSetLinkCbackParams )))
+    {
+        PELOGE(limLog(pMac, LOGE,  FL("Could not allocate memory for LinkState callback params\n"));)
+        goto end;
+    }
+
+    if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pAddBssCbackInfo, sizeof( tAddBssParams )))
+    {
+        PELOGE(limLog(pMac, LOGE,  FL("Could not allocate memory for Add BSS info callback param\n"));)
+        goto end;
+    }
+
+    vos_mem_copy(pAddBssCbackInfo, pAddBssParams, sizeof(tAddBssParams));
+
+    pCbackParam->cbackDataPtr = (void*)pAddBssCbackInfo;
+
+    // Set the filter state to post assoc and send out re-assoc request OTA only after response is received
+    if (limSetLinkState(pMac, eSIR_LINK_POSTASSOC_STATE,
+            pAddBssParams->bssId, psessionEntry->selfMacAddr,
+            (tpSetLinkStateCallback)limSetLinkStateForPostAssocCallback, 
+                        (void *)pCbackParam) != eSIR_SUCCESS)
+    {
+        PELOGE(limLog(pMac, LOGE,  FL("Failed to set the LinkState\n"));)
+        goto end;
+    }
+
+    return;
+
+end:
+
+    if (pCbackParam != NULL)
+    {
+        if (pCbackParam->cbackDataPtr != NULL)
+        {
+            palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam->cbackDataPtr);        
+        }
+        palFreeMemory( pMac->hHdd, (tANI_U8 *) pCbackParam);        
+    }
+
     mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
     mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
     /* Update PE sessio Id*/
diff --git a/CORE/MAC/src/pe/lim/limProcessProbeReqFrame.c b/CORE/MAC/src/pe/lim/limProcessProbeReqFrame.c
index b222c9e..e6737bb 100644
--- a/CORE/MAC/src/pe/lim/limProcessProbeReqFrame.c
+++ b/CORE/MAC/src/pe/lim/limProcessProbeReqFrame.c
@@ -429,7 +429,7 @@
         if((psessionEntry->pePersona == VOS_P2P_GO_MODE) && ((pMac->lim.gpLimRemainOnChanReq )
                                   || (pMac->lim.gLimHalScanState != eLIM_HAL_IDLE_SCAN_STATE)))
         {
-           limLog(pMac, LOGP,
+           limLog(pMac, LOG3,
               FL("While GO is scanning, don't send probe response on diff channel\n"));
            break;
         }
diff --git a/CORE/MAC/src/pe/lim/limProcessTdls.c b/CORE/MAC/src/pe/lim/limProcessTdls.c
new file mode 100644
index 0000000..cc2865f
--- /dev/null
+++ b/CORE/MAC/src/pe/lim/limProcessTdls.c
@@ -0,0 +1,4581 @@
+/*
+* Copyright (c) 2012 Qualcomm Atheros, Inc.
+* All Rights Reserved.
+* Qualcomm Atheros Confidential and Proprietary.
+*/
+
+/*===========================================================================
+
+                      limProcessTdls.c 
+
+  OVERVIEW:
+
+  DEPENDENCIES:
+
+  Are listed for each API below.
+
+
+  Copyright (c) 2010 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
+----------    ---    --------------------------------------------------------
+05/05/2010   Ashwani    Initial Creation, added TDLS action frame functionality,
+                         TDLS message exchange with SME..etc..
+
+===========================================================================*/
+
+
+/**
+ * \file limProcessTdls.c
+ *
+ * \brief Code for preparing,processing and sending 802.11z action frames
+ *
+ */
+
+#ifdef FEATURE_WLAN_TDLS
+
+#include "sirApi.h"
+#include "aniGlobal.h"
+#include "sirMacProtDef.h"
+#include "cfgApi.h"
+#include "utilsApi.h"
+#include "limTypes.h"
+#include "limUtils.h"
+#include "limSecurityUtils.h"
+#include "dot11f.h"
+#include "limStaHashApi.h"
+#include "schApi.h"
+#include "limSendMessages.h"
+#include "utilsParser.h"
+#include "limAssocUtils.h"
+#include "dphHashTable.h"
+#include "wlan_qct_wda.h"
+
+
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/* forword declarations */
+static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac,
+                   tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry) ;
+static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac, 
+                                   tSirMacAddr peerMac, tANI_U8 status);
+static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac, 
+                 tANI_U8 sessionId, tDphHashNode   *pStaDs, tANI_U8 status) ;
+static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac, 
+                                                            tANI_U8 state);
+static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state, 
+                                     tLimTdlsLinkSetupPeer **setupPeer) ;
+static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
+
+static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peer_mac);
+static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, 
+                                                 tpPESession psessionEntry) ;
+
+#endif
+static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac, tSirMacAddr, 
+             tLimTdlsLinkSetupPeer *setupPeer, tpPESession psessionEntry) ;
+void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry,
+                          tDot11fIELinkIdentifier *linkIden, 
+                             tSirMacAddr peerMac , tANI_U8 reqType) ;
+void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac, 
+                                    tDot11fIEExtCap *extCapability) ;
+/*
+ * TDLS data frames will go out/come in as non-qos data.
+ * so, eth_890d_header will be aligned access..
+ */
+static const tANI_U8 eth_890d_header[] = 
+{ 
+    0xaa, 0xaa, 0x03, 0x00, 
+    0x00, 0x00, 0x89, 0x0d,
+} ;
+
+/*
+ * type of links used in TDLS 
+ */
+enum tdlsLinks
+{
+    TDLS_LINK_AP,
+    TDLS_LINK_DIRECT
+} eTdlsLink ;
+
+/* 
+ * node status in node searching
+ */
+enum tdlsLinkNodeStatus
+{
+    TDLS_NODE_NOT_FOUND,
+    TDLS_NODE_FOUND
+} eTdlsLinkNodeStatus ;
+
+
+enum tdlsReqType
+{
+    TDLS_INITIATOR,
+    TDLS_RESPONDER
+} eTdlsReqType ;
+
+typedef enum tdlsLinkSetupStatus
+{
+    TDLS_SETUP_STATUS_SUCCESS = 0,
+    TDLS_SETUP_STATUS_FAILURE = 37
+}etdlsLinkSetupStatus ;
+
+/* some local defines */
+#define LINK_IDEN_BSSID_OFFSET      (0)
+#define PEER_MAC_OFFSET   (12) 
+#define STA_MAC_OFFSET    (6)
+#define LINK_IDEN_ELE_ID  (101)
+//#define LINK_IDEN_LENGTH   (18) 
+#define LINK_IDEN_ADDR_OFFSET(x) (&x.LinkIdentifier)
+#define PTI_LINK_IDEN_OFFSET     (5)
+#define PTI_BUF_STATUS_OFFSET    (25)
+
+/* TODO, Move this parameters to configuration */
+#define PEER_PSM_SUPPORT          (0)
+#define PEER_BUFFER_STA_SUPPORT   (1)
+#define CH_SWITCH_SUPPORT         (0)
+#define TDLS_SUPPORT              (1)
+#define TDLS_PROHIBITED           (0)
+#define TDLS_CH_SWITCH_PROHIBITED (1)
+
+#ifdef LIM_DEBUG_TDLS
+#define TDLS_CASE_RETURN_STRING(x) case (x): return( ((const tANI_U8*)#x) + 8);  /* 8 = remove redundant SIR_MAC_ */
+
+#ifdef FEATURE_WLAN_TDLS
+#define WNI_CFG_TDLS_DISCOVERY_RSP_WAIT             (100)
+#define WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT         (800)
+#define WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT         (200)
+#endif
+
+const tANI_U8* limTraceTdlsActionString( tANI_U8 tdlsActionCode )
+{
+   switch( tdlsActionCode )
+   {
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_REQ);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_RSP);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_SETUP_CNF);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_TEARDOWN);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_IND);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_REQ);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_CH_SWITCH_RSP);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_PEER_TRAFFIC_RSP);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_REQ);
+       TDLS_CASE_RETURN_STRING(SIR_MAC_TDLS_DIS_RSP);
+   }
+   return (const tANI_U8*)"UNKNOWN";
+}
+#endif
+#if 0
+static void printMacAddr(tSirMacAddr macAddr)
+{
+    int i = 0 ;
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, (" Mac Addr: "));
+
+    for(i = 0 ; i < 6; i++)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                                 (" %02x "), macAddr[i]);
+    }
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("\n"));
+    return ;
+}
+#endif
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * initialize TDLS setup list and related data structures.
+ */
+void limInitTdlsData(tpAniSirGlobal pMac, tpPESession sessionEntry)
+{
+    pMac->lim.gLimTdlsDisResultList = NULL ;
+    pMac->lim.gLimTdlsDisStaCount = 0 ;
+    palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsDisReq, 
+                                            sizeof(tSirTdlsDisReq));
+    palZeroMemory(pMac->hHdd, &pMac->lim.gLimTdlsLinkSetupInfo, 
+                                            sizeof(tLimTdlsLinkSetupInfo));
+    pMac->lim.gAddStaDisRspWait = 0 ;
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    /* when reassociated, negative behavior will not be kept */
+    /* you have to explicitly enable negative behavior per (re)association */
+    pMac->lim.gLimTdlsNegativeBehavior = 0;
+#endif
+    limInitAIDpool(pMac, sessionEntry) ;
+
+    return ;
+}
+#endif
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+void limTdlsSetNegativeBehavior(tpAniSirGlobal pMac, tANI_U8 value, tANI_BOOLEAN on)
+{
+    if(on) {
+        if(value == 255)
+            pMac->lim.gLimTdlsNegativeBehavior = 0XFFFFFFFF;
+        else
+            pMac->lim.gLimTdlsNegativeBehavior |= (1 << (value-1));
+    }
+    else {
+        if(value == 255)
+            pMac->lim.gLimTdlsNegativeBehavior = 0;
+        else
+            pMac->lim.gLimTdlsNegativeBehavior &= ~(1 << (value-1));
+    }
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("%d %d -> gLimTdlsNegativeBehavior= 0x%lx\n"), \
+        value, on, pMac->lim.gLimTdlsNegativeBehavior));
+}
+#endif
+#if 0
+/*
+ * This function is used for creating TDLS public Action frame to
+ * transmit on Direct link
+ */
+static void limPreparesActionFrameHdr(tpAniSirGlobal pMac, tANI_U8 *pFrame,
+                                         tANI_U8 type, tANI_U8 subType,
+                                                   tANI_U8 *link_iden )
+{
+    tpSirMacMgmtHdr pMacHdr ;
+    tANI_U8 *bssid = link_iden ;
+#if 0     
+    tANI_U8 *staMac = (tANI_U8 *)(bssid + sizeof(tSirMacAddr)) ;
+    tANI_U8 *peerMac = (tANI_U8 *) (staMac + sizeof(tSirMacAddr)) ;
+#else    
+   tANI_U8 *peerMac = (tANI_U8 *) (bssid + sizeof(tSirMacAddr)) ;
+   tANI_U8 *staMac = (tANI_U8 *)(peerMac + sizeof(tSirMacAddr)) ;
+#endif    
+    tANI_U8 toDs =  ANI_TXDIR_IBSS  ;
+
+    pMacHdr = (tpSirMacMgmtHdr) (pFrame);
+
+    /*
+     * prepare 802.11 header
+     */ 
+    pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
+    pMacHdr->fc.type    = type ;
+    pMacHdr->fc.subType = subType ;
+    /*
+     * TL is not setting up below fields, so we are doing it here
+     */
+    pMacHdr->fc.toDS    = toDs ;
+    pMacHdr->fc.powerMgmt = 0 ;
+
+     
+    palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, peerMac,
+                                                    sizeof( tSirMacAddr ));
+    palCopyMemory( pMac->hHdd,
+                   (tANI_U8 *) pMacHdr->sa,
+                   staMac, sizeof( tSirMacAddr ));
+
+    palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId,
+                                bssid, sizeof( tSirMacAddr ));
+   
+   LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, ("Preparing TDLS action frame\n%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x\n"), \
+       pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \
+       pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \
+       pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \
+       pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
+
+    return ; 
+}
+#endif
+/*
+ * prepare TDLS frame header, it includes
+ * |             |              |                |
+ * |802.11 header|RFC1042 header|TDLS_PYLOAD_TYPE|PAYLOAD
+ * |             |              |                |
+ */
+static tANI_U32 limPrepareTdlsFrameHeader(tpAniSirGlobal pMac, tANI_U8* pFrame, 
+           tDot11fIELinkIdentifier *link_iden, tANI_U8 tdlsLinkType, tANI_U8 reqType, tpPESession psessionEntry )
+{
+    tpSirMacMgmtHdr pMacHdr ;
+    tANI_U32 header_offset = 0 ;
+    tANI_U8 *addr1 = NULL ;
+    tANI_U8 *addr3 = NULL ;
+    tANI_U8 toDs = (tdlsLinkType == TDLS_LINK_AP) 
+                                       ? ANI_TXDIR_TODS :ANI_TXDIR_IBSS  ;
+    tANI_U8 *peerMac = (reqType == TDLS_INITIATOR) 
+                                       ? link_iden->RespStaAddr : link_iden->InitStaAddr; 
+    tANI_U8 *staMac = (reqType == TDLS_INITIATOR) 
+                                       ? link_iden->InitStaAddr : link_iden->RespStaAddr; 
+   
+    pMacHdr = (tpSirMacMgmtHdr) (pFrame);
+
+    /* 
+     * if TDLS frame goes through the AP link, it follows normal address
+     * pattern, if TDLS frame goes thorugh the direct link, then
+     * A1--> Peer STA addr, A2-->Self STA address, A3--> BSSID
+     */
+    (tdlsLinkType == TDLS_LINK_AP) ? ((addr1 = (link_iden->bssid)),
+                                      (addr3 = (peerMac))) 
+                                   : ((addr1 = (peerMac)),
+                                     (addr3 = (link_iden->bssid))) ;
+    /*
+     * prepare 802.11 header
+     */ 
+    pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
+    pMacHdr->fc.type    = SIR_MAC_DATA_FRAME ;
+    pMacHdr->fc.subType = SIR_MAC_DATA_DATA ;
+    /*
+     * TL is not setting up below fields, so we are doing it here
+     */
+    pMacHdr->fc.toDS    = toDs ;
+    pMacHdr->fc.powerMgmt = 0 ;
+    pMacHdr->fc.wep = (psessionEntry->encryptType == eSIR_ED_NONE)? 0 : 1;
+
+     
+    palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->da, (tANI_U8 *)addr1,
+                                                    sizeof( tSirMacAddr ));
+    palCopyMemory( pMac->hHdd,
+                   (tANI_U8 *) pMacHdr->sa,
+                   (tANI_U8 *) staMac,
+                   sizeof( tSirMacAddr ));
+
+    palCopyMemory( pMac->hHdd, (tANI_U8 *) pMacHdr->bssId,
+                                (tANI_U8 *) (addr3), sizeof( tSirMacAddr ));
+   
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, ("Preparing TDLS frame header to %s\n%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x:%02x\n"), \
+       (tdlsLinkType == TDLS_LINK_AP) ? "AP" : "TD", \
+        pMacHdr->da[0], pMacHdr->da[1], pMacHdr->da[2], pMacHdr->da[3], pMacHdr->da[4], pMacHdr->da[5], \
+        pMacHdr->sa[0], pMacHdr->sa[1], pMacHdr->sa[2], pMacHdr->sa[3], pMacHdr->sa[4], pMacHdr->sa[5], \
+        pMacHdr->bssId[0], pMacHdr->bssId[1], pMacHdr->bssId[2], \
+        pMacHdr->bssId[3], pMacHdr->bssId[4], pMacHdr->bssId[5]));
+
+    //printMacAddr(pMacHdr->bssId) ;
+    //printMacAddr(pMacHdr->sa) ;
+    //printMacAddr(pMacHdr->da) ;
+ 
+    header_offset += sizeof(tSirMacMgmtHdr) ;
+    /* 
+     * Now form RFC1042 header
+     */
+    palCopyMemory(pMac->hHdd, (tANI_U8 *)(pFrame + header_offset), 
+                       (tANI_U8 *)eth_890d_header , sizeof(eth_890d_header)) ;
+
+    header_offset += sizeof(eth_890d_header) ; 
+
+    /* add payload type as TDLS */
+    *(pFrame + header_offset) = PAYLOAD_TYPE_TDLS ;
+
+    return(header_offset += PAYLOAD_TYPE_TDLS_SIZE) ; 
+}
+
+/*
+ * This function can be used for bacst or unicast discovery request
+ * We are not differentiating it here, it will all depnds on peer MAC address,
+ */
+tSirRetStatus limSendTdlsDisReqFrame(tpAniSirGlobal pMac, tSirMacAddr peer_mac,
+                                      tANI_U8 dialog, tpPESession psessionEntry)
+{
+    tDot11fTDLSDisReq   tdlsDisReq ;
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            size = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisReq, 
+                                      sizeof( tDot11fTDLSDisReq ) );
+
+    /*
+     * setup Fixed fields,
+     */
+    tdlsDisReq.Category.category = SIR_MAC_ACTION_TDLS ;
+    tdlsDisReq.Action.action     = SIR_MAC_TDLS_DIS_REQ ;
+    tdlsDisReq.DialogToken.token = dialog ;
+
+
+    size = sizeof(tSirMacAddr) ;
+   
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisReq.LinkIdentifier, 
+                                                 peer_mac, TDLS_INITIATOR) ;
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSDisReqSize( pMac, &tdlsDisReq, &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fTDLSDisReq );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+                     + sizeof( eth_890d_header ) 
+                        + PAYLOAD_TYPE_TDLS_SIZE ;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes, ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * request frame
+     */
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+           LINK_IDEN_ADDR_OFFSET(tdlsDisReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ;
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_REQ)
+    {
+        tdlsDisReq.LinkIdentifier.bssid[4] = 0xde;
+        tdlsDisReq.LinkIdentifier.bssid[5] = 0xad; 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Req\n"), \
+        tdlsDisReq.LinkIdentifier.bssid[0], 
+        tdlsDisReq.LinkIdentifier.bssid[1], 
+        tdlsDisReq.LinkIdentifier.bssid[2], 
+        tdlsDisReq.LinkIdentifier.bssid[3], 
+        tdlsDisReq.LinkIdentifier.bssid[4], 
+        tdlsDisReq.LinkIdentifier.bssid[5]);
+    }
+#endif
+    status = dot11fPackTDLSDisReq( pMac, &tdlsDisReq, pFrame 
+                               + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Discovery Request (0x%08x).\n") );
+    }
+
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+            SIR_MAC_TDLS_DIS_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_REQ) ));
+
+    halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_TODS,
+                            7,
+                            limTxComplete, pFrame, 0 );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+
+    return eSIR_SUCCESS;
+
+}
+
+/*
+ * Once Discovery response is sent successfully (or failure) on air, now send
+ * response to PE and send del STA to HAL.
+ */
+eHalStatus limTdlsDisRspTxComplete(tpAniSirGlobal pMac, 
+                                           tANI_U32 txCompleteSuccess)
+{
+    eHalStatus status = eHAL_STATUS_SUCCESS ;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+    tpDphHashNode pStaDs = NULL ;
+    tSirTdlsPeerInfo *peerInfo = 0 ;
+
+    /* find peer by looking into the list by expected state */
+    peerInfo = limTdlsFindDisPeerByState(pMac, TDLS_DIS_RSP_SENT_WAIT_STATE) ;
+
+    if(NULL == peerInfo)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                       ("DisRspTxComplete: No TDLS state machine waits for this event\n"));
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+
+    peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_DONE_STATE ;
+
+    if(peerInfo->delStaNeeded)
+    {
+        tpPESession psessionEntry;
+        
+        peerInfo->delStaNeeded = false ;
+        psessionEntry = peFindSessionBySessionId (pMac, peerInfo->sessionId);
+
+        if(NULL == psessionEntry) 
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                           ("DisRspTxComplete: sessionID %d is not found\n"), peerInfo->sessionId);
+            return eHAL_STATUS_FAILURE;
+        }
+        /* send del STA to remove context for this TDLS STA */
+        pStaDs = limTdlsDelSta(pMac, peerInfo->peerMac, psessionEntry) ;
+
+        /* now send indication to SME-->HDD->TL to remove STA from TL */
+        if(pStaDs)
+        {
+            limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, 
+                                                     pStaDs, eSIR_SUCCESS) ;
+        }
+        else
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                           ("DisRspTxComplete: staDs not found for %02x:%02x:%02x:%02x:%02x:%02x\n"),
+                           (peerInfo)->peerMac[0],    
+                           (peerInfo)->peerMac[1],    
+                           (peerInfo)->peerMac[2],    
+                           (peerInfo)->peerMac[3],    
+                           (peerInfo)->peerMac[4],    
+                           (peerInfo)->peerMac[5]) ;
+            VOS_ASSERT(0) ;
+            return eHAL_STATUS_FAILURE;
+        }
+    }
+ 
+    if(!txCompleteSuccess)
+     {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                       ("TX complete failure for Dis RSP"));
+        limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE, 
+                                     eWNI_SME_TDLS_DISCOVERY_START_IND) ;
+        status = eHAL_STATUS_FAILURE;
+    }
+    else
+    {
+        limSendSmeTdlsDisRsp(pMac, eSIR_SUCCESS, 
+                                     eWNI_SME_TDLS_DISCOVERY_START_IND) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                       ("TX complete Success for Dis RSP"));
+        status = eHAL_STATUS_SUCCESS ;
+    }
+    //pMac->hal.pCBackFnTxComp = NULL ;
+#endif 
+    return status ;
+
+}
+/*
+ * Once setup CNF is sent successfully (or failure) on air, now send
+ * response to PE and send del STA to HAL.
+ */
+eHalStatus limTdlsSetupCnfTxComplete(tpAniSirGlobal pMac,
+                                           tANI_U32 txCompleteSuccess)
+{
+    eHalStatus status = eHAL_STATUS_SUCCESS ;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+    tLimTdlsLinkSetupPeer *peerInfo = 0 ;
+    /* find peer by looking into the list by expected state */
+    limTdlsFindSetupPeerByState(pMac, 
+                             TDLS_LINK_SETUP_RSP_WAIT_STATE, &peerInfo) ;
+  
+    if(NULL == peerInfo)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                       ("limTdlsSetupCnfTxComplete: No TDLS state machine waits for this event\n"));
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+ 
+    (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
+    (peerInfo)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ; 
+
+    if(!txCompleteSuccess)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                   ("TX complete Failure for setup CNF"));
+        limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, (peerInfo)->peerMac,
+                                               eWNI_SME_TDLS_LINK_START_RSP) ;
+        status = eHAL_STATUS_FAILURE;
+    }
+    else
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+              ("RSP-->SME peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                           (peerInfo)->peerMac[0],    
+                           (peerInfo)->peerMac[1],    
+                           (peerInfo)->peerMac[2],    
+                           (peerInfo)->peerMac[3],    
+                           (peerInfo)->peerMac[4],    
+                           (peerInfo)->peerMac[5]) ;
+    
+        limSendSmeTdlsLinkStartRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
+                                               eWNI_SME_TDLS_LINK_START_RSP) ;
+
+        /* tdls_hklee: prepare PTI template and send it to HAL */
+        limTdlsLinkEstablish(pMac, (peerInfo)->peerMac);
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                 ("TX complete Success for setup CNF"));
+        status = eHAL_STATUS_SUCCESS ;
+    }
+    //pMac->hal.pCBackFnTxComp = NULL ;
+#endif 
+    return status ;
+
+}
+
+/*
+ * Tx Complete for Teardown frame
+ */
+eHalStatus limTdlsTeardownTxComplete(tpAniSirGlobal pMac,
+                                           tANI_U32 txCompleteSuccess)  
+{
+    eHalStatus status = eHAL_STATUS_SUCCESS ;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+    tpDphHashNode pStaDs = NULL ;
+    tLimTdlsLinkSetupPeer *peerInfo = 0 ;
+    tpPESession psessionEntry = NULL ;
+    //tANI_U16 msgType = 0 ;
+
+    //tSirMacAddr peerMac = {0} ;
+    /* find peer by looking into the list by expected state */
+    limTdlsFindSetupPeerByState(pMac, 
+                             TDLS_LINK_TEARDOWN_START_STATE, &peerInfo) ;
+  
+    if(NULL == peerInfo)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                       ("limTdlsTeardownTxComplete: No TDLS state machine waits for this event\n"));
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                  ("teardown peer Mac = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                             (peerInfo)->peerMac[0] ,             
+                             (peerInfo)->peerMac[1] ,             
+                             (peerInfo)->peerMac[2] ,             
+                             (peerInfo)->peerMac[3] ,             
+                             (peerInfo)->peerMac[4] ,             
+                             (peerInfo)->peerMac[5] ) ;           
+             
+
+    //pMac->hal.pCBackFnTxComp = NULL ;
+
+    psessionEntry = peFindSessionBySessionId(pMac, (peerInfo)->tdls_sessionId);
+
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                       ("limTdlsTeardownTxComplete: sessionID %d is not found\n"), (peerInfo)->tdls_sessionId);
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+
+    if(!txCompleteSuccess)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                         ("TX complete failure for Teardown  \n")) ;
+
+        /* 
+         * we should be sending Teradown to AP with status code 
+         * eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, we are not worried if 
+         * that is delivered or not, any way we removing this peer STA from our
+         * list
+         */
+        if(NULL != psessionEntry)
+        {
+            limSendTdlsTeardownFrame(pMac, (peerInfo)->peerMac, 
+                     eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE, psessionEntry, NULL, 0) ;
+        }
+    }
+
+    if(TDLS_LINK_SETUP_WAIT_STATE != (peerInfo)->tdls_prev_link_state)
+    {
+        (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
+        (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ; 
+        /* send del STA to remove context for this TDLS STA */
+        if(NULL != psessionEntry)
+        {
+            /* tdls_hklee: send message to HAL before it is deleted */
+            limTdlsLinkTeardown(pMac, (peerInfo)->peerMac) ;
+
+            pStaDs = limTdlsDelSta(pMac, (peerInfo)->peerMac, psessionEntry) ;
+        }
+
+        /* now send indication to SME-->HDD->TL to remove STA from TL */
+        if(!pStaDs)
+        {
+            VOS_ASSERT(0) ;
+            return eSIR_FAILURE ;
+        }
+        limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId, 
+                                                pStaDs, eSIR_SUCCESS) ;
+ 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                      ("TX complete SUCCESS for Teardown\n")) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                      ("Prev State = %d\n"), (peerInfo)->tdls_prev_link_state) ;
+        limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
+                                                     eWNI_SME_TDLS_TEARDOWN_RSP) ;
+        /* Delete Peer for Link Peer List */
+        limTdlsDelLinkPeer(pMac, (peerInfo)->peerMac) ;
+    }
+    else
+    {
+        (peerInfo)->tdls_prev_link_state = (peerInfo)->tdls_link_state ;
+        (peerInfo)->tdls_link_state = TDLS_LINK_TEARDOWN_DONE_STATE ; 
+        limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (peerInfo)->peerMac,
+                                                eWNI_SME_TDLS_TEARDOWN_IND) ;
+    }
+
+
+#if 0
+    /* if previous state is link restart, then restart link setup again */
+    if(TDLS_LINK_SETUP_RESTART_STATE == (peerInfo)->tdls_prev_link_state)
+    {
+        tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
+        limTdlsPrepareSetupReqFrame(pMac, setupInfo, 37, 
+                                                   peerMac, psessionEntry) ;
+    }
+#endif  
+    status = eHAL_STATUS_SUCCESS ;
+#endif
+    return status ;
+}
+
+/*
+ * Send TDLS discovery response frame on direct link.
+ */
+
+static tSirRetStatus limSendTdlsDisRspFrame(tpAniSirGlobal pMac, 
+                     tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry)
+{
+    tDot11fTDLSDisRsp   tdlsDisRsp ;
+    tANI_U16            caps = 0 ;            
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsDisRsp, 
+                                      sizeof( tDot11fTDLSDisRsp ) );
+
+    /*
+     * setup Fixed fields,
+     */
+    tdlsDisRsp.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
+    tdlsDisRsp.Action.action     = SIR_MAC_TDLS_DIS_RSP ;
+    tdlsDisRsp.DialogToken.token = dialog ;
+
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsDisRsp.LinkIdentifier, 
+                                           peerMac, TDLS_RESPONDER) ;
+
+    if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
+    {
+        /*
+         * Could not get Capabilities value
+         * from CFG. Log error.
+         */
+         limLog(pMac, LOGP,
+                   FL("could not retrieve Capabilities value\n"));
+    }
+    swapBitField16(caps, ( tANI_U16* )&tdlsDisRsp.Capabilities );
+
+    /* populate supported rate IE */
+    PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, 
+                                     &tdlsDisRsp.SuppRates, psessionEntry );
+   
+    /* Populate extended supported rates */
+    PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
+                                &tdlsDisRsp.ExtSuppRates, psessionEntry );
+
+    /* Populate extended supported rates */
+    PopulateDot11fTdlsExtCapability( pMac, &tdlsDisRsp.ExtCap );
+
+    /* Include HT Capability IE */
+    //This does not depend on peer capabilities. If it is supported then it should be included
+    PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsDisRsp.HTCaps );
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSDisRspSize( pMac, &tdlsDisRsp, &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fProbeRequest );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) ;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes, ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * response frame
+     */
+
+    /* Make public Action Frame */
+
+#if 0
+    limPreparesActionFrameHdr(pMac, pFrame, SIR_MAC_MGMT_FRAME,
+                                          SIR_MAC_MGMT_ACTION, 
+                                            LINK_IDEN_ADDR_OFFSET(tdlsDisRsp)) ;
+#endif
+    limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
+              SIR_MAC_MGMT_ACTION, peerMac, psessionEntry->selfMacAddr);
+
+    {
+        tpSirMacMgmtHdr     pMacHdr;
+        pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
+        pMacHdr->fc.toDS    = ANI_TXDIR_IBSS;
+        pMacHdr->fc.powerMgmt = 0 ;
+        sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
+    }
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_DSCV_RSP)
+    {
+        tdlsDisRsp.LinkIdentifier.bssid[4] = 0xde;
+        tdlsDisRsp.LinkIdentifier.bssid[5] = 0xad; 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Discovery Rsp\n"), \
+        tdlsDisRsp.LinkIdentifier.bssid[0], 
+        tdlsDisRsp.LinkIdentifier.bssid[1], 
+        tdlsDisRsp.LinkIdentifier.bssid[2], 
+        tdlsDisRsp.LinkIdentifier.bssid[3], 
+        tdlsDisRsp.LinkIdentifier.bssid[4], 
+        tdlsDisRsp.LinkIdentifier.bssid[5]);
+    }
+#endif
+    status = dot11fPackTDLSDisRsp( pMac, &tdlsDisRsp, pFrame + 
+                                              sizeof( tSirMacMgmtHdr ),
+                                                  nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Discovery Request (0x%08x).\n") );
+    }
+
+#if 0
+    if(pMac->hal.pCBackFnTxComp == NULL) 
+    {
+        pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsDisRspTxComplete;
+
+        if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) 
+        {
+            status = eHAL_STATUS_FAILURE;
+            return status;
+                
+        }
+    }
+#endif
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                 ("transmitting Discovery response on direct link\n")) ;
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+            SIR_MAC_TDLS_DIS_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_DIS_RSP) ));
+
+
+    /*
+     * Transmit Discovery response and watch if this is delivered to
+     * peer STA.
+     */
+    halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_IBSS,
+                            0,
+                            limTxComplete, pFrame, 
+                            limTdlsDisRspTxComplete,
+                            HAL_USE_SELF_STA_REQUESTED_MASK );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+
+    return eSIR_SUCCESS;
+
+}
+
+/*
+ * TDLS setup Request frame on AP link
+ */
+
+tSirRetStatus limSendTdlsLinkSetupReqFrame(tpAniSirGlobal pMac,
+            tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry,
+            tANI_U8 *addIe, tANI_U16 addIeLen) 
+{
+    tDot11fTDLSSetupReq    tdlsSetupReq ;
+    tANI_U16            caps = 0 ;            
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupReq, 
+                                      sizeof( tDot11fTDLSSetupReq ) );
+    tdlsSetupReq.Category.category = SIR_MAC_ACTION_TDLS ;
+    tdlsSetupReq.Action.action     = SIR_MAC_TDLS_SETUP_REQ ;
+    tdlsSetupReq.DialogToken.token = dialog ;
+
+
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupReq.LinkIdentifier,
+                                                    peerMac, TDLS_INITIATOR) ;
+
+    if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
+    {
+        /*
+         * Could not get Capabilities value
+         * from CFG. Log error.
+         */
+         limLog(pMac, LOGP,
+                   FL("could not retrieve Capabilities value\n"));
+    }
+    swapBitField16(caps, ( tANI_U16* )&tdlsSetupReq.Capabilities );
+
+    /* populate supported rate IE */
+    PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, 
+                              &tdlsSetupReq.SuppRates, psessionEntry );
+   
+    /* Populate extended supported rates */
+    PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
+                                &tdlsSetupReq.ExtSuppRates, psessionEntry );
+
+    /* Populate extended supported rates */
+    PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupReq.ExtCap );
+
+   /* 
+     * TODO: we need to see if we have to support conditions where we have
+     * EDCA parameter info element is needed a) if we need different QOS
+     * parameters for off channel operations or QOS is not supported on 
+     * AP link and we wanted to QOS on direct link.
+     */
+    /* Populate QOS info, needed for Peer U-APSD session */
+    /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
+    TDLS doesn't want to depend on AP's capability */
+    tdlsSetupReq.QOSCapsStation.present = 1;
+    tdlsSetupReq.QOSCapsStation.max_sp_length = 0;
+    tdlsSetupReq.QOSCapsStation.qack = 0;
+    tdlsSetupReq.QOSCapsStation.acbe_uapsd = 0;
+    tdlsSetupReq.QOSCapsStation.acbk_uapsd = 0;
+    tdlsSetupReq.QOSCapsStation.acvi_uapsd = 0;
+    tdlsSetupReq.QOSCapsStation.acvo_uapsd = 0;
+    
+
+    /*
+     * we will always try to init TDLS link with 11n capabilities
+     * let TDLS setup response to come, and we will set our caps based
+     * of peer caps
+     */
+
+    /* Include HT Capability IE */
+    PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupReq.HTCaps );
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSSetupReqSize( pMac, &tdlsSetupReq, 
+                                                              &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fProbeRequest );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+                     + sizeof( eth_890d_header ) 
+                        + PAYLOAD_TYPE_TDLS_SIZE
+                        + addIeLen;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes , ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * request frame
+     */
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+                     LINK_IDEN_ADDR_OFFSET(tdlsSetupReq), TDLS_LINK_AP, TDLS_INITIATOR, psessionEntry) ;
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_REQ)
+    {
+        tdlsSetupReq.LinkIdentifier.bssid[4] = 0xde;
+        tdlsSetupReq.LinkIdentifier.bssid[5] = 0xad; 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Req\n"), \
+        tdlsSetupReq.LinkIdentifier.bssid[0], 
+        tdlsSetupReq.LinkIdentifier.bssid[1], 
+        tdlsSetupReq.LinkIdentifier.bssid[2], 
+        tdlsSetupReq.LinkIdentifier.bssid[3], 
+        tdlsSetupReq.LinkIdentifier.bssid[4], 
+        tdlsSetupReq.LinkIdentifier.bssid[5]);
+    }
+#endif
+    status = dot11fPackTDLSSetupReq( pMac, &tdlsSetupReq, pFrame 
+                               + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Discovery Request (0x%08x).\n") );
+    }
+
+    //Copy the additional IE. 
+    //TODO : addIe is added at the end of the frame. This means it doesnt
+    //follow the order. This should be ok, but we should consider changing this
+    //if there is any IOT issue.
+    if( addIeLen != 0 )
+    {
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),  
+            addIeLen ));
+       palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); 
+    }
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+            SIR_MAC_TDLS_SETUP_REQ, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_REQ) ));
+
+    halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_TODS,
+                            7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
+                            limTxComplete, pFrame, 0 );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+
+    return eSIR_SUCCESS;
+
+}
+/*
+ * Send TDLS Teardown frame on Direct link or AP link, depends on reason code.
+ */
+
+tSirRetStatus limSendTdlsTeardownFrame(tpAniSirGlobal pMac,
+            tSirMacAddr peerMac, tANI_U16 reason, tpPESession psessionEntry,
+            tANI_U8 *addIe, tANI_U16 addIeLen) 
+{
+    tDot11fTDLSTeardown teardown ;
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&teardown, 
+                                      sizeof( tDot11fTDLSTeardown ) );
+    teardown.Category.category = SIR_MAC_ACTION_TDLS ;
+    teardown.Action.action     = SIR_MAC_TDLS_TEARDOWN ;
+    teardown.Reason.code       = reason ;
+
+    PopulateDot11fLinkIden( pMac, psessionEntry, &teardown.LinkIdentifier, 
+                                                peerMac, TDLS_INITIATOR) ;
+
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSTeardownSize( pMac, &teardown, &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fProbeRequest );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+                     + sizeof( eth_890d_header ) 
+                        + PAYLOAD_TYPE_TDLS_SIZE
+                        + addIeLen;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes, ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * request frame
+     */
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+                     LINK_IDEN_ADDR_OFFSET(teardown), 
+                          (reason == eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE) 
+                              ? TDLS_LINK_AP : TDLS_LINK_DIRECT, TDLS_INITIATOR,
+                              psessionEntry) ;
+
+    status = dot11fPackTDLSTeardown( pMac, &teardown, pFrame 
+                               + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS Teardown req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Teardown Request (0x%08x).\n") );
+    }
+#if 0
+    if(pMac->hal.pCBackFnTxComp == NULL) 
+    {
+        pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsTeardownTxComplete;
+        if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) 
+        {
+            status = eHAL_STATUS_FAILURE;
+            return status;
+                
+        }
+    }
+    else
+    {
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+#endif
+ 
+    if( addIeLen != 0 )
+    {
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Copy Additional Ie Len = %d"),  
+            addIeLen ));
+       palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); 
+    }
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+         SIR_MAC_TDLS_TEARDOWN, limTraceTdlsActionString(SIR_MAC_TDLS_TEARDOWN) ));
+
+    halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_TODS,
+                            7,
+                            limTxComplete, pFrame, 
+                            limTdlsTeardownTxComplete,
+                            0 );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+    return eSIR_SUCCESS;
+
+}
+
+/*
+ * Send Setup RSP frame on AP link.
+ */
+static tSirRetStatus limSendTdlsSetupRspFrame(tpAniSirGlobal pMac, 
+                    tSirMacAddr peerMac, tANI_U8 dialog, tpPESession psessionEntry, 
+                    etdlsLinkSetupStatus setupStatus, tANI_U8 *addIe, tANI_U16 addIeLen )
+{
+    tDot11fTDLSSetupRsp  tdlsSetupRsp ;
+    tANI_U32            status = 0 ;
+    tANI_U16            caps = 0 ;            
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupRsp, 
+                                      sizeof( tDot11fTDLSSetupRsp ) );
+
+    /*
+     * setup Fixed fields,
+     */
+    tdlsSetupRsp.Category.category = SIR_MAC_ACTION_TDLS;
+    tdlsSetupRsp.Action.action     = SIR_MAC_TDLS_SETUP_RSP ;
+    tdlsSetupRsp.DialogToken.token = dialog;
+
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupRsp.LinkIdentifier,
+                 peerMac, TDLS_RESPONDER) ;
+
+    if (cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
+    {
+        /*
+         * Could not get Capabilities value
+         * from CFG. Log error.
+         */
+         limLog(pMac, LOGP,
+                   FL("could not retrieve Capabilities value\n"));
+    }
+    swapBitField16(caps, ( tANI_U16* )&tdlsSetupRsp.Capabilities );
+
+    /* ipopulate supported rate IE */
+    PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, 
+                                &tdlsSetupRsp.SuppRates, psessionEntry );
+   
+    /* Populate extended supported rates */
+    PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
+                                &tdlsSetupRsp.ExtSuppRates, psessionEntry );
+
+    /* Populate extended supported rates */
+    PopulateDot11fTdlsExtCapability( pMac, &tdlsSetupRsp.ExtCap );
+
+    /* 
+     * TODO: we need to see if we have to support conditions where we have
+     * EDCA parameter info element is needed a) if we need different QOS
+     * parameters for off channel operations or QOS is not supported on 
+     * AP link and we wanted to QOS on direct link.
+     */
+    /* Populate QOS info, needed for Peer U-APSD session */
+    /* TODO: Now hardcoded, because PopulateDot11fQOSCapsStation() depends on AP's capability, and
+    TDLS doesn't want to depend on AP's capability */
+    tdlsSetupRsp.QOSCapsStation.present = 1;
+    tdlsSetupRsp.QOSCapsStation.max_sp_length = 0;
+    tdlsSetupRsp.QOSCapsStation.qack = 0;
+    tdlsSetupRsp.QOSCapsStation.acbe_uapsd = 1;
+    tdlsSetupRsp.QOSCapsStation.acbk_uapsd = 1;
+    tdlsSetupRsp.QOSCapsStation.acvi_uapsd = 1;
+    tdlsSetupRsp.QOSCapsStation.acvo_uapsd = 1;
+
+    /* Include HT Info IE */
+//    if ( setupReq->HTCaps.present)
+//    {
+        PopulateDot11fHTCaps( pMac, psessionEntry, &tdlsSetupRsp.HTCaps );
+//    }
+
+    tdlsSetupRsp.Status.status = setupStatus ;
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSSetupRspSize( pMac, &tdlsSetupRsp, 
+                                                     &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fProbeRequest );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+                     + sizeof( eth_890d_header ) 
+                        + PAYLOAD_TYPE_TDLS_SIZE
+                        + addIeLen;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes, ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * request frame
+     */
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+                                 LINK_IDEN_ADDR_OFFSET(tdlsSetupRsp), 
+                                       TDLS_LINK_AP, TDLS_RESPONDER,
+                                       psessionEntry) ;
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_WRONG_BSSID_IN_SETUP_RSP)
+    {
+        tdlsSetupRsp.LinkIdentifier.bssid[4] = 0xde;
+        tdlsSetupRsp.LinkIdentifier.bssid[5] = 0xad; 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: wrong BSSID %02x:%02x:%02x:%02x:%02x:%02x in TDLS Setup Rsp\n"), \
+        tdlsSetupRsp.LinkIdentifier.bssid[0], 
+        tdlsSetupRsp.LinkIdentifier.bssid[1], 
+        tdlsSetupRsp.LinkIdentifier.bssid[2], 
+        tdlsSetupRsp.LinkIdentifier.bssid[3], 
+        tdlsSetupRsp.LinkIdentifier.bssid[4], 
+        tdlsSetupRsp.LinkIdentifier.bssid[5]);
+    }
+#endif
+    status = dot11fPackTDLSSetupRsp( pMac, &tdlsSetupRsp, pFrame 
+                               + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Discovery Request (0x%08x).\n") );
+    }
+
+    //Copy the additional IE. 
+    //TODO : addIe is added at the end of the frame. This means it doesnt
+    //follow the order. This should be ok, but we should consider changing this
+    //if there is any IOT issue.
+    if( addIeLen != 0 )
+    {
+       palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); 
+    }
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+         SIR_MAC_TDLS_SETUP_RSP, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_RSP) ));
+
+    halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_TODS,
+                            //ANI_TXDIR_IBSS,
+                            7,
+                            limTxComplete, pFrame, 0 );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+
+    return eSIR_SUCCESS;
+
+}
+
+/*
+ * Send TDLS setup CNF frame on AP link
+ */
+
+tSirRetStatus limSendTdlsLinkSetupCnfFrame(tpAniSirGlobal pMac, tSirMacAddr peerMac,
+                    tANI_U8 dialog, tpPESession psessionEntry, tANI_U8* addIe, tANI_U16 addIeLen)  
+{
+    tDot11fTDLSSetupCnf  tdlsSetupCnf ;
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U8            *pFrame;
+    void               *pPacket;
+    eHalStatus          halstatus;
+
+    /* 
+     * The scheme here is to fill out a 'tDot11fProbeRequest' structure
+     * and then hand it off to 'dot11fPackProbeRequest' (for
+     * serialization).  We start by zero-initializing the structure:
+     */
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsSetupCnf, 
+                                      sizeof( tDot11fTDLSSetupCnf ) );
+
+    /*
+     * setup Fixed fields,
+     */
+    tdlsSetupCnf.Category.category = SIR_MAC_ACTION_TDLS;
+    tdlsSetupCnf.Action.action     = SIR_MAC_TDLS_SETUP_CNF ;
+    tdlsSetupCnf.DialogToken.token = dialog ;
+
+#if 1
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsSetupCnf.LinkIdentifier,
+                      peerMac, TDLS_INITIATOR) ;
+#else
+    palCopyMemory( pMac->hHdd, (tANI_U8 *)&tdlsSetupCnf.LinkIdentifier, 
+                     (tANI_U8 *)&setupRsp->LinkIdentifier, sizeof(tDot11fIELinkIdentifier)) ; 
+#endif
+
+    /* 
+     * TODO: we need to see if we have to support conditions where we have
+     * EDCA parameter info element is needed a) if we need different QOS
+     * parameters for off channel operations or QOS is not supported on 
+     * AP link and we wanted to QOS on direct link.
+     */
+
+    /* Include HT Info IE */
+    //if ( tdlsSetupCnf.HTCaps.present)
+    //{
+    //    PopulateDot11fHTInfo( pMac, &tdlsSetupCnf.HTInfo, psessionEntry );
+   // }
+
+    /* 
+     * now we pack it.  First, how much space are we going to need?
+     */
+    status = dot11fGetPackedTDLSSetupCnfSize( pMac, &tdlsSetupCnf, 
+                                                     &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
+                               "or a discovery Request (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tDot11fProbeRequest );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating"
+                               "the packed size for a discovery Request ("
+                               "0x%08x).\n"), status );
+    }
+
+    /*
+     * This frame is going out from PE as data frames with special ethertype
+     * 89-0d.
+     * 8 bytes of RFC 1042 header
+     */ 
+
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+                     + sizeof( eth_890d_header ) 
+                        + PAYLOAD_TYPE_TDLS_SIZE
+                        + addIeLen;
+
+    /* Ok-- try to allocate memory from MGMT PKT pool */
+
+    halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
+                             ( tANI_U16 )nBytes, ( void** ) &pFrame,
+                             ( void** ) &pPacket );
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TDLS"
+                               "Discovery Request.\n"), nBytes );
+        return eSIR_MEM_ALLOC_FAILED;
+    }
+
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, nBytes );
+
+    /* 
+     * IE formation, memory allocation is completed, Now form TDLS discovery
+     * request frame
+     */
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+                     LINK_IDEN_ADDR_OFFSET(tdlsSetupCnf), TDLS_LINK_AP, TDLS_INITIATOR,
+                     psessionEntry) ;
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_STATUS_37_IN_SETUP_CNF) {
+        tdlsSetupCnf.StatusCode.statusCode = 37;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: StatusCode = 37 in TDLS Setup Cnf\n"));
+    }
+#endif
+    status = dot11fPackTDLSSetupCnf( pMac, &tdlsSetupCnf, pFrame 
+                               + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a TDLS discovery req \
+                                               (0x%08x).\n"), status );
+        palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, 
+                                   ( void* ) pFrame, ( void* ) pPacket );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+                               "Discovery Request (0x%08x).\n") );
+    }
+#if 0
+    if(pMac->hal.pCBackFnTxComp == NULL) 
+    {
+        pMac->hal.pCBackFnTxComp = (tpCBackFnTxComp)limTdlsSetupCnfTxComplete;
+        if(TX_SUCCESS != tx_timer_activate(&pMac->hal.txCompTimer)) 
+        {
+            status = eHAL_STATUS_FAILURE;
+            return status;
+                
+        }
+    }
+    else
+    {
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+#endif
+    //Copy the additional IE. 
+    //TODO : addIe is added at the end of the frame. This means it doesnt
+    //follow the order. This should be ok, but we should consider changing this
+    //if there is any IOT issue.
+    if( addIeLen != 0 )
+    {
+       palCopyMemory( pMac->hHdd, pFrame + header_offset + nPayload, addIe, addIeLen ); 
+    }
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Send TDLS action %d (%s)"),  
+         SIR_MAC_TDLS_SETUP_CNF, limTraceTdlsActionString(SIR_MAC_TDLS_SETUP_CNF) ));
+
+    halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
+                            HAL_TXRX_FRM_802_11_DATA,
+                            ANI_TXDIR_TODS,
+                            7,
+                            limTxComplete, pFrame, 
+                            limTdlsSetupCnfTxComplete,
+                            0 );
+
+
+    if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
+    {
+        limLog( pMac, LOGE, FL("could not send TDLS Dis Request frame!\n" ));
+        return eSIR_FAILURE;
+
+    }
+
+    return eSIR_SUCCESS;
+}
+
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * Convert HT caps to lim based HT caps 
+ */
+static void limTdlsCovertHTCaps(tpAniSirGlobal pMac ,
+                         tSirTdlsPeerInfo *peerInfo, tDot11fIEHTCaps *HTCaps)
+{
+
+    /* HT Capability Info */
+    peerInfo->tdlsPeerHtCaps.advCodingCap = HTCaps->advCodingCap ;
+    peerInfo->tdlsPeerHtCaps.supportedChannelWidthSet = 
+                                            HTCaps->supportedChannelWidthSet ;
+    peerInfo->tdlsPeerHtCaps.mimoPowerSave = HTCaps->mimoPowerSave ;
+    peerInfo->tdlsPeerHtCaps.greenField = HTCaps->greenField ;
+    peerInfo->tdlsPeerHtCaps.shortGI20MHz = HTCaps->shortGI20MHz ;
+    peerInfo->tdlsPeerHtCaps.shortGI40MHz = HTCaps->shortGI40MHz ;
+    peerInfo->tdlsPeerHtCaps.txSTBC = HTCaps->txSTBC ;
+    peerInfo->tdlsPeerHtCaps.rxSTBC = HTCaps->rxSTBC ;
+    peerInfo->tdlsPeerHtCaps.delayedBA = HTCaps->delayedBA;
+    peerInfo->tdlsPeerHtCaps.maximalAMSDUsize = HTCaps->maximalAMSDUsize ;
+    peerInfo->tdlsPeerHtCaps.dsssCckMode40MHz = HTCaps->dsssCckMode40MHz ;
+    peerInfo->tdlsPeerHtCaps.psmp = HTCaps->stbcControlFrame ;
+    peerInfo->tdlsPeerHtCaps.stbcControlFrame = HTCaps->stbcControlFrame ;
+    peerInfo->tdlsPeerHtCaps.lsigTXOPProtection = 
+                                                 HTCaps->lsigTXOPProtection ;
+
+    /* HT Capa parameters */
+    peerInfo->tdlsPeerHtParams.maxRxAMPDUFactor = HTCaps->maxRxAMPDUFactor ;
+    peerInfo->tdlsPeerHtParams.mpduDensity = HTCaps->mpduDensity ;
+    peerInfo->tdlsPeerHtParams.reserved = HTCaps->reserved1 ;
+    
+    /* Extended HT caps */
+    peerInfo->tdlsPeerHtExtCaps.pco = HTCaps->pco ;
+    peerInfo->tdlsPeerHtExtCaps.transitionTime = HTCaps->transitionTime ;
+    peerInfo->tdlsPeerHtExtCaps.mcsFeedback = HTCaps->mcsFeedback ;
+    palCopyMemory(pMac->hHdd, peerInfo->supportedMCSSet, 
+                      HTCaps->supportedMCSSet, SIZE_OF_SUPPORTED_MCS_SET) ;
+
+    return ;
+}
+
+/*
+ * update capability info..
+ */
+void tdlsUpdateCapInfo(tSirMacCapabilityInfo *capabilityInfo, 
+                                tDot11fFfCapabilities *Capabilities)
+{
+
+    capabilityInfo->ess            = Capabilities->ess;
+    capabilityInfo->ibss           = Capabilities->ibss;
+    capabilityInfo->cfPollable     = Capabilities->cfPollable;
+    capabilityInfo->cfPollReq      = Capabilities->cfPollReq;
+    capabilityInfo->privacy        = Capabilities->privacy;
+    capabilityInfo->shortPreamble  = Capabilities->shortPreamble;
+    capabilityInfo->pbcc           = Capabilities->pbcc;
+    capabilityInfo->channelAgility = Capabilities->channelAgility;
+    capabilityInfo->spectrumMgt    = Capabilities->spectrumMgt;
+    capabilityInfo->qos            = Capabilities->qos;
+    capabilityInfo->shortSlotTime  = Capabilities->shortSlotTime;
+    capabilityInfo->apsd           = Capabilities->apsd;
+    capabilityInfo->rrm            = Capabilities->rrm;
+    capabilityInfo->dsssOfdm       = Capabilities->dsssOfdm;
+    capabilityInfo->immediateBA    = Capabilities->immediateBA;
+
+    return ;
+}
+
+/*
+ * update Peer info from the link request frame recieved from Peer..
+ * in list of STA participating in TDLS link setup
+ */
+void limTdlsUpdateLinkReqPeerInfo(tpAniSirGlobal pMac, 
+                                 tLimTdlsLinkSetupPeer *setupPeer, 
+                                             tDot11fTDLSSetupReq *setupReq)
+{
+
+    /* Populate peer info of tdls discovery result */
+
+    tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupReq->Capabilities) ;
+
+    if(setupReq->SuppRates.present)
+    {
+        ConvertSuppRates( pMac, &setupPeer->supportedRates, 
+                                            &setupReq->SuppRates );
+    }
+
+    /* update QOS info, needed for Peer U-APSD session */
+    if(setupReq->QOSCapsStation.present)
+    {
+       ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps, 
+                   &setupReq->QOSCapsStation) ;
+       LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,("setupReq->SPLen=%d (be %d %d %d %d vo) more %d qack %d.\n"), \
+         setupReq->QOSCapsStation.max_sp_length, setupReq->QOSCapsStation.acbe_uapsd, \
+         setupReq->QOSCapsStation.acbk_uapsd, setupReq->QOSCapsStation.acvi_uapsd, \
+         setupReq->QOSCapsStation.acvo_uapsd, setupReq->QOSCapsStation.more_data_ack, \
+         setupReq->QOSCapsStation.qack));
+    }
+    
+    if(setupReq->ExtSuppRates.present)
+    {
+        setupPeer->ExtRatesPresent = 1;
+        ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
+                                                &setupReq->ExtSuppRates );
+    }
+    /* update HT caps */
+    if(setupReq->HTCaps.present)
+    {
+        palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps, 
+                    &setupReq->HTCaps, sizeof(tDot11fIEHTCaps)) ;
+    }
+    /* Update EXT caps */
+    if(setupReq->ExtCap.present)
+    {
+        palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps, 
+                    &setupReq->ExtCap, sizeof(tDot11fIEExtCap)) ;
+    }    
+
+    return ;
+}
+
+/*
+ * update peer Info recieved with TDLS setup RSP 
+ */
+void limTdlsUpdateLinkRspPeerInfo(tpAniSirGlobal pMac, 
+                                   tLimTdlsLinkSetupPeer *setupPeer, 
+                                             tDot11fTDLSSetupRsp *setupRsp)
+{
+
+    /* Populate peer info of tdls discovery result */
+    tdlsUpdateCapInfo(&setupPeer->capabilityInfo , &setupRsp->Capabilities) ;
+
+    if(setupRsp->SuppRates.present)
+    {
+        tDot11fIESuppRates *suppRates = &setupRsp->SuppRates ;
+        ConvertSuppRates( pMac, &setupPeer->supportedRates, suppRates);
+    }
+
+    /* update QOS info, needed for Peer U-APSD session */
+    if(setupRsp->QOSCapsStation.present)
+    {
+       ConvertQOSCapsStation(pMac->hHdd, &setupPeer->qosCaps, 
+                   &setupRsp->QOSCapsStation) ;
+       LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("setupRsp->SPLen=%d (be %d %d %d %d vo) more %d qack %d.\n"), \
+         setupRsp->QOSCapsStation.max_sp_length, setupRsp->QOSCapsStation.acbe_uapsd, \
+         setupRsp->QOSCapsStation.acbk_uapsd, setupRsp->QOSCapsStation.acvi_uapsd, \
+         setupRsp->QOSCapsStation.acvo_uapsd, setupRsp->QOSCapsStation.more_data_ack, \
+         setupRsp->QOSCapsStation.qack));
+    }
+    
+    if(setupRsp->ExtSuppRates.present)
+    {
+        setupPeer->ExtRatesPresent = 1;
+        ConvertExtSuppRates( pMac, &setupPeer->extendedRates,
+                                                &setupRsp->ExtSuppRates );
+    }
+    /* update HT caps */
+    if(setupRsp->HTCaps.present)
+    {
+        palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerHTCaps, 
+                    &setupRsp->HTCaps, sizeof(tDot11fIEHTCaps)) ;
+    }
+
+    /* update EXT caps */
+    if(setupRsp->ExtCap.present)
+    {
+        palCopyMemory(pMac->hHdd, &setupPeer->tdlsPeerExtCaps, 
+                    &setupRsp->ExtCap, sizeof(tDot11fIEExtCap)) ;
+    }
+
+    return ;
+}
+#endif
+/*
+ * update HASH node entry info
+ */
+static void limTdlsUpdateHashNodeInfo(tpAniSirGlobal pMac, tDphHashNode *pStaDs,
+              tLimTdlsLinkSetupPeer *setupPeerInfo, tpPESession psessionEntry)
+{
+    //tDot11fIEHTCaps *htCaps = &setupPeerInfo->tdlsPeerHTCaps ;
+    tDot11fIEHTCaps htCap, *htCaps;
+    tpDphHashNode pSessStaDs = NULL;
+    tANI_U16 aid;
+
+    //HACK- to get the session's htcaps.
+    PopulateDot11fHTCaps(pMac, psessionEntry, &htCap);
+    htCaps = &htCap;
+    if(htCaps->present)
+    {
+        pStaDs->mlmStaContext.htCapability = 1 ;
+        pStaDs->htGreenfield = htCaps->greenField ;
+        pStaDs->htSupportedChannelWidthSet =  htCaps->supportedChannelWidthSet ;
+        pStaDs->htMIMOPSState =             htCaps->mimoPowerSave ;
+        pStaDs->htMaxAmsduLength =  htCaps->maximalAMSDUsize;
+        pStaDs->htAMpduDensity =    htCaps->mpduDensity;
+        pStaDs->htDsssCckRate40MHzSupport = htCaps->dsssCckMode40MHz ;
+        pStaDs->htShortGI20Mhz = htCaps->shortGI20MHz;
+        pStaDs->htShortGI40Mhz = htCaps->shortGI40MHz;
+        pStaDs->htMaxRxAMpduFactor = htCaps->maxRxAMPDUFactor;
+        limFillRxHighestSupportedRate(pMac, 
+                             &pStaDs->supportedRates.rxHighestDataRate, 
+                                                 htCaps->supportedMCSSet);
+        pStaDs->baPolicyFlag = 0xFF;
+
+        pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_N ;
+    }
+    else
+    {
+        pStaDs->mlmStaContext.htCapability = 0 ;
+        pMac->lim.gLimTdlsLinkMode = TDLS_LINK_MODE_BG ;
+    }
+    
+    pSessStaDs = dphLookupHashEntry(pMac, psessionEntry->bssId, &aid, 
+                                          &psessionEntry->dph.dphHashTable) ;
+
+    /* Lets enable QOS parameter */
+    pStaDs->qosMode    = 1;
+    pStaDs->wmeEnabled = 1;
+    pStaDs->lleEnabled = 0;
+    pStaDs->qos.capability.qosInfo = pSessStaDs->qos.capability.qosInfo; //setupPeerInfo->qosCaps.qosInfo;
+
+    /* populate matching rate set */
+#if 0
+#ifdef WLAN_FEATURE_11AC
+    limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates,
+                          &setupPeerInfo->extendedRates, 
+                     (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet,
+                            &pStaDs->mlmStaContext.propRateSet, psessionEntry, NULL);
+#else
+    limPopulateMatchingRateSet(pMac, pStaDs, &setupPeerInfo->supportedRates,
+                          &setupPeerInfo->extendedRates, 
+                     (tANI_U8 *)setupPeerInfo->tdlsPeerHTCaps.supportedMCSSet,
+                            &pStaDs->mlmStaContext.propRateSet, psessionEntry);
+#endif
+#else
+    palCopyMemory( pMac->hHdd, &pStaDs->supportedRates, &pSessStaDs->supportedRates, sizeof(pStaDs->supportedRates));
+#endif
+
+    pStaDs->mlmStaContext.capabilityInfo = pSessStaDs->mlmStaContext.capabilityInfo;// setupPeerInfo->capabilityInfo;
+
+    return ; 
+}
+
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * find Peer in setup link list.
+ */
+ 
+tANI_U8 limTdlsFindLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac, 
+                                            tLimTdlsLinkSetupPeer  **setupPeer)
+{
+    tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
+    tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
+    tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ; 
+
+    while (linkSetupList != NULL)
+    {
+        if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac, 
+                        (tANI_U8 *) linkSetupList->peerMac, 
+                                                 sizeof(tSirMacAddr)) )
+        {
+            checkNode = TDLS_NODE_FOUND ;
+            *setupPeer = linkSetupList ;
+            break ;
+        }
+        linkSetupList = linkSetupList->next;
+    }
+
+    return ((TDLS_NODE_FOUND ==  checkNode) ? eSIR_SUCCESS : eSIR_FAILURE ) ;
+}
+
+/*
+ * find peer in Discovery list.
+ * Dicovery list get populated in two instances, a) Recieved responses in reply
+ * to discovery request b) If discover request is received from TDLS peer STA
+ */
+tSirTdlsPeerInfo *limTdlsFindDisPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
+{
+    tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
+    tSirTdlsPeerInfo *peerInfo = NULL ;
+
+    while (discoveryList != NULL)
+    {
+        peerInfo = &discoveryList->tdlsDisPeerInfo ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+         ("Peer in discovery list = %02x, %02x, %02x, %02x, %02x, %02x \n"),
+                 peerInfo->peerMac[0], 
+                 peerInfo->peerMac[1], 
+                 peerInfo->peerMac[2], 
+                 peerInfo->peerMac[3], 
+                 peerInfo->peerMac[4], 
+                 peerInfo->peerMac[5]) ;
+
+        if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac,
+                       (tANI_U8 *) &peerInfo->peerMac, sizeof(tSirMacAddr)) )
+        {
+            break ;
+        }
+        discoveryList = discoveryList->next;
+    }
+
+    return peerInfo ;
+}
+
+/*
+ * find peer in Discovery list by looking into peer state.
+ * Dicovery list get populated in two instances, a) Recieved responses in reply
+ * to discovery request b) If discover request is received from TDLS peer STA
+ */
+static tSirTdlsPeerInfo *limTdlsFindDisPeerByState(tpAniSirGlobal pMac, 
+                                                                tANI_U8 state)
+{
+    tLimDisResultList *discoveryList = pMac->lim.gLimTdlsDisResultList ;
+    tSirTdlsPeerInfo *peerInfo = NULL ;
+
+    while (discoveryList != NULL)
+    {
+        peerInfo = &discoveryList->tdlsDisPeerInfo ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                     ("peerInfo Mac = %02x, %02x, %02x, %02x, %02x, %02x "),
+                                 peerInfo->peerMac[0], 
+                                 peerInfo->peerMac[1], 
+                                 peerInfo->peerMac[2], 
+                                 peerInfo->peerMac[3], 
+                                 peerInfo->peerMac[4], 
+                                 peerInfo->peerMac[5]) ;
+
+        if (peerInfo->tdlsPeerState == state)
+        {
+            break ;
+        }
+        discoveryList = discoveryList->next;
+    }
+
+    return peerInfo ;
+}
+
+/*
+ * find peer in Setup list by looking into peer state.
+ * setup list get populated in two instances, a) Recieved responses in reply
+ * to setup request b) If discover request is received from TDLS peer STA
+ */
+static tANI_U8 limTdlsFindSetupPeerByState(tpAniSirGlobal pMac, tANI_U8 state, 
+                                              tLimTdlsLinkSetupPeer **setupPeer)
+{    
+
+    tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
+    tLimTdlsLinkSetupPeer *linkSetupList = setupInfo->tdlsLinkSetupList ;
+    tANI_U8 checkNode = TDLS_NODE_NOT_FOUND ; 
+
+    while (linkSetupList != NULL)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                 ("peer state = %02x\n"), (linkSetupList)->tdls_link_state) ;
+        if((linkSetupList)->tdls_link_state == state) 
+        {
+            checkNode = TDLS_NODE_FOUND ;
+            *setupPeer = linkSetupList ;
+            break ;
+        }
+        linkSetupList = (linkSetupList)->next;
+    }
+
+    return ((TDLS_NODE_FOUND == checkNode) ? eSIR_SUCCESS: eSIR_FAILURE) ;
+}
+
+
+/*
+ * delete Peer from Setup Link
+ */
+void limTdlsDelLinkPeer(tpAniSirGlobal pMac, tSirMacAddr peerMac)
+{
+    tLimTdlsLinkSetupInfo *setupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
+    tLimTdlsLinkSetupPeer **linkSetupList = &setupInfo->tdlsLinkSetupList ;
+    tLimTdlsLinkSetupPeer *currentNode = NULL ;
+    tLimTdlsLinkSetupPeer *prevNode = NULL ;
+
+    for(currentNode = *linkSetupList ; currentNode != NULL ;
+                    prevNode = currentNode, currentNode = currentNode->next)
+    {
+        if (palEqualMemory( pMac->hHdd,(tANI_U8 *) peerMac, 
+                        (tANI_U8 *) currentNode->peerMac, 
+                                                 sizeof(tSirMacAddr)) )
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                    ("Del Node for Peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                                    currentNode->peerMac[0], 
+                                    currentNode->peerMac[1], 
+                                    currentNode->peerMac[2], 
+                                    currentNode->peerMac[3], 
+                                    currentNode->peerMac[4], 
+                                    currentNode->peerMac[5]) ;
+            /* if it's first Node */
+            if(NULL == prevNode)
+            {
+                *linkSetupList = currentNode->next ;
+            }
+            else
+            {
+                prevNode->next = currentNode->next ;
+            }
+            palFreeMemory(pMac, currentNode) ;
+            return ;
+        }
+    }
+        
+    return ;
+}
+   
+
+
+/*
+ * TDLS discovery request frame received from TDLS peer STA..
+ */
+static tSirRetStatus limProcessTdlsDisReqFrame(tpAniSirGlobal pMac, 
+                                    tANI_U8 *pBody, tANI_U32 frmLen )
+{
+    tDot11fTDLSDisReq tdlsDisReq = {{0}} ;
+    tANI_U32 status = 0 ;
+    tLimDisResultList *tdlsDisResult = NULL ; 
+    tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
+    tSirMacAddr peerMac = {0} ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tSirTdlsPeerInfo *peerInfo = NULL ;
+    tpPESession psessionEntry = NULL ;
+    tANI_U8 sessionId = 0 ;
+
+    status = dot11fUnpackTDLSDisReq(pMac, pBody, frmLen, &tdlsDisReq) ;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_WARN, 
+            ("TDLS dis request dialog = %d\n"), tdlsDisReq.DialogToken.token);
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS discovery Request frame (0x%08x," "%d bytes):\n"),
+                   status, frmLen );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+    }
+
+    /*
+     * find session entry using BSSID in link identifier, not using MAC
+     * header beacuse, there is cases in TDLS, there may be BSSID will not
+     * be present in header
+     */
+    psessionEntry = peFindSessionByBssid(pMac, 
+                         &tdlsDisReq.LinkIdentifier.bssid[0], &sessionId) ;
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
+        ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
+        tdlsDisReq.LinkIdentifier.bssid[0],    
+        tdlsDisReq.LinkIdentifier.bssid[1],    
+        tdlsDisReq.LinkIdentifier.bssid[2],    
+        tdlsDisReq.LinkIdentifier.bssid[3],    
+        tdlsDisReq.LinkIdentifier.bssid[4],    
+        tdlsDisReq.LinkIdentifier.bssid[5]) ;
+
+        //VOS_ASSERT(0) ;
+        return eSIR_FAILURE;
+    }
+ 
+    /* varify BSSID */
+    status = palEqualMemory(pMac->hHdd, &psessionEntry->bssId[0],
+                    &tdlsDisReq.LinkIdentifier.bssid[0], sizeof(tSirMacAddr)) ;
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+            ("lim BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"), 
+                                             psessionEntry->bssId[0], 
+                                             psessionEntry->bssId[1], 
+                                             psessionEntry->bssId[2], 
+                                             psessionEntry->bssId[3], 
+                                             psessionEntry->bssId[4], 
+                                             psessionEntry->bssId[5]) ;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+            ("Dis req from BSSID %02x, %02x, %02x, %02x, %02x, %02x\n"), 
+                   tdlsDisReq.LinkIdentifier.bssid[0], 
+                   tdlsDisReq.LinkIdentifier.bssid[1], 
+                   tdlsDisReq.LinkIdentifier.bssid[2], 
+                   tdlsDisReq.LinkIdentifier.bssid[3], 
+                   tdlsDisReq.LinkIdentifier.bssid[4], 
+                   tdlsDisReq.LinkIdentifier.bssid[5]
+          ) ;
+    if(!status)
+    {
+        limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ;
+
+        return eSIR_FAILURE ; 
+    }
+
+    /*
+     * check if this is echo of our transmitted discovery request
+     * drop it here, TODO: better to drop this in TL.
+     */    
+    status = palEqualMemory(pMac->hHdd, psessionEntry->selfMacAddr, 
+                    &tdlsDisReq.LinkIdentifier.InitStaAddr[0],
+                                                     sizeof(tSirMacAddr)) ;
+    if(status)
+    {
+        limLog( pMac, LOGE, FL("Echo of our TDLS discovery request frame\n")) ;
+        return eSIR_FAILURE ; 
+    }
+
+    /*
+     * while processing Discovery request from Peer,
+     * STA_MAC--> MAC of TDLS discovery initiator
+     * STA_PEER_MAC--> MAC of TDLS discovery responder.
+     */
+    palCopyMemory(pMac->hHdd, peerMac,  
+                        &tdlsDisReq.LinkIdentifier.InitStaAddr[0], 
+                                                     sizeof(tSirMacAddr)) ;
+    /* TODO, do more validation */
+    
+    /* see if discovery is already in progress */
+    peerInfo = limTdlsFindDisPeer(pMac, peerMac) ;
+
+    if(NULL == peerInfo)
+    {    
+        /*
+         * we are allocating peer info for individual peers found in TDLS
+         * discovery, we need to keep adding TDLS peers till we have timed
+         * out. We are freeing this memory at the time we are sending this
+         * collected peer info to SME.
+         */
+        status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult, 
+                                           sizeof(tLimDisResultList)) ; 
+    
+        if(status != eHAL_STATUS_SUCCESS)
+        {
+            limLog(pMac, LOGP, FL("alloc fail for TDLS discovery \
+                                                    reponse info\n")) ;
+            return eSIR_FAILURE ;
+        }
+
+ 
+        peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
+        peerInfo->tdlsPeerState = TDLS_DIS_REQ_PROCESS_STATE ;
+        peerInfo->dialog = tdlsDisReq.DialogToken.token ;
+
+        peerInfo->sessionId = psessionEntry->peSessionId;
+        
+        /* Populate peer info of tdls discovery result */
+        status = palCopyMemory(pMac->hHdd, peerInfo->peerMac, peerMac, 
+                                                 sizeof(tSirMacAddr)) ;
+
+         /*
+         * Now, as per D13, there will not be any Supp rates, ext Supp rates
+         * info in Discovery request frames, so we are populating this info
+         * locally to pass it to ADD STA.
+         */
+        do
+        {
+            tDot11fIESuppRates suppRates = {0} ;
+            tDot11fIEExtSuppRates extSuppRates = {0} ;
+            tANI_U16 caps = 0 ;
+            tDot11fFfCapabilities capsInfo = {0} ;
+            tDot11fIEHTCaps HTCaps = {0} ;
+            /* populate supported rate IE */
+            PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, 
+                                                  &suppRates, psessionEntry );
+            ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates, 
+                                                            &suppRates);
+            /* Populate extended supported rates */
+            PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
+                                &extSuppRates, psessionEntry );
+
+            peerInfo->ExtRatesPresent = 1;
+            ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates, 
+                                                          &extSuppRates);
+ 
+            if(cfgGetCapabilityInfo(pMac, &caps, psessionEntry) != eSIR_SUCCESS)
+            {
+                /*
+                 * Could not get Capabilities value
+                 * from CFG. Log error.
+                 */
+                 limLog(pMac, LOGP,
+                   FL("could not retrieve Capabilities value\n"));
+            }
+            swapBitField16(caps, ( tANI_U16* )&capsInfo );
+            /* update Caps Info */
+            tdlsUpdateCapInfo(&peerInfo->capabilityInfo , &capsInfo) ;
+
+            PopulateDot11fHTCaps( pMac, psessionEntry, &HTCaps );
+            limTdlsCovertHTCaps(pMac, peerInfo, &HTCaps) ;
+
+        } while (0) ;
+    
+        /* now add this new found discovery node into tdls discovery list */
+        tdlsDisResult->next = *disResultList ;
+        *disResultList = tdlsDisResult ;
+        pMac->lim.gLimTdlsDisStaCount++ ; 
+
+        /* See if for this peer already entry in setup Link */ 
+        limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
+
+        /* 
+         * if there is no entry for this peer in setup list, we need to 
+         * do add sta for this peer to transmit discovery rsp.
+         */ 
+        if(NULL == setupPeer)
+        {
+            /* To start with, send add STA request to HAL */
+            pMac->lim.gLimAddStaTdls = true ;
+            peerInfo->delStaNeeded = true ;
+
+            if(eSIR_FAILURE == limTdlsDisAddSta(pMac, peerMac, 
+                                                     peerInfo, psessionEntry))
+            {
+                VOS_ASSERT(0) ;
+                limLog(pMac, LOGE, "Add STA for dis response is failed \n") ;
+                return eSIR_FAILURE ;
+            }
+        } /* use setup link sta ID for discovery rsp */
+        else
+        {
+            peerInfo->delStaNeeded = false ;
+            limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
+            peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
+        }
+
+    }
+    else
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                    ("discovery procedure in progress for this peer\n")) ;
+    } 
+
+    return eSIR_SUCCESS ;
+}
+
+/* Process TDLS setup Request Frame */
+
+static tSirRetStatus limProcessTdlsSetupReqFrame(tpAniSirGlobal pMac, 
+                                         tANI_U8 *pBody, tANI_U32 frmLen)
+{
+
+    tDot11fTDLSSetupReq tdlsSetupReq = {{0}} ;
+    tANI_U32 status = 0 ;
+    tpPESession psessionEntry = NULL ;
+    tANI_U8 sessionId = 0 ;
+    tANI_U8 currentState = TDLS_LINK_SETUP_WAIT_STATE ;
+    tANI_U8 previousState = TDLS_LINK_IDLE_STATE ;
+    /* create node for Link setup */
+    tLimTdlsLinkSetupInfo *linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tLimTdlsLinkSetupPeer *tmpSetupPeer = NULL ;
+
+    status = dot11fUnpackTDLSSetupReq(pMac, pBody, frmLen, &tdlsSetupReq) ;
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS setup Request frame (0x%08x," "%d bytes):\n"),
+                   status, pBody );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+    }
+    /*
+     * find session entry using BSSID in link identifier, not using MAC
+     * header beacuse, there is cases in TDLS, there may be BSSID will not
+     * be present in header
+     */
+    psessionEntry = peFindSessionByBssid(pMac, 
+                         &tdlsSetupReq.LinkIdentifier.bssid[0], &sessionId) ;
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
+        ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
+        tdlsSetupReq.LinkIdentifier.bssid[0],    
+        tdlsSetupReq.LinkIdentifier.bssid[1],    
+        tdlsSetupReq.LinkIdentifier.bssid[2],    
+        tdlsSetupReq.LinkIdentifier.bssid[3],    
+        tdlsSetupReq.LinkIdentifier.bssid[4],    
+        tdlsSetupReq.LinkIdentifier.bssid[5]) ;
+
+        //VOS_ASSERT(0) ;
+        return eSIR_FAILURE ;
+    }
+    /* TODO: we don;t need this check now, varify BSSID */
+    status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, 
+                    &tdlsSetupReq.LinkIdentifier.bssid[0], 
+                                                     sizeof(tSirMacAddr)) ;
+     
+    if(!status)
+    {
+        limLog( pMac, LOGE, FL("TDLS setup request frame from other BSS -> something wrong. Check RXP filter\n")) ;
+
+        limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token , psessionEntry,
+                                            TDLS_SETUP_STATUS_FAILURE, NULL, 0 ) ;
+        return eSIR_FAILURE ; 
+    }
+
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_RSP_TIMEOUT_TO_SETUP_REQ) 
+    {
+        /* simply ignore this setup request packet */
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: ignore TDLS Setup Req packet\n"));
+        return eSIR_SUCCESS ;
+    }
+    if(pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+        ("TDLS negative running: send TDLS Setup Req to peer TDLS Setup Req\n"));
+        /* format TDLS discovery request frame and transmit it */
+        limSendTdlsLinkSetupReqFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, tdlsSetupReq.DialogToken.token, psessionEntry,
+            NULL, 0) ;
+    }    
+#endif
+    /* TODO, do more validation */
+    
+    if(!limTdlsFindLinkPeer(pMac, 
+                  &tdlsSetupReq.LinkIdentifier.InitStaAddr[0],
+                                                  &tmpSetupPeer))
+    {
+        tANI_U32 tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                        ("Link is already setup with this peer\n" )) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                        ("state = %d\n"), tmpSetupPeer->tdls_link_state) ;
+        //return eSIR_FAILURE ; 
+
+        if(tmpSetupPeer == NULL)
+        {
+            VOS_ASSERT(0) ;
+            return eSIR_FAILURE ; 
+            
+        }
+        switch(tmpSetupPeer->tdls_link_state)
+        {
+
+            case TDLS_LINK_SETUP_START_STATE:
+            {
+                v_SINT_t macCompare = 0 ;
+                macCompare= vos_mem_compare2(tmpSetupPeer->peerMac, 
+                           psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
+                VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                        ("MAC comparison Rslt = %d\n"), macCompare ) ;
+                if(0 > macCompare)
+                {
+                    /* 
+                     * Delete our Setup Request/Peer info and honour Peer 
+                     * Setup Request, go ahead and respond for this 
+                     */
+                    /* Deactivate the timer */
+                    tx_timer_deactivate(&tmpSetupPeer->gLimTdlsLinkSetupRspTimeoutTimer) ;
+#ifdef FEATURE_WLAN_TDLS_NEGATIVE
+                    if((pMac->lim.gLimTdlsNegativeBehavior & LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ) 
+                        != LIM_TDLS_NEGATIVE_SEND_REQ_TO_SETUP_REQ)
+#endif
+                    limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, 
+                            tmpSetupPeer->peerMac, eWNI_SME_TDLS_LINK_START_RSP);
+
+                    limTdlsDelLinkPeer(pMac, tmpSetupPeer->peerMac) ;
+                    tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
+                }
+                else if(0 < macCompare)
+                {
+                    /* 
+                     * Go ahead with current setup as peer is going to 
+                     * respond for setup request 
+                     */
+                    tdlsStateStatus = TDLS_LINK_SETUP_START_STATE ;
+                }
+                else
+                {
+                    /* same MAC, not possible */
+                    VOS_ASSERT(0) ;
+                }
+            
+                break ;
+            }
+#if 1
+            case TDLS_LINK_SETUP_DONE_STATE:
+            {
+                tpDphHashNode pStaDs = NULL ;
+
+                previousState = TDLS_LINK_SETUP_WAIT_STATE ;
+                currentState = TDLS_LINK_TEARDOWN_START_STATE ;
+                VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                        ("link Setup Done state "  )) ;
+                tmpSetupPeer->tdls_prev_link_state =  previousState ;
+                tmpSetupPeer->tdls_link_state = currentState ;
+                setupPeer = tmpSetupPeer ;
+#if 0                
+                /* Send Teardown to this Peer and Initiate new TDLS Setup */
+                limSendTdlsTeardownFrame(pMac, 
+                      &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], 
+                        eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry) ;
+#else
+                
+                /* tdls_hklee: send message to HAL before it is deleted, cause  */
+                limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
+
+                /* send del STA to remove context for this TDLS STA */
+                pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
+
+                /* now send indication to SME-->HDD->TL to remove STA from TL */
+
+                if(pStaDs)
+                {
+                    limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
+                                                           pStaDs, eSIR_SUCCESS) ;
+
+                    /* send Teardown Ind to SME */
+                    limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
+                                                  eWNI_SME_TDLS_TEARDOWN_IND) ;
+                    /* remove node from setup list */
+                    limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
+                }
+#endif
+                //setupPeer->tdls_prev_link_state = TDLS_LINK_SETUP_RESTART_STATE;
+                tdlsStateStatus = TDLS_LINK_IDLE_STATE ;
+                break ;
+
+            }
+            default:
+            {
+                VOS_ASSERT(0) ;
+                VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                        ("link Setup is Recieved in unknown state\n" )) ;
+                break ;
+            }
+#endif
+        }
+        if(tdlsStateStatus == TDLS_LINK_SETUP_START_STATE) 
+            return eSIR_FAILURE ;
+    }
+
+    if(currentState != TDLS_LINK_TEARDOWN_START_STATE)
+    {  
+        /* 
+         * Now we are sure to send discovery response frame to TDLS discovery 
+         * initiator, we don't care, if this request is unicast ro broadcast,
+         * we simply, send discovery response frame on direct link.
+         */
+        if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
+                      (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer )))
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                                 ( "Unable to allocate memory during ADD_STA\n" ));
+            return eSIR_MEM_ALLOC_FAILED;
+        }
+
+        setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
+        //setupPeer->tdls_prev_link_state =  setupPeer->tdls_link_state ;
+        //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
+        setupPeer->tdls_prev_link_state =  previousState ;
+        setupPeer->tdls_link_state = currentState ;
+        /* TDLS_sessionize: remember sessionId for future */
+        setupPeer->tdls_sessionId = psessionEntry->peSessionId;
+        setupPeer->tdls_bIsResponder = 0;
+
+        palCopyMemory(pMac->hHdd, setupPeer->peerMac,  
+                     &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                   ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"),
+                                    setupPeer->peerMac[0],  
+                                    setupPeer->peerMac[1],  
+                                    setupPeer->peerMac[2],  
+                                    setupPeer->peerMac[3],  
+                                    setupPeer->peerMac[4],  
+                                    setupPeer->peerMac[5] ) ;
+ 
+        limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
+        pMac->lim.gLimAddStaTdls = true ;
+
+        /* To start with, send add STA request to HAL */
+        if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, setupPeer->peerMac, 
+                                                  setupPeer, psessionEntry))
+        {
+            VOS_ASSERT(0) ;
+            palFreeMemory(pMac->hHdd, (void **) &setupPeer) ;
+            return eSIR_FAILURE ;
+        }
+
+        limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr,
+                                  tdlsSetupReq.DialogToken.token , psessionEntry, 
+                                  TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
+
+        limStartTdlsTimer(pMac, psessionEntry->peSessionId, 
+                                  &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
+                               (tANI_U32)setupPeer->peerMac,
+                                 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
+                                   SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
+
+        /* update setup peer list */
+        setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
+        linkSetupInfo->tdlsLinkSetupList = setupPeer ;
+    }
+    else
+    {
+        setupPeer->dialog = tdlsSetupReq.DialogToken.token ;
+        //setupPeer->tdls_prev_link_state =  setupPeer->tdls_link_state ;
+        //setupPeer->tdls_link_state = TDLS_LINK_SETUP_WAIT_STATE ;
+        setupPeer->tdls_prev_link_state =  previousState ;
+        setupPeer->tdls_link_state = currentState ;
+        /* TDLS_sessionize: remember sessionId for future */
+        setupPeer->tdls_sessionId = psessionEntry->peSessionId;
+        setupPeer->tdls_bIsResponder = 0;
+
+        palCopyMemory(pMac->hHdd, setupPeer->peerMac,  
+                     &tdlsSetupReq.LinkIdentifier.InitStaAddr[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                   ("Setup REQ MAC = %02x,%02x, %02x, %02x, %02x, %02x\n"),
+                                    setupPeer->peerMac[0],  
+                                    setupPeer->peerMac[1],  
+                                    setupPeer->peerMac[2],  
+                                    setupPeer->peerMac[3],  
+                                    setupPeer->peerMac[4],  
+                                    setupPeer->peerMac[5] ) ;
+ 
+        limTdlsUpdateLinkReqPeerInfo(pMac, setupPeer, &tdlsSetupReq) ;
+        limSendTdlsSetupRspFrame(pMac, tdlsSetupReq.LinkIdentifier.InitStaAddr, 
+                                 tdlsSetupReq.DialogToken.token , psessionEntry, 
+                                 TDLS_SETUP_STATUS_SUCCESS, NULL, 0) ;
+
+        limStartTdlsTimer(pMac, psessionEntry->peSessionId, 
+                                  &setupPeer->gLimTdlsLinkSetupCnfTimeoutTimer,
+                               (tANI_U32)setupPeer->peerMac,
+                                 WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT,
+                                   SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT) ;
+    }
+ 
+   
+    return eSIR_SUCCESS ;
+
+}
+
+/*
+ * TDLS discovery request frame received from TDLS peer STA..
+ */
+static tSirRetStatus limProcessTdlsSetupRspFrame(tpAniSirGlobal pMac, 
+                                            tANI_U8 *pBody, tANI_U32 frmLen )
+{
+    tDot11fTDLSSetupRsp tdlsSetupRsp = {{0}} ;
+    tANI_U32 status = 0 ;
+    tSirMacAddr peerMac = {0} ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tpPESession psessionEntry = NULL ;
+    tANI_U8 sessionId = 0 ;
+
+    status = dot11fUnpackTDLSSetupRsp(pMac, pBody, frmLen, &tdlsSetupRsp) ;
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse TDLS discovery Request \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS discovery Request frame (0x%08x," "%d bytes):\n"),
+                   status, frmLen );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+    }
+
+    /*
+     * find session entry using BSSID in link identifier, not using MAC
+     * header beacuse, there is cases in TDLS, there may be BSSID will not
+     * be present in header
+     */
+    psessionEntry = peFindSessionByBssid(pMac, 
+                         &tdlsSetupRsp.LinkIdentifier.bssid[0], &sessionId) ;
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
+        ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
+        tdlsSetupRsp.LinkIdentifier.bssid[0],    
+        tdlsSetupRsp.LinkIdentifier.bssid[1],    
+        tdlsSetupRsp.LinkIdentifier.bssid[2],    
+        tdlsSetupRsp.LinkIdentifier.bssid[3],    
+        tdlsSetupRsp.LinkIdentifier.bssid[4],    
+        tdlsSetupRsp.LinkIdentifier.bssid[5]) ;
+
+        //VOS_ASSERT(0) ;
+        return eSIR_FAILURE;
+    }
+  
+    /* varify BSSID */
+    status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, 
+                    &tdlsSetupRsp.LinkIdentifier.bssid[0], 
+                                                  sizeof(tSirMacAddr)) ;
+     
+    if(!status)
+    {
+        limLog( pMac, LOGE, FL("TDLS discovery request frame from other BSS -> something wrong. Check RXP filter\n")) ;
+
+        VOS_ASSERT(0) ;
+        return eSIR_FAILURE ; 
+    }
+    palCopyMemory(pMac->hHdd, peerMac,  
+                      &tdlsSetupRsp.LinkIdentifier.RespStaAddr[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+             ("TDLS setup RSP peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                                peerMac[0], 
+                                peerMac[1], 
+                                peerMac[2], 
+                                peerMac[3], 
+                                peerMac[4], 
+                                peerMac[5]) ; 
+    limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
+
+    if(NULL == setupPeer)
+    {
+        limLog( pMac, LOGE, FL(" unknown setup Response frame \
+                                                        other BSS\n")) ;
+        return eSIR_FAILURE ;
+    }
+                                                
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                      ("deactivating Setup RSP timer\n")) ;
+
+    /* Deactivate the timer */
+    tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupRspTimeoutTimer) ;
+
+    /*
+     * TDLS Setup RSP is recieved with Failure, Delete this STA entry
+     * don't respond with TDLS CNF frame.
+     */
+    if(TDLS_SETUP_STATUS_SUCCESS != tdlsSetupRsp.Status.status)
+    {
+        limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                    ("setup RSP with Failure Code\n")) ;
+        return eSIR_FAILURE ;
+    }    
+    
+    /* update Link Info */
+    limTdlsUpdateLinkRspPeerInfo(pMac, setupPeer, &tdlsSetupRsp) ;
+ 
+    /* TODO, do more validation */
+    
+
+    /* 
+     * Now we are sure to send link setup CNF  frame to TDLS link setup 
+     * reponded, now we will create dph hash entry and send add STA to HAL
+     */
+
+    pMac->lim.gLimAddStaTdls = true ;
+    if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, peerMac,  
+                                                 setupPeer, psessionEntry))
+    {
+       /* through error */
+       VOS_ASSERT(0) ;
+       return eSIR_FAILURE ;
+    } 
+    /* TDLS_HKLEE_FIXME: now we add some delay for AddSta_Rsp comes */
+    
+         
+    /* send TDLS confim frame to TDLS Peer STA */           
+    limSendTdlsLinkSetupCnfFrame(pMac, peerMac, tdlsSetupRsp.DialogToken.token, psessionEntry, NULL, 0) ;
+
+    /* 
+     * set the tdls_link_state to TDLS_LINK_SETUP_RSP_WAIT_STATE, and
+     * wait for Setup CNF transmission on air, once we receive tx complete
+     * message, we will change the peer state and send message to SME 
+     * callback..
+     */
+    (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
+    (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_RSP_WAIT_STATE ;
+
+    return eSIR_SUCCESS ;
+}
+/*
+ * TDLS setup CNF  frame processing ..
+ */
+
+static tSirRetStatus limProcessTdlsSetupCnfFrame(tpAniSirGlobal pMac, 
+                                            tANI_U8 *pBody, tANI_U32 frmLen)
+{
+    tDot11fTDLSSetupCnf tdlsSetupCnf = {{0}} ;
+    tANI_U32 status = 0 ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tpPESession psessionEntry = NULL ;
+    tANI_U8 sessionId = 0 ;
+
+    status = dot11fUnpackTDLSSetupCnf(pMac, pBody, frmLen, &tdlsSetupCnf) ;
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
+                   status, frmLen );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+    }
+    /*
+     * find session entry using BSSID in link identifier, not using MAC
+     * header beacuse, there is cases in TDLS, there may be BSSID will not
+     * be present in header
+     */
+    psessionEntry = peFindSessionByBssid(pMac, 
+                         &tdlsSetupCnf.LinkIdentifier.bssid[0], &sessionId) ;
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
+        ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
+        tdlsSetupCnf.LinkIdentifier.bssid[0],    
+        tdlsSetupCnf.LinkIdentifier.bssid[1],    
+        tdlsSetupCnf.LinkIdentifier.bssid[2],    
+        tdlsSetupCnf.LinkIdentifier.bssid[3],    
+        tdlsSetupCnf.LinkIdentifier.bssid[4],    
+        tdlsSetupCnf.LinkIdentifier.bssid[5]) ;
+
+        //VOS_ASSERT(0) ;
+        return eSIR_FAILURE;
+    }
+ 
+    /* varify BSSID */
+    status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, 
+                    &tdlsSetupCnf.LinkIdentifier.bssid[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+    if(!status)
+    {
+        limLog( pMac, LOGE, FL("TDLS setup CNF frame other BSS -> something wrong. Check RXP filter\n")) ;
+
+        VOS_ASSERT(0) ;
+        return eSIR_FAILURE ; 
+    }
+    /* TODO, do more validation */
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+               ("setup Cnf peer MAc = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[1],
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[2], 
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[3],  
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[4],  
+                      tdlsSetupCnf.LinkIdentifier.InitStaAddr[5]
+                      ) ;
+    
+    limTdlsFindLinkPeer(pMac, 
+                   &tdlsSetupCnf.LinkIdentifier.InitStaAddr[0],
+                            &setupPeer) ;
+
+    if(NULL == setupPeer)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                          (" unknown setup CNF frame\n")) ;
+        VOS_ASSERT(0) ;
+        return eSIR_FAILURE ;
+    }
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                   ("setup CNF peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"), 
+                            (setupPeer)->peerMac[0], 
+                            (setupPeer)->peerMac[1], 
+                            (setupPeer)->peerMac[2], 
+                            (setupPeer)->peerMac[3], 
+                            (setupPeer)->peerMac[4], 
+                            (setupPeer)->peerMac[5]) ; 
+    /*T match dialog token, before proceeding further */
+    if((setupPeer)->dialog != tdlsSetupCnf.DialogToken.token)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                          ("setup CNF frame not matching with setup RSP\n")) ;
+        VOS_ASSERT(0) ;
+        return eSIR_FAILURE ;
+    }
+
+    /* 
+     * Now we are sure that, this set CNF is for us, now stop 
+     * the running timer..
+     */
+    tx_timer_deactivate(&(setupPeer)->gLimTdlsLinkSetupCnfTimeoutTimer) ;
+
+    /* change TDLS peer State */
+    (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
+    (setupPeer)->tdls_link_state = TDLS_LINK_SETUP_DONE_STATE ; 
+
+    /* send indication to SME that, new link is setup */
+    limSendSmeTdlsLinkSetupInd(pMac, (setupPeer)->peerMac, eSIR_SUCCESS) ;
+
+    /* tdls_hklee: prepare PTI template and send it to HAL */
+    limTdlsLinkEstablish(pMac, (setupPeer)->peerMac);
+
+    return eSIR_SUCCESS ; 
+
+}
+
+/*
+ * TDLS discovery response frame processing ..
+ */
+
+static tSirRetStatus limProcessTdlsDisRspFrame(tpAniSirGlobal pMac, 
+                              tANI_U8 *pBody, tANI_U32 frmLen, 
+                                 tANI_S8 rssi, tpPESession psessionEntry)
+{
+    tDot11fTDLSDisRsp tdlsDisRsp = {{0}} ;
+    tANI_U32 status = 0 ;
+    tLimDisResultList *tdlsDisResult = NULL ; 
+    tLimDisResultList **disResultList = &pMac->lim.gLimTdlsDisResultList ;
+    tSirTdlsDisReq *prevDisReq = &pMac->lim.gLimTdlsDisReq ;
+
+    status = dot11fUnpackTDLSDisRsp(pMac, pBody, frmLen, &tdlsDisRsp) ;
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
+                   status, frmLen );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pFrame, nFrame);)
+    }
+    /*TODO:  match dialog token, before proceeding further */
+
+    /* varify BSSID */
+    status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, 
+                    &tdlsDisRsp.LinkIdentifier.bssid[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+    if(!status)
+    {
+        limLog( pMac, LOGW, FL(" TDLS discovery Response frame other BSS\n")) ;
+        return eSIR_FAILURE ; 
+    }
+    /* TODO, do more validation */
+  
+    if(tdlsDisRsp.DialogToken.token != prevDisReq->dialog)
+    {
+        limLog( pMac, LOGW, FL(" wrong TDLS discovery Response frame\n")) ;
+        return eSIR_FAILURE ;
+    } 
+
+    pMac->lim.gLimTdlsDisStaCount++ ;
+
+    /*
+     * we are allocating peer info for individual peers found in TDLS
+     * discovery, we need to keep adding TDLS peers till we have timed
+     * out. We are freeing this memory at the time we are sending this
+     * collected peer info to SME.
+     */
+    status = palAllocateMemory(pMac->hHdd, (void **)&tdlsDisResult, 
+                                               sizeof(tLimDisResultList)) ; 
+    
+    if(status != eHAL_STATUS_SUCCESS)
+    {
+        limLog(pMac, LOGP, FL("alloc fail for TDLS discovery reponse info\n")) ;
+        return eSIR_FAILURE ;
+    }
+
+    do
+    {
+        tSirTdlsPeerInfo *peerInfo = &tdlsDisResult->tdlsDisPeerInfo ;
+
+        /* Populate peer info of tdls discovery result */
+        peerInfo->sessionId = psessionEntry->peSessionId;
+        /*
+         * When we receive DIS RSP from peer MAC, 
+         * STA_MAC_OFFSET will carry peer MAC address and PEER MAC OFFSET
+         * will carry our MAC.
+         */
+        status = palCopyMemory(pMac->hHdd, peerInfo->peerMac, 
+                    &tdlsDisRsp.LinkIdentifier.RespStaAddr[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+        /* update RSSI for this TDLS peer STA */
+        peerInfo->tdlsPeerRssi = rssi ;
+
+        /* update Caps Info */
+        tdlsUpdateCapInfo(&peerInfo->capabilityInfo , 
+                                          &tdlsDisRsp.Capabilities) ;
+
+        /* update Supp rates */
+        if(tdlsDisRsp.SuppRates.present)
+        { 
+            ConvertSuppRates( pMac, &peerInfo->tdlsPeerSuppRates, 
+                                             &tdlsDisRsp.SuppRates );
+        }
+
+        /* update EXT supp rates */
+        if(tdlsDisRsp.ExtSuppRates.present) 
+        {
+            peerInfo->ExtRatesPresent = 1;
+            ConvertExtSuppRates( pMac, &peerInfo->tdlsPeerExtRates, 
+                                                    &tdlsDisRsp.ExtSuppRates );
+        }
+        /* update HT caps */
+        if (tdlsDisRsp.HTCaps.present)
+        {
+            palCopyMemory( pMac, &peerInfo->tdlsPeerHtCaps, &tdlsDisRsp.HTCaps, 
+                                               sizeof( tDot11fIEHTCaps ) );
+        }
+        /* update EXT caps */
+        if (tdlsDisRsp.ExtCap.present)
+        {
+            //palCopyMemory( pMac, &peerInfo->tdlsPeerExtenCaps, 
+             //                &tdlsDisRsp.ExtCap, 
+              //                          sizeof( tDot11fIEExtCap ) );
+        }
+    } while(0) ;
+
+    /* now add this new found discovery node into tdls discovery list */
+    tdlsDisResult->next = *disResultList ;
+    *disResultList = tdlsDisResult ; 
+
+    return eSIR_SUCCESS ; 
+}
+
+/* 
+ * Process TDLS Teardown request frame from TDLS peer STA
+ */
+static tSirRetStatus limProcessTdlsTeardownFrame(tpAniSirGlobal pMac, 
+                                      tANI_U8 *pBody, tANI_U32 frmLen )
+{
+    tDot11fTDLSTeardown tdlsTeardown = {{0}} ;
+    tANI_U32 status = 0 ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tpPESession psessionEntry = NULL ;
+    tANI_U8 sessionId = 0 ;
+
+    status = dot11fUnpackTDLSTeardown(pMac, pBody, frmLen, &tdlsTeardown) ;
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog(pMac, LOGE, FL("Failed to parse an TDLS discovery Response \
+                              frame (0x%08x, %d bytes):\n"),status, frmLen);
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while unpacking an\
+                      TDLS discovery Response frame (0x%08x," "%d bytes):\n"),
+                   status, frmLen );
+        PELOG2(sirDumpBuf(pMac, SIR_DBG_MODULE_ID, LOG2, pBody, frmLen);)
+    }
+
+    /*
+     * find session entry using BSSID in link identifier, not using MAC
+     * header beacuse, there is cases in TDLS, there may be BSSID will not
+     * be present in header
+     */
+    psessionEntry = peFindSessionByBssid(pMac, 
+                         &tdlsTeardown.LinkIdentifier.bssid[0], &sessionId) ;
+    if(NULL == psessionEntry)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, \
+        ("no Seesion entry for TDLS session (bssid %02x:%02x:%02x:%02x:%02x:%02x)\n"), \
+        tdlsTeardown.LinkIdentifier.bssid[0],    
+        tdlsTeardown.LinkIdentifier.bssid[1],    
+        tdlsTeardown.LinkIdentifier.bssid[2],    
+        tdlsTeardown.LinkIdentifier.bssid[3],    
+        tdlsTeardown.LinkIdentifier.bssid[4],    
+        tdlsTeardown.LinkIdentifier.bssid[5]) ;
+
+        //VOS_ASSERT(0) ;
+        return eSIR_FAILURE;
+    }
+ 
+    /* varify BSSID */
+    status = palEqualMemory(pMac->hHdd, psessionEntry->bssId, 
+                                  &tdlsTeardown.LinkIdentifier.bssid[0], 
+                                                     sizeof(tSirMacAddr)) ;
+
+
+    if(!status)
+    {
+        limLog( pMac, LOGE, FL("Teardown from other BSS -> something wrong. Check RXP filter\n")) ;
+        VOS_ASSERT(0) ;
+        return eSIR_FAILURE ; 
+    }
+    
+    limTdlsFindLinkPeer(pMac, 
+                     &tdlsTeardown.LinkIdentifier.InitStaAddr[0],
+                                            &setupPeer) ;
+
+    if(NULL == setupPeer)
+    {
+        //ignore
+        //VOS_ASSERT(0) ;
+        limLog( pMac, LOGE, FL("Teardown from unknown peer. --> ignored\n") );
+        
+        return eSIR_FAILURE ;
+    }
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                     ("teardown for peer %02x,%02x,%02x,%02x,%02x,%02x\n"), 
+                          (setupPeer)->peerMac[0],            
+                          (setupPeer)->peerMac[1],            
+                          (setupPeer)->peerMac[2],            
+                          (setupPeer)->peerMac[3],            
+                          (setupPeer)->peerMac[4],            
+                          (setupPeer)->peerMac[5]) ;            
+
+    switch(tdlsTeardown.Reason.code)
+    {
+        case eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON:
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                 ("teardown with unspecified reason\n")) ;
+            break ;
+        }
+        case eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE:
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                       (" Teardown from AP, TDLS peer unreachable\n")) ;
+            break ;
+        }
+        default:
+        {
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                            (" unknown teardown\n")) ;
+            break ;
+        }
+    }
+
+    /* change TDLS peer State */
+    (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
+    (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ; 
+
+    do
+    {
+        tpDphHashNode pStaDs = NULL ;
+
+        /* tdls_hklee: send message to HAL before it is deleted, cause  */
+        limTdlsLinkTeardown(pMac, (setupPeer)->peerMac) ;
+
+        /* send del STA to remove context for this TDLS STA */
+        pStaDs = limTdlsDelSta(pMac, (setupPeer)->peerMac, psessionEntry) ;
+
+        /* now send indication to SME-->HDD->TL to remove STA from TL */
+
+        if(pStaDs)
+        {
+            limSendSmeTdlsDelPeerInd(pMac, psessionEntry->smeSessionId,
+                                                   pStaDs, eSIR_SUCCESS) ;
+      
+            /* send Teardown Ind to SME */
+            limSendSmeTdlsTeardownRsp(pMac, eSIR_SUCCESS, (setupPeer)->peerMac,
+                                          eWNI_SME_TDLS_TEARDOWN_IND) ;
+            /* remove node from setup list */
+            limTdlsDelLinkPeer(pMac, (setupPeer)->peerMac) ;
+        }
+
+    }while(0) ;
+    
+    return status ;
+}
+
+/*
+ * Common processing of TDLS action frames recieved 
+ */
+void limProcessTdlsFrame(tpAniSirGlobal pMac, tANI_U32 *pBd)
+{
+    tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd);
+    tANI_U8 pOffset = ((0 == WDA_GET_RX_FT_DONE(pBd)) 
+                         ? (( sizeof( eth_890d_header ))) :(0)) ;
+
+    tANI_U8 category   = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[0] ; 
+    tANI_U8 action     =   (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE)[1] ; 
+    tANI_U32 frameLen  = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
+    tANI_U8 *tdlsFrameBody = (pBody + pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
+    //tANI_S8 rssi = (tANI_S8)SIR_MAC_BD_TO_RSSI_DB(pBd);
+
+    if(category != SIR_MAC_ACTION_TDLS)
+    {
+        limLog( pMac, LOGE, FL("Invalid TDLS action frame=(%d). Ignored\n"), category );
+        return ; 
+    }
+
+    frameLen -= (pOffset + PAYLOAD_TYPE_TDLS_SIZE) ;
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("Received TDLS action %d (%s)"), \
+        action, limTraceTdlsActionString(action) ));
+
+    switch(action)
+    {
+
+        case SIR_MAC_TDLS_SETUP_REQ:
+        {
+            limProcessTdlsSetupReqFrame(pMac, tdlsFrameBody, frameLen) ;
+            break ;
+        }
+        case SIR_MAC_TDLS_SETUP_RSP:
+        {
+            limProcessTdlsSetupRspFrame(pMac, tdlsFrameBody, frameLen) ;
+            break ;
+        }
+        case SIR_MAC_TDLS_SETUP_CNF:
+        {
+            limProcessTdlsSetupCnfFrame(pMac, tdlsFrameBody, frameLen) ; 
+            break ;
+        }
+        case SIR_MAC_TDLS_TEARDOWN: 
+        {
+            limProcessTdlsTeardownFrame(pMac, tdlsFrameBody, frameLen) ; 
+            break ;
+        }
+        case SIR_MAC_TDLS_DIS_REQ:
+        {
+            limProcessTdlsDisReqFrame(pMac, tdlsFrameBody, frameLen) ;
+            break ;
+        }
+        case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
+        case SIR_MAC_TDLS_CH_SWITCH_REQ:      
+        case SIR_MAC_TDLS_CH_SWITCH_RSP:    
+        case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
+        default:
+        {
+            break ;
+        }
+    }
+    
+    return ;    
+}
+
+/*
+ * ADD sta for dis response fame sent on direct link
+ */
+static tSirRetStatus limTdlsDisAddSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, 
+                          tSirTdlsPeerInfo *peerInfo, tpPESession psessionEntry)
+{
+    tpDphHashNode pStaDs = NULL ;
+    tSirRetStatus status = eSIR_SUCCESS ;
+    tANI_U16 aid = 0 ;
+
+    if(NULL == peerInfo)
+    {
+        VOS_ASSERT(0) ;
+        return status ;
+
+    } 
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+               ("ADD STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"), 
+                                             peerMac[0],
+                                             peerMac[1],
+                                             peerMac[2],
+                                             peerMac[3],
+                                             peerMac[4],
+                                             peerMac[5]) ;
+
+
+    if(NULL != dphLookupHashEntry(pMac, peerMac, 
+                                  &aid, &psessionEntry->dph.dphHashTable))
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    (" there is hash entry for this client\n")) ;
+        status = eSIR_FAILURE ;
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+
+    aid = limAssignAID(pMac) ;
+
+    pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
+
+    if (pStaDs)
+    {
+        (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
+        limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
+    }
+    pStaDs = dphAddHashEntry(pMac, peerMac, aid, 
+                                         &psessionEntry->dph.dphHashTable) ;
+
+    if(NULL == pStaDs)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    (" add hash entry failed\n")) ;
+        status = eSIR_FAILURE ;
+        VOS_ASSERT(0) ;
+        return status;
+    }
+    if(eSIR_SUCCESS == status)
+    {
+#ifdef TDLS_RATE_DEBUG
+        tSirMacRateSet *suppRates = &peerInfo->tdlsPeerSuppRates ;
+        tSirMacRateSet *extRates = &peerInfo->tdlsPeerExtRates ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                                  ("pSta DS [%p] \n"), pStaDs) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                   ("peerInfo->tdlsPeerSuppRates = [%p]\n"), 
+                        (tANI_U8 *)&peerInfo->tdlsPeerSuppRates) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+               ("peerInfo->tdlsPeerExtRates = [%p]\n"), 
+                        (tANI_U8 *)&peerInfo->tdlsPeerExtRates) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+              ("peerInfo->tdlsPeerPropRates = [%p]\n"), 
+                        (tANI_U8 *)&pStaDs->mlmStaContext.propRateSet) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+              ("peerInfo->mcs = [%p]\n"), 
+                        (tANI_U8 *)peerInfo->supportedMCSSet) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                  ("num of supp rates = %02x\n"), suppRates->numRates) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                      ("num of ext rates = %01x\n"), extRates->numRates) ;
+#endif
+
+        /* Populate matching rate set */
+#ifdef WLAN_FEATURE_11AC
+        if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs, 
+                                    &peerInfo->tdlsPeerSuppRates,
+                                      &peerInfo->tdlsPeerExtRates, 
+                                        peerInfo->supportedMCSSet,
+                                         &pStaDs->mlmStaContext.propRateSet, 
+                                                              psessionEntry, NULL))
+#else
+        if(eSIR_FAILURE == limPopulateMatchingRateSet(pMac, pStaDs, 
+                                    &peerInfo->tdlsPeerSuppRates,
+                                      &peerInfo->tdlsPeerExtRates, 
+                                        peerInfo->supportedMCSSet,
+                                         &pStaDs->mlmStaContext.propRateSet, 
+                                                              psessionEntry))
+#endif
+        {
+            VOS_ASSERT(0) ;
+        }
+
+
+        pStaDs->mlmStaContext.capabilityInfo = peerInfo->capabilityInfo;
+        palCopyMemory(pMac->hHdd, pStaDs->staAddr, peerMac, 
+                                                   sizeof(tSirMacAddr)) ; 
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
+                ("Add STA for Peer: %02x, %02x, %02x, %02x, %02x, %02x\n"), 
+                             pStaDs->staAddr[0],
+                             pStaDs->staAddr[1],
+                             pStaDs->staAddr[2],
+                             pStaDs->staAddr[3],
+                             pStaDs->staAddr[4],
+                             pStaDs->staAddr[5]) ;
+    
+
+        pStaDs->staType = STA_ENTRY_TDLS_PEER ;
+
+        status = limAddSta(pMac, pStaDs, psessionEntry);
+
+        if(eSIR_SUCCESS != status)
+        {
+            /* should not fail */
+            VOS_ASSERT(0) ;
+        }
+    }
+  
+    return status ;
+}
+#endif
+/*
+ * Add STA for TDLS setup procedure 
+ */ 
+static tSirRetStatus limTdlsSetupAddSta(tpAniSirGlobal pMac, 
+                        tSirMacAddr peerMac, tLimTdlsLinkSetupPeer *setupPeer,
+                                            tpPESession psessionEntry)
+{
+    tpDphHashNode pStaDs = NULL ;
+    tSirRetStatus status = eSIR_SUCCESS ;
+    tANI_U16 aid = 0 ;
+
+    if(NULL != dphLookupHashEntry(pMac, peerMac, &aid, 
+                                      &psessionEntry->dph.dphHashTable))
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    (" there is hash entry for this client\n")) ;
+        status = eSIR_FAILURE ;
+        /* TDLS_TODO: I have seen this VOS ASSERT happened. must handle this (called from limProcessTdlsSetupReqFrame) */
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+    aid = limAssignAID(pMac) ;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+          ("Aid = %d, for peer = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                     aid, peerMac[0],peerMac[1],peerMac[2],
+                              peerMac[3],peerMac[4],peerMac[5]) ;
+    pStaDs = dphGetHashEntry(pMac, aid, &psessionEntry->dph.dphHashTable);
+
+    if (pStaDs)
+    {
+        (void) limDelSta(pMac, pStaDs, false /*asynchronous*/, psessionEntry);
+        limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry);
+    }
+
+    pStaDs = dphAddHashEntry(pMac, peerMac, aid, 
+                                          &psessionEntry->dph.dphHashTable) ;
+
+    if(NULL == pStaDs)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    (" add hash entry failed\n")) ;
+        status = eSIR_FAILURE ;
+        VOS_ASSERT(0) ;
+    }
+  
+    limTdlsUpdateHashNodeInfo(pMac, pStaDs, setupPeer, psessionEntry) ; 
+
+    pStaDs->staType = STA_ENTRY_TDLS_PEER ;
+
+    status = limAddSta(pMac, pStaDs, psessionEntry);
+
+    if(eSIR_SUCCESS != status)
+    {
+        /* should not fail */
+        VOS_ASSERT(0) ;
+    }  
+    return status ;
+}
+
+/*
+ * Del STA, after Link is teardown or discovery response sent on direct link
+ */
+static tpDphHashNode limTdlsDelSta(tpAniSirGlobal pMac, tSirMacAddr peerMac, 
+                                                    tpPESession psessionEntry)
+{
+    tSirRetStatus status = eSIR_SUCCESS ;
+    tANI_U16 aid = 0 ;
+    tpDphHashNode pStaDs = NULL ;
+ 
+    pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, 
+                                         &psessionEntry->dph.dphHashTable) ;
+
+    if(pStaDs)
+    {
+    
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+             ("DEL STA peer MAC: %02x, %02x, %02x, %02x, %02x, %02x \n"),
+                                   pStaDs->staAddr[0],
+                                   pStaDs->staAddr[1],
+                                   pStaDs->staAddr[2],
+                                   pStaDs->staAddr[3],
+                                   pStaDs->staAddr[4],
+                                   pStaDs->staAddr[5]
+                                    ) ;
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+                   ("STA type = %x, sta idx = %x\n"),pStaDs->staType, 
+                                                           pStaDs->staIndex) ;
+ 
+        status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
+        if(eSIR_SUCCESS == status)
+        {
+            limDeleteDphHashEntry(pMac, pStaDs->staAddr, aid, psessionEntry) ;
+            limReleaseAID(pMac, aid) ;
+        }
+        else
+        {
+            VOS_ASSERT(0) ;
+        }
+    }
+           
+    return pStaDs ;
+}
+     
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/* 
+* Prepare link establish message for HAL, construct PTI template.
+*
+*/   
+static tSirRetStatus limTdlsLinkEstablish(tpAniSirGlobal pMac, tSirMacAddr peerMac)
+{
+    tANI_U8             pFrame[64] ;
+    tDot11fTDLSPeerTrafficInd tdlsPtiTemplate ;
+    tANI_U32            status = 0 ;
+    tANI_U32            nPayload = 0 ;
+    tANI_U32            nBytes = 0 ;
+    tANI_U32            header_offset = 0 ;
+    tANI_U16            aid = 0 ;
+    tDphHashNode        *pStaDs = NULL ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tpPESession psessionEntry = NULL ;
+
+
+    limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
+    if(NULL == setupPeer) {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+            ("limTdlsLinkEstablish: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \
+        peerMac[0], peerMac[1], peerMac[2], \
+        peerMac[3], peerMac[4], peerMac[5]);
+        return eSIR_FAILURE;
+    }
+
+    psessionEntry = peFindSessionBySessionId(pMac, 
+                         setupPeer->tdls_sessionId) ;
+
+    if(NULL == psessionEntry) 
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+             ("limTdlsLinkEstablish: sessionID %d is not found\n"), setupPeer->tdls_sessionId);
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+
+    /* */
+    pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable) ;
+    if(pStaDs == NULL) {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+            ("limTdlsLinkEstablish: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \
+            peerMac[0], peerMac[1], peerMac[2], \
+            peerMac[3], peerMac[4], peerMac[5]);
+        return eSIR_FAILURE;
+    }
+
+    palZeroMemory( pMac->hHdd, ( tANI_U8* )&tdlsPtiTemplate, 
+               sizeof( tDot11fTDLSPeerTrafficInd ) );
+
+    /*
+    * setup Fixed fields,
+    */
+    tdlsPtiTemplate.Category.category = SIR_MAC_ACTION_TDLS;
+    tdlsPtiTemplate.Action.action     = SIR_MAC_TDLS_PEER_TRAFFIC_IND;
+    tdlsPtiTemplate.DialogToken.token = 0 ; /* filled by firmware at the time of transmission */
+#if 1 
+    /* CHECK_PTI_LINK_IDENTIFIER_INITIATOR_ADDRESS: initator address should be TDLS link setup's initiator address, 
+    then below code makes such an way */
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
+        peerMac, !setupPeer->tdls_bIsResponder) ;
+#else
+   /* below code will make PTI's linkIdentifier's initiator address be selfAddr */
+    PopulateDot11fLinkIden( pMac, psessionEntry, &tdlsPtiTemplate.LinkIdentifier,
+        peerMac, TDLS_INITIATOR) ;
+#endif
+
+    /* PUBufferStatus will be filled by firmware at the time of transmission */
+    tdlsPtiTemplate.PUBufferStatus.present = 1;
+
+    /* TODO: get ExtendedCapabilities IE */
+
+    /* 
+    * now we pack it.  First, how much space are we going to need?
+    */
+    status = dot11fGetPackedTDLSPeerTrafficIndSize ( pMac, &tdlsPtiTemplate, &nPayload);
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGP, FL("Failed to calculate the packed size for a PTI template (0x%08x).\n"), status );
+        /* We'll fall back on the worst case scenario: */
+        nPayload = sizeof( tdlsPtiTemplate );
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while calculating the packed size for a PTI template (0x%08x).\n"), status );
+    }
+
+    /*
+    * This frame is going out from PE as data frames with special ethertype
+    * 89-0d.
+    * 8 bytes of RFC 1042 header
+    */ 
+
+    nBytes = nPayload + sizeof( tSirMacMgmtHdr ) 
+            + sizeof( eth_890d_header ) 
+            + PAYLOAD_TYPE_TDLS_SIZE ;
+
+    if(nBytes > 64) {
+        limLog( pMac, LOGE, FL("required memory for PTI frame is %ld, but reserved only 64.\n"), nBytes);
+        nBytes = 64;
+    }
+    /* zero out the memory */
+    palZeroMemory( pMac->hHdd, pFrame, sizeof(pFrame) );
+
+    /* fill out the buffer descriptor */
+
+    header_offset = limPrepareTdlsFrameHeader(pMac, pFrame, 
+        LINK_IDEN_ADDR_OFFSET(tdlsPtiTemplate), TDLS_LINK_AP, !setupPeer->tdls_bIsResponder, psessionEntry) ;
+
+    status = dot11fPackTDLSPeerTrafficInd ( pMac, &tdlsPtiTemplate, pFrame 
+        + header_offset, nPayload, &nPayload );
+
+    if ( DOT11F_FAILED( status ) )
+    {
+        limLog( pMac, LOGE, FL("Failed to pack a PTI template \
+                            (0x%08x).\n"), status );
+        return eSIR_FAILURE;
+    }
+    else if ( DOT11F_WARNED( status ) )
+    {
+        limLog( pMac, LOGW, FL("There were warnings while packing TDLS"
+            "Peer Traffic Indication (0x%08x).\n") );
+    }
+
+    LIM_LOG_TDLS(VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, ("bIsResponder=%d, header_offset=%ld, linkIdenOffset=%d, ptiBufStatusOffset=%d \n"), \
+        setupPeer->tdls_bIsResponder, header_offset, PTI_LINK_IDEN_OFFSET, PTI_BUF_STATUS_OFFSET));
+
+    limSendTdlsLinkEstablish(pMac, setupPeer->tdls_bIsResponder, 
+        header_offset+PTI_LINK_IDEN_OFFSET, header_offset+PTI_BUF_STATUS_OFFSET, 
+      nBytes, pFrame, (tANI_U8 *)&setupPeer->tdlsPeerExtCaps);
+
+    return eSIR_SUCCESS;
+}
+
+/* 
+* Prepare link teardown message for HAL from peer_mac
+*
+*/   
+static tSirRetStatus limTdlsLinkTeardown(tpAniSirGlobal pMac, tSirMacAddr peerMac)
+{
+    tDphHashNode        *pStaDs = NULL ;
+    tANI_U16            aid = 0 ;
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+    tpPESession psessionEntry = NULL ;
+
+
+    limTdlsFindLinkPeer(pMac, peerMac, &setupPeer) ;
+    if(NULL == setupPeer) {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+            ("limTdlsLinkTeardown: cannot find peer mac in tdls linksetup list: %02X %02X %02X %02X %02X %02X\n"), \
+        peerMac[0], peerMac[1], peerMac[2], \
+        peerMac[3], peerMac[4], peerMac[5]);
+        return eSIR_FAILURE;
+    }
+
+    psessionEntry = peFindSessionBySessionId(pMac, 
+                         setupPeer->tdls_sessionId) ;
+
+    if(NULL == psessionEntry) 
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+             ("limTdlsLinkTeardown: sessionID %d is not found\n"), setupPeer->tdls_sessionId);
+        VOS_ASSERT(0) ;
+        return eHAL_STATUS_FAILURE;
+    }
+
+
+    /* */
+    pStaDs = dphLookupHashEntry(pMac, peerMac, &aid, &psessionEntry->dph.dphHashTable);
+
+    if(pStaDs == NULL) {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+            ("limTdlsLinkTeardown: cannot find peer mac in hash table: %02X %02X %02X %02X %02X %02X\n"), \
+            peerMac[0], peerMac[1], peerMac[2], \
+            peerMac[3], peerMac[4], peerMac[5]);
+        return eSIR_FAILURE;
+    }
+
+    limSendTdlsLinkTeardown(pMac, pStaDs->staIndex);
+
+    return eSIR_SUCCESS;
+}
+
+/* 
+ * Prepare Discovery RSP message for SME, collect peerINfo for all the 
+ * peers discovered and delete/clean discovery lists in PE.
+ */   
+ 
+static tSirTdlsDisRsp *tdlsPrepareTdlsDisRsp(tpAniSirGlobal pMac, 
+                                 tSirTdlsDisRsp *disRsp, tANI_U8 disStaCount) 
+{
+    tANI_U32 disMsgRspSize = sizeof(tSirTdlsDisRsp);
+    tANI_U8 status = eHAL_STATUS_SUCCESS ;
+
+    /*
+     * allocate memory for tdls discovery response, allocated memory should
+     * be alloc_mem = tdlsStaCount * sizeof(peerinfo) 
+     *                              + siezeof tSirTdlsDisRsp.
+     */
+    disMsgRspSize += (disStaCount * sizeof(tSirTdlsPeerInfo));
+        
+    /* now allocate memory */
+    status = palAllocateMemory( pMac->hHdd, (void **)&disRsp, disMsgRspSize ) ;
+ 
+    if(eHAL_STATUS_FAILURE == status)
+    {
+        limLog(pMac, LOGP, FL("palAllocateMemory failed for DIS RSP"));
+        return NULL ;
+    }
+        
+    if(disStaCount)
+    { 
+        tLimDisResultList *tdlsDisRspList = pMac->lim.gLimTdlsDisResultList ;
+        tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[0] ;
+            
+        tLimDisResultList *currentNode = tdlsDisRspList ;
+        while(tdlsDisRspList != NULL)
+        {
+
+            palCopyMemory( pMac->hHdd, (tANI_U8 *)peerInfo, 
+                          (tANI_U8 *) &tdlsDisRspList->tdlsDisPeerInfo, 
+                                                 sizeof(tSirTdlsPeerInfo));
+        
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO, 
+            ("Msg Sent to PE, peer MAC: %02x, %02x, %02x, %02x, %02x, %02x\n"), 
+                                  peerInfo->peerMac[0] ,
+                                  peerInfo->peerMac[1] ,
+                                  peerInfo->peerMac[2] ,
+                                  peerInfo->peerMac[3] ,
+                                  peerInfo->peerMac[4] ,
+                                  peerInfo->peerMac[5]) ;
+            disStaCount-- ;
+            peerInfo++ ;
+            currentNode = tdlsDisRspList ;
+            tdlsDisRspList = tdlsDisRspList->next ;
+            palFreeMemory(pMac->hHdd, currentNode) ;
+            /* boundary condition check, may be fatal */
+            if(((!disStaCount) && (tdlsDisRspList)) 
+                            || ((!tdlsDisRspList) && disStaCount))
+            {
+                limLog(pMac, LOG1, FL("mismatch in dis sta count and\
+                                        and number of nodes in list\n")) ;
+                VOS_ASSERT(0) ;
+                return NULL ;
+            } 
+        } /* end  of while */
+
+        /* All discovery STA processed */
+        pMac->lim.gLimTdlsDisResultList = NULL ;
+
+    } /* end of if dis STA count */
+    
+    return (disRsp) ;
+}
+
+/* Send Teardown response back to PE */
+
+void limSendSmeTdlsTeardownRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
+                                        tSirMacAddr peerMac, tANI_U16 msgType)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsTeardownRsp *teardownRspMsg = NULL ;
+    tANI_U8 status = eHAL_STATUS_SUCCESS ;
+    
+    mmhMsg.type = msgType ;
+
+    status = palAllocateMemory( pMac->hHdd, (void **)&teardownRspMsg, 
+                                        sizeof(tSirTdlsTeardownRsp)) ;
+
+    if(eHAL_STATUS_SUCCESS != status)
+    {
+        VOS_ASSERT(0) ;
+    } 
+    palCopyMemory( pMac->hHdd, teardownRspMsg->peerMac, (tANI_U8 *)peerMac, 
+                                                   sizeof(tSirMacAddr)) ;
+    teardownRspMsg->statusCode =  statusCode ;
+    mmhMsg.bodyptr = teardownRspMsg ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+    return ;
+
+}
+
+/*
+ * Send Link start RSP back to SME after link is setup or failed
+ */
+void limSendSmeTdlsLinkStartRsp(tpAniSirGlobal pMac,
+                                         tSirResultCodes statusCode,
+                                          tSirMacAddr peerMac, 
+                                                 tANI_U16 msgType)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsLinksetupRsp *setupRspMsg = NULL ;
+    tANI_U8 status = eHAL_STATUS_SUCCESS ;
+
+    mmhMsg.type = msgType ;
+
+    status = palAllocateMemory( pMac->hHdd, (void **)&setupRspMsg, 
+                                        sizeof(tSirTdlsLinksetupRsp)) ;
+
+    if(eHAL_STATUS_SUCCESS != status)
+    {
+        VOS_ASSERT(0) ;
+    } 
+
+    palCopyMemory( pMac->hHdd, setupRspMsg->peerMac, (tANI_U8 *)peerMac, 
+                                                   sizeof(tSirMacAddr)) ;
+    setupRspMsg->statusCode =  statusCode ;
+    mmhMsg.bodyptr = setupRspMsg ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+    return ;
+}
+
+/*
+ * Send TDLS discovery RSP back to SME 
+ */
+void limSendSmeTdlsDisRsp(tpAniSirGlobal pMac, tSirResultCodes statusCode,
+                                                          tANI_U16 msgType)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsDisRsp *tdlsDisRsp = NULL ;
+
+    mmhMsg.type = msgType ;
+
+    if(eSIR_SME_SUCCESS == statusCode)
+    {
+        tANI_U8 tdlsStaCount = pMac->lim.gLimTdlsDisStaCount ;
+
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    ("no of TDLS STA discovered: %d\n"), tdlsStaCount) ; 
+        tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, tdlsStaCount) ;
+
+        if(tdlsDisRsp)
+        {
+            tdlsDisRsp->numDisSta = tdlsStaCount ;
+        }
+        else
+        {
+            limLog(pMac, LOGP, FL("fatal failure for TDLS DIS RSP\n"));
+            VOS_ASSERT(0) ; 
+            return ;
+        }
+        /* all Discovery STA is processed */
+        pMac->lim.gLimTdlsDisStaCount = 0 ;
+    }
+    else
+    {
+        tdlsDisRsp = tdlsPrepareTdlsDisRsp(pMac, tdlsDisRsp, 0) ;
+    }
+
+    tdlsDisRsp->statusCode =  statusCode ;
+    mmhMsg.bodyptr = tdlsDisRsp ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+     return ;
+}
+
+/* 
+ * Once Link is setup with PEER, send Add STA ind to SME
+ */
+static eHalStatus limSendSmeTdlsAddPeerInd(tpAniSirGlobal pMac, 
+                   tANI_U8 sessionId, tDphHashNode   *pStaDs, tANI_U8 status)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsPeerInd *peerInd = NULL ;
+    mmhMsg.type = eWNI_SME_ADD_TDLS_PEER_IND ;
+    if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd,
+                                                (sizeof(tSirTdlsPeerInd))))
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
+        return eSIR_FAILURE;
+    }
+
+    palCopyMemory( pMac->hHdd, peerInd->peerMac, 
+                           (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
+    peerInd->sessionId = sessionId;
+    peerInd->staId = pStaDs->staIndex ;
+    peerInd->ucastSig = pStaDs->ucUcastSig ;
+    peerInd->bcastSig = pStaDs->ucBcastSig ;
+    peerInd->length = sizeof(tSmeIbssPeerInd) ;
+
+    mmhMsg.bodyptr = peerInd ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+    return eSIR_SUCCESS ;
+
+}
+
+/*
+ * Once link is teardown, send Del Peer Ind to SME
+ */
+static eHalStatus limSendSmeTdlsDelPeerInd(tpAniSirGlobal pMac, 
+                    tANI_U8 sessionId, tDphHashNode   *pStaDs, tANI_U8 status)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsPeerInd *peerInd = NULL ;
+    mmhMsg.type = eWNI_SME_DELETE_TDLS_PEER_IND ;
+    if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &peerInd,
+                                                (sizeof(tSirTdlsPeerInd))))
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
+        return eSIR_FAILURE;
+    }
+
+    palCopyMemory( pMac->hHdd, peerInd->peerMac, 
+                           (tANI_U8 *) pStaDs->staAddr, sizeof(tSirMacAddr));
+    peerInd->sessionId = sessionId;
+    peerInd->staId = pStaDs->staIndex ;
+    peerInd->ucastSig = pStaDs->ucUcastSig ;
+    peerInd->bcastSig = pStaDs->ucBcastSig ;
+    peerInd->length = sizeof(tSmeIbssPeerInd) ;
+
+    mmhMsg.bodyptr = peerInd ;
+
+    //peerInd->statusCode =  status ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+    return eSIR_SUCCESS ;
+
+}
+
+/*
+ * Send Link setup Ind to SME, This is the case where, link setup is 
+ * initiated by peer STA
+ */
+static eHalStatus limSendSmeTdlsLinkSetupInd(tpAniSirGlobal pMac, 
+                                   tSirMacAddr peerMac, tANI_U8 status)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsLinkSetupInd *setupInd = NULL ;
+
+    mmhMsg.type = eWNI_SME_TDLS_LINK_START_IND ;
+    if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &setupInd,
+                                            (sizeof(tSirTdlsLinkSetupInd))))
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
+        return eSIR_FAILURE;
+    }
+
+    palCopyMemory( pMac->hHdd, setupInd->peerMac, 
+                           (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
+    setupInd->length = sizeof(tSirTdlsLinkSetupInd);
+    setupInd->statusCode = status ;
+    mmhMsg.bodyptr = setupInd ;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+    return eSIR_SUCCESS ;
+
+}
+
+/*
+ * Setup RSP timer handler 
+ */
+void limTdlsLinkSetupRspTimerHandler(void *pMacGlobal, tANI_U32 timerId)
+{
+
+    tANI_U32         statusCode;
+    tSirMsgQ    msg;
+    tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
+
+    /* Prepare and post message to LIM Message Queue */
+
+    msg.type = SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT;
+    msg.bodyptr = NULL ;
+    msg.bodyval = timerId ;
+
+    if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
+        limLog(pMac, LOGE,
+               FL("posting message %X to LIM failed, reason=%d\n"),
+               msg.type, statusCode);
+    return ;
+}
+
+/*
+ * Link setup CNF timer
+ */
+void limTdlsLinkSetupCnfTimerHandler(void *pMacGlobal, tANI_U32 timerId)
+{
+
+    tANI_U32         statusCode;
+    tSirMsgQ    msg;
+    tpAniSirGlobal pMac = (tpAniSirGlobal)pMacGlobal;
+
+    // Prepare and post message to LIM Message Queue
+
+    msg.type = SIR_LIM_TDLS_LINK_SETUP_CNF_TIMEOUT;
+    msg.bodyptr = NULL ;
+    msg.bodyval = timerId ;
+
+    if ((statusCode = limPostMsgApi(pMac, &msg)) != eSIR_SUCCESS)
+        limLog(pMac, LOGE,
+               FL("posting message %X to LIM failed, reason=%d\n"),
+               msg.type, statusCode);
+    return ;
+}
+
+/*
+ * start TDLS timer
+ */
+void limStartTdlsTimer(tpAniSirGlobal pMac, tANI_U8 sessionId, TX_TIMER *timer,
+                        tANI_U32 timerId, tANI_U16 timerType, tANI_U32 timerMsg)
+{
+    tANI_U32 cfgValue = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
+                           ? WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT
+                            : WNI_CFG_TDLS_LINK_SETUP_CNF_TIMEOUT ;
+
+    void *timerFunc = (timerMsg == SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT)
+                                ? (limTdlsLinkSetupRspTimerHandler) 
+                                    : limTdlsLinkSetupCnfTimerHandler ;
+
+    /* TODO: Read timer vals from CFG */
+
+    cfgValue = SYS_MS_TO_TICKS(cfgValue);
+    /*
+     * create TDLS discovery response wait timer and activate it
+     */
+    if (tx_timer_create(timer, "TDLS link setup timers", timerFunc,
+                        timerId, cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS)
+    {
+        limLog(pMac, LOGP,
+           FL("could not create TDLS discovery response wait timer\n"));
+        return;
+    }
+
+    //assign appropriate sessionId to the timer object
+    timer->sessionId = sessionId; 
+    
+     MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
+                                             eLIM_TDLS_DISCOVERY_RSP_WAIT));
+    if (tx_timer_activate(timer) != TX_SUCCESS)
+    {
+        limLog(pMac, LOGP, FL("TDLS link setup timer activation failed!\n"));
+        return ;
+    }
+
+    return ;
+
+}
+#endif
+
+/* 
+ * Once Link is setup with PEER, send Add STA ind to SME
+ */
+static eHalStatus limSendSmeTdlsAddStaRsp(tpAniSirGlobal pMac, 
+                   tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode   *pStaDs,
+                   tANI_U8 status)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsAddStaRsp *addStaRsp = NULL ;
+    mmhMsg.type = eWNI_SME_TDLS_ADD_STA_RSP ;
+    if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &addStaRsp,
+                                                (sizeof(tSirTdlsAddStaRsp))))
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
+        return eSIR_FAILURE;
+    }
+
+    addStaRsp->sessionId = sessionId;
+    addStaRsp->statusCode = status;
+    if( pStaDs )
+    {
+        addStaRsp->staId = pStaDs->staIndex ;
+        addStaRsp->ucastSig = pStaDs->ucUcastSig ;
+        addStaRsp->bcastSig = pStaDs->ucBcastSig ;
+    }
+    if( peerMac )
+    {
+        palCopyMemory( pMac->hHdd, addStaRsp->peerMac, 
+                (tANI_U8 *) peerMac, sizeof(tSirMacAddr));
+    }
+    addStaRsp->length = sizeof(tSirTdlsAddStaRsp) ;
+    addStaRsp->messageType = eWNI_SME_TDLS_ADD_STA_RSP ;
+
+    mmhMsg.bodyptr = addStaRsp;
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+
+    return eSIR_SUCCESS ;
+
+}
+/* 
+ * STA RSP received from HAL
+ */
+eHalStatus limProcessTdlsAddStaRsp(tpAniSirGlobal pMac, void *msg, 
+                                                   tpPESession psessionEntry)
+{
+    tAddStaParams  *pAddStaParams = (tAddStaParams *) msg ;
+    tANI_U8        status = eSIR_SUCCESS ;
+    tDphHashNode   *pStaDs = NULL ;
+    tANI_U16        aid = 0 ;
+
+    SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+            ("ADD_STA_RSP received :staIdx=%d, staMac=%02x:%02x:%02x:%02x:%02x:%02x"), pAddStaParams->staIdx, \
+                            pAddStaParams->staMac[0], 
+                            pAddStaParams->staMac[1], 
+                            pAddStaParams->staMac[2], 
+                            pAddStaParams->staMac[3], 
+                            pAddStaParams->staMac[4], 
+                            pAddStaParams->staMac[5] ) ;
+
+    if (pAddStaParams->status != eHAL_STATUS_SUCCESS)
+    {
+        VOS_ASSERT(0) ;
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
+                                                   ("Add sta failed \n")) ;
+        status = eSIR_FAILURE;
+        goto add_sta_error;
+    }
+
+    pStaDs = dphLookupHashEntry(pMac, pAddStaParams->staMac, &aid, 
+                                         &psessionEntry->dph.dphHashTable);
+    if(NULL == pStaDs)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
+                                                   ("pStaDs is NULL \n")) ;
+        status = eSIR_FAILURE;
+        goto add_sta_error;
+    }
+
+    pStaDs->bssId                  = pAddStaParams->bssIdx;
+    pStaDs->staIndex               = pAddStaParams->staIdx;
+    pStaDs->ucUcastSig             = pAddStaParams->ucUcastSig;
+    pStaDs->ucBcastSig             = pAddStaParams->ucBcastSig;
+    pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
+    pStaDs->valid                  = 1 ;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL    
+    status = limSendSmeTdlsAddPeerInd(pMac, psessionEntry->smeSessionId, 
+                                                    pStaDs, eSIR_SUCCESS ) ;
+    if(eSIR_FAILURE == status)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
+                                         ("Peer IND msg to SME failed\n")) ;
+        palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
+        return eSIR_FAILURE ;
+    }
+
+    /* 
+     * Now, there is two things a) ADD STA RSP for ADD STA request sent
+     * after recieving discovery request from Peer.
+     * now we have to send discovery response, if there is any pending
+     * discovery equest..
+     */
+    do
+    {
+        tSirTdlsPeerInfo *peerInfo = limTdlsFindDisPeer(pMac,
+                                            pAddStaParams->staMac) ;
+
+    
+        if(peerInfo)
+        {
+            /* 
+             * send TDLS discovery response frame on direct link, state machine
+             * is rolling.., once discovery response is get Acked, we will 
+             * send response to SME based on TxComplete callback results
+             */ 
+            limSendTdlsDisRspFrame(pMac, peerInfo->peerMac, peerInfo->dialog, psessionEntry) ;
+            peerInfo->tdlsPeerState = TDLS_DIS_RSP_SENT_WAIT_STATE ;
+        }
+    } while(0) ;
+#else
+    status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId, 
+                                        pAddStaParams->staMac, pStaDs, status) ;
+    if(eSIR_FAILURE == status)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
+                                         ("Peer IND msg to SME failed\n")) ;
+        palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
+    }
+    return status;
+
+#endif
+add_sta_error:
+    status = limSendSmeTdlsAddStaRsp(pMac, psessionEntry->smeSessionId, 
+                                        pAddStaParams->staMac, NULL, status) ;
+    palFreeMemory( pMac->hHdd, (void *) pAddStaParams );
+    return status ;
+}
+
+/*
+ * FUNCTION: Populate Link Identifier element IE
+ *
+ */
+
+ 
+void PopulateDot11fLinkIden(tpAniSirGlobal pMac, tpPESession psessionEntry, 
+                                 tDot11fIELinkIdentifier *linkIden,
+                                       tSirMacAddr peerMac, tANI_U8 reqType)
+{
+    //tANI_U32 size = sizeof(tSirMacAddr) ;
+    tANI_U8 *initStaAddr = NULL ;
+    tANI_U8 *respStaAddr = NULL ;
+
+    (reqType == TDLS_INITIATOR) ? ((initStaAddr = linkIden->InitStaAddr),
+                                   (respStaAddr = linkIden->RespStaAddr))
+                                : ((respStaAddr = linkIden->InitStaAddr ),
+                                   (initStaAddr = linkIden->RespStaAddr)) ;
+    palCopyMemory( pMac->hHdd, (tANI_U8 *)linkIden->bssid, 
+                     (tANI_U8 *) psessionEntry->bssId, sizeof(tSirMacAddr)) ; 
+
+    palCopyMemory( pMac->hHdd, (tANI_U8 *)initStaAddr,
+                          psessionEntry->selfMacAddr, sizeof(tSirMacAddr)) ;
+
+    palCopyMemory( pMac->hHdd, (tANI_U8 *)respStaAddr, (tANI_U8 *) peerMac, 
+                                                       sizeof( tSirMacAddr ));
+
+    linkIden->present = 1 ;
+    return ;
+
+}
+
+void PopulateDot11fTdlsExtCapability(tpAniSirGlobal pMac, 
+                                        tDot11fIEExtCap *extCapability)
+{
+    extCapability->TDLSPeerPSMSupp = PEER_PSM_SUPPORT ;
+    extCapability->TDLSPeerUAPSDBufferSTA = PEER_BUFFER_STA_SUPPORT ;
+    extCapability->TDLSChannelSwitching = CH_SWITCH_SUPPORT ;
+    extCapability->TDLSSupport = TDLS_SUPPORT ;
+    extCapability->TDLSProhibited = TDLS_PROHIBITED ;
+    extCapability->TDLSChanSwitProhibited = TDLS_CH_SWITCH_PROHIBITED ;
+    extCapability->present = 1 ;
+    return ;
+}
+                                     
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * Public Action frame common processing
+ * This Function will be moved/merged to appropriate place
+ * once other public action frames (particularly 802.11k)
+ * is in place
+ */
+void limProcessTdlsPublicActionFrame(tpAniSirGlobal pMac, tANI_U32 *pBd, 
+                                                  tpPESession psessionEntry)
+{
+    tANI_U32 frameLen = WDA_GET_RX_PAYLOAD_LEN(pBd) ;
+    tANI_U8 *pBody = WDA_GET_RX_MPDU_DATA(pBd) ;
+    tANI_S8 rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pBd) ;
+
+    limProcessTdlsDisRspFrame(pMac, pBody, frameLen, rssi, psessionEntry) ;
+    return ; 
+}
+
+eHalStatus limTdlsPrepareSetupReqFrame(tpAniSirGlobal pMac, 
+                              tLimTdlsLinkSetupInfo *linkSetupInfo,
+                                 tANI_U8 dialog, tSirMacAddr peerMac,
+                                                 tpPESession psessionEntry)
+{
+    tLimTdlsLinkSetupPeer *setupPeer = NULL ;
+
+    /*
+    * we allocate the TDLS setup Peer Memory here, we will free'd this
+    * memory after teardown, if the link is successfully setup or
+    * free this memory if any timeout is happen in link setup procedure
+    */
+    if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
+                  (void **) &setupPeer, sizeof( tLimTdlsLinkSetupPeer )))
+    {
+        limLog( pMac, LOGP, 
+                  FL( "Unable to allocate memory during ADD_STA\n" ));
+         VOS_ASSERT(0) ;
+         return eSIR_MEM_ALLOC_FAILED;
+    }
+    setupPeer->dialog = dialog ;
+    setupPeer->tdls_prev_link_state =  setupPeer->tdls_link_state ;
+    setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
+
+    /* TDLS_sessionize: remember sessionId for future */
+    setupPeer->tdls_sessionId = psessionEntry->peSessionId;
+    setupPeer->tdls_bIsResponder = 1;
+
+    /* 
+    * we only populate peer MAC, so it can assit us to find the
+    * TDLS peer after response/or after response timeout
+    */
+    palCopyMemory(pMac->hHdd, setupPeer->peerMac, peerMac,
+                                              sizeof(tSirMacAddr)) ;
+    /* format TDLS discovery request frame and transmit it */
+    limSendTdlsLinkSetupReqFrame(pMac, peerMac, dialog, psessionEntry, NULL, 0) ;
+
+    limStartTdlsTimer(pMac, psessionEntry->peSessionId, 
+                        &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
+                            (tANI_U32)setupPeer->peerMac, 
+                               WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
+                                 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
+    /* update setup peer list */
+    setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
+    linkSetupInfo->tdlsLinkSetupList = setupPeer ;
+
+    /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to 
+     * SME later when TDLS setup cnf TX complete is successful. --> see 
+     * limTdlsSetupCnfTxComplete() 
+     */
+    return eSIR_SUCCESS ; 
+}
+#endif
+
+/*
+ * Process Send Mgmt Request from SME and transmit to AP.
+ */
+tSirRetStatus limProcessSmeTdlsMgmtSendReq(tpAniSirGlobal pMac, 
+                                                           tANI_U32 *pMsgBuf)
+{
+    /* get all discovery request parameters */
+    tSirTdlsSendMgmtReq *pSendMgmtReq = (tSirTdlsSendMgmtReq*) pMsgBuf ;
+    tpPESession psessionEntry;
+    tANI_U8      sessionId;
+    tSirResultCodes resultCode = eSIR_SME_INVALID_PARAMETERS;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
+            ("Send Mgmt Recieved\n")) ;
+
+    if((psessionEntry = peFindSessionByBssid(pMac, pSendMgmtReq->bssid, &sessionId)) 
+            == NULL)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                "PE Session does not exist for given sme sessionId %d\n", 
+                pSendMgmtReq->sessionId);
+        goto lim_tdls_send_mgmt_error;
+    }
+
+    /* check if we are in proper state to work as TDLS client */ 
+    if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                "send mgmt received in wrong system Role %d\n", 
+                psessionEntry->limSystemRole);
+        goto lim_tdls_send_mgmt_error;
+    }
+
+    /*
+     * if we are still good, go ahead and check if we are in proper state to
+     * do TDLS discovery req/rsp/....frames.
+     */
+    if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
+            (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
+    {
+
+        limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \
+                state (%d)\n", psessionEntry->limSmeState);
+        goto lim_tdls_send_mgmt_error;
+    }
+
+    switch( pSendMgmtReq->reqType )
+    {
+        case SIR_MAC_TDLS_DIS_REQ:
+            VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
+                    "Transmit Discovery Request Frame\n") ;
+            /* format TDLS discovery request frame and transmit it */
+            limSendTdlsDisReqFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, 
+                    psessionEntry) ;
+            resultCode = eSIR_SME_SUCCESS;
+            break;
+        case SIR_MAC_TDLS_DIS_RSP:
+            {
+                //Send a response mgmt action frame
+                limSendTdlsDisRspFrame(pMac, pSendMgmtReq->peerMac,
+                        pSendMgmtReq->dialog, psessionEntry) ;
+                resultCode = eSIR_SME_SUCCESS;
+            }
+            break;
+        case SIR_MAC_TDLS_SETUP_REQ:
+            {
+                limSendTdlsLinkSetupReqFrame(pMac,
+                        pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry,
+                        &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); 
+                resultCode = eSIR_SME_SUCCESS;
+            }
+            break;
+        case SIR_MAC_TDLS_SETUP_RSP:
+            {
+                limSendTdlsSetupRspFrame(pMac, 
+                        pSendMgmtReq->peerMac, pSendMgmtReq->dialog, psessionEntry, pSendMgmtReq->statusCode,
+                        &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));
+                resultCode = eSIR_SME_SUCCESS;
+            }
+            break;
+        case SIR_MAC_TDLS_SETUP_CNF:
+            {
+                limSendTdlsLinkSetupCnfFrame(pMac, pSendMgmtReq->peerMac, pSendMgmtReq->dialog, 
+                        psessionEntry, &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq)));  
+                resultCode = eSIR_SME_SUCCESS;
+            }
+            break;
+        case SIR_MAC_TDLS_TEARDOWN:
+            {
+                limSendTdlsTeardownFrame(pMac,
+                        pSendMgmtReq->peerMac, pSendMgmtReq->statusCode, psessionEntry,
+                        &pSendMgmtReq->addIe[0], (pSendMgmtReq->length - sizeof(tSirTdlsSendMgmtReq))); 
+                resultCode = eSIR_SME_SUCCESS;
+            }
+            break;
+        case SIR_MAC_TDLS_PEER_TRAFFIC_IND:
+            {
+            }
+            break;
+        case SIR_MAC_TDLS_CH_SWITCH_REQ:
+            {
+            }
+            break;
+        case SIR_MAC_TDLS_CH_SWITCH_RSP:
+            {
+            }
+            break;
+        case SIR_MAC_TDLS_PEER_TRAFFIC_RSP:
+            {
+            }
+            break;
+        default:
+            break;
+    }
+
+lim_tdls_send_mgmt_error:
+
+    limSendSmeRsp( pMac, eWNI_SME_TDLS_SEND_MGMT_RSP,
+            resultCode, pSendMgmtReq->sessionId, pSendMgmtReq->transactionId);
+
+    return eSIR_SUCCESS;
+}
+
+/*
+ * Once link is teardown, send Del Peer Ind to SME
+ */
+static eHalStatus limSendSmeTdlsDelStaRsp(tpAniSirGlobal pMac, 
+                    tANI_U8 sessionId, tSirMacAddr peerMac, tDphHashNode   *pStaDs,
+                    tANI_U8 status)
+{
+    tSirMsgQ  mmhMsg = {0} ;
+    tSirTdlsDelStaRsp *pDelSta = NULL ;
+    mmhMsg.type = eWNI_SME_TDLS_DEL_STA_RSP ;
+    if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,(void * *) &pDelSta,
+                (sizeof(tSirTdlsDelStaRsp))))
+    {
+        PELOGE(limLog(pMac, LOGE, FL("Failed to allocate memory"));)
+            return eSIR_FAILURE;
+    }
+
+    pDelSta->sessionId = sessionId;
+    pDelSta->statusCode =  status ;
+    if( pStaDs )
+    {
+        pDelSta->staId = pStaDs->staIndex ;
+    }
+    if( peerMac )
+    {
+        palCopyMemory(pMac->hHdd, pDelSta->peerMac, peerMac, sizeof(tSirMacAddr));
+    }
+
+    pDelSta->length = sizeof(tSirTdlsDelStaRsp) ;
+    pDelSta->messageType = eWNI_SME_TDLS_DEL_STA_RSP ;
+
+    mmhMsg.bodyptr = pDelSta;
+
+    mmhMsg.bodyval = 0;
+    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
+    return eSIR_SUCCESS ;
+
+}
+
+/*
+ * Process Send Mgmt Request from SME and transmit to AP.
+ */
+tSirRetStatus limProcessSmeTdlsAddStaReq(tpAniSirGlobal pMac, 
+                                                           tANI_U32 *pMsgBuf)
+{
+    /* get all discovery request parameters */
+    tSirTdlsAddStaReq *pAddStaReq = (tSirTdlsAddStaReq*) pMsgBuf ;
+    tpPESession psessionEntry;
+    tANI_U8      sessionId;
+    tLimTdlsLinkSetupPeer setupPeer = {0};
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
+                                  ("Send Mgmt Recieved\n")) ;
+
+    if((psessionEntry = peFindSessionByBssid(pMac, pAddStaReq->bssid, &sessionId)) 
+                                                                        == NULL)
+    {
+         VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                    "PE Session does not exist for given sme sessionId %d\n", 
+                                                            pAddStaReq->sessionId);
+         goto lim_tdls_add_sta_error;
+    }
+    
+    /* check if we are in proper state to work as TDLS client */ 
+    if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                         "send mgmt received in wrong system Role %d\n", 
+                                             psessionEntry->limSystemRole);
+        goto lim_tdls_add_sta_error;
+    }
+
+    /*
+     * if we are still good, go ahead and check if we are in proper state to
+     * do TDLS discovery req/rsp/....frames.
+     */
+     if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
+                (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
+     {
+     
+         limLog(pMac, LOGE, "send mgmt received in invalid LIMsme \
+                               state (%d)\n", psessionEntry->limSmeState);
+         goto lim_tdls_add_sta_error;
+     }
+
+     pMac->lim.gLimAddStaTdls = true ;
+
+     /* To start with, send add STA request to HAL */
+     if(eSIR_FAILURE == limTdlsSetupAddSta(pMac, pAddStaReq->peerMac, 
+                                               &setupPeer, psessionEntry))
+     {
+         VOS_ASSERT(0) ;
+         goto lim_tdls_add_sta_error;
+     }
+     return eSIR_SUCCESS;
+lim_tdls_add_sta_error:
+     limSendSmeTdlsAddStaRsp(pMac, 
+                   pAddStaReq->sessionId, pAddStaReq->peerMac, NULL, eSIR_FAILURE );
+
+   return eSIR_SUCCESS;
+}
+/*
+ * Process Del Sta Request from SME .
+ */
+tSirRetStatus limProcessSmeTdlsDelStaReq(tpAniSirGlobal pMac, 
+                                                           tANI_U32 *pMsgBuf)
+{
+    /* get all discovery request parameters */
+    tSirTdlsDelStaReq *pDelStaReq = (tSirTdlsDelStaReq*) pMsgBuf ;
+    tpPESession psessionEntry;
+    tANI_U8      sessionId;
+    tpDphHashNode pStaDs = NULL ;
+
+    VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
+            ("Send Mgmt Recieved\n")) ;
+
+    if((psessionEntry = peFindSessionByBssid(pMac, pDelStaReq->bssid, &sessionId)) 
+            == NULL)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                "PE Session does not exist for given sme sessionId %d\n", 
+                pDelStaReq->sessionId);
+        limSendSmeTdlsDelStaRsp(pMac, 0, pDelStaReq->peerMac,
+             NULL, eSIR_FAILURE) ;
+        return eSIR_FAILURE;
+    }
+
+    /* check if we are in proper state to work as TDLS client */ 
+    if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
+    {
+        VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, 
+                "Del sta received in wrong system Role %d\n", 
+                psessionEntry->limSystemRole);
+        goto lim_tdls_del_sta_error;
+    }
+
+    /*
+     * if we are still good, go ahead and check if we are in proper state to
+     * do TDLS discovery req/rsp/....frames.
+     */
+    if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
+            (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
+    {
+
+        limLog(pMac, LOGE, "Del Sta received in invalid LIMsme \
+                state (%d)\n", psessionEntry->limSmeState);
+        goto lim_tdls_del_sta_error;
+    }
+
+    pStaDs = limTdlsDelSta(pMac, pDelStaReq->peerMac, psessionEntry) ;
+
+    /* now send indication to SME-->HDD->TL to remove STA from TL */
+
+    if(pStaDs)
+    {
+        limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
+                pStaDs, eSIR_SUCCESS) ;
+        return eSIR_SUCCESS;
+
+    }
+
+lim_tdls_del_sta_error:
+     limSendSmeTdlsDelStaRsp(pMac, psessionEntry->smeSessionId, pDelStaReq->peerMac,
+             NULL, eSIR_FAILURE) ;
+
+    return eSIR_SUCCESS;
+}
+#endif
diff --git a/CORE/MAC/src/pe/lim/limSendManagementFrames.c b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
index 01c2641..28fa937 100644
--- a/CORE/MAC/src/pe/lim/limSendManagementFrames.c
+++ b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
@@ -2587,10 +2587,10 @@
     }
 
 #ifdef WLAN_FEATURE_P2P
-	if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
-	{
-		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
-	}
+    if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
+    {
+        txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
+    }
 #endif
 
     halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
@@ -3369,10 +3369,10 @@
     }
 
 #ifdef WLAN_FEATURE_P2P
-	if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
-	{
-		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
-	}
+    if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)	
+    {
+        txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
+    }
 #endif
 
     halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
@@ -3680,10 +3680,10 @@
     }
 
 #ifdef WLAN_FEATURE_P2P
-	if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
-	{
-		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
-	}
+    if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
+    {
+        txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
+    }
 #endif
 
     /// Queue Authentication frame in high priority WQ
@@ -4005,11 +4005,11 @@
     }
 
 #ifdef WLAN_FEATURE_P2P
-	if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
-	   (psessionEntry->pePersona == VOS_P2P_GO_MODE))
-	{
-		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
-	}
+    if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
+       (psessionEntry->pePersona == VOS_P2P_GO_MODE))
+    {
+        txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
+    }
 #endif
 
     if (waitForAck)
@@ -4180,11 +4180,11 @@
     }
 
 #ifdef WLAN_FEATURE_P2P
-	if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
-	   (psessionEntry->pePersona == VOS_P2P_GO_MODE))
-	{
-		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
-	}
+    if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
+       (psessionEntry->pePersona == VOS_P2P_GO_MODE))
+    {
+        txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
+    }
 #endif
 
     if (waitForAck)
diff --git a/CORE/MAC/src/pe/lim/limTypes.h b/CORE/MAC/src/pe/lim/limTypes.h
index 889680c..68b90f4 100644
--- a/CORE/MAC/src/pe/lim/limTypes.h
+++ b/CORE/MAC/src/pe/lim/limTypes.h
@@ -1132,5 +1132,12 @@
 void limProcessDeauthAckTimeout(tpAniSirGlobal pMac);
 eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac);
 eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac);
+
+#ifdef WLAN_FEATURE_VOWIFI_11R
+typedef struct sSetLinkCbackParams
+{
+    void * cbackDataPtr;
+} tSetLinkCbackParams;
+#endif
 #endif /* __LIM_TYPES_H */
 
diff --git a/CORE/MAC/src/pe/sch/schBeaconGen.c b/CORE/MAC/src/pe/sch/schBeaconGen.c
index 8ba2050..d072b08 100644
--- a/CORE/MAC/src/pe/sch/schBeaconGen.c
+++ b/CORE/MAC/src/pe/sch/schBeaconGen.c
@@ -86,7 +86,6 @@
         {
             if(palEqualMemory(NULL, (void *)(pExtraIe+2), &P2pOui, sizeof(P2pOui)))
             {
-                (*pP2pIeOffset)++;
                 status = eSIR_SUCCESS;
                 break;
             }
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index fa2ecb0..0fff1d8 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -8097,7 +8097,7 @@
         if(NULL != pTlRssiInd->tlCallback)
         {
             ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
-            (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt);
+            (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
         }
         else
         {
diff --git a/CORE/SME/src/csr/csrApiScan.c b/CORE/SME/src/csr/csrApiScan.c
index fddeb11..5646342 100644
--- a/CORE/SME/src/csr/csrApiScan.c
+++ b/CORE/SME/src/csr/csrApiScan.c
@@ -1857,11 +1857,20 @@
 //pIes can not be NULL
 static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes)
 {
+#ifdef FEATURE_WLAN_LFR 
+    tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
+#endif
+
     pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi);
     pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes);
     csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK );
 #ifdef FEATURE_WLAN_LFR
-    csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes);
+    if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
+    {
+        /* Build the occupied channel list, only if "gNeighborScanChannelList" is 
+           NOT set in the cfg.ini file */
+        csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes);
+    }
 #endif
 }
 
@@ -6996,6 +7005,15 @@
   tListElem *pEntry = NULL;
   tCsrScanResult *pBssDesc = NULL;
   tDot11fBeaconIEs *pIes = NULL;
+  tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
+
+  if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
+  {
+       smsLog(pMac, LOG1, FL("%s: Ini file contains neighbor scan channel list,"
+             " hence NO need to build occupied channel list (numChannels = %d)\n"),
+              __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
+      return;
+  }
 
   if (!csrNeighborRoamIsNewConnectedProfile(pMac))
   {
diff --git a/CORE/SME/src/csr/csrNeighborRoam.c b/CORE/SME/src/csr/csrNeighborRoam.c
index 4094fd4..8523235 100644
--- a/CORE/SME/src/csr/csrNeighborRoam.c
+++ b/CORE/SME/src/csr/csrNeighborRoam.c
@@ -81,9 +81,11 @@
 static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
 
 VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
-                                                                               v_PVOID_t pUserCtxt);
+                                                                               v_PVOID_t pUserCtxt,
+                                                                               v_S7_t avgRssi);
 VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
-                                                                               v_PVOID_t pUserCtxt);
+                                                                               v_PVOID_t pUserCtxt,
+                                                                               v_S7_t avgRssi);
 void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
 eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
 
@@ -299,14 +301,16 @@
 ---------------------------------------------------------------------------*/
 VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter, 
                                v_U8_t trafficStatus, 
-                               v_PVOID_t pUserCtxt)
+                               v_PVOID_t pUserCtxt,
+                               v_S7_t   avgRssi)
 {
     tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
     tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
     VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;   
  
-    NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
-
+    NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"), 
+                         pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
+                         avgRssi);
 
     vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
                                                         WLANTL_HO_THRESHOLD_DOWN, 
@@ -319,8 +323,8 @@
         smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
     }
     
-    NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. RSSI = %d"),
-            NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
+    NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
+            NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
     vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
                         (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
                         WLANTL_HO_THRESHOLD_UP,
@@ -2784,13 +2788,16 @@
 
 ---------------------------------------------------------------------------*/
 VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
-                                                                               v_PVOID_t pUserCtxt)
+                                                                               v_PVOID_t pUserCtxt,
+                                                                               v_S7_t avgRssi)
 {
     tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
     tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
     VOS_STATUS  vosStatus = eHAL_STATUS_SUCCESS;
 
-    NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d"), rssiNotification);
+    NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
+                                       rssiNotification,
+                                       avgRssi);
 
     if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
     {
@@ -2818,13 +2825,16 @@
 
 ---------------------------------------------------------------------------*/
 VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
-                                                                               v_PVOID_t pUserCtxt)
+                                                                               v_PVOID_t pUserCtxt,
+                                                                               v_S7_t avgRssi)
 {
     tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
     tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
     VOS_STATUS  vosStatus = eHAL_STATUS_SUCCESS;
 
-    NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d"), rssiNotification);
+    NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
+                               rssiNotification,
+                               avgRssi);
 
     if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
     {
@@ -3342,7 +3352,9 @@
 
     /* Free the profile.. */ 
     csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
-
+#ifdef FEATURE_WLAN_LFR    
+    csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
+#endif
 #ifdef WLAN_FEATURE_VOWIFI_11R
     pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
     palTimerFree(pMac->hHdd, pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimer);
diff --git a/CORE/SME/src/csr/csrTdlsProcess.c b/CORE/SME/src/csr/csrTdlsProcess.c
new file mode 100644
index 0000000..804aa58
--- /dev/null
+++ b/CORE/SME/src/csr/csrTdlsProcess.c
@@ -0,0 +1,1000 @@
+/*
+* Copyright (c) 2012 Qualcomm Atheros, Inc.
+* All Rights Reserved.
+* Qualcomm Atheros Confidential and Proprietary.
+*/
+
+/** ------------------------------------------------------------------------- * 
+    ------------------------------------------------------------------------- *  
+
+  
+    \file csrTdlsProcess.c
+  
+    Implementation for the TDLS interface to PE.
+  
+    Copyright (C) 2010 Qualcomm, Incorporated
+  
+ 
+   ========================================================================== */
+
+#ifdef FEATURE_WLAN_TDLS
+
+#include "aniGlobal.h" //for tpAniSirGlobal
+#include "palApi.h"
+#include "csrInsideApi.h"
+#include "smeInside.h"
+#include "smsDebug.h"
+
+#include "csrSupport.h"
+#include "wlan_qct_tl.h"
+
+#include "vos_diag_core_log.h"
+#include "vos_diag_core_event.h"
+#include "csrInternal.h"
+
+
+
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * initialize Discovery list 
+ */
+eHalStatus csrTdlsInitPeerList(tpAniSirGlobal pMac )
+{
+    tCsrTdlsCtxStruct *tdlsDisInfo = &pMac->tdlsCtx ;
+    csrLLOpen(pMac->hHdd, &tdlsDisInfo->tdlsPotentialPeerList) ;
+
+    return eHAL_STATUS_SUCCESS ;
+}
+#endif
+
+tANI_BOOLEAN csrTdlsPowerSaveCheck( void *hHal )
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    
+    //Avoid entering into BMPS if any TDLS peer is connected
+    return ((pMac->tdlsCtx.tdlsPeerCount > 0) ? FALSE : TRUE) ;
+}
+/*
+ * open TDLS context for SME
+ */
+eHalStatus csrTdlsOpen(tHalHandle hHal)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+    csrTdlsInitPeerList(pMac) ;
+#endif
+    pMac->tdlsCtx.tdlsPeerCount = 0;
+    if( eHAL_STATUS_SUCCESS != pmcRegisterPowerSaveCheck (pMac, csrTdlsPowerSaveCheck, pMac) )
+    {
+        smsLog( pMac, LOGE, FL("Register power save check failed\n") );
+    }
+    return eHAL_STATUS_SUCCESS ;
+}
+
+/*
+ * common routine to remove TDLS cmd from SME command list..
+ * commands are removed after getting reponse from PE.
+ */
+eHalStatus csrTdlsRemoveSmeCmd(tpAniSirGlobal pMac, eSmeCommandType cmdType)
+{
+    eHalStatus status = eHAL_STATUS_FAILURE;
+    tListElem *pEntry;
+    tSmeCmd *pCommand;
+
+    pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
+    if( pEntry )
+    {
+        pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
+        if( cmdType == pCommand->command )
+        {
+            if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, 
+                                             pEntry, LL_ACCESS_LOCK ) )
+            {
+                vos_mem_zero( &pCommand->u.tdlsCmd, sizeof( tTdlsCmd ) );
+                csrReleaseCommand( pMac, pCommand );
+                smeProcessPendingQueue( pMac );
+                status = eHAL_STATUS_SUCCESS ;
+            }
+        }
+    }
+    return status ;
+}
+    
+/*
+ * TDLS request API, called from HDD to send a TDLS frame 
+ * in SME/CSR and send message to PE to trigger TDLS discovery procedure.
+ */
+eHalStatus csrTdlsSendMgmtReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsSendMgmt *tdlsSendMgmt)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsSendMgmtCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    //If connected and in Infra. Only then allow this
+    if( CSR_IS_SESSION_VALID( pMac, sessionId ) && 
+        csrIsConnStateConnectedInfra( pMac, sessionId ) &&
+        (NULL != tdlsSendMgmt) )
+    {
+        tdlsSendMgmtCmd = csrGetCommandBuffer(pMac) ;
+
+        if(tdlsSendMgmtCmd)
+        {
+            tTdlsSendMgmtCmdInfo *tdlsSendMgmtCmdInfo = 
+                            &tdlsSendMgmtCmd->u.tdlsCmd.u.tdlsSendMgmtCmdInfo ;
+
+            tdlsSendMgmtCmd->sessionId = sessionId;
+
+            tdlsSendMgmtCmdInfo->frameType = tdlsSendMgmt->frameType ;   
+            tdlsSendMgmtCmdInfo->dialog = tdlsSendMgmt->dialog ;   
+            tdlsSendMgmtCmdInfo->statusCode = tdlsSendMgmt->statusCode ;   
+            palCopyMemory(pMac->hHdd, tdlsSendMgmtCmdInfo->peerMac, 
+                                   tdlsSendMgmt->peerMac, sizeof(tSirMacAddr)) ; 
+
+            if( (0 != tdlsSendMgmt->len) && (NULL != tdlsSendMgmt->buf) )
+            {
+                status = palAllocateMemory( pMac->hHdd, (void **)&tdlsSendMgmtCmdInfo->buf, 
+                        tdlsSendMgmt->len );
+                if(!HAL_STATUS_SUCCESS( status ) )
+                {
+                    smsLog( pMac, LOGE, FL("Alloc Failed\n") );
+                    VOS_ASSERT(0) ;
+                    return status ;
+                }
+                palCopyMemory(pMac->hHdd, tdlsSendMgmtCmdInfo->buf,
+                        tdlsSendMgmt->buf, tdlsSendMgmt->len );
+                tdlsSendMgmtCmdInfo->len = tdlsSendMgmt->len;
+            }
+            else
+            {
+                tdlsSendMgmtCmdInfo->buf = NULL;
+                tdlsSendMgmtCmdInfo->len = 0;
+            }
+
+            tdlsSendMgmtCmd->command = eSmeCommandTdlsSendMgmt ;
+            tdlsSendMgmtCmd->u.tdlsCmd.size = sizeof(tTdlsSendMgmtCmdInfo) ;
+            smePushCommand(pMac, tdlsSendMgmtCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+
+/*
+ * TDLS request API, called from HDD to add a TDLS peer 
+ */
+eHalStatus csrTdlsAddPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsAddStaCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    //If connected and in Infra. Only then allow this
+    if( CSR_IS_SESSION_VALID( pMac, sessionId ) && 
+        csrIsConnStateConnectedInfra( pMac, sessionId ) &&
+        (NULL != peerMac) )
+    {
+        tdlsAddStaCmd = csrGetCommandBuffer(pMac) ;
+
+        if(tdlsAddStaCmd)
+        {
+            tTdlsAddStaCmdInfo *tdlsAddStaCmdInfo = 
+                &tdlsAddStaCmd->u.tdlsCmd.u.tdlsAddStaCmdInfo ;
+
+            tdlsAddStaCmd->sessionId = sessionId;
+
+            palCopyMemory(pMac->hHdd, tdlsAddStaCmdInfo->peerMac, 
+                    peerMac, sizeof(tSirMacAddr)) ; 
+
+            tdlsAddStaCmd->command = eSmeCommandTdlsAddPeer ;
+            tdlsAddStaCmd->u.tdlsCmd.size = sizeof(tTdlsAddStaCmdInfo) ;
+            smePushCommand(pMac, tdlsAddStaCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+
+/*
+ * TDLS request API, called from HDD to delete a TDLS peer 
+ */
+eHalStatus csrTdlsDelPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsDelStaCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    //If connected and in Infra. Only then allow this
+    if( CSR_IS_SESSION_VALID( pMac, sessionId ) && 
+        csrIsConnStateConnectedInfra( pMac, sessionId ) &&
+        (NULL != peerMac) )
+    {
+        tdlsDelStaCmd = csrGetCommandBuffer(pMac) ;
+
+        if(tdlsDelStaCmd)
+        {
+            tTdlsDelStaCmdInfo *tdlsDelStaCmdInfo = 
+                            &tdlsDelStaCmd->u.tdlsCmd.u.tdlsDelStaCmdInfo ;
+
+            tdlsDelStaCmd->sessionId = sessionId;
+
+            palCopyMemory(pMac->hHdd, tdlsDelStaCmdInfo->peerMac, 
+                                   peerMac, sizeof(tSirMacAddr)) ; 
+
+            tdlsDelStaCmd->command = eSmeCommandTdlsDelPeer ;
+            tdlsDelStaCmd->u.tdlsCmd.size = sizeof(tTdlsDelStaCmdInfo) ;
+            smePushCommand(pMac, tdlsDelStaCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * TDLS request API, called from HDD to enable TDLS discovery request
+ * in SME/CSR and send message to PE to trigger TDLS discovery procedure.
+ */
+eHalStatus csrTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsDisRequest *tdlsDisReq)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsDisReqCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    if(tdlsDisReq)
+    {
+        tdlsDisReqCmd = csrGetCommandBuffer(pMac) ;
+
+        if(tdlsDisReqCmd)
+        {
+            tTdlsDisReqCmdinfo *disReqCmdInfo = 
+                            &tdlsDisReqCmd->u.tdlsCmd.u.tdlsDisReqCmdInfo ;
+
+            tdlsDisReqCmd->sessionId = sessionId;
+
+            disReqCmdInfo->tdlsDisType = tdlsDisReq->disType ;   
+            palCopyMemory(pMac->hHdd, disReqCmdInfo->peerMac, 
+                                   tdlsDisReq->peerMac, sizeof(tSirMacAddr)) ; 
+            tdlsDisReqCmd->command = eSmeCommandTdlsDiscovery ;
+            tdlsDisReqCmd->u.tdlsCmd.size = sizeof(tTdlsDisReqCmdinfo) ;
+            smePushCommand(pMac, tdlsDisReqCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+
+/*
+ * TDLS request API, called from HDD to enable TDLS link setup request
+ * in SME/CSR and send message to PE to trigger TDLS link setup procedure.
+ */
+eHalStatus csrTdlsSetupReq(tHalHandle hHal, tANI_U8 sessionId, tCsrTdlsSetupRequest *tdlsSetupReq)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsSetupReqCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    if(tdlsSetupReq)
+    {
+        tdlsSetupReqCmd = csrGetCommandBuffer(pMac) ;
+
+        if(tdlsSetupReqCmd)
+        {
+           tTdlsLinkSetupReqCmdinfo *setupCmdInfo = 
+                        &tdlsSetupReqCmd->u.tdlsCmd.u.tdlsLinkSetupReqCmdInfo ;
+
+            tdlsSetupReqCmd->sessionId = sessionId;
+
+            palCopyMemory(pMac->hHdd, setupCmdInfo->peerMac, 
+                                tdlsSetupReq->peerMac, sizeof(tSirMacAddr)) ; 
+            tdlsSetupReqCmd->command = eSmeCommandTdlsLinkSetup ;
+            tdlsSetupReqCmd->u.tdlsCmd.size = sizeof(tTdlsLinkSetupReqCmdinfo) ;
+            smePushCommand(pMac, tdlsSetupReqCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+/*
+ * TDLS request API, called from HDD to enable TDLS link teardown request
+ * in SME/CSR and send message to PE to trigger TDLS link teardown procedure.
+ */
+eHalStatus csrTdlsTeardownReq(tHalHandle hHal, tANI_U8 sessionId, 
+                                 tCsrTdlsTeardownRequest *tdlsTeardownReq)
+{
+    tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
+    tSmeCmd *tdlsTeardownReqCmd ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+ 
+    if(tdlsTeardownReq)
+    {
+        tdlsTeardownReqCmd = csrGetCommandBuffer(pMac) ;
+        
+        if(tdlsTeardownReqCmd)
+        {
+            tTdlsLinkTeardownCmdinfo *teardownCmdInfo = 
+                   &tdlsTeardownReqCmd->u.tdlsCmd.u.tdlsLinkTeardownCmdInfo ;
+
+            tdlsTeardownReqCmd->sessionId = sessionId;
+
+            palCopyMemory(pMac->hHdd, teardownCmdInfo->peerMac, 
+                         tdlsTeardownReq->peerMac, sizeof(tSirMacAddr)) ; 
+            tdlsTeardownReqCmd->command = eSmeCommandTdlsLinkTear ;
+            tdlsTeardownReqCmd->u.tdlsCmd.size = 
+                                        sizeof(tTdlsLinkTeardownCmdinfo) ;
+            smePushCommand(pMac, tdlsTeardownReqCmd, FALSE) ;
+            status = eHAL_STATUS_SUCCESS ;
+        }
+    }
+
+    return status ;
+}
+
+#endif
+
+/*
+ * TDLS messages sent to PE .
+ */
+eHalStatus tdlsSendMessage(tpAniSirGlobal pMac, tANI_U16 msg_type, 
+                              void *msg_data, tANI_U32 msg_size)
+{
+
+    tSirMbMsg *pMsg = (tSirMbMsg *)msg_data ;
+    pMsg->type = msg_type ;
+    pMsg->msgLen = (tANI_U16) (msg_size) ;
+
+    VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, 
+                              ("sending msg = %d\n"), pMsg->type) ;
+      /* Send message. */
+    if (palSendMBMessage(pMac->hHdd, pMsg) != eHAL_STATUS_SUCCESS)
+    {
+        smsLog(pMac, LOGE, FL("Cannot send message\n"));
+        return eHAL_STATUS_FAILURE;
+    }
+
+    return eHAL_STATUS_SUCCESS;
+}
+
+eHalStatus csrTdlsProcessSendMgmt( tpAniSirGlobal pMac, tSmeCmd *cmd )
+{
+    tTdlsSendMgmtCmdInfo *tdlsSendMgmtCmdInfo = &cmd->u.tdlsCmd.u.tdlsSendMgmtCmdInfo ;
+    tSirTdlsSendMgmtReq *tdlsSendMgmtReq = NULL ;
+    tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+    eHalStatus status = eHAL_STATUS_FAILURE;
+
+    status = palAllocateMemory( pMac->hHdd, (void **)&tdlsSendMgmtReq, 
+            (sizeof(tSirTdlsSendMgmtReq) + tdlsSendMgmtCmdInfo->len ) );
+
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("alloc failed \n") );
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+    tdlsSendMgmtReq->sessionId = cmd->sessionId;
+    //Using dialog as transactionId. This can be used to match response with request
+    tdlsSendMgmtReq->transactionId = tdlsSendMgmtCmdInfo->dialog;  
+    tdlsSendMgmtReq->reqType =  tdlsSendMgmtCmdInfo->frameType ;
+    tdlsSendMgmtReq->dialog =  tdlsSendMgmtCmdInfo->dialog ;
+    tdlsSendMgmtReq->statusCode =  tdlsSendMgmtCmdInfo->statusCode ;
+    palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->bssid, pSession->pConnectBssDesc->bssId, 
+            sizeof (tSirMacAddr));
+    palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->peerMac, 
+            tdlsSendMgmtCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+
+    if(tdlsSendMgmtCmdInfo->len && tdlsSendMgmtCmdInfo->buf)
+    {
+        palCopyMemory(pMac->hHdd, tdlsSendMgmtReq->addIe, tdlsSendMgmtCmdInfo->buf,
+                tdlsSendMgmtCmdInfo->len);
+
+    }
+    // Send the request to PE.
+    smsLog( pMac, LOGE, "sending TDLS Mgmt Frame req to PE \n" );
+    status = tdlsSendMessage(pMac, eWNI_SME_TDLS_SEND_MGMT_REQ, 
+            (void *)tdlsSendMgmtReq , sizeof(tSirTdlsSendMgmtReq)+tdlsSendMgmtCmdInfo->len) ;
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("Failed to send request to MAC\n"));
+    }
+    if(tdlsSendMgmtCmdInfo->len && tdlsSendMgmtCmdInfo->buf)
+    {
+        //Done with the buf. Free it.
+        palFreeMemory( pMac->hHdd, tdlsSendMgmtCmdInfo->buf );
+        tdlsSendMgmtCmdInfo->len = 0;
+    }
+
+    return status;
+}
+
+eHalStatus csrTdlsProcessAddSta( tpAniSirGlobal pMac, tSmeCmd *cmd )
+{
+    tTdlsAddStaCmdInfo *tdlsAddStaCmdInfo = &cmd->u.tdlsCmd.u.tdlsAddStaCmdInfo ;
+    tSirTdlsAddStaReq *tdlsAddStaReq = NULL ;
+    tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+    eHalStatus status = eHAL_STATUS_FAILURE;
+
+    status = palAllocateMemory( pMac->hHdd, (void **)&tdlsAddStaReq, 
+            (sizeof(tSirTdlsAddStaReq) ) );
+
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("alloc failed \n") );
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+    tdlsAddStaReq->sessionId = cmd->sessionId;
+    //Using dialog as transactionId. This can be used to match response with request
+    tdlsAddStaReq->transactionId = 0;
+    palCopyMemory(pMac->hHdd, tdlsAddStaReq->bssid, pSession->pConnectBssDesc->bssId, 
+            sizeof (tSirMacAddr));
+    palCopyMemory(pMac->hHdd, tdlsAddStaReq->peerMac, 
+            tdlsAddStaCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+
+    // Send the request to PE.
+    smsLog( pMac, LOGE, "sending TDLS Add Sta req to PE \n" );
+    status = tdlsSendMessage(pMac, eWNI_SME_TDLS_ADD_STA_REQ, 
+            (void *)tdlsAddStaReq , sizeof(tSirTdlsAddStaReq)) ;
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("Failed to send request to MAC\n"));
+    }
+    return status;
+}
+
+eHalStatus csrTdlsProcessDelSta( tpAniSirGlobal pMac, tSmeCmd *cmd )
+{
+    tTdlsDelStaCmdInfo *tdlsDelStaCmdInfo = &cmd->u.tdlsCmd.u.tdlsDelStaCmdInfo ;
+    tSirTdlsDelStaReq *tdlsDelStaReq = NULL ;
+    tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+    eHalStatus status = eHAL_STATUS_FAILURE;
+
+    status = palAllocateMemory( pMac->hHdd, (void **)&tdlsDelStaReq, 
+            (sizeof(tSirTdlsDelStaReq) ) );
+
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("alloc failed \n") );
+        VOS_ASSERT(0) ;
+        return status ;
+    }
+    tdlsDelStaReq->sessionId = cmd->sessionId;
+    //Using dialog as transactionId. This can be used to match response with request
+    tdlsDelStaReq->transactionId = 0;
+    palCopyMemory(pMac->hHdd, tdlsDelStaReq->bssid, pSession->pConnectBssDesc->bssId, 
+            sizeof (tSirMacAddr));
+    palCopyMemory(pMac->hHdd, tdlsDelStaReq->peerMac, 
+            tdlsDelStaCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+
+    // Send the request to PE.
+    smsLog( pMac, LOGE, "sending TDLS Del Sta req to PE \n" );
+    status = tdlsSendMessage(pMac, eWNI_SME_TDLS_DEL_STA_REQ, 
+            (void *)tdlsDelStaReq , sizeof(tSirTdlsDelStaReq)) ;
+    if(!HAL_STATUS_SUCCESS( status ) )
+    {
+        smsLog( pMac, LOGE, FL("Failed to send request to MAC\n"));
+    }
+    return status;
+}
+/*
+ * commands received from CSR
+ */
+eHalStatus csrTdlsProcessCmd(tpAniSirGlobal pMac, tSmeCmd *cmd)
+{
+    eSmeCommandType  cmdType = cmd->command ;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+    tTdlsCmd tdlsCmd = cmd->u.tdlsCmd ;
+#endif
+    tANI_BOOLEAN status = eANI_BOOLEAN_TRUE;
+    switch(cmdType)
+    {
+        case eSmeCommandTdlsSendMgmt:
+        {
+            status = csrTdlsProcessSendMgmt( pMac, cmd );
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+        }
+        break ;
+        case eSmeCommandTdlsAddPeer:
+        {
+            status = csrTdlsProcessAddSta( pMac, cmd );
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+        }
+        break;
+        case eSmeCommandTdlsDelPeer: 
+        {
+            status = csrTdlsProcessDelSta( pMac, cmd );
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+        }
+        break;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+        case eSmeCommandTdlsDiscovery:
+        {
+            tTdlsDisReqCmdinfo *disReqCmdInfo = &tdlsCmd.u.tdlsDisReqCmdInfo ;
+            tSirTdlsDisReq *disReq = NULL ;
+            tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+            
+            status = palAllocateMemory( pMac->hHdd, (void **)&disReq, 
+                                                      sizeof(tSirTdlsDisReq));
+
+            if(!HAL_STATUS_SUCCESS( status ) )
+            {
+                smsLog( pMac, LOGE, "dis Req alloc failed \n" );
+                VOS_ASSERT(0) ;
+                break ;
+            }
+            disReq->sessionId = cmd->sessionId;
+            disReq->transactionId = 0;  /* TODO ? */
+            disReq->reqType =  disReqCmdInfo->tdlsDisType ;
+            palCopyMemory(pMac->hHdd, disReq->bssid, pSession->pConnectBssDesc->bssId, 
+                                 sizeof (tSirMacAddr));
+            palCopyMemory(pMac->hHdd, disReq->peerMac, 
+                                 disReqCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+            smsLog( pMac, LOGE, "sending TDLS discovery to PE \n" );
+            status = tdlsSendMessage(pMac, eWNI_SME_TDLS_DISCOVERY_START_REQ, 
+                          (void *)disReq , sizeof(tSirTdlsDisReq)) ;
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+                /* TODO: Add error handling */
+
+            break ;
+        }
+        case eSmeCommandTdlsLinkSetup:
+        {
+            tTdlsLinkSetupReqCmdinfo *linkSetupReqCmdInfo = 
+                                         &tdlsCmd.u.tdlsLinkSetupReqCmdInfo ;   
+            tSirTdlsSetupReq *setupReq = NULL ;
+            tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+
+            status = palAllocateMemory( pMac->hHdd, (void **)&setupReq, 
+                                                sizeof(tSirTdlsSetupReq));
+
+            if(!HAL_STATUS_SUCCESS( status ) )
+            {
+                smsLog( pMac, LOGE, "dis Req alloc failed \n" );
+                VOS_ASSERT(0) ;
+                break ;
+            }
+            setupReq->sessionId = cmd->sessionId;
+            setupReq->transactionId = 0;  /* TODO ? */
+            
+            palCopyMemory(pMac->hHdd, setupReq->bssid, pSession->pConnectBssDesc->bssId, 
+                                 sizeof (tSirMacAddr));
+            palCopyMemory(pMac->hHdd, setupReq->peerMac, 
+                           linkSetupReqCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+    
+            VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                             ("sending TDLS link setup to PE \n"));
+            status = tdlsSendMessage(pMac, eWNI_SME_TDLS_LINK_START_REQ,    
+                          (void *)setupReq , sizeof(tSirTdlsSetupReq) ) ;
+
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+                /* TODO: Add error handling */
+            break ;
+        }
+        case eSmeCommandTdlsLinkTear:
+        {
+            tTdlsLinkTeardownCmdinfo *linkTeardownCmdInfo = 
+                                        &tdlsCmd.u.tdlsLinkTeardownCmdInfo ;
+            tSirTdlsTeardownReq *teardownReq = NULL ;
+            tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, cmd->sessionId );
+
+            status = palAllocateMemory( pMac->hHdd, (void **)&teardownReq, 
+                                                sizeof(tSirTdlsTeardownReq));
+            if(!HAL_STATUS_SUCCESS( status ) )
+            {
+                smsLog( pMac, LOGE, "teardown Req alloc failed \n" );
+                VOS_ASSERT(0) ;
+                break ;
+            }
+            teardownReq->sessionId = cmd->sessionId;
+            teardownReq->transactionId = 0;  /* TODO ? */
+
+            palCopyMemory(pMac->hHdd, teardownReq->bssid, pSession->pConnectBssDesc->bssId, 
+                                 sizeof (tSirMacAddr));
+            palCopyMemory(pMac->hHdd, &teardownReq->peerMac, 
+                           linkTeardownCmdInfo->peerMac, sizeof(tSirMacAddr)) ;
+            VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                                                ("teardown request..\n")) ;
+            status = tdlsSendMessage(pMac, eWNI_SME_TDLS_TEARDOWN_REQ,
+                          (void *)teardownReq , sizeof(tSirTdlsTeardownReq)) ;
+
+            if(HAL_STATUS_SUCCESS( status ) )
+            {
+               status = eANI_BOOLEAN_FALSE ;
+            }
+                /* TODO: Add error handling */
+            break ;
+        }
+#endif
+       default:
+       {
+            /* TODO: Add defualt handling */  
+           break ;
+       } 
+             
+    }
+    return status ; 
+}
+
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+/*
+ * Find specific TDLS peer (based on peer MAC address).
+ */
+tCsrTdlsPeerLinkinfo *findTdlsPeer(tpAniSirGlobal pMac, 
+                                tDblLinkList *peerList, tSirMacAddr peerMac)
+{
+    tListElem *pEntry = NULL ;
+    tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ; 
+    tSirTdlsPeerInfo *peerInfo = NULL ;
+
+    pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
+    while(pEntry)
+    {
+        peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo, 
+                                                        tdlsPeerStaLink) ;
+        peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
+ 
+        if(palEqualMemory( pMac->hHdd,(tANI_U8 *)peerInfo->peerMac,
+                              (tANI_U8 *) peerMac, sizeof(tSirMacAddr)) )
+        {
+            break ;
+        }
+
+        pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
+    }
+ 
+    return ((pEntry) ? peerLinkInfo: NULL) ; 
+}
+/*
+ * Delete TDLD peer info, called from TDLS teardown request.
+ */
+static eHalStatus tdlsDeleteTdlsPeerInfo(tpAniSirGlobal pMac,
+                                              tSirMacAddr peerMac)
+{
+    tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
+    tCsrTdlsPeerLinkinfo *peerInfo = 
+               findTdlsPeer(pMac, &disInfo->tdlsPotentialPeerList, peerMac) ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+
+    if((csrLLRemoveEntry(&disInfo->tdlsPotentialPeerList, 
+                        &peerInfo->tdlsPeerStaLink, LL_ACCESS_NOLOCK)))
+    {
+       status = palFreeMemory(pMac->hHdd, (void *)peerInfo) ;
+
+    }
+
+    return status ; 
+}
+
+/*
+ * UPDATE TDLS peer state to TDLS LINK STATE, this will be called after
+ * link is successfully setup with TDLS Peer.
+ */
+static eHalStatus tdlsUpdateTdlsPeerState(tpAniSirGlobal pMac,
+                                          tSirMacAddr peerMac,tANI_U8 state )
+{
+    tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
+    tCsrTdlsPeerLinkinfo *peerLinkInfo = 
+                findTdlsPeer(pMac, &disInfo->tdlsPotentialPeerList, peerMac) ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+
+    if(peerLinkInfo)
+    {
+        tSirTdlsPeerInfo *peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
+        peerInfo->tdlsPeerState = state ;  
+        status = eHAL_STATUS_SUCCESS ;
+    }
+    else
+    {
+        /* TODO: update this peer found in link setup in peer list */
+        VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                       ("This TDLS client is not in discovery list \n") );
+        status = eHAL_STATUS_SUCCESS ;
+    }
+
+    return status ;
+}
+
+/*
+ * save TDLS peer info, this will be called after successfull completion
+ * of TDLS discovery procedure.
+ */
+static eHalStatus tdlsSaveTdlsPeerInfo(tpAniSirGlobal pMac, 
+                                          tSirTdlsPeerInfo *disPeerInfo)
+{
+    tCsrTdlsPeerLinkinfo *peerInfo = NULL ; 
+    tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
+    eHalStatus status = eHAL_STATUS_FAILURE ;
+    /* 
+     * Ok, allocate memory for peer info here
+     * we allocate memory for each peer here and free his memory
+     * at the time the peer node is getting deleted, possible case is 
+     * teardown
+     */
+    status = palAllocateMemory( pMac->hHdd, (void **)&peerInfo, 
+                                sizeof(tCsrTdlsPeerLinkinfo));
+
+    /* 
+     * go ahead and copy peerInfo and insert this node info discovery rsp
+     * database.
+     */ 
+    if (HAL_STATUS_SUCCESS(status))
+    {
+        palZeroMemory(pMac->hHdd, &peerInfo->tdlsDisPeerInfo, 
+                                            sizeof(tSirTdlsPeerInfo));
+        palCopyMemory(pMac->hHdd, &peerInfo->tdlsDisPeerInfo, disPeerInfo, 
+                                             sizeof(tSirTdlsPeerInfo));
+
+        /*
+         * update TDLS client count to indicate there is tdls client
+         * in tdls potential peer list.
+         */
+        disInfo->tdlsPeerCount++ ;
+
+        /*
+         * finally insert this tdls peer info into tdls potential peer list
+         */
+        csrLLInsertTail( &disInfo->tdlsPotentialPeerList, 
+                                 &peerInfo->tdlsPeerStaLink, LL_ACCESS_LOCK );
+    }
+
+    return status ;
+
+}
+
+#endif
+/*
+ * TDLS Message processor, will be called after TDLS message recieved from
+ * PE
+ */
+eHalStatus tdlsMsgProcessor(tpAniSirGlobal pMac,  v_U16_t msgType,
+                                void *pMsgBuf)
+{
+    switch(msgType)
+    {
+        case eWNI_SME_TDLS_SEND_MGMT_RSP:
+        {
+            /* remove pending eSmeCommandTdlsDiscovery command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsSendMgmt) ;
+        }
+        break;
+        case eWNI_SME_TDLS_ADD_STA_RSP:
+        {
+            tSirTdlsAddStaRsp *addStaRsp = (tSirTdlsAddStaRsp *) pMsgBuf ;
+            tCsrRoamInfo roamInfo = {0} ;
+            palCopyMemory(pMac->hHdd, &roamInfo.peerMac, addStaRsp->peerMac, 
+                                         sizeof(tSirMacAddr)) ;
+            roamInfo.staId = addStaRsp->staId ;
+            roamInfo.ucastSig = addStaRsp->ucastSig ;
+            roamInfo.bcastSig = addStaRsp->bcastSig ;
+            roamInfo.statusCode = addStaRsp->bcastSig ;
+            pMac->tdlsCtx.tdlsPeerCount++;
+            /*
+             * register peer with TL, we have to go through HDD as this is
+             * the only way to register any STA with TL.
+             */
+            csrRoamCallCallback(pMac, addStaRsp->sessionId, &roamInfo, 0, 
+                         eCSR_ROAM_TDLS_STATUS_UPDATE, 
+                               eCSR_ROAM_RESULT_ADD_TDLS_PEER);
+ 
+            /* remove pending eSmeCommandTdlsDiscovery command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsAddPeer) ;
+        }
+        break;
+        case eWNI_SME_TDLS_DEL_STA_RSP:
+        {
+            tSirTdlsDelStaRsp *delStaRsp = (tSirTdlsDelStaRsp *) pMsgBuf ;
+            tCsrRoamInfo roamInfo = {0} ;
+
+            palCopyMemory(pMac->hHdd, &roamInfo.peerMac, delStaRsp->peerMac, 
+                                         sizeof(tSirMacAddr)) ;
+            roamInfo.staId = delStaRsp->staId ;
+            roamInfo.statusCode = delStaRsp->statusCode ;
+            /*
+             * register peer with TL, we have to go through HDD as this is
+             * the only way to register any STA with TL.
+             */
+            csrRoamCallCallback(pMac, delStaRsp->sessionId, &roamInfo, 0, 
+                         eCSR_ROAM_TDLS_STATUS_UPDATE, 
+                               eCSR_ROAM_RESULT_DELETE_TDLS_PEER);
+
+            pMac->tdlsCtx.tdlsPeerCount--;
+            //If all tdls connection is teared down, start bmps timer again.
+            if( pMac->tdlsCtx.tdlsPeerCount == 0 )
+            {
+                pmcStartAutoBmpsTimer(pMac);
+            }
+            /* remove pending eSmeCommandTdlsDiscovery command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsDelPeer) ;
+        }
+        break;
+#ifdef FEATURE_WLAN_TDLS_INTERNAL
+        case eWNI_SME_TDLS_DISCOVERY_START_RSP:
+        {
+            /* remove pending eSmeCommandTdlsDiscovery command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsDiscovery) ;
+        }
+        /* fall through .. */
+        case eWNI_SME_TDLS_DISCOVERY_START_IND:
+        {
+            tSirTdlsDisRsp *disRsp = (tSirTdlsDisRsp *)pMsgBuf ;
+
+            if(eSIR_SME_SUCCESS == disRsp->statusCode)
+            {
+                tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
+                tANI_U16  disStaCount = disRsp->numDisSta ;
+                tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
+                tANI_U8 i = 0 ;
+  
+                VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                ("DIS START RSP/IND recieved sta count = %d\n"), disStaCount) ;     
+                for( ; i < disStaCount ; i++)
+                {
+                    tSirTdlsPeerInfo *peerInfo = &disRsp->tdlsDisPeerInfo[i] ;
+                    VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                                                   ("SME, peer MAC:\n")) ;
+                    VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                                    (" %02x,%02x,%02x,%02x,%02x,%02x"), 
+                                          peerInfo->peerMac[0], 
+                                          peerInfo->peerMac[1], 
+                                          peerInfo->peerMac[2], 
+                                          peerInfo->peerMac[3], 
+                                          peerInfo->peerMac[4], 
+                                          peerInfo->peerMac[5]) ;
+
+                    peerLinkInfo = findTdlsPeer(pMac,
+                                   &disInfo->tdlsPotentialPeerList,
+                                                     peerInfo->peerMac) ; 
+
+                    if(NULL == peerLinkInfo)
+                    {
+                        /* update discovery data base, if this is new entry */
+                        tdlsSaveTdlsPeerInfo(pMac, peerInfo) ;
+                    }
+                    else
+                    {
+                        /* update RSSI of existing peer */
+                        tSirTdlsPeerInfo *newPeerInfo = 
+                                            &peerLinkInfo->tdlsDisPeerInfo ; 
+                        newPeerInfo->tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
+                    }
+                }
+                if(0 == i)
+                {
+                    smsLog( pMac, LOGW, "there is no tdls client \
+                                                      discovered .." ) ;
+                }
+            }
+            else
+            {
+                smsLog( pMac, LOGW, "there is no tdls client discovered .." );
+            }
+            /* Now free the memory for this message */
+            break ;    
+	}    
+        case eWNI_SME_TDLS_LINK_START_RSP:
+        {
+            /* remove pending eSmeCommandTdlsLinkSetup command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsLinkSetup) ;
+        }
+        /* fall through .. */
+        case eWNI_SME_TDLS_LINK_START_IND:
+        {
+            tSirTdlsLinksetupRsp *linkSetupRsp = 
+                                        (tSirTdlsLinksetupRsp *) pMsgBuf ;
+
+            if(eSIR_SME_SUCCESS == linkSetupRsp->statusCode)
+            {
+                VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                      ("Link setup for Peer %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                                 linkSetupRsp->peerMac[0],       
+                                 linkSetupRsp->peerMac[1],       
+                                 linkSetupRsp->peerMac[2],       
+                                 linkSetupRsp->peerMac[3],       
+                                 linkSetupRsp->peerMac[4],       
+                                 linkSetupRsp->peerMac[5]) ;
+       
+                tdlsUpdateTdlsPeerState(pMac, linkSetupRsp->peerMac, 
+                                                  TDLS_LINK_SETUP_STATE) ;
+            }
+            else
+            {
+                smsLog( pMac, LOGW, "failure receieved in link setup .." );
+            }
+            break ;       
+        }
+
+        case eWNI_SME_TDLS_TEARDOWN_RSP:
+        {
+            VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                                          ("TEARDOWN RSP from PE \n")) ;
+            /* remove pending eSmeCommandTdlsLinkTear command */
+            csrTdlsRemoveSmeCmd(pMac, eSmeCommandTdlsLinkTear) ;
+        }
+        /* fall through .. */
+        case eWNI_SME_TDLS_TEARDOWN_IND:
+        {
+            tSirTdlsTeardownRsp *linkTearRsp = 
+                                        (tSirTdlsTeardownRsp *) pMsgBuf ;
+            if(eSIR_SME_SUCCESS == linkTearRsp->statusCode)
+            {
+            
+                VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                 ("Teardown peer MAC = %02x,%02x,%02x,%02x,%02x,%02x\n"),
+                            linkTearRsp->peerMac[0],  
+                            linkTearRsp->peerMac[1],  
+                            linkTearRsp->peerMac[2],  
+                            linkTearRsp->peerMac[3],  
+                            linkTearRsp->peerMac[4],  
+                            linkTearRsp->peerMac[5]) ;  
+                tdlsDeleteTdlsPeerInfo(pMac, linkTearRsp->peerMac) ;
+            }
+            else
+            {
+                VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, 
+                                   ("failure receieved in Teardown .." ));
+            }
+            break ;
+        }
+        case eWNI_SME_ADD_TDLS_PEER_IND:
+        {
+            tSirTdlsPeerInd *peerInd = (tSirTdlsPeerInd *) pMsgBuf ;
+            tCsrRoamInfo roamInfo = {0} ;
+            palCopyMemory(pMac->hHdd, &roamInfo.peerMac, peerInd->peerMac, 
+                                         sizeof(tSirMacAddr)) ;
+            roamInfo.staId = peerInd->staId ;
+            roamInfo.ucastSig = peerInd->ucastSig ;
+            roamInfo.bcastSig = peerInd->bcastSig ;
+            /*
+             * register peer with TL, we have to go through HDD as this is
+             * the only way to register any STA with TL.
+             */
+            csrRoamCallCallback(pMac, peerInd->sessionId, &roamInfo, 0, 
+                         eCSR_ROAM_TDLS_STATUS_UPDATE, 
+                               eCSR_ROAM_RESULT_ADD_TDLS_PEER);
+            break ;
+ 
+        }
+        case eWNI_SME_DELETE_TDLS_PEER_IND:
+        {
+            tSirTdlsPeerInd *peerInd = (tSirTdlsPeerInd *) pMsgBuf ;
+            tCsrRoamInfo roamInfo = {0} ;
+            palCopyMemory(pMac->hHdd, &roamInfo.peerMac, peerInd->peerMac, 
+                                         sizeof(tSirMacAddr)) ;
+            roamInfo.staId = peerInd->staId ;
+            /*
+             * register peer with TL, we have to go through HDD as this is
+             * the only way to register any STA with TL.
+             */
+            csrRoamCallCallback(pMac, peerInd->sessionId, &roamInfo, 0, 
+                         eCSR_ROAM_TDLS_STATUS_UPDATE, 
+                               eCSR_ROAM_RESULT_DELETE_TDLS_PEER);
+            break ;
+
+        }
+#endif
+        default:
+        {
+            break ;
+        }
+    }
+    
+    return eHAL_STATUS_SUCCESS ;
+}
+#endif
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 7f7c8e8..f79645b 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -6114,8 +6114,12 @@
                 status = csrGetRegulatoryDomainForCountry( pMac, pIes->Country.country, &domainId );
                 if( !HAL_STATUS_SUCCESS( status ) )
                 {
-                    fRet = eANI_BOOLEAN_FALSE;
-                    break;
+                     status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCode11d,(v_REGDOMAIN_t *) &domainId );
+                     if( !HAL_STATUS_SUCCESS( status ) )
+                     {
+                           fRet = eANI_BOOLEAN_FALSE;
+                           break;
+                     }
                 }
             }
             //check whether it is needed to enforce to the default regulatory domain first
diff --git a/CORE/SYS/legacy/src/system/src/macInitApi.c b/CORE/SYS/legacy/src/system/src/macInitApi.c
index dfd29ed..0653715 100644
--- a/CORE/SYS/legacy/src/system/src/macInitApi.c
+++ b/CORE/SYS/legacy/src/system/src/macInitApi.c
@@ -293,7 +293,7 @@
         return eSIR_FAILURE;
 
     /*
-     * Make sure this adapter is not already opened. (Compare pAdaptor pointer in already
+     * Make sure this adapter is not already opened. (Compare pAdapter pointer in already
      * allocated pMac structures.)
      * If it is opened just return pointer to previously allocated pMac pointer.
      * Or should this result in error?
diff --git a/CORE/SYS/legacy/src/utils/src/utilsApi.c b/CORE/SYS/legacy/src/utils/src/utilsApi.c
index 004827c..67bdd80 100644
--- a/CORE/SYS/legacy/src/utils/src/utilsApi.c
+++ b/CORE/SYS/legacy/src/utils/src/utilsApi.c
@@ -66,7 +66,7 @@
         NdisStallExecution((duration+999)/1000); // This routine takes the duration in uSecs.
 } // sirBusyWaitIntern()
 
-#endif // (WNI_POLARIS_FW_OS == SIR_WINDOWS)
+#endif // (ANI_OS_TYPE_WINDOWS)
 
 
 
diff --git a/CORE/TL/inc/wlan_qct_tl.h b/CORE/TL/inc/wlan_qct_tl.h
index d6073bf..1e1efbd 100644
--- a/CORE/TL/inc/wlan_qct_tl.h
+++ b/CORE/TL/inc/wlan_qct_tl.h
@@ -784,7 +784,8 @@
 (
    v_PVOID_t                       pAdapter,
    v_U8_t                          rssiNotification,
-   v_PVOID_t                       pUserCtxt
+   v_PVOID_t                       pUserCtxt,
+   v_S7_t                          avgRssi
 );
 
 typedef struct
@@ -794,6 +795,7 @@
     v_U16_t                         msgLen;  // length of the entire request
     v_U8_t                          sessionId; //sme Session Id
     v_U8_t                          rssiNotification;    
+    v_U8_t                          avgRssi;
     v_PVOID_t                       tlCallback;
     v_PVOID_t                       pAdapter;
     v_PVOID_t                       pUserCtxt;
diff --git a/CORE/TL/src/wlan_qct_tl_hosupport.c b/CORE/TL/src/wlan_qct_tl_hosupport.c
index 1cc9c5a..79c7ef1 100644
--- a/CORE/TL/src/wlan_qct_tl_hosupport.c
+++ b/CORE/TL/src/wlan_qct_tl_hosupport.c
@@ -797,6 +797,7 @@
    v_U32_t                         isSet;
    v_U8_t                          idx, sIdx;
 
+
    if(NULL == tlCtxt)
    {
       TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"Invalid TL handle"));
@@ -894,10 +895,11 @@
                {
                   cbFunction = hoSupport->registeredInd[idx].crossCBFunction[sIdx];
                   usrCtxt = hoSupport->registeredInd[idx].usrCtxt[sIdx];
+
                   evtType = WLANTL_HO_THRESHOLD_DOWN;
                   TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Trigger Event %d, region index %d", hoSupport->registeredInd[idx].triggerEvent[sIdx], idx));
                   currentHO->regionNumber = newRegionNumber;
-                  status = cbFunction(pAdapter, evtType, usrCtxt);
+                  status = cbFunction(pAdapter, evtType, usrCtxt, pRSSINotification->avgRssi);
                }
             }
          }
@@ -918,10 +920,11 @@
                {
                   cbFunction = hoSupport->registeredInd[idx].crossCBFunction[sIdx];
                   usrCtxt = hoSupport->registeredInd[idx].usrCtxt[sIdx];
+
                   evtType = WLANTL_HO_THRESHOLD_UP;
                   TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Trigger Event %d, region index %d", hoSupport->registeredInd[idx].triggerEvent[sIdx], idx));
                   currentHO->regionNumber = newRegionNumber;
-                  status = cbFunction(pAdapter, evtType, usrCtxt);
+                  status = cbFunction(pAdapter, evtType, usrCtxt, pRSSINotification->avgRssi);
                }
             }
          }
@@ -1017,9 +1020,10 @@
                {
                   cbFunction = hoSupport->registeredInd[idx].crossCBFunction[sIdx];
                   usrCtxt = hoSupport->registeredInd[idx].usrCtxt[sIdx];
+
                   evtType = WLANTL_HO_THRESHOLD_DOWN;
                   TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"Trigger Event %d, region index %d", hoSupport->registeredInd[idx].triggerEvent[sIdx], idx));
-                  status = WLANTL_HSSerializeTlIndication(pAdapter, evtType, usrCtxt, cbFunction);
+                  status = WLANTL_HSSerializeTlIndication(pAdapter, evtType, usrCtxt, cbFunction, currentRSSI);
                }
             }
          }
@@ -1039,9 +1043,10 @@
                {
                   cbFunction = hoSupport->registeredInd[idx - 1].crossCBFunction[sIdx];
                   usrCtxt = hoSupport->registeredInd[idx - 1].usrCtxt[sIdx];
+
                   evtType = WLANTL_HO_THRESHOLD_UP;
                   TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,"Trigger Event %d, region index %d", hoSupport->registeredInd[idx - 1].triggerEvent[sIdx], idx - 1));
-                  status = WLANTL_HSSerializeTlIndication(pAdapter, evtType, usrCtxt, cbFunction);
+                  status = WLANTL_HSSerializeTlIndication(pAdapter, evtType, usrCtxt, cbFunction, currentRSSI);
                }
             }
          }
@@ -1385,7 +1390,8 @@
             if((WLANTL_HO_THRESHOLD_DOWN == triggerEvent) || (WLANTL_HO_THRESHOLD_CROSS == triggerEvent))
             {
                TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Registered RSSI value larger than Current RSSI, and DOWN event, Send Notification"));
-               WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_DOWN, usrCtxt, crossCBFunction);
+               WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_DOWN, usrCtxt, crossCBFunction,
+                                              hoSupport->registeredInd[currentHO->regionNumber].rssiValue);
             }
          }
          else if((currentHO->regionNumber < (currentHO->numThreshold - 1)) &&
@@ -1414,14 +1420,14 @@
       ((WLANTL_HO_THRESHOLD_DOWN == triggerEvent) || (WLANTL_HO_THRESHOLD_CROSS == triggerEvent)))
    {
       TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Registered RSSI value larger than Current RSSI, and DOWN event, Send Notification"));
-      WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_DOWN, usrCtxt, crossCBFunction);
+      WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_DOWN, usrCtxt, crossCBFunction, currentHO->historyRSSI);
    }
    else if((VOS_FALSE == tlCtxt->isBMPS) &&
            (rssiValue < currentHO->historyRSSI) && (0 != currentHO->historyRSSI) &&
            ((WLANTL_HO_THRESHOLD_UP == triggerEvent) || (WLANTL_HO_THRESHOLD_CROSS == triggerEvent)))
    {
       TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Registered RSSI value smaller than Current RSSI, and UP event, Send Notification"));
-      WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_UP, usrCtxt, crossCBFunction);
+      WLANTL_HSSerializeTlIndication(pAdapter, WLANTL_HO_THRESHOLD_UP, usrCtxt, crossCBFunction, currentHO->historyRSSI);
    }
 
    if((VOS_TRUE == tlCtxt->isBMPS) || (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
@@ -1861,7 +1867,8 @@
    v_PVOID_t   pAdapter,
    v_U8_t      rssiNotification,
    v_PVOID_t   pUserCtxt,
-   WLANTL_RSSICrossThresholdCBType cbFunction
+   WLANTL_RSSICrossThresholdCBType cbFunction,
+   v_U8_t      avgRssi
 )
 {
    VOS_STATUS       status = VOS_STATUS_SUCCESS;
@@ -1881,6 +1888,7 @@
    pMsg->pAdapter = pAdapter;
    pMsg->pUserCtxt = pUserCtxt;
    pMsg->rssiNotification = rssiNotification;
+   pMsg->avgRssi = avgRssi;
    pMsg->tlCallback = cbFunction;
 
 
diff --git a/CORE/TL/src/wlan_qct_tl_hosupport.h b/CORE/TL/src/wlan_qct_tl_hosupport.h
index f8fa116..4a4aa43 100644
--- a/CORE/TL/src/wlan_qct_tl_hosupport.h
+++ b/CORE/TL/src/wlan_qct_tl_hosupport.h
@@ -274,7 +274,8 @@
    v_PVOID_t   pAdapter,
    v_U8_t      rssiNotification,
    v_PVOID_t   pUserCtxt,
-   WLANTL_RSSICrossThresholdCBType cbFunction
+   WLANTL_RSSICrossThresholdCBType cbFunction,
+   v_U8_t      avgRssi
 );
 
 /*==========================================================================
diff --git a/CORE/VOSS/src/vos_trace.c b/CORE/VOSS/src/vos_trace.c
index 38ecbd5..f118193 100644
--- a/CORE/VOSS/src/vos_trace.c
+++ b/CORE/VOSS/src/vos_trace.c
@@ -259,7 +259,7 @@
       va_start(val, strFormat);
 
       // print the prefix string into the string buffer...
-      n = snprintf(strBuffer, VOS_TRACE_BUFFER_SIZE, "[WLAN][%d:%2s:%3s] ",
+      n = snprintf(strBuffer, VOS_TRACE_BUFFER_SIZE, "wlan: [%d:%2s:%3s] ",
                    in_interrupt() ? 0 : current->pid,
                    (char *) TRACE_LEVEL_STR[ level ],
                    (char *) gVosTraceInfo[ module ].moduleNameStr );
diff --git a/CORE/WDA/inc/legacy/wlan_qct_hal.h b/CORE/WDA/inc/legacy/wlan_qct_hal.h
index 928b808..abb3bd2 100644
--- a/CORE/WDA/inc/legacy/wlan_qct_hal.h
+++ b/CORE/WDA/inc/legacy/wlan_qct_hal.h
@@ -408,7 +408,7 @@
   SIDE EFFECTS 
   
 ============================================================================*/
-VOS_STATUS WLANHAL_FillTxBd(void *pAdaptor, tANI_U8 typeSubtype, void *pDestMacAddr, void *pAddr2,
+VOS_STATUS WLANHAL_FillTxBd(void *pAdapter, tANI_U8 typeSubtype, void *pDestMacAddr, void *pAddr2,
         tANI_U8* ptid, tANI_U8 disableFrmXtl, void *pTxBd, tANI_U8 txFlag, tANI_U32 timeStamp);
 
 #ifdef WLAN_SOFTAP_FEATURE
@@ -425,7 +425,7 @@
 void WLANHAL_RxAmsduBdFix(void *pVosGCtx,v_PVOID_t _pvBDHeader);
 
 #ifdef WLAN_PERF
-tANI_U32 WLANHAL_TxBdFastFwd(void *pAdaptor, tANI_U8 *pDestMac, tANI_U8 tid, tANI_U8 unicastDst,  void *pTxBd, tANI_U16);
+tANI_U32 WLANHAL_TxBdFastFwd(void *pAdapter, tANI_U8 *pDestMac, tANI_U8 tid, tANI_U8 unicastDst,  void *pTxBd, tANI_U16);
 #endif
 
 #ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
diff --git a/CORE/WDA/src/wlan_qct_wda.c b/CORE/WDA/src/wlan_qct_wda.c
index a454a40..62bf11f 100644
--- a/CORE/WDA/src/wlan_qct_wda.c
+++ b/CORE/WDA/src/wlan_qct_wda.c
@@ -1403,7 +1403,6 @@
       
    tlvStruct = (tHalCfg *)( (tANI_U8 *) tlvStruct 
                             + sizeof(tHalCfg) + tlvStruct->length) ; 
-
    wdiStartParams->usConfigBufferLen = (tANI_U8 *)tlvStruct - tlvStructStart ;
 #ifdef WLAN_DEBUG
    {
@@ -9306,19 +9305,18 @@
    }
    else
    {
-   /* Get system role, use the self station if in unknown role or STA role */
-   systemRole = wdaGetGlobalSystemRole(pMac);
-   if (( eSYSTEM_UNKNOWN_ROLE == systemRole ) || 
-       (( eSYSTEM_STA_ROLE == systemRole )
+      /* Get system role, use the self station if in unknown role or STA role */
+      systemRole = wdaGetGlobalSystemRole(pMac);
+      if (( eSYSTEM_UNKNOWN_ROLE == systemRole ) || 
+          (( eSYSTEM_STA_ROLE == systemRole )
 #if defined FEATURE_WLAN_CCX || defined FEATURE_WLAN_TDLS
-      && frmType == HAL_TXRX_FRM_802_11_MGMT
+         && frmType == HAL_TXRX_FRM_802_11_MGMT
 #endif
-            ))
-   {
-       txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
+         ))
+      {
+         txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
+      }
    }
-   }
-
 
    /* Divert Disassoc/Deauth frames thru self station, as by the time unicast
       disassoc frame reaches the HW, HAL has already deleted the peer station */
@@ -10066,6 +10064,8 @@
             wdiLowLevelInd->wdiIndicationData.wdiLowRSSIInfo.bRssiThres3NegCross;
          rssiNotification.bRssiThres3PosCross = 
             wdiLowLevelInd->wdiIndicationData.wdiLowRSSIInfo.bRssiThres3PosCross;
+         rssiNotification.avgRssi = (v_S7_t) 
+            ((-1)*wdiLowLevelInd->wdiIndicationData.wdiLowRSSIInfo.avgRssi);
          WLANTL_BMPSRSSIRegionChangedNotification(
             pWDA->pVosContext,
             &rssiNotification);
diff --git a/CORE/WDI/CP/inc/wlan_qct_wdi.h b/CORE/WDI/CP/inc/wlan_qct_wdi.h
index cc47e02..71f256c 100644
--- a/CORE/WDI/CP/inc/wlan_qct_wdi.h
+++ b/CORE/WDI/CP/inc/wlan_qct_wdi.h
@@ -394,7 +394,8 @@
   /*Negative crossing of Rssi Thresh3*/
    wpt_uint32             bRssiThres3NegCross : 1;
 
-   wpt_uint32             bReserved           : 26;
+   wpt_uint32             avgRssi             : 8;
+   wpt_uint32             bReserved           : 18;
 
 }WDI_LowRSSIThIndType;
 
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index 3296834..bf3fc84 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -6508,7 +6508,14 @@
         return VOS_STATUS_E_FAILURE;
      }
      /* Stop Transport Driver, DXE */
-     WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_DOWN, WDI_SetPowerStateCb);
+     status = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_DOWN, WDI_SetPowerStateCb);
+     if( eWLAN_PAL_STATUS_SUCCESS != status ) 
+     {
+        WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Power Down state\n", status);
+        WDI_ASSERT(0);
+        return WDI_STATUS_E_FAILURE;
+     }
      /*
       * Wait for the event to be set once the ACK comes back from DXE
       */
@@ -6663,7 +6670,6 @@
 
   wpalMutexRelease(&pWDICtx->wptMutex);
 #endif
-
   if ((pwdiInitScanParams->wdiReqInfo.bUseNOA) && (!WDI_getFwWlanFeatCaps(P2P_GO_NOA_DECOUPLE_INIT_SCAN)))
   {
     /*This is temporary fix.
@@ -6998,7 +7004,7 @@
   wpt_uint16                    usDataOffset         = 0;
   wpt_uint16                    usSendSize           = 0;
   wpt_uint8                     i                    = 0;
-
+  wpt_status                    wptStatus;
   tHalFinishScanReqMsg          halFinishScanReqMsg;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
@@ -7034,7 +7040,7 @@
                pWDICtx->bScanInProgress );
 
     wpalMutexRelease(&pWDICtx->wptMutex);
-    return WDI_STATUS_E_NOT_ALLOWED;
+    return WDI_STATUS_E_NOT_ALLOWED; 
   }
 
   /*-----------------------------------------------------------------------
@@ -7049,7 +7055,13 @@
   if ( pWDICtx->bInBmps )
   {
      // notify DTS that we are entering BMPS
-     WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_BMPS, NULL);
+     wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_BMPS, NULL);
+     if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) 
+     {
+        WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering BMPS\n", wptStatus);
+        WDI_ASSERT(0);
+     }
   }
 
   /*-----------------------------------------------------------------------
@@ -11754,7 +11766,13 @@
    }
 
    // notify DTS that we are entering IMPS
-   WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_IMPS, WDI_SetPowerStateCb);
+   wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_IMPS, WDI_SetPowerStateCb);
+   if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) {
+        WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering IMPS\n", wptStatus);
+        WDI_ASSERT(0);
+        return WDI_STATUS_E_FAILURE;
+    }
 
    /*
     * Wait for the event to be set once the ACK comes back from DXE
@@ -11903,7 +11921,14 @@
    }
 
    // notify DTS that we are entering BMPS
-   WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_BMPS, WDI_SetPowerStateCb);
+   wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_BMPS, WDI_SetPowerStateCb);
+   if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) 
+   {
+        WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that we are entering BMPS\n", wptStatus);
+        WDI_ASSERT(0);
+        return WDI_STATUS_E_FAILURE;
+    }
 
 /*
     * Wait for the event to be set once the ACK comes back from DXE
@@ -11916,7 +11941,7 @@
                 "WDI Init failed to wait on an event");
 
       WDI_ASSERT(0);
-      return VOS_STATUS_E_FAILURE;
+      return VOS_STATUS_E_FAILURE; 
    }
 
    pWDICtx->bInBmps = eWLAN_PAL_TRUE;
@@ -13916,6 +13941,7 @@
   WDI_Status            wdiStatus;
   WDI_InitScanRspCb     wdiInitScanRspCb;
   tHalInitScanRspMsg    halInitScanRspMsg;
+  wpt_status            wptStatus;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
   /*-------------------------------------------------------------------------
@@ -13952,7 +13978,12 @@
   if ( pWDICtx->bInBmps )
   {
      // notify DTS that we are entering Full power
-     WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+     wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+     if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) {
+        WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Full Power state\n", wptStatus);
+        WDI_ASSERT(0);
+    }
   }
 
   /*Notify UMAC*/
@@ -16783,6 +16814,7 @@
   WDI_Status           wdiStatus;
   eHalStatus           halStatus;
   WDI_EnterImpsRspCb   wdiEnterImpsRspCb;
+  wpt_status wptStatus;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
   /*-------------------------------------------------------------------------
@@ -16817,7 +16849,13 @@
                 halStatus);
      /* Call Back is not required as we are putting the DXE in FULL
       * and riva is already in full (IMPS RSP Failed)*/
-     WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+     wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+     
+     if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) {
+          WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Full Power state\n", wptStatus);
+          WDI_ASSERT(0);
+     }
   }
   /*Notify UMAC*/
   wdiEnterImpsRspCb( wdiStatus, pWDICtx->pRspCBUserData);
@@ -16845,6 +16883,7 @@
   WDI_Status           wdiStatus;
   eHalStatus           halStatus;
   WDI_ExitImpsRspCb    wdiExitImpsRspCb;
+  wpt_status           wptStatus;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
   /*-------------------------------------------------------------------------
@@ -16868,8 +16907,13 @@
   wdiStatus   =   WDI_HAL_2_WDI_STATUS(halStatus);
 
   // notify DTS that we are entering Full power
-  WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
-
+  wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+  if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) 
+  {
+    WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Full Power state\n", wptStatus);
+    WDI_ASSERT(0);
+  }
   /*Notify UMAC*/
   wdiExitImpsRspCb( wdiStatus, pWDICtx->pRspCBUserData);
 
@@ -16897,7 +16941,7 @@
   tHalEnterBmpsRspParams halEnterBmpsRsp;
   WDI_EnterBmpsRspCb     wdiEnterBmpsRspCb;
   WDI_EnterBmpsRspParamsType wdiEnterBmpsRspparams;
-  
+  wpt_status             wptStatus;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
   /*-------------------------------------------------------------------------
@@ -16946,7 +16990,13 @@
                   halStatus); 
        /* Call Back is not required as we are putting the DXE in FULL
         * and riva is already in FULL (BMPS RSP Failed)*/
-       WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+       wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+       if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) 
+       {
+           WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Full Power state\n", wptStatus);
+           WDI_ASSERT(0);
+       }
        pWDICtx->bInBmps = eWLAN_PAL_FALSE;
    }
   
@@ -16976,7 +17026,8 @@
   eHalStatus           halStatus;
   WDI_ExitBmpsRspCb   wdiExitBmpsRspCb;
   tHalExitBmpsRspParams halExitBmpsRsp;
-  WDI_ExitBmpsRspParamsType wdiExitBmpsRspParams; 
+  WDI_ExitBmpsRspParamsType wdiExitBmpsRspParams;
+  wpt_status                wptStatus;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
   /*-------------------------------------------------------------------------
@@ -17013,8 +17064,13 @@
   }
 
   // notify DTS that we are entering Full power
-  WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
-
+  wptStatus = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_FULL, NULL);
+  if( eWLAN_PAL_STATUS_SUCCESS != wptStatus ) 
+  {
+    WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
+                "WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Full Power state\n", wptStatus);
+    WDI_ASSERT(0);
+  }
   pWDICtx->bInBmps = eWLAN_PAL_FALSE;
 
   /*Notify UMAC*/
@@ -18127,6 +18183,8 @@
      halRSSINotificationIndMsg.rssiNotificationParams.bRssiThres3PosCross;
   wdiInd.wdiIndicationData.wdiLowRSSIInfo.bRssiThres3NegCross =
      halRSSINotificationIndMsg.rssiNotificationParams.bRssiThres3NegCross;
+  wdiInd.wdiIndicationData.wdiLowRSSIInfo.avgRssi =
+     halRSSINotificationIndMsg.rssiNotificationParams.avgRssi;
 
   /*Notify UMAC*/
   pWDICtx->wdiLowLevelIndCB( &wdiInd, pWDICtx->pIndUserData );
diff --git a/CORE/WDI/WPAL/src/wlan_qct_pal_trace.c b/CORE/WDI/WPAL/src/wlan_qct_pal_trace.c
index a47c9b9..6a18055 100644
--- a/CORE/WDI/WPAL/src/wlan_qct_pal_trace.c
+++ b/CORE/WDI/WPAL/src/wlan_qct_pal_trace.c
@@ -256,7 +256,7 @@
       va_start(val, strFormat);
 
       // print the prefix string into the string buffer...
-      n = snprintf(strBuffer, WPAL_TRACE_BUFFER_SIZE, "[%d:%d:%2s:%3s] ",
+      n = snprintf(strBuffer, WPAL_TRACE_BUFFER_SIZE, "wlan: [%d:%d:%2s:%3s] ",
                    smp_processor_id(),
                    in_interrupt() ? 0 : current->pid,
                    (char *) TRACE_LEVEL_STR[ level ],
diff --git a/Kbuild b/Kbuild
index a2ded76..48a938a 100644
--- a/Kbuild
+++ b/Kbuild
@@ -490,7 +490,6 @@
 		-DGEN6_ONWARDS \
 		-DANI_COMPILER_TYPE_GCC \
 		-DANI_OS_TYPE_ANDROID=6 \
-		-DWNI_POLARIS_FW_OS=6 \
 		-DADVANCED=3 \
 		-DWNI_POLARIS_FW_PACKAGE=9 \
 		-DANI_LOGDUMP \
diff --git a/firmware_bin/WCNSS_cfg.dat b/firmware_bin/WCNSS_cfg.dat
old mode 100644
new mode 100755
index 7671178..0dac5be
--- a/firmware_bin/WCNSS_cfg.dat
+++ b/firmware_bin/WCNSS_cfg.dat
Binary files differ
diff --git a/riva/inc/halCompiler.h b/riva/inc/halCompiler.h
index 263ec52..9a0d6ca 100644
--- a/riva/inc/halCompiler.h
+++ b/riva/inc/halCompiler.h
@@ -126,6 +126,23 @@
 #endif
 #elif defined(ANI_COMPILER_TYPE_RVCT)
 /* Nothing defined so far */
+
+/* 
+ * RIVA 1.2 and Pronto uses ARMCT5.1 compiler and it throws lot of warning when __align() is used in structure definitions. 
+ * __attribute__((aligned())) is GNU compiler attribute that is accepted by ARM compiler and resolves the warnings. 
+ */
+#if (__ARMCC_VERSION > 400000) 
+#define __ani_attr_packed
+#define __ani_attr_pre_packed                   __packed
+#define __ani_attr_aligned_2                    __attribute__((aligned(2)))
+#define __ani_attr_aligned_4                    __attribute__((aligned(4)))
+#define __ani_attr_aligned_8                    __attribute__((aligned(8)))
+#define __ani_attr_aligned_16                   __attribute__((aligned(16)))
+#define __ani_attr_aligned_32                   __attribute__((aligned(32)))
+#define PACKED                                  __packed
+#define PACKED_POST
+#define ALIGN(__value)                          __align(__value)
+#else
 #define __ani_attr_packed
 #define __ani_attr_pre_packed                   __packed
 #define __ani_attr_aligned_2                    __align(2)
@@ -136,6 +153,8 @@
 #define PACKED                                  __packed
 #define PACKED_POST
 #define ALIGN(__value)                          __align(__value)
+#endif
+
 #else
 #error "Unknown compiler"
 #endif
diff --git a/riva/inc/wlan_hal_msg.h b/riva/inc/wlan_hal_msg.h
index 219a416..96629e7 100644
--- a/riva/inc/wlan_hal_msg.h
+++ b/riva/inc/wlan_hal_msg.h
@@ -4100,7 +4100,8 @@
     tANI_U32             bRssiThres2NegCross : 1;
     tANI_U32             bRssiThres3PosCross : 1;
     tANI_U32             bRssiThres3NegCross : 1;
-    tANI_U32             bReserved           : 26;
+    tANI_U32             avgRssi             : 8;
+    tANI_U32             bReserved           : 18;
 } tHalRSSINotification, *tpHalRSSINotification;
 
 typedef PACKED_PRE struct PACKED_POST
diff --git a/riva/inc/wlan_phy.h b/riva/inc/wlan_phy.h
index 47c1d6c..3e34162 100644
--- a/riva/inc/wlan_phy.h
+++ b/riva/inc/wlan_phy.h
@@ -211,6 +211,8 @@
 //[RY] new for PRIMA
 #define DPD_RESPONSE_SIZE 128
 typedef PACKED_PRE struct PACKED_POST {
+    tANI_U8  dpdCalFailCnt;                     //Count for number of times DPD cal failed.
+    tANI_U8  dpdCalSuccessCnt;                  //Count for number of times DPD cal passed.
     tANI_S16 dpd_threshold[DPD_RESPONSE_SIZE];
     tANI_S16 dpd_aoffset[DPD_RESPONSE_SIZE];
     tANI_S16 dpd_again[DPD_RESPONSE_SIZE];