wlan: Limit the BW of new channel to original BW during ECSA

During ECSA switch, limit the channel BW to the original BW
to which the SAP was started. So device should not set BW
greater than the original BW.

Change-Id: Id8bb45bccd61df224bc12ab3b7ac05d483120bd9
CRs-Fixed: 2143138
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index d4c33a8..4a3a936 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -14480,7 +14480,7 @@
         /* This call decides required channel bonding mode */
         sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
                      hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
-                     operationChannel);
+                     operationChannel, eHT_MAX_CHANNEL_WIDTH);
     }
 }
 
diff --git a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
index 48be67b..90f0f40 100644
--- a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
@@ -5781,6 +5781,7 @@
    uint8_t session_id;      /* PE session_id */
    int8_t max_tx_pwr;
    uint32_t val = 0;
+   uint8_t cb_mode;
 
    if (!msg_buf) {
        limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
@@ -5820,15 +5821,55 @@
    session_entry->channelChangeReasonCode =
                           LIM_SWITCH_CHANNEL_SAP_ECSA;
 
-   limLog(mac_ctx, LOGE, FL("switch old chnl %d to new chnl %d, cb_mode %d"),
+   limLog(mac_ctx, LOG1, FL("switch old chnl %d to new chnl %d, cb_mode %d"),
           session_entry->currentOperChannel,
           ch_change_req->new_chan,
           ch_change_req->cb_mode);
 
+   cb_mode = ch_change_req->cb_mode;
+
+   if (session_entry->vhtCapability) {
+       if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
+           session_entry->vhtTxChannelWidthSet =
+                                    WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
+           session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
+           /*
+            * In case of DFS operation, If AP falls back to lower
+            * bandwidth [< 80Mhz] then there is no need of
+            * Center freq segment. So reset it to zero.
+            */
+           if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, 0)
+              != eSIR_SUCCESS)
+              limLog(mac_ctx, LOGE,
+                     FL("couldn't set center freq seg 0 in beacon"));
+           if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
+                         WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) != eSIR_SUCCESS)
+               limLog(mac_ctx, LOGE, FL("could not set channel width to 20/40 in CFG"));
+           session_entry->apCenterChan = 0;
+       } else {
+           uint32_t center_chan;
+
+           session_entry->vhtTxChannelWidthSet =
+                                     WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
+           session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
+           center_chan = limGetCenterChannel(mac_ctx, ch_change_req->new_chan,
+                                 cb_mode, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
+           limLog(mac_ctx, LOGW,
+                  FL("***Center Channel for 80MHZ channel width = %d"),
+                  center_chan);
+           session_entry->apCenterChan = center_chan;
+           if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
+               center_chan) != eSIR_SUCCESS)
+                limLog(mac_ctx, LOGE, FL("could not set center freq seg 0 in beacon"));
+           if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
+                         WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) != eSIR_SUCCESS)
+               limLog(mac_ctx, LOGE, FL("could not set channel width to 80 in CFG"));
+       }
+   }
+
    /* Store the New Channel Params in session_entry */
-   session_entry->htSecondaryChannelOffset =
-                         limGetHTCBState(ch_change_req->cb_mode);
-   session_entry->htSupportedChannelWidthSet = (ch_change_req->cb_mode ? 1 : 0);
+   session_entry->htSecondaryChannelOffset = limGetHTCBState(cb_mode);
+   session_entry->htSupportedChannelWidthSet = (cb_mode ? 1 : 0);
    session_entry->htRecommendedTxWidthSet =
                                    session_entry->htSupportedChannelWidthSet;
    session_entry->currentOperChannel = ch_change_req->new_chan;
diff --git a/CORE/SAP/src/sapApiLinkCntl.c b/CORE/SAP/src/sapApiLinkCntl.c
index 34cc975..33bd851 100644
--- a/CORE/SAP/src/sapApiLinkCntl.c
+++ b/CORE/SAP/src/sapApiLinkCntl.c
@@ -280,7 +280,8 @@
     sapPhyMode =
         sapConvertSapPhyModeToCsrPhyMode(sapContext->csrRoamProfile.phyMode);
 
-    sme_SelectCBMode(hHal, sapPhyMode, sapContext->channel);
+    sme_SelectCBMode(hHal, sapPhyMode,
+                     sapContext->channel, eHT_MAX_CHANNEL_WIDTH);
 
     cbMode = sme_GetChannelBondingMode24G(hHal);
 
@@ -710,7 +711,8 @@
     sapPhyMode =
      sapConvertSapPhyModeToCsrPhyMode(psapCtx->csrRoamProfile.phyMode);
 
-    sme_SelectCBMode(halHandle, sapPhyMode, psapCtx->channel);
+    sme_SelectCBMode(halHandle, sapPhyMode,
+                     psapCtx->channel, eHT_MAX_CHANNEL_WIDTH);
 
     cbMode = sme_GetChannelBondingMode24G(halHandle);
 
@@ -1108,7 +1110,8 @@
 #ifdef WLAN_FEATURE_AP_HT40_24G
     if (psapContext->channel > SIR_11B_CHANNEL_END)
 #endif
-        sme_SelectCBMode(halHandle, sapPhyMode, psapContext->channel);
+        sme_SelectCBMode(halHandle, sapPhyMode,
+                         psapContext->channel, eHT_MAX_CHANNEL_WIDTH);
 
 #ifdef SOFTAP_CHANNEL_RANGE
     if(psapContext->channelList != NULL)
diff --git a/CORE/SAP/src/sapFsm.c b/CORE/SAP/src/sapFsm.c
index be18ea4..26ffc7a 100644
--- a/CORE/SAP/src/sapFsm.c
+++ b/CORE/SAP/src/sapFsm.c
@@ -286,7 +286,8 @@
 #ifdef WLAN_FEATURE_AP_HT40_24G
             if (sapContext->channel > SIR_11B_CHANNEL_END)
 #endif
-                sme_SelectCBMode(hHal, sapPhyMode, sapContext->channel);
+                sme_SelectCBMode(hHal, sapPhyMode,
+                                 sapContext->channel, eHT_MAX_CHANNEL_WIDTH);
         }
     }
 
@@ -512,7 +513,8 @@
 selectChannelBonding:
             if (sapContext->channel > SIR_11B_CHANNEL_END)
 #endif
-                sme_SelectCBMode(hHal, sapPhyMode, sapContext->channel);
+                sme_SelectCBMode(hHal, sapPhyMode,
+                                 sapContext->channel, eHT_MAX_CHANNEL_WIDTH);
 
             /* Fill in the event structure */
             // Eventhough scan was not done, means a user set channel was chosen
@@ -1007,7 +1009,8 @@
    sapContext->csrRoamProfile.ChannelInfo.ChannelList[0] = sapContext->channel;
    vos_status = sme_roam_channel_change_req(hal, sapContext->bssid,
                                sapContext->ecsa_info.new_channel,
-                               &sapContext->csrRoamProfile);
+                               &sapContext->csrRoamProfile,
+                               sapContext->sessionId);
    return vos_status;
 }
 
@@ -1216,7 +1219,8 @@
                 }
                 vosStatus = sme_roam_csa_ie_request(hHal, sapContext->bssid,
                                         sapContext->ecsa_info.new_channel,
-                                        sapContext->csrRoamProfile.phyMode);
+                                        sapContext->csrRoamProfile.phyMode,
+                                        sapContext->sessionId);
             }
             else
             {
diff --git a/CORE/SME/inc/csrInternal.h b/CORE/SME/inc/csrInternal.h
index 3d1fff6..dbb5355 100644
--- a/CORE/SME/inc/csrInternal.h
+++ b/CORE/SME/inc/csrInternal.h
@@ -367,6 +367,7 @@
     tCsrBssid           bssid;    //this is the BSSID for the party we want to join (only use for IBSS or WDS)
     tSirNwType          sirNwType;
     ePhyChanBondState   cbMode;
+    enum eSirMacHTChannelWidth orig_ch_width;
     tSirMacRateSet      operationalRateSet;
     tSirMacRateSet      extendedRateSet;
     tANI_U8             operationChn;
diff --git a/CORE/SME/inc/sme_Api.h b/CORE/SME/inc/sme_Api.h
index a853885..77999c3 100644
--- a/CORE/SME/inc/sme_Api.h
+++ b/CORE/SME/inc/sme_Api.h
@@ -3566,7 +3566,8 @@
 /*
  * SME API to determine the channel bonding mode
  */
-VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode, tANI_U8 channel);
+VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode,
+                            tANI_U8 channel, enum eSirMacHTChannelWidth max_bw);
 
 #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
 /*--------------------------------------------------------------------------
@@ -4015,11 +4016,13 @@
  * @bssid: SAP bssid
  * @new_chan: target channel information
  * @phy_mode: SAP phymode
+ * @sme_session_id: sme session id
  *
  * Return: VOS_STATUS
  */
 VOS_STATUS sme_roam_csa_ie_request(tHalHandle hal, tCsrBssid bssid,
-                                   uint8_t new_chan, uint32_t phy_mode);
+                                   uint8_t new_chan, uint32_t phy_mode,
+                                   uint8_t sme_session_id);
 
 /**
  * sme_roam_channel_change_req() - Channel change to new target channel
@@ -4027,13 +4030,15 @@
  * @bssid: SAP bssid
  * @new_chan: target channel information
  * @profile: roam profile
+ * @sme_session_id: sme session id
  *
  * API to Indicate Channel change to new target channel
  *
  * Return: VOS_STATUS
  */
 VOS_STATUS sme_roam_channel_change_req(tHalHandle hal, tCsrBssid bssid,
-                                   uint8_t new_chan, tCsrRoamProfile *profile);
+                                   uint8_t new_chan, tCsrRoamProfile *profile,
+                                   uint8_t sme_session_id);
 
 
 #endif //#if !defined( __SME_API_H )
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index b06ffb4..4985863 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -12633,9 +12633,16 @@
             {
                 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
             }
-            smsLog(pMac, LOG1, "## cbMode %d", cbMode);
             pBssConfig->cbMode = cbMode;
             pSession->bssParams.cbMode = cbMode;
+            if (cbMode >= PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
+                pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_80MHZ;
+            else if (cbMode > PHY_SINGLE_CHANNEL_CENTERED)
+                pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_40MHZ;
+            else
+                pSession->bssParams.orig_ch_width = eHT_CHANNEL_WIDTH_20MHZ;
+            smsLog(pMac, LOG1, FL("## cbMode %d orig_width %d"), cbMode,
+                   pSession->bssParams.orig_ch_width);
         }
     }
 }
diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c
index 6d523a3..9703d37 100644
--- a/CORE/SME/src/sme_common/sme_Api.c
+++ b/CORE/SME/src/sme_common/sme_Api.c
@@ -12000,7 +12000,9 @@
 /*
  * SME API to determine the channel bonding mode
  */
-VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode, tANI_U8 channel)
+VOS_STATUS sme_SelectCBMode(tHalHandle hHal,
+                            eCsrPhyMode eCsrPhyMode, tANI_U8 channel,
+                            enum eSirMacHTChannelWidth max_bw)
 {
    tSmeConfigParams  smeConfig;
    tpAniSirGlobal    pMac = PMAC_STRUCT(hHal);
@@ -12038,70 +12040,72 @@
       return VOS_STATUS_SUCCESS;
    }
 
+/* Check if VHT80 is allowed for the channel*/
+   vht80Allowed = vos_is_channel_valid_for_vht80(channel);
 
 #ifdef WLAN_FEATURE_11AC
-   if ( eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
-         eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode )
-   {
-      /* Check if VHT80 is allowed for the channel*/
-      vht80Allowed = vos_is_channel_valid_for_vht80(channel);
+   if ((eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
+        eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
+        vht80Allowed && (max_bw >= eHT_CHANNEL_WIDTH_80MHZ)) {
+      if (channel== 36 || channel == 52 || channel == 100 ||
+                channel == 116 || channel == 149 || channel == 132) {
+          smeConfig.csrConfig.channelBondingMode5GHz =
+                eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
+      } else if (channel == 40 || channel == 56 || channel == 104 ||
+                     channel == 120 || channel == 153 || channel == 136) {
+          smeConfig.csrConfig.channelBondingMode5GHz =
+                eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
+      } else if (channel == 44 || channel == 60 || channel == 108 ||
+                     channel == 124 || channel == 157 || channel == 140) {
+          smeConfig.csrConfig.channelBondingMode5GHz =
+                eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
+      } else if (channel == 48 || channel == 64 || channel == 112 ||
+                     channel == 128 || channel == 144 || channel == 161) {
+          smeConfig.csrConfig.channelBondingMode5GHz =
+                eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
+      } else if (channel == 165) {
+          smeConfig.csrConfig.channelBondingMode5GHz =
+                                     eCSR_INI_SINGLE_CHANNEL_CENTERED;
+      }
 
-      if (vht80Allowed)
+#ifdef WLAN_FEATURE_AP_HT40_24G
+      if (smeConfig.csrConfig.apHT40_24GEnabled &&
+          max_bw >= eHT_CHANNEL_WIDTH_40MHZ)
       {
-         if (channel== 36 || channel == 52 || channel == 100 ||
-              channel == 116 || channel == 149)
-         {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-              eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
-         }
-         else if (channel == 40 || channel == 56 || channel == 104 ||
-              channel == 120 || channel == 153)
-         {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-              eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
-         }
-         else if (channel == 44 || channel == 60 || channel == 108 ||
-            channel == 124 || channel == 157)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-              eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
-        }
-        else if (channel == 48 || channel == 64 || channel == 112 ||
-             channel == 128 || channel == 144 || channel == 161)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-              eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
-        }
-        else if (channel == 165)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-              eCSR_INI_SINGLE_CHANNEL_CENTERED;
-        }
-      }
-      else /* Set VHT40 */
-      {
-        if (channel== 40 || channel == 48 || channel == 56 ||
-            channel == 64 || channel == 104 || channel == 112 ||
-            channel == 120 || channel == 128 || channel == 136 ||
-            channel == 144 || channel == 153 || channel == 161)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
-                eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
-        }
-        else if (channel== 36 || channel == 44 || channel == 52 ||
-            channel == 60 || channel == 100 || channel == 108 ||
-            channel == 116 || channel == 124 || channel == 132 ||
-            channel == 140 || channel == 149 || channel == 157)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
+          if (channel >= 1 && channel <= 7)
+             smeConfig.csrConfig.channelBondingAPMode24GHz =
                 eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
-        }
-        else if (channel == 165)
-        {
-            smeConfig.csrConfig.channelBondingMode5GHz =
+          else if (channel >= 8 && channel <= 13)
+             smeConfig.csrConfig.channelBondingAPMode24GHz =
+                eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
+          else if (channel ==14)
+             smeConfig.csrConfig.channelBondingAPMode24GHz =
                 eCSR_INI_SINGLE_CHANNEL_CENTERED;
-        }
       }
+#endif
+   } else
+#endif
+   if ((eCSR_DOT11_MODE_11n == eCsrPhyMode ||
+        eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode ||
+        eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
+        eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode) &&
+        (max_bw >= eHT_CHANNEL_WIDTH_40MHZ)) {
+       if (channel== 40 || channel == 48 || channel == 56 ||
+                channel == 64 || channel == 104 || channel == 112 ||
+                channel == 120 || channel == 128 || channel == 136 ||
+                channel == 153 || channel == 161 || channel == 144) {
+           smeConfig.csrConfig.channelBondingMode5GHz =
+                                    eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
+       } else if (channel== 36 || channel == 44 || channel == 52 ||
+                channel == 60 || channel == 100 || channel == 108 ||
+                channel == 116 || channel == 124 || channel == 132 ||
+                channel == 149 || channel == 157 || channel == 140) {
+           smeConfig.csrConfig.channelBondingMode5GHz =
+                                        eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
+       } else if (channel == 165) {
+           smeConfig.csrConfig.channelBondingMode5GHz =
+                                            eCSR_INI_SINGLE_CHANNEL_CENTERED;
+       }
 
 #ifdef WLAN_FEATURE_AP_HT40_24G
       if (smeConfig.csrConfig.apHT40_24GEnabled)
@@ -12117,69 +12121,19 @@
                 eCSR_INI_SINGLE_CHANNEL_CENTERED;
       }
 #endif
-   }
-#endif
-
-   if ( eCSR_DOT11_MODE_11n == eCsrPhyMode ||
-         eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode )
-   {
-      if ( channel== 40 || channel == 48 || channel == 56 ||
-            channel == 64 || channel == 104 || channel == 112 ||
-            channel == 120 || channel == 128 || channel == 136 ||
-            channel == 144 || channel == 153 || channel == 161 )
-      {
-         smeConfig.csrConfig.channelBondingMode5GHz =
-                eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
-      }
-      else if ( channel== 36 || channel == 44 || channel == 52 ||
-            channel == 60 || channel == 100 || channel == 108 ||
-            channel == 116 || channel == 124 || channel == 132 ||
-            channel == 140 || channel == 149 || channel == 157 )
-      {
-         smeConfig.csrConfig.channelBondingMode5GHz =
-                eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
-      }
-      else if ( channel == 165 )
-      {
-         smeConfig.csrConfig.channelBondingMode5GHz =
-                eCSR_INI_SINGLE_CHANNEL_CENTERED;
-      }
-
+   } else {
 #ifdef WLAN_FEATURE_AP_HT40_24G
-      if (smeConfig.csrConfig.apHT40_24GEnabled)
-      {
-          if (channel >= 1 && channel <= 7)
-             smeConfig.csrConfig.channelBondingAPMode24GHz =
-                eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
-          else if (channel >= 8 && channel <= 13)
-             smeConfig.csrConfig.channelBondingAPMode24GHz =
-                eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
-          else if (channel ==14)
-             smeConfig.csrConfig.channelBondingAPMode24GHz =
-                eCSR_INI_SINGLE_CHANNEL_CENTERED;
-      }
+       if (CSR_IS_CHANNEL_24GHZ(channel)) {
+           smeConfig.csrConfig.channelBondingMode24GHz =
+                            eCSR_INI_SINGLE_CHANNEL_CENTERED;
+       } else
 #endif
+       {
+           smeConfig.csrConfig.channelBondingMode5GHz =
+                            eCSR_INI_SINGLE_CHANNEL_CENTERED;
+       }
    }
 
-   /*
-      for 802.11a phy mode, channel bonding should be zero.
-      From default config, it is set as PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
-      through csrChangeDefaultConfigParam function. We will override this
-      value here.
-   */
-   if (  eCSR_DOT11_MODE_11a == eCsrPhyMode ||
-         eCSR_DOT11_MODE_11a_ONLY == eCsrPhyMode ||
-         eCSR_DOT11_MODE_abg == eCsrPhyMode)
-   {
-      smeConfig.csrConfig.channelBondingMode5GHz = 0;
-#ifdef WLAN_FEATURE_AP_HT40_24G
-   } else if ( eCSR_DOT11_MODE_11g_ONLY == eCsrPhyMode)
-      smeConfig.csrConfig.channelBondingAPMode24GHz =
-         eCSR_INI_SINGLE_CHANNEL_CENTERED;
-#else
-   }
-#endif
-
    sme_AdjustCBMode(pMac, &smeConfig, channel);
 
 #ifdef WLAN_FEATURE_AP_HT40_24G
@@ -15173,16 +15127,26 @@
 }
 
 VOS_STATUS sme_roam_csa_ie_request(tHalHandle hal, tCsrBssid bssid,
-                                   uint8_t new_chan, uint32_t phy_mode)
+                                   uint8_t new_chan, uint32_t phy_mode,
+                                   uint8_t sme_session_id)
 {
    VOS_STATUS status = VOS_STATUS_E_FAILURE;
    tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
    uint8_t cb_mode = 0;
+   tCsrRoamSession *session;
+
+   session = CSR_GET_SESSION(mac_ctx, sme_session_id);
+
+   if (!session) {
+       smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
+       return VOS_STATUS_E_FAILURE;
+   }
 
    status = sme_AcquireGlobalLock(&mac_ctx->sme);
    if (VOS_IS_STATUS_SUCCESS(status)) {
        if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
-           sme_SelectCBMode(hal, phy_mode, new_chan);
+           sme_SelectCBMode(hal, phy_mode, new_chan,
+                            session->bssParams.orig_ch_width);
            cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
        }
        status = csr_roam_send_chan_sw_ie_request(mac_ctx, bssid,
@@ -15194,16 +15158,26 @@
 
 
 VOS_STATUS sme_roam_channel_change_req(tHalHandle hal, tCsrBssid bssid,
-                                   uint8_t new_chan, tCsrRoamProfile *profile)
+                                   uint8_t new_chan, tCsrRoamProfile *profile,
+                                   uint8_t sme_session_id)
 {
    VOS_STATUS status;
    tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
    uint8_t cb_mode = 0;
+   tCsrRoamSession *session;
+
+   session = CSR_GET_SESSION(mac_ctx, sme_session_id);
+
+   if (!session) {
+       smsLog(mac_ctx, LOGE, FL("session %d not found"), sme_session_id);
+       return VOS_STATUS_E_FAILURE;
+   }
 
    status = sme_AcquireGlobalLock(&mac_ctx->sme);
    if (VOS_IS_STATUS_SUCCESS(status)) {
        if (CSR_IS_CHANNEL_5GHZ(new_chan)) {
-           sme_SelectCBMode(hal, profile->phyMode, new_chan);
+           sme_SelectCBMode(hal, profile->phyMode, new_chan,
+                            session->bssParams.orig_ch_width);
            cb_mode = mac_ctx->roam.configParam.channelBondingMode5GHz;
        }
        status = csr_roam_channel_change_req(mac_ctx, bssid, new_chan, cb_mode,