Merge "qcacld-3.0: Enable FW flow steering on NAPI" into wlan-cld3.driver.lnx.1.1-dev
diff --git a/core/dp/txrx/ol_tx_desc.h b/core/dp/txrx/ol_tx_desc.h
index 4842a8a..9c56ebf 100644
--- a/core/dp/txrx/ol_tx_desc.h
+++ b/core/dp/txrx/ol_tx_desc.h
@@ -296,7 +296,7 @@
 void ol_tx_desc_dup_detect_init(struct ol_txrx_pdev_t *pdev, uint16_t pool_size)
 {
 	uint16_t size = (pool_size >> DIV_BY_8) +
-			((pool_size & MOD_BY_8) ? 1 : 0);
+		sizeof(*pdev->tx_desc.free_list_bitmap);
 	pdev->tx_desc.free_list_bitmap = qdf_mem_malloc(size);
 	if (!pdev->tx_desc.free_list_bitmap)
 		qdf_print("%s: malloc failed", __func__);
@@ -329,13 +329,19 @@
 				struct ol_tx_desc_t *tx_desc)
 {
 	uint16_t msdu_id = ol_tx_desc_id(pdev, tx_desc);
-	uint16_t index = msdu_id >> DIV_BY_32;
-	uint8_t pos = msdu_id & MOD_BY_32;
+	bool test;
 
 	if (!pdev->tx_desc.free_list_bitmap)
 		return;
 
-	if (qdf_unlikely(pdev->tx_desc.free_list_bitmap[index] & (1 << pos))) {
+	if (qdf_unlikely(msdu_id > pdev->tx_desc.pool_size)) {
+		qdf_print("%s: msdu_id %d > pool_size %d",
+			  __func__, msdu_id, pdev->tx_desc.pool_size);
+		QDF_BUG(0);
+	}
+
+	test = test_and_set_bit(msdu_id, pdev->tx_desc.free_list_bitmap);
+	if (qdf_unlikely(test)) {
 		uint16_t size = (pdev->tx_desc.pool_size >> DIV_BY_8) +
 			((pdev->tx_desc.pool_size & MOD_BY_8) ? 1 : 0);
 		qdf_print("duplicate msdu_id %d detected !!\n", msdu_id);
@@ -343,7 +349,6 @@
 		(void *)pdev->tx_desc.free_list_bitmap, size);
 		QDF_BUG(0);
 	}
-	pdev->tx_desc.free_list_bitmap[index] |= (1 << pos);
 }
 
 /**
@@ -358,14 +363,19 @@
 				 struct ol_tx_desc_t *tx_desc)
 {
 	uint16_t msdu_id = ol_tx_desc_id(pdev, tx_desc);
-	uint16_t index = msdu_id >> DIV_BY_32;
-	uint8_t pos = msdu_id & MOD_BY_32;
+	bool test;
 
 	if (!pdev->tx_desc.free_list_bitmap)
 		return;
 
-	if (qdf_unlikely(!
-		(pdev->tx_desc.free_list_bitmap[index] & (1 << pos)))) {
+	if (qdf_unlikely(msdu_id > pdev->tx_desc.pool_size)) {
+		qdf_print("%s: msdu_id %d > pool_size %d",
+			  __func__, msdu_id, pdev->tx_desc.pool_size);
+		QDF_BUG(0);
+	}
+
+	test = !test_and_clear_bit(msdu_id, pdev->tx_desc.free_list_bitmap);
+	if (qdf_unlikely(test)) {
 		uint16_t size = (pdev->tx_desc.pool_size >> DIV_BY_8) +
 			((pdev->tx_desc.pool_size & MOD_BY_8) ? 1 : 0);
 		qdf_print("duplicate free msg received for msdu_id %d!!\n",
@@ -374,7 +384,6 @@
 		(void *)pdev->tx_desc.free_list_bitmap, size);
 		QDF_BUG(0);
 	}
-	pdev->tx_desc.free_list_bitmap[index] &= ~(1 << pos);
 }
 #else
 static inline
diff --git a/core/dp/txrx/ol_txrx_types.h b/core/dp/txrx/ol_txrx_types.h
index ea1ccc6..26ecfba 100644
--- a/core/dp/txrx/ol_txrx_types.h
+++ b/core/dp/txrx/ol_txrx_types.h
@@ -669,7 +669,7 @@
 		uint32_t offset_filter;
 		struct qdf_mem_multi_page_t desc_pages;
 #ifdef DESC_DUP_DETECT_DEBUG
-		uint32_t *free_list_bitmap;
+		unsigned long *free_list_bitmap;
 #endif
 	} tx_desc;
 
diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c
index acff948..e335d2b 100644
--- a/core/hdd/src/wlan_hdd_driver_ops.c
+++ b/core/hdd/src/wlan_hdd_driver_ops.c
@@ -554,9 +554,16 @@
 	if (err)
 		goto resume_wma;
 
+	err = wma_is_target_wake_up_received();
+	if (err)
+		goto resume_hif;
+
 	hdd_err("suspend done, status = %d", err);
 	return err;
 
+resume_hif:
+	status = hif_bus_resume(hif_ctx);
+	QDF_BUG(!status);
 resume_wma:
 	status = wma_bus_resume();
 	QDF_BUG(!status);
@@ -590,77 +597,6 @@
 }
 
 /**
- * __wlan_hdd_bus_suspend_noirq() - handle .suspend_noirq callback
- *
- * This function is called by the platform driver to complete the
- * bus suspend callback when device interrupts are disabled by kernel.
- * Call HIF and WMA suspend_noirq callbacks to make sure there is no
- * wake up pending from FW before allowing suspend.
- *
- * Return: 0 for success and -EBUSY if FW is requesting wake up
- */
-int __wlan_hdd_bus_suspend_noirq(void)
-{
-	hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	void *hif_ctx;
-	int err = wlan_hdd_validate_context(hdd_ctx);
-	int status;
-
-	if (err)
-		goto done;
-
-	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
-	if (NULL == hif_ctx) {
-		err = -EINVAL;
-		goto done;
-	}
-
-	if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) {
-		hdd_info("Driver Module closed return success");
-		return 0;
-	}
-
-	err = hif_bus_suspend_noirq(hif_ctx);
-	if (err)
-		goto done;
-
-	err = wma_is_target_wake_up_received();
-	if (err)
-		goto resume_hif_noirq;
-
-	hdd_err("suspend_noirq done, status = %d", err);
-	return err;
-
-resume_hif_noirq:
-	status = hif_bus_resume_noirq(hif_ctx);
-	QDF_BUG(!status);
-done:
-	hdd_err("suspend_noirq done, status = %d", err);
-	return err;
-}
-
-/**
- * wlan_hdd_bus_suspend_noirq() - handle .suspend_noirq callback
- *
- * This function is called by the platform driver to complete the
- * bus suspend callback when device interrupts are disabled by kernel.
- * Call HIF and WMA suspend_noirq callbacks to make sure there is no
- * wake up pending from FW before allowing suspend.
- *
- * Return: 0 for success and -EBUSY if FW is requesting wake up
- */
-int wlan_hdd_bus_suspend_noirq(void)
-{
-	int ret;
-
-	cds_ssr_protect(__func__);
-	ret = __wlan_hdd_bus_suspend_noirq();
-	cds_ssr_unprotect(__func__);
-
-	return ret;
-}
-
-/**
  * __wlan_hdd_bus_resume() - handles platform resume
  *
  * Does precondtion validation. Ensures that a subsystem restart isn't in
@@ -724,63 +660,6 @@
 }
 
 /**
- * __wlan_hdd_bus_resume_noirq(): handle bus resume no irq
- *
- * This function is called by the platform driver to do bus
- * resume no IRQ before calling resume callback. Call WMA and HIF
- * layers to complete the resume_noirq.
- *
- * Return: 0 for success and negative error code for failure
- */
-int __wlan_hdd_bus_resume_noirq(void)
-{
-	hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	void *hif_ctx;
-	int status = wlan_hdd_validate_context(hdd_ctx);
-
-	if (status)
-		return status;
-
-	if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) {
-		hdd_info("Driver Module closed return success");
-		return 0;
-	}
-
-	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
-	if (NULL == hif_ctx)
-		return -EINVAL;
-
-	status = wma_clear_target_wake_up();
-	QDF_BUG(!status);
-
-	status = hif_bus_resume_noirq(hif_ctx);
-	QDF_BUG(!status);
-
-	hdd_err("resume_noirq done");
-	return status;
-}
-
-/**
- * wlan_hdd_bus_resume_noirq(): handle bus resume no irq
- *
- * This function is called by the platform driver to do bus
- * resume no IRQ before calling resume callback. Call WMA and HIF
- * layers to complete the resume_noirq.
- *
- * Return: 0 for success and negative error code for failure
- */
-int wlan_hdd_bus_resume_noirq(void)
-{
-	int ret;
-
-	cds_ssr_protect(__func__);
-	ret = __wlan_hdd_bus_resume_noirq();
-	cds_ssr_unprotect(__func__);
-
-	return ret;
-}
-
-/**
  * wlan_hdd_bus_reset_resume() - resume wlan bus after reset
  *
  * This function is called to tell the driver that the device has been resumed
@@ -1042,45 +921,6 @@
 	return wlan_hdd_bus_resume();
 }
 
-
-/**
- * wlan_hdd_pld_suspend_noirq() - handle suspend no irq
- * @dev: device
- * @pld_bus_type: PLD bus type
- *
- * Complete the actions started by suspend().  Carry out any
- * additional operations required for suspending the device that might be
- * racing with its driver's interrupt handler, which is guaranteed not to
- * run while suspend_noirq() is being executed. Make sure to resume device
- * if FW has sent initial wake up message and expecting APPS to wake up.
- *
- * Return: 0 on success
- */
-static int wlan_hdd_pld_suspend_noirq(struct device *dev,
-		     enum pld_bus_type bus_type)
-{
-	return wlan_hdd_bus_suspend_noirq();
-}
-
-/**
- * wlan_hdd_pld_resume_noirq() - handle resume no irq
- * @dev: device
- * @pld_bus_type: PLD bus type
- *
- * Prepare for the execution of resume() by carrying out any
- * operations required for resuming the device that might be racing with
- * its driver's interrupt handler, which is guaranteed not to run while
- * resume_noirq() is being executed. Make sure to clear target initial
- * wake up request such that next suspend can happen cleanly.
- *
- * Return: 0 on success
- */
-static int wlan_hdd_pld_resume_noirq(struct device *dev,
-		    enum pld_bus_type bus_type)
-{
-	return wlan_hdd_bus_resume_noirq();
-}
-
 /**
  * wlan_hdd_pld_reset_resume() - reset resume function registered to PLD
  * @dev: device
@@ -1145,8 +985,6 @@
 	.crash_shutdown = wlan_hdd_pld_crash_shutdown,
 	.suspend    = wlan_hdd_pld_suspend,
 	.resume     = wlan_hdd_pld_resume,
-	.suspend_noirq = wlan_hdd_pld_suspend_noirq,
-	.resume_noirq  = wlan_hdd_pld_resume_noirq,
 	.reset_resume = wlan_hdd_pld_reset_resume,
 	.modem_status = wlan_hdd_pld_notify_handler,
 #ifdef FEATURE_RUNTIME_PM
diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c
index 53cb64c..c44ef12 100644
--- a/core/hdd/src/wlan_hdd_tdls.c
+++ b/core/hdd/src/wlan_hdd_tdls.c
@@ -4057,9 +4057,9 @@
 					 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
 
 	if ((0 == rc) || (true != pAdapter->mgmtTxCompletionStatus)) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-			  "%s: Mgmt Tx Completion timed out TxCompletion %u",
-			  __func__, pAdapter->mgmtTxCompletionStatus);
+		hdd_err("%s rc %ld mgmtTxCompletionStatus %u",
+			!rc ? "Mgmt Tx Completion timed out" : "Mgmt Tx Completion failed",
+			rc, pAdapter->mgmtTxCompletionStatus);
 
 		if (cds_is_driver_recovering()) {
 			hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
diff --git a/core/mac/inc/ani_global.h b/core/mac/inc/ani_global.h
index 3058535..00e03c0 100644
--- a/core/mac/inc/ani_global.h
+++ b/core/mac/inc/ani_global.h
@@ -815,6 +815,7 @@
 	qdf_mutex_t lim_frame_register_lock;
 	qdf_list_t gLimMgmtFrameRegistratinQueue;
 	uint32_t mgmtFrameSessionId;
+	uint32_t tdls_frm_session_id;
 
 	tpPESession pSessionEntry;
 	uint8_t reAssocRetryAttempt;
diff --git a/core/mac/inc/qwlan_version.h b/core/mac/inc/qwlan_version.h
index c454c7f..87a2d64 100644
--- a/core/mac/inc/qwlan_version.h
+++ b/core/mac/inc/qwlan_version.h
@@ -41,9 +41,9 @@
 #define QWLAN_VERSION_MAJOR            5
 #define QWLAN_VERSION_MINOR            1
 #define QWLAN_VERSION_PATCH            0
-#define QWLAN_VERSION_EXTRA            "S"
+#define QWLAN_VERSION_EXTRA            "X"
 #define QWLAN_VERSION_BUILD            25
 
-#define QWLAN_VERSIONSTR               "5.1.0.25S"
+#define QWLAN_VERSIONSTR               "5.1.0.25X"
 
 #endif /* QWLAN_VERSION_H */
diff --git a/core/mac/src/include/parser_api.h b/core/mac/src/include/parser_api.h
index 495e86a..1b1486e 100644
--- a/core/mac/src/include/parser_api.h
+++ b/core/mac/src/include/parser_api.h
@@ -757,7 +757,8 @@
 tSirRetStatus
 populate_dot11f_rates_tdls(tpAniSirGlobal p_mac,
 			tDot11fIESuppRates *p_supp_rates,
-			tDot11fIEExtSuppRates *p_ext_supp_rates);
+			tDot11fIEExtSuppRates *p_ext_supp_rates,
+			uint8_t curr_oper_channel);
 
 tSirRetStatus populate_dot11f_tpc_report(tpAniSirGlobal pMac,
 					tDot11fIETPCReport *pDot11f,
diff --git a/core/mac/src/pe/lim/lim_api.c b/core/mac/src/pe/lim/lim_api.c
index e343db8..426f622 100644
--- a/core/mac/src/pe/lim/lim_api.c
+++ b/core/mac/src/pe/lim/lim_api.c
@@ -726,6 +726,7 @@
 		    sizeof(tPESession) * pMac->lim.maxBssId, 0);
 
 	pMac->lim.mgmtFrameSessionId = 0xff;
+	pMac->lim.tdls_frm_session_id = NO_SESSION;
 	pMac->lim.deferredMsgCnt = 0;
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(&pMac->lim.lkPeGlobalLock))) {
diff --git a/core/mac/src/pe/lim/lim_process_beacon_frame.c b/core/mac/src/pe/lim/lim_process_beacon_frame.c
index 7422049..b7546b2 100644
--- a/core/mac/src/pe/lim/lim_process_beacon_frame.c
+++ b/core/mac/src/pe/lim/lim_process_beacon_frame.c
@@ -143,11 +143,16 @@
 				eLIM_MLM_WT_PROBE_RESP_STATE) ||
 		(mac_ctx->lim.gLimMlmState ==
 				eLIM_MLM_PASSIVE_SCAN_STATE)) {
-		lim_check_and_add_bss_description(mac_ctx, bcn_ptr,
-			rx_pkt_info,
-			((mac_ctx->lim.gLimHalScanState ==
-			      eLIM_HAL_SCANNING_STATE) ? true : false),
-			      false);
+		/* If we are scanning for P2P, only accept probe rsp */
+		if ((mac_ctx->lim.gLimHalScanState !=
+		    eLIM_HAL_SCANNING_STATE) ||
+		    (NULL == mac_ctx->lim.gpLimMlmScanReq) ||
+		    !mac_ctx->lim.gpLimMlmScanReq->p2pSearch)
+			lim_check_and_add_bss_description(mac_ctx, bcn_ptr,
+				rx_pkt_info,
+				((mac_ctx->lim.gLimHalScanState ==
+				 eLIM_HAL_SCANNING_STATE) ? true : false),
+				false);
 		/*
 		 * Calling dfsChannelList which will convert DFS channel
 		 * to active channel for x secs if this channel is DFS
@@ -237,9 +242,13 @@
 
 		if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) ||
 		    (pMac->lim.gLimMlmState == eLIM_MLM_PASSIVE_SCAN_STATE)) {
-			lim_check_and_add_bss_description(pMac, pBeacon,
-							  pRxPacketInfo, true,
-							  false);
+			/*If we are scanning for P2P, only accept probe rsp */
+			if ((pMac->lim.gLimHalScanState !=
+			    eLIM_HAL_SCANNING_STATE) ||
+			    (NULL == pMac->lim.gpLimMlmScanReq) ||
+			    !pMac->lim.gpLimMlmScanReq->p2pSearch)
+				lim_check_and_add_bss_description(pMac, pBeacon,
+					pRxPacketInfo, true, false);
 			/* Calling dfsChannelList which will convert DFS channel
 			 * to Active channel for x secs if this channel is DFS channel */
 			lim_set_dfs_channel_list(pMac, pBeacon->channelNumber,
diff --git a/core/mac/src/pe/lim/lim_process_tdls.c b/core/mac/src/pe/lim/lim_process_tdls.c
index 27dea06..58a0add 100644
--- a/core/mac/src/pe/lim/lim_process_tdls.c
+++ b/core/mac/src/pe/lim/lim_process_tdls.c
@@ -318,25 +318,34 @@
 	return header_offset;
 }
 
-/*
- * TX Complete for Management frames
+/**
+ * lim_mgmt_tdls_tx_complete - callback to indicate Tx completion
+ * @mac_ctx: pointer to mac structure
+ * @tx_complete: indicates tx sucess/failure
+ *
+ * function will be invoked on receiving tx completion indication
+ *
+ * return: success: eHAL_STATUS_SUCCESS failure: eHAL_STATUS_FAILURE
  */
-QDF_STATUS lim_mgmt_tx_complete(tpAniSirGlobal pMac, uint32_t txCompleteSuccess)
+QDF_STATUS lim_mgmt_tdls_tx_complete(tpAniSirGlobal mac_ctx,
+				     uint32_t tx_complete)
 {
-	tpPESession psessionEntry = NULL;
+	tpPESession session_entry = NULL;
 
-	if (0xff != pMac->lim.mgmtFrameSessionId) {
-		psessionEntry =
-			pe_find_session_by_session_id(pMac,
-						      pMac->lim.mgmtFrameSessionId);
-		if (NULL == psessionEntry) {
-			lim_log(pMac, LOGE, FL("sessionID %d is not found"),
-				pMac->lim.mgmtFrameSessionId);
+	lim_log(mac_ctx, LOG1, FL("tdls_frm_session_id %x tx_complete %x"),
+		mac_ctx->lim.tdls_frm_session_id, tx_complete);
+
+	if (NO_SESSION != mac_ctx->lim.tdls_frm_session_id) {
+		session_entry = pe_find_session_by_session_id(mac_ctx,
+					mac_ctx->lim.tdls_frm_session_id);
+		if (!session_entry) {
+			lim_log(mac_ctx, LOGE, FL("session id %d is not found"),
+				mac_ctx->lim.tdls_frm_session_id);
 			return QDF_STATUS_E_FAILURE;
 		}
-		lim_send_sme_mgmt_tx_completion(pMac, psessionEntry,
-						txCompleteSuccess);
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		lim_send_sme_mgmt_tx_completion(mac_ctx, session_entry,
+						tx_complete);
+		mac_ctx->lim.tdls_frm_session_id = NO_SESSION;
 	}
 	return QDF_STATUS_SUCCESS;
 }
@@ -510,17 +519,17 @@
 		lim_trace_tdls_action_string(SIR_MAC_TDLS_DIS_REQ),
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 	qdf_status = wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
 					      TXRX_FRM_802_11_DATA,
 					      ANI_TXDIR_TODS,
 					      TID_AC_VI,
 					      lim_tx_complete, pFrame,
-					      lim_mgmt_tx_complete,
+					      lim_mgmt_tdls_tx_complete,
 					      HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME,
 					      smeSessionId, false, 0);
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Discovery Request frame"));
 		return eSIR_FAILURE;
@@ -698,8 +707,9 @@
 
 	/* populate supported rate and ext supported rate IE */
 	if (eSIR_FAILURE == populate_dot11f_rates_tdls(pMac,
-						&tdlsDisRsp.SuppRates,
-						&tdlsDisRsp.ExtSuppRates))
+					&tdlsDisRsp.SuppRates,
+					&tdlsDisRsp.ExtSuppRates,
+					psessionEntry->currentOperChannel))
 		lim_log(pMac, LOGE,
 			FL("could not populate supported data rates"));
 
@@ -827,7 +837,7 @@
 		lim_trace_tdls_action_string(SIR_MAC_TDLS_DIS_RSP),
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 	/*
 	 * Transmit Discovery response and watch if this is delivered to
 	 * peer STA.
@@ -841,11 +851,11 @@
 					      ANI_TXDIR_IBSS,
 					      0,
 					      lim_tx_complete, pFrame,
-					      lim_mgmt_tx_complete,
+					      lim_mgmt_tdls_tx_complete,
 					      HAL_USE_SELF_STA_REQUESTED_MASK,
 					      smeSessionId, false, 0);
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Discovery Response frame!"));
 		return eSIR_FAILURE;
@@ -924,7 +934,7 @@
 					  ANI_TXDIR_TODS,
 					  tid,
 					  lim_tx_complete, pFrame,
-					  lim_mgmt_tx_complete,
+					  lim_mgmt_tdls_tx_complete,
 					  HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME,
 					  smeSessionId, flag, 0);
 }
@@ -943,7 +953,7 @@
 					  ANI_TXDIR_TODS,
 					  tid,
 					  lim_tx_complete, pFrame,
-					  lim_mgmt_tx_complete,
+					  lim_mgmt_tdls_tx_complete,
 					  HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME,
 					  smeSessionId, false, 0);
 }
@@ -1004,8 +1014,9 @@
 
 	/* populate supported rate and ext supported rate IE */
 	if (eSIR_FAILURE == populate_dot11f_rates_tdls(pMac,
-						&tdlsSetupReq.SuppRates,
-						&tdlsSetupReq.ExtSuppRates))
+					&tdlsSetupReq.SuppRates,
+					&tdlsSetupReq.ExtSuppRates,
+					psessionEntry->currentOperChannel))
 		lim_log(pMac, LOGE,
 			FL("could not populate supported data rates"));
 
@@ -1208,7 +1219,7 @@
 		lim_trace_tdls_action_string(SIR_MAC_TDLS_SETUP_REQ),
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1217,7 +1228,7 @@
 						     smeSessionId, true);
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Setup Request frame!"));
 		return eSIR_FAILURE;
@@ -1407,7 +1418,7 @@
 		    "DIRECT"),
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1418,7 +1429,7 @@
 						     ? true : false);
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Teardown frame"));
 		return eSIR_FAILURE;
@@ -1491,8 +1502,9 @@
 
 	/* populate supported rate and ext supported rate IE */
 	if (eSIR_FAILURE == populate_dot11f_rates_tdls(pMac,
-						&tdlsSetupRsp.SuppRates,
-						&tdlsSetupRsp.ExtSuppRates))
+					&tdlsSetupRsp.SuppRates,
+					&tdlsSetupRsp.ExtSuppRates,
+					psessionEntry->currentOperChannel))
 		lim_log(pMac, LOGE,
 			FL("could not populate supported data rates"));
 
@@ -1684,7 +1696,7 @@
 		lim_trace_tdls_action_string(SIR_MAC_TDLS_SETUP_RSP),
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1693,7 +1705,7 @@
 						     smeSessionId, true);
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Dis Request frame!"));
 		return eSIR_FAILURE;
@@ -1901,7 +1913,7 @@
 		lim_trace_tdls_action_string(SIR_MAC_TDLS_SETUP_CNF),
 	       MAC_ADDR_ARRAY(peer_mac.bytes));
 
-	pMac->lim.mgmtFrameSessionId = psessionEntry->peSessionId;
+	pMac->lim.tdls_frm_session_id = psessionEntry->peSessionId;
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1910,7 +1922,7 @@
 						     smeSessionId, true);
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-		pMac->lim.mgmtFrameSessionId = 0xff;
+		pMac->lim.tdls_frm_session_id = NO_SESSION;
 		lim_log(pMac, LOGE,
 			FL("could not send TDLS Setup Confirm frame"));
 		return eSIR_FAILURE;
diff --git a/core/mac/src/pe/lim/lim_scan_result_utils.c b/core/mac/src/pe/lim/lim_scan_result_utils.c
index 65796e0..dc65b8d 100644
--- a/core/mac/src/pe/lim/lim_scan_result_utils.c
+++ b/core/mac/src/pe/lim/lim_scan_result_utils.c
@@ -70,7 +70,7 @@
  *
  * @return None
  */
-QDF_STATUS
+void
 lim_collect_bss_description(tpAniSirGlobal pMac,
 			    tSirBssDescription *pBssDescr,
 			    tpSirProbeRespBeacon pBPR,
@@ -88,7 +88,7 @@
 	if (SIR_MAC_B_PR_SSID_OFFSET > WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo)) {
 		QDF_ASSERT(WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >=
 			   SIR_MAC_B_PR_SSID_OFFSET);
-		return QDF_STATUS_E_FAILURE;
+		return;
 	}
 	ieLen =
 		WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET;
@@ -229,7 +229,7 @@
 		FL("Collected BSS Description for Channel(%1d), length(%u), IE Fields(%u)"),
 		pBssDescr->channelId, pBssDescr->length, ieLen);
 
-	return QDF_STATUS_SUCCESS;
+	return;
 } /*** end lim_collect_bss_description() ***/
 
 /**
@@ -389,10 +389,8 @@
 		return;
 	}
 	/* In scan state, store scan result. */
-	status = lim_collect_bss_description(mac_ctx, bssdescr,
-					     bpr, rx_packet_info, scanning);
-	if (QDF_STATUS_SUCCESS != status)
-		goto last;
+	lim_collect_bss_description(mac_ctx, bssdescr, bpr, rx_packet_info,
+				    scanning);
 	bssdescr->fProbeRsp = fProbeRsp;
 
 	/*
@@ -406,8 +404,6 @@
 			FL("No CSR callback routine to send beacons"));
 		status = QDF_STATUS_E_INVAL;
 	}
-last:
 	qdf_mem_free(bssdescr);
-	return;
 }
 
diff --git a/core/mac/src/pe/lim/lim_scan_result_utils.h b/core/mac/src/pe/lim/lim_scan_result_utils.h
index 4548d28..0b55f17 100644
--- a/core/mac/src/pe/lim/lim_scan_result_utils.h
+++ b/core/mac/src/pe/lim/lim_scan_result_utils.h
@@ -46,7 +46,7 @@
 void lim_copy_scan_result(tpAniSirGlobal, uint8_t *);
 void lim_check_and_add_bss_description(tpAniSirGlobal, tpSirProbeRespBeacon,
 				       uint8_t *, bool, uint8_t);
-QDF_STATUS lim_collect_bss_description(tpAniSirGlobal pMac,
+void lim_collect_bss_description(tpAniSirGlobal pMac,
 			    tSirBssDescription *pBssDescr,
 			    tpSirProbeRespBeacon pBPR,
 			    uint8_t *pRxPacketInfo, uint8_t fScanning);
diff --git a/core/mac/src/sys/legacy/src/utils/src/parser_api.c b/core/mac/src/sys/legacy/src/utils/src/parser_api.c
index 4339fec..a213331 100644
--- a/core/mac/src/sys/legacy/src/utils/src/parser_api.c
+++ b/core/mac/src/sys/legacy/src/utils/src/parser_api.c
@@ -1770,6 +1770,7 @@
  * @p_mac gloabl - header.
  * @p_supp_rates - pointer to supported rates IE
  * @p_ext_supp_rates - pointer to extended supported rates IE
+ * @curr_oper_channel - current operating channel
  *
  * This function populates the supported rates and extended supported
  * rates IE based in the STA capability. If the number of rates
@@ -1783,7 +1784,8 @@
 tSirRetStatus
 populate_dot11f_rates_tdls(tpAniSirGlobal p_mac,
 			   tDot11fIESuppRates *p_supp_rates,
-			   tDot11fIEExtSuppRates *p_ext_supp_rates)
+			   tDot11fIEExtSuppRates *p_ext_supp_rates,
+			   uint8_t curr_oper_channel)
 {
 	tSirMacRateSet temp_rateset;
 	tSirMacRateSet temp_rateset2;
@@ -1793,15 +1795,23 @@
 	wlan_cfg_get_int(p_mac, WNI_CFG_DOT11_MODE, &self_dot11mode);
 
 	/**
-	* Include 11b rates only when the device configured in
-	 * auto, 11a/b/g or 11b_only
+	 * Include 11b rates only when the device configured in
+	 * auto, 11a/b/g or 11b_only and also if current base
+	 * channel is 5 GHz then no need to advertise the 11b rates.
+	 * If devices move to 2.4GHz off-channel then they can communicate
+	 * in 11g rates i.e. (6, 9, 12, 18, 24, 36 and 54).
 	 */
-	if ((self_dot11mode == WNI_CFG_DOT11_MODE_ALL) ||
+	lim_log(p_mac, LOG1,
+		FL("Current operating channel %d self_dot11mode = %d"),
+		curr_oper_channel, self_dot11mode);
+
+	if ((curr_oper_channel <= SIR_11B_CHANNEL_END) &&
+	    ((self_dot11mode == WNI_CFG_DOT11_MODE_ALL) ||
 	    (self_dot11mode == WNI_CFG_DOT11_MODE_11A) ||
 	    (self_dot11mode == WNI_CFG_DOT11_MODE_11AC) ||
 	    (self_dot11mode == WNI_CFG_DOT11_MODE_11N) ||
 	    (self_dot11mode == WNI_CFG_DOT11_MODE_11G) ||
-	    (self_dot11mode == WNI_CFG_DOT11_MODE_11B)) {
+	    (self_dot11mode == WNI_CFG_DOT11_MODE_11B))) {
 		val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
 		wlan_cfg_get_str(p_mac, WNI_CFG_SUPPORTED_RATES_11B,
 				(uint8_t *)&temp_rateset.rate, &val);
diff --git a/core/sap/dfs/src/dfs_process_phyerr.c b/core/sap/dfs/src/dfs_process_phyerr.c
index 9189d58..5290a70 100644
--- a/core/sap/dfs/src/dfs_process_phyerr.c
+++ b/core/sap/dfs/src/dfs_process_phyerr.c
@@ -463,7 +463,7 @@
 	 * Print the final line if we didn't print it above.
 	 */
 	if (n != 0)
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, "%s: %s\n",
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, "%s: %s",
 			  __func__, buf);
 #endif /* def CONFIG_ENABLE_DUMP_PHYERR_CONTENTS */
 }
@@ -481,7 +481,7 @@
 
 	if (dfs == NULL) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: sc_dfs is NULL\n", __func__);
+			  "%s: sc_dfs is NULL", __func__);
 		return;
 	}
 
@@ -509,8 +509,8 @@
 		dump_phyerr_contents(buf, datalen);
 
 	if (chan == NULL) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: chan is NULL\n", __func__);
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
+			  "%s: chan is NULL", __func__);
 		return;
 	}
 
@@ -561,7 +561,7 @@
 					      enable_log) == 0) {
 			dfs->dfs_phyerr_reject_count++;
 			QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
-				  "%s:Rejected phyerr count after parsing=%d\n",
+				  "%s:Rejected phyerr count after parsing=%d",
 				  __func__, dfs->dfs_phyerr_reject_count);
 			return;
 		} else {
@@ -592,7 +592,7 @@
 	}
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
-		  "\n %s: Frequency at which the phyerror was injected = %d",
+		  "%s: Frequency at which the phyerror was injected = %d",
 		  __func__, e.freq);
 	/*
 	 * If the hardware supports radar reporting on the extension channel
diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c
index 1c9a610..a40e7bf 100644
--- a/core/sme/src/csr/csr_api_roam.c
+++ b/core/sme/src/csr/csr_api_roam.c
@@ -10295,7 +10295,7 @@
 	cmd = qdf_mem_malloc(sizeof(*cmd));
 	if (NULL == cmd) {
 		sms_log(mac_ctx, LOGE,
-			FL("memory allocation failed for size = %ld"),
+			FL("memory allocation failed for size = %zu"),
 			sizeof(*cmd));
 		return;
 	}
diff --git a/core/wma/inc/wma_api.h b/core/wma/inc/wma_api.h
index a63db28..1bc33af 100644
--- a/core/wma/inc/wma_api.h
+++ b/core/wma/inc/wma_api.h
@@ -146,7 +146,6 @@
 int wma_runtime_resume(void);
 int wma_bus_suspend(void);
 int wma_is_target_wake_up_received(void);
-int wma_clear_target_wake_up(void);
 QDF_STATUS wma_suspend_target(WMA_HANDLE handle, int disable_target_intr);
 void wma_target_suspend_acknowledge(void *context, bool wow_nack);
 void wma_handle_initial_wake_up(void);
diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c
index bdb4363..f6c73a2 100644
--- a/core/wma/src/wma_features.c
+++ b/core/wma/src/wma_features.c
@@ -6625,30 +6625,9 @@
 	if (wma->wow_initial_wake_up) {
 		WMA_LOGE("Target initial wake up received try again");
 		return -EAGAIN;
+	} else {
+		return 0;
 	}
-
-	return 0;
-}
-
-/**
- * wma_clear_target_wake_up() - clear initial wake up
- *
- * Clear target initial wake up reason
- *
- * Return: 0 for success and negative error code for failure
- */
-int wma_clear_target_wake_up(void)
-{
-	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
-
-	if (NULL == wma) {
-		WMA_LOGE("%s: wma is NULL", __func__);
-		return -EFAULT;
-	}
-
-	wma->wow_initial_wake_up = false;
-
-	return 0;
 }
 
 /**
diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c
index bfeeeeb..9de21c4 100644
--- a/core/wma/src/wma_scan_roam.c
+++ b/core/wma/src/wma_scan_roam.c
@@ -2947,7 +2947,8 @@
 	params = qdf_mem_malloc(sizeof(struct pno_scan_req_params));
 	if (params == NULL) {
 		WMA_LOGE("%s : Memory allocation failed", __func__);
-		return QDF_STATUS_E_NOMEM;
+		status = QDF_STATUS_E_NOMEM;
+		goto exit_pno_start;
 	}
 
 	params->enable = pno->enable;
@@ -2991,17 +2992,17 @@
 
 	status = wmi_unified_pno_start_cmd(wma->wmi_handle,
 					params, channel_list);
-	if (QDF_IS_STATUS_ERROR(status)) {
-		qdf_mem_free(channel_list);
-		return status;
+	if (QDF_IS_STATUS_SUCCESS(status)) {
+		wma->interfaces[pno->sessionId].pno_in_progress = true;
+		WMA_LOGD("PNO start request sent successfully for vdev %d",
+			 pno->sessionId);
 	}
 
-	qdf_mem_free(channel_list);
-	wma->interfaces[pno->sessionId].pno_in_progress = true;
-
-	WMA_LOGD("PNO start request sent successfully for vdev %d",
-		 pno->sessionId);
-
+exit_pno_start:
+	if (channel_list)
+		qdf_mem_free(channel_list);
+	if (params)
+		qdf_mem_free(params);
 	return status;
 }