prima: Don't request tdls offchannel if peer doesn't support the channel

If tdls peer does not support the requested tdls off channel do not
initiate tdls channel switch request.

CRs-Fixed: 822721
Change-Id: I23ca198ca16ecc881be4862f81aee081a2b9197d
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 6a97a9b..d436e41 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -15162,6 +15162,7 @@
                 WLAN_STADescType         staDesc;
                 tANI_U16 numCurrTdlsPeers = 0;
                 hddTdlsPeer_t *connPeer = NULL;
+                tANI_U8 suppChannelLen = 0;
 
                 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
                 memset(&staDesc, 0, sizeof(staDesc));
@@ -15291,6 +15292,40 @@
                             }
                         }
 
+                        suppChannelLen =
+                               tdlsLinkEstablishParams.supportedChannelsLen;
+                        if  ((TRUE == pTdlsPeer->isOffChannelSupported) &&
+                             (TRUE == pTdlsPeer->isOffChannelConfigured) &&
+                             (suppChannelLen > 0) &&
+                             (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
+                        {
+                            int offChan =  pTdlsPeer->peerParams.channel;
+                            int i = 0;
+                            for (i = 0U; i < suppChannelLen; i++)
+                            {
+                                pTdlsPeer->isOffChannelConfigured = FALSE;
+                                if (
+                                   (tdlsLinkEstablishParams.supportedChannels[i]
+                                    <= offChan) &&
+                                   (tdlsLinkEstablishParams.supportedChannels[i]
+                                    == offChan))
+                                {
+                                    pTdlsPeer->isOffChannelConfigured = TRUE;
+                                    break;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            pTdlsPeer->isOffChannelConfigured = FALSE;
+                        }
+                        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
+                                  "%s: TDLS channel switch request for channel "
+                                  "%d isOffChannelConfigured %d suppChannelLen "
+                                  "%d", __func__, pTdlsPeer->peerParams.channel,
+                                  pTdlsPeer->isOffChannelConfigured,
+                                  suppChannelLen);
+
                         /* TDLS Off Channel, Enable tdls channel switch,
                            when their is only one tdls link and it supports */
                         numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);