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