Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 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. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /*=========================================================================== |
| 29 | |
| 30 | s a p C h S e l e c t . C |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | OVERVIEW: |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 32 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 33 | This software unit holds the implementation of the WLAN SAP modules |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 34 | functions for channel selection. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 36 | DEPENDENCIES: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 38 | Are listed for each API below. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 39 | ===========================================================================*/ |
| 40 | |
| 41 | /*=========================================================================== |
| 42 | |
| 43 | EDIT HISTORY FOR FILE |
| 44 | |
| 45 | |
| 46 | This section contains comments describing changes made to the module. |
| 47 | Notice that changes are listed in reverse chronological order. |
| 48 | |
| 49 | |
| 50 | |
| 51 | when who what, where, why |
| 52 | ---------- --- -------------------------------------------------------- |
| 53 | 2010-03-15 SOFTAP Created module |
| 54 | |
| 55 | ===========================================================================*/ |
| 56 | |
| 57 | |
| 58 | /*-------------------------------------------------------------------------- |
| 59 | Include Files |
| 60 | ------------------------------------------------------------------------*/ |
| 61 | #include "vos_trace.h" |
| 62 | #include "csrApi.h" |
| 63 | #include "sme_Api.h" |
| 64 | #include "sapChSelect.h" |
| 65 | #include "sapInternal.h" |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 66 | #ifdef ANI_OS_TYPE_QNX |
| 67 | #include "stdio.h" |
| 68 | #endif |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 69 | #include "wlan_hdd_main.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 70 | |
| 71 | /*-------------------------------------------------------------------------- |
| 72 | Function definitions |
| 73 | --------------------------------------------------------------------------*/ |
| 74 | |
| 75 | /*-------------------------------------------------------------------------- |
| 76 | Defines |
| 77 | --------------------------------------------------------------------------*/ |
| 78 | #define SAP_DEBUG |
| 79 | |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 80 | #define IS_RSSI_VALID( extRssi, rssi ) \ |
| 81 | ( \ |
| 82 | ((extRssi < rssi)?eANI_BOOLEAN_TRUE:eANI_BOOLEAN_FALSE) \ |
| 83 | ) |
| 84 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 85 | #ifdef FEATURE_WLAN_CH_AVOID |
| 86 | extern safeChannelType safeChannels[]; |
| 87 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 88 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 89 | /*========================================================================== |
| 90 | FUNCTION sapCleanupChannelList |
| 91 | |
| 92 | DESCRIPTION |
| 93 | Function sapCleanupChannelList frees up the memory allocated to the channel list. |
| 94 | |
| 95 | DEPENDENCIES |
| 96 | NA. |
| 97 | |
| 98 | PARAMETERS |
| 99 | |
| 100 | IN |
| 101 | NULL |
| 102 | |
| 103 | RETURN VALUE |
| 104 | NULL |
| 105 | ============================================================================*/ |
| 106 | |
| 107 | void sapCleanupChannelList(void) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 108 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 109 | 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] | 110 | ptSapContext pSapCtx; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 111 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 112 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 113 | "Cleaning up the channel list structure"); |
| 114 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 115 | if (NULL == pvosGCtx) |
| 116 | { |
| 117 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 118 | "SAP Global Context is NULL"); |
| 119 | return ; |
| 120 | } |
| 121 | |
| 122 | pSapCtx = VOS_GET_SAP_CB(pvosGCtx); |
| 123 | if (NULL == pSapCtx) |
| 124 | { |
| 125 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 126 | "SAP Context is NULL"); |
| 127 | return ; |
| 128 | } |
| 129 | |
| 130 | pSapCtx->SapChnlList.numChannel = 0; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 131 | vos_mem_free(pSapCtx->SapChnlList.channelList); |
| 132 | pSapCtx->SapChnlList.channelList = NULL; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 135 | typedef struct |
| 136 | { |
| 137 | v_U16_t chStartNum; |
| 138 | v_U32_t weight; |
| 139 | } sapAcsChannelInfo; |
| 140 | |
| 141 | #define ACS_WEIGHT_MAX 4444 |
| 142 | |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 143 | sapAcsChannelInfo acsHT40Channels5G[ ] = { |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 144 | {36, ACS_WEIGHT_MAX}, |
| 145 | {44, ACS_WEIGHT_MAX}, |
| 146 | {52, ACS_WEIGHT_MAX}, |
| 147 | {60, ACS_WEIGHT_MAX}, |
| 148 | {100, ACS_WEIGHT_MAX}, |
| 149 | {108, ACS_WEIGHT_MAX}, |
| 150 | {116, ACS_WEIGHT_MAX}, |
| 151 | {124, ACS_WEIGHT_MAX}, |
| 152 | {132, ACS_WEIGHT_MAX}, |
| 153 | {140, ACS_WEIGHT_MAX}, |
| 154 | {149, ACS_WEIGHT_MAX}, |
| 155 | {157, ACS_WEIGHT_MAX}, |
| 156 | }; |
| 157 | |
| 158 | sapAcsChannelInfo acsHT80Channels[ ] = { |
| 159 | {36, ACS_WEIGHT_MAX}, |
| 160 | {52, ACS_WEIGHT_MAX}, |
| 161 | {100, ACS_WEIGHT_MAX}, |
| 162 | {116, ACS_WEIGHT_MAX}, |
| 163 | {132, ACS_WEIGHT_MAX}, |
| 164 | {149, ACS_WEIGHT_MAX}, |
| 165 | }; |
| 166 | |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 167 | sapAcsChannelInfo acsHT40Channels24G[ ] = { |
| 168 | {1, ACS_WEIGHT_MAX}, |
| 169 | {2, ACS_WEIGHT_MAX}, |
| 170 | {3, ACS_WEIGHT_MAX}, |
| 171 | {4, ACS_WEIGHT_MAX}, |
| 172 | {9, ACS_WEIGHT_MAX}, |
| 173 | }; |
| 174 | |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 175 | typedef enum { |
| 176 | CHWIDTH_HT20, |
| 177 | CHWIDTH_HT40, |
| 178 | CHWIDTH_HT80, |
| 179 | } eChannelWidthInfo; |
| 180 | |
| 181 | #define CHANNEL_165 165 |
| 182 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 183 | /*========================================================================== |
| 184 | FUNCTION sapSetPreferredChannel |
| 185 | |
| 186 | DESCRIPTION |
| 187 | Function sapSetPreferredChannel sets the channel list which has been configured |
| 188 | into sap context (pSapCtx) which will be used at the time of best channel selection. |
| 189 | |
| 190 | DEPENDENCIES |
| 191 | NA. |
| 192 | |
| 193 | PARAMETERS |
| 194 | |
| 195 | IN |
| 196 | *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] | 197 | |
| 198 | RETURN VALUE |
| 199 | int: return 0 when success else returns error code. |
| 200 | ============================================================================*/ |
| 201 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 202 | int sapSetPreferredChannel(tANI_U8* ptr) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 203 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 204 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 205 | 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] | 206 | ptSapContext pSapCtx; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 207 | tANI_U8* param; |
| 208 | int tempInt; |
| 209 | int j; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 210 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 211 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 212 | "Enter: %s", __func__); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 213 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 214 | if (NULL == pvosGCtx) |
| 215 | { |
| 216 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 217 | "SAP Global Context is NULL"); |
| 218 | return -EINVAL; |
| 219 | } |
| 220 | |
| 221 | pSapCtx = VOS_GET_SAP_CB(pvosGCtx); |
| 222 | if (NULL == pSapCtx) |
| 223 | { |
| 224 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL, |
| 225 | "SAP Context is NULL"); |
| 226 | return -EINVAL; |
| 227 | } |
| 228 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 229 | if (NULL != pSapCtx->SapChnlList.channelList) |
| 230 | { |
| 231 | sapCleanupChannelList(); |
| 232 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 233 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 234 | param = strchr(ptr, ' '); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 235 | /*no argument after the command*/ |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 236 | if (NULL == param) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 237 | { |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 238 | return -EINVAL; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 239 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 240 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 241 | /*no space after the command*/ |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 242 | else if (SPACE_ASCII_VALUE != *param) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 243 | { |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 244 | return -EINVAL; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 245 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 246 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 247 | param++; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 248 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 249 | /*removing empty spaces*/ |
| 250 | while((SPACE_ASCII_VALUE == *param)&& ('\0' != *param) ) param++; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 251 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 252 | /*no argument followed by spaces*/ |
| 253 | if('\0' == *param) |
| 254 | { |
| 255 | return -EINVAL; |
| 256 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 257 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 258 | /*getting the first argument ie the number of channels*/ |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 259 | if (sscanf(param, "%d ", &tempInt) != 1) |
| 260 | { |
| 261 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 262 | "%s: Cannot get number of channels from input", __func__); |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 263 | return -EINVAL; |
| 264 | } |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 265 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 266 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 267 | "%s: Number of channel added are: %d", __func__, tempInt); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 268 | |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 269 | if (tempInt <= 0 || tempInt > 255) |
| 270 | { |
| 271 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 272 | "%s: Invalid Number of channel received", __func__); |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 273 | return -EINVAL; |
| 274 | } |
| 275 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 276 | /*allocating space for the desired number of channels*/ |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 277 | pSapCtx->SapChnlList.channelList = (v_U8_t *)vos_mem_malloc(tempInt); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 278 | |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 279 | if (NULL == pSapCtx->SapChnlList.channelList) |
| 280 | { |
| 281 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 282 | "In %s, VOS_MALLOC_ERR", __func__); |
| 283 | return -EINVAL; |
| 284 | } |
| 285 | |
| 286 | pSapCtx->SapChnlList.numChannel = tempInt; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 287 | for(j=0;j<pSapCtx->SapChnlList.numChannel;j++) |
| 288 | { |
| 289 | |
| 290 | /*param pointing to the beginning of first space after number of channels*/ |
| 291 | param = strpbrk( param, " " ); |
| 292 | /*no channel list after the number of channels argument*/ |
| 293 | if (NULL == param) |
| 294 | { |
| 295 | sapCleanupChannelList(); |
| 296 | return -EINVAL; |
| 297 | } |
| 298 | |
| 299 | param++; |
| 300 | |
| 301 | /*removing empty space*/ |
| 302 | while((SPACE_ASCII_VALUE == *param) && ('\0' != *param) ) param++; |
| 303 | |
| 304 | /*no channel list after the number of channels argument and spaces*/ |
| 305 | if( '\0' == *param ) |
| 306 | { |
| 307 | sapCleanupChannelList(); |
| 308 | return -EINVAL; |
| 309 | } |
| 310 | |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 311 | if (sscanf(param, "%d ", &tempInt) != 1) |
| 312 | { |
| 313 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 314 | "%s: Cannot read channel number", __func__); |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 315 | sapCleanupChannelList(); |
| 316 | return -EINVAL; |
| 317 | } |
| 318 | if (tempInt < 0 || tempInt > 255) |
| 319 | { |
| 320 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 321 | "%s: Invalid channel number received", __func__); |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 322 | sapCleanupChannelList(); |
| 323 | return -EINVAL; |
| 324 | } |
| 325 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 326 | pSapCtx->SapChnlList.channelList[j] = tempInt; |
| 327 | |
| 328 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Jeff Johnson | a47e992 | 2013-11-05 12:01:42 -0800 | [diff] [blame] | 329 | "%s: Channel %d added to preferred channel list", |
| 330 | __func__, pSapCtx->SapChnlList.channelList[j] ); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 331 | |
| 332 | } |
| 333 | |
| 334 | /*extra arguments check*/ |
| 335 | param = strpbrk( param, " " ); |
| 336 | if (NULL != param) |
| 337 | { |
| 338 | while((SPACE_ASCII_VALUE == *param) && ('\0' != *param) ) param++; |
| 339 | |
| 340 | if('\0' != *param) |
| 341 | { |
| 342 | sapCleanupChannelList(); |
| 343 | return -EINVAL; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 348 | "Exit: %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 349 | |
| 350 | return 0; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /*========================================================================== |
| 354 | FUNCTION sapSelectPreferredChannelFromChannelList |
| 355 | |
| 356 | DESCRIPTION |
| 357 | Function sapSelectPreferredChannelFromChannelList calculates the best channel |
| 358 | among the configured channel list. If channel list not configured then returns |
| 359 | the best channel calculated among all the channel list. |
| 360 | |
| 361 | DEPENDENCIES |
| 362 | NA. |
| 363 | |
| 364 | PARAMETERS |
| 365 | |
| 366 | IN |
| 367 | *pSpectInfoParams : Pointer to tSapChSelSpectInfo structure |
| 368 | bestChNum: best channel already calculated among all the chanels |
| 369 | pSapCtx: having info of channel list from which best channel is selected |
| 370 | |
| 371 | RETURN VALUE |
| 372 | v_U8_t: best channel |
| 373 | ============================================================================*/ |
| 374 | v_U8_t sapSelectPreferredChannelFromChannelList(v_U8_t bestChNum, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 375 | ptSapContext pSapCtx, |
| 376 | tSapChSelSpectInfo *pSpectInfoParams) |
| 377 | { |
| 378 | v_U8_t j = 0; |
| 379 | v_U8_t count = 0; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 380 | |
| 381 | //If Channel List is not Configured don't do anything |
| 382 | //Else return the Best Channel from the Channel List |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 383 | if((NULL == pSapCtx->SapChnlList.channelList) || |
| 384 | (NULL == pSpectInfoParams) || |
| 385 | (0 == pSapCtx->SapChnlList.numChannel)) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 386 | { |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 387 | return bestChNum; |
| 388 | } |
| 389 | |
| 390 | if (bestChNum > 0 && bestChNum <= 252) |
| 391 | { |
| 392 | for(count=0; count < pSpectInfoParams->numSpectChans ; count++) |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 393 | { |
| 394 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[count].chNum; |
| 395 | // Select the best channel from allowed list |
| 396 | for(j=0;j< pSapCtx->SapChnlList.numChannel;j++) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 397 | { |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 398 | if( (pSapCtx->SapChnlList.channelList[j]) == bestChNum) |
| 399 | { |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 400 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 401 | "Best channel computed from Channel List is: %d", |
| 402 | bestChNum); |
| 403 | return bestChNum; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 404 | } |
| 405 | } |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | return SAP_CHANNEL_NOT_SELECTED; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 409 | } |
| 410 | else |
| 411 | return SAP_CHANNEL_NOT_SELECTED; |
| 412 | } |
| 413 | |
| 414 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 415 | /*========================================================================== |
| 416 | FUNCTION sapChanSelInit |
| 417 | |
| 418 | DESCRIPTION |
| 419 | Function sapChanSelInit allocates the memory, intializes the |
| 420 | structures used by the channel selection algorithm |
| 421 | |
| 422 | DEPENDENCIES |
| 423 | NA. |
| 424 | |
| 425 | PARAMETERS |
| 426 | |
| 427 | IN |
| 428 | *pSpectInfoParams : Pointer to tSapChSelSpectInfo structure |
| 429 | |
| 430 | RETURN VALUE |
| 431 | v_BOOL_t: Success or FAIL |
| 432 | |
| 433 | SIDE EFFECTS |
| 434 | ============================================================================*/ |
| 435 | v_BOOL_t sapChanSelInit(tHalHandle halHandle, tSapChSelSpectInfo *pSpectInfoParams) |
| 436 | { |
| 437 | tSapSpectChInfo *pSpectCh = NULL; |
| 438 | v_U8_t *pChans = NULL; |
| 439 | v_U16_t channelnum = 0; |
| 440 | tpAniSirGlobal pMac = PMAC_STRUCT(halHandle); |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 441 | #ifdef FEATURE_WLAN_CH_AVOID |
| 442 | v_U16_t i; |
| 443 | v_BOOL_t chSafe = VOS_TRUE; |
| 444 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 445 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 446 | 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] | 447 | |
| 448 | // Channels for that 2.4GHz band |
| 449 | //Considered only for 2.4GHz need to change in future to support 5GHz support |
| 450 | pSpectInfoParams->numSpectChans = pMac->scan.base20MHzChannels.numChannels; |
| 451 | |
| 452 | // Allocate memory for weight computation of 2.4GHz |
| 453 | pSpectCh = (tSapSpectChInfo *)vos_mem_malloc((pSpectInfoParams->numSpectChans) * sizeof(*pSpectCh)); |
| 454 | |
| 455 | if(pSpectCh == NULL) { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 456 | 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] | 457 | return eSAP_FALSE; |
| 458 | } |
| 459 | |
| 460 | vos_mem_zero(pSpectCh, (pSpectInfoParams->numSpectChans) * sizeof(*pSpectCh)); |
| 461 | |
| 462 | // Initialize the pointers in the DfsParams to the allocated memory |
| 463 | pSpectInfoParams->pSpectCh = pSpectCh; |
| 464 | |
| 465 | pChans = pMac->scan.base20MHzChannels.channelList; |
| 466 | |
| 467 | // Fill the channel number in the spectrum in the operating freq band |
| 468 | for (channelnum = 0; channelnum < pSpectInfoParams->numSpectChans; channelnum++) { |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 469 | #ifdef FEATURE_WLAN_CH_AVOID |
| 470 | chSafe = VOS_TRUE; |
| 471 | for(i = 0; i < NUM_20MHZ_RF_CHANNELS; i++) |
| 472 | { |
| 473 | if((safeChannels[i].channelNumber == *pChans) && |
| 474 | (VOS_FALSE == safeChannels[i].isSafe)) |
| 475 | { |
| 476 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 477 | "%s : CH %d is not safe", __func__, *pChans); |
| 478 | chSafe = VOS_FALSE; |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 483 | |
| 484 | if(*pChans == 14 ) //OFDM rates are not supported on channel 14 |
Abhishek Singh | b51853c | 2014-03-13 18:26:41 +0530 | [diff] [blame] | 485 | { |
| 486 | pChans++; |
Kaushik, Sushant | e054e47 | 2014-09-26 19:45:48 +0530 | [diff] [blame] | 487 | pSpectCh++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 488 | continue; |
Abhishek Singh | b51853c | 2014-03-13 18:26:41 +0530 | [diff] [blame] | 489 | } |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 490 | #ifdef FEATURE_WLAN_CH_AVOID |
| 491 | if (VOS_TRUE == chSafe) |
| 492 | { |
| 493 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 494 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_DEBUG, |
| 495 | "%s : Available Ch %d", |
| 496 | __func__, *pChans); |
| 497 | pSpectCh->chNum = *pChans; |
| 498 | pSpectCh->valid = eSAP_TRUE; |
| 499 | // Initialise for all channels |
| 500 | pSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 501 | // Initialise 20MHz for all the Channels |
| 502 | pSpectCh->channelWidth = SOFTAP_HT20_CHANNELWIDTH; |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 503 | #ifdef FEATURE_WLAN_CH_AVOID |
| 504 | } |
| 505 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Kaushik, Sushant | e054e47 | 2014-09-26 19:45:48 +0530 | [diff] [blame] | 506 | pSpectCh++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 507 | pChans++; |
| 508 | } |
| 509 | return eSAP_TRUE; |
| 510 | } |
| 511 | |
| 512 | /*========================================================================== |
| 513 | FUNCTION sapweightRssiCount |
| 514 | |
| 515 | DESCRIPTION |
| 516 | Function weightRssiCount calculates the channel weight due to rssi |
| 517 | and data count(here number of BSS observed) |
| 518 | |
| 519 | DEPENDENCIES |
| 520 | NA. |
| 521 | |
| 522 | PARAMETERS |
| 523 | |
| 524 | IN |
| 525 | rssi : Max signal strength receieved from a BSS for the channel |
| 526 | count : Number of BSS observed in the channel |
| 527 | |
| 528 | RETURN VALUE |
| 529 | v_U32_t : Calculated channel weight based on above two |
| 530 | |
| 531 | SIDE EFFECTS |
| 532 | ============================================================================*/ |
| 533 | v_U32_t sapweightRssiCount(v_S7_t rssi, v_U16_t count) |
| 534 | { |
| 535 | v_S31_t rssiWeight=0; |
| 536 | v_S31_t countWeight=0; |
| 537 | v_U32_t rssicountWeight=0; |
| 538 | |
| 539 | // Weight from RSSI |
| 540 | rssiWeight = SOFTAP_RSSI_WEIGHT * (rssi - SOFTAP_MIN_RSSI) |
| 541 | /(SOFTAP_MAX_RSSI - SOFTAP_MIN_RSSI); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 542 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 543 | if(rssiWeight > SOFTAP_RSSI_WEIGHT) |
| 544 | rssiWeight = SOFTAP_RSSI_WEIGHT; |
| 545 | else if (rssiWeight < 0) |
| 546 | rssiWeight = 0; |
| 547 | |
| 548 | // Weight from data count |
| 549 | countWeight = SOFTAP_COUNT_WEIGHT * (count - SOFTAP_MIN_COUNT) |
| 550 | /(SOFTAP_MAX_COUNT - SOFTAP_MIN_COUNT); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 551 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 552 | if(countWeight > SOFTAP_COUNT_WEIGHT) |
| 553 | countWeight = SOFTAP_COUNT_WEIGHT; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 554 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 555 | rssicountWeight = rssiWeight + countWeight; |
| 556 | |
| 557 | 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] | 558 | __func__, rssiWeight, countWeight, rssicountWeight); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | |
| 560 | return(rssicountWeight); |
| 561 | } |
| 562 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 563 | |
| 564 | /*========================================================================== |
| 565 | FUNCTION sapInterferenceRssiCount |
| 566 | |
| 567 | DESCRIPTION |
| 568 | Function sapInterferenceRssiCount Considers the Adjacent channel rssi |
| 569 | and data count(here number of BSS observed) |
| 570 | |
| 571 | DEPENDENCIES |
| 572 | NA. |
| 573 | |
| 574 | PARAMETERS |
| 575 | |
| 576 | pSpectCh : Channel Information |
| 577 | |
| 578 | RETURN VALUE |
| 579 | NA. |
| 580 | |
| 581 | SIDE EFFECTS |
| 582 | ============================================================================*/ |
| 583 | void sapInterferenceRssiCount(tSapSpectChInfo *pSpectCh) |
| 584 | { |
| 585 | tSapSpectChInfo *pExtSpectCh = NULL; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 586 | v_S31_t rssi; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 587 | |
Abhishek Singh | 4eb7906 | 2014-04-10 14:48:14 +0530 | [diff] [blame] | 588 | if (NULL == pSpectCh) |
| 589 | { |
| 590 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 591 | "%s: pSpectCh is NULL", __func__); |
| 592 | return; |
| 593 | } |
| 594 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 595 | switch(pSpectCh->chNum) |
| 596 | { |
| 597 | case CHANNEL_1: |
| 598 | pExtSpectCh = (pSpectCh + 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 599 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 600 | { |
| 601 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 602 | rssi = pSpectCh->rssiAgr + |
| 603 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 604 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 605 | { |
| 606 | pExtSpectCh->rssiAgr = rssi; |
| 607 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 608 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 609 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 610 | } |
| 611 | pExtSpectCh = (pSpectCh + 2); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 612 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 613 | { |
| 614 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 615 | rssi = pSpectCh->rssiAgr + |
| 616 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 617 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 618 | { |
| 619 | pExtSpectCh->rssiAgr = rssi; |
| 620 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 621 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 622 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 623 | } |
| 624 | pExtSpectCh = (pSpectCh + 3); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 625 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 626 | { |
| 627 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 628 | rssi = pSpectCh->rssiAgr + |
| 629 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 630 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 631 | { |
| 632 | pExtSpectCh->rssiAgr = rssi; |
| 633 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 634 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 635 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 636 | } |
| 637 | pExtSpectCh = (pSpectCh + 4); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 638 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 639 | { |
| 640 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 641 | rssi = pSpectCh->rssiAgr + |
| 642 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 643 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 644 | { |
| 645 | pExtSpectCh->rssiAgr = rssi; |
| 646 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 647 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 648 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 649 | } |
| 650 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 651 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 652 | case CHANNEL_2: |
| 653 | pExtSpectCh = (pSpectCh - 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 654 | if (pExtSpectCh != NULL) |
| 655 | { |
| 656 | ++pExtSpectCh->bssCount; |
| 657 | rssi = pSpectCh->rssiAgr + |
| 658 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 659 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 660 | { |
| 661 | pExtSpectCh->rssiAgr = rssi; |
| 662 | } |
| 663 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 664 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 665 | } |
| 666 | pExtSpectCh = (pSpectCh + 1); |
| 667 | if (pExtSpectCh != NULL) |
| 668 | { |
| 669 | ++pExtSpectCh->bssCount; |
| 670 | rssi = pSpectCh->rssiAgr + |
| 671 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 672 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 673 | { |
| 674 | pExtSpectCh->rssiAgr = rssi; |
| 675 | } |
| 676 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 677 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 678 | } |
| 679 | pExtSpectCh = (pSpectCh + 2); |
| 680 | if (pExtSpectCh != NULL) |
| 681 | { |
| 682 | ++pExtSpectCh->bssCount; |
| 683 | rssi = pSpectCh->rssiAgr + |
| 684 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 685 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 686 | { |
| 687 | pExtSpectCh->rssiAgr = rssi; |
| 688 | } |
| 689 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 690 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 691 | } |
| 692 | pExtSpectCh = (pSpectCh + 3); |
| 693 | if (pExtSpectCh != NULL) |
| 694 | { |
| 695 | ++pExtSpectCh->bssCount; |
| 696 | rssi = pSpectCh->rssiAgr + |
| 697 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 698 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 699 | { |
| 700 | pExtSpectCh->rssiAgr = rssi; |
| 701 | } |
| 702 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 703 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 704 | } |
| 705 | pExtSpectCh = (pSpectCh + 4); |
| 706 | if (pExtSpectCh != NULL) |
| 707 | { |
| 708 | ++pExtSpectCh->bssCount; |
| 709 | rssi = pSpectCh->rssiAgr + |
| 710 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 711 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 712 | { |
| 713 | pExtSpectCh->rssiAgr = rssi; |
| 714 | } |
| 715 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 716 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 717 | } |
| 718 | break; |
| 719 | case CHANNEL_3: |
| 720 | pExtSpectCh = (pSpectCh - 2); |
| 721 | if (pExtSpectCh != NULL) |
| 722 | { |
| 723 | ++pExtSpectCh->bssCount; |
| 724 | rssi = pSpectCh->rssiAgr + |
| 725 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 726 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 727 | { |
| 728 | pExtSpectCh->rssiAgr = rssi; |
| 729 | } |
| 730 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 731 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 732 | } |
| 733 | pExtSpectCh = (pSpectCh - 1); |
| 734 | if (pExtSpectCh != NULL) |
| 735 | { |
| 736 | ++pExtSpectCh->bssCount; |
| 737 | rssi = pSpectCh->rssiAgr + |
| 738 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 739 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 740 | { |
| 741 | pExtSpectCh->rssiAgr = rssi; |
| 742 | } |
| 743 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 744 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 745 | } |
| 746 | pExtSpectCh = (pSpectCh + 1); |
| 747 | if (pExtSpectCh != NULL) |
| 748 | { |
| 749 | ++pExtSpectCh->bssCount; |
| 750 | rssi = pSpectCh->rssiAgr + |
| 751 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 752 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 753 | { |
| 754 | pExtSpectCh->rssiAgr = rssi; |
| 755 | } |
| 756 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 757 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 758 | } |
| 759 | pExtSpectCh = (pSpectCh + 2); |
| 760 | if (pExtSpectCh != NULL) |
| 761 | { |
| 762 | ++pExtSpectCh->bssCount; |
| 763 | rssi = pSpectCh->rssiAgr + |
| 764 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 765 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 766 | { |
| 767 | pExtSpectCh->rssiAgr = rssi; |
| 768 | } |
| 769 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 770 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 771 | } |
| 772 | pExtSpectCh = (pSpectCh + 3); |
| 773 | if (pExtSpectCh != NULL) |
| 774 | { |
| 775 | ++pExtSpectCh->bssCount; |
| 776 | rssi = pSpectCh->rssiAgr + |
| 777 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 778 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 779 | { |
| 780 | pExtSpectCh->rssiAgr = rssi; |
| 781 | } |
| 782 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 783 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 784 | } |
| 785 | pExtSpectCh = (pSpectCh + 4); |
| 786 | if (pExtSpectCh != NULL) |
| 787 | { |
| 788 | ++pExtSpectCh->bssCount; |
| 789 | rssi = pSpectCh->rssiAgr + |
| 790 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 791 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 792 | { |
| 793 | pExtSpectCh->rssiAgr = rssi; |
| 794 | } |
| 795 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 796 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 797 | } |
| 798 | break; |
| 799 | case CHANNEL_4: |
| 800 | pExtSpectCh = (pSpectCh - 3); |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 801 | if(pExtSpectCh != NULL) |
| 802 | { |
| 803 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 804 | rssi = pSpectCh->rssiAgr + |
| 805 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 806 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 807 | { |
| 808 | pExtSpectCh->rssiAgr = rssi; |
| 809 | } |
| 810 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 811 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 812 | } |
| 813 | pExtSpectCh = (pSpectCh - 2); |
| 814 | if (pExtSpectCh != NULL) |
| 815 | { |
| 816 | ++pExtSpectCh->bssCount; |
| 817 | rssi = pSpectCh->rssiAgr + |
| 818 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 819 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 820 | { |
| 821 | pExtSpectCh->rssiAgr = rssi; |
| 822 | } |
| 823 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 824 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 825 | } |
| 826 | pExtSpectCh = (pSpectCh - 1); |
| 827 | if (pExtSpectCh != NULL) |
| 828 | { |
| 829 | ++pExtSpectCh->bssCount; |
| 830 | rssi = pSpectCh->rssiAgr + |
| 831 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 832 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 833 | { |
| 834 | pExtSpectCh->rssiAgr = rssi; |
| 835 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 836 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 837 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 838 | } |
| 839 | pExtSpectCh = (pSpectCh + 1); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 840 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 841 | { |
| 842 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 843 | rssi = pSpectCh->rssiAgr + |
| 844 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 845 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 846 | { |
| 847 | pExtSpectCh->rssiAgr = rssi; |
| 848 | } |
| 849 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 850 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 851 | } |
| 852 | pExtSpectCh = (pSpectCh + 2); |
| 853 | if (pExtSpectCh != NULL) |
| 854 | { |
| 855 | ++pExtSpectCh->bssCount; |
| 856 | rssi = pSpectCh->rssiAgr + |
| 857 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 858 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 859 | { |
| 860 | pExtSpectCh->rssiAgr = rssi; |
| 861 | } |
| 862 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 863 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 864 | } |
| 865 | pExtSpectCh = (pSpectCh + 3); |
| 866 | if (pExtSpectCh != NULL) |
| 867 | { |
| 868 | ++pExtSpectCh->bssCount; |
| 869 | rssi = pSpectCh->rssiAgr + |
| 870 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 871 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 872 | { |
| 873 | pExtSpectCh->rssiAgr = rssi; |
| 874 | } |
| 875 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 876 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 877 | } |
| 878 | pExtSpectCh = (pSpectCh + 4); |
| 879 | if (pExtSpectCh != NULL) |
| 880 | { |
| 881 | ++pExtSpectCh->bssCount; |
| 882 | rssi = pSpectCh->rssiAgr + |
| 883 | SAP_24GHZ_FOURTH_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 | break; |
| 892 | |
| 893 | case CHANNEL_5: |
| 894 | case CHANNEL_6: |
| 895 | case CHANNEL_7: |
| 896 | pExtSpectCh = (pSpectCh - 4); |
| 897 | if (pExtSpectCh != NULL) |
| 898 | { |
| 899 | ++pExtSpectCh->bssCount; |
| 900 | rssi = pSpectCh->rssiAgr + |
| 901 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 902 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 903 | { |
| 904 | pExtSpectCh->rssiAgr = rssi; |
| 905 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 906 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 907 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 908 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 909 | pExtSpectCh = (pSpectCh - 3); |
| 910 | if (pExtSpectCh != NULL) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 911 | { |
| 912 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 913 | rssi = pSpectCh->rssiAgr + |
| 914 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 915 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 916 | { |
| 917 | pExtSpectCh->rssiAgr = rssi; |
| 918 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 919 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 920 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 921 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 922 | pExtSpectCh = (pSpectCh - 2); |
| 923 | if (pExtSpectCh != NULL) |
| 924 | { |
| 925 | ++pExtSpectCh->bssCount; |
| 926 | rssi = pSpectCh->rssiAgr + |
| 927 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 928 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 929 | { |
| 930 | pExtSpectCh->rssiAgr = rssi; |
| 931 | } |
| 932 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 933 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 934 | } |
| 935 | pExtSpectCh = (pSpectCh - 1); |
| 936 | if(pExtSpectCh != NULL) |
| 937 | { |
| 938 | ++pExtSpectCh->bssCount; |
| 939 | rssi = pSpectCh->rssiAgr + |
| 940 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 941 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 942 | { |
| 943 | pExtSpectCh->rssiAgr = rssi; |
| 944 | } |
| 945 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 946 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 947 | } |
| 948 | pExtSpectCh = (pSpectCh + 1); |
| 949 | if (pExtSpectCh != NULL) |
| 950 | { |
| 951 | ++pExtSpectCh->bssCount; |
| 952 | rssi = pSpectCh->rssiAgr + |
| 953 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 954 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 955 | { |
| 956 | pExtSpectCh->rssiAgr = rssi; |
| 957 | } |
| 958 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 959 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 960 | } |
| 961 | pExtSpectCh = (pSpectCh + 2); |
| 962 | if(pExtSpectCh != NULL) |
| 963 | { |
| 964 | ++pExtSpectCh->bssCount; |
| 965 | rssi = pSpectCh->rssiAgr + |
| 966 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 967 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 968 | { |
| 969 | pExtSpectCh->rssiAgr = rssi; |
| 970 | } |
| 971 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 972 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 973 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 974 | pExtSpectCh = (pSpectCh + 3); |
| 975 | if(pExtSpectCh != NULL) |
| 976 | { |
| 977 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 978 | rssi = pSpectCh->rssiAgr + |
| 979 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 980 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 981 | { |
| 982 | pExtSpectCh->rssiAgr = rssi; |
| 983 | } |
| 984 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 985 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 986 | } |
| 987 | pExtSpectCh = (pSpectCh + 4); |
| 988 | if (pExtSpectCh != NULL) |
| 989 | { |
| 990 | ++pExtSpectCh->bssCount; |
| 991 | rssi = pSpectCh->rssiAgr + |
| 992 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 993 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 994 | { |
| 995 | pExtSpectCh->rssiAgr = rssi; |
| 996 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 997 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 998 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 999 | } |
| 1000 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1001 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1002 | case CHANNEL_8: |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1003 | pExtSpectCh = (pSpectCh - 4); |
| 1004 | if(pExtSpectCh != NULL) |
| 1005 | { |
| 1006 | ++pExtSpectCh->bssCount; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1007 | rssi = pSpectCh->rssiAgr + |
| 1008 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1009 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1010 | { |
| 1011 | pExtSpectCh->rssiAgr = rssi; |
| 1012 | } |
| 1013 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1014 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1015 | } |
| 1016 | |
| 1017 | pExtSpectCh = (pSpectCh - 3); |
| 1018 | if (pExtSpectCh != NULL) |
| 1019 | { |
| 1020 | ++pExtSpectCh->bssCount; |
| 1021 | rssi = pSpectCh->rssiAgr + |
| 1022 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1023 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1024 | { |
| 1025 | pExtSpectCh->rssiAgr = rssi; |
| 1026 | } |
| 1027 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1028 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1029 | } |
| 1030 | pExtSpectCh = (pSpectCh - 2); |
| 1031 | if (pExtSpectCh != NULL) |
| 1032 | { |
| 1033 | ++pExtSpectCh->bssCount; |
| 1034 | rssi = pSpectCh->rssiAgr + |
| 1035 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1036 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1037 | { |
| 1038 | pExtSpectCh->rssiAgr = rssi; |
| 1039 | } |
| 1040 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1041 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1042 | } |
| 1043 | pExtSpectCh = (pSpectCh - 1); |
| 1044 | if (pExtSpectCh != NULL) |
| 1045 | { |
| 1046 | ++pExtSpectCh->bssCount; |
| 1047 | rssi = pSpectCh->rssiAgr + |
| 1048 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1049 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1050 | { |
| 1051 | pExtSpectCh->rssiAgr = rssi; |
| 1052 | } |
| 1053 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1054 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1055 | } |
| 1056 | pExtSpectCh = (pSpectCh + 1); |
| 1057 | if (pExtSpectCh != NULL) |
| 1058 | { |
| 1059 | ++pExtSpectCh->bssCount; |
| 1060 | rssi = pSpectCh->rssiAgr + |
| 1061 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1062 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1063 | { |
| 1064 | pExtSpectCh->rssiAgr = rssi; |
| 1065 | } |
| 1066 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1067 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1068 | } |
| 1069 | pExtSpectCh = (pSpectCh + 2); |
| 1070 | if (pExtSpectCh != NULL) |
| 1071 | { |
| 1072 | ++pExtSpectCh->bssCount; |
| 1073 | rssi = pSpectCh->rssiAgr + |
| 1074 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1075 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1076 | { |
| 1077 | pExtSpectCh->rssiAgr = rssi; |
| 1078 | } |
| 1079 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1080 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1081 | } |
| 1082 | pExtSpectCh = (pSpectCh + 3); |
| 1083 | if (pExtSpectCh != NULL) |
| 1084 | { |
| 1085 | ++pExtSpectCh->bssCount; |
| 1086 | rssi = pSpectCh->rssiAgr + |
| 1087 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1088 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1089 | { |
| 1090 | pExtSpectCh->rssiAgr = rssi; |
| 1091 | } |
| 1092 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1093 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1094 | } |
| 1095 | break; |
| 1096 | |
| 1097 | case CHANNEL_9: |
| 1098 | pExtSpectCh = (pSpectCh - 4); |
| 1099 | if (pExtSpectCh != NULL) |
| 1100 | { |
| 1101 | ++pExtSpectCh->bssCount; |
| 1102 | rssi = pSpectCh->rssiAgr + |
| 1103 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1104 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1105 | { |
| 1106 | pExtSpectCh->rssiAgr = rssi; |
| 1107 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1108 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1109 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1110 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1111 | |
| 1112 | pExtSpectCh = (pSpectCh - 3); |
| 1113 | if (pExtSpectCh != NULL) |
| 1114 | { |
| 1115 | ++pExtSpectCh->bssCount; |
| 1116 | rssi = pSpectCh->rssiAgr + |
| 1117 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1118 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1119 | { |
| 1120 | pExtSpectCh->rssiAgr = rssi; |
| 1121 | } |
| 1122 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1123 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1124 | } |
| 1125 | pExtSpectCh = (pSpectCh - 2); |
| 1126 | if (pExtSpectCh != NULL) |
| 1127 | { |
| 1128 | ++pExtSpectCh->bssCount; |
| 1129 | rssi = pSpectCh->rssiAgr + |
| 1130 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1131 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1132 | { |
| 1133 | pExtSpectCh->rssiAgr = rssi; |
| 1134 | } |
| 1135 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1136 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1137 | } |
| 1138 | pExtSpectCh = (pSpectCh - 1); |
| 1139 | if (pExtSpectCh != NULL) |
| 1140 | { |
| 1141 | ++pExtSpectCh->bssCount; |
| 1142 | rssi = pSpectCh->rssiAgr + |
| 1143 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1144 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1145 | { |
| 1146 | pExtSpectCh->rssiAgr = rssi; |
| 1147 | } |
| 1148 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1149 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1150 | } |
| 1151 | pExtSpectCh = (pSpectCh + 1); |
| 1152 | if (pExtSpectCh != NULL) |
| 1153 | { |
| 1154 | ++pExtSpectCh->bssCount; |
| 1155 | rssi = pSpectCh->rssiAgr + |
| 1156 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1157 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1158 | { |
| 1159 | pExtSpectCh->rssiAgr = rssi; |
| 1160 | } |
| 1161 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1162 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1163 | } |
| 1164 | pExtSpectCh = (pSpectCh + 2); |
| 1165 | if (pExtSpectCh != NULL) |
| 1166 | { |
| 1167 | ++pExtSpectCh->bssCount; |
| 1168 | rssi = pSpectCh->rssiAgr + |
| 1169 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1170 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1171 | { |
| 1172 | pExtSpectCh->rssiAgr = rssi; |
| 1173 | } |
| 1174 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1175 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1176 | } |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1177 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1178 | |
| 1179 | case CHANNEL_10: |
| 1180 | pExtSpectCh = (pSpectCh - 4); |
| 1181 | if (pExtSpectCh != NULL) |
| 1182 | { |
| 1183 | ++pExtSpectCh->bssCount; |
| 1184 | rssi = pSpectCh->rssiAgr + |
| 1185 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1186 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1187 | { |
| 1188 | pExtSpectCh->rssiAgr = rssi; |
| 1189 | } |
| 1190 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1191 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1192 | } |
| 1193 | |
| 1194 | pExtSpectCh = (pSpectCh - 3); |
| 1195 | if (pExtSpectCh != NULL) |
| 1196 | { |
| 1197 | ++pExtSpectCh->bssCount; |
| 1198 | rssi = pSpectCh->rssiAgr + |
| 1199 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1200 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1201 | { |
| 1202 | pExtSpectCh->rssiAgr = rssi; |
| 1203 | } |
| 1204 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1205 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1206 | } |
| 1207 | pExtSpectCh = (pSpectCh - 2); |
| 1208 | if(pExtSpectCh != NULL) |
| 1209 | { |
| 1210 | ++pExtSpectCh->bssCount; |
| 1211 | rssi = pSpectCh->rssiAgr + |
| 1212 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1213 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1214 | { |
| 1215 | pExtSpectCh->rssiAgr = rssi; |
| 1216 | } |
| 1217 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1218 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1219 | } |
| 1220 | pExtSpectCh = (pSpectCh - 1); |
| 1221 | if (pExtSpectCh != NULL) |
| 1222 | { |
| 1223 | ++pExtSpectCh->bssCount; |
| 1224 | rssi = pSpectCh->rssiAgr + |
| 1225 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1226 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1227 | { |
| 1228 | pExtSpectCh->rssiAgr = rssi; |
| 1229 | } |
| 1230 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1231 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1232 | } |
| 1233 | pExtSpectCh = (pSpectCh + 1); |
| 1234 | if (pExtSpectCh != NULL) |
| 1235 | { |
| 1236 | ++pExtSpectCh->bssCount; |
| 1237 | rssi = pSpectCh->rssiAgr + |
| 1238 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1239 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1240 | { |
| 1241 | pExtSpectCh->rssiAgr = rssi; |
| 1242 | } |
| 1243 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1244 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1245 | } |
| 1246 | break; |
| 1247 | |
| 1248 | case CHANNEL_11: |
| 1249 | pExtSpectCh = (pSpectCh - 1); |
| 1250 | if (pExtSpectCh != NULL) |
| 1251 | { |
| 1252 | ++pExtSpectCh->bssCount; |
| 1253 | rssi = pSpectCh->rssiAgr + |
| 1254 | SAP_24GHZ_FIRST_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1255 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1256 | { |
| 1257 | pExtSpectCh->rssiAgr = rssi; |
| 1258 | } |
| 1259 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1260 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1261 | } |
| 1262 | pExtSpectCh = (pSpectCh - 2); |
| 1263 | if (pExtSpectCh != NULL) |
| 1264 | { |
| 1265 | ++pExtSpectCh->bssCount; |
| 1266 | rssi = pSpectCh->rssiAgr + |
| 1267 | SAP_24GHZ_SEC_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1268 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1269 | { |
| 1270 | pExtSpectCh->rssiAgr = rssi; |
| 1271 | } |
| 1272 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1273 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1274 | } |
| 1275 | pExtSpectCh = (pSpectCh - 3); |
| 1276 | if (pExtSpectCh != NULL) |
| 1277 | { |
| 1278 | ++pExtSpectCh->bssCount; |
| 1279 | rssi = pSpectCh->rssiAgr + |
| 1280 | SAP_24GHZ_THIRD_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1281 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1282 | { |
| 1283 | pExtSpectCh->rssiAgr = rssi; |
| 1284 | } |
| 1285 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1286 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1287 | } |
| 1288 | pExtSpectCh = (pSpectCh - 4); |
| 1289 | if (pExtSpectCh != NULL) |
| 1290 | { |
| 1291 | ++pExtSpectCh->bssCount; |
| 1292 | rssi = pSpectCh->rssiAgr + |
| 1293 | SAP_24GHZ_FOURTH_OVERLAP_CHAN_RSSI_EFFECT_PRIMARY; |
| 1294 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1295 | { |
| 1296 | pExtSpectCh->rssiAgr = rssi; |
| 1297 | } |
| 1298 | if (pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1299 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1300 | } |
| 1301 | break; |
| 1302 | |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1303 | default: |
| 1304 | break; |
| 1305 | } |
| 1306 | } |
| 1307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1308 | /*========================================================================== |
| 1309 | FUNCTION sapComputeSpectWeight |
| 1310 | |
| 1311 | DESCRIPTION |
| 1312 | Main function for computing the weight of each channel in the |
| 1313 | spectrum based on the RSSI value of the BSSes on the channel |
| 1314 | and number of BSS |
| 1315 | |
| 1316 | DEPENDENCIES |
| 1317 | NA. |
| 1318 | |
| 1319 | PARAMETERS |
| 1320 | |
| 1321 | IN |
| 1322 | pSpectInfoParams : Pointer to the tSpectInfoParams structure |
| 1323 | halHandle : Pointer to HAL handle |
| 1324 | pResult : Pointer to tScanResultHandle |
| 1325 | |
| 1326 | RETURN VALUE |
| 1327 | void : NULL |
| 1328 | |
| 1329 | SIDE EFFECTS |
| 1330 | ============================================================================*/ |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1331 | void sapComputeSpectWeight( tSapChSelSpectInfo* pSpectInfoParams, |
| 1332 | tHalHandle halHandle, tScanResultHandle pResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1333 | { |
| 1334 | v_S7_t rssi = 0; |
| 1335 | v_U8_t chn_num = 0; |
| 1336 | v_U8_t channel_id = 0; |
| 1337 | |
| 1338 | tCsrScanResultInfo *pScanResult; |
| 1339 | tSapSpectChInfo *pSpectCh = pSpectInfoParams->pSpectCh; |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1340 | v_U32_t operatingBand; |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1341 | v_U16_t channelWidth; |
| 1342 | v_U16_t secondaryChannelOffset; |
| 1343 | v_U16_t centerFreq; |
| 1344 | v_U16_t vhtSupport; |
| 1345 | v_U32_t ieLen = 0; |
| 1346 | tSirProbeRespBeacon *pBeaconStruct; |
| 1347 | tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1348 | |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1349 | pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon)); |
| 1350 | if ( NULL == pBeaconStruct ) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1351 | { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1352 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1353 | "Unable to allocate memory in sapComputeSpectWeight\n"); |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1354 | return; |
| 1355 | } |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1356 | 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] | 1357 | |
| 1358 | /** |
| 1359 | * Soft AP specific channel weight calculation using DFS formula |
| 1360 | */ |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1361 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1362 | |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1363 | pScanResult = sme_ScanResultGetFirst(halHandle, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1364 | |
| 1365 | while (pScanResult) { |
| 1366 | pSpectCh = pSpectInfoParams->pSpectCh; |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1367 | // Defining the default values, so that any value will hold the default values |
| 1368 | channelWidth = eHT_CHANNEL_WIDTH_20MHZ; |
| 1369 | secondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED; |
| 1370 | vhtSupport = 0; |
| 1371 | centerFreq = 0; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1372 | |
| 1373 | if (pScanResult->BssDescriptor.ieFields != NULL) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1374 | { |
| 1375 | ieLen = (pScanResult->BssDescriptor.length + sizeof(tANI_U16) + sizeof(tANI_U32) - sizeof(tSirBssDescription)); |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1376 | vos_mem_set((tANI_U8 *) pBeaconStruct, sizeof(tSirProbeRespBeacon), 0); |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1377 | |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1378 | if ((sirParseBeaconIE(pMac, pBeaconStruct,(tANI_U8 *)( pScanResult->BssDescriptor.ieFields), ieLen)) == eSIR_SUCCESS) |
| 1379 | { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1380 | if (pBeaconStruct->HTCaps.present && pBeaconStruct->HTInfo.present) |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1381 | { |
| 1382 | channelWidth = pBeaconStruct->HTCaps.supportedChannelWidthSet; |
| 1383 | secondaryChannelOffset = pBeaconStruct->HTInfo.secondaryChannelOffset; |
| 1384 | if(pBeaconStruct->VHTOperation.present) |
| 1385 | { |
| 1386 | vhtSupport = pBeaconStruct->VHTOperation.present; |
| 1387 | if(pBeaconStruct->VHTOperation.chanWidth > WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) |
| 1388 | { |
| 1389 | channelWidth = eHT_CHANNEL_WIDTH_80MHZ; |
| 1390 | centerFreq = pBeaconStruct->VHTOperation.chanCenterFreqSeg1; |
| 1391 | } |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | } |
Madan Mohan Koyyalamudi | 1e02f7f | 2012-12-04 16:46:45 -0800 | [diff] [blame] | 1396 | // Processing for each tCsrScanResultInfo in the tCsrScanResult DLink list |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1397 | for (chn_num = 0; chn_num < pSpectInfoParams->numSpectChans; chn_num++) { |
| 1398 | |
| 1399 | /* |
| 1400 | * if the Beacon has channel ID, use it other wise we will |
| 1401 | * rely on the channelIdSelf |
| 1402 | */ |
| 1403 | if(pScanResult->BssDescriptor.channelId == 0) |
| 1404 | channel_id = pScanResult->BssDescriptor.channelIdSelf; |
| 1405 | else |
| 1406 | channel_id = pScanResult->BssDescriptor.channelId; |
| 1407 | |
krunal soni | c39d959 | 2014-02-04 11:54:24 -0800 | [diff] [blame] | 1408 | if (pSpectCh && (channel_id == pSpectCh->chNum)) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1409 | if (pSpectCh->rssiAgr < pScanResult->BssDescriptor.rssi) |
| 1410 | pSpectCh->rssiAgr = pScanResult->BssDescriptor.rssi; |
| 1411 | |
| 1412 | ++pSpectCh->bssCount; // Increment the count of BSS |
| 1413 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1414 | if(operatingBand) // Connsidering the Extension Channel only in a channels |
| 1415 | { |
| 1416 | /* Updating the received ChannelWidth */ |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1417 | if (pSpectCh->channelWidth != channelWidth) |
| 1418 | pSpectCh->channelWidth = channelWidth; |
Madan Mohan Koyyalamudi | 1e02f7f | 2012-12-04 16:46:45 -0800 | [diff] [blame] | 1419 | /* If received ChannelWidth is other than HT20, we need to update the extension channel Params as well */ |
| 1420 | /* channelWidth == 0, HT20 */ |
| 1421 | /* channelWidth == 1, HT40 */ |
| 1422 | /* channelWidth == 2, VHT80*/ |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1423 | switch(pSpectCh->channelWidth) |
| 1424 | { |
| 1425 | case eHT_CHANNEL_WIDTH_40MHZ: //HT40 |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1426 | switch( secondaryChannelOffset) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1427 | { |
| 1428 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1429 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: // Above the Primary Channel |
| 1430 | pExtSpectCh = (pSpectCh + 1); |
| 1431 | if(pExtSpectCh != NULL) |
| 1432 | { |
| 1433 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1434 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1435 | // REducing the rssi by -20 and assigning it to Extension channel |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1436 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1437 | { |
| 1438 | pExtSpectCh->rssiAgr = rssi; |
| 1439 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1440 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1441 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1442 | } |
| 1443 | break; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1444 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1445 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: // Below the Primary channel |
| 1446 | pExtSpectCh = (pSpectCh - 1); |
| 1447 | if(pExtSpectCh != NULL) |
| 1448 | { |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1449 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1450 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1451 | { |
| 1452 | pExtSpectCh->rssiAgr = rssi; |
| 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; |
| 1456 | ++pExtSpectCh->bssCount; |
| 1457 | } |
| 1458 | break; |
| 1459 | } |
| 1460 | break; |
| 1461 | case eHT_CHANNEL_WIDTH_80MHZ: // VHT80 |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1462 | if((centerFreq - channel_id) == 6) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1463 | { |
| 1464 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 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; // Reducing the rssi by -20 and assigning it to Subband 1 |
| 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 | pExtSpectCh = (pSpectCh + 2); |
| 1478 | if(pExtSpectCh != NULL) |
| 1479 | { |
| 1480 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1481 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1482 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1483 | { |
| 1484 | pExtSpectCh->rssiAgr = rssi; // Reducing the rssi by -30 and assigning it to Subband 2 |
| 1485 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1486 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1487 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1488 | } |
| 1489 | pExtSpectCh = (pSpectCh + 3); |
| 1490 | if(pExtSpectCh != NULL) |
| 1491 | { |
| 1492 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1493 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND3_RSSI_EFFECT_PRIMARY; |
| 1494 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1495 | { |
| 1496 | pExtSpectCh->rssiAgr = rssi; // Reducing the rssi by -40 and assigning it to Subband 3 |
| 1497 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1498 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1499 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1500 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1501 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1502 | else if((centerFreq - channel_id) == 2) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1503 | { |
| 1504 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1505 | pExtSpectCh = (pSpectCh - 1 ); |
| 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_SUBBAND1_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 | pExtSpectCh = (pSpectCh + 1); |
| 1518 | if(pExtSpectCh != NULL) |
| 1519 | { |
| 1520 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1521 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1522 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1523 | { |
| 1524 | pExtSpectCh->rssiAgr = rssi; |
| 1525 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1526 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1527 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1528 | } |
| 1529 | pExtSpectCh = (pSpectCh + 2); |
| 1530 | if(pExtSpectCh != NULL) |
| 1531 | { |
| 1532 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1533 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1534 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1535 | { |
| 1536 | pExtSpectCh->rssiAgr = rssi; |
| 1537 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1538 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1539 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1540 | } |
| 1541 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1542 | else if((centerFreq - channel_id) == -2) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1543 | { |
| 1544 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1545 | pExtSpectCh = (pSpectCh - 1 ); |
| 1546 | if(pExtSpectCh != NULL) |
| 1547 | { |
| 1548 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1549 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1550 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1551 | { |
| 1552 | pExtSpectCh->rssiAgr = rssi; |
| 1553 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1554 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1555 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1556 | } |
| 1557 | pExtSpectCh = (pSpectCh - 2); |
| 1558 | if(pExtSpectCh != NULL) |
| 1559 | { |
| 1560 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1561 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1562 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1563 | { |
| 1564 | pExtSpectCh->rssiAgr = rssi; |
| 1565 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1566 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1567 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1568 | } |
| 1569 | pExtSpectCh = (pSpectCh + 1); |
| 1570 | if(pExtSpectCh != NULL) |
| 1571 | { |
| 1572 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1573 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1574 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1575 | { |
| 1576 | pExtSpectCh->rssiAgr = rssi; |
| 1577 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1578 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1579 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1580 | } |
| 1581 | } |
Prathyusha Kuntupalli | 7b8f6aa | 2012-12-10 13:17:35 -0800 | [diff] [blame] | 1582 | else if((centerFreq - channel_id) == -6) |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1583 | { |
| 1584 | tSapSpectChInfo *pExtSpectCh = NULL; |
| 1585 | pExtSpectCh = (pSpectCh - 1 ); |
| 1586 | if(pExtSpectCh != NULL) |
| 1587 | { |
| 1588 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1589 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND1_RSSI_EFFECT_PRIMARY; |
| 1590 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1591 | { |
| 1592 | pExtSpectCh->rssiAgr = rssi; |
| 1593 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1594 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1595 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1596 | } |
| 1597 | pExtSpectCh = (pSpectCh - 2); |
| 1598 | if(pExtSpectCh != NULL) |
| 1599 | { |
| 1600 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1601 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND2_RSSI_EFFECT_PRIMARY; |
| 1602 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1603 | { |
| 1604 | pExtSpectCh->rssiAgr = rssi; |
| 1605 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1606 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1607 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1608 | } |
| 1609 | pExtSpectCh = (pSpectCh - 3); |
| 1610 | if(pExtSpectCh != NULL) |
| 1611 | { |
| 1612 | ++pExtSpectCh->bssCount; |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 1613 | rssi = pSpectCh->rssiAgr + SAP_SUBBAND3_RSSI_EFFECT_PRIMARY; |
| 1614 | if (IS_RSSI_VALID(pExtSpectCh->rssiAgr, rssi)) |
| 1615 | { |
| 1616 | pExtSpectCh->rssiAgr = rssi; |
| 1617 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1618 | if(pExtSpectCh->rssiAgr < SOFTAP_MIN_RSSI) |
| 1619 | pExtSpectCh->rssiAgr = SOFTAP_MIN_RSSI; |
| 1620 | } |
| 1621 | } |
| 1622 | break; |
| 1623 | } |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1624 | } |
Leela Venkata Kiran Kumar Reddy Chirala | 9f6566c | 2014-09-05 19:06:58 +0530 | [diff] [blame] | 1625 | else if(operatingBand == eSAP_RF_SUBBAND_2_4_GHZ) |
Venkata Prathyusha Kuntupalli | e2e7208 | 2013-01-30 17:37:50 -0800 | [diff] [blame] | 1626 | { |
| 1627 | sapInterferenceRssiCount(pSpectCh); |
| 1628 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 1629 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1630 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1631 | "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] | 1632 | __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] | 1633 | pSpectCh++; |
| 1634 | break; |
| 1635 | } else { |
| 1636 | pSpectCh++; |
| 1637 | } |
| 1638 | } |
| 1639 | |
| 1640 | pScanResult = sme_ScanResultGetNext(halHandle, pResult); |
| 1641 | } |
| 1642 | |
| 1643 | // Calculate the weights for all channels in the spectrum pSpectCh |
| 1644 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 1645 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1646 | 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] | 1647 | |
| 1648 | for (chn_num = 0; chn_num < (pSpectInfoParams->numSpectChans); chn_num++) { |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1649 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1650 | /* |
| 1651 | rssi : Maximum received signal strength among all BSS on that channel |
| 1652 | bssCount : Number of BSS on that channel |
| 1653 | */ |
| 1654 | |
| 1655 | rssi = (v_S7_t)pSpectCh->rssiAgr; |
| 1656 | |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1657 | pSpectCh->weight = |
| 1658 | SAPDFS_NORMALISE_1000 * sapweightRssiCount(rssi, pSpectCh->bssCount); |
| 1659 | pSpectCh->weight_copy = pSpectCh->weight; |
Madan Mohan Koyyalamudi | 8c8bb1e | 2013-08-26 23:13:07 +0530 | [diff] [blame] | 1660 | //------ Debug Info ------ |
| 1661 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1662 | "In %s, Chan=%d Weight= %d rssiAgr=%d bssCount=%d", __func__, |
| 1663 | pSpectCh->chNum, pSpectCh->weight, |
| 1664 | pSpectCh->rssiAgr, pSpectCh->bssCount); |
| 1665 | //------ Debug Info ------ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1666 | pSpectCh++; |
| 1667 | } |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 1668 | vos_mem_free(pBeaconStruct); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | /*========================================================================== |
| 1672 | FUNCTION sapChanSelExit |
| 1673 | |
| 1674 | DESCRIPTION |
| 1675 | Exit function for free out the allocated memory, to be called |
| 1676 | at the end of the dfsSelectChannel function |
| 1677 | |
| 1678 | DEPENDENCIES |
| 1679 | NA. |
| 1680 | |
| 1681 | PARAMETERS |
| 1682 | |
| 1683 | IN |
| 1684 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1685 | |
| 1686 | RETURN VALUE |
| 1687 | void : NULL |
| 1688 | |
| 1689 | SIDE EFFECTS |
| 1690 | ============================================================================*/ |
| 1691 | void sapChanSelExit( tSapChSelSpectInfo *pSpectInfoParams ) |
| 1692 | { |
| 1693 | // Free all the allocated memory |
| 1694 | vos_mem_free(pSpectInfoParams->pSpectCh); |
| 1695 | } |
| 1696 | |
| 1697 | /*========================================================================== |
| 1698 | FUNCTION sapSortChlWeight |
| 1699 | |
| 1700 | DESCRIPTION |
| 1701 | Funtion to sort the channels with the least weight first |
| 1702 | |
| 1703 | DEPENDENCIES |
| 1704 | NA. |
| 1705 | |
| 1706 | PARAMETERS |
| 1707 | |
| 1708 | IN |
| 1709 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1710 | |
| 1711 | RETURN VALUE |
| 1712 | void : NULL |
| 1713 | |
| 1714 | SIDE EFFECTS |
| 1715 | ============================================================================*/ |
| 1716 | void sapSortChlWeight(tSapChSelSpectInfo *pSpectInfoParams) |
| 1717 | { |
| 1718 | tSapSpectChInfo temp; |
| 1719 | |
| 1720 | tSapSpectChInfo *pSpectCh = NULL; |
| 1721 | v_U32_t i = 0, j = 0, minWeightIndex = 0; |
| 1722 | |
| 1723 | pSpectCh = pSpectInfoParams->pSpectCh; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1724 | for (i = 0; i < pSpectInfoParams->numSpectChans; i++) { |
| 1725 | minWeightIndex = i; |
| 1726 | for( j = i + 1; j < pSpectInfoParams->numSpectChans; j++) { |
| 1727 | if(pSpectCh[j].weight < pSpectCh[minWeightIndex].weight) { |
| 1728 | minWeightIndex = j; |
| 1729 | } |
| 1730 | } |
| 1731 | if(minWeightIndex != i) { |
| 1732 | vos_mem_copy(&temp, &pSpectCh[minWeightIndex], sizeof(*pSpectCh)); |
| 1733 | vos_mem_copy(&pSpectCh[minWeightIndex], &pSpectCh[i], sizeof(*pSpectCh)); |
| 1734 | vos_mem_copy(&pSpectCh[i], &temp, sizeof(*pSpectCh)); |
| 1735 | } |
| 1736 | } |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | /*========================================================================== |
| 1740 | FUNCTION sapSortChlWeightHT80 |
| 1741 | |
| 1742 | DESCRIPTION |
| 1743 | Funtion to sort the channels with the least weight first for HT80 channels |
| 1744 | |
| 1745 | DEPENDENCIES |
| 1746 | NA. |
| 1747 | |
| 1748 | PARAMETERS |
| 1749 | |
| 1750 | IN |
| 1751 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1752 | |
| 1753 | RETURN VALUE |
| 1754 | void : NULL |
| 1755 | |
| 1756 | SIDE EFFECTS |
| 1757 | ============================================================================*/ |
| 1758 | void sapSortChlWeightHT80(tSapChSelSpectInfo *pSpectInfoParams) |
| 1759 | { |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1760 | v_U8_t i, j, n; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1761 | tSapSpectChInfo *pSpectInfo; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1762 | v_U8_t minIdx; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1763 | |
| 1764 | pSpectInfo = pSpectInfoParams->pSpectCh; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1765 | /* for each HT80 channel, calculate the combined weight of the |
| 1766 | four 20MHz weight */ |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1767 | for (i = 0; i < ARRAY_SIZE(acsHT80Channels); i++) |
| 1768 | { |
| 1769 | for (j = 0; j < pSpectInfoParams->numSpectChans; j++) |
| 1770 | { |
| 1771 | if ( pSpectInfo[j].chNum == acsHT80Channels[i].chStartNum ) |
| 1772 | break; |
| 1773 | } |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1774 | if (j == pSpectInfoParams->numSpectChans) |
| 1775 | continue; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1776 | |
| 1777 | /*found the channel, add the 4 adjacent channels' weight*/ |
| 1778 | if (((pSpectInfo[j].chNum +4) == pSpectInfo[j+1].chNum) && |
| 1779 | ((pSpectInfo[j].chNum +8) == pSpectInfo[j+2].chNum) && |
| 1780 | ((pSpectInfo[j].chNum +12) == pSpectInfo[j+3].chNum)) |
| 1781 | { |
| 1782 | acsHT80Channels[i].weight = pSpectInfo[j].weight + |
| 1783 | pSpectInfo[j+1].weight + |
| 1784 | pSpectInfo[j+2].weight + |
| 1785 | pSpectInfo[j+3].weight; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1786 | /* find best channel among 4 channels as the primary channel */ |
Rajesh Babu Prathipati | 32ddabf | 2014-09-11 16:08:59 +0530 | [diff] [blame] | 1787 | if ((pSpectInfo[j].weight + pSpectInfo[j+1].weight) < |
| 1788 | (pSpectInfo[j+2].weight + pSpectInfo[j+3].weight)) |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1789 | { |
Rajesh Babu Prathipati | 32ddabf | 2014-09-11 16:08:59 +0530 | [diff] [blame] | 1790 | /* lower 2 channels are better choice */ |
| 1791 | if (pSpectInfo[j].weight < pSpectInfo[j+1].weight) |
| 1792 | minIdx = 0; |
| 1793 | else |
| 1794 | minIdx = 1; |
| 1795 | } |
| 1796 | else |
| 1797 | { |
| 1798 | /* upper 2 channels are better choice */ |
| 1799 | if (pSpectInfo[j+2].weight <= pSpectInfo[j+3].weight) |
| 1800 | minIdx = 2; |
| 1801 | else |
| 1802 | minIdx = 3; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1803 | } |
| 1804 | |
| 1805 | /* set all 4 channels to max value first, then reset the |
| 1806 | best channel as the selected primary channel, update its |
| 1807 | weightage with the combined weight value */ |
| 1808 | for (n=0; n<4; n++) |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1809 | pSpectInfo[j+n].weight = ACS_WEIGHT_MAX * 4; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1810 | |
| 1811 | pSpectInfo[j+minIdx].weight = acsHT80Channels[i].weight; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1812 | } |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1813 | else |
| 1814 | { |
| 1815 | /* some channels does not exist in pSectInfo array, |
| 1816 | skip this channel and those in the same HT80 width*/ |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1817 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 4; |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1818 | if ((pSpectInfo[j].chNum +4) == pSpectInfo[j+1].chNum) |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1819 | pSpectInfo[j+1].weight = ACS_WEIGHT_MAX * 4; |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1820 | if ((pSpectInfo[j].chNum +8) == pSpectInfo[j+2].chNum) |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1821 | pSpectInfo[j+2].weight = ACS_WEIGHT_MAX * 4; |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1822 | if ((pSpectInfo[j].chNum +12) == pSpectInfo[j+3].chNum) |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1823 | pSpectInfo[j+3].weight = ACS_WEIGHT_MAX * 4; |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1824 | } |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1825 | } |
| 1826 | |
| 1827 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 1828 | for (j = 0; j < pSpectInfoParams->numSpectChans; j++) |
| 1829 | { |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1830 | if ( CHANNEL_165 == pSpectInfo[j].chNum ) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1831 | { |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1832 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 4; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1833 | break; |
| 1834 | } |
| 1835 | } |
| 1836 | |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 1837 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 1838 | for (j = 0; j < (pSpectInfoParams->numSpectChans); j++) { |
| 1839 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1840 | "In %s, Channel=%d Weight= %d rssi=%d bssCount=%d", |
| 1841 | __func__, pSpectInfo->chNum, pSpectInfo->weight, |
| 1842 | pSpectInfo->rssiAgr, pSpectInfo->bssCount); |
| 1843 | pSpectInfo++; |
| 1844 | } |
| 1845 | |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1846 | sapSortChlWeight(pSpectInfoParams); |
| 1847 | } |
| 1848 | |
| 1849 | /*========================================================================== |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1850 | FUNCTION sapSortChlWeightHT40_24G |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1851 | |
| 1852 | DESCRIPTION |
| 1853 | Funtion to sort the channels with the least weight first for 20MHz channels |
| 1854 | |
| 1855 | DEPENDENCIES |
| 1856 | NA. |
| 1857 | |
| 1858 | PARAMETERS |
| 1859 | |
| 1860 | IN |
| 1861 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1862 | |
| 1863 | RETURN VALUE |
| 1864 | void : NULL |
| 1865 | |
| 1866 | SIDE EFFECTS |
| 1867 | ============================================================================*/ |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1868 | void sapSortChlWeightHT40_24G(tSapChSelSpectInfo *pSpectInfoParams) |
| 1869 | { |
| 1870 | v_U8_t i, j; |
| 1871 | tSapSpectChInfo *pSpectInfo; |
| 1872 | v_U32_t tmpWeight1, tmpWeight2; |
| 1873 | |
| 1874 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 1875 | /*for each HT40 channel, calculate the combined weight of the |
| 1876 | two 20MHz weight */ |
| 1877 | for (i = 0; i < ARRAY_SIZE(acsHT40Channels24G); i++) |
| 1878 | { |
| 1879 | for (j = 0; j < pSpectInfoParams->numSpectChans; j++) |
| 1880 | { |
| 1881 | if (pSpectInfo[j].chNum == acsHT40Channels24G[i].chStartNum) |
| 1882 | break; |
| 1883 | } |
| 1884 | if (j == pSpectInfoParams->numSpectChans) |
| 1885 | continue; |
| 1886 | |
| 1887 | if ((pSpectInfo[j].chNum +4) == pSpectInfo[j+4].chNum) |
| 1888 | { |
| 1889 | /* check if there is another channel combination possiblity |
| 1890 | e.g., {1, 5} & {5, 9} */ |
| 1891 | if ((pSpectInfo[j+4].chNum + 4)== pSpectInfo[j+8].chNum) |
| 1892 | { |
| 1893 | /* need to compare two channel pairs */ |
| 1894 | tmpWeight1 = pSpectInfo[j].weight + pSpectInfo[j+4].weight; |
| 1895 | tmpWeight2 = pSpectInfo[j+4].weight + pSpectInfo[j+8].weight; |
| 1896 | if (tmpWeight1 <= tmpWeight2) |
| 1897 | { |
| 1898 | if (pSpectInfo[j].weight <= pSpectInfo[j+4].weight) |
| 1899 | { |
| 1900 | pSpectInfo[j].weight = tmpWeight1; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1901 | pSpectInfo[j+4].weight = ACS_WEIGHT_MAX * 2; |
| 1902 | pSpectInfo[j+8].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1903 | } |
| 1904 | else |
| 1905 | { |
| 1906 | pSpectInfo[j+4].weight = tmpWeight1; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1907 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
| 1908 | pSpectInfo[j+8].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1909 | } |
| 1910 | } |
| 1911 | else |
| 1912 | { |
| 1913 | if (pSpectInfo[j+4].weight <= pSpectInfo[j+8].weight) |
| 1914 | { |
| 1915 | pSpectInfo[j+4].weight = tmpWeight2; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1916 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
| 1917 | pSpectInfo[j+8].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1918 | } |
| 1919 | else |
| 1920 | { |
| 1921 | pSpectInfo[j+8].weight = tmpWeight2; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1922 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
| 1923 | pSpectInfo[j+4].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1924 | } |
| 1925 | } |
| 1926 | } |
| 1927 | else |
| 1928 | { |
| 1929 | tmpWeight1 = pSpectInfo[j].weight + pSpectInfo[j+4].weight; |
| 1930 | if (pSpectInfo[j].weight <= pSpectInfo[j+4].weight) |
| 1931 | { |
| 1932 | pSpectInfo[j].weight = tmpWeight1; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1933 | pSpectInfo[j+4].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1934 | } |
| 1935 | else |
| 1936 | { |
| 1937 | pSpectInfo[j+4].weight = tmpWeight1; |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1938 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1939 | } |
| 1940 | } |
| 1941 | } |
| 1942 | else |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1943 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1944 | } |
Rajesh Babu Prathipati | 684ad72 | 2014-09-11 16:14:05 +0530 | [diff] [blame] | 1945 | |
| 1946 | sapSortChlWeight(pSpectInfoParams); |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 1947 | } |
| 1948 | |
| 1949 | |
| 1950 | /*========================================================================== |
| 1951 | FUNCTION sapSortChlWeightHT40_5G |
| 1952 | |
| 1953 | DESCRIPTION |
| 1954 | Funtion to sort the channels with the least weight first for HT40 channels |
| 1955 | |
| 1956 | DEPENDENCIES |
| 1957 | NA. |
| 1958 | |
| 1959 | PARAMETERS |
| 1960 | |
| 1961 | IN |
| 1962 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 1963 | |
| 1964 | RETURN VALUE |
| 1965 | void : NULL |
| 1966 | |
| 1967 | SIDE EFFECTS |
| 1968 | ============================================================================*/ |
| 1969 | void sapSortChlWeightHT40_5G(tSapChSelSpectInfo *pSpectInfoParams) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1970 | { |
| 1971 | v_U8_t i, j; |
| 1972 | tSapSpectChInfo *pSpectInfo; |
| 1973 | |
| 1974 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 1975 | /*for each HT40 channel, calculate the combined weight of the |
| 1976 | two 20MHz weight */ |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1977 | for (i = 0; i < ARRAY_SIZE(acsHT40Channels5G); i++) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1978 | { |
| 1979 | for (j = 0; j < pSpectInfoParams->numSpectChans; j++) |
| 1980 | { |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1981 | if (pSpectInfo[j].chNum == acsHT40Channels5G[i].chStartNum) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1982 | break; |
| 1983 | } |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1984 | if (j == pSpectInfoParams->numSpectChans) |
| 1985 | continue; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1986 | |
| 1987 | /* found the channel, add the two adjacent channels' weight */ |
| 1988 | if ( (pSpectInfo[j].chNum +4) == pSpectInfo[j+1].chNum) |
| 1989 | { |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 1990 | acsHT40Channels5G[i].weight = pSpectInfo[j].weight + |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 1991 | pSpectInfo[j+1].weight; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1992 | /* select better of the adjact channel as the primary channel */ |
| 1993 | if (pSpectInfo[j].weight <= pSpectInfo[j+1].weight) |
| 1994 | { |
| 1995 | pSpectInfo[j].weight = acsHT40Channels5G[i].weight; |
| 1996 | /* mark the adjacent channel's weight as max value so |
| 1997 | that it will be sorted to the bottom */ |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 1998 | pSpectInfo[j+1].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 1999 | } |
| 2000 | else |
| 2001 | { |
| 2002 | pSpectInfo[j+1].weight = acsHT40Channels5G[i].weight; |
| 2003 | /* mark the adjacent channel's weight as max value so |
| 2004 | that it will be sorted to the bottom */ |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2005 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
Rajesh Babu Prathipati | af5ceac | 2014-09-09 13:10:25 +0530 | [diff] [blame] | 2006 | } |
| 2007 | |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2008 | } |
Rajesh Babu Prathipati | 2bc3059 | 2014-09-09 13:05:26 +0530 | [diff] [blame] | 2009 | else |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2010 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | /* avoid channel 165 by setting its weight to max */ |
| 2014 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 2015 | for (j = 0; j < pSpectInfoParams->numSpectChans; j++) |
| 2016 | { |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2017 | if ( CHANNEL_165 == pSpectInfo[j].chNum ) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2018 | { |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2019 | pSpectInfo[j].weight = ACS_WEIGHT_MAX * 2; |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2020 | break; |
| 2021 | } |
| 2022 | } |
| 2023 | |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2024 | pSpectInfo = pSpectInfoParams->pSpectCh; |
| 2025 | for (j = 0; j < (pSpectInfoParams->numSpectChans); j++) { |
| 2026 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2027 | "In %s, Channel=%d Weight= %d rssi=%d bssCount=%d", |
| 2028 | __func__, pSpectInfo->chNum, pSpectInfo->weight, |
| 2029 | pSpectInfo->rssiAgr, pSpectInfo->bssCount); |
| 2030 | pSpectInfo++; |
| 2031 | } |
| 2032 | |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2033 | sapSortChlWeight(pSpectInfoParams); |
| 2034 | } |
| 2035 | |
| 2036 | /*========================================================================== |
| 2037 | FUNCTION sapSortChlWeightAll |
| 2038 | |
| 2039 | DESCRIPTION |
| 2040 | Funtion to sort the channels with the least weight first |
| 2041 | |
| 2042 | DEPENDENCIES |
| 2043 | NA. |
| 2044 | |
| 2045 | PARAMETERS |
| 2046 | |
| 2047 | IN |
| 2048 | ptSapContext : Pointer to the ptSapContext structure |
| 2049 | pSpectInfoParams : Pointer to the tSapChSelSpectInfo structure |
| 2050 | |
| 2051 | RETURN VALUE |
| 2052 | void : NULL |
| 2053 | |
| 2054 | SIDE EFFECTS |
| 2055 | ============================================================================*/ |
| 2056 | void sapSortChlWeightAll(ptSapContext pSapCtx, |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2057 | tSapChSelSpectInfo *pSpectInfoParams, |
| 2058 | eChannelWidthInfo chWidth, |
| 2059 | v_U32_t operatingBand) |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2060 | { |
| 2061 | tSapSpectChInfo *pSpectCh = NULL; |
| 2062 | v_U32_t j = 0; |
| 2063 | #ifndef SOFTAP_CHANNEL_RANGE |
| 2064 | v_U32_t i = 0; |
| 2065 | #endif |
| 2066 | |
| 2067 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 2068 | #ifdef SOFTAP_CHANNEL_RANGE |
| 2069 | |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2070 | switch (chWidth) |
| 2071 | { |
| 2072 | case CHWIDTH_HT40: |
Rajesh Babu Prathipati | ff748c0 | 2014-09-09 13:19:57 +0530 | [diff] [blame] | 2073 | if (eSAP_RF_SUBBAND_2_4_GHZ == operatingBand) |
| 2074 | sapSortChlWeightHT40_24G(pSpectInfoParams); |
| 2075 | else |
| 2076 | sapSortChlWeightHT40_5G(pSpectInfoParams); |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2077 | break; |
| 2078 | |
| 2079 | case CHWIDTH_HT80: |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2080 | sapSortChlWeightHT80(pSpectInfoParams); |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2081 | break; |
| 2082 | |
| 2083 | case CHWIDTH_HT20: |
| 2084 | default: |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2085 | /* Sorting the channels as per weights as 20MHz channels */ |
| 2086 | sapSortChlWeight(pSpectInfoParams); |
| 2087 | } |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2088 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2089 | #else |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2090 | /* Sorting the channels as per weights */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2091 | for (i = 0; i < SPECT_24GHZ_CH_COUNT; i++) { |
| 2092 | minWeightIndex = i; |
| 2093 | for( j = i + 1; j < SPECT_24GHZ_CH_COUNT; j++) { |
| 2094 | if(pSpectCh[j].weight < pSpectCh[minWeightIndex].weight) { |
| 2095 | minWeightIndex = j; |
| 2096 | } |
| 2097 | } |
| 2098 | if(minWeightIndex != i) { |
| 2099 | vos_mem_copy(&temp, &pSpectCh[minWeightIndex], sizeof(*pSpectCh)); |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2100 | vos_mem_copy(&pSpectCh[minWeightIndex], &pSpectCh[i], |
| 2101 | sizeof(*pSpectCh)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2102 | vos_mem_copy(&pSpectCh[i], &temp, sizeof(*pSpectCh)); |
| 2103 | } |
| 2104 | } |
| 2105 | #endif |
| 2106 | |
| 2107 | /* For testing */ |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2108 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2109 | "In %s, Sorted Spectrum Channels Weight", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2110 | pSpectCh = pSpectInfoParams->pSpectCh; |
| 2111 | for (j = 0; j < (pSpectInfoParams->numSpectChans); j++) { |
Peng Xu | 7d410f4 | 2014-09-09 12:15:47 +0530 | [diff] [blame] | 2112 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2113 | "In %s, Channel=%d Weight= %d rssi=%d bssCount=%d", |
| 2114 | __func__, pSpectCh->chNum, pSpectCh->weight, |
| 2115 | pSpectCh->rssiAgr, pSpectCh->bssCount); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2116 | pSpectCh++; |
| 2117 | } |
| 2118 | |
| 2119 | } |
| 2120 | |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2121 | eChannelWidthInfo sapGetChannelWidthInfo(tHalHandle halHandle, ptSapContext pSapCtx, |
| 2122 | v_U32_t operatingBand, eSapPhyMode phyMode) |
| 2123 | { |
| 2124 | v_U32_t cbMode; |
| 2125 | eChannelWidthInfo chWidth = CHWIDTH_HT20; |
| 2126 | |
Hardik Kantilal Patel | dd10795 | 2014-11-20 15:24:52 +0530 | [diff] [blame] | 2127 | #ifdef WLAN_FEATURE_AP_HT40_24G |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2128 | if (eSAP_RF_SUBBAND_2_4_GHZ == operatingBand) |
| 2129 | cbMode = sme_GetChannelBondingMode24G(halHandle); |
| 2130 | else |
Hardik Kantilal Patel | dd10795 | 2014-11-20 15:24:52 +0530 | [diff] [blame] | 2131 | #endif |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2132 | cbMode = sme_GetChannelBondingMode5G(halHandle); |
| 2133 | |
| 2134 | if (phyMode == eSAP_DOT11_MODE_11n || |
| 2135 | phyMode == eSAP_DOT11_MODE_11n_ONLY) |
| 2136 | { |
| 2137 | if (cbMode) |
| 2138 | chWidth = CHWIDTH_HT40; |
| 2139 | else |
| 2140 | chWidth = CHWIDTH_HT20; |
| 2141 | } |
| 2142 | else if (pSapCtx->csrRoamProfile.phyMode == eSAP_DOT11_MODE_11ac || |
| 2143 | pSapCtx->csrRoamProfile.phyMode == eSAP_DOT11_MODE_11ac_ONLY) { |
| 2144 | chWidth = CHWIDTH_HT80; |
| 2145 | } |
| 2146 | else { |
| 2147 | /* Sorting the channels as per weights as 20MHz channels */ |
| 2148 | chWidth = CHWIDTH_HT20; |
| 2149 | } |
| 2150 | |
| 2151 | return chWidth; |
| 2152 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2153 | /*========================================================================== |
| 2154 | FUNCTION sapSelectChannel |
| 2155 | |
| 2156 | DESCRIPTION |
| 2157 | Runs a algorithm to select the best channel to operate in based on BSS |
| 2158 | rssi and bss count on each channel |
| 2159 | |
| 2160 | DEPENDENCIES |
| 2161 | NA. |
| 2162 | |
| 2163 | PARAMETERS |
| 2164 | |
| 2165 | IN |
| 2166 | halHandle : Pointer to HAL handle |
| 2167 | pResult : Pointer to tScanResultHandle |
| 2168 | |
| 2169 | RETURN VALUE |
| 2170 | v_U8_t : Success - channel number, Fail - zero |
| 2171 | |
| 2172 | SIDE EFFECTS |
| 2173 | ============================================================================*/ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 2174 | v_U8_t sapSelectChannel(tHalHandle halHandle, ptSapContext pSapCtx, tScanResultHandle pScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2175 | { |
| 2176 | // DFS param object holding all the data req by the algo |
| 2177 | tSapChSelSpectInfo oSpectInfoParams = {NULL,0}; |
| 2178 | tSapChSelSpectInfo *pSpectInfoParams = &oSpectInfoParams; // Memory? NB |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2179 | v_U8_t bestChNum = SAP_CHANNEL_NOT_SELECTED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2180 | #ifdef SOFTAP_CHANNEL_RANGE |
| 2181 | v_U32_t startChannelNum; |
| 2182 | v_U32_t endChannelNum; |
Gopichand Nakkala | 936715f | 2013-03-18 19:48:10 +0530 | [diff] [blame] | 2183 | v_U32_t operatingBand = 0; |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2184 | v_U32_t tmpChNum; |
| 2185 | v_U8_t count; |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2186 | eChannelWidthInfo chWidth; |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2187 | #endif |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2188 | 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] | 2189 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2190 | // Initialize the structure pointed by pSpectInfoParams |
| 2191 | if(sapChanSelInit( halHandle, pSpectInfoParams) != eSAP_TRUE ) { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2192 | 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] | 2193 | return SAP_CHANNEL_NOT_SELECTED; |
| 2194 | } |
| 2195 | |
| 2196 | // Compute the weight of the entire spectrum in the operating band |
| 2197 | sapComputeSpectWeight( pSpectInfoParams, halHandle, pScanResult); |
| 2198 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2199 | #ifdef SOFTAP_CHANNEL_RANGE |
Peng Xu | fc6ad8e | 2014-09-25 13:16:43 +0530 | [diff] [blame] | 2200 | if (eCSR_BAND_ALL == pSapCtx->scanBandPreference) |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 2201 | { |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2202 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL, |
| 2203 | &startChannelNum); |
| 2204 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL, |
| 2205 | &endChannelNum); |
| 2206 | ccmCfgGetInt( halHandle, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, |
| 2207 | &operatingBand); |
Peng Xu | fc6ad8e | 2014-09-25 13:16:43 +0530 | [diff] [blame] | 2208 | } |
| 2209 | else |
| 2210 | { |
| 2211 | if (eCSR_BAND_24 == pSapCtx->currentPreferredBand) |
| 2212 | { |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 2213 | startChannelNum = rfChannels[RF_CHAN_1].channelNum; |
| 2214 | endChannelNum = rfChannels[RF_CHAN_14].channelNum; |
Leela Venkata Kiran Kumar Reddy Chirala | 9f6566c | 2014-09-05 19:06:58 +0530 | [diff] [blame] | 2215 | operatingBand = eSAP_RF_SUBBAND_2_4_GHZ; |
Peng Xu | fc6ad8e | 2014-09-25 13:16:43 +0530 | [diff] [blame] | 2216 | } |
| 2217 | else |
| 2218 | { |
Peng Xu | 2446a89 | 2014-09-05 17:21:18 +0530 | [diff] [blame] | 2219 | startChannelNum = rfChannels[RF_CHAN_36].channelNum; |
| 2220 | endChannelNum = rfChannels[RF_CHAN_165].channelNum; |
Deepthi Gowri | 7db41f3 | 2014-10-13 17:02:29 +0530 | [diff] [blame] | 2221 | operatingBand = eSAP_RF_SUBBAND_5_ALL_GHZ; |
Peng Xu | fc6ad8e | 2014-09-25 13:16:43 +0530 | [diff] [blame] | 2222 | } |
| 2223 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2224 | |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2225 | pSapCtx->acsBestChannelInfo.channelNum = 0; |
| 2226 | pSapCtx->acsBestChannelInfo.weight = CFG_ACS_BAND_SWITCH_THRESHOLD_MAX; |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2227 | /* find the channel width info */ |
| 2228 | chWidth = sapGetChannelWidthInfo(halHandle, pSapCtx, operatingBand, pSapCtx->csrRoamProfile.phyMode); |
| 2229 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2230 | "In %s, chWidth=%u", __func__, chWidth); |
| 2231 | |
| 2232 | /* Sort the channel list as per the computed weights, lesser weight first.*/ |
| 2233 | sapSortChlWeightAll(pSapCtx, pSpectInfoParams, chWidth, operatingBand); |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2234 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2235 | /*Loop till get the best channel in the given range */ |
| 2236 | for(count=0; count < pSpectInfoParams->numSpectChans ; count++) |
| 2237 | { |
| 2238 | if((startChannelNum <= pSpectInfoParams->pSpectCh[count].chNum)&& |
| 2239 | ( endChannelNum >= pSpectInfoParams->pSpectCh[count].chNum)) |
| 2240 | { |
Deepthi Gowri | 38c219d | 2014-08-05 19:34:08 +0530 | [diff] [blame] | 2241 | if (NV_CHANNEL_ENABLE != |
| 2242 | vos_nv_getChannelEnabledState(pSpectInfoParams->pSpectCh[count].chNum)) |
| 2243 | { |
| 2244 | continue; //skip this channel, continue to next channel |
| 2245 | } |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2246 | if(bestChNum == SAP_CHANNEL_NOT_SELECTED) |
Bansidhar Gopalachari | 1e56faa | 2013-07-25 19:30:20 +0530 | [diff] [blame] | 2247 | { |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2248 | bestChNum = pSpectInfoParams->pSpectCh[count].chNum; |
| 2249 | /* check if bestChNum is in preferred channel list */ |
| 2250 | bestChNum = sapSelectPreferredChannelFromChannelList( |
| 2251 | bestChNum, pSapCtx, pSpectInfoParams); |
| 2252 | if (bestChNum == SAP_CHANNEL_NOT_SELECTED) |
| 2253 | { |
| 2254 | /* not in preferred channel list, go to next best channel*/ |
| 2255 | continue; |
| 2256 | } |
| 2257 | |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2258 | if (pSpectInfoParams->pSpectCh[count].weight_copy > |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2259 | pSapCtx->acsBandSwitchThreshold) |
| 2260 | { |
| 2261 | /* the best channel exceeds the threshold |
| 2262 | check if need to scan next band */ |
| 2263 | if ((eCSR_BAND_ALL != pSapCtx->scanBandPreference) && |
| 2264 | !pSapCtx->allBandScanned) |
| 2265 | { |
| 2266 | /* store best channel for later comparison */ |
| 2267 | pSapCtx->acsBestChannelInfo.channelNum = bestChNum; |
| 2268 | pSapCtx->acsBestChannelInfo.weight = |
| 2269 | pSpectInfoParams->pSpectCh[count].weight; |
| 2270 | bestChNum = SAP_CHANNEL_NOT_SELECTED; |
| 2271 | break; |
| 2272 | } |
| 2273 | else |
| 2274 | { |
| 2275 | /* all bands are scanned, compare current best channel |
| 2276 | with channel scanned previously */ |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2277 | if ( pSpectInfoParams->pSpectCh[count].weight_copy > |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2278 | pSapCtx->acsBestChannelInfo.weight) |
| 2279 | { |
| 2280 | /* previous stored channel is better */ |
| 2281 | bestChNum = pSapCtx->acsBestChannelInfo.channelNum; |
| 2282 | } |
| 2283 | else |
| 2284 | { |
| 2285 | pSapCtx->acsBestChannelInfo.channelNum = bestChNum; |
| 2286 | pSapCtx->acsBestChannelInfo.weight = |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2287 | pSpectInfoParams->pSpectCh[count].weight_copy; |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | } |
Bansidhar Gopalachari | 1e56faa | 2013-07-25 19:30:20 +0530 | [diff] [blame] | 2291 | } |
| 2292 | else |
| 2293 | { |
| 2294 | if(operatingBand == RF_SUBBAND_2_4_GHZ) |
| 2295 | { |
| 2296 | /* Give preference to Non-overlap channels */ |
| 2297 | if(((pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_1) || |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2298 | (pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_6) || |
| 2299 | (pSpectInfoParams->pSpectCh[count].chNum == CHANNEL_11))&& |
Abhishek Singh | 906b91f | 2015-07-02 12:25:52 +0530 | [diff] [blame] | 2300 | (pSpectInfoParams->pSpectCh[count].weight_copy == |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2301 | pSapCtx->acsBestChannelInfo.weight)) |
| 2302 | { |
| 2303 | tmpChNum = pSpectInfoParams->pSpectCh[count].chNum; |
| 2304 | tmpChNum = |
| 2305 | sapSelectPreferredChannelFromChannelList(tmpChNum, |
| 2306 | pSapCtx, pSpectInfoParams); |
| 2307 | if ( tmpChNum != SAP_CHANNEL_NOT_SELECTED) |
| 2308 | { |
| 2309 | bestChNum = tmpChNum; |
| 2310 | break; |
| 2311 | } |
| 2312 | |
| 2313 | } |
Bansidhar Gopalachari | 1e56faa | 2013-07-25 19:30:20 +0530 | [diff] [blame] | 2314 | } |
| 2315 | } |
| 2316 | } |
| 2317 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2318 | #else |
Peng Xu | 117eab4 | 2014-09-25 13:33:27 +0530 | [diff] [blame] | 2319 | // Sort the channel list as per the computed weights, lesser weight first. |
| 2320 | sapSortChlWeightAll(pSapCtx, halHandle, pSpectInfoParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2321 | // Get the first channel in sorted array as best 20M Channel |
| 2322 | bestChNum = (v_U8_t)pSpectInfoParams->pSpectCh[0].chNum; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 2323 | //Select Best Channel from Channel List if Configured |
Peng Xu | afc34e3 | 2014-09-25 13:23:55 +0530 | [diff] [blame] | 2324 | bestChNum = sapSelectPreferredChannelFromChannelList(bestChNum, |
| 2325 | pSapCtx, pSpectInfoParams); |
| 2326 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2327 | |
| 2328 | // Free all the allocated memory |
| 2329 | sapChanSelExit(pSpectInfoParams); |
| 2330 | |
| 2331 | 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] | 2332 | __func__, bestChNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2333 | if (bestChNum > 0 && bestChNum <= 252) |
| 2334 | return bestChNum; |
| 2335 | else |
| 2336 | return SAP_CHANNEL_NOT_SELECTED; |
| 2337 | } |
Venkata Prathyusha Kuntupalli | 5c9e4e8 | 2013-04-15 13:10:09 -0700 | [diff] [blame] | 2338 | |