Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /*=========================================================================== |
| 43 | |
| 44 | s a p C h S e l e c t . C |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 45 | OVERVIEW: |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 46 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | This software unit holds the implementation of the WLAN SAP modules |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 48 | functions for channel selection. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 49 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 50 | DEPENDENCIES: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 51 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 52 | Are listed for each API below. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 53 | ===========================================================================*/ |
| 54 | |
| 55 | /*=========================================================================== |
| 56 | |
| 57 | EDIT HISTORY FOR FILE |
| 58 | |
| 59 | |
| 60 | This section contains comments describing changes made to the module. |
| 61 | Notice that changes are listed in reverse chronological order. |
| 62 | |
| 63 | |
| 64 | |
| 65 | when who what, where, why |
| 66 | ---------- --- -------------------------------------------------------- |
| 67 | 2010-03-15 SOFTAP Created module |
| 68 | |
| 69 | ===========================================================================*/ |
| 70 | |
| 71 | |
| 72 | /*-------------------------------------------------------------------------- |
| 73 | Include Files |
| 74 | ------------------------------------------------------------------------*/ |
| 75 | #include "vos_trace.h" |
| 76 | #include "csrApi.h" |
| 77 | #include "sme_Api.h" |
| 78 | #include "sapChSelect.h" |
| 79 | #include "sapInternal.h" |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 80 | #ifdef ANI_OS_TYPE_QNX |
| 81 | #include "stdio.h" |
| 82 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 83 | |
| 84 | /*-------------------------------------------------------------------------- |
| 85 | Function definitions |
| 86 | --------------------------------------------------------------------------*/ |
| 87 | |
| 88 | /*-------------------------------------------------------------------------- |
| 89 | Defines |
| 90 | --------------------------------------------------------------------------*/ |
| 91 | #define SAP_DEBUG |
| 92 | |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 93 | #define IS_RSSI_VALID( extRssi, rssi ) \ |
| 94 | ( \ |
| 95 | ((extRssi < rssi)?eANI_BOOLEAN_TRUE:eANI_BOOLEAN_FALSE) \ |
| 96 | ) |
| 97 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 98 | /*========================================================================== |
| 99 | FUNCTION sapCleanupChannelList |
| 100 | |
| 101 | DESCRIPTION |
| 102 | Function sapCleanupChannelList frees up the memory allocated to the channel list. |
| 103 | |
| 104 | DEPENDENCIES |
| 105 | NA. |
| 106 | |
| 107 | PARAMETERS |
| 108 | |
| 109 | IN |
| 110 | NULL |
| 111 | |
| 112 | RETURN VALUE |
| 113 | NULL |
| 114 | ============================================================================*/ |
| 115 | |
| 116 | void sapCleanupChannelList(void) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 117 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 118 | v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL); |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 119 | ptSapContext pSapCtx; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 120 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 121 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 122 | "Cleaning up the channel list structure"); |
| 123 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 124 | if (NULL == pvosGCtx) |
| 125 | { |
| 126 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 127 | "SAP Global Context is NULL"); |
| 128 | return ; |
| 129 | } |
| 130 | |
| 131 | pSapCtx = VOS_GET_SAP_CB(pvosGCtx); |
| 132 | if (NULL == pSapCtx) |
| 133 | { |
| 134 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 135 | "SAP Context is NULL"); |
| 136 | return ; |
| 137 | } |
| 138 | |
| 139 | pSapCtx->SapChnlList.numChannel = 0; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 140 | vos_mem_free(pSapCtx->SapChnlList.channelList); |
| 141 | pSapCtx->SapChnlList.channelList = NULL; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /*========================================================================== |
| 145 | FUNCTION sapSetPreferredChannel |
| 146 | |
| 147 | DESCRIPTION |
| 148 | Function sapSetPreferredChannel sets the channel list which has been configured |
| 149 | into sap context (pSapCtx) which will be used at the time of best channel selection. |
| 150 | |
| 151 | DEPENDENCIES |
| 152 | NA. |
| 153 | |
| 154 | PARAMETERS |
| 155 | |
| 156 | IN |
| 157 | *ptr: pointer having the command followed by the arguments in string format |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 158 | |
| 159 | RETURN VALUE |
| 160 | int: return 0 when success else returns error code. |
| 161 | ============================================================================*/ |
| 162 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 163 | int sapSetPreferredChannel(tANI_U8* ptr) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 164 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 165 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 166 | v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL); |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 167 | ptSapContext pSapCtx; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 168 | tANI_U8* param; |
| 169 | int tempInt; |
| 170 | int j; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 171 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 172 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 173 | "Enter: %s", __func__); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 174 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 175 | if (NULL == pvosGCtx) |
| 176 | { |
| 177 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 178 | "SAP Global Context is NULL"); |
| 179 | return -EINVAL; |
| 180 | } |
| 181 | |
| 182 | pSapCtx = VOS_GET_SAP_CB(pvosGCtx); |
| 183 | if (NULL == pSapCtx) |
| 184 | { |
| 185 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 186 | "SAP Context is NULL"); |
| 187 | return -EINVAL; |
| 188 | } |
| 189 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 190 | if (NULL != pSapCtx->SapChnlList.channelList) |
| 191 | { |
| 192 | sapCleanupChannelList(); |
| 193 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 194 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 195 | param = strchr(ptr, ' '); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 196 | /*no argument after the command*/ |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 197 | if (NULL == param) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 198 | { |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 199 | return -EINVAL; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 200 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 201 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 202 | /*no space after the command*/ |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 203 | else if (SPACE_ASCII_VALUE != *param) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 204 | { |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 205 | return -EINVAL; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 206 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 207 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 208 | param++; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 209 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 210 | /*removing empty spaces*/ |
| 211 | while((SPACE_ASCII_VALUE == *param)&& ('\0' != *param) ) param++; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 212 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 213 | /*no argument followed by spaces*/ |
| 214 | if('\0' == *param) |
| 215 | { |
| 216 | return -EINVAL; |
| 217 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 218 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 219 | /*getting the first argument ie the number of channels*/ |
| 220 | sscanf(param, "%d ", &tempInt); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 221 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 222 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 223 | "Number of channel added are: %d", tempInt); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 224 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 225 | /*allocating space for the desired number of channels*/ |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 226 | pSapCtx->SapChnlList.channelList = (v_U8_t *)vos_mem_malloc(tempInt); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 227 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 228 | if (NULL == pSapCtx->SapChnlList.channelList) |
| 229 | { |
| 230 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 231 | "In %s, VOS_MALLOC_ERR", __func__); |
| 232 | return -EINVAL; |
| 233 | } |
| 234 | |
| 235 | pSapCtx->SapChnlList.numChannel = tempInt; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 236 | for(j=0;j<pSapCtx->SapChnlList.numChannel;j++) |
| 237 | { |
| 238 | |
| 239 | /*param pointing to the beginning of first space after number of channels*/ |
| 240 | param = strpbrk( param, " " ); |
| 241 | /*no channel list after the number of channels argument*/ |
| 242 | if (NULL == param) |
| 243 | { |
| 244 | sapCleanupChannelList(); |
| 245 | return -EINVAL; |
| 246 | } |
| 247 | |
| 248 | param++; |
| 249 | |
| 250 | /*removing empty space*/ |
| 251 | while((SPACE_ASCII_VALUE == *param) && ('\0' != *param) ) param++; |
| 252 | |
| 253 | /*no channel list after the number of channels argument and spaces*/ |
| 254 | if( '\0' == *param ) |
| 255 | { |
| 256 | sapCleanupChannelList(); |
| 257 | return -EINVAL; |
| 258 | } |
| 259 | |
| 260 | sscanf(param, "%d ", &tempInt); |
| 261 | pSapCtx->SapChnlList.channelList[j] = tempInt; |
| 262 | |
| 263 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 264 | "Channel %d added to preferred channel list", |
| 265 | pSapCtx->SapChnlList.channelList[j] ); |
| 266 | |
| 267 | } |
| 268 | |
| 269 | /*extra arguments check*/ |
| 270 | param = strpbrk( param, " " ); |
| 271 | if (NULL != param) |
| 272 | { |
| 273 | while((SPACE_ASCII_VALUE == *param) && ('\0' != *param) ) param++; |
| 274 | |
| 275 | if('\0' != *param) |
| 276 | { |
| 277 | sapCleanupChannelList(); |
| 278 | return -EINVAL; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 283 | "Exit: %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 284 | |
| 285 | return 0; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /*========================================================================== |
| 289 | FUNCTION sapSelectPreferredChannelFromChannelList |
| 290 | |
| 291 | DESCRIPTION |
| 292 | Function sapSelectPreferredChannelFromChannelList calculates the best channel |
| 293 | among the configured channel list. If channel list not configured then returns |
| 294 | the best channel calculated among all the channel list. |
| 295 | |
| 296 | DEPENDENCIES |
| 297 | NA. |
| 298 | |
| 299 | PARAMETERS |
| 300 | |
| 301 | IN |
| 302 | *pSpectInfoParams : Pointer to tSapChSelSpectInfo structure |
| 303 | bestChNum: best channel already calculated among all the chanels |
| 304 | pSapCtx: having info of channel list from which best channel is selected |
| 305 | |
| 306 | RETURN VALUE |
| 307 | v_U8_t: best channel |
| 308 | ============================================================================*/ |
| 309 | v_U8_t sapSelectPreferredChannelFromChannelList(v_U8_t bestChNum, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 310 | ptSapContext pSapCtx, |
| 311 | tSapChSelSpectInfo *pSpectInfoParams) |
| 312 | { |
| 313 | v_U8_t j = 0; |
| 314 | v_U8_t count = 0; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 315 | |
| 316 | //If Channel List is not Configured don't do anything |
| 317 | //Else return the Best Channel from the Channel List |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 318 | if((NULL == pSapCtx->SapChnlList.channelList) || |
| 319 | (NULL == pSpectInfoParams) || |
| 320 | (0 == pSapCtx->SapChnlList.numChannel)) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 321 | { |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 322 | return bestChNum; |
| 323 | } |
| 324 | |
| 325 | if (bestChNum > 0 && bestChNum <= 252) |
| 326 | { |
| 327 | for(count=0; count < pSpectInfoParams->numSpectChans ; count++) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 328 | { |
| 329 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[count].chNum; |
| 330 | // Select the best channel from allowed list |
| 331 | for(j=0;j< pSapCtx->SapChnlList.numChannel;j++) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 332 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 333 | if( (pSapCtx->SapChnlList.channelList[j]) == bestChNum) |
| 334 | { |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 335 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 336 | "Best channel computed from Channel List is: %d", |
| 337 | bestChNum); |
| 338 | return bestChNum; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 339 | } |
| 340 | } |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | return SAP_CHANNEL_NOT_SELECTED; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 344 | } |
| 345 | else |
| 346 | return SAP_CHANNEL_NOT_SELECTED; |
| 347 | } |
| 348 | |
| 349 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 350 | /*========================================================================== |
| 351 | FUNCTION sapChanSelInit |
| 352 | |
| 353 | DESCRIPTION |
| 354 | Function sapChanSelInit allocates the memory, intializes the |
| 355 | structures used by the channel selection algorithm |
| 356 | |
| 357 | DEPENDENCIES |
| 358 | NA. |
| 359 | |
| 360 | PARAMETERS |
| 361 | |
| 362 | IN |
| 363 | *pSpectInfoParams : Pointer to tSapChSelSpectInfo structure |
| 364 | |
| 365 | RETURN VALUE |
| 366 | v_BOOL_t: Success or FAIL |
| 367 | |
| 368 | SIDE EFFECTS |
| 369 | ============================================================================*/ |
| 370 | v_BOOL_t sapChanSelInit(tHalHandle halHandle, tSapChSelSpectInfo *pSpectInfoParams) |
| 371 | { |
| 372 | tSapSpectChInfo *pSpectCh = NULL; |
| 373 | v_U8_t *pChans = NULL; |
| 374 | v_U16_t channelnum = 0; |
| 375 | tpAniSirGlobal pMac = PMAC_STRUCT(halHandle); |
| 376 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 377 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 378 | |
| 379 | // Channels for that 2.4GHz band |
| 380 | //Considered only for 2.4GHz need to change in future to support 5GHz support |
| 381 | pSpectInfoParams->numSpectChans = pMac->scan.base20MHzChannels.numChannels; |
| 382 | |
| 383 | // Allocate memory for weight computation of 2.4GHz |
| 384 | pSpectCh = (tSapSpectChInfo *)vos_mem_malloc((pSpectInfoParams->numSpectChans) * sizeof(*pSpectCh)); |
| 385 | |
| 386 | if(pSpectCh == NULL) { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 387 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, VOS_MALLOC_ERR", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 388 | return eSAP_FALSE; |
| 389 | } |
| 390 | |
| 391 | vos_mem_zero(pSpectCh, (pSpectInfoParams->numSpectChans) * sizeof(*pSpectCh)); |
| 392 | |
| 393 | // Initialize the pointers in the DfsParams to the allocated memory |
| 394 | pSpectInfoParams->pSpectCh = pSpectCh; |
| 395 | |
| 396 | pChans = pMac->scan.base20MHzChannels.channelList; |
| 397 | |
| 398 | // Fill the channel number in the spectrum in the operating freq band |
| 399 | for (channelnum = 0; channelnum < pSpectInfoParams->numSpectChans; channelnum++) { |
| 400 | |
| 401 | if(*pChans == 14 ) //OFDM rates are not supported on channel 14 |
| 402 | continue; |
| 403 | pSpectCh->chNum = *pChans; |
| 404 | pSpectCh->valid = eSAP_TRUE; |
| 405 | pSpectCh->rssiAgr = SOFTAP_MIN_RSSI;// Initialise for all channels |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 406 | pSpectCh->channelWidth = SOFTAP_HT20_CHANNELWIDTH; // Initialise 20MHz for all the Channels |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 407 | pSpectCh++; |
| 408 | pChans++; |
| 409 | } |
| 410 | return eSAP_TRUE; |
| 411 | } |
| 412 | |
| 413 | /*========================================================================== |
| 414 | FUNCTION sapweightRssiCount |
| 415 | |
| 416 | DESCRIPTION |
| 417 | Function weightRssiCount calculates the channel weight due to rssi |
| 418 | and data count(here number of BSS observed) |
| 419 | |
| 420 | DEPENDENCIES |
| 421 | NA. |
| 422 | |
| 423 | PARAMETERS |
| 424 | |
| 425 | IN |
| 426 | rssi : Max signal strength receieved from a BSS for the channel |
| 427 | count : Number of BSS observed in the channel |
| 428 | |
| 429 | RETURN VALUE |
| 430 | v_U32_t : Calculated channel weight based on above two |
| 431 | |
| 432 | SIDE EFFECTS |
| 433 | ============================================================================*/ |
| 434 | v_U32_t sapweightRssiCount(v_S7_t rssi, v_U16_t count) |
| 435 | { |
| 436 | v_S31_t rssiWeight=0; |
| 437 | v_S31_t countWeight=0; |
| 438 | v_U32_t rssicountWeight=0; |
| 439 | |
| 440 | // Weight from RSSI |
| 441 | rssiWeight = SOFTAP_RSSI_WEIGHT * (rssi - SOFTAP_MIN_RSSI) |
| 442 | /(SOFTAP_MAX_RSSI - SOFTAP_MIN_RSSI); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 443 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 444 | if(rssiWeight > SOFTAP_RSSI_WEIGHT) |
| 445 | rssiWeight = SOFTAP_RSSI_WEIGHT; |
| 446 | else if (rssiWeight < 0) |
| 447 | rssiWeight = 0; |
| 448 | |
| 449 | // Weight from data count |
| 450 | countWeight = SOFTAP_COUNT_WEIGHT * (count - SOFTAP_MIN_COUNT) |
| 451 | /(SOFTAP_MAX_COUNT - SOFTAP_MIN_COUNT); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 453 | if(countWeight > SOFTAP_COUNT_WEIGHT) |
| 454 | countWeight = SOFTAP_COUNT_WEIGHT; |
| 455 | else if (countWeight < 0) |
| 456 | countWeight = 0; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 457 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 458 | rssicountWeight = rssiWeight + countWeight; |
| 459 | |
| 460 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, rssiWeight=%d, countWeight=%d, rssicountWeight=%d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 461 | __func__, rssiWeight, countWeight, rssicountWeight); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 462 | |
| 463 | return(rssicountWeight); |
| 464 | } |
| 465 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 466 | |
| 467 | /*========================================================================== |
| 468 | FUNCTION sapInterferenceRssiCount |
| 469 | |
| 470 | DESCRIPTION |
| 471 | Function sapInterferenceRssiCount Considers the Adjacent channel rssi |
| 472 | and data count(here number of BSS observed) |
| 473 | |
| 474 | DEPENDENCIES |
| 475 | NA. |
| 476 | |
| 477 | PARAMETERS |
| 478 | |
| 479 | pSpectCh : Channel Information |
| 480 | |
| 481 | RETURN VALUE |
| 482 | NA. |
| 483 | |
| 484 | SIDE EFFECTS |
| 485 | ============================================================================*/ |
| 486 | void sapInterferenceRssiCount(tSapSpectChInfo *pSpectCh) |
| 487 | { |
| 488 | tSapSpectChInfo *pExtSpectCh = NULL; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 489 | v_S31_t rssi; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 490 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 491 | switch(pSpectCh->chNum) |
| 492 | { |
| 493 | case CHANNEL_1: |
| 494 | pExtSpectCh = (pSpectCh + 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 495 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 496 | { |
| 497 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 498 | rssi = pSpectCh->rssiAgr + |
| 499 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 500 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 501 | { |
| 502 | pExtSpectCh->rssiAgr = rssi; |
| 503 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 504 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 505 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 506 | } |
| 507 | pExtSpectCh = (pSpectCh + 2); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 508 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 509 | { |
| 510 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 511 | rssi = pSpectCh->rssiAgr + |
| 512 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 513 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 514 | { |
| 515 | pExtSpectCh->rssiAgr = rssi; |
| 516 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 517 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 518 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 519 | } |
| 520 | pExtSpectCh = (pSpectCh + 3); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 521 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 522 | { |
| 523 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 524 | rssi = pSpectCh->rssiAgr + |
| 525 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 526 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 527 | { |
| 528 | pExtSpectCh->rssiAgr = rssi; |
| 529 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 530 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 531 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 532 | } |
| 533 | pExtSpectCh = (pSpectCh + 4); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 534 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 535 | { |
| 536 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 537 | rssi = pSpectCh->rssiAgr + |
| 538 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 539 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 540 | { |
| 541 | pExtSpectCh->rssiAgr = rssi; |
| 542 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 543 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 544 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 545 | } |
| 546 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 547 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 548 | case CHANNEL_2: |
| 549 | pExtSpectCh = (pSpectCh - 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 550 | if (pExtSpectCh != NULL) |
| 551 | { |
| 552 | ++pExtSpectCh->bssCount; |
| 553 | rssi = pSpectCh->rssiAgr + |
| 554 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 555 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 556 | { |
| 557 | pExtSpectCh->rssiAgr = rssi; |
| 558 | } |
| 559 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 560 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 561 | } |
| 562 | pExtSpectCh = (pSpectCh + 1); |
| 563 | if (pExtSpectCh != NULL) |
| 564 | { |
| 565 | ++pExtSpectCh->bssCount; |
| 566 | rssi = pSpectCh->rssiAgr + |
| 567 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 568 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 569 | { |
| 570 | pExtSpectCh->rssiAgr = rssi; |
| 571 | } |
| 572 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 573 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 574 | } |
| 575 | pExtSpectCh = (pSpectCh + 2); |
| 576 | if (pExtSpectCh != NULL) |
| 577 | { |
| 578 | ++pExtSpectCh->bssCount; |
| 579 | rssi = pSpectCh->rssiAgr + |
| 580 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 581 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 582 | { |
| 583 | pExtSpectCh->rssiAgr = rssi; |
| 584 | } |
| 585 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 586 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 587 | } |
| 588 | pExtSpectCh = (pSpectCh + 3); |
| 589 | if (pExtSpectCh != NULL) |
| 590 | { |
| 591 | ++pExtSpectCh->bssCount; |
| 592 | rssi = pSpectCh->rssiAgr + |
| 593 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 594 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 595 | { |
| 596 | pExtSpectCh->rssiAgr = rssi; |
| 597 | } |
| 598 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 599 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 600 | } |
| 601 | pExtSpectCh = (pSpectCh + 4); |
| 602 | if (pExtSpectCh != NULL) |
| 603 | { |
| 604 | ++pExtSpectCh->bssCount; |
| 605 | rssi = pSpectCh->rssiAgr + |
| 606 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 607 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 608 | { |
| 609 | pExtSpectCh->rssiAgr = rssi; |
| 610 | } |
| 611 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 612 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 613 | } |
| 614 | break; |
| 615 | case CHANNEL_3: |
| 616 | pExtSpectCh = (pSpectCh - 2); |
| 617 | if (pExtSpectCh != NULL) |
| 618 | { |
| 619 | ++pExtSpectCh->bssCount; |
| 620 | rssi = pSpectCh->rssiAgr + |
| 621 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 622 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 623 | { |
| 624 | pExtSpectCh->rssiAgr = rssi; |
| 625 | } |
| 626 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 627 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 628 | } |
| 629 | pExtSpectCh = (pSpectCh - 1); |
| 630 | if (pExtSpectCh != NULL) |
| 631 | { |
| 632 | ++pExtSpectCh->bssCount; |
| 633 | rssi = pSpectCh->rssiAgr + |
| 634 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 635 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 636 | { |
| 637 | pExtSpectCh->rssiAgr = rssi; |
| 638 | } |
| 639 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 640 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 641 | } |
| 642 | pExtSpectCh = (pSpectCh + 1); |
| 643 | if (pExtSpectCh != NULL) |
| 644 | { |
| 645 | ++pExtSpectCh->bssCount; |
| 646 | rssi = pSpectCh->rssiAgr + |
| 647 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 648 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 649 | { |
| 650 | pExtSpectCh->rssiAgr = rssi; |
| 651 | } |
| 652 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 653 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 654 | } |
| 655 | pExtSpectCh = (pSpectCh + 2); |
| 656 | if (pExtSpectCh != NULL) |
| 657 | { |
| 658 | ++pExtSpectCh->bssCount; |
| 659 | rssi = pSpectCh->rssiAgr + |
| 660 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 661 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 662 | { |
| 663 | pExtSpectCh->rssiAgr = rssi; |
| 664 | } |
| 665 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 666 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 667 | } |
| 668 | pExtSpectCh = (pSpectCh + 3); |
| 669 | if (pExtSpectCh != NULL) |
| 670 | { |
| 671 | ++pExtSpectCh->bssCount; |
| 672 | rssi = pSpectCh->rssiAgr + |
| 673 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 674 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 675 | { |
| 676 | pExtSpectCh->rssiAgr = rssi; |
| 677 | } |
| 678 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 679 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 680 | } |
| 681 | pExtSpectCh = (pSpectCh + 4); |
| 682 | if (pExtSpectCh != NULL) |
| 683 | { |
| 684 | ++pExtSpectCh->bssCount; |
| 685 | rssi = pSpectCh->rssiAgr + |
| 686 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 687 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 688 | { |
| 689 | pExtSpectCh->rssiAgr = rssi; |
| 690 | } |
| 691 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 692 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 693 | } |
| 694 | break; |
| 695 | case CHANNEL_4: |
| 696 | pExtSpectCh = (pSpectCh - 3); |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 697 | if(pExtSpectCh != NULL) |
| 698 | { |
| 699 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 700 | rssi = pSpectCh->rssiAgr + |
| 701 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 702 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 703 | { |
| 704 | pExtSpectCh->rssiAgr = rssi; |
| 705 | } |
| 706 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 707 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 708 | } |
| 709 | pExtSpectCh = (pSpectCh - 2); |
| 710 | if (pExtSpectCh != NULL) |
| 711 | { |
| 712 | ++pExtSpectCh->bssCount; |
| 713 | rssi = pSpectCh->rssiAgr + |
| 714 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 715 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 716 | { |
| 717 | pExtSpectCh->rssiAgr = rssi; |
| 718 | } |
| 719 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 720 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 721 | } |
| 722 | pExtSpectCh = (pSpectCh - 1); |
| 723 | if (pExtSpectCh != NULL) |
| 724 | { |
| 725 | ++pExtSpectCh->bssCount; |
| 726 | rssi = pSpectCh->rssiAgr + |
| 727 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 728 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 729 | { |
| 730 | pExtSpectCh->rssiAgr = rssi; |
| 731 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 732 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 733 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 734 | } |
| 735 | pExtSpectCh = (pSpectCh + 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 736 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 737 | { |
| 738 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 739 | rssi = pSpectCh->rssiAgr + |
| 740 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 741 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 742 | { |
| 743 | pExtSpectCh->rssiAgr = rssi; |
| 744 | } |
| 745 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 746 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 747 | } |
| 748 | pExtSpectCh = (pSpectCh + 2); |
| 749 | if (pExtSpectCh != NULL) |
| 750 | { |
| 751 | ++pExtSpectCh->bssCount; |
| 752 | rssi = pSpectCh->rssiAgr + |
| 753 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 754 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 755 | { |
| 756 | pExtSpectCh->rssiAgr = rssi; |
| 757 | } |
| 758 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 759 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 760 | } |
| 761 | pExtSpectCh = (pSpectCh + 3); |
| 762 | if (pExtSpectCh != NULL) |
| 763 | { |
| 764 | ++pExtSpectCh->bssCount; |
| 765 | rssi = pSpectCh->rssiAgr + |
| 766 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 767 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 768 | { |
| 769 | pExtSpectCh->rssiAgr = rssi; |
| 770 | } |
| 771 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 772 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 773 | } |
| 774 | pExtSpectCh = (pSpectCh + 4); |
| 775 | if (pExtSpectCh != NULL) |
| 776 | { |
| 777 | ++pExtSpectCh->bssCount; |
| 778 | rssi = pSpectCh->rssiAgr + |
| 779 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 780 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 781 | { |
| 782 | pExtSpectCh->rssiAgr = rssi; |
| 783 | } |
| 784 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 785 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 786 | } |
| 787 | break; |
| 788 | |
| 789 | case CHANNEL_5: |
| 790 | case CHANNEL_6: |
| 791 | case CHANNEL_7: |
| 792 | pExtSpectCh = (pSpectCh - 4); |
| 793 | if (pExtSpectCh != NULL) |
| 794 | { |
| 795 | ++pExtSpectCh->bssCount; |
| 796 | rssi = pSpectCh->rssiAgr + |
| 797 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 798 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 799 | { |
| 800 | pExtSpectCh->rssiAgr = rssi; |
| 801 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 802 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 803 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 804 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 805 | pExtSpectCh = (pSpectCh - 3); |
| 806 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 807 | { |
| 808 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 809 | rssi = pSpectCh->rssiAgr + |
| 810 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 811 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 812 | { |
| 813 | pExtSpectCh->rssiAgr = rssi; |
| 814 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 815 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 816 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 817 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 818 | pExtSpectCh = (pSpectCh - 2); |
| 819 | if (pExtSpectCh != NULL) |
| 820 | { |
| 821 | ++pExtSpectCh->bssCount; |
| 822 | rssi = pSpectCh->rssiAgr + |
| 823 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 824 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 825 | { |
| 826 | pExtSpectCh->rssiAgr = rssi; |
| 827 | } |
| 828 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 829 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 830 | } |
| 831 | pExtSpectCh = (pSpectCh - 1); |
| 832 | if(pExtSpectCh != NULL) |
| 833 | { |
| 834 | ++pExtSpectCh->bssCount; |
| 835 | rssi = pSpectCh->rssiAgr + |
| 836 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 837 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 838 | { |
| 839 | pExtSpectCh->rssiAgr = rssi; |
| 840 | } |
| 841 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 842 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 843 | } |
| 844 | pExtSpectCh = (pSpectCh + 1); |
| 845 | if (pExtSpectCh != NULL) |
| 846 | { |
| 847 | ++pExtSpectCh->bssCount; |
| 848 | rssi = pSpectCh->rssiAgr + |
| 849 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 850 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 851 | { |
| 852 | pExtSpectCh->rssiAgr = rssi; |
| 853 | } |
| 854 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 855 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 856 | } |
| 857 | pExtSpectCh = (pSpectCh + 2); |
| 858 | if(pExtSpectCh != NULL) |
| 859 | { |
| 860 | ++pExtSpectCh->bssCount; |
| 861 | rssi = pSpectCh->rssiAgr + |
| 862 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 863 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 864 | { |
| 865 | pExtSpectCh->rssiAgr = rssi; |
| 866 | } |
| 867 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 868 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 869 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 870 | pExtSpectCh = (pSpectCh + 3); |
| 871 | if(pExtSpectCh != NULL) |
| 872 | { |
| 873 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 874 | rssi = pSpectCh->rssiAgr + |
| 875 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 876 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 877 | { |
| 878 | pExtSpectCh->rssiAgr = rssi; |
| 879 | } |
| 880 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 881 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 882 | } |
| 883 | pExtSpectCh = (pSpectCh + 4); |
| 884 | if (pExtSpectCh != NULL) |
| 885 | { |
| 886 | ++pExtSpectCh->bssCount; |
| 887 | rssi = pSpectCh->rssiAgr + |
| 888 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 889 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 890 | { |
| 891 | pExtSpectCh->rssiAgr = rssi; |
| 892 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 893 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 894 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 895 | } |
| 896 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 897 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 898 | case CHANNEL_8: |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 899 | pExtSpectCh = (pSpectCh - 4); |
| 900 | if(pExtSpectCh != NULL) |
| 901 | { |
| 902 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 903 | rssi = pSpectCh->rssiAgr + |
| 904 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 905 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 906 | { |
| 907 | pExtSpectCh->rssiAgr = rssi; |
| 908 | } |
| 909 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 910 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 911 | } |
| 912 | |
| 913 | pExtSpectCh = (pSpectCh - 3); |
| 914 | if (pExtSpectCh != NULL) |
| 915 | { |
| 916 | ++pExtSpectCh->bssCount; |
| 917 | rssi = pSpectCh->rssiAgr + |
| 918 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 919 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 920 | { |
| 921 | pExtSpectCh->rssiAgr = rssi; |
| 922 | } |
| 923 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 924 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 925 | } |
| 926 | pExtSpectCh = (pSpectCh - 2); |
| 927 | if (pExtSpectCh != NULL) |
| 928 | { |
| 929 | ++pExtSpectCh->bssCount; |
| 930 | rssi = pSpectCh->rssiAgr + |
| 931 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 932 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 933 | { |
| 934 | pExtSpectCh->rssiAgr = rssi; |
| 935 | } |
| 936 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 937 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 938 | } |
| 939 | pExtSpectCh = (pSpectCh - 1); |
| 940 | if (pExtSpectCh != NULL) |
| 941 | { |
| 942 | ++pExtSpectCh->bssCount; |
| 943 | rssi = pSpectCh->rssiAgr + |
| 944 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 945 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 946 | { |
| 947 | pExtSpectCh->rssiAgr = rssi; |
| 948 | } |
| 949 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 950 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 951 | } |
| 952 | pExtSpectCh = (pSpectCh + 1); |
| 953 | if (pExtSpectCh != NULL) |
| 954 | { |
| 955 | ++pExtSpectCh->bssCount; |
| 956 | rssi = pSpectCh->rssiAgr + |
| 957 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 958 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 959 | { |
| 960 | pExtSpectCh->rssiAgr = rssi; |
| 961 | } |
| 962 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 963 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 964 | } |
| 965 | pExtSpectCh = (pSpectCh + 2); |
| 966 | if (pExtSpectCh != NULL) |
| 967 | { |
| 968 | ++pExtSpectCh->bssCount; |
| 969 | rssi = pSpectCh->rssiAgr + |
| 970 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 971 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 972 | { |
| 973 | pExtSpectCh->rssiAgr = rssi; |
| 974 | } |
| 975 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 976 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 977 | } |
| 978 | pExtSpectCh = (pSpectCh + 3); |
| 979 | if (pExtSpectCh != NULL) |
| 980 | { |
| 981 | ++pExtSpectCh->bssCount; |
| 982 | rssi = pSpectCh->rssiAgr + |
| 983 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 984 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 985 | { |
| 986 | pExtSpectCh->rssiAgr = rssi; |
| 987 | } |
| 988 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 989 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 990 | } |
| 991 | break; |
| 992 | |
| 993 | case CHANNEL_9: |
| 994 | pExtSpectCh = (pSpectCh - 4); |
| 995 | if (pExtSpectCh != NULL) |
| 996 | { |
| 997 | ++pExtSpectCh->bssCount; |
| 998 | rssi = pSpectCh->rssiAgr + |
| 999 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1000 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1001 | { |
| 1002 | pExtSpectCh->rssiAgr = rssi; |
| 1003 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1004 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1005 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1006 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1007 | |
| 1008 | pExtSpectCh = (pSpectCh - 3); |
| 1009 | if (pExtSpectCh != NULL) |
| 1010 | { |
| 1011 | ++pExtSpectCh->bssCount; |
| 1012 | rssi = pSpectCh->rssiAgr + |
| 1013 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1014 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1015 | { |
| 1016 | pExtSpectCh->rssiAgr = rssi; |
| 1017 | } |
| 1018 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1019 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1020 | } |
| 1021 | pExtSpectCh = (pSpectCh - 2); |
| 1022 | if (pExtSpectCh != NULL) |
| 1023 | { |
| 1024 | ++pExtSpectCh->bssCount; |
| 1025 | rssi = pSpectCh->rssiAgr + |
| 1026 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1027 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1028 | { |
| 1029 | pExtSpectCh->rssiAgr = rssi; |
| 1030 | } |
| 1031 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1032 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1033 | } |
| 1034 | pExtSpectCh = (pSpectCh - 1); |
| 1035 | if (pExtSpectCh != NULL) |
| 1036 | { |
| 1037 | ++pExtSpectCh->bssCount; |
| 1038 | rssi = pSpectCh->rssiAgr + |
| 1039 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1040 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1041 | { |
| 1042 | pExtSpectCh->rssiAgr = rssi; |
| 1043 | } |
| 1044 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1045 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1046 | } |
| 1047 | pExtSpectCh = (pSpectCh + 1); |
| 1048 | if (pExtSpectCh != NULL) |
| 1049 | { |
| 1050 | ++pExtSpectCh->bssCount; |
| 1051 | rssi = pSpectCh->rssiAgr + |
| 1052 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1053 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1054 | { |
| 1055 | pExtSpectCh->rssiAgr = rssi; |
| 1056 | } |
| 1057 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1058 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1059 | } |
| 1060 | pExtSpectCh = (pSpectCh + 2); |
| 1061 | if (pExtSpectCh != NULL) |
| 1062 | { |
| 1063 | ++pExtSpectCh->bssCount; |
| 1064 | rssi = pSpectCh->rssiAgr + |
| 1065 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1066 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1067 | { |
| 1068 | pExtSpectCh->rssiAgr = rssi; |
| 1069 | } |
| 1070 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1071 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1072 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1073 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1074 | |
| 1075 | case CHANNEL_10: |
| 1076 | pExtSpectCh = (pSpectCh - 4); |
| 1077 | if (pExtSpectCh != NULL) |
| 1078 | { |
| 1079 | ++pExtSpectCh->bssCount; |
| 1080 | rssi = pSpectCh->rssiAgr + |
| 1081 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1082 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1083 | { |
| 1084 | pExtSpectCh->rssiAgr = rssi; |
| 1085 | } |
| 1086 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1087 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1088 | } |
| 1089 | |
| 1090 | pExtSpectCh = (pSpectCh - 3); |
| 1091 | if (pExtSpectCh != NULL) |
| 1092 | { |
| 1093 | ++pExtSpectCh->bssCount; |
| 1094 | rssi = pSpectCh->rssiAgr + |
| 1095 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1096 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1097 | { |
| 1098 | pExtSpectCh->rssiAgr = rssi; |
| 1099 | } |
| 1100 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1101 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1102 | } |
| 1103 | pExtSpectCh = (pSpectCh - 2); |
| 1104 | if(pExtSpectCh != NULL) |
| 1105 | { |
| 1106 | ++pExtSpectCh->bssCount; |
| 1107 | rssi = pSpectCh->rssiAgr + |
| 1108 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1109 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1110 | { |
| 1111 | pExtSpectCh->rssiAgr = rssi; |
| 1112 | } |
| 1113 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1114 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1115 | } |
| 1116 | pExtSpectCh = (pSpectCh - 1); |
| 1117 | if (pExtSpectCh != NULL) |
| 1118 | { |
| 1119 | ++pExtSpectCh->bssCount; |
| 1120 | rssi = pSpectCh->rssiAgr + |
| 1121 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1122 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1123 | { |
| 1124 | pExtSpectCh->rssiAgr = rssi; |
| 1125 | } |
| 1126 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1127 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1128 | } |
| 1129 | pExtSpectCh = (pSpectCh + 1); |
| 1130 | if (pExtSpectCh != NULL) |
| 1131 | { |
| 1132 | ++pExtSpectCh->bssCount; |
| 1133 | rssi = pSpectCh->rssiAgr + |
| 1134 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1135 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1136 | { |
| 1137 | pExtSpectCh->rssiAgr = rssi; |
| 1138 | } |
| 1139 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1140 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1141 | } |
| 1142 | break; |
| 1143 | |
| 1144 | case CHANNEL_11: |
| 1145 | pExtSpectCh = (pSpectCh - 1); |
| 1146 | if (pExtSpectCh != NULL) |
| 1147 | { |
| 1148 | ++pExtSpectCh->bssCount; |
| 1149 | rssi = pSpectCh->rssiAgr + |
| 1150 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1151 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1152 | { |
| 1153 | pExtSpectCh->rssiAgr = rssi; |
| 1154 | } |
| 1155 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1156 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1157 | } |
| 1158 | pExtSpectCh = (pSpectCh - 2); |
| 1159 | if (pExtSpectCh != NULL) |
| 1160 | { |
| 1161 | ++pExtSpectCh->bssCount; |
| 1162 | rssi = pSpectCh->rssiAgr + |
| 1163 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1164 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1165 | { |
| 1166 | pExtSpectCh->rssiAgr = rssi; |
| 1167 | } |
| 1168 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1169 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1170 | } |
| 1171 | pExtSpectCh = (pSpectCh - 3); |
| 1172 | if (pExtSpectCh != NULL) |
| 1173 | { |
| 1174 | ++pExtSpectCh->bssCount; |
| 1175 | rssi = pSpectCh->rssiAgr + |
| 1176 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1177 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1178 | { |
| 1179 | pExtSpectCh->rssiAgr = rssi; |
| 1180 | } |
| 1181 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1182 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1183 | } |
| 1184 | pExtSpectCh = (pSpectCh - 4); |
| 1185 | if (pExtSpectCh != NULL) |
| 1186 | { |
| 1187 | ++pExtSpectCh->bssCount; |
| 1188 | rssi = pSpectCh->rssiAgr + |
| 1189 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1190 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1191 | { |
| 1192 | pExtSpectCh->rssiAgr = rssi; |
| 1193 | } |
| 1194 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1195 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1196 | } |
| 1197 | break; |
| 1198 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1199 | default: |
| 1200 | break; |
| 1201 | } |
| 1202 | } |
| 1203 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1204 | /*========================================================================== |
| 1205 | FUNCTION sapComputeSpectWeight |
| 1206 | |
| 1207 | DESCRIPTION |
| 1208 | Main function for computing the weight of each channel in the |
| 1209 | spectrum based on the RSSI value of the BSSes on the channel |
| 1210 | and number of BSS |
| 1211 | |
| 1212 | DEPENDENCIES |
| 1213 | NA. |
| 1214 | |
| 1215 | PARAMETERS |
| 1216 | |
| 1217 | IN |
| 1218 | pSpectInfoParams : Pointer to the tSpectInfoParams structure |
| 1219 | halHandle : Pointer to HAL handle |
| 1220 | pResult : Pointer to tScanResultHandle |
| 1221 | |
| 1222 | RETURN VALUE |
| 1223 | void : NULL |
| 1224 | |
| 1225 | SIDE EFFECTS |
| 1226 | ============================================================================*/ |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1227 | void sapComputeSpectWeight( tSapChSelSpectInfo* pSpectInfoParams, |
| 1228 | tHalHandle halHandle, tScanResultHandle pResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1229 | { |
| 1230 | v_S7_t rssi = 0; |
| 1231 | v_U8_t chn_num = 0; |
| 1232 | v_U8_t channel_id = 0; |
| 1233 | |
| 1234 | tCsrScanResultInfo *pScanResult; |
| 1235 | tSapSpectChInfo *pSpectCh = pSpectInfoParams->pSpectCh; |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1236 | v_U32_t operatingBand; |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1237 | v_U16_t channelWidth; |
| 1238 | v_U16_t secondaryChannelOffset; |
| 1239 | v_U16_t centerFreq; |
| 1240 | v_U16_t vhtSupport; |
| 1241 | v_U32_t ieLen = 0; |
| 1242 | tSirProbeRespBeacon *pBeaconStruct; |
| 1243 | tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1244 | |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1245 | pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon)); |
| 1246 | if ( NULL == pBeaconStruct ) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1247 | { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1248 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1249 | "Unable to allocate memory in sapComputeSpectWeight\n"); |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1250 | return; |
| 1251 | } |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1252 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Computing spectral weight", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1253 | |
| 1254 | /** |
| 1255 | * Soft AP specific channel weight calculation using DFS formula |
| 1256 | */ |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1257 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1258 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1259 | pScanResult = sme_ScanResultGetFirst(halHandle, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1260 | |
| 1261 | while (pScanResult) { |
| 1262 | pSpectCh = pSpectInfoParams->pSpectCh; |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1263 | // Defining the default values, so that any value will hold the default values |
| 1264 | channelWidth = eHT_CHANNEL_WIDTH_20MHZ; |
| 1265 | secondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED; |
| 1266 | vhtSupport = 0; |
| 1267 | centerFreq = 0; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1268 | |
| 1269 | if (pScanResult->BssDescriptor.ieFields != NULL) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1270 | { |
| 1271 | ieLen = (pScanResult->BssDescriptor.length + sizeof(tANI_U16) + sizeof(tANI_U32) - sizeof(tSirBssDescription)); |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1272 | vos_mem_set((tANI_U8 *) pBeaconStruct, sizeof(tSirProbeRespBeacon), 0); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1273 | |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1274 | if ((sirParseBeaconIE(pMac, pBeaconStruct,(tANI_U8 *)( pScanResult->BssDescriptor.ieFields), ieLen)) == eSIR_SUCCESS) |
| 1275 | { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1276 | if (pBeaconStruct->HTCaps.present && pBeaconStruct->HTInfo.present) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1277 | { |
| 1278 | channelWidth = pBeaconStruct->HTCaps.supportedChannelWidthSet; |
| 1279 | secondaryChannelOffset = pBeaconStruct->HTInfo.secondaryChannelOffset; |
| 1280 | if(pBeaconStruct->VHTOperation.present) |
| 1281 | { |
| 1282 | vhtSupport = pBeaconStruct->VHTOperation.present; |
| 1283 | if(pBeaconStruct->VHTOperation.chanWidth > WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) |
| 1284 | { |
| 1285 | channelWidth = eHT_CHANNEL_WIDTH_80MHZ; |
| 1286 | centerFreq = pBeaconStruct->VHTOperation.chanCenterFreqSeg1; |
| 1287 | } |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | } |
Madan Mohan Koyyalamudi | 1e02f7f | 2012-12-04 16:46:45 -0800 | [diff] [blame] | 1292 | // Processing for each tCsrScanResultInfo in the tCsrScanResult DLink list |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1293 | for (chn_num = 0; chn_num < pSpectInfoParams->numSpectChans; chn_num++) { |
| 1294 | |
| 1295 | /* |
| 1296 | * if the Beacon has channel ID, use it other wise we will |
| 1297 | * rely on the channelIdSelf |
| 1298 | */ |
| 1299 | if(pScanResult->BssDescriptor.channelId == 0) |
| 1300 | channel_id = pScanResult->BssDescriptor.channelIdSelf; |
| 1301 | else |
| 1302 | channel_id = pScanResult->BssDescriptor.channelId; |
| 1303 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1304 | if (channel_id == pSpectCh->chNum) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1305 | if (pSpectCh->rssiAgr < pScanResult->BssDescriptor.rssi) |
| 1306 | pSpectCh->rssiAgr = pScanResult->BssDescriptor.rssi; |
| 1307 | |
| 1308 | ++pSpectCh->bssCount; // Increment the count of BSS |
| 1309 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1310 | if(operatingBand) // Connsidering the Extension Channel only in a channels |
| 1311 | { |
| 1312 | /* Updating the received ChannelWidth */ |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1313 | if (pSpectCh->channelWidth != channelWidth) |
| 1314 | pSpectCh->channelWidth = channelWidth; |
Madan Mohan Koyyalamudi | 1e02f7f | 2012-12-04 16:46:45 -0800 | [diff] [blame] | 1315 | /* If received ChannelWidth is other than HT20, we need to update the extension channel Params as well */ |
| 1316 | /* channelWidth == 0, HT20 */ |
| 1317 | /* channelWidth == 1, HT40 */ |
| 1318 | /* channelWidth == 2, VHT80*/ |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1319 | switch(pSpectCh->channelWidth) |
| 1320 | { |
| 1321 | case eHT_CHANNEL_WIDTH_40MHZ: //HT40 |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1322 | switch( secondaryChannelOffset) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1323 | { |
| 1324 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1325 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: // Above the Primary Channel |
| 1326 | pExtSpectCh = (pSpectCh + 1); |
| 1327 | if(pExtSpectCh != NULL) |
| 1328 | { |
| 1329 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1330 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1331 | // REducing the rssi by -20 and assigning it to Extension channel |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1332 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1333 | { |
| 1334 | pExtSpectCh->rssiAgr = rssi; |
| 1335 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1336 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1337 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1338 | } |
| 1339 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1340 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1341 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: // Below the Primary channel |
| 1342 | pExtSpectCh = (pSpectCh - 1); |
| 1343 | if(pExtSpectCh != NULL) |
| 1344 | { |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1345 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1346 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1347 | { |
| 1348 | pExtSpectCh->rssiAgr = rssi; |
| 1349 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1350 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1351 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1352 | ++pExtSpectCh->bssCount; |
| 1353 | } |
| 1354 | break; |
| 1355 | } |
| 1356 | break; |
| 1357 | case eHT_CHANNEL_WIDTH_80MHZ: // VHT80 |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1358 | if((centerFreq - channel_id) == 6) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1359 | { |
| 1360 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1361 | pExtSpectCh = (pSpectCh + 1); |
| 1362 | if(pExtSpectCh != NULL) |
| 1363 | { |
| 1364 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1365 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1366 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1367 | { |
| 1368 | pExtSpectCh->rssiAgr = rssi; // Reducing the rssi by -20 and assigning it to Subband 1 |
| 1369 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1370 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1371 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1372 | } |
| 1373 | pExtSpectCh = (pSpectCh + 2); |
| 1374 | if(pExtSpectCh != NULL) |
| 1375 | { |
| 1376 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1377 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1378 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1379 | { |
| 1380 | pExtSpectCh->rssiAgr = rssi; // Reducing the rssi by -30 and assigning it to Subband 2 |
| 1381 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1382 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1383 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1384 | } |
| 1385 | pExtSpectCh = (pSpectCh + 3); |
| 1386 | if(pExtSpectCh != NULL) |
| 1387 | { |
| 1388 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1389 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND3_RSSI_EFFECT_PRIMARY; |
| 1390 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1391 | { |
| 1392 | pExtSpectCh->rssiAgr = rssi; // Reducing the rssi by -40 and assigning it to Subband 3 |
| 1393 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1394 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1395 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1396 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1397 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1398 | else if((centerFreq - channel_id) == 2) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1399 | { |
| 1400 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1401 | pExtSpectCh = (pSpectCh - 1 ); |
| 1402 | if(pExtSpectCh != NULL) |
| 1403 | { |
| 1404 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1405 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1406 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1407 | { |
| 1408 | pExtSpectCh->rssiAgr = rssi; |
| 1409 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1410 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1411 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1412 | } |
| 1413 | pExtSpectCh = (pSpectCh + 1); |
| 1414 | if(pExtSpectCh != NULL) |
| 1415 | { |
| 1416 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1417 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1418 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1419 | { |
| 1420 | pExtSpectCh->rssiAgr = rssi; |
| 1421 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1422 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1423 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1424 | } |
| 1425 | pExtSpectCh = (pSpectCh + 2); |
| 1426 | if(pExtSpectCh != NULL) |
| 1427 | { |
| 1428 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1429 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1430 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1431 | { |
| 1432 | pExtSpectCh->rssiAgr = rssi; |
| 1433 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1434 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1435 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1436 | } |
| 1437 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1438 | else if((centerFreq - channel_id) == -2) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1439 | { |
| 1440 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1441 | pExtSpectCh = (pSpectCh - 1 ); |
| 1442 | if(pExtSpectCh != NULL) |
| 1443 | { |
| 1444 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1445 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1446 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1447 | { |
| 1448 | pExtSpectCh->rssiAgr = rssi; |
| 1449 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1450 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1451 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1452 | } |
| 1453 | pExtSpectCh = (pSpectCh - 2); |
| 1454 | if(pExtSpectCh != NULL) |
| 1455 | { |
| 1456 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1457 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1458 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1459 | { |
| 1460 | pExtSpectCh->rssiAgr = rssi; |
| 1461 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1462 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1463 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1464 | } |
| 1465 | pExtSpectCh = (pSpectCh + 1); |
| 1466 | if(pExtSpectCh != NULL) |
| 1467 | { |
| 1468 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1469 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1470 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1471 | { |
| 1472 | pExtSpectCh->rssiAgr = rssi; |
| 1473 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1474 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1475 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1476 | } |
| 1477 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1478 | else if((centerFreq - channel_id) == -6) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1479 | { |
| 1480 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1481 | pExtSpectCh = (pSpectCh - 1 ); |
| 1482 | if(pExtSpectCh != NULL) |
| 1483 | { |
| 1484 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1485 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1486 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1487 | { |
| 1488 | pExtSpectCh->rssiAgr = rssi; |
| 1489 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1490 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1491 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1492 | } |
| 1493 | pExtSpectCh = (pSpectCh - 2); |
| 1494 | if(pExtSpectCh != NULL) |
| 1495 | { |
| 1496 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1497 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1498 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1499 | { |
| 1500 | pExtSpectCh->rssiAgr = rssi; |
| 1501 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1502 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1503 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1504 | } |
| 1505 | pExtSpectCh = (pSpectCh - 3); |
| 1506 | if(pExtSpectCh != NULL) |
| 1507 | { |
| 1508 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1509 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND3_RSSI_EFFECT_PRIMARY; |
| 1510 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1511 | { |
| 1512 | pExtSpectCh->rssiAgr = rssi; |
| 1513 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1514 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1515 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1516 | } |
| 1517 | } |
| 1518 | break; |
| 1519 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1520 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1521 | else if(operatingBand == RF_SUBBAND_2_4_GHZ) |
| 1522 | { |
| 1523 | sapInterferenceRssiCount(pSpectCh); |
| 1524 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1525 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1526 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1527 | "In %s, bssdes.ch_self=%d, bssdes.ch_ID=%d, bssdes.rssi=%d, SpectCh.bssCount=%d, pScanResult=%p, ChannelWidth %d, secondaryChanOffset %d, center frequency %d \n", |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1528 | __func__, pScanResult->BssDescriptor.channelIdSelf, pScanResult->BssDescriptor.channelId, pScanResult->BssDescriptor.rssi, pSpectCh->bssCount, pScanResult,pSpectCh->channelWidth,secondaryChannelOffset,centerFreq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1529 | pSpectCh++; |
| 1530 | break; |
| 1531 | } else { |
| 1532 | pSpectCh++; |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | pScanResult = sme_ScanResultGetNext(halHandle, pResult); |
| 1537 | } |
| 1538 | |
| 1539 | // Calculate the weights for all channels in the spectrum pSpectCh |
| 1540 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 1541 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1542 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Spectrum Channels Weight", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1543 | |
| 1544 | for (chn_num = 0; chn_num < (pSpectInfoParams->numSpectChans); chn_num++) { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1545 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1546 | /* |
| 1547 | rssi : Maximum received signal strength among all BSS on that channel |
| 1548 | bssCount : Number of BSS on that channel |
| 1549 | */ |
| 1550 | |
| 1551 | rssi = (v_S7_t)pSpectCh->rssiAgr; |
| 1552 | |
| 1553 | pSpectCh->weight = SAPDFS_NORMALISE_1000 * sapweightRssiCount(rssi, pSpectCh->bssCount); |
| 1554 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame^] | 1555 | //------ Debug Info ------ |
| 1556 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1557 | "In %s, Chan=%d Weight= %d rssiAgr=%d bssCount=%d", __func__, |
| 1558 | pSpectCh->chNum, pSpectCh->weight, |
| 1559 | pSpectCh->rssiAgr, pSpectCh->bssCount); |
| 1560 | //------ Debug Info ------ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1561 | pSpectCh++; |
| 1562 | } |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1563 | vos_mem_free(pBeaconStruct); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
| 1566 | /*========================================================================== |
| 1567 | FUNCTION sapChanSelExit |
| 1568 | |
| 1569 | DESCRIPTION |
| 1570 | Exit function for free out the allocated memory, to be called |
| 1571 | at the end of the dfsSelectChannel function |
| 1572 | |
| 1573 | DEPENDENCIES |
| 1574 | NA. |
| 1575 | |
| 1576 | PARAMETERS |
| 1577 | |
| 1578 | IN |
| 1579 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1580 | |
| 1581 | RETURN VALUE |
| 1582 | void : NULL |
| 1583 | |
| 1584 | SIDE EFFECTS |
| 1585 | ============================================================================*/ |
| 1586 | void sapChanSelExit( tSapChSelSpectInfo *pSpectInfoParams ) |
| 1587 | { |
| 1588 | // Free all the allocated memory |
| 1589 | vos_mem_free(pSpectInfoParams->pSpectCh); |
| 1590 | } |
| 1591 | |
| 1592 | /*========================================================================== |
| 1593 | FUNCTION sapSortChlWeight |
| 1594 | |
| 1595 | DESCRIPTION |
| 1596 | Funtion to sort the channels with the least weight first |
| 1597 | |
| 1598 | DEPENDENCIES |
| 1599 | NA. |
| 1600 | |
| 1601 | PARAMETERS |
| 1602 | |
| 1603 | IN |
| 1604 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1605 | |
| 1606 | RETURN VALUE |
| 1607 | void : NULL |
| 1608 | |
| 1609 | SIDE EFFECTS |
| 1610 | ============================================================================*/ |
| 1611 | void sapSortChlWeight(tSapChSelSpectInfo *pSpectInfoParams) |
| 1612 | { |
| 1613 | tSapSpectChInfo temp; |
| 1614 | |
| 1615 | tSapSpectChInfo *pSpectCh = NULL; |
| 1616 | v_U32_t i = 0, j = 0, minWeightIndex = 0; |
| 1617 | |
| 1618 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 1619 | #ifdef SOFTAP_CHANNEL_RANGE |
| 1620 | // Sorting the channels as per weights |
| 1621 | for (i = 0; i < pSpectInfoParams->numSpectChans; i++) { |
| 1622 | minWeightIndex = i; |
| 1623 | for( j = i + 1; j < pSpectInfoParams->numSpectChans; j++) { |
| 1624 | if(pSpectCh[j].weight < pSpectCh[minWeightIndex].weight) { |
| 1625 | minWeightIndex = j; |
| 1626 | } |
| 1627 | } |
| 1628 | if(minWeightIndex != i) { |
| 1629 | vos_mem_copy(&temp, &pSpectCh[minWeightIndex], sizeof(*pSpectCh)); |
| 1630 | vos_mem_copy(&pSpectCh[minWeightIndex], &pSpectCh[i], sizeof(*pSpectCh)); |
| 1631 | vos_mem_copy(&pSpectCh[i], &temp, sizeof(*pSpectCh)); |
| 1632 | } |
| 1633 | } |
| 1634 | #else |
| 1635 | // Sorting the channels as per weights |
| 1636 | for (i = 0; i < SPECT_24GHZ_CH_COUNT; i++) { |
| 1637 | minWeightIndex = i; |
| 1638 | for( j = i + 1; j < SPECT_24GHZ_CH_COUNT; j++) { |
| 1639 | if(pSpectCh[j].weight < pSpectCh[minWeightIndex].weight) { |
| 1640 | minWeightIndex = j; |
| 1641 | } |
| 1642 | } |
| 1643 | if(minWeightIndex != i) { |
| 1644 | vos_mem_copy(&temp, &pSpectCh[minWeightIndex], sizeof(*pSpectCh)); |
| 1645 | vos_mem_copy(&pSpectCh[minWeightIndex], &pSpectCh[i], sizeof(*pSpectCh)); |
| 1646 | vos_mem_copy(&pSpectCh[i], &temp, sizeof(*pSpectCh)); |
| 1647 | } |
| 1648 | } |
| 1649 | #endif |
| 1650 | |
| 1651 | /* For testing */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1652 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Sorted Spectrum Channels Weight", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1653 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 1654 | for (j = 0; j < (pSpectInfoParams->numSpectChans); j++) { |
| 1655 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Channel=%d Weight= %d rssi=%d bssCount=%d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1656 | __func__, pSpectCh->chNum, pSpectCh->weight, pSpectCh->rssiAgr, pSpectCh->bssCount); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1657 | pSpectCh++; |
| 1658 | } |
| 1659 | |
| 1660 | } |
| 1661 | |
| 1662 | /*========================================================================== |
| 1663 | FUNCTION sapSelectChannel |
| 1664 | |
| 1665 | DESCRIPTION |
| 1666 | Runs a algorithm to select the best channel to operate in based on BSS |
| 1667 | rssi and bss count on each channel |
| 1668 | |
| 1669 | DEPENDENCIES |
| 1670 | NA. |
| 1671 | |
| 1672 | PARAMETERS |
| 1673 | |
| 1674 | IN |
| 1675 | halHandle : Pointer to HAL handle |
| 1676 | pResult : Pointer to tScanResultHandle |
| 1677 | |
| 1678 | RETURN VALUE |
| 1679 | v_U8_t : Success - channel number, Fail - zero |
| 1680 | |
| 1681 | SIDE EFFECTS |
| 1682 | ============================================================================*/ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 1683 | v_U8_t sapSelectChannel(tHalHandle halHandle, ptSapContext pSapCtx, tScanResultHandle pScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1684 | { |
| 1685 | // DFS param object holding all the data req by the algo |
| 1686 | tSapChSelSpectInfo oSpectInfoParams = {NULL,0}; |
| 1687 | tSapChSelSpectInfo *pSpectInfoParams = &oSpectInfoParams; // Memory? NB |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1688 | v_U8_t bestChNum = 0; |
| 1689 | #ifdef SOFTAP_CHANNEL_RANGE |
| 1690 | v_U32_t startChannelNum; |
| 1691 | v_U32_t endChannelNum; |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 1692 | v_U32_t operatingBand = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1693 | v_U8_t count = 0; |
| 1694 | #endif |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1695 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Running SAP Ch Select", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1696 | |
| 1697 | // Set to zero tSapChSelParams |
| 1698 | //vos_mem_zero(&sapChSelParams, sizeof(sapChSelParams)); |
| 1699 | |
| 1700 | // Initialize the structure pointed by pSpectInfoParams |
| 1701 | if(sapChanSelInit( halHandle, pSpectInfoParams) != eSAP_TRUE ) { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1702 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, Ch Select initialization failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1703 | return SAP_CHANNEL_NOT_SELECTED; |
| 1704 | } |
| 1705 | |
| 1706 | // Compute the weight of the entire spectrum in the operating band |
| 1707 | sapComputeSpectWeight( pSpectInfoParams, halHandle, pScanResult); |
| 1708 | |
| 1709 | // Sort the 20M channel list as per the computed weights, lesser weight first. |
| 1710 | sapSortChlWeight(pSpectInfoParams); |
| 1711 | |
| 1712 | #ifdef SOFTAP_CHANNEL_RANGE |
| 1713 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL, &startChannelNum); |
| 1714 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL, &endChannelNum); |
| 1715 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
| 1716 | |
| 1717 | /*Loop till get the best channel in the given range */ |
| 1718 | for(count=0; count < pSpectInfoParams->numSpectChans ; count++) |
| 1719 | { |
| 1720 | if((startChannelNum <= pSpectInfoParams->pSpectCh[count].chNum)&& |
| 1721 | ( endChannelNum >= pSpectInfoParams->pSpectCh[count].chNum)) |
| 1722 | { |
Bansidhar Gopalachari | 1e56faa | 2013-07-25 19:30:20 +0530 | [diff] [blame] | 1723 | if(bestChNum == 0) |
| 1724 | { |
| 1725 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[count].chNum; |
| 1726 | } |
| 1727 | else |
| 1728 | { |
| 1729 | if(operatingBand == RF_SUBBAND_2_4_GHZ) |
| 1730 | { |
| 1731 | /* Give preference to Non-overlap channels */ |
| 1732 | if(((pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_1) || |
| 1733 | (pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_6) || |
| 1734 | (pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_11))&& |
| 1735 | (pSpectInfoParams->pSpectCh[count].weight == 0)) |
| 1736 | { |
| 1737 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[count].chNum; |
| 1738 | break; |
| 1739 | } |
| 1740 | } |
| 1741 | } |
| 1742 | } |
| 1743 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1744 | #else |
| 1745 | // Get the first channel in sorted array as best 20M Channel |
| 1746 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[0].chNum; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1747 | #endif |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1748 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 1749 | //Select Best Channel from Channel List if Configured |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 1750 | bestChNum = sapSelectPreferredChannelFromChannelList(bestChNum, pSapCtx, pSpectInfoParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1751 | |
| 1752 | // Free all the allocated memory |
| 1753 | sapChanSelExit(pSpectInfoParams); |
| 1754 | |
| 1755 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Running SAP Ch select Completed, Ch=%d", |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1756 | __func__, bestChNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1757 | if (bestChNum > 0 && bestChNum <= 252) |
| 1758 | return bestChNum; |
| 1759 | else |
| 1760 | return SAP_CHANNEL_NOT_SELECTED; |
| 1761 | } |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1762 | |