Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 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 | |
| 28 | /*=========================================================================== |
| 29 | |
| 30 | s a p F s m . C |
| 31 | |
| 32 | OVERVIEW: |
| 33 | |
| 34 | This software unit holds the implementation of the WLAN SAP Finite |
| 35 | State Machine modules |
| 36 | |
| 37 | DEPENDENCIES: |
| 38 | |
| 39 | Are listed for each API below. |
| 40 | ===========================================================================*/ |
| 41 | |
| 42 | /*---------------------------------------------------------------------------- |
| 43 | * Include Files |
| 44 | * -------------------------------------------------------------------------*/ |
| 45 | #include "sap_internal.h" |
| 46 | /* Pick up the SME API definitions */ |
| 47 | #include "sme_api.h" |
| 48 | /* Pick up the PMC API definitions */ |
| 49 | #include "cds_utils.h" |
| 50 | #include "cds_ieee80211_common_i.h" |
| 51 | #include "cds_reg_service.h" |
| 52 | #include "cdf_util.h" |
| 53 | #include "cds_concurrency.h" |
| 54 | |
| 55 | /*---------------------------------------------------------------------------- |
| 56 | * Preprocessor Definitions and Constants |
| 57 | * -------------------------------------------------------------------------*/ |
| 58 | |
| 59 | /*---------------------------------------------------------------------------- |
| 60 | * Type Declarations |
| 61 | * -------------------------------------------------------------------------*/ |
| 62 | |
| 63 | /*---------------------------------------------------------------------------- |
| 64 | * Global Data Definitions |
| 65 | * -------------------------------------------------------------------------*/ |
| 66 | |
| 67 | /*---------------------------------------------------------------------------- |
| 68 | * External declarations for global context |
| 69 | * -------------------------------------------------------------------------*/ |
| 70 | #ifdef FEATURE_WLAN_CH_AVOID |
| 71 | extern sapSafeChannelType safe_channels[]; |
| 72 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 73 | |
| 74 | /*---------------------------------------------------------------------------- |
| 75 | * Static Variable Definitions |
| 76 | * -------------------------------------------------------------------------*/ |
| 77 | |
| 78 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 79 | /* |
| 80 | * TODO: At present SAP Channel leakage matrix for ch 144 |
| 81 | * is not available from system's team. So to play it safe |
| 82 | * and avoid crash if channel 144 is request, in following |
| 83 | * matix channel 144 is added such that it will cause code |
| 84 | * to avoid selecting channel 144. |
| 85 | * |
| 86 | * THESE ENTRIES SHOULD BE REPLACED WITH CORRECT VALUES AS |
| 87 | * PROVIDED BY SYSTEM'S TEAM. |
| 88 | */ |
| 89 | |
| 90 | /* channel tx leakage table - ht80 */ |
| 91 | tSapChanMatrixInfo ht80_chan[] = { |
| 92 | {52, |
| 93 | {{36, 148}, {40, 199}, |
| 94 | {44, 193}, {48, 197}, |
| 95 | {52, SAP_TX_LEAKAGE_MIN}, {56, 153}, |
| 96 | {60, 137}, {64, 134}, |
| 97 | {100, 358}, {104, 350}, |
| 98 | {108, 404}, {112, 344}, |
| 99 | {116, 424}, {120, 429}, |
| 100 | {124, 437}, {128, 435}, |
| 101 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 102 | {140, SAP_TX_LEAKAGE_MAX}, |
| 103 | {144, SAP_TX_LEAKAGE_MIN} |
| 104 | } }, |
| 105 | |
| 106 | |
| 107 | {56, |
| 108 | {{36, 171}, {40, 178}, |
| 109 | {44, 171}, {48, 178}, |
| 110 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 111 | {60, SAP_TX_LEAKAGE_MIN}, {64, 280}, |
| 112 | {100, 351}, {104, 376}, |
| 113 | {108, 362}, {112, 362}, |
| 114 | {116, 403}, {120, 397}, |
| 115 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 116 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 117 | {140, SAP_TX_LEAKAGE_MAX}, |
| 118 | {144, SAP_TX_LEAKAGE_MIN} |
| 119 | } }, |
| 120 | |
| 121 | {60, |
| 122 | {{36, 156}, {40, 146}, |
| 123 | {44, SAP_TX_LEAKAGE_MIN}, {48, SAP_TX_LEAKAGE_MIN}, |
| 124 | {52, 180}, {56, SAP_TX_LEAKAGE_MIN}, |
| 125 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 126 | {100, 376}, {104, 360}, |
| 127 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 128 | {116, 395}, {120, 399}, |
| 129 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 130 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 131 | {140, SAP_TX_LEAKAGE_MAX}, |
| 132 | {144, SAP_TX_LEAKAGE_MIN} |
| 133 | } }, |
| 134 | |
| 135 | {64, |
| 136 | {{36, 217}, {40, 221}, |
| 137 | {44, SAP_TX_LEAKAGE_MIN}, {48, SAP_TX_LEAKAGE_MIN}, |
| 138 | {52, 176}, {56, 176}, |
| 139 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 140 | {100, 384}, {104, 390}, |
| 141 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 142 | {116, 375}, {120, 374}, |
| 143 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 144 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 145 | {140, SAP_TX_LEAKAGE_MAX}, |
| 146 | {144, SAP_TX_LEAKAGE_MIN} |
| 147 | } }, |
| 148 | |
| 149 | {100, |
| 150 | {{36, 357}, {40, 326}, |
| 151 | {44, 321}, {48, 326}, |
| 152 | {52, 378}, {56, 396}, |
| 153 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 154 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 155 | {108, 196}, {112, 116}, |
| 156 | {116, 166}, {120, SAP_TX_LEAKAGE_MIN}, |
| 157 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 158 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 159 | {140, SAP_TX_LEAKAGE_MIN}, |
| 160 | {144, SAP_TX_LEAKAGE_MIN} |
| 161 | } }, |
| 162 | |
| 163 | {104, |
| 164 | {{36, 325}, {40, 325}, |
| 165 | {44, 305}, {48, 352}, |
| 166 | {52, 411}, {56, 411}, |
| 167 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 168 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 169 | {108, SAP_TX_LEAKAGE_MIN}, {112, 460}, |
| 170 | {116, 198}, {120, SAP_TX_LEAKAGE_MIN}, |
| 171 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 172 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 173 | {140, SAP_TX_LEAKAGE_MIN}, |
| 174 | {144, SAP_TX_LEAKAGE_MIN} |
| 175 | } }, |
| 176 | |
| 177 | {108, |
| 178 | {{36, 304}, {40, 332}, |
| 179 | {44, 310}, {48, 335}, |
| 180 | {52, 431}, {56, 391}, |
| 181 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 182 | {100, 280}, {104, SAP_TX_LEAKAGE_MIN}, |
| 183 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 184 | {116, 185}, {120, SAP_TX_LEAKAGE_MIN}, |
| 185 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 186 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 187 | {140, SAP_TX_LEAKAGE_MIN}, |
| 188 | {144, SAP_TX_LEAKAGE_MIN} |
| 189 | } }, |
| 190 | |
| 191 | {112, |
| 192 | {{36, 327}, {40, 335}, |
| 193 | {44, 331}, {48, 345}, |
| 194 | {52, 367}, {56, 401}, |
| 195 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 196 | {100, 131}, {104, 132}, |
| 197 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 198 | {116, 189}, {120, SAP_TX_LEAKAGE_MIN}, |
| 199 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 200 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 201 | {140, SAP_TX_LEAKAGE_MIN}, |
| 202 | {144, SAP_TX_LEAKAGE_MIN} |
| 203 | } }, |
| 204 | |
| 205 | {116, |
| 206 | {{36, 384}, {40, 372}, |
| 207 | {44, 389}, {48, 396}, |
| 208 | {52, 348}, {56, 336}, |
| 209 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 210 | {100, 172}, {104, 169}, |
| 211 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 212 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 213 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 214 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 215 | {140, SAP_TX_LEAKAGE_MIN}, |
| 216 | {144, SAP_TX_LEAKAGE_MIN} |
| 217 | } }, |
| 218 | |
| 219 | {120, |
| 220 | {{36, 395}, {40, 419}, |
| 221 | {44, 439}, {48, 407}, |
| 222 | {52, 321}, {56, 334}, |
| 223 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 224 | {100, 134}, {104, 186}, |
| 225 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 226 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 227 | {124, SAP_TX_LEAKAGE_MIN}, {128, 159}, |
| 228 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 229 | {140, SAP_TX_LEAKAGE_MIN}, |
| 230 | {144, SAP_TX_LEAKAGE_MIN} |
| 231 | } }, |
| 232 | |
| 233 | {124, |
| 234 | {{36, 469}, {40, 433}, |
| 235 | {44, 434}, {48, 435}, |
| 236 | {52, 332}, {56, 345}, |
| 237 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 238 | {100, 146}, {104, 177}, |
| 239 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 240 | {116, 350}, {120, SAP_TX_LEAKAGE_MIN}, |
| 241 | {124, SAP_TX_LEAKAGE_MIN}, {128, 138}, |
| 242 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 243 | {140, SAP_TX_LEAKAGE_MIN}, |
| 244 | {144, SAP_TX_LEAKAGE_MIN} |
| 245 | } }, |
| 246 | |
| 247 | {128, |
| 248 | {{36, 408}, {40, 434}, |
| 249 | {44, 449}, {48, 444}, |
| 250 | {52, 341}, {56, 374}, |
| 251 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 252 | {100, 205}, {104, 208}, |
| 253 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 254 | {116, 142}, {120, SAP_TX_LEAKAGE_MIN}, |
| 255 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 256 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 257 | {140, SAP_TX_LEAKAGE_MIN}, |
| 258 | {144, SAP_TX_LEAKAGE_MIN} |
| 259 | } }, |
| 260 | |
| 261 | {132, |
| 262 | {{36, SAP_TX_LEAKAGE_MAX}, {40, SAP_TX_LEAKAGE_MAX}, |
| 263 | {44, SAP_TX_LEAKAGE_MAX}, {48, SAP_TX_LEAKAGE_MAX}, |
| 264 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 265 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 266 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 267 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 268 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 269 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 270 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 271 | {140, SAP_TX_LEAKAGE_MIN}, |
| 272 | {144, SAP_TX_LEAKAGE_MIN} |
| 273 | } }, |
| 274 | |
| 275 | {136, |
| 276 | {{36, SAP_TX_LEAKAGE_MAX}, {40, SAP_TX_LEAKAGE_MAX}, |
| 277 | {44, SAP_TX_LEAKAGE_MAX}, {48, SAP_TX_LEAKAGE_MAX}, |
| 278 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 279 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 280 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 281 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 282 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 283 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 284 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 285 | {140, SAP_TX_LEAKAGE_MIN}, |
| 286 | {144, SAP_TX_LEAKAGE_MIN} |
| 287 | } }, |
| 288 | |
| 289 | {140, |
| 290 | {{36, SAP_TX_LEAKAGE_MAX}, {40, SAP_TX_LEAKAGE_MAX}, |
| 291 | {44, SAP_TX_LEAKAGE_MAX}, {48, SAP_TX_LEAKAGE_MAX}, |
| 292 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 293 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 294 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 295 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 296 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 297 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 298 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 299 | {144, SAP_TX_LEAKAGE_MIN} |
| 300 | } }, |
| 301 | }; |
| 302 | |
| 303 | /* channel tx leakage table - ht40 */ |
| 304 | tSapChanMatrixInfo ht40_chan[] = { |
| 305 | {52, |
| 306 | {{36, SAP_TX_LEAKAGE_AUTO_MIN}, {40, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 307 | {44, 230}, {48, 230}, |
| 308 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 309 | {60, SAP_TX_LEAKAGE_AUTO_MIN}, {64, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 310 | {100, 625}, {104, 323}, |
| 311 | {108, 646}, {112, 646}, |
| 312 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 313 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 314 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 315 | {140, SAP_TX_LEAKAGE_MAX}, |
| 316 | {144, SAP_TX_LEAKAGE_MIN} |
| 317 | } }, |
| 318 | |
| 319 | {56, |
| 320 | {{36, SAP_TX_LEAKAGE_AUTO_MIN}, {40, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 321 | {44, SAP_TX_LEAKAGE_AUTO_MIN}, {48, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 322 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 323 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 324 | {100, 611}, {104, 611}, |
| 325 | {108, 617}, {112, 617}, |
| 326 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 327 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 328 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 329 | {140, SAP_TX_LEAKAGE_MAX}, |
| 330 | {144, SAP_TX_LEAKAGE_MIN} |
| 331 | } }, |
| 332 | |
| 333 | {60, |
| 334 | {{36, SAP_TX_LEAKAGE_AUTO_MIN}, {40, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 335 | {44, SAP_TX_LEAKAGE_AUTO_MIN}, {48, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 336 | {52, 190}, {56, 190}, |
| 337 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 338 | {100, 608}, {104, 608}, |
| 339 | {108, 623}, {112, 623}, |
| 340 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 341 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 342 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 343 | {140, SAP_TX_LEAKAGE_MAX}, |
| 344 | {144, SAP_TX_LEAKAGE_MIN} |
| 345 | } }, |
| 346 | |
| 347 | {64, |
| 348 | {{36, SAP_TX_LEAKAGE_AUTO_MIN}, {40, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 349 | {44, SAP_TX_LEAKAGE_AUTO_MIN}, {48, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 350 | {52, 295}, {56, 295}, |
| 351 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 352 | {100, 594}, {104, 594}, |
| 353 | {108, 625}, {112, 625}, |
| 354 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 355 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 356 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 357 | {140, SAP_TX_LEAKAGE_MAX}, |
| 358 | {144, SAP_TX_LEAKAGE_MIN} |
| 359 | } }, |
| 360 | |
| 361 | {100, |
| 362 | {{36, 618}, {40, 618}, |
| 363 | {44, 604}, {48, 604}, |
| 364 | {52, 596}, {56, 596}, |
| 365 | {60, 584}, {64, 584}, |
| 366 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 367 | {108, 299}, {112, 299}, |
| 368 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 369 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 370 | {132, 538}, {136, 538}, |
| 371 | {140, 598}, |
| 372 | {144, SAP_TX_LEAKAGE_MIN} |
| 373 | } }, |
| 374 | |
| 375 | {104, |
| 376 | {{36, 636}, {40, 636}, |
| 377 | {44, 601}, {48, 601}, |
| 378 | {52, 616}, {56, 616}, |
| 379 | {60, 584}, {64, 584}, |
| 380 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 381 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 382 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 383 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 384 | {132, 553}, {136, 553}, |
| 385 | {140, 568}, |
| 386 | {144, SAP_TX_LEAKAGE_MIN} |
| 387 | } }, |
| 388 | |
| 389 | {108, |
| 390 | {{36, 600}, {40, 600}, |
| 391 | {44, 627}, {48, 627}, |
| 392 | {52, 611}, {56, 611}, |
| 393 | {60, 611}, {64, 611}, |
| 394 | {100, 214}, {104, 214}, |
| 395 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 396 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 397 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 398 | {132, SAP_TX_LEAKAGE_AUTO_MIN}, {136, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 399 | {140, 534}, |
| 400 | {144, SAP_TX_LEAKAGE_MIN} |
| 401 | } }, |
| 402 | |
| 403 | {112, |
| 404 | {{36, 645}, {40, 645}, |
| 405 | {44, 641}, {48, 641}, |
| 406 | {52, 618}, {56, 618}, |
| 407 | {60, 612}, {64, 612}, |
| 408 | {100, 293}, {104, 293}, |
| 409 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 410 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 411 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 412 | {132, SAP_TX_LEAKAGE_AUTO_MIN}, {136, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 413 | {140, 521}, |
| 414 | {144, SAP_TX_LEAKAGE_MIN} |
| 415 | } }, |
| 416 | |
| 417 | {116, |
| 418 | {{36, 661}, {40, 661}, |
| 419 | {44, 624}, {48, 624}, |
| 420 | {52, 634}, {56, 634}, |
| 421 | {60, 611}, {64, 611}, |
| 422 | {100, SAP_TX_LEAKAGE_AUTO_MIN}, {104, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 423 | {108, 217}, {112, 217}, |
| 424 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 425 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 426 | {132, SAP_TX_LEAKAGE_AUTO_MIN}, {136, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 427 | {140, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 428 | {144, SAP_TX_LEAKAGE_MIN} |
| 429 | } }, |
| 430 | |
| 431 | {120, |
| 432 | {{36, 667}, {40, 667}, |
| 433 | {44, 645}, {48, 645}, |
| 434 | {52, 633}, {56, 633}, |
| 435 | {60, 619}, {64, 619}, |
| 436 | {100, SAP_TX_LEAKAGE_AUTO_MIN}, {104, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 437 | {108, 291}, {112, 291}, |
| 438 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 439 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 440 | {132, SAP_TX_LEAKAGE_AUTO_MIN}, {136, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 441 | {140, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 442 | {144, SAP_TX_LEAKAGE_MIN} |
| 443 | } }, |
| 444 | |
| 445 | {124, |
| 446 | {{36, 676}, {40, 676}, |
| 447 | {44, 668}, {48, 668}, |
| 448 | {52, 595}, {56, 595}, |
| 449 | {60, 622}, {64, 622}, |
| 450 | {100, SAP_TX_LEAKAGE_AUTO_MIN}, {104, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 451 | {108, SAP_TX_LEAKAGE_AUTO_MIN}, {112, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 452 | {116, 225}, {120, 225}, |
| 453 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 454 | {132, SAP_TX_LEAKAGE_AUTO_MIN}, {136, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 455 | {140, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 456 | {144, SAP_TX_LEAKAGE_MIN} |
| 457 | } }, |
| 458 | |
| 459 | {128, |
| 460 | {{36, 678}, {40, 678}, |
| 461 | {44, 664}, {48, 664}, |
| 462 | {52, 651}, {56, 651}, |
| 463 | {60, 643}, {64, 643}, |
| 464 | {100, SAP_TX_LEAKAGE_AUTO_MIN}, {104, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 465 | {108, SAP_TX_LEAKAGE_AUTO_MIN}, {112, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 466 | {116, 293}, {120, 293}, |
| 467 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 468 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 469 | {140, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 470 | {144, SAP_TX_LEAKAGE_MIN} |
| 471 | } }, |
| 472 | |
| 473 | {132, |
| 474 | {{36, 689}, {40, 689}, |
| 475 | {44, 669}, {48, 669}, |
| 476 | {52, 662}, {56, 662}, |
| 477 | {60, 609}, {64, 609}, |
| 478 | {100, 538}, {104, 538}, |
| 479 | {108, SAP_TX_LEAKAGE_AUTO_MIN}, {112, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 480 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 481 | {124, 247}, {128, 247}, |
| 482 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 483 | {140, SAP_TX_LEAKAGE_MIN}, |
| 484 | {144, SAP_TX_LEAKAGE_MIN} |
| 485 | } }, |
| 486 | |
| 487 | {136, |
| 488 | {{36, 703}, {40, 703}, |
| 489 | {44, 688}, {48, SAP_TX_LEAKAGE_MIN}, |
| 490 | {52, 671}, {56, 671}, |
| 491 | {60, 658}, {64, 658}, |
| 492 | {100, 504}, {104, 504}, |
| 493 | {108, SAP_TX_LEAKAGE_AUTO_MIN}, {112, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 494 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 495 | {124, 289}, {128, 289}, |
| 496 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 497 | {140, SAP_TX_LEAKAGE_MIN}, |
| 498 | {144, SAP_TX_LEAKAGE_MIN} |
| 499 | } }, |
| 500 | |
| 501 | {140, |
| 502 | {{36, 695}, {40, 695}, |
| 503 | {44, 684}, {48, 684}, |
| 504 | {52, 664}, {56, 664}, |
| 505 | {60, 658}, {64, 658}, |
| 506 | {100, 601}, {104, 601}, |
| 507 | {108, 545}, {112, 545}, |
| 508 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 509 | {124, SAP_TX_LEAKAGE_AUTO_MIN}, {128, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 510 | {132, 262}, {136, 262}, |
| 511 | {140, SAP_TX_LEAKAGE_MIN}, |
| 512 | {144, SAP_TX_LEAKAGE_MIN} |
| 513 | } }, |
| 514 | |
| 515 | }; |
| 516 | |
| 517 | /* channel tx leakage table - ht20 */ |
| 518 | tSapChanMatrixInfo ht20_chan[] = { |
| 519 | {52, |
| 520 | {{36, SAP_TX_LEAKAGE_AUTO_MIN}, {40, 286}, |
| 521 | {44, 225}, {48, 121}, |
| 522 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 523 | {60, 300}, {64, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 524 | {100, 637}, {104, SAP_TX_LEAKAGE_MAX}, |
| 525 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 526 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 527 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 528 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 529 | {140, SAP_TX_LEAKAGE_MAX}, |
| 530 | {144, SAP_TX_LEAKAGE_MIN} |
| 531 | } }, |
| 532 | |
| 533 | {56, |
| 534 | {{36, 468}, {40, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 535 | {44, SAP_TX_LEAKAGE_AUTO_MIN}, {48, 206}, |
| 536 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 537 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 538 | {100, SAP_TX_LEAKAGE_MAX}, {104, SAP_TX_LEAKAGE_MAX}, |
| 539 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 540 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 541 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 542 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 543 | {140, SAP_TX_LEAKAGE_MAX}, |
| 544 | {144, SAP_TX_LEAKAGE_MIN} |
| 545 | } }, |
| 546 | |
| 547 | {60, |
| 548 | {{36, 507}, {40, 440}, |
| 549 | {44, SAP_TX_LEAKAGE_AUTO_MIN}, {48, 313}, |
| 550 | {52, SAP_TX_LEAKAGE_MIN}, {56, SAP_TX_LEAKAGE_MIN}, |
| 551 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 552 | {100, SAP_TX_LEAKAGE_MAX}, {104, SAP_TX_LEAKAGE_MAX}, |
| 553 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 554 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 555 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 556 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 557 | {140, SAP_TX_LEAKAGE_MAX}, |
| 558 | {144, SAP_TX_LEAKAGE_MIN} |
| 559 | } }, |
| 560 | |
| 561 | {64, |
| 562 | {{36, 516}, {40, 520}, |
| 563 | {44, 506}, {48, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 564 | {52, 301}, {56, 258}, |
| 565 | {60, SAP_TX_LEAKAGE_MIN}, {64, SAP_TX_LEAKAGE_MIN}, |
| 566 | {100, 620}, {104, 617}, |
| 567 | {108, SAP_TX_LEAKAGE_MAX}, {112, SAP_TX_LEAKAGE_MAX}, |
| 568 | {116, SAP_TX_LEAKAGE_MAX}, {120, SAP_TX_LEAKAGE_MAX}, |
| 569 | {124, SAP_TX_LEAKAGE_MAX}, {128, SAP_TX_LEAKAGE_MAX}, |
| 570 | {132, SAP_TX_LEAKAGE_MAX}, {136, SAP_TX_LEAKAGE_MAX}, |
| 571 | {140, SAP_TX_LEAKAGE_MAX}, |
| 572 | {144, SAP_TX_LEAKAGE_MIN} |
| 573 | } }, |
| 574 | |
| 575 | {100, |
| 576 | {{36, 616}, {40, 601}, |
| 577 | {44, 604}, {48, 589}, |
| 578 | {52, 612}, {56, 592}, |
| 579 | {60, 590}, {64, 582}, |
| 580 | {100, SAP_TX_LEAKAGE_MIN}, {104, 131}, |
| 581 | {108, SAP_TX_LEAKAGE_AUTO_MIN}, {112, SAP_TX_LEAKAGE_AUTO_MIN}, |
| 582 | {116, SAP_TX_LEAKAGE_AUTO_MIN}, {120, 522}, |
| 583 | {124, 571}, {128, 589}, |
| 584 | {132, 593}, {136, 598}, |
| 585 | {140, 594}, |
| 586 | {144, SAP_TX_LEAKAGE_MIN}, |
| 587 | } }, |
| 588 | |
| 589 | {104, |
| 590 | {{36, 622}, {40, 624}, |
| 591 | {44, 618}, {48, 610}, |
| 592 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 593 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 594 | {100, SAP_TX_LEAKAGE_MIN}, {104, SAP_TX_LEAKAGE_MIN}, |
| 595 | {108, SAP_TX_LEAKAGE_MIN}, {112, 463}, |
| 596 | {116, 483}, {120, 503}, |
| 597 | {124, 523}, {128, 565}, |
| 598 | {132, 570}, {136, 588}, |
| 599 | {140, 585}, |
| 600 | {144, SAP_TX_LEAKAGE_MIN}, |
| 601 | } }, |
| 602 | |
| 603 | {108, |
| 604 | {{36, 620}, {40, 638}, |
| 605 | {44, 611}, {48, 614}, |
| 606 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 607 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 608 | {100, 477}, {104, SAP_TX_LEAKAGE_MIN}, |
| 609 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 610 | {116, 477}, {120, 497}, |
| 611 | {124, 517}, {128, 537}, |
| 612 | {132, 557}, {136, 577}, |
| 613 | {140, 603}, |
| 614 | {144, SAP_TX_LEAKAGE_MIN}, |
| 615 | } }, |
| 616 | |
| 617 | {112, |
| 618 | {{36, 636}, {40, 623}, |
| 619 | {44, 638}, {48, 628}, |
| 620 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 621 | {60, SAP_TX_LEAKAGE_MAX}, {64, 606}, |
| 622 | {100, 501}, {104, 481}, |
| 623 | {108, SAP_TX_LEAKAGE_MIN}, {112, SAP_TX_LEAKAGE_MIN}, |
| 624 | {116, SAP_TX_LEAKAGE_MIN}, {120, 481}, |
| 625 | {124, 501}, {128, 421}, |
| 626 | {132, 541}, {136, 561}, |
| 627 | {140, 583}, |
| 628 | {144, SAP_TX_LEAKAGE_MIN}, |
| 629 | } }, |
| 630 | |
| 631 | {116, |
| 632 | {{36, 646}, {40, 648}, |
| 633 | {44, 633}, {48, 634}, |
| 634 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 635 | {60, 615}, {64, 594}, |
| 636 | {100, 575}, {104, 554}, |
| 637 | {108, 534}, {112, SAP_TX_LEAKAGE_MIN}, |
| 638 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 639 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 640 | {132, 534}, {136, 554}, |
| 641 | {140, 574}, |
| 642 | {144, SAP_TX_LEAKAGE_MIN}, |
| 643 | } }, |
| 644 | |
| 645 | {120, |
| 646 | {{36, 643}, {40, 649}, |
| 647 | {44, 654}, {48, 629}, |
| 648 | {52, SAP_TX_LEAKAGE_MAX}, {56, 621}, |
| 649 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 650 | {100, 565}, {104, 545}, |
| 651 | {108, 525}, {112, 505}, |
| 652 | {116, SAP_TX_LEAKAGE_MIN}, {120, SAP_TX_LEAKAGE_MIN}, |
| 653 | {124, SAP_TX_LEAKAGE_MIN}, {128, 505}, |
| 654 | {132, 525}, {136, 545}, |
| 655 | {140, 565}, |
| 656 | {144, SAP_TX_LEAKAGE_MIN}, |
| 657 | } }, |
| 658 | |
| 659 | {124, |
| 660 | {{36, 638}, {40, 657}, |
| 661 | {44, 663}, {48, 649}, |
| 662 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 663 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 664 | {100, 581}, {104, 561}, |
| 665 | {108, 541}, {112, 521}, |
| 666 | {116, 499}, {120, SAP_TX_LEAKAGE_MIN}, |
| 667 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 668 | {132, 499}, {136, 519}, |
| 669 | {140, 539}, |
| 670 | {144, SAP_TX_LEAKAGE_MIN} |
| 671 | } }, |
| 672 | |
| 673 | {128, |
| 674 | {{36, 651}, {40, 651}, |
| 675 | {44, 674}, {48, 640}, |
| 676 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 677 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 678 | {100, 603}, {104, 560}, |
| 679 | {108, 540}, {112, 520}, |
| 680 | {116, 499}, {120, 479}, |
| 681 | {124, SAP_TX_LEAKAGE_MIN}, {128, SAP_TX_LEAKAGE_MIN}, |
| 682 | {132, SAP_TX_LEAKAGE_MIN}, {136, 479}, |
| 683 | {140, 499}, |
| 684 | {144, SAP_TX_LEAKAGE_MIN} |
| 685 | } }, |
| 686 | |
| 687 | {132, |
| 688 | {{36, 643}, {40, 668}, |
| 689 | {44, 651}, {48, 657}, |
| 690 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 691 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 692 | {100, SAP_TX_LEAKAGE_MAX}, {104, 602}, |
| 693 | {108, 578}, {112, 570}, |
| 694 | {116, 550}, {120, 530}, |
| 695 | {124, 510}, {128, SAP_TX_LEAKAGE_MIN}, |
| 696 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 697 | {140, 490}, |
| 698 | {144, SAP_TX_LEAKAGE_MIN} |
| 699 | } }, |
| 700 | |
| 701 | {136, |
| 702 | {{36, 654}, {40, 667}, |
| 703 | {44, 666}, {48, 642}, |
| 704 | {52, SAP_TX_LEAKAGE_MAX}, {56, SAP_TX_LEAKAGE_MAX}, |
| 705 | {60, SAP_TX_LEAKAGE_MAX}, {64, SAP_TX_LEAKAGE_MAX}, |
| 706 | {100, SAP_TX_LEAKAGE_MAX}, {104, SAP_TX_LEAKAGE_MAX}, |
| 707 | {108, SAP_TX_LEAKAGE_MAX}, {112, 596}, |
| 708 | {116, 555}, {120, 535}, |
| 709 | {124, 515}, {128, 495}, |
| 710 | {132, SAP_TX_LEAKAGE_MIN}, {136, SAP_TX_LEAKAGE_MIN}, |
| 711 | {140, SAP_TX_LEAKAGE_MIN}, |
| 712 | {144, SAP_TX_LEAKAGE_MIN} |
| 713 | } }, |
| 714 | |
| 715 | {140, |
| 716 | {{36, 679}, {40, 673}, |
| 717 | {44, 667}, {48, 656}, |
| 718 | {52, 634}, {56, 663}, |
| 719 | {60, 662}, {64, 660}, |
| 720 | {100, SAP_TX_LEAKAGE_MAX}, {104, SAP_TX_LEAKAGE_MAX}, |
| 721 | {108, SAP_TX_LEAKAGE_MAX}, {112, 590}, |
| 722 | {116, 573}, {120, 553}, |
| 723 | {124, 533}, {128, 513}, |
| 724 | {132, 490}, {136, SAP_TX_LEAKAGE_MIN}, |
| 725 | {140, SAP_TX_LEAKAGE_MIN}, |
| 726 | {144, SAP_TX_LEAKAGE_MIN} |
| 727 | } }, |
| 728 | }; |
| 729 | #endif /* WLAN_ENABLE_CHNL_MATRIX_RESTRICTION */ |
| 730 | |
| 731 | /*---------------------------------------------------------------------------- |
| 732 | * Static Function Declarations and Definitions |
| 733 | * -------------------------------------------------------------------------*/ |
| 734 | #ifdef SOFTAP_CHANNEL_RANGE |
| 735 | static CDF_STATUS sap_get_channel_list(ptSapContext sapContext, |
| 736 | uint8_t **channelList, |
| 737 | uint8_t *numberOfChannels); |
| 738 | #endif |
| 739 | |
| 740 | /*========================================================================== |
| 741 | FUNCTION sapGet5GHzChannelList |
| 742 | |
| 743 | DESCRIPTION |
| 744 | Function for initializing list of 2.4/5 Ghz [NON-DFS/DFS] available |
| 745 | channels in the current regulatory domain. |
| 746 | |
| 747 | DEPENDENCIES |
| 748 | NA. |
| 749 | |
| 750 | PARAMETERS |
| 751 | |
| 752 | IN |
| 753 | sapContext: SAP Context |
| 754 | |
| 755 | RETURN VALUE |
| 756 | NA |
| 757 | |
| 758 | SIDE EFFECTS |
| 759 | ============================================================================*/ |
| 760 | static CDF_STATUS sap_get5_g_hz_channel_list(ptSapContext sapContext); |
| 761 | |
| 762 | /*========================================================================== |
| 763 | FUNCTION sapStopDfsCacTimer |
| 764 | |
| 765 | DESCRIPTION |
| 766 | Function to sttop the DFS CAC timer when SAP is stopped |
| 767 | DEPENDENCIES |
| 768 | NA. |
| 769 | |
| 770 | PARAMETERS |
| 771 | |
| 772 | IN |
| 773 | sapContext: SAP Context |
| 774 | RETURN VALUE |
| 775 | DFS Timer start status |
| 776 | SIDE EFFECTS |
| 777 | ============================================================================*/ |
| 778 | |
| 779 | static int sap_stop_dfs_cac_timer(ptSapContext sapContext); |
| 780 | |
| 781 | /*========================================================================== |
| 782 | FUNCTION sapStartDfsCacTimer |
| 783 | |
| 784 | DESCRIPTION |
| 785 | Function to start the DFS CAC timer when SAP is started on DFS Channel |
| 786 | DEPENDENCIES |
| 787 | NA. |
| 788 | |
| 789 | PARAMETERS |
| 790 | |
| 791 | IN |
| 792 | sapContext: SAP Context |
| 793 | RETURN VALUE |
| 794 | DFS Timer start status |
| 795 | SIDE EFFECTS |
| 796 | ============================================================================*/ |
| 797 | |
| 798 | int sap_start_dfs_cac_timer(ptSapContext sapContext); |
| 799 | |
| 800 | /** sap_hdd_event_to_string() - convert hdd event to string |
| 801 | * @event: eSapHddEvent event type |
| 802 | * |
| 803 | * This function converts eSapHddEvent into string |
| 804 | * |
| 805 | * Return: string for the @event. |
| 806 | */ |
| 807 | static uint8_t *sap_hdd_event_to_string(eSapHddEvent event) |
| 808 | { |
| 809 | switch (event) { |
| 810 | CASE_RETURN_STRING(eSAP_START_BSS_EVENT); |
| 811 | CASE_RETURN_STRING(eSAP_STOP_BSS_EVENT); |
| 812 | CASE_RETURN_STRING(eSAP_STA_ASSOC_IND); |
| 813 | CASE_RETURN_STRING(eSAP_STA_ASSOC_EVENT); |
| 814 | CASE_RETURN_STRING(eSAP_STA_REASSOC_EVENT); |
| 815 | CASE_RETURN_STRING(eSAP_STA_DISASSOC_EVENT); |
| 816 | CASE_RETURN_STRING(eSAP_STA_SET_KEY_EVENT); |
| 817 | CASE_RETURN_STRING(eSAP_STA_MIC_FAILURE_EVENT); |
| 818 | CASE_RETURN_STRING(eSAP_ASSOC_STA_CALLBACK_EVENT); |
| 819 | CASE_RETURN_STRING(eSAP_GET_WPSPBC_SESSION_EVENT); |
| 820 | CASE_RETURN_STRING(eSAP_WPS_PBC_PROBE_REQ_EVENT); |
| 821 | CASE_RETURN_STRING(eSAP_INDICATE_MGMT_FRAME); |
| 822 | CASE_RETURN_STRING(eSAP_REMAIN_CHAN_READY); |
| 823 | CASE_RETURN_STRING(eSAP_SEND_ACTION_CNF); |
| 824 | CASE_RETURN_STRING(eSAP_DISCONNECT_ALL_P2P_CLIENT); |
| 825 | CASE_RETURN_STRING(eSAP_MAC_TRIG_STOP_BSS_EVENT); |
| 826 | CASE_RETURN_STRING(eSAP_UNKNOWN_STA_JOIN); |
| 827 | CASE_RETURN_STRING(eSAP_MAX_ASSOC_EXCEEDED); |
| 828 | CASE_RETURN_STRING(eSAP_CHANNEL_CHANGE_EVENT); |
| 829 | CASE_RETURN_STRING(eSAP_DFS_CAC_START); |
| 830 | CASE_RETURN_STRING(eSAP_DFS_CAC_END); |
| 831 | CASE_RETURN_STRING(eSAP_DFS_RADAR_DETECT); |
| 832 | CASE_RETURN_STRING(eSAP_DFS_NOL_GET); |
| 833 | CASE_RETURN_STRING(eSAP_DFS_NOL_SET); |
| 834 | CASE_RETURN_STRING(eSAP_DFS_NO_AVAILABLE_CHANNEL); |
| 835 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 836 | CASE_RETURN_STRING(eSAP_ACS_SCAN_SUCCESS_EVENT); |
| 837 | #endif |
| 838 | CASE_RETURN_STRING(eSAP_ACS_CHANNEL_SELECTED); |
| 839 | default: |
| 840 | return "eSAP_HDD_EVENT_UNKNOWN"; |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | /*---------------------------------------------------------------------------- |
| 845 | * Externalized Function Definitions |
| 846 | * -------------------------------------------------------------------------*/ |
| 847 | |
| 848 | /*---------------------------------------------------------------------------- |
| 849 | * Function Declarations and Documentation |
| 850 | * -------------------------------------------------------------------------*/ |
| 851 | |
| 852 | /*========================================================================== |
| 853 | FUNCTION sap_event_init |
| 854 | |
| 855 | DESCRIPTION |
| 856 | Function for initializing sWLAN_SAPEvent structure |
| 857 | |
| 858 | DEPENDENCIES |
| 859 | NA. |
| 860 | |
| 861 | PARAMETERS |
| 862 | |
| 863 | IN |
| 864 | sapEvent : State machine event |
| 865 | |
| 866 | RETURN VALUE |
| 867 | |
| 868 | None |
| 869 | |
| 870 | SIDE EFFECTS |
| 871 | ============================================================================*/ |
| 872 | static inline void sap_event_init(ptWLAN_SAPEvent sapEvent) |
| 873 | { |
| 874 | sapEvent->event = eSAP_MAC_SCAN_COMPLETE; |
| 875 | sapEvent->params = 0; |
| 876 | sapEvent->u1 = 0; |
| 877 | sapEvent->u2 = 0; |
| 878 | } |
| 879 | |
| 880 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 881 | /* |
| 882 | * This function gives the leakage matrix for given NOL channel and cbMode |
| 883 | * |
| 884 | * PARAMETERS |
| 885 | * IN |
| 886 | * sapContext : Pointer to vos global context structure |
| 887 | * cbMode : target channel bonding mode |
| 888 | * NOL_channel : the NOL channel whose leakage matrix is required |
| 889 | * pTarget_chnl_mtrx : pointer to target channel matrix returned. |
| 890 | * |
| 891 | * RETURN VALUE |
| 892 | * BOOLEAN |
| 893 | * TRUE: leakage matrix was found |
| 894 | * FALSE: leakage matrix was not found |
| 895 | */ |
| 896 | bool |
| 897 | sap_find_target_channel_in_channel_matrix(ptSapContext sapContext, |
| 898 | ePhyChanBondState cbMode, |
| 899 | uint8_t NOL_channel, |
| 900 | tSapTxLeakInfo **pTarget_chnl_mtrx) |
| 901 | { |
| 902 | tSapTxLeakInfo *target_chan_matrix = NULL; |
| 903 | tSapChanMatrixInfo *pchan_matrix = NULL; |
| 904 | uint32_t nchan_matrix; |
| 905 | int i = 0; |
| 906 | |
| 907 | switch (cbMode) { |
| 908 | case PHY_SINGLE_CHANNEL_CENTERED: |
| 909 | /* HT20 */ |
| 910 | pchan_matrix = ht20_chan; |
| 911 | nchan_matrix = CDF_ARRAY_SIZE(ht20_chan); |
| 912 | break; |
| 913 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: |
| 914 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: |
| 915 | /* HT40 */ |
| 916 | pchan_matrix = ht40_chan; |
| 917 | nchan_matrix = CDF_ARRAY_SIZE(ht40_chan); |
| 918 | break; |
| 919 | #ifdef WLAN_FEATURE_11AC |
| 920 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW: |
| 921 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW: |
| 922 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH: |
| 923 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH: |
| 924 | /* HT80 */ |
| 925 | pchan_matrix = ht80_chan; |
| 926 | nchan_matrix = CDF_ARRAY_SIZE(ht80_chan); |
| 927 | break; |
| 928 | #endif |
| 929 | default: |
| 930 | /* handle exception and fall back to HT20 table */ |
| 931 | pchan_matrix = ht20_chan; |
| 932 | nchan_matrix = CDF_ARRAY_SIZE(ht20_chan); |
| 933 | break; |
| 934 | } |
| 935 | |
| 936 | for (i = 0; i < nchan_matrix; i++) { |
| 937 | /* find the SAP channel to map the leakage matrix */ |
| 938 | if (NOL_channel == pchan_matrix[i].channel) { |
| 939 | target_chan_matrix = pchan_matrix[i].chan_matrix; |
| 940 | break; |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | if (NULL == target_chan_matrix) { |
| 945 | return false; |
| 946 | } else { |
| 947 | *pTarget_chnl_mtrx = target_chan_matrix; |
| 948 | return true; |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | /** |
| 953 | * sap_mark_channels_leaking_into_nol() - to mark channel leaking in to nol |
| 954 | * @sap_ctx: pointer to SAP context |
| 955 | * @cb_mode: channel bonding mode |
| 956 | * @nol: nol info |
| 957 | * @temp_ch_lst_sz: the target channel list |
| 958 | * @temp_ch_lst: the target channel list |
| 959 | * |
| 960 | * This function removes the channels from temp channel list that |
| 961 | * (if selected as target channel) will cause leakage in one of |
| 962 | * the NOL channels |
| 963 | * |
| 964 | * Return: CDF_STATUS |
| 965 | */ |
| 966 | |
| 967 | CDF_STATUS |
| 968 | sap_mark_channels_leaking_into_nol(ptSapContext sap_ctx, |
| 969 | ePhyChanBondState cb_mode, |
| 970 | tSapDfsNolInfo *nol, |
| 971 | uint8_t temp_ch_lst_sz, |
| 972 | uint8_t *temp_ch_lst) |
| 973 | { |
| 974 | tSapTxLeakInfo *target_chan_matrix = NULL; |
| 975 | uint32_t num_channel = (RF_CHAN_144 - RF_CHAN_36) + 1; |
| 976 | uint32_t i = 0; |
| 977 | uint32_t j = 0; |
| 978 | uint32_t k = 0; |
| 979 | uint8_t dfs_nol_channel; |
| 980 | |
| 981 | |
| 982 | /* traverse target_chan_matrix and */ |
| 983 | for (i = 0; i < NUM_5GHZ_CHANNELS ; i++) { |
| 984 | dfs_nol_channel = nol[i].dfs_channel_number; |
| 985 | if (nol[i].radar_status_flag == eSAP_DFS_CHANNEL_USABLE || |
| 986 | nol[i].radar_status_flag == eSAP_DFS_CHANNEL_AVAILABLE) { |
| 987 | /* not present in NOL */ |
| 988 | continue; |
| 989 | } |
| 990 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_DEBUG, |
| 991 | FL("sapdfs: processing NOL channel: %d"), |
| 992 | dfs_nol_channel); |
| 993 | if (false == sap_find_target_channel_in_channel_matrix( |
| 994 | sap_ctx, cb_mode, dfs_nol_channel, |
| 995 | &target_chan_matrix)) { |
| 996 | /* |
| 997 | * should never happen, we should always find a table |
| 998 | * here, if we don't, need a fix here! |
| 999 | */ |
| 1000 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1001 | FL("Couldn't find target channel matrix!")); |
| 1002 | CDF_ASSERT(0); |
| 1003 | return CDF_STATUS_E_FAILURE; |
| 1004 | } |
| 1005 | /* |
| 1006 | * following is based on assumption that both temp_ch_lst |
| 1007 | * and target channel matrix are in increasing order of |
| 1008 | * channelID |
| 1009 | */ |
| 1010 | for (j = 0, k = 0; j < temp_ch_lst_sz && k < num_channel;) { |
| 1011 | if (temp_ch_lst[j] == 0) { |
| 1012 | j++; |
| 1013 | continue; |
| 1014 | } |
| 1015 | if (target_chan_matrix[k].leak_chan != temp_ch_lst[j]) { |
| 1016 | k++; |
| 1017 | continue; |
| 1018 | } |
| 1019 | /* |
| 1020 | * check leakage from candidate channel |
| 1021 | * to NOL channel |
| 1022 | */ |
| 1023 | if (target_chan_matrix[k].leak_lvl <= |
| 1024 | SAP_TX_LEAKAGE_THRES) { |
| 1025 | /* |
| 1026 | * candidate channel will have |
| 1027 | * bad leakage in NOL channel, |
| 1028 | * remove from temp list |
| 1029 | */ |
| 1030 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1031 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1032 | FL("sapdfs: channel: %d will have bad leakage due to channel: %d\n"), |
| 1033 | dfs_nol_channel, temp_ch_lst[j]); |
| 1034 | temp_ch_lst[j] = 0; |
| 1035 | break; |
| 1036 | } |
| 1037 | j++; |
| 1038 | k++; |
| 1039 | } |
| 1040 | } /* end of loop that selects each NOL */ |
| 1041 | return CDF_STATUS_SUCCESS; |
| 1042 | } |
| 1043 | #endif /* end of WLAN_ENABLE_CHNL_MATRIX_RESTRICTION */ |
| 1044 | |
| 1045 | /* |
| 1046 | * This function adds availabe channel to bitmap |
| 1047 | * |
| 1048 | * PARAMETERS |
| 1049 | * IN |
| 1050 | * pBitmap: bitmap to populate |
| 1051 | * channel: channel to set in bitmap |
| 1052 | */ |
| 1053 | static void sap_set_bitmap(chan_bonding_bitmap *pBitmap, uint8_t channel) |
| 1054 | { |
| 1055 | int i = 0; |
| 1056 | int start_channel = 0; |
| 1057 | for (i = 0; i < MAX_80MHZ_BANDS; i++) { |
| 1058 | start_channel = pBitmap->chanBondingSet[i].startChannel; |
| 1059 | if (channel >= start_channel && channel <= start_channel + 12) { |
| 1060 | pBitmap->chanBondingSet[i].channelMap |= |
| 1061 | 1 << ((channel - start_channel) / 4); |
| 1062 | return; |
| 1063 | } |
| 1064 | } |
| 1065 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1066 | FL("Channel=%d is not in the bitmap"), channel); |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * sap_populate_available_channels - To populate available channel |
| 1071 | * @bitmap: bitmap to populate |
| 1072 | * @current_cbmode: cb mode to check for channel availability |
| 1073 | * @avail_chnl: available channel list to populate |
| 1074 | * |
| 1075 | * This function reads the bitmap and populates available channel |
| 1076 | * list according to channel bonding mode. This will be called for |
| 1077 | * 80 MHz and 40 Mhz only. For 20 MHz no need for bitmap hence list |
| 1078 | * is directly created while parsing the main list |
| 1079 | * |
| 1080 | * Return: number of channels found |
| 1081 | */ |
| 1082 | static uint8_t sap_populate_available_channels(chan_bonding_bitmap *bitmap, |
| 1083 | ePhyChanBondState current_cbmode, |
| 1084 | uint8_t *avail_chnl) |
| 1085 | { |
| 1086 | uint8_t i = 0; |
| 1087 | uint8_t chnl_count = 0; |
| 1088 | uint8_t start_channel = 0; |
| 1089 | |
| 1090 | switch (current_cbmode) { |
| 1091 | #ifdef WLAN_FEATURE_11AC |
| 1092 | /* HT80 */ |
| 1093 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW: |
| 1094 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW: |
| 1095 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH: |
| 1096 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH: |
| 1097 | for (i = 0; i < MAX_80MHZ_BANDS; i++) { |
| 1098 | start_channel = bitmap->chanBondingSet[i].startChannel; |
| 1099 | if (bitmap->chanBondingSet[i].channelMap == |
| 1100 | SAP_80MHZ_MASK) { |
| 1101 | avail_chnl[chnl_count++] = start_channel; |
| 1102 | avail_chnl[chnl_count++] = start_channel + 4; |
| 1103 | avail_chnl[chnl_count++] = start_channel + 8; |
| 1104 | avail_chnl[chnl_count++] = start_channel + 12; |
| 1105 | } |
| 1106 | } |
| 1107 | break; |
| 1108 | #endif |
| 1109 | /* HT40 */ |
| 1110 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: |
| 1111 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: |
| 1112 | for (i = 0; i < MAX_80MHZ_BANDS; i++) { |
| 1113 | start_channel = bitmap->chanBondingSet[i].startChannel; |
| 1114 | if ((bitmap->chanBondingSet[i].channelMap & |
| 1115 | SAP_40MHZ_MASK_L) == SAP_40MHZ_MASK_L) { |
| 1116 | avail_chnl[chnl_count++] = start_channel; |
| 1117 | avail_chnl[chnl_count++] = start_channel + 4; |
| 1118 | } else if ((bitmap->chanBondingSet[i].channelMap & |
| 1119 | SAP_40MHZ_MASK_H) == SAP_40MHZ_MASK_H) { |
| 1120 | avail_chnl[chnl_count++] = start_channel + 8; |
| 1121 | avail_chnl[chnl_count++] = start_channel + 12; |
| 1122 | } |
| 1123 | } |
| 1124 | break; |
| 1125 | default: |
| 1126 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1127 | FL("Invalid case.")); |
| 1128 | break; |
| 1129 | } |
| 1130 | |
| 1131 | return chnl_count; |
| 1132 | } |
| 1133 | |
| 1134 | /* |
| 1135 | * FUNCTION sap_dfs_is_w53_invalid |
| 1136 | * |
| 1137 | * DESCRIPTION Checks if the passed channel is W53 and returns if |
| 1138 | * SAP W53 opearation is allowed. |
| 1139 | * |
| 1140 | * DEPENDENCIES PARAMETERS |
| 1141 | * IN hHAL : HAL pointer |
| 1142 | * channelID: Channel Number to be verified |
| 1143 | * |
| 1144 | * RETURN VALUE : bool |
| 1145 | * true: If W53 operation is disabled |
| 1146 | * false: If W53 operation is enabled |
| 1147 | * |
| 1148 | * SIDE EFFECTS |
| 1149 | */ |
| 1150 | bool sap_dfs_is_w53_invalid(tHalHandle hHal, uint8_t channelID) |
| 1151 | { |
| 1152 | tpAniSirGlobal pMac; |
| 1153 | |
| 1154 | pMac = PMAC_STRUCT(hHal); |
| 1155 | if (NULL == pMac) { |
| 1156 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1157 | FL("invalid pMac")); |
| 1158 | return false; |
| 1159 | } |
| 1160 | |
| 1161 | /* |
| 1162 | * Check for JAPAN W53 Channel operation capability |
| 1163 | */ |
| 1164 | if (true == pMac->sap.SapDfsInfo.is_dfs_w53_disabled && |
| 1165 | true == IS_CHAN_JAPAN_W53(channelID)) { |
| 1166 | return true; |
| 1167 | } |
| 1168 | |
| 1169 | return false; |
| 1170 | } |
| 1171 | |
| 1172 | /* |
| 1173 | * FUNCTION sap_dfs_is_channel_in_preferred_location |
| 1174 | * |
| 1175 | * DESCRIPTION Checks if the passed channel is in accordance with preferred |
| 1176 | * Channel location settings. |
| 1177 | * |
| 1178 | * DEPENDENCIES PARAMETERS |
| 1179 | * IN hHAL : HAL pointer |
| 1180 | * channelID: Channel Number to be verified |
| 1181 | * |
| 1182 | * RETURN VALUE :bool |
| 1183 | * true:If Channel location is same as the preferred location |
| 1184 | * false:If Channel location is not same as the preferred location |
| 1185 | * |
| 1186 | * SIDE EFFECTS |
| 1187 | */ |
| 1188 | bool sap_dfs_is_channel_in_preferred_location(tHalHandle hHal, uint8_t channelID) |
| 1189 | { |
| 1190 | tpAniSirGlobal pMac; |
| 1191 | |
| 1192 | pMac = PMAC_STRUCT(hHal); |
| 1193 | if (NULL == pMac) { |
| 1194 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1195 | FL("invalid pMac")); |
| 1196 | return true; |
| 1197 | } |
| 1198 | if ((SAP_CHAN_PREFERRED_INDOOR == |
| 1199 | pMac->sap.SapDfsInfo.sap_operating_chan_preferred_location) && |
| 1200 | (true == IS_CHAN_JAPAN_OUTDOOR(channelID))) { |
| 1201 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1202 | FL |
| 1203 | ("CHAN=%d is Outdoor so invalid,preferred Indoor only"), |
| 1204 | channelID); |
| 1205 | return false; |
| 1206 | } else if ((SAP_CHAN_PREFERRED_OUTDOOR == |
| 1207 | pMac->sap.SapDfsInfo.sap_operating_chan_preferred_location) |
| 1208 | && (true == IS_CHAN_JAPAN_INDOOR(channelID))) { |
| 1209 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1210 | FL |
| 1211 | ("CHAN=%d is Indoor so invalid,preferred Outdoor only"), |
| 1212 | channelID); |
| 1213 | return false; |
| 1214 | } |
| 1215 | |
| 1216 | return true; |
| 1217 | } |
| 1218 | |
| 1219 | #ifdef FEATURE_AP_MCC_CH_AVOIDANCE |
| 1220 | /** |
| 1221 | * sap_check_in_avoid_ch_list() - checks if given channel present is channel |
| 1222 | * avoidance list |
| 1223 | * |
| 1224 | * @sap_ctx: sap context. |
| 1225 | * @channel: channel to be checked in sap_ctx's avoid ch list |
| 1226 | * |
| 1227 | * sap_ctx contains sap_avoid_ch_info strcut containing the list of channels on |
| 1228 | * which MDM device's AP with MCC was detected. This function checks if given |
| 1229 | * channel is present in that list. |
| 1230 | * |
| 1231 | * Return: true, if channel was present, false othersie. |
| 1232 | */ |
| 1233 | bool sap_check_in_avoid_ch_list(ptSapContext sap_ctx, uint8_t channel) |
| 1234 | { |
| 1235 | uint8_t i = 0; |
| 1236 | struct sap_avoid_channels_info *ie_info = |
| 1237 | &sap_ctx->sap_detected_avoid_ch_ie; |
| 1238 | for (i = 0; i < sizeof(ie_info->channels); i++) |
| 1239 | if (ie_info->channels[i] == channel) |
| 1240 | return true; |
| 1241 | return false; |
| 1242 | } |
| 1243 | #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ |
| 1244 | |
| 1245 | /* |
| 1246 | * This function randomly pick up an AVAILABLE channel |
| 1247 | */ |
| 1248 | static uint8_t sap_random_channel_sel(ptSapContext sapContext) |
| 1249 | { |
| 1250 | uint32_t random_byte = 0; |
| 1251 | uint8_t available_ch_cnt = 0; |
| 1252 | uint8_t avail_dfs_chan_count = 0; |
| 1253 | uint8_t avail_non_dfs_chan_count = 0; |
| 1254 | uint8_t valid_chnl_count = 0; |
| 1255 | uint8_t availableChannels[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0, }; |
| 1256 | uint8_t avail_dfs_chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0,}; |
| 1257 | uint8_t avail_non_dfs_chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0,}; |
| 1258 | uint8_t target_channel = 0; |
| 1259 | bool isChannelNol = false; |
| 1260 | bool isOutOfRange = false; |
| 1261 | chan_bonding_bitmap channelBitmap; |
| 1262 | uint8_t i = 0; |
| 1263 | uint8_t channelID; |
| 1264 | tHalHandle hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 1265 | tpAniSirGlobal pMac; |
| 1266 | uint32_t chanWidth; |
| 1267 | ePhyChanBondState cbModeCurrent; |
| 1268 | uint8_t *tmp_ch_lst = NULL; |
| 1269 | uint8_t dfs_region; |
| 1270 | |
| 1271 | if (NULL == hHal) { |
| 1272 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1273 | FL("invalid hHal")); |
| 1274 | return target_channel; |
| 1275 | } |
| 1276 | |
| 1277 | pMac = PMAC_STRUCT(hHal); |
| 1278 | if (NULL == pMac) { |
| 1279 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1280 | FL("invalid pMac")); |
| 1281 | return target_channel; |
| 1282 | } |
| 1283 | |
| 1284 | /* |
| 1285 | * Retrieve the original one and store it. |
| 1286 | * use the stored original value when you call this function next time |
| 1287 | * so fall back mechanism always starts with original ini value. |
| 1288 | */ |
| 1289 | if (pMac->sap.SapDfsInfo.orig_cbMode == 0) { |
| 1290 | pMac->sap.SapDfsInfo.orig_cbMode = |
| 1291 | (sapContext->ch_width_orig > CH_WIDTH_20MHZ ? 1 : 0); |
| 1292 | cbModeCurrent = pMac->sap.SapDfsInfo.orig_cbMode; |
| 1293 | } else { |
| 1294 | cbModeCurrent = pMac->sap.SapDfsInfo.orig_cbMode; |
| 1295 | } |
| 1296 | |
| 1297 | /* |
| 1298 | * Retrieve the original one and store it. |
| 1299 | * use the stored original value when you call this function next time |
| 1300 | * so fall back mechanism always starts with original ini value. |
| 1301 | */ |
| 1302 | if (pMac->sap.SapDfsInfo.orig_chanWidth == 0) { |
| 1303 | pMac->sap.SapDfsInfo.orig_chanWidth = |
| 1304 | sapContext->ch_width_orig; |
| 1305 | chanWidth = pMac->sap.SapDfsInfo.orig_chanWidth; |
| 1306 | } else { |
| 1307 | chanWidth = pMac->sap.SapDfsInfo.orig_chanWidth; |
| 1308 | } |
| 1309 | |
| 1310 | if (sap_get5_g_hz_channel_list(sapContext)) { |
| 1311 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1312 | FL("Getting 5Ghz channel list failed")); |
| 1313 | return target_channel; |
| 1314 | } |
| 1315 | |
| 1316 | cds_get_dfs_region(&dfs_region); |
| 1317 | |
| 1318 | /* |
| 1319 | * valid_chnl_count will be used to find number of valid channels |
| 1320 | * after following for loop ends |
| 1321 | */ |
| 1322 | valid_chnl_count = sapContext->SapAllChnlList.numChannel; |
| 1323 | /* loop to check ACS range or NOL channels */ |
| 1324 | for (i = 0; i < sapContext->SapAllChnlList.numChannel; i++) { |
| 1325 | channelID = sapContext->SapAllChnlList.channelList[i].channel; |
| 1326 | |
| 1327 | /* |
| 1328 | * IN JAPAN REGULATORY DOMAIN CHECK IF THE FOLLOWING TWO |
| 1329 | * TWO RULES APPLY AND FILTER THE AVAILABLE CHANNELS |
| 1330 | * ACCORDINGLY. |
| 1331 | * |
| 1332 | * 1. If we are operating in Japan regulatory domain |
| 1333 | * Check if Japan W53 Channel operation is NOT |
| 1334 | * allowed and if its not allowed then mark all the |
| 1335 | * W53 channels as Invalid. |
| 1336 | * |
| 1337 | * 2. If we are operating in Japan regulatory domain |
| 1338 | * Check if channel switch between Indoor/Outdoor |
| 1339 | * is allowed. If it is not allowed then limit |
| 1340 | * the avaiable channels to Indoor or Outdoor |
| 1341 | * channels only based up on the SAP Channel location |
| 1342 | * indicated by "sap_operating_channel_location" param. |
| 1343 | */ |
| 1344 | if (DFS_MKK4_DOMAIN == dfs_region) { |
| 1345 | /* |
| 1346 | * Check for JAPAN W53 Channel operation capability |
| 1347 | */ |
| 1348 | if (true == sap_dfs_is_w53_invalid(hHal, channelID)) { |
| 1349 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1350 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1351 | FL |
| 1352 | ("index:%d, Channel=%d Invalid,Japan W53 Disabled"), |
| 1353 | i, channelID); |
| 1354 | sapContext->SapAllChnlList.channelList[i]. |
| 1355 | valid = false; |
| 1356 | valid_chnl_count--; |
| 1357 | continue; |
| 1358 | } |
| 1359 | |
| 1360 | /* |
| 1361 | * If SAP's preferred channel location is Indoor |
| 1362 | * then set all the outdoor channels in the domain |
| 1363 | * to invalid.If the preferred channel location is |
| 1364 | * outdoor then set all the Indoor channels in the |
| 1365 | * domain to Invalid. |
| 1366 | */ |
| 1367 | if (false == |
| 1368 | sap_dfs_is_channel_in_preferred_location(hHal, |
| 1369 | channelID)) { |
| 1370 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1371 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1372 | FL |
| 1373 | ("CHAN=%d is invalid,preferred Channel Location %d Only"), |
| 1374 | channelID, |
| 1375 | pMac->sap.SapDfsInfo. |
| 1376 | sap_operating_chan_preferred_location); |
| 1377 | sapContext->SapAllChnlList.channelList[i]. |
| 1378 | valid = false; |
| 1379 | valid_chnl_count--; |
| 1380 | continue; |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | if (cds_get_channel_state(channelID) == |
| 1385 | CHANNEL_STATE_DFS) { |
| 1386 | isChannelNol = |
| 1387 | sap_dfs_is_channel_in_nol_list(sapContext, |
| 1388 | channelID, |
| 1389 | PHY_SINGLE_CHANNEL_CENTERED); |
| 1390 | if (true == isChannelNol) { |
| 1391 | /* |
| 1392 | * Mark this channel invalid since it is still |
| 1393 | * in DFS Non-Occupancy-Period which is 30 mins. |
| 1394 | */ |
| 1395 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1396 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1397 | FL |
| 1398 | ("index: %d, Channel = %d Present in NOL LIST"), |
| 1399 | i, channelID); |
| 1400 | sapContext->SapAllChnlList.channelList[i]. |
| 1401 | valid = false; |
| 1402 | valid_chnl_count--; |
| 1403 | continue; |
| 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | #ifdef FEATURE_AP_MCC_CH_AVOIDANCE |
| 1408 | /* avoid ch on which another MDM AP in MCC mode is detected */ |
| 1409 | if (pMac->sap.sap_channel_avoidance |
| 1410 | && sapContext->sap_detected_avoid_ch_ie.present) { |
| 1411 | if (sap_check_in_avoid_ch_list(sapContext, channelID)) { |
| 1412 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1413 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1414 | FL("index: %d, Channel = %d, avoided due to presence of another AP+AP MCC device in same channel."), |
| 1415 | i, channelID); |
| 1416 | sapContext->SapAllChnlList.channelList[i].valid |
| 1417 | = false; |
| 1418 | } |
| 1419 | } |
| 1420 | #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ |
| 1421 | |
| 1422 | /* check if the channel is within ACS channel range */ |
| 1423 | isOutOfRange = sap_acs_channel_check(sapContext, channelID); |
| 1424 | if (true == isOutOfRange) { |
| 1425 | /* |
| 1426 | * mark this channel invalid since it is out of ACS |
| 1427 | * channel range |
| 1428 | */ |
| 1429 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1430 | FL |
| 1431 | ("index: %d, Channel = %d out of ACS channel range"), |
| 1432 | i, channelID); |
| 1433 | sapContext->SapAllChnlList.channelList[i].valid = false; |
| 1434 | valid_chnl_count--; |
| 1435 | continue; |
| 1436 | } |
| 1437 | } /* end of check for NOL or ACS channels */ |
| 1438 | |
| 1439 | /* valid_chnl_count now have number of valid channels */ |
| 1440 | tmp_ch_lst = cdf_mem_malloc(valid_chnl_count); |
| 1441 | if (tmp_ch_lst == NULL) { |
| 1442 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1443 | FL("sapdfs: memory alloc failed")); |
| 1444 | return target_channel; |
| 1445 | } |
| 1446 | |
| 1447 | do { |
| 1448 | uint8_t j = 0; |
| 1449 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 1450 | tSapDfsNolInfo *nol = pMac->sap.SapDfsInfo.sapDfsChannelNolList; |
| 1451 | #endif |
| 1452 | |
| 1453 | /* prepare temp list of just the valid channels */ |
| 1454 | for (i = 0; i < sapContext->SapAllChnlList.numChannel; i++) { |
| 1455 | if (sapContext->SapAllChnlList.channelList[i].valid) { |
| 1456 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1457 | CDF_TRACE_LEVEL_ERROR, |
| 1458 | FL |
| 1459 | ("sapdfs: Adding Channel = %d to temp List"), |
| 1460 | sapContext->SapAllChnlList. |
| 1461 | channelList[i].channel); |
| 1462 | tmp_ch_lst[j++] = sapContext->SapAllChnlList. |
| 1463 | channelList[i].channel; |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 1468 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1469 | CDF_TRACE_LEVEL_ERROR, |
| 1470 | FL |
| 1471 | ("sapdfs: Processing temp channel list against NOL.") |
| 1472 | ); |
| 1473 | if (CDF_STATUS_SUCCESS != |
| 1474 | sap_mark_channels_leaking_into_nol(sapContext, |
| 1475 | cbModeCurrent, |
| 1476 | nol, |
| 1477 | valid_chnl_count, |
| 1478 | tmp_ch_lst)) { |
| 1479 | cdf_mem_free(tmp_ch_lst); |
| 1480 | return target_channel; |
| 1481 | } |
| 1482 | #endif |
| 1483 | cdf_mem_zero(availableChannels, sizeof(availableChannels)); |
| 1484 | cdf_mem_zero(&channelBitmap, sizeof(channelBitmap)); |
| 1485 | channelBitmap.chanBondingSet[0].startChannel = 36; |
| 1486 | channelBitmap.chanBondingSet[1].startChannel = 52; |
| 1487 | channelBitmap.chanBondingSet[2].startChannel = 100; |
| 1488 | channelBitmap.chanBondingSet[3].startChannel = 116; |
| 1489 | channelBitmap.chanBondingSet[3].startChannel = 132; |
| 1490 | channelBitmap.chanBondingSet[4].startChannel = 149; |
| 1491 | /* now loop through whatever is left of channel list */ |
| 1492 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1493 | CDF_TRACE_LEVEL_ERROR, |
| 1494 | FL("sapdfs: Moving temp channel list to final.")); |
| 1495 | for (i = 0; i < valid_chnl_count; i++) { |
| 1496 | /* |
| 1497 | * add channel from temp channel list to bitmap or fianl |
| 1498 | * channel list (in case of 20MHz width) |
| 1499 | */ |
| 1500 | if (tmp_ch_lst[i] != 0) { |
| 1501 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1502 | CDF_TRACE_LEVEL_DEBUG, |
| 1503 | FL("sapdfs: processing channel: %d "), |
| 1504 | tmp_ch_lst[i]); |
| 1505 | /* |
| 1506 | * for 20MHz, directly create available |
| 1507 | * channel list |
| 1508 | */ |
| 1509 | if (cbModeCurrent == |
| 1510 | PHY_SINGLE_CHANNEL_CENTERED) { |
| 1511 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1512 | CDF_TRACE_LEVEL_DEBUG, |
| 1513 | FL |
| 1514 | ("sapdfs: Channel=%d added to available list"), |
| 1515 | tmp_ch_lst[i]); |
| 1516 | availableChannels[available_ch_cnt++] = |
| 1517 | tmp_ch_lst[i]; |
| 1518 | } else { |
| 1519 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1520 | CDF_TRACE_LEVEL_DEBUG, |
| 1521 | FL("sapdfs: Channel=%d added to bitmap"), |
| 1522 | tmp_ch_lst[i]); |
| 1523 | sap_set_bitmap(&channelBitmap, |
| 1524 | tmp_ch_lst[i]); |
| 1525 | } |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | /* |
| 1530 | * if 40 MHz or 80 MHz, populate available |
| 1531 | * channel list from bitmap |
| 1532 | */ |
| 1533 | if (cbModeCurrent != PHY_SINGLE_CHANNEL_CENTERED) { |
| 1534 | available_ch_cnt = |
| 1535 | sap_populate_available_channels(&channelBitmap, |
| 1536 | cbModeCurrent, |
| 1537 | availableChannels); |
| 1538 | /* |
| 1539 | * if no valid channel bonding found, |
| 1540 | * fallback to lower bandwidth |
| 1541 | */ |
| 1542 | if (available_ch_cnt == 0) { |
| 1543 | if (cbModeCurrent >= |
| 1544 | PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED) { |
| 1545 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1546 | CDF_TRACE_LEVEL_WARN, |
| 1547 | FL |
| 1548 | ("sapdfs:No 80MHz cb found, falling to 40MHz")); |
| 1549 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1550 | CDF_TRACE_LEVEL_WARN, |
| 1551 | FL |
| 1552 | ("sapdfs:Changing chanWidth from [%d] to [%d]"), |
| 1553 | chanWidth, |
| 1554 | CH_WIDTH_40MHZ); |
| 1555 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1556 | CDF_TRACE_LEVEL_WARN, |
| 1557 | FL |
| 1558 | ("sapdfs:Changing CB mode from [%d] to [%d]"), |
| 1559 | cbModeCurrent, |
| 1560 | PHY_DOUBLE_CHANNEL_LOW_PRIMARY |
| 1561 | ); |
| 1562 | cbModeCurrent = |
| 1563 | PHY_DOUBLE_CHANNEL_LOW_PRIMARY; |
| 1564 | chanWidth = CH_WIDTH_40MHZ; |
| 1565 | /* continue to start of do loop */ |
| 1566 | continue; |
| 1567 | } else if (cbModeCurrent >= |
| 1568 | PHY_DOUBLE_CHANNEL_LOW_PRIMARY) { |
| 1569 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1570 | CDF_TRACE_LEVEL_WARN, |
| 1571 | FL |
| 1572 | ("sapdfs:No 40MHz cb found, falling to 20MHz")); |
| 1573 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1574 | CDF_TRACE_LEVEL_WARN, |
| 1575 | FL |
| 1576 | ("sapdfs:Changing chanWidth from [%d] to [%d]"), |
| 1577 | chanWidth, |
| 1578 | CH_WIDTH_20MHZ); |
| 1579 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1580 | CDF_TRACE_LEVEL_WARN, |
| 1581 | FL |
| 1582 | ("sapdfs:Changing CB mode from [%d] to [%d]"), |
| 1583 | cbModeCurrent, |
| 1584 | PHY_SINGLE_CHANNEL_CENTERED); |
| 1585 | cbModeCurrent = |
| 1586 | PHY_SINGLE_CHANNEL_CENTERED; |
| 1587 | chanWidth = CH_WIDTH_20MHZ; |
| 1588 | /* continue to start of do loop */ |
| 1589 | continue; |
| 1590 | } |
| 1591 | } |
| 1592 | } |
| 1593 | |
| 1594 | /* |
| 1595 | * by now, available channels list will be populated or |
| 1596 | * no channels are avaialbe |
| 1597 | */ |
| 1598 | if (available_ch_cnt) { |
| 1599 | for (i = 0; i < available_ch_cnt; i++) { |
| 1600 | if (CDS_IS_DFS_CH(availableChannels[i])) { |
| 1601 | avail_dfs_chan_list[ |
| 1602 | avail_dfs_chan_count++] = |
| 1603 | availableChannels[i]; |
| 1604 | } else { |
| 1605 | avail_non_dfs_chan_list[ |
| 1606 | avail_non_dfs_chan_count++] = |
| 1607 | availableChannels[i]; |
| 1608 | } |
| 1609 | } |
| 1610 | } else { |
| 1611 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1612 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1613 | FL("No target channel found")); |
| 1614 | } |
| 1615 | |
| 1616 | cds_rand_get_bytes(0, (uint8_t *)&random_byte, 1); |
| 1617 | |
| 1618 | /* Give preference to non-DFS channel */ |
| 1619 | if (!pMac->f_prefer_non_dfs_on_radar) { |
| 1620 | i = (random_byte + cdf_mc_timer_get_system_ticks()) % |
| 1621 | available_ch_cnt; |
| 1622 | target_channel = availableChannels[i]; |
| 1623 | } else if (avail_non_dfs_chan_count) { |
| 1624 | i = (random_byte + cdf_mc_timer_get_system_ticks()) % |
| 1625 | avail_non_dfs_chan_count; |
| 1626 | target_channel = avail_non_dfs_chan_list[i]; |
| 1627 | } else { |
| 1628 | i = (random_byte + cdf_mc_timer_get_system_ticks()) % |
| 1629 | avail_dfs_chan_count; |
| 1630 | target_channel = avail_dfs_chan_list[i]; |
| 1631 | } |
| 1632 | |
| 1633 | pMac->sap.SapDfsInfo.new_chanWidth = chanWidth; |
| 1634 | pMac->sap.SapDfsInfo.new_cbMode = cbModeCurrent; |
| 1635 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1636 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1637 | FL("sapdfs: New CB mode = %d"), |
| 1638 | pMac->sap.SapDfsInfo.new_cbMode); |
| 1639 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1640 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1641 | FL("sapdfs: New Channel width = %d"), |
| 1642 | pMac->sap.SapDfsInfo.new_chanWidth); |
| 1643 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1644 | CDF_TRACE_LEVEL_INFO_LOW, |
| 1645 | FL("sapdfs: target_channel = %d"), |
| 1646 | target_channel); |
| 1647 | break; |
| 1648 | /* this loop will iterate at max 3 times */ |
| 1649 | } while (1); |
| 1650 | cdf_mem_free(tmp_ch_lst); |
| 1651 | return target_channel; |
| 1652 | } |
| 1653 | |
| 1654 | bool sap_acs_channel_check(ptSapContext sapContext, uint8_t channelNumber) |
| 1655 | { |
| 1656 | int i = 0; |
| 1657 | if (!sapContext->acs_cfg->acs_mode) |
| 1658 | return false; |
| 1659 | |
| 1660 | if ((channelNumber >= sapContext->acs_cfg->start_ch) || |
| 1661 | (channelNumber <= sapContext->acs_cfg->end_ch)) { |
| 1662 | if (!sapContext->acs_cfg->ch_list) { |
| 1663 | return false; |
| 1664 | } else { |
| 1665 | for (i = 0; i < sapContext->acs_cfg->ch_list_count; i++) |
| 1666 | if (channelNumber == |
| 1667 | sapContext->acs_cfg->ch_list[i]) |
| 1668 | return false; |
| 1669 | } |
| 1670 | } |
| 1671 | return true; |
| 1672 | } |
| 1673 | |
| 1674 | /** |
| 1675 | * sap_mark_dfs_channels() - to mark dfs channel |
| 1676 | * @sapContext: pointer sap context |
| 1677 | * @channels: list of channels |
| 1678 | * @numChannels: number of channels |
| 1679 | * @time: time |
| 1680 | * |
| 1681 | * Mark the channels in NOL with time and eSAP_DFS_CHANNEL_UNAVAILABLE |
| 1682 | * |
| 1683 | * Return: none |
| 1684 | */ |
| 1685 | void sap_mark_dfs_channels(ptSapContext sapContext, uint8_t *channels, |
| 1686 | uint8_t numChannels, uint64_t time) |
| 1687 | { |
| 1688 | int i, j; |
| 1689 | tSapDfsNolInfo *psapDfsChannelNolList = NULL; |
| 1690 | uint8_t nRegDomainDfsChannels; |
| 1691 | tHalHandle hHal; |
| 1692 | tpAniSirGlobal pMac; |
| 1693 | |
| 1694 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 1695 | if (NULL == channels) |
| 1696 | return; |
| 1697 | if (NULL == hHal) { |
| 1698 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1699 | FL("invalid hHal")); |
| 1700 | return; |
| 1701 | } |
| 1702 | pMac = PMAC_STRUCT(hHal); |
| 1703 | if (NULL == pMac) { |
| 1704 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1705 | FL("invalid pMac")); |
| 1706 | return; |
| 1707 | } |
| 1708 | |
| 1709 | /* |
| 1710 | * Mark the current channel on which Radar is found |
| 1711 | * in the NOL list as eSAP_DFS_CHANNEL_UNAVAILABLE. |
| 1712 | */ |
| 1713 | psapDfsChannelNolList = pMac->sap.SapDfsInfo.sapDfsChannelNolList; |
| 1714 | nRegDomainDfsChannels = |
| 1715 | pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels; |
| 1716 | |
| 1717 | for (i = 0; i < numChannels; i++) { |
| 1718 | for (j = 0; j <= nRegDomainDfsChannels; j++) { |
| 1719 | if (!(psapDfsChannelNolList[j].dfs_channel_number == |
| 1720 | channels[i])) |
| 1721 | continue; |
| 1722 | /* |
| 1723 | * If channel is already in NOL, don't update it again. |
| 1724 | * This is useful when marking bonding channels which |
| 1725 | * are already unavailable. |
| 1726 | */ |
| 1727 | if (psapDfsChannelNolList[j].radar_status_flag == |
| 1728 | eSAP_DFS_CHANNEL_UNAVAILABLE) { |
| 1729 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1730 | CDF_TRACE_LEVEL_INFO_HIGH, |
| 1731 | FL("Channel=%d already in NOL"), |
| 1732 | channels[i]); |
| 1733 | continue; |
| 1734 | } |
| 1735 | /* |
| 1736 | * Capture the Radar Found timestamp on the |
| 1737 | * Current Channel in ms. |
| 1738 | */ |
| 1739 | psapDfsChannelNolList[j].radar_found_timestamp = time; |
| 1740 | /* Mark the Channel to be unavailble for next 30 mins */ |
| 1741 | psapDfsChannelNolList[j].radar_status_flag = |
| 1742 | eSAP_DFS_CHANNEL_UNAVAILABLE; |
| 1743 | |
| 1744 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 1745 | CDF_TRACE_LEVEL_INFO_HIGH, |
| 1746 | FL("Channel=%d Added to NOL LIST"), |
| 1747 | channels[i]); |
| 1748 | } |
| 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | /* |
| 1753 | * This Function is to get bonding channels from primary channel. |
| 1754 | * |
| 1755 | */ |
| 1756 | uint8_t sap_get_bonding_channels(ptSapContext sapContext, uint8_t channel, |
| 1757 | uint8_t *channels, uint8_t size, |
| 1758 | ePhyChanBondState chanBondState) |
| 1759 | { |
| 1760 | tHalHandle hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 1761 | tpAniSirGlobal pMac; |
| 1762 | uint8_t numChannel; |
| 1763 | |
| 1764 | if (channels == NULL) |
| 1765 | return 0; |
| 1766 | |
| 1767 | if (size < MAX_BONDED_CHANNELS) |
| 1768 | return 0; |
| 1769 | |
| 1770 | if (NULL != hHal) { |
| 1771 | pMac = PMAC_STRUCT(hHal); |
| 1772 | } else |
| 1773 | return 0; |
| 1774 | |
| 1775 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 1776 | FL("cbmode: %d, channel: %d"), chanBondState, channel); |
| 1777 | |
| 1778 | switch (chanBondState) { |
| 1779 | case PHY_SINGLE_CHANNEL_CENTERED: |
| 1780 | numChannel = 1; |
| 1781 | channels[0] = channel; |
| 1782 | break; |
| 1783 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: |
| 1784 | numChannel = 2; |
| 1785 | channels[0] = channel - 4; |
| 1786 | channels[1] = channel; |
| 1787 | break; |
| 1788 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: |
| 1789 | numChannel = 2; |
| 1790 | channels[0] = channel; |
| 1791 | channels[1] = channel + 4; |
| 1792 | break; |
| 1793 | #ifdef WLAN_FEATURE_11AC |
| 1794 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW: |
| 1795 | numChannel = 4; |
| 1796 | channels[0] = channel; |
| 1797 | channels[1] = channel + 4; |
| 1798 | channels[2] = channel + 8; |
| 1799 | channels[3] = channel + 12; |
| 1800 | break; |
| 1801 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW: |
| 1802 | numChannel = 4; |
| 1803 | channels[0] = channel - 4; |
| 1804 | channels[1] = channel; |
| 1805 | channels[2] = channel + 4; |
| 1806 | channels[3] = channel + 8; |
| 1807 | break; |
| 1808 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH: |
| 1809 | numChannel = 4; |
| 1810 | channels[0] = channel - 8; |
| 1811 | channels[1] = channel - 4; |
| 1812 | channels[2] = channel; |
| 1813 | channels[3] = channel + 4; |
| 1814 | break; |
| 1815 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH: |
| 1816 | numChannel = 4; |
| 1817 | channels[0] = channel - 12; |
| 1818 | channels[1] = channel - 8; |
| 1819 | channels[2] = channel - 4; |
| 1820 | channels[3] = channel; |
| 1821 | break; |
| 1822 | #endif |
| 1823 | default: |
| 1824 | numChannel = 1; |
| 1825 | channels[0] = channel; |
| 1826 | break; |
| 1827 | } |
| 1828 | |
| 1829 | return numChannel; |
| 1830 | } |
| 1831 | |
| 1832 | /** |
| 1833 | * sap_dfs_check_if_channel_avaialable() - Check if a channel is out of NOL |
| 1834 | * @nol: Pointer to the Non-Occupancy List. |
| 1835 | * |
| 1836 | * This function Checks if a given channel is available or |
| 1837 | * usable or unavailable based on the time lapse since the |
| 1838 | * last radar time stamp. |
| 1839 | * |
| 1840 | * Return: true if channel available or usable, false if unavailable. |
| 1841 | */ |
| 1842 | static bool sap_dfs_check_if_channel_avaialable(tSapDfsNolInfo *nol) |
| 1843 | { |
| 1844 | uint64_t time_since_last_radar, time_when_radar_found, current_time = 0; |
| 1845 | uint64_t max_jiffies; |
| 1846 | |
| 1847 | if ((nol->radar_status_flag == eSAP_DFS_CHANNEL_USABLE) || |
| 1848 | (nol->radar_status_flag == eSAP_DFS_CHANNEL_AVAILABLE)) { |
| 1849 | /* |
| 1850 | * Allow SAP operation on this channel |
| 1851 | * either the DFS channel has not been used |
| 1852 | * for SAP operation or it is available for |
| 1853 | * SAP operation since it is past |
| 1854 | * Non-Occupancy-Period so, return false. |
| 1855 | */ |
| 1856 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1857 | FL("Chan=%d not in NOL,CHAN AVAILABLE"), |
| 1858 | nol->dfs_channel_number); |
| 1859 | return true; |
| 1860 | } else if (nol->radar_status_flag == eSAP_DFS_CHANNEL_UNAVAILABLE) { |
| 1861 | /* |
| 1862 | * If a DFS Channel is UNAVAILABLE then |
| 1863 | * check to see if it is past |
| 1864 | * Non-occupancy-period |
| 1865 | * of 30 minutes. If it is past 30 mins then |
| 1866 | * mark the channel as AVAILABLE and return |
| 1867 | * false as the channel is not anymore in |
| 1868 | * NON-Occupancy-Period. |
| 1869 | */ |
| 1870 | time_when_radar_found = nol->radar_found_timestamp; |
| 1871 | current_time = cds_get_monotonic_boottime(); |
| 1872 | if (current_time < time_when_radar_found) { |
| 1873 | /* cds_get_monotonic_boottime() can overflow. |
| 1874 | * Jiffies is initialized such that 32 bit jiffies |
| 1875 | * value wrap 5 minutes after boot so jiffies wrap bugs |
| 1876 | * show up earlier |
| 1877 | */ |
| 1878 | max_jiffies = (uint64_t)UINT_MAX * 1000; |
| 1879 | time_since_last_radar = (max_jiffies - |
| 1880 | time_when_radar_found) + (current_time); |
| 1881 | } else { |
| 1882 | time_since_last_radar = current_time - |
| 1883 | time_when_radar_found; |
| 1884 | } |
| 1885 | if (time_since_last_radar >= SAP_DFS_NON_OCCUPANCY_PERIOD) { |
| 1886 | nol->radar_status_flag = eSAP_DFS_CHANNEL_AVAILABLE; |
| 1887 | nol->radar_found_timestamp = 0; |
| 1888 | |
| 1889 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1890 | FL("Chan=%d not in NOL, Channel AVAILABLE"), |
| 1891 | nol->dfs_channel_number); |
| 1892 | return true; |
| 1893 | } else { |
| 1894 | /* |
| 1895 | * Channel is not still available for |
| 1896 | * SAP operation so return true; As the |
| 1897 | * Channel is still in |
| 1898 | * Non-occupancy-Period. |
| 1899 | */ |
| 1900 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1901 | FL("Chan=%d in NOL, Channel UNAVAILBLE"), |
| 1902 | nol->dfs_channel_number); |
| 1903 | return false; |
| 1904 | } |
| 1905 | } else { |
| 1906 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1907 | FL("Invalid Radar Status Flag")); |
| 1908 | } |
| 1909 | return true; |
| 1910 | } |
| 1911 | |
| 1912 | /** |
| 1913 | * sap_dfs_is_channel_in_nol_list() - given bonded channel is available |
| 1914 | * @sap_context: Handle to SAP context. |
| 1915 | * @channel_number: Channel on which availability should be checked. |
| 1916 | * @chan_bondState: The channel bonding mode of the passed channel. |
| 1917 | * |
| 1918 | * This function Checks if a given bonded channel is available or |
| 1919 | * usable for DFS operation. |
| 1920 | * |
| 1921 | * Return: false if channel is available, true if channel is in NOL. |
| 1922 | */ |
| 1923 | bool |
| 1924 | sap_dfs_is_channel_in_nol_list(ptSapContext sap_context, |
| 1925 | uint8_t channel_number, |
| 1926 | ePhyChanBondState chan_bondState) |
| 1927 | { |
| 1928 | int i, j; |
| 1929 | tHalHandle h_hal = CDS_GET_HAL_CB(sap_context->p_cds_gctx); |
| 1930 | tpAniSirGlobal mac_ctx; |
| 1931 | uint8_t channels[MAX_BONDED_CHANNELS]; |
| 1932 | uint8_t num_channels; |
| 1933 | tSapDfsNolInfo *nol; |
| 1934 | tSapDfsInfo *dfs_info; |
| 1935 | bool channel_available; |
| 1936 | |
| 1937 | if (NULL == h_hal) { |
| 1938 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 1939 | FL("invalid h_hal")); |
| 1940 | return false; |
| 1941 | } else { |
| 1942 | mac_ctx = PMAC_STRUCT(h_hal); |
| 1943 | } |
| 1944 | |
| 1945 | dfs_info = &mac_ctx->sap.SapDfsInfo; |
| 1946 | if ((dfs_info->numCurrentRegDomainDfsChannels == 0) || |
| 1947 | (dfs_info->numCurrentRegDomainDfsChannels > |
| 1948 | NUM_5GHZ_CHANNELS)) { |
| 1949 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 1950 | FL("invalid dfs channel count %d"), |
| 1951 | dfs_info->numCurrentRegDomainDfsChannels); |
| 1952 | return false; |
| 1953 | } |
| 1954 | |
| 1955 | /* get the bonded channels */ |
| 1956 | num_channels = sap_get_bonding_channels(sap_context, channel_number, |
| 1957 | channels, MAX_BONDED_CHANNELS, chan_bondState); |
| 1958 | |
| 1959 | /* check for NOL, first on will break the loop */ |
| 1960 | for (j = 0; j < num_channels; j++) { |
| 1961 | for (i = 0; i < dfs_info->numCurrentRegDomainDfsChannels; i++) { |
| 1962 | nol = &dfs_info->sapDfsChannelNolList[i]; |
| 1963 | if (nol->dfs_channel_number != channels[j]) |
| 1964 | continue; |
| 1965 | |
| 1966 | channel_available = |
| 1967 | sap_dfs_check_if_channel_avaialable(nol); |
| 1968 | |
| 1969 | if (channel_available == false) |
| 1970 | break; |
| 1971 | |
| 1972 | } /* loop for dfs channels */ |
| 1973 | |
| 1974 | if (i < dfs_info->numCurrentRegDomainDfsChannels) |
| 1975 | break; |
| 1976 | |
| 1977 | } /* loop for bonded channels */ |
| 1978 | |
| 1979 | /* |
| 1980 | * if any of the channel is not available, mark all available channels |
| 1981 | * as unavailable with same time stamp. |
| 1982 | */ |
| 1983 | if (j < num_channels && |
| 1984 | i < dfs_info->numCurrentRegDomainDfsChannels) { |
| 1985 | if (num_channels > MAX_BONDED_CHANNELS) { |
| 1986 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_WARN, |
| 1987 | FL("num_channel>MAX_BONDED_CHANNEL, reset")); |
| 1988 | num_channels = MAX_BONDED_CHANNELS; |
| 1989 | } |
| 1990 | nol = &dfs_info->sapDfsChannelNolList[i]; |
| 1991 | sap_mark_dfs_channels(sap_context, channels, num_channels, |
| 1992 | nol->radar_found_timestamp); |
| 1993 | |
| 1994 | /* set DFS-NOL back to keep it update-to-date in CNSS */ |
| 1995 | sap_signal_hdd_event(sap_context, NULL, eSAP_DFS_NOL_SET, |
| 1996 | (void *) eSAP_STATUS_SUCCESS); |
| 1997 | |
| 1998 | return true; |
| 1999 | } |
| 2000 | |
| 2001 | return false; |
| 2002 | } |
| 2003 | |
| 2004 | /** |
| 2005 | * sap_goto_channel_sel - Function for initiating scan request for SME |
| 2006 | * @sap_context: Sap Context value. |
| 2007 | * @sap_event: State machine event |
| 2008 | * @sap_do_acs_pre_start_bss: true, if ACS scan is issued pre start BSS |
| 2009 | * false, if ACS scan is issued post start BSS. |
| 2010 | * |
| 2011 | * Initiates sme scan for ACS to pick a channel. |
| 2012 | * |
| 2013 | * Return: The CDF_STATUS code associated with performing the operation. |
| 2014 | */ |
| 2015 | CDF_STATUS sap_goto_channel_sel(ptSapContext sap_context, |
| 2016 | ptWLAN_SAPEvent sap_event, |
| 2017 | bool sap_do_acs_pre_start_bss) |
| 2018 | { |
| 2019 | |
| 2020 | /* Initiate a SCAN request */ |
| 2021 | CDF_STATUS cdf_ret_status; |
| 2022 | /* To be initialised if scan is required */ |
| 2023 | tCsrScanRequest scan_request; |
| 2024 | CDF_STATUS cdf_status = CDF_STATUS_SUCCESS; |
| 2025 | |
| 2026 | #ifdef SOFTAP_CHANNEL_RANGE |
| 2027 | uint8_t *channel_list = NULL; |
| 2028 | uint8_t num_of_channels = 0; |
| 2029 | #endif |
| 2030 | tHalHandle h_hal; |
| 2031 | uint8_t con_ch; |
| 2032 | |
| 2033 | h_hal = cds_get_context(CDF_MODULE_ID_SME); |
| 2034 | if (NULL == h_hal) { |
| 2035 | /* we have a serious problem */ |
| 2036 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_FATAL, |
| 2037 | FL("invalid h_hal")); |
| 2038 | return CDF_STATUS_E_FAULT; |
| 2039 | } |
| 2040 | #ifdef WLAN_FEATURE_MBSSID |
| 2041 | if (cds_concurrent_beaconing_sessions_running()) { |
| 2042 | con_ch = |
| 2043 | sme_get_concurrent_operation_channel(h_hal); |
| 2044 | |
| 2045 | if (con_ch && sap_context->channel == AUTO_CHANNEL_SELECT) { |
| 2046 | sap_context->dfs_ch_disable = true; |
| 2047 | } else if (con_ch && sap_context->channel != con_ch && |
| 2048 | CDS_IS_DFS_CH(sap_context->channel)) { |
| 2049 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_WARN, |
| 2050 | FL("MCC DFS not supported in AP_AP Mode")); |
| 2051 | return CDF_STATUS_E_ABORTED; |
| 2052 | } |
| 2053 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 2054 | if (sap_context->cc_switch_mode != |
| 2055 | CDF_MCC_TO_SCC_SWITCH_DISABLE) { |
| 2056 | con_ch = sme_check_concurrent_channel_overlap(h_hal, |
| 2057 | sap_context->channel, |
| 2058 | sap_context->csr_roamProfile.phyMode, |
| 2059 | sap_context->cc_switch_mode); |
| 2060 | if (con_ch) { |
| 2061 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 2062 | CDF_TRACE_LEVEL_ERROR, |
| 2063 | "%s: Override ch %d to %d due to CC Intf", |
| 2064 | __func__, sap_context->channel, con_ch); |
| 2065 | sap_context->channel = con_ch; |
| 2066 | } |
| 2067 | } |
| 2068 | #endif |
| 2069 | } |
| 2070 | #endif |
| 2071 | |
| 2072 | if (cds_get_concurrency_mode() == (CDF_STA_MASK | CDF_SAP_MASK)) { |
| 2073 | #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE |
| 2074 | if (sap_context->channel == AUTO_CHANNEL_SELECT) |
| 2075 | sap_context->dfs_ch_disable = true; |
| 2076 | else if (CDS_IS_DFS_CH(sap_context->channel)) { |
| 2077 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_WARN, |
| 2078 | FL("DFS not supported in STA_AP Mode")); |
| 2079 | return CDF_STATUS_E_ABORTED; |
| 2080 | } |
| 2081 | #endif |
| 2082 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 2083 | if (sap_context->cc_switch_mode != |
| 2084 | CDF_MCC_TO_SCC_SWITCH_DISABLE) { |
| 2085 | con_ch = sme_check_concurrent_channel_overlap(h_hal, |
| 2086 | sap_context->channel, |
| 2087 | sap_context->csr_roamProfile.phyMode, |
| 2088 | sap_context->cc_switch_mode); |
| 2089 | if (con_ch && !CDS_IS_DFS_CH(con_ch)) { |
| 2090 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 2091 | CDF_TRACE_LEVEL_ERROR, |
| 2092 | "%s: Override ch %d to %d due to CC Intf", |
| 2093 | __func__, sap_context->channel, con_ch); |
| 2094 | sap_context->channel = con_ch; |
| 2095 | } |
| 2096 | } |
| 2097 | #endif |
| 2098 | } |
| 2099 | |
| 2100 | if (sap_context->channel == AUTO_CHANNEL_SELECT) { |
| 2101 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 2102 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2103 | FL("%s skip_acs_status = %d "), __func__, |
| 2104 | sap_context->acs_cfg->skip_scan_status); |
| 2105 | if (sap_context->acs_cfg->skip_scan_status != |
| 2106 | eSAP_SKIP_ACS_SCAN) { |
| 2107 | #endif |
| 2108 | cdf_mem_zero(&scan_request, sizeof(scan_request)); |
| 2109 | |
| 2110 | /* |
| 2111 | * Set scanType to Active scan. FW takes care of using passive |
| 2112 | * scan for DFS and active for non DFS channels. |
| 2113 | */ |
| 2114 | scan_request.scanType = eSIR_ACTIVE_SCAN; |
| 2115 | |
| 2116 | /* Set min and max channel time to zero */ |
| 2117 | scan_request.minChnTime = 0; |
| 2118 | scan_request.maxChnTime = 0; |
| 2119 | |
| 2120 | /* Set BSSType to default type */ |
| 2121 | scan_request.BSSType = eCSR_BSS_TYPE_ANY; |
| 2122 | |
| 2123 | #ifndef SOFTAP_CHANNEL_RANGE |
| 2124 | /*Scan all the channels */ |
| 2125 | scan_request.ChannelInfo.num_of_channels = 0; |
| 2126 | |
| 2127 | scan_request.ChannelInfo.ChannelList = NULL; |
| 2128 | |
| 2129 | scan_request.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 2130 | /* eCSR_SCAN_REQUEST_11D_SCAN; */ |
| 2131 | |
| 2132 | #else |
| 2133 | |
| 2134 | sap_get_channel_list(sap_context, &channel_list, |
| 2135 | &num_of_channels); |
| 2136 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 2137 | if (num_of_channels != 0) { |
| 2138 | #endif |
| 2139 | /*Scan the channels in the list */ |
| 2140 | scan_request.ChannelInfo.numOfChannels = |
| 2141 | num_of_channels; |
| 2142 | |
| 2143 | scan_request.ChannelInfo.ChannelList = |
| 2144 | channel_list; |
| 2145 | |
| 2146 | scan_request.requestType = |
| 2147 | eCSR_SCAN_SOFTAP_CHANNEL_RANGE; |
| 2148 | |
| 2149 | sap_context->channelList = channel_list; |
| 2150 | |
| 2151 | #endif |
| 2152 | /* Set requestType to Full scan */ |
| 2153 | |
| 2154 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2155 | FL("calling sme_scan_request")); |
| 2156 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 2157 | if (sap_context->acs_cfg->skip_scan_status == |
| 2158 | eSAP_DO_NEW_ACS_SCAN) |
| 2159 | #endif |
| 2160 | sme_scan_flush_result(h_hal); |
| 2161 | if (true == sap_do_acs_pre_start_bss) { |
| 2162 | /* |
| 2163 | * when ID == 0 11D scan/active scan with callback, |
| 2164 | * min-maxChntime set in csrScanRequest()? |
| 2165 | * csrScanCompleteCallback callback |
| 2166 | * pContext scan_request_id filled up |
| 2167 | */ |
| 2168 | cdf_ret_status = sme_scan_request(h_hal, |
| 2169 | sap_context->sessionId, |
| 2170 | &scan_request, |
| 2171 | &wlansap_pre_start_bss_acs_scan_callback, |
| 2172 | sap_context); |
| 2173 | } else { |
| 2174 | /* |
| 2175 | * when ID == 0 11D scan/active scan with callback, |
| 2176 | * min-maxChntime set in csrScanRequest()? |
| 2177 | * csrScanCompleteCallback callback, |
| 2178 | * pContext scan_request_id filled up |
| 2179 | */ |
| 2180 | cdf_ret_status = sme_scan_request(h_hal, |
| 2181 | sap_context->sessionId, |
| 2182 | &scan_request, |
| 2183 | &wlansap_scan_callback, |
| 2184 | sap_context); |
| 2185 | } |
| 2186 | if (CDF_STATUS_SUCCESS != cdf_ret_status) { |
| 2187 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2188 | FL("sme_scan_request fail %d!!!"), |
| 2189 | cdf_ret_status); |
| 2190 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2191 | FL("SAP Configuring default channel, Ch=%d"), |
| 2192 | sap_context->channel); |
| 2193 | /* In case of error, switch to default channel */ |
| 2194 | sap_context->channel = SAP_DEFAULT_24GHZ_CHANNEL; |
| 2195 | |
| 2196 | #ifdef SOFTAP_CHANNEL_RANGE |
| 2197 | if (sap_context->channelList != NULL) { |
| 2198 | sap_context->channel = |
| 2199 | sap_context->channelList[0]; |
| 2200 | cdf_mem_free(sap_context-> |
| 2201 | channelList); |
| 2202 | sap_context->channelList = NULL; |
| 2203 | } |
| 2204 | #endif |
| 2205 | if (true == sap_do_acs_pre_start_bss) { |
| 2206 | /* |
| 2207 | * In case of ACS req before start Bss, |
| 2208 | * return failure so that the calling |
| 2209 | * fucntion can use the default channel. |
| 2210 | */ |
| 2211 | return CDF_STATUS_E_FAILURE; |
| 2212 | } else { |
| 2213 | /* Fill in the event structure */ |
| 2214 | sap_event_init(sap_event); |
| 2215 | /* Handle event */ |
| 2216 | cdf_status = sap_fsm(sap_context, sap_event); |
| 2217 | } |
| 2218 | } else { |
| 2219 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2220 | FL("return sme_ScanReq, scanID=%d, Ch=%d"), |
| 2221 | scan_request.scan_id, sap_context->channel); |
| 2222 | } |
| 2223 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 2224 | } |
| 2225 | } else { |
| 2226 | sap_context->acs_cfg->skip_scan_status = eSAP_SKIP_ACS_SCAN; |
| 2227 | } |
| 2228 | |
| 2229 | if (sap_context->acs_cfg->skip_scan_status == eSAP_SKIP_ACS_SCAN) { |
| 2230 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2231 | FL("## %s SKIPPED ACS SCAN"), __func__); |
| 2232 | wlansap_scan_callback(h_hal, sap_context, |
| 2233 | sap_context->sessionId, 0, eCSR_SCAN_SUCCESS); |
| 2234 | } |
| 2235 | #endif |
| 2236 | } else { |
| 2237 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2238 | FL("for configured channel, Ch= %d"), |
| 2239 | sap_context->channel); |
| 2240 | if (sap_do_acs_pre_start_bss == true) { |
| 2241 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 2242 | FL("ACS end due to Ch override. Sel Ch = %d"), |
| 2243 | sap_context->channel); |
| 2244 | sap_context->acs_cfg->pri_ch = sap_context->channel; |
| 2245 | sap_context->acs_cfg->ch_width = |
| 2246 | sap_context->ch_width_orig; |
| 2247 | sap_config_acs_result(h_hal, sap_context, 0); |
| 2248 | return CDF_STATUS_E_CANCELED; |
| 2249 | } else { |
| 2250 | /* |
| 2251 | * Fill in the event structure |
| 2252 | * Eventhough scan was not done, |
| 2253 | * means a user set channel was chosen |
| 2254 | */ |
| 2255 | sap_event_init(sap_event); |
| 2256 | /* Handle event */ |
| 2257 | cdf_status = sap_fsm(sap_context, sap_event); |
| 2258 | } |
| 2259 | } |
| 2260 | |
| 2261 | /* |
| 2262 | * If scan failed, get default channel and advance state |
| 2263 | * machine as success with default channel |
| 2264 | * |
| 2265 | * Have to wait for the call back to be called to get the |
| 2266 | * channel cannot advance state machine here as said above |
| 2267 | */ |
| 2268 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2269 | FL("before exiting sap_goto_channel_sel channel=%d"), |
| 2270 | sap_context->channel); |
| 2271 | |
| 2272 | return CDF_STATUS_SUCCESS; |
| 2273 | } |
| 2274 | |
| 2275 | /*========================================================================== |
| 2276 | FUNCTION sap_OpenSession |
| 2277 | |
| 2278 | DESCRIPTION |
| 2279 | Function for opening SME and SAP sessions when system is in SoftAP role |
| 2280 | |
| 2281 | DEPENDENCIES |
| 2282 | NA. |
| 2283 | |
| 2284 | PARAMETERS |
| 2285 | |
| 2286 | IN |
| 2287 | hHal : Hal handle |
| 2288 | sapContext : Sap Context value |
| 2289 | |
| 2290 | RETURN VALUE |
| 2291 | The CDF_STATUS code associated with performing the operation |
| 2292 | |
| 2293 | CDF_STATUS_SUCCESS: Success |
| 2294 | |
| 2295 | SIDE EFFECTS |
| 2296 | ============================================================================*/ |
| 2297 | CDF_STATUS sap_open_session(tHalHandle hHal, ptSapContext sapContext) |
| 2298 | { |
| 2299 | uint32_t type, subType; |
| 2300 | CDF_STATUS cdf_ret_status; |
| 2301 | CDF_STATUS status = CDF_STATUS_E_FAILURE; |
| 2302 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 2303 | |
| 2304 | if (sapContext->csr_roamProfile.csrPersona == CDF_P2P_GO_MODE) |
| 2305 | status = cds_get_vdev_types(CDF_P2P_GO_MODE, &type, &subType); |
| 2306 | else |
| 2307 | status = cds_get_vdev_types(CDF_SAP_MODE, &type, &subType); |
| 2308 | |
| 2309 | if (CDF_STATUS_SUCCESS != status) { |
| 2310 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_FATAL, |
| 2311 | "failed to get vdev type"); |
| 2312 | return CDF_STATUS_E_FAILURE; |
| 2313 | } |
| 2314 | /* Open SME Session for Softap */ |
| 2315 | cdf_ret_status = sme_open_session(hHal, |
| 2316 | &wlansap_roam_callback, |
| 2317 | sapContext, |
| 2318 | sapContext->self_mac_addr, |
| 2319 | &sapContext->sessionId, type, subType); |
| 2320 | |
| 2321 | if (CDF_STATUS_SUCCESS != cdf_ret_status) { |
| 2322 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2323 | "Error: In %s calling sme_roam_connect status = %d", |
| 2324 | __func__, cdf_ret_status); |
| 2325 | |
| 2326 | return CDF_STATUS_E_FAILURE; |
| 2327 | } |
| 2328 | |
| 2329 | pMac->sap.sapCtxList[sapContext->sessionId].sessionID = |
| 2330 | sapContext->sessionId; |
| 2331 | pMac->sap.sapCtxList[sapContext->sessionId].pSapContext = sapContext; |
| 2332 | pMac->sap.sapCtxList[sapContext->sessionId].sapPersona = |
| 2333 | sapContext->csr_roamProfile.csrPersona; |
| 2334 | return CDF_STATUS_SUCCESS; |
| 2335 | } |
| 2336 | |
| 2337 | /*========================================================================== |
| 2338 | FUNCTION sapGotoStarting |
| 2339 | |
| 2340 | DESCRIPTION |
| 2341 | Function for initiating start bss request for SME |
| 2342 | |
| 2343 | DEPENDENCIES |
| 2344 | NA. |
| 2345 | |
| 2346 | PARAMETERS |
| 2347 | |
| 2348 | IN |
| 2349 | sapContext : Sap Context value |
| 2350 | sapEvent : State machine event |
| 2351 | bssType : Type of bss to start, INRA AP |
| 2352 | status : Return the SAP status here |
| 2353 | |
| 2354 | RETURN VALUE |
| 2355 | The CDF_STATUS code associated with performing the operation |
| 2356 | |
| 2357 | CDF_STATUS_SUCCESS: Success |
| 2358 | |
| 2359 | SIDE EFFECTS |
| 2360 | ============================================================================*/ |
| 2361 | CDF_STATUS |
| 2362 | sap_goto_starting |
| 2363 | (ptSapContext sapContext, |
| 2364 | ptWLAN_SAPEvent sapEvent, eCsrRoamBssType bssType) { |
| 2365 | /* tHalHandle */ |
| 2366 | tHalHandle hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 2367 | CDF_STATUS cdf_ret_status; |
| 2368 | |
| 2369 | /*- - - - - - - - TODO:once configs from hdd available - - - - - - - - -*/ |
| 2370 | char key_material[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, |
| 2371 | 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, }; |
| 2372 | sapContext->key_type = 0x05; |
| 2373 | sapContext->key_length = 32; |
| 2374 | cdf_mem_copy(sapContext->key_material, key_material, sizeof(key_material)); /* Need a key size define */ |
| 2375 | |
| 2376 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, "In %s", |
| 2377 | __func__); |
| 2378 | |
| 2379 | if (NULL == hHal) { |
| 2380 | /* we have a serious problem */ |
| 2381 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_FATAL, |
| 2382 | "In %s, invalid hHal", __func__); |
| 2383 | return CDF_STATUS_E_FAULT; |
| 2384 | } |
| 2385 | |
| 2386 | cdf_ret_status = sap_open_session(hHal, sapContext); |
| 2387 | |
| 2388 | if (CDF_STATUS_SUCCESS != cdf_ret_status) { |
| 2389 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2390 | "Error: In %s calling sap_open_session status = %d", |
| 2391 | __func__, cdf_ret_status); |
| 2392 | return CDF_STATUS_E_FAILURE; |
| 2393 | } |
| 2394 | |
| 2395 | return CDF_STATUS_SUCCESS; |
| 2396 | } /* sapGotoStarting */ |
| 2397 | |
| 2398 | /*========================================================================== |
| 2399 | FUNCTION sapGotoDisconnecting |
| 2400 | |
| 2401 | DESCRIPTION |
| 2402 | Processing of SAP FSM Disconnecting state |
| 2403 | |
| 2404 | DEPENDENCIES |
| 2405 | NA. |
| 2406 | |
| 2407 | PARAMETERS |
| 2408 | |
| 2409 | IN |
| 2410 | sapContext : Sap Context value |
| 2411 | status : Return the SAP status here |
| 2412 | |
| 2413 | RETURN VALUE |
| 2414 | The CDF_STATUS code associated with performing the operation |
| 2415 | |
| 2416 | CDF_STATUS_SUCCESS: Success |
| 2417 | |
| 2418 | SIDE EFFECTS |
| 2419 | ============================================================================*/ |
| 2420 | CDF_STATUS sap_goto_disconnecting(ptSapContext sapContext) |
| 2421 | { |
| 2422 | CDF_STATUS cdf_ret_status; |
| 2423 | tHalHandle hHal; |
| 2424 | |
| 2425 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 2426 | if (NULL == hHal) { |
| 2427 | /* we have a serious problem */ |
| 2428 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2429 | "In %s, invalid hHal", __func__); |
| 2430 | return CDF_STATUS_E_FAULT; |
| 2431 | } |
| 2432 | |
| 2433 | sap_free_roam_profile(&sapContext->csr_roamProfile); |
| 2434 | cdf_ret_status = sme_roam_stop_bss(hHal, sapContext->sessionId); |
| 2435 | if (CDF_STATUS_SUCCESS != cdf_ret_status) { |
| 2436 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2437 | "Error: In %s calling sme_roam_stop_bss status = %d", |
| 2438 | __func__, cdf_ret_status); |
| 2439 | return CDF_STATUS_E_FAILURE; |
| 2440 | } |
| 2441 | |
| 2442 | return CDF_STATUS_SUCCESS; |
| 2443 | } |
| 2444 | |
| 2445 | static CDF_STATUS sap_roam_session_close_callback(void *pContext) |
| 2446 | { |
| 2447 | ptSapContext sapContext = (ptSapContext) pContext; |
| 2448 | return sap_signal_hdd_event(sapContext, NULL, |
| 2449 | eSAP_STOP_BSS_EVENT, |
| 2450 | (void *) eSAP_STATUS_SUCCESS); |
| 2451 | } |
| 2452 | |
| 2453 | /*========================================================================== |
| 2454 | FUNCTION sapGotoDisconnected |
| 2455 | |
| 2456 | DESCRIPTION |
| 2457 | Function for setting the SAP FSM to Disconnection state |
| 2458 | |
| 2459 | DEPENDENCIES |
| 2460 | NA. |
| 2461 | |
| 2462 | PARAMETERS |
| 2463 | |
| 2464 | IN |
| 2465 | sapContext : Sap Context value |
| 2466 | sapEvent : State machine event |
| 2467 | status : Return the SAP status here |
| 2468 | |
| 2469 | RETURN VALUE |
| 2470 | The CDF_STATUS code associated with performing the operation |
| 2471 | |
| 2472 | CDF_STATUS_SUCCESS: Success |
| 2473 | |
| 2474 | SIDE EFFECTS |
| 2475 | ============================================================================*/ |
| 2476 | CDF_STATUS sap_goto_disconnected(ptSapContext sapContext) |
| 2477 | { |
| 2478 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 2479 | tWLAN_SAPEvent sapEvent; |
| 2480 | /* Processing has to be coded */ |
| 2481 | /* Clean up stations from TL etc as AP BSS is shut down then set event */ |
| 2482 | sapEvent.event = eSAP_MAC_READY_FOR_CONNECTIONS; /* hardcoded */ |
| 2483 | sapEvent.params = 0; |
| 2484 | sapEvent.u1 = 0; |
| 2485 | sapEvent.u2 = 0; |
| 2486 | /* Handle event */ |
| 2487 | cdf_status = sap_fsm(sapContext, &sapEvent); |
| 2488 | |
| 2489 | return cdf_status; |
| 2490 | } |
| 2491 | |
| 2492 | /** |
| 2493 | * sap_signal_hdd_event() - send event notification |
| 2494 | * @sap_ctx: Sap Context |
| 2495 | * @csr_roaminfo: Pointer to CSR roam information |
| 2496 | * @sap_hddevent: SAP HDD event |
| 2497 | * @context: to pass the element for future support |
| 2498 | * |
| 2499 | * Function for HDD to send the event notification using callback |
| 2500 | * |
| 2501 | * Return: CDF_STATUS |
| 2502 | */ |
| 2503 | CDF_STATUS sap_signal_hdd_event(ptSapContext sap_ctx, |
| 2504 | tCsrRoamInfo *csr_roaminfo, eSapHddEvent sap_hddevent, |
| 2505 | void *context) |
| 2506 | { |
| 2507 | CDF_STATUS cdf_status = CDF_STATUS_SUCCESS; |
| 2508 | tSap_Event sap_ap_event; /* This now encodes ALL event types */ |
| 2509 | tHalHandle hal = CDS_GET_HAL_CB(sap_ctx->p_cds_gctx); |
| 2510 | tpAniSirGlobal mac_ctx; |
| 2511 | tSirSmeChanInfo *chaninfo; |
| 2512 | tSap_StationAssocIndication *assoc_ind; |
| 2513 | tSap_StartBssCompleteEvent *bss_complete; |
| 2514 | struct sap_ch_selected_s *acs_selected; |
| 2515 | tSap_StationAssocReassocCompleteEvent *reassoc_complete; |
| 2516 | tSap_StationDisassocCompleteEvent *disassoc_comp; |
| 2517 | tSap_StationSetKeyCompleteEvent *key_complete; |
| 2518 | tSap_StationMICFailureEvent *mic_failure; |
| 2519 | tSap_ManagementFrameInfo *mgmt_frame; |
| 2520 | |
| 2521 | /* Format the Start BSS Complete event to return... */ |
| 2522 | if (NULL == sap_ctx->pfnSapEventCallback) { |
| 2523 | CDF_ASSERT(0); |
| 2524 | return CDF_STATUS_E_FAILURE; |
| 2525 | } |
| 2526 | if (NULL == hal) { |
| 2527 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2528 | FL("Invalid hal")); |
| 2529 | return CDF_STATUS_E_FAILURE; |
| 2530 | } |
| 2531 | mac_ctx = PMAC_STRUCT(hal); |
| 2532 | if (NULL == mac_ctx) { |
| 2533 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2534 | FL("Invalid MAC context")); |
| 2535 | return CDF_STATUS_E_FAILURE; |
| 2536 | } |
| 2537 | |
| 2538 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2539 | FL("SAP event callback event = %s"), |
| 2540 | sap_hdd_event_to_string(sap_hddevent)); |
| 2541 | |
| 2542 | switch (sap_hddevent) { |
| 2543 | case eSAP_STA_ASSOC_IND: |
| 2544 | /* TODO - Indicate the assoc request indication to OS */ |
| 2545 | sap_ap_event.sapHddEventCode = eSAP_STA_ASSOC_IND; |
| 2546 | assoc_ind = &sap_ap_event.sapevt.sapAssocIndication; |
| 2547 | |
| 2548 | cdf_copy_macaddr(&assoc_ind->staMac, &csr_roaminfo->peerMac); |
| 2549 | assoc_ind->staId = csr_roaminfo->staId; |
| 2550 | assoc_ind->status = 0; |
| 2551 | /* Required for indicating the frames to upper layer */ |
| 2552 | assoc_ind->beaconLength = csr_roaminfo->beaconLength; |
| 2553 | assoc_ind->beaconPtr = csr_roaminfo->beaconPtr; |
| 2554 | assoc_ind->assocReqLength = csr_roaminfo->assocReqLength; |
| 2555 | assoc_ind->assocReqPtr = csr_roaminfo->assocReqPtr; |
| 2556 | assoc_ind->fWmmEnabled = csr_roaminfo->wmmEnabledSta; |
| 2557 | if (csr_roaminfo->u.pConnectedProfile != NULL) { |
| 2558 | assoc_ind->negotiatedAuthType = |
| 2559 | csr_roaminfo->u.pConnectedProfile->AuthType; |
| 2560 | assoc_ind->negotiatedUCEncryptionType = |
| 2561 | csr_roaminfo->u.pConnectedProfile->EncryptionType; |
| 2562 | assoc_ind->negotiatedMCEncryptionType = |
| 2563 | csr_roaminfo->u.pConnectedProfile->mcEncryptionType; |
| 2564 | assoc_ind->fAuthRequired = csr_roaminfo->fAuthRequired; |
| 2565 | } |
| 2566 | break; |
| 2567 | case eSAP_START_BSS_EVENT: |
| 2568 | sap_ap_event.sapHddEventCode = eSAP_START_BSS_EVENT; |
| 2569 | bss_complete = &sap_ap_event.sapevt.sapStartBssCompleteEvent; |
| 2570 | |
| 2571 | bss_complete->status = (eSapStatus) context; |
| 2572 | if (csr_roaminfo != NULL) |
| 2573 | bss_complete->staId = csr_roaminfo->staId; |
| 2574 | else |
| 2575 | bss_complete->staId = 0; |
| 2576 | |
| 2577 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 2578 | FL("(eSAP_START_BSS_EVENT): staId = %d"), |
| 2579 | bss_complete->staId); |
| 2580 | |
| 2581 | bss_complete->operatingChannel = (uint8_t) sap_ctx->channel; |
| 2582 | bss_complete->sessionId = sap_ctx->sessionId; |
| 2583 | break; |
| 2584 | case eSAP_DFS_CAC_START: |
| 2585 | case eSAP_DFS_CAC_INTERRUPTED: |
| 2586 | case eSAP_DFS_CAC_END: |
| 2587 | case eSAP_DFS_RADAR_DETECT: |
| 2588 | case eSAP_DFS_NO_AVAILABLE_CHANNEL: |
| 2589 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 2590 | case eSAP_ACS_SCAN_SUCCESS_EVENT: |
| 2591 | #endif |
| 2592 | sap_ap_event.sapHddEventCode = sap_hddevent; |
| 2593 | sap_ap_event.sapevt.sapStopBssCompleteEvent.status = |
| 2594 | (eSapStatus) context; |
| 2595 | break; |
| 2596 | |
| 2597 | case eSAP_ACS_CHANNEL_SELECTED: |
| 2598 | sap_ap_event.sapHddEventCode = sap_hddevent; |
| 2599 | acs_selected = &sap_ap_event.sapevt.sap_ch_selected; |
| 2600 | if (eSAP_STATUS_SUCCESS == (eSapStatus)context) { |
| 2601 | acs_selected->pri_ch = sap_ctx->acs_cfg->pri_ch; |
| 2602 | acs_selected->ht_sec_ch = sap_ctx->acs_cfg->ht_sec_ch; |
| 2603 | acs_selected->ch_width = sap_ctx->acs_cfg->ch_width; |
| 2604 | acs_selected->vht_seg0_center_ch = |
| 2605 | sap_ctx->acs_cfg->vht_seg0_center_ch; |
| 2606 | acs_selected->vht_seg1_center_ch = |
| 2607 | sap_ctx->acs_cfg->vht_seg1_center_ch; |
| 2608 | } else if (eSAP_STATUS_FAILURE == (eSapStatus)context) { |
| 2609 | acs_selected->pri_ch = 0; |
| 2610 | } |
| 2611 | break; |
| 2612 | |
| 2613 | case eSAP_STOP_BSS_EVENT: |
| 2614 | sap_ap_event.sapHddEventCode = eSAP_STOP_BSS_EVENT; |
| 2615 | sap_ap_event.sapevt.sapStopBssCompleteEvent.status = |
| 2616 | (eSapStatus) context; |
| 2617 | break; |
| 2618 | |
| 2619 | case eSAP_STA_ASSOC_EVENT: |
| 2620 | case eSAP_STA_REASSOC_EVENT: |
| 2621 | reassoc_complete = |
| 2622 | &sap_ap_event.sapevt.sapStationAssocReassocCompleteEvent; |
| 2623 | |
| 2624 | if (csr_roaminfo->fReassocReq) |
| 2625 | sap_ap_event.sapHddEventCode = eSAP_STA_REASSOC_EVENT; |
| 2626 | else |
| 2627 | sap_ap_event.sapHddEventCode = eSAP_STA_ASSOC_EVENT; |
| 2628 | |
| 2629 | cdf_copy_macaddr(&reassoc_complete->staMac, |
| 2630 | &csr_roaminfo->peerMac); |
| 2631 | reassoc_complete->staId = csr_roaminfo->staId; |
| 2632 | reassoc_complete->statusCode = csr_roaminfo->statusCode; |
| 2633 | reassoc_complete->iesLen = csr_roaminfo->rsnIELen; |
| 2634 | cdf_mem_copy(reassoc_complete->ies, csr_roaminfo->prsnIE, |
| 2635 | csr_roaminfo->rsnIELen); |
| 2636 | |
| 2637 | #ifdef FEATURE_WLAN_WAPI |
| 2638 | if (csr_roaminfo->wapiIELen) { |
| 2639 | uint8_t len = reassoc_complete->iesLen; |
| 2640 | reassoc_complete->iesLen += csr_roaminfo->wapiIELen; |
| 2641 | cdf_mem_copy(&reassoc_complete->ies[len], |
| 2642 | csr_roaminfo->pwapiIE, |
| 2643 | csr_roaminfo->wapiIELen); |
| 2644 | } |
| 2645 | #endif |
| 2646 | if (csr_roaminfo->addIELen) { |
| 2647 | uint8_t len = reassoc_complete->iesLen; |
| 2648 | reassoc_complete->iesLen += csr_roaminfo->addIELen; |
| 2649 | cdf_mem_copy(&reassoc_complete->ies[len], |
| 2650 | csr_roaminfo->paddIE, |
| 2651 | csr_roaminfo->addIELen); |
| 2652 | } |
| 2653 | |
| 2654 | /* also fill up the channel info from the csr_roamInfo */ |
| 2655 | chaninfo = &reassoc_complete->chan_info; |
| 2656 | |
| 2657 | chaninfo->chan_id = csr_roaminfo->chan_info.chan_id; |
| 2658 | chaninfo->mhz = csr_roaminfo->chan_info.mhz; |
| 2659 | chaninfo->info = csr_roaminfo->chan_info.info; |
| 2660 | chaninfo->band_center_freq1 = |
| 2661 | csr_roaminfo->chan_info.band_center_freq1; |
| 2662 | chaninfo->band_center_freq2 = |
| 2663 | csr_roaminfo->chan_info.band_center_freq2; |
| 2664 | chaninfo->reg_info_1 = |
| 2665 | csr_roaminfo->chan_info.reg_info_1; |
| 2666 | chaninfo->reg_info_2 = |
| 2667 | csr_roaminfo->chan_info.reg_info_2; |
| 2668 | |
| 2669 | reassoc_complete->wmmEnabled = csr_roaminfo->wmmEnabledSta; |
| 2670 | reassoc_complete->status = (eSapStatus) context; |
| 2671 | reassoc_complete->timingMeasCap = csr_roaminfo->timingMeasCap; |
| 2672 | break; |
| 2673 | |
| 2674 | case eSAP_STA_DISASSOC_EVENT: |
| 2675 | sap_ap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT; |
| 2676 | disassoc_comp = |
| 2677 | &sap_ap_event.sapevt.sapStationDisassocCompleteEvent; |
| 2678 | |
| 2679 | cdf_copy_macaddr(&disassoc_comp->staMac, |
| 2680 | &csr_roaminfo->peerMac); |
| 2681 | disassoc_comp->staId = csr_roaminfo->staId; |
| 2682 | if (csr_roaminfo->reasonCode == eCSR_ROAM_RESULT_FORCED) |
| 2683 | disassoc_comp->reason = eSAP_USR_INITATED_DISASSOC; |
| 2684 | else |
| 2685 | disassoc_comp->reason = eSAP_MAC_INITATED_DISASSOC; |
| 2686 | |
| 2687 | disassoc_comp->statusCode = csr_roaminfo->statusCode; |
| 2688 | disassoc_comp->status = (eSapStatus) context; |
| 2689 | break; |
| 2690 | |
| 2691 | case eSAP_STA_SET_KEY_EVENT: |
| 2692 | sap_ap_event.sapHddEventCode = eSAP_STA_SET_KEY_EVENT; |
| 2693 | key_complete = |
| 2694 | &sap_ap_event.sapevt.sapStationSetKeyCompleteEvent; |
| 2695 | key_complete->status = (eSapStatus) context; |
| 2696 | cdf_copy_macaddr(&key_complete->peerMacAddr, |
| 2697 | &csr_roaminfo->peerMac); |
| 2698 | break; |
| 2699 | |
| 2700 | case eSAP_STA_MIC_FAILURE_EVENT: |
| 2701 | sap_ap_event.sapHddEventCode = eSAP_STA_MIC_FAILURE_EVENT; |
| 2702 | mic_failure = &sap_ap_event.sapevt.sapStationMICFailureEvent; |
| 2703 | |
| 2704 | cdf_mem_copy(&mic_failure->srcMacAddr, |
| 2705 | csr_roaminfo->u.pMICFailureInfo->srcMacAddr, |
| 2706 | sizeof(tSirMacAddr)); |
| 2707 | cdf_mem_copy(&mic_failure->staMac.bytes, |
| 2708 | csr_roaminfo->u.pMICFailureInfo->taMacAddr, |
| 2709 | sizeof(tSirMacAddr)); |
| 2710 | cdf_mem_copy(&mic_failure->dstMacAddr.bytes, |
| 2711 | csr_roaminfo->u.pMICFailureInfo->dstMacAddr, |
| 2712 | sizeof(tSirMacAddr)); |
| 2713 | mic_failure->multicast = |
| 2714 | csr_roaminfo->u.pMICFailureInfo->multicast; |
| 2715 | mic_failure->IV1 = csr_roaminfo->u.pMICFailureInfo->IV1; |
| 2716 | mic_failure->keyId = csr_roaminfo->u.pMICFailureInfo->keyId; |
| 2717 | cdf_mem_copy(mic_failure->TSC, |
| 2718 | csr_roaminfo->u.pMICFailureInfo->TSC, |
| 2719 | SIR_CIPHER_SEQ_CTR_SIZE); |
| 2720 | break; |
| 2721 | |
| 2722 | case eSAP_ASSOC_STA_CALLBACK_EVENT: |
| 2723 | break; |
| 2724 | |
| 2725 | case eSAP_WPS_PBC_PROBE_REQ_EVENT: |
| 2726 | sap_ap_event.sapHddEventCode = eSAP_WPS_PBC_PROBE_REQ_EVENT; |
| 2727 | |
| 2728 | cdf_mem_copy(&sap_ap_event.sapevt.sapPBCProbeReqEvent. |
| 2729 | WPSPBCProbeReq, csr_roaminfo->u.pWPSPBCProbeReq, |
| 2730 | sizeof(tSirWPSPBCProbeReq)); |
| 2731 | break; |
| 2732 | |
| 2733 | case eSAP_INDICATE_MGMT_FRAME: |
| 2734 | sap_ap_event.sapHddEventCode = eSAP_INDICATE_MGMT_FRAME; |
| 2735 | mgmt_frame = &sap_ap_event.sapevt.sapManagementFrameInfo; |
| 2736 | |
| 2737 | mgmt_frame->nFrameLength = csr_roaminfo->nFrameLength; |
| 2738 | mgmt_frame->pbFrames = csr_roaminfo->pbFrames; |
| 2739 | mgmt_frame->frameType = csr_roaminfo->frameType; |
| 2740 | mgmt_frame->rxChan = csr_roaminfo->rxChan; |
| 2741 | break; |
| 2742 | |
| 2743 | case eSAP_REMAIN_CHAN_READY: |
| 2744 | sap_ap_event.sapHddEventCode = eSAP_REMAIN_CHAN_READY; |
| 2745 | sap_ap_event.sapevt.sap_roc_ind.scan_id = |
| 2746 | sap_ctx->roc_ind_scan_id; |
| 2747 | break; |
| 2748 | case eSAP_SEND_ACTION_CNF: |
| 2749 | sap_ap_event.sapHddEventCode = eSAP_SEND_ACTION_CNF; |
| 2750 | sap_ap_event.sapevt.sapActionCnf.actionSendSuccess = |
| 2751 | (eSapStatus) context; |
| 2752 | break; |
| 2753 | |
| 2754 | case eSAP_DISCONNECT_ALL_P2P_CLIENT: |
| 2755 | sap_ap_event.sapHddEventCode = eSAP_DISCONNECT_ALL_P2P_CLIENT; |
| 2756 | sap_ap_event.sapevt.sapActionCnf.actionSendSuccess = |
| 2757 | (eSapStatus) context; |
| 2758 | break; |
| 2759 | |
| 2760 | case eSAP_MAC_TRIG_STOP_BSS_EVENT: |
| 2761 | sap_ap_event.sapHddEventCode = eSAP_MAC_TRIG_STOP_BSS_EVENT; |
| 2762 | sap_ap_event.sapevt.sapActionCnf.actionSendSuccess = |
| 2763 | (eSapStatus) context; |
| 2764 | break; |
| 2765 | |
| 2766 | case eSAP_UNKNOWN_STA_JOIN: |
| 2767 | sap_ap_event.sapHddEventCode = eSAP_UNKNOWN_STA_JOIN; |
| 2768 | cdf_mem_copy((void *) sap_ap_event.sapevt.sapUnknownSTAJoin. |
| 2769 | macaddr.bytes, (void *) context, |
| 2770 | CDF_MAC_ADDR_SIZE); |
| 2771 | break; |
| 2772 | |
| 2773 | case eSAP_MAX_ASSOC_EXCEEDED: |
| 2774 | sap_ap_event.sapHddEventCode = eSAP_MAX_ASSOC_EXCEEDED; |
| 2775 | cdf_copy_macaddr(&sap_ap_event.sapevt. |
| 2776 | sapMaxAssocExceeded.macaddr, |
| 2777 | &csr_roaminfo->peerMac); |
| 2778 | break; |
| 2779 | |
| 2780 | case eSAP_CHANNEL_CHANGE_EVENT: |
| 2781 | /* |
| 2782 | * Reconfig ACS result info. For DFS AP-AP Mode Sec AP ACS |
| 2783 | * follows pri AP |
| 2784 | */ |
| 2785 | sap_ctx->acs_cfg->pri_ch = sap_ctx->channel; |
| 2786 | sap_ctx->acs_cfg->ch_width = sap_ctx->ch_params.ch_width; |
| 2787 | sap_config_acs_result(hal, sap_ctx, sap_ctx->secondary_ch); |
| 2788 | |
| 2789 | sap_ap_event.sapHddEventCode = eSAP_CHANNEL_CHANGE_EVENT; |
| 2790 | |
| 2791 | acs_selected = &sap_ap_event.sapevt.sap_ch_selected; |
| 2792 | acs_selected->pri_ch = sap_ctx->acs_cfg->pri_ch; |
| 2793 | acs_selected->ht_sec_ch = sap_ctx->acs_cfg->ht_sec_ch; |
| 2794 | acs_selected->ch_width = sap_ctx->acs_cfg->ch_width; |
| 2795 | acs_selected->vht_seg0_center_ch = |
| 2796 | sap_ctx->acs_cfg->vht_seg0_center_ch; |
| 2797 | acs_selected->vht_seg1_center_ch = |
| 2798 | sap_ctx->acs_cfg->vht_seg1_center_ch; |
| 2799 | break; |
| 2800 | |
| 2801 | case eSAP_DFS_NOL_GET: |
| 2802 | sap_ap_event.sapHddEventCode = eSAP_DFS_NOL_GET; |
| 2803 | sap_ap_event.sapevt.sapDfsNolInfo.sDfsList = |
| 2804 | NUM_5GHZ_CHANNELS * sizeof(tSapDfsNolInfo); |
| 2805 | sap_ap_event.sapevt.sapDfsNolInfo.pDfsList = (void *) |
| 2806 | (&mac_ctx->sap.SapDfsInfo.sapDfsChannelNolList[0]); |
| 2807 | break; |
| 2808 | |
| 2809 | case eSAP_DFS_NOL_SET: |
| 2810 | sap_ap_event.sapHddEventCode = eSAP_DFS_NOL_SET; |
| 2811 | sap_ap_event.sapevt.sapDfsNolInfo.sDfsList = |
| 2812 | mac_ctx->sap.SapDfsInfo.numCurrentRegDomainDfsChannels * |
| 2813 | sizeof(tSapDfsNolInfo); |
| 2814 | sap_ap_event.sapevt.sapDfsNolInfo.pDfsList = (void *) |
| 2815 | (&mac_ctx->sap.SapDfsInfo.sapDfsChannelNolList[0]); |
| 2816 | break; |
| 2817 | |
| 2818 | default: |
| 2819 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 2820 | FL("SAP Unknown callback event = %d"), |
| 2821 | sap_hddevent); |
| 2822 | break; |
| 2823 | } |
| 2824 | cdf_status = (*sap_ctx->pfnSapEventCallback) |
| 2825 | (&sap_ap_event, sap_ctx->pUsrContext); |
| 2826 | |
| 2827 | return cdf_status; |
| 2828 | |
| 2829 | } |
| 2830 | |
| 2831 | /*========================================================================== |
| 2832 | FUNCTION sap_find_valid_concurrent_session |
| 2833 | |
| 2834 | DESCRIPTION |
| 2835 | This function will return sapcontext of any valid sap session. |
| 2836 | |
| 2837 | PARAMETERS |
| 2838 | |
| 2839 | IN |
| 2840 | hHal : HAL pointer |
| 2841 | |
| 2842 | RETURN VALUE |
| 2843 | ptSapContext : valid sap context |
| 2844 | |
| 2845 | SIDE EFFECTS |
| 2846 | NA |
| 2847 | ============================================================================*/ |
| 2848 | ptSapContext sap_find_valid_concurrent_session(tHalHandle hHal) |
| 2849 | { |
| 2850 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 2851 | uint8_t intf = 0; |
| 2852 | |
| 2853 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 2854 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 2855 | || |
| 2856 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) && |
| 2857 | pMac->sap.sapCtxList[intf].pSapContext != NULL) { |
| 2858 | return pMac->sap.sapCtxList[intf].pSapContext; |
| 2859 | } |
| 2860 | } |
| 2861 | |
| 2862 | return NULL; |
| 2863 | } |
| 2864 | |
| 2865 | /*========================================================================== |
| 2866 | FUNCTION sap_close_session |
| 2867 | |
| 2868 | DESCRIPTION |
| 2869 | This function will close all the sme sessions as well as zero-out the |
| 2870 | sap global structure |
| 2871 | |
| 2872 | PARAMETERS |
| 2873 | |
| 2874 | IN |
| 2875 | hHal : HAL pointer |
| 2876 | sapContext : Sap Context value |
| 2877 | callback : Roam Session close callback |
| 2878 | valid : Sap context is valid or no |
| 2879 | |
| 2880 | RETURN VALUE |
| 2881 | The CDF_STATUS code associated with performing the operation |
| 2882 | CDF_STATUS_SUCCESS: Success |
| 2883 | |
| 2884 | SIDE EFFECTS |
| 2885 | NA |
| 2886 | ============================================================================*/ |
| 2887 | CDF_STATUS sap_close_session(tHalHandle hHal, |
| 2888 | ptSapContext sapContext, |
| 2889 | csr_roamSessionCloseCallback callback, bool valid) |
| 2890 | { |
| 2891 | CDF_STATUS cdf_status; |
| 2892 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 2893 | |
| 2894 | if (false == valid) { |
| 2895 | cdf_status = sme_close_session(hHal, |
| 2896 | sapContext->sessionId, |
| 2897 | callback, NULL); |
| 2898 | } else { |
| 2899 | cdf_status = sme_close_session(hHal, |
| 2900 | sapContext->sessionId, |
| 2901 | callback, sapContext); |
| 2902 | } |
| 2903 | |
| 2904 | sapContext->isCacStartNotified = false; |
| 2905 | sapContext->isCacEndNotified = false; |
| 2906 | pMac->sap.sapCtxList[sapContext->sessionId].pSapContext = NULL; |
| 2907 | |
| 2908 | if (NULL == sap_find_valid_concurrent_session(hHal)) { |
| 2909 | /* If timer is running then stop the timer and destory it */ |
| 2910 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 2911 | "sapdfs: no session are valid, so clearing dfs global structure"); |
| 2912 | /* |
| 2913 | * CAC timer will be initiated and started only when SAP starts |
| 2914 | * on DFS channel and it will be stopped and destroyed |
| 2915 | * immediately once the radar detected or timedout. So |
| 2916 | * as per design CAC timer should be destroyed after stop |
| 2917 | */ |
| 2918 | if (pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) { |
| 2919 | cdf_mc_timer_stop(&pMac->sap.SapDfsInfo. |
| 2920 | sap_dfs_cac_timer); |
| 2921 | pMac->sap.SapDfsInfo.is_dfs_cac_timer_running = 0; |
| 2922 | cdf_mc_timer_destroy( |
| 2923 | &pMac->sap.SapDfsInfo.sap_dfs_cac_timer); |
| 2924 | } |
| 2925 | pMac->sap.SapDfsInfo.cac_state = eSAP_DFS_DO_NOT_SKIP_CAC; |
| 2926 | sap_cac_reset_notify(hHal); |
| 2927 | cdf_mem_zero(&pMac->sap, sizeof(pMac->sap)); |
| 2928 | } |
| 2929 | |
| 2930 | return cdf_status; |
| 2931 | } |
| 2932 | |
| 2933 | /*========================================================================== |
| 2934 | FUNCTION sap_cac_reset_notify |
| 2935 | |
| 2936 | DESCRIPTION Function will be called up on stop bss indication to clean up |
| 2937 | DFS global structure. |
| 2938 | |
| 2939 | DEPENDENCIES PARAMETERS |
| 2940 | IN hHAL : HAL pointer |
| 2941 | |
| 2942 | RETURN VALUE : void. |
| 2943 | |
| 2944 | SIDE EFFECTS |
| 2945 | ============================================================================*/ |
| 2946 | void sap_cac_reset_notify(tHalHandle hHal) |
| 2947 | { |
| 2948 | uint8_t intf = 0; |
| 2949 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 2950 | |
| 2951 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 2952 | ptSapContext pSapContext = |
| 2953 | (ptSapContext) pMac->sap.sapCtxList[intf].pSapContext; |
| 2954 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 2955 | || |
| 2956 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) |
| 2957 | && pMac->sap.sapCtxList[intf].pSapContext != NULL) { |
| 2958 | pSapContext->isCacStartNotified = false; |
| 2959 | pSapContext->isCacEndNotified = false; |
| 2960 | } |
| 2961 | } |
| 2962 | } |
| 2963 | |
| 2964 | /*========================================================================== |
| 2965 | FUNCTION sap_cac_start_notify |
| 2966 | |
| 2967 | DESCRIPTION Function will be called to notify eSAP_DFS_CAC_START event |
| 2968 | to HDD |
| 2969 | |
| 2970 | DEPENDENCIES PARAMETERS |
| 2971 | IN hHAL : HAL pointer |
| 2972 | |
| 2973 | RETURN VALUE : CDF_STATUS. |
| 2974 | |
| 2975 | SIDE EFFECTS |
| 2976 | ============================================================================*/ |
| 2977 | CDF_STATUS sap_cac_start_notify(tHalHandle hHal) |
| 2978 | { |
| 2979 | uint8_t intf = 0; |
| 2980 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 2981 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 2982 | |
| 2983 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 2984 | ptSapContext pSapContext = |
| 2985 | (ptSapContext) pMac->sap.sapCtxList[intf].pSapContext; |
| 2986 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 2987 | || |
| 2988 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) |
| 2989 | && pMac->sap.sapCtxList[intf].pSapContext != NULL && |
| 2990 | (false == pSapContext->isCacStartNotified)) { |
| 2991 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 2992 | "sapdfs: Signaling eSAP_DFS_CAC_START to HDD for sapctx[%p]", |
| 2993 | pSapContext); |
| 2994 | |
| 2995 | cdf_status = sap_signal_hdd_event(pSapContext, NULL, |
| 2996 | eSAP_DFS_CAC_START, |
| 2997 | (void *) |
| 2998 | eSAP_STATUS_SUCCESS); |
| 2999 | if (CDF_STATUS_SUCCESS != cdf_status) { |
| 3000 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3001 | CDF_TRACE_LEVEL_ERROR, |
| 3002 | "In %s, failed setting isCacStartNotified on interface[%d]", |
| 3003 | __func__, intf); |
| 3004 | return cdf_status; |
| 3005 | } |
| 3006 | pSapContext->isCacStartNotified = true; |
| 3007 | } |
| 3008 | } |
| 3009 | return cdf_status; |
| 3010 | } |
| 3011 | |
| 3012 | /*========================================================================== |
| 3013 | FUNCTION sap_cac_end_notify |
| 3014 | |
| 3015 | DESCRIPTION Function will be called to notify eSAP_DFS_CAC_END event |
| 3016 | to HDD |
| 3017 | |
| 3018 | DEPENDENCIES PARAMETERS |
| 3019 | IN hHAL : HAL pointer |
| 3020 | |
| 3021 | RETURN VALUE : CDF_STATUS. |
| 3022 | |
| 3023 | SIDE EFFECTS |
| 3024 | ============================================================================*/ |
| 3025 | CDF_STATUS sap_cac_end_notify(tHalHandle hHal, tCsrRoamInfo *roamInfo) |
| 3026 | { |
| 3027 | uint8_t intf; |
| 3028 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 3029 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3030 | |
| 3031 | /* |
| 3032 | * eSAP_DFS_CHANNEL_CAC_END: |
| 3033 | * CAC Period elapsed and there was no radar |
| 3034 | * found so, SAP can continue beaconing. |
| 3035 | * sap_radar_found_status is set to 0 |
| 3036 | */ |
| 3037 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 3038 | ptSapContext pSapContext = |
| 3039 | (ptSapContext) pMac->sap.sapCtxList[intf].pSapContext; |
| 3040 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 3041 | || |
| 3042 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) |
| 3043 | && pMac->sap.sapCtxList[intf].pSapContext != NULL && |
| 3044 | (false == pSapContext->isCacEndNotified)) { |
| 3045 | pSapContext = pMac->sap.sapCtxList[intf].pSapContext; |
| 3046 | cdf_status = sap_signal_hdd_event(pSapContext, NULL, |
| 3047 | eSAP_DFS_CAC_END, |
| 3048 | (void *) |
| 3049 | eSAP_STATUS_SUCCESS); |
| 3050 | if (CDF_STATUS_SUCCESS != cdf_status) { |
| 3051 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3052 | CDF_TRACE_LEVEL_ERROR, |
| 3053 | "In %s, failed setting isCacEndNotified on interface[%d]", |
| 3054 | __func__, intf); |
| 3055 | return cdf_status; |
| 3056 | } |
| 3057 | pSapContext->isCacEndNotified = true; |
| 3058 | pMac->sap.SapDfsInfo.sap_radar_found_status = false; |
| 3059 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 3060 | "sapdfs: Start beacon request on sapctx[%p]", |
| 3061 | pSapContext); |
| 3062 | |
| 3063 | /* Start beaconing on the new channel */ |
| 3064 | wlansap_start_beacon_req(pSapContext); |
| 3065 | |
| 3066 | /* Transition from eSAP_STARTING to eSAP_STARTED |
| 3067 | * (both without substates) |
| 3068 | */ |
| 3069 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 3070 | "sapdfs: channel[%d] from state %s => %s", |
| 3071 | pSapContext->channel, "eSAP_STARTING", |
| 3072 | "eSAP_STARTED"); |
| 3073 | |
| 3074 | pSapContext->sapsMachine = eSAP_STARTED; |
| 3075 | |
| 3076 | /*Action code for transition */ |
| 3077 | cdf_status = sap_signal_hdd_event(pSapContext, roamInfo, |
| 3078 | eSAP_START_BSS_EVENT, |
| 3079 | (void *) |
| 3080 | eSAP_STATUS_SUCCESS); |
| 3081 | if (CDF_STATUS_SUCCESS != cdf_status) { |
| 3082 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3083 | CDF_TRACE_LEVEL_ERROR, |
| 3084 | "In %s, failed setting isCacEndNotified on interface[%d]", |
| 3085 | __func__, intf); |
| 3086 | return cdf_status; |
| 3087 | } |
| 3088 | |
| 3089 | /* Transition from eSAP_STARTING to eSAP_STARTED |
| 3090 | * (both without substates) |
| 3091 | */ |
| 3092 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3093 | "In %s, from state %s => %s", |
| 3094 | __func__, "eSAP_DFS_CAC_WAIT", |
| 3095 | "eSAP_STARTED"); |
| 3096 | } |
| 3097 | } |
| 3098 | /* |
| 3099 | * All APs are done with CAC timer, all APs should start beaconing. |
| 3100 | * Lets assume AP1 and AP2 started beaconing on DFS channel, Now lets |
| 3101 | * say AP1 goes down and comes back on same DFS channel. In this case |
| 3102 | * AP1 shouldn't start CAC timer and start beacon immediately beacause |
| 3103 | * AP2 is already beaconing on this channel. This case will be handled |
| 3104 | * by checking against eSAP_DFS_SKIP_CAC while starting the timer. |
| 3105 | */ |
| 3106 | pMac->sap.SapDfsInfo.cac_state = eSAP_DFS_SKIP_CAC; |
| 3107 | return cdf_status; |
| 3108 | } |
| 3109 | |
| 3110 | /** |
| 3111 | * sap_fsm_state_disconnected() - utility function called from sap fsm |
| 3112 | * @sap_ctx: SAP context |
| 3113 | * @sap_event: SAP event buffer |
| 3114 | * @mac_ctx: global MAC context |
| 3115 | * @hal: HAL handle |
| 3116 | * |
| 3117 | * This function is called for state transition from "eSAP_DISCONNECTED" |
| 3118 | * |
| 3119 | * Return: CDF_STATUS |
| 3120 | */ |
| 3121 | static CDF_STATUS sap_fsm_state_disconnected(ptSapContext sap_ctx, |
| 3122 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx, |
| 3123 | tHalHandle hal) |
| 3124 | { |
| 3125 | uint32_t msg = sap_event->event; |
| 3126 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3127 | |
| 3128 | if (msg == eSAP_HDD_START_INFRA_BSS) { |
| 3129 | /* |
| 3130 | * Transition from eSAP_DISCONNECTED to eSAP_CH_SELECT |
| 3131 | * (both without substates) |
| 3132 | */ |
| 3133 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3134 | FL("new from state %s => %s"), |
| 3135 | "eSAP_DISCONNECTED", "eSAP_CH_SELECT"); |
| 3136 | |
| 3137 | /* There can be one SAP Session for softap */ |
| 3138 | if (sap_ctx->isSapSessionOpen == eSAP_TRUE) { |
| 3139 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_FATAL, |
| 3140 | FL("SME Session is already opened")); |
| 3141 | return CDF_STATUS_E_EXISTS; |
| 3142 | } |
| 3143 | |
| 3144 | sap_ctx->sessionId = 0xff; |
| 3145 | |
| 3146 | if ((sap_ctx->channel == AUTO_CHANNEL_SELECT) && |
| 3147 | (sap_ctx->isScanSessionOpen == eSAP_FALSE)) { |
| 3148 | uint32_t type, subtype; |
| 3149 | if (CDF_STATUS_SUCCESS == cds_get_vdev_types( |
| 3150 | CDF_STA_MODE, &type, &subtype)) { |
| 3151 | /* Open SME Session for scan */ |
| 3152 | cdf_status = sme_open_session(hal, NULL, |
| 3153 | sap_ctx, sap_ctx->self_mac_addr, |
| 3154 | &sap_ctx->sessionId, type, subtype); |
| 3155 | if (CDF_STATUS_SUCCESS != cdf_status) { |
| 3156 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3157 | CDF_TRACE_LEVEL_ERROR, |
| 3158 | FL("Error: calling sme_open_session")); |
| 3159 | } else { |
| 3160 | sap_ctx->isScanSessionOpen = eSAP_TRUE; |
| 3161 | } |
| 3162 | } |
| 3163 | } |
| 3164 | /* init dfs channel nol */ |
| 3165 | sap_init_dfs_channel_nol_list(sap_ctx); |
| 3166 | |
| 3167 | /* Set SAP device role */ |
| 3168 | sap_ctx->sapsMachine = eSAP_CH_SELECT; |
| 3169 | |
| 3170 | /* |
| 3171 | * Perform sme_ScanRequest. This scan request is post start bss |
| 3172 | * request so, set the third to false. |
| 3173 | */ |
| 3174 | cdf_status = sap_goto_channel_sel(sap_ctx, sap_event, false); |
| 3175 | |
| 3176 | /* |
| 3177 | * Transition from eSAP_DISCONNECTED to eSAP_CH_SELECT |
| 3178 | * (both without substates) |
| 3179 | */ |
| 3180 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3181 | FL("from state %s => %s"), |
| 3182 | "eSAP_DISCONNECTED", "eSAP_CH_SELECT"); |
| 3183 | } else if (msg == eSAP_DFS_CHANNEL_CAC_START) { |
| 3184 | /* |
| 3185 | * No need of state check here, caller is expected to perform |
| 3186 | * the checks before sending the event |
| 3187 | */ |
| 3188 | sap_ctx->sapsMachine = eSAP_DFS_CAC_WAIT; |
| 3189 | |
| 3190 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 3191 | FL("from state eSAP_DISCONNECTED => SAP_DFS_CAC_WAIT")); |
| 3192 | if (mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running != true) { |
| 3193 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 3194 | FL("sapdfs: starting dfs cac timer on sapctx[%p]"), |
| 3195 | sap_ctx); |
| 3196 | sap_start_dfs_cac_timer(sap_ctx); |
| 3197 | } |
| 3198 | |
| 3199 | cdf_status = sap_cac_start_notify(hal); |
| 3200 | } else if (msg == eSAP_CHANNEL_SELECTION_RETRY) { |
| 3201 | /* Set SAP device role */ |
| 3202 | sap_ctx->sapsMachine = eSAP_CH_SELECT; |
| 3203 | |
| 3204 | /* |
| 3205 | * Perform sme_ScanRequest. This scan request is post start bss |
| 3206 | * request so, set the third to false. |
| 3207 | */ |
| 3208 | cdf_status = sap_goto_channel_sel(sap_ctx, sap_event, false); |
| 3209 | } else { |
| 3210 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3211 | FL("in state %s, event msg %d"), |
| 3212 | "eSAP_DISCONNECTED", msg); |
| 3213 | } |
| 3214 | |
| 3215 | return cdf_status; |
| 3216 | } |
| 3217 | |
| 3218 | /** |
| 3219 | * sap_fsm_state_ch_select() - utility function called from sap fsm |
| 3220 | * @sap_ctx: SAP context |
| 3221 | * @sap_event: SAP event buffer |
| 3222 | * @mac_ctx: global MAC context |
| 3223 | * @hal: HAL handle |
| 3224 | * |
| 3225 | * This function is called for state transition from "eSAP_CH_SELECT" |
| 3226 | * |
| 3227 | * Return: CDF_STATUS |
| 3228 | */ |
| 3229 | static CDF_STATUS sap_fsm_state_ch_select(ptSapContext sap_ctx, |
| 3230 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx, |
| 3231 | tHalHandle hal) |
| 3232 | { |
| 3233 | uint32_t msg = sap_event->event; |
| 3234 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3235 | uint32_t cbmode; |
| 3236 | bool b_leak_chan = false; |
| 3237 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 3238 | uint8_t temp_chan; |
| 3239 | tSapDfsNolInfo *p_nol; |
| 3240 | #endif |
| 3241 | |
| 3242 | if (sap_ctx->isScanSessionOpen == eSAP_TRUE) { |
| 3243 | /* scan completed, so close the session */ |
| 3244 | cdf_status = sme_close_session(hal, sap_ctx->sessionId, |
| 3245 | NULL, NULL); |
| 3246 | if (CDF_STATUS_SUCCESS != cdf_status) |
| 3247 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3248 | FL("CloseSession error event msg %d"), msg); |
| 3249 | else |
| 3250 | sap_ctx->isScanSessionOpen = eSAP_FALSE; |
| 3251 | sap_ctx->sessionId = 0xff; |
| 3252 | } |
| 3253 | |
| 3254 | if (msg == eSAP_MAC_SCAN_COMPLETE) { |
| 3255 | /* get the bonding mode */ |
| 3256 | if (sap_ctx->channel <= 14) |
| 3257 | cbmode = sme_get_cb_phy_state_from_cb_ini_value( |
| 3258 | sme_get_channel_bonding_mode24_g(hal)); |
| 3259 | else |
| 3260 | cbmode = sme_get_cb_phy_state_from_cb_ini_value( |
| 3261 | sme_get_channel_bonding_mode5_g(hal)); |
| 3262 | |
| 3263 | #ifdef WLAN_ENABLE_CHNL_MATRIX_RESTRICTION |
| 3264 | temp_chan = sap_ctx->channel; |
| 3265 | p_nol = mac_ctx->sap.SapDfsInfo.sapDfsChannelNolList; |
| 3266 | |
| 3267 | sap_mark_channels_leaking_into_nol(sap_ctx, |
| 3268 | cbmode, p_nol, 1, &temp_chan); |
| 3269 | |
| 3270 | /* |
| 3271 | * if selelcted channel has leakage to channels |
| 3272 | * in NOL, the temp_chan will be reset |
| 3273 | */ |
| 3274 | b_leak_chan = (temp_chan != sap_ctx->channel); |
| 3275 | #endif |
| 3276 | /* |
| 3277 | * check if channel is in DFS_NOL or if the channel |
| 3278 | * has leakage to the channels in NOL |
| 3279 | */ |
| 3280 | if (sap_dfs_is_channel_in_nol_list(sap_ctx, sap_ctx->channel, |
| 3281 | cbmode) || b_leak_chan) { |
| 3282 | uint8_t ch; |
| 3283 | |
| 3284 | /* find a new available channel */ |
| 3285 | ch = sap_random_channel_sel(sap_ctx); |
| 3286 | if (ch == 0) { |
| 3287 | /* No available channel found */ |
| 3288 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3289 | CDF_TRACE_LEVEL_ERROR, |
| 3290 | FL("No available channel found!!!")); |
| 3291 | sap_signal_hdd_event(sap_ctx, NULL, |
| 3292 | eSAP_DFS_NO_AVAILABLE_CHANNEL, |
| 3293 | (void *)eSAP_STATUS_SUCCESS); |
| 3294 | return CDF_STATUS_E_FAULT; |
| 3295 | } |
| 3296 | |
| 3297 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3298 | FL("channel %d is in NOL, StartBss on new channel %d"), |
| 3299 | sap_ctx->channel, ch); |
| 3300 | |
| 3301 | sap_ctx->channel = ch; |
| 3302 | sme_set_ch_params(hal, sap_ctx->csr_roamProfile.phyMode, |
| 3303 | sap_ctx->channel, sap_ctx->secondary_ch, |
| 3304 | &sap_ctx->ch_params); |
| 3305 | } |
| 3306 | if (sap_ctx->channel > 14 && |
| 3307 | (sap_ctx->csr_roamProfile.phyMode == eCSR_DOT11_MODE_11g || |
| 3308 | sap_ctx->csr_roamProfile.phyMode == |
| 3309 | eCSR_DOT11_MODE_11g_ONLY)) |
| 3310 | sap_ctx->csr_roamProfile.phyMode = eCSR_DOT11_MODE_11a; |
| 3311 | |
| 3312 | #ifdef WLAN_FEATURE_MBSSID |
| 3313 | /* |
| 3314 | * when AP2 is started while AP1 is performing ACS, we may not |
| 3315 | * have the AP1 channel yet.So here after the completion of AP2 |
| 3316 | * ACS check if AP1 ACS resulting channel is DFS and if yes |
| 3317 | * override AP2 ACS scan result with AP1 DFS channel |
| 3318 | */ |
| 3319 | if (cds_concurrent_beaconing_sessions_running()) { |
| 3320 | uint16_t con_ch; |
| 3321 | |
| 3322 | con_ch = sme_get_concurrent_operation_channel(hal); |
| 3323 | if (con_ch && CDS_IS_DFS_CH(con_ch)) |
| 3324 | sap_ctx->channel = con_ch; |
| 3325 | } |
| 3326 | #endif |
| 3327 | /* |
| 3328 | * Transition from eSAP_CH_SELECT to eSAP_STARTING |
| 3329 | * (both without substates) |
| 3330 | */ |
| 3331 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3332 | FL("from state %s => %s"), |
| 3333 | "eSAP_CH_SELECT", "eSAP_STARTING"); |
| 3334 | /* Channel selected. Now can sap_goto_starting */ |
| 3335 | sap_ctx->sapsMachine = eSAP_STARTING; |
| 3336 | /* Specify the channel */ |
| 3337 | sap_ctx->csr_roamProfile.ChannelInfo.numOfChannels = |
| 3338 | 1; |
| 3339 | sap_ctx->csr_roamProfile.ChannelInfo.ChannelList = |
| 3340 | &sap_ctx->csr_roamProfile.operationChannel; |
| 3341 | sap_ctx->csr_roamProfile.operationChannel = |
| 3342 | (uint8_t) sap_ctx->channel; |
| 3343 | sap_ctx->csr_roamProfile.ch_params.ch_width = |
| 3344 | sap_ctx->ch_params.ch_width; |
| 3345 | sap_ctx->csr_roamProfile.ch_params.center_freq_seg0 = |
| 3346 | sap_ctx->ch_params.center_freq_seg0; |
| 3347 | sap_ctx->csr_roamProfile.ch_params.center_freq_seg1 = |
| 3348 | sap_ctx->ch_params.center_freq_seg1; |
| 3349 | sap_ctx->csr_roamProfile.ch_params.sec_ch_offset = |
| 3350 | sap_ctx->ch_params.sec_ch_offset; |
| 3351 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3352 | FL("notify hostapd about channel selection: %d"), |
| 3353 | sap_ctx->channel); |
| 3354 | sap_signal_hdd_event(sap_ctx, NULL, |
| 3355 | eSAP_CHANNEL_CHANGE_EVENT, |
| 3356 | (void *) eSAP_STATUS_SUCCESS); |
| 3357 | cdf_status = sap_goto_starting(sap_ctx, sap_event, |
| 3358 | eCSR_BSS_TYPE_INFRA_AP); |
| 3359 | } else if (msg == eSAP_CHANNEL_SELECTION_FAILED) { |
| 3360 | sap_ctx->sapsMachine = eSAP_DISCONNECTED; |
| 3361 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3362 | FL("Cannot start BSS, ACS Fail")); |
| 3363 | } else if (msg == eSAP_HDD_STOP_INFRA_BSS) { |
| 3364 | sap_ctx->sapsMachine = eSAP_DISCONNECTED; |
| 3365 | sap_signal_hdd_event(sap_ctx, NULL, eSAP_START_BSS_EVENT, |
| 3366 | (void *)eSAP_STATUS_FAILURE); |
| 3367 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 3368 | "%s: BSS stopped when Ch select in Progress", __func__); |
| 3369 | } else { |
| 3370 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3371 | FL("in state %s, invalid event msg %d"), |
| 3372 | "eSAP_CH_SELECT", msg); |
| 3373 | } |
| 3374 | |
| 3375 | return cdf_status; |
| 3376 | } |
| 3377 | |
| 3378 | /** |
| 3379 | * sap_fsm_state_dfs_cac_wait() - utility function called from sap fsm |
| 3380 | * @sap_ctx: SAP context |
| 3381 | * @sap_event: SAP event buffer |
| 3382 | * @mac_ctx: global MAC context |
| 3383 | * @hal: HAL handle |
| 3384 | * |
| 3385 | * This function is called for state transition from "eSAP_DFS_CAC_WAIT" |
| 3386 | * |
| 3387 | * Return: CDF_STATUS |
| 3388 | */ |
| 3389 | static CDF_STATUS sap_fsm_state_dfs_cac_wait(ptSapContext sap_ctx, |
| 3390 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx, |
| 3391 | tHalHandle hal) |
| 3392 | { |
| 3393 | uint32_t msg = sap_event->event; |
| 3394 | tCsrRoamInfo *roam_info = (tCsrRoamInfo *) (sap_event->params); |
| 3395 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3396 | |
| 3397 | if (msg == eSAP_DFS_CHANNEL_CAC_START) { |
| 3398 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3399 | FL("from state %s => %s"), |
| 3400 | "eSAP_CH_SELECT", "eSAP_DFS_CAC_WAIT"); |
| 3401 | if (mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running != true) |
| 3402 | sap_start_dfs_cac_timer(sap_ctx); |
| 3403 | cdf_status = sap_cac_start_notify(hal); |
| 3404 | } else if (msg == eSAP_DFS_CHANNEL_CAC_RADAR_FOUND) { |
| 3405 | uint8_t intf; |
| 3406 | /* |
| 3407 | * Radar found while performing channel availability |
| 3408 | * check, need to switch the channel again |
| 3409 | */ |
| 3410 | eCsrPhyMode phymode = sap_ctx->csr_roamProfile.phyMode; |
| 3411 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 3412 | "ENTERTRED CAC WAIT STATE-->eSAP_DISCONNECTING\n"); |
| 3413 | if (mac_ctx->sap.SapDfsInfo.target_channel) { |
| 3414 | sme_set_ch_params(hal, phymode, |
| 3415 | mac_ctx->sap.SapDfsInfo.target_channel, 0, |
| 3416 | &sap_ctx->ch_params); |
| 3417 | } |
| 3418 | |
| 3419 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 3420 | ptSapContext t_sap_ctx; |
| 3421 | if (((CDF_SAP_MODE == |
| 3422 | mac_ctx->sap.sapCtxList[intf].sapPersona) || |
| 3423 | (CDF_P2P_GO_MODE == |
| 3424 | mac_ctx->sap.sapCtxList[intf].sapPersona)) && |
| 3425 | mac_ctx->sap.sapCtxList[intf].pSapContext != NULL) { |
| 3426 | t_sap_ctx = |
| 3427 | mac_ctx->sap.sapCtxList[intf].pSapContext; |
| 3428 | /* SAP to be moved to DISCONNECTING state */ |
| 3429 | sap_ctx->sapsMachine = eSAP_DISCONNECTING; |
| 3430 | /* |
| 3431 | * eSAP_DFS_CHANNEL_CAC_RADAR_FOUND: |
| 3432 | * A Radar is found on current DFS Channel |
| 3433 | * while in CAC WAIT period So, do a channel |
| 3434 | * switch to randomly selected target channel. |
| 3435 | * Send the Channel change message to SME/PE. |
| 3436 | * sap_radar_found_status is set to 1 |
| 3437 | */ |
| 3438 | sap_signal_hdd_event(t_sap_ctx, NULL, |
| 3439 | eSAP_DFS_RADAR_DETECT, |
| 3440 | (void *)eSAP_STATUS_SUCCESS); |
| 3441 | |
| 3442 | wlansap_channel_change_request( |
| 3443 | (void *)t_sap_ctx, |
| 3444 | mac_ctx->sap.SapDfsInfo.target_channel); |
| 3445 | } |
| 3446 | } |
| 3447 | } else if (msg == eSAP_DFS_CHANNEL_CAC_END) { |
| 3448 | cdf_status = sap_cac_end_notify(hal, roam_info); |
| 3449 | } else if (msg == eSAP_HDD_STOP_INFRA_BSS) { |
| 3450 | /* Transition from eSAP_DFS_CAC_WAIT to eSAP_DISCONNECTING */ |
| 3451 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3452 | FL("from state %s => %s"), |
| 3453 | "eSAP_DFS_CAC_WAIT", "eSAP_DISCONNECTING"); |
| 3454 | |
| 3455 | /* |
| 3456 | * Stop the CAC timer only in following conditions |
| 3457 | * single AP: if there is a single AP then stop the timer |
| 3458 | * mulitple APs: incase of multiple APs, make sure that |
| 3459 | * all APs are down. |
| 3460 | */ |
| 3461 | if (NULL == sap_find_valid_concurrent_session(hal)) { |
| 3462 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3463 | CDF_TRACE_LEVEL_INFO_MED, |
| 3464 | FL("sapdfs: no sessions are valid, stopping timer")); |
| 3465 | sap_stop_dfs_cac_timer(sap_ctx); |
| 3466 | } |
| 3467 | |
| 3468 | sap_ctx->sapsMachine = eSAP_DISCONNECTING; |
| 3469 | cdf_status = sap_goto_disconnecting(sap_ctx); |
| 3470 | } else { |
| 3471 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3472 | FL("in state %s, invalid event msg %d"), |
| 3473 | "eSAP_DFS_CAC_WAIT", msg); |
| 3474 | } |
| 3475 | |
| 3476 | return cdf_status; |
| 3477 | } |
| 3478 | |
| 3479 | /** |
| 3480 | * sap_fsm_state_starting() - utility function called from sap fsm |
| 3481 | * @sap_ctx: SAP context |
| 3482 | * @sap_event: SAP event buffer |
| 3483 | * @mac_ctx: global MAC context |
| 3484 | * @hal: HAL handle |
| 3485 | * |
| 3486 | * This function is called for state transition from "eSAP_STARTING" |
| 3487 | * |
| 3488 | * Return: CDF_STATUS |
| 3489 | */ |
| 3490 | static CDF_STATUS sap_fsm_state_starting(ptSapContext sap_ctx, |
| 3491 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx, |
| 3492 | tHalHandle hal) |
| 3493 | { |
| 3494 | uint32_t msg = sap_event->event; |
| 3495 | tCsrRoamInfo *roam_info = (tCsrRoamInfo *) (sap_event->params); |
| 3496 | tSapDfsInfo *sap_dfs_info; |
| 3497 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3498 | |
| 3499 | if (msg == eSAP_MAC_START_BSS_SUCCESS) { |
| 3500 | /* |
| 3501 | * Transition from eSAP_STARTING to eSAP_STARTED |
| 3502 | * (both without substates) |
| 3503 | */ |
| 3504 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3505 | FL("from state channel = %d %s => %s"), |
| 3506 | sap_ctx->channel, "eSAP_STARTING", "eSAP_STARTED"); |
| 3507 | sap_ctx->sapsMachine = eSAP_STARTED; |
| 3508 | |
| 3509 | /* Action code for transition */ |
| 3510 | cdf_status = sap_signal_hdd_event(sap_ctx, roam_info, |
| 3511 | eSAP_START_BSS_EVENT, |
| 3512 | (void *) eSAP_STATUS_SUCCESS); |
| 3513 | |
| 3514 | /* |
| 3515 | * The upper layers have been informed that AP is up and |
| 3516 | * running, however, the AP is still not beaconing, until |
| 3517 | * CAC is done if the operating channel is DFS |
| 3518 | */ |
| 3519 | if (CHANNEL_STATE_DFS == |
| 3520 | cds_get_channel_state(sap_ctx->channel)) { |
| 3521 | sap_dfs_info = &mac_ctx->sap.SapDfsInfo; |
| 3522 | if ((false == sap_dfs_info->ignore_cac) && |
| 3523 | (eSAP_DFS_DO_NOT_SKIP_CAC == |
| 3524 | sap_dfs_info->cac_state)) { |
| 3525 | /* Move the device in CAC_WAIT_STATE */ |
| 3526 | sap_ctx->sapsMachine = eSAP_DFS_CAC_WAIT; |
| 3527 | |
| 3528 | /* |
| 3529 | * Need to stop the OS transmit queues, |
| 3530 | * so that no traffic can flow down the stack |
| 3531 | */ |
| 3532 | |
| 3533 | /* Start CAC wait timer */ |
| 3534 | if (sap_dfs_info->is_dfs_cac_timer_running != |
| 3535 | true) |
| 3536 | sap_start_dfs_cac_timer(sap_ctx); |
| 3537 | cdf_status = sap_cac_start_notify(hal); |
| 3538 | |
| 3539 | } else { |
| 3540 | wlansap_start_beacon_req(sap_ctx); |
| 3541 | } |
| 3542 | } |
| 3543 | } else if (msg == eSAP_MAC_START_FAILS) { |
| 3544 | /* |
| 3545 | * Transition from STARTING to DISCONNECTED |
| 3546 | * (both without substates) |
| 3547 | */ |
| 3548 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3549 | FL("from state %s => %s"), |
| 3550 | "eSAP_STARTING", "eSAP_DISCONNECTED"); |
| 3551 | |
| 3552 | /*Action code for transition */ |
| 3553 | cdf_status = sap_signal_hdd_event(sap_ctx, NULL, |
| 3554 | eSAP_START_BSS_EVENT, |
| 3555 | (void *) eSAP_STATUS_FAILURE); |
| 3556 | cdf_status = sap_goto_disconnected(sap_ctx); |
| 3557 | /* Advance outer statevar */ |
| 3558 | sap_ctx->sapsMachine = eSAP_DISCONNECTED; |
| 3559 | } else if (msg == eSAP_HDD_STOP_INFRA_BSS) { |
| 3560 | /* |
| 3561 | * Transition from eSAP_STARTING to eSAP_DISCONNECTED |
| 3562 | * (both without substates) |
| 3563 | */ |
| 3564 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3565 | FL("from state %s => %s"), |
| 3566 | "eSAP_STARTING", "eSAP_DISCONNECTED"); |
| 3567 | |
| 3568 | /* Advance outer statevar */ |
| 3569 | sap_ctx->sapsMachine = eSAP_DISCONNECTED; |
| 3570 | cdf_status = sap_signal_hdd_event(sap_ctx, NULL, |
| 3571 | eSAP_START_BSS_EVENT, |
| 3572 | (void *) eSAP_STATUS_FAILURE); |
| 3573 | cdf_status = sap_goto_disconnected(sap_ctx); |
| 3574 | /* Close the SME session */ |
| 3575 | |
| 3576 | if (eSAP_TRUE == sap_ctx->isSapSessionOpen) { |
| 3577 | if (CDF_STATUS_SUCCESS == sap_close_session(hal, |
| 3578 | sap_ctx, NULL, false)) |
| 3579 | sap_ctx->isSapSessionOpen = eSAP_FALSE; |
| 3580 | } |
| 3581 | } else if (msg == eSAP_OPERATING_CHANNEL_CHANGED) { |
| 3582 | /* The operating channel has changed, update hostapd */ |
| 3583 | sap_ctx->channel = |
| 3584 | (uint8_t) mac_ctx->sap.SapDfsInfo.target_channel; |
| 3585 | |
| 3586 | sap_ctx->sapsMachine = eSAP_STARTED; |
| 3587 | |
| 3588 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3589 | FL("from state %s => %s"), |
| 3590 | "eSAP_STARTING", "eSAP_STARTED"); |
| 3591 | |
| 3592 | /* Indicate change in the state to upper layers */ |
| 3593 | cdf_status = sap_signal_hdd_event(sap_ctx, roam_info, |
| 3594 | eSAP_START_BSS_EVENT, |
| 3595 | (void *)eSAP_STATUS_SUCCESS); |
| 3596 | } else { |
| 3597 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3598 | FL("in state %s, invalid event msg %d"), |
| 3599 | "eSAP_STARTING", msg); |
| 3600 | } |
| 3601 | |
| 3602 | return cdf_status; |
| 3603 | } |
| 3604 | |
| 3605 | /** |
| 3606 | * sap_fsm_state_started() - utility function called from sap fsm |
| 3607 | * @sap_ctx: SAP context |
| 3608 | * @sap_event: SAP event buffer |
| 3609 | * @mac_ctx: global MAC context |
| 3610 | * |
| 3611 | * This function is called for state transition from "eSAP_STARTED" |
| 3612 | * |
| 3613 | * Return: CDF_STATUS |
| 3614 | */ |
| 3615 | static CDF_STATUS sap_fsm_state_started(ptSapContext sap_ctx, |
| 3616 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx) |
| 3617 | { |
| 3618 | uint32_t msg = sap_event->event; |
| 3619 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3620 | |
| 3621 | if (msg == eSAP_HDD_STOP_INFRA_BSS) { |
| 3622 | /* |
| 3623 | * Transition from eSAP_STARTED to eSAP_DISCONNECTING |
| 3624 | * (both without substates) |
| 3625 | */ |
| 3626 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3627 | FL("from state %s => %s"), |
| 3628 | "eSAP_STARTED", "eSAP_DISCONNECTING"); |
| 3629 | sap_ctx->sapsMachine = eSAP_DISCONNECTING; |
| 3630 | cdf_status = sap_goto_disconnecting(sap_ctx); |
| 3631 | } else if (eSAP_DFS_CHNL_SWITCH_ANNOUNCEMENT_START == msg) { |
| 3632 | uint8_t intf; |
| 3633 | /* |
| 3634 | * Radar is seen on the current operating channel |
| 3635 | * send CSA IE for all associated stations |
| 3636 | * Request for CSA IE transmission |
| 3637 | */ |
| 3638 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 3639 | ptSapContext temp_sap_ctx; |
| 3640 | if (((CDF_SAP_MODE == |
| 3641 | mac_ctx->sap.sapCtxList[intf].sapPersona) || |
| 3642 | (CDF_P2P_GO_MODE == |
| 3643 | mac_ctx->sap.sapCtxList[intf].sapPersona)) && |
| 3644 | mac_ctx->sap.sapCtxList[intf].pSapContext != NULL) { |
| 3645 | temp_sap_ctx = |
| 3646 | mac_ctx->sap.sapCtxList[intf].pSapContext; |
| 3647 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 3648 | CDF_TRACE_LEVEL_INFO_MED, |
| 3649 | FL("sapdfs: Sending CSAIE for sapctx[%p]"), |
| 3650 | temp_sap_ctx); |
| 3651 | |
| 3652 | cdf_status = wlansap_dfs_send_csa_ie_request( |
| 3653 | (void *) temp_sap_ctx); |
| 3654 | } |
| 3655 | } |
| 3656 | } else { |
| 3657 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3658 | FL("in state %s, invalid event msg %d"), |
| 3659 | "eSAP_STARTED", msg); |
| 3660 | } |
| 3661 | |
| 3662 | return cdf_status; |
| 3663 | } |
| 3664 | |
| 3665 | /** |
| 3666 | * sap_fsm_state_disconnecting() - utility function called from sap fsm |
| 3667 | * @sap_ctx: SAP context |
| 3668 | * @sap_event: SAP event buffer |
| 3669 | * @mac_ctx: global MAC context |
| 3670 | * |
| 3671 | * This function is called for state transition from "eSAP_DISCONNECTING" |
| 3672 | * |
| 3673 | * Return: CDF_STATUS |
| 3674 | */ |
| 3675 | static CDF_STATUS sap_fsm_state_disconnecting(ptSapContext sap_ctx, |
| 3676 | ptWLAN_SAPEvent sap_event, tpAniSirGlobal mac_ctx, |
| 3677 | tHalHandle hal) |
| 3678 | { |
| 3679 | uint32_t msg = sap_event->event; |
| 3680 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3681 | |
| 3682 | if (msg == eSAP_MAC_READY_FOR_CONNECTIONS) { |
| 3683 | /* |
| 3684 | * Transition from eSAP_DISCONNECTING to eSAP_DISCONNECTED |
| 3685 | * (both without substates) |
| 3686 | */ |
| 3687 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3688 | FL("from state %s => %s"), |
| 3689 | "eSAP_DISCONNECTING", "eSAP_DISCONNECTED"); |
| 3690 | sap_ctx->sapsMachine = eSAP_DISCONNECTED; |
| 3691 | |
| 3692 | /* Close the SME session */ |
| 3693 | if (eSAP_TRUE == sap_ctx->isSapSessionOpen) { |
| 3694 | sap_ctx->isSapSessionOpen = eSAP_FALSE; |
| 3695 | cdf_status = sap_close_session(hal, sap_ctx, |
| 3696 | sap_roam_session_close_callback, true); |
| 3697 | if (!CDF_IS_STATUS_SUCCESS(cdf_status)) { |
| 3698 | cdf_status = sap_signal_hdd_event(sap_ctx, NULL, |
| 3699 | eSAP_STOP_BSS_EVENT, |
| 3700 | (void *)eSAP_STATUS_SUCCESS); |
| 3701 | } |
| 3702 | } |
| 3703 | } else if (msg == eWNI_SME_CHANNEL_CHANGE_REQ) { |
| 3704 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 3705 | FL("sapdfs: Send channel change request on sapctx[%p]"), |
| 3706 | sap_ctx); |
| 3707 | /* |
| 3708 | * Most likely, radar has been detected and SAP wants to |
| 3709 | * change the channel |
| 3710 | */ |
| 3711 | cdf_status = wlansap_channel_change_request((void *) sap_ctx, |
| 3712 | mac_ctx->sap.SapDfsInfo.target_channel); |
| 3713 | |
| 3714 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 3715 | FL("Sending DFS eWNI_SME_CHANNEL_CHANGE_REQ")); |
| 3716 | } else { |
| 3717 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3718 | FL("in state %s, invalid event msg %d"), |
| 3719 | "eSAP_DISCONNECTING", msg); |
| 3720 | } |
| 3721 | |
| 3722 | return cdf_status; |
| 3723 | } |
| 3724 | |
| 3725 | /** |
| 3726 | * sap_fsm() - SAP statem machine entry function |
| 3727 | * @sap_ctx: SAP context |
| 3728 | * @sap_event: SAP event |
| 3729 | * |
| 3730 | * SAP statem machine entry function |
| 3731 | * |
| 3732 | * Return: CDF_STATUS |
| 3733 | */ |
| 3734 | CDF_STATUS sap_fsm(ptSapContext sap_ctx, ptWLAN_SAPEvent sap_event) |
| 3735 | { |
| 3736 | /* |
| 3737 | * Retrieve the phy link state machine structure |
| 3738 | * from the sap_ctx value |
| 3739 | * state var that keeps track of state machine |
| 3740 | */ |
| 3741 | eSapFsmStates_t state_var = sap_ctx->sapsMachine; |
| 3742 | uint32_t msg = sap_event->event; /* State machine input event message */ |
| 3743 | CDF_STATUS cdf_status = CDF_STATUS_E_FAILURE; |
| 3744 | tHalHandle hal = CDS_GET_HAL_CB(sap_ctx->p_cds_gctx); |
| 3745 | tpAniSirGlobal mac_ctx; |
| 3746 | |
| 3747 | if (NULL == hal) { |
| 3748 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3749 | FL("Invalid hal")); |
| 3750 | return CDF_STATUS_E_FAILURE; |
| 3751 | } |
| 3752 | |
| 3753 | mac_ctx = PMAC_STRUCT(hal); |
| 3754 | if (NULL == mac_ctx) { |
| 3755 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3756 | FL("Invalid MAC context")); |
| 3757 | return CDF_STATUS_E_FAILURE; |
| 3758 | } |
| 3759 | |
| 3760 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_DEBUG, |
| 3761 | FL("sap_ctx=%p, state_var=%d, msg=0x%x"), |
| 3762 | sap_ctx, state_var, msg); |
| 3763 | |
| 3764 | switch (state_var) { |
| 3765 | case eSAP_DISCONNECTED: |
| 3766 | cdf_status = sap_fsm_state_disconnected(sap_ctx, sap_event, |
| 3767 | mac_ctx, hal); |
| 3768 | break; |
| 3769 | |
| 3770 | case eSAP_CH_SELECT: |
| 3771 | cdf_status = sap_fsm_state_ch_select(sap_ctx, sap_event, |
| 3772 | mac_ctx, hal); |
| 3773 | break; |
| 3774 | |
| 3775 | case eSAP_DFS_CAC_WAIT: |
| 3776 | cdf_status = sap_fsm_state_dfs_cac_wait(sap_ctx, sap_event, |
| 3777 | mac_ctx, hal); |
| 3778 | break; |
| 3779 | |
| 3780 | case eSAP_STARTING: |
| 3781 | cdf_status = sap_fsm_state_starting(sap_ctx, sap_event, |
| 3782 | mac_ctx, hal); |
| 3783 | break; |
| 3784 | |
| 3785 | case eSAP_STARTED: |
| 3786 | cdf_status = sap_fsm_state_started(sap_ctx, sap_event, |
| 3787 | mac_ctx); |
| 3788 | break; |
| 3789 | |
| 3790 | case eSAP_DISCONNECTING: |
| 3791 | cdf_status = sap_fsm_state_disconnecting(sap_ctx, sap_event, |
| 3792 | mac_ctx, hal); |
| 3793 | break; |
| 3794 | } |
| 3795 | return cdf_status; |
| 3796 | } |
| 3797 | |
| 3798 | eSapStatus |
| 3799 | sapconvert_to_csr_profile(tsap_Config_t *pconfig_params, eCsrRoamBssType bssType, |
| 3800 | tCsrRoamProfile *profile) |
| 3801 | { |
| 3802 | /* Create Roam profile for SoftAP to connect */ |
| 3803 | profile->BSSType = eCSR_BSS_TYPE_INFRA_AP; |
| 3804 | profile->SSIDs.numOfSSIDs = 1; |
| 3805 | profile->csrPersona = pconfig_params->persona; |
| 3806 | profile->disableDFSChSwitch = pconfig_params->disableDFSChSwitch; |
| 3807 | |
| 3808 | cdf_mem_zero(profile->SSIDs.SSIDList[0].SSID.ssId, |
| 3809 | sizeof(profile->SSIDs.SSIDList[0].SSID.ssId)); |
| 3810 | |
| 3811 | /* Flag to not broadcast the SSID information */ |
| 3812 | profile->SSIDs.SSIDList[0].ssidHidden = |
| 3813 | pconfig_params->SSIDinfo.ssidHidden; |
| 3814 | |
| 3815 | profile->SSIDs.SSIDList[0].SSID.length = |
| 3816 | pconfig_params->SSIDinfo.ssid.length; |
| 3817 | cdf_mem_copy(&profile->SSIDs.SSIDList[0].SSID.ssId, |
| 3818 | pconfig_params->SSIDinfo.ssid.ssId, |
| 3819 | sizeof(pconfig_params->SSIDinfo.ssid.ssId)); |
| 3820 | |
| 3821 | profile->negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 3822 | |
| 3823 | if (pconfig_params->authType == eSAP_OPEN_SYSTEM) { |
| 3824 | profile->negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 3825 | } else if (pconfig_params->authType == eSAP_SHARED_KEY) { |
| 3826 | profile->negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 3827 | } else { |
| 3828 | profile->negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 3829 | } |
| 3830 | |
| 3831 | profile->AuthType.numEntries = 1; |
| 3832 | profile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 3833 | |
| 3834 | /* Always set the Encryption Type */ |
| 3835 | profile->EncryptionType.numEntries = 1; |
| 3836 | profile->EncryptionType.encryptionType[0] = |
| 3837 | pconfig_params->RSNEncryptType; |
| 3838 | |
| 3839 | profile->mcEncryptionType.numEntries = 1; |
| 3840 | profile->mcEncryptionType.encryptionType[0] = |
| 3841 | pconfig_params->mcRSNEncryptType; |
| 3842 | |
| 3843 | if (pconfig_params->privacy & eSAP_SHARED_KEY) { |
| 3844 | profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY; |
| 3845 | } |
| 3846 | |
| 3847 | profile->privacy = pconfig_params->privacy; |
| 3848 | profile->fwdWPSPBCProbeReq = pconfig_params->fwdWPSPBCProbeReq; |
| 3849 | |
| 3850 | if (pconfig_params->authType == eSAP_SHARED_KEY) { |
| 3851 | profile->csr80211AuthType = eSIR_SHARED_KEY; |
| 3852 | } else if (pconfig_params->authType == eSAP_OPEN_SYSTEM) { |
| 3853 | profile->csr80211AuthType = eSIR_OPEN_SYSTEM; |
| 3854 | } else { |
| 3855 | profile->csr80211AuthType = eSIR_AUTO_SWITCH; |
| 3856 | } |
| 3857 | |
| 3858 | /* Initialize we are not going to use it */ |
| 3859 | profile->pWPAReqIE = NULL; |
| 3860 | profile->nWPAReqIELength = 0; |
| 3861 | |
| 3862 | /* set the RSN/WPA IE */ |
| 3863 | profile->pRSNReqIE = NULL; |
| 3864 | profile->nRSNReqIELength = pconfig_params->RSNWPAReqIELength; |
| 3865 | if (pconfig_params->RSNWPAReqIELength) { |
| 3866 | profile->pRSNReqIE = |
| 3867 | cdf_mem_malloc(pconfig_params->RSNWPAReqIELength); |
| 3868 | if (NULL == profile->pRSNReqIE) { |
| 3869 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 3870 | " %s Fail to alloc memory", __func__); |
| 3871 | return eSAP_STATUS_FAILURE; |
| 3872 | } |
| 3873 | cdf_mem_copy(profile->pRSNReqIE, pconfig_params->RSNWPAReqIE, |
| 3874 | pconfig_params->RSNWPAReqIELength); |
| 3875 | profile->nRSNReqIELength = pconfig_params->RSNWPAReqIELength; |
| 3876 | } |
| 3877 | /* Turn off CB mode */ |
| 3878 | profile->CBMode = eCSR_CB_OFF; |
| 3879 | |
| 3880 | /* set the phyMode to accept anything */ |
| 3881 | /* Best means everything because it covers all the things we support */ |
| 3882 | /* eCSR_DOT11_MODE_BEST */ |
| 3883 | profile->phyMode = pconfig_params->SapHw_mode; |
| 3884 | |
| 3885 | /* Configure beaconInterval */ |
| 3886 | profile->beaconInterval = (uint16_t) pconfig_params->beacon_int; |
| 3887 | |
| 3888 | /* set DTIM period */ |
| 3889 | profile->dtimPeriod = pconfig_params->dtim_period; |
| 3890 | |
| 3891 | /* set Uapsd enable bit */ |
| 3892 | profile->ApUapsdEnable = pconfig_params->UapsdEnable; |
| 3893 | |
| 3894 | /* Enable protection parameters */ |
| 3895 | profile->protEnabled = pconfig_params->protEnabled; |
| 3896 | profile->obssProtEnabled = pconfig_params->obssProtEnabled; |
| 3897 | profile->cfg_protection = pconfig_params->ht_capab; |
| 3898 | |
| 3899 | /* country code */ |
| 3900 | if (pconfig_params->countryCode[0]) |
| 3901 | cdf_mem_copy(profile->countryCode, pconfig_params->countryCode, |
| 3902 | WNI_CFG_COUNTRY_CODE_LEN); |
| 3903 | profile->ieee80211d = pconfig_params->ieee80211d; |
| 3904 | /* wps config info */ |
| 3905 | profile->wps_state = pconfig_params->wps_state; |
| 3906 | |
| 3907 | #ifdef WLAN_FEATURE_11W |
| 3908 | /* MFP capable/required */ |
| 3909 | profile->MFPCapable = pconfig_params->mfpCapable ? 1 : 0; |
| 3910 | profile->MFPRequired = pconfig_params->mfpRequired ? 1 : 0; |
| 3911 | #endif |
| 3912 | |
| 3913 | if (pconfig_params->probeRespIEsBufferLen > 0 && |
| 3914 | pconfig_params->pProbeRespIEsBuffer != NULL) { |
| 3915 | profile->addIeParams.probeRespDataLen = |
| 3916 | pconfig_params->probeRespIEsBufferLen; |
| 3917 | profile->addIeParams.probeRespData_buff = |
| 3918 | pconfig_params->pProbeRespIEsBuffer; |
| 3919 | } else { |
| 3920 | profile->addIeParams.probeRespDataLen = 0; |
| 3921 | profile->addIeParams.probeRespData_buff = NULL; |
| 3922 | } |
| 3923 | /*assoc resp IE */ |
| 3924 | if (pconfig_params->assocRespIEsLen > 0 && |
| 3925 | pconfig_params->pAssocRespIEsBuffer != NULL) { |
| 3926 | profile->addIeParams.assocRespDataLen = |
| 3927 | pconfig_params->assocRespIEsLen; |
| 3928 | profile->addIeParams.assocRespData_buff = |
| 3929 | pconfig_params->pAssocRespIEsBuffer; |
| 3930 | } else { |
| 3931 | profile->addIeParams.assocRespDataLen = 0; |
| 3932 | profile->addIeParams.assocRespData_buff = NULL; |
| 3933 | } |
| 3934 | |
| 3935 | if (pconfig_params->probeRespBcnIEsLen > 0 && |
| 3936 | pconfig_params->pProbeRespBcnIEsBuffer != NULL) { |
| 3937 | profile->addIeParams.probeRespBCNDataLen = |
| 3938 | pconfig_params->probeRespBcnIEsLen; |
| 3939 | profile->addIeParams.probeRespBCNData_buff = |
| 3940 | pconfig_params->pProbeRespBcnIEsBuffer; |
| 3941 | } else { |
| 3942 | profile->addIeParams.probeRespBCNDataLen = 0; |
| 3943 | profile->addIeParams.probeRespBCNData_buff = NULL; |
| 3944 | } |
| 3945 | profile->sap_dot11mc = pconfig_params->sap_dot11mc; |
| 3946 | |
| 3947 | return eSAP_STATUS_SUCCESS; /* Success. */ |
| 3948 | } |
| 3949 | |
| 3950 | void sap_free_roam_profile(tCsrRoamProfile *profile) |
| 3951 | { |
| 3952 | if (profile->pRSNReqIE) { |
| 3953 | cdf_mem_free(profile->pRSNReqIE); |
| 3954 | profile->pRSNReqIE = NULL; |
| 3955 | } |
| 3956 | } |
| 3957 | |
| 3958 | void sap_sort_mac_list(struct cdf_mac_addr *macList, uint8_t size) |
| 3959 | { |
| 3960 | uint8_t outer, inner; |
| 3961 | struct cdf_mac_addr temp; |
| 3962 | int32_t nRes = -1; |
| 3963 | |
| 3964 | if ((NULL == macList) || (size > MAX_ACL_MAC_ADDRESS)) { |
| 3965 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 3966 | FL("either buffer is NULL or size = %d is more"), size); |
| 3967 | return; |
| 3968 | } |
| 3969 | |
| 3970 | for (outer = 0; outer < size; outer++) { |
| 3971 | for (inner = 0; inner < size - 1; inner++) { |
| 3972 | nRes = |
| 3973 | cdf_mem_compare2((macList + inner)->bytes, |
| 3974 | (macList + inner + 1)->bytes, |
| 3975 | CDF_MAC_ADDR_SIZE); |
| 3976 | if (nRes > 0) { |
| 3977 | cdf_mem_copy(temp.bytes, |
| 3978 | (macList + inner + 1)->bytes, |
| 3979 | CDF_MAC_ADDR_SIZE); |
| 3980 | cdf_mem_copy((macList + inner + 1)->bytes, |
| 3981 | (macList + inner)->bytes, |
| 3982 | CDF_MAC_ADDR_SIZE); |
| 3983 | cdf_mem_copy((macList + inner)->bytes, |
| 3984 | temp.bytes, CDF_MAC_ADDR_SIZE); |
| 3985 | } |
| 3986 | } |
| 3987 | } |
| 3988 | } |
| 3989 | |
| 3990 | eSapBool |
| 3991 | sap_search_mac_list(struct cdf_mac_addr *macList, |
| 3992 | uint8_t num_mac, uint8_t *peerMac, |
| 3993 | uint8_t *index) |
| 3994 | { |
| 3995 | int32_t nRes = -1; |
| 3996 | int8_t nStart = 0, nEnd, nMiddle; |
| 3997 | nEnd = num_mac - 1; |
| 3998 | |
| 3999 | if ((NULL == macList) || (num_mac > MAX_ACL_MAC_ADDRESS)) { |
| 4000 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4001 | FL("either buffer is NULL or size = %d is more."), num_mac); |
| 4002 | return eSAP_FALSE; |
| 4003 | } |
| 4004 | |
| 4005 | while (nStart <= nEnd) { |
| 4006 | nMiddle = (nStart + nEnd) / 2; |
| 4007 | nRes = |
| 4008 | cdf_mem_compare2(&macList[nMiddle], peerMac, |
| 4009 | CDF_MAC_ADDR_SIZE); |
| 4010 | |
| 4011 | if (0 == nRes) { |
| 4012 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4013 | "search SUCC"); |
| 4014 | /* "index equals NULL" means the caller does not need the */ |
| 4015 | /* index value of the peerMac being searched */ |
| 4016 | if (index != NULL) { |
| 4017 | *index = (uint8_t) nMiddle; |
| 4018 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4019 | CDF_TRACE_LEVEL_INFO_HIGH, "index %d", |
| 4020 | *index); |
| 4021 | } |
| 4022 | return eSAP_TRUE; |
| 4023 | } |
| 4024 | if (nRes < 0) |
| 4025 | nStart = nMiddle + 1; |
| 4026 | else |
| 4027 | nEnd = nMiddle - 1; |
| 4028 | } |
| 4029 | |
| 4030 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4031 | "search not succ"); |
| 4032 | return eSAP_FALSE; |
| 4033 | } |
| 4034 | |
| 4035 | void sap_add_mac_to_acl(struct cdf_mac_addr *macList, |
| 4036 | uint8_t *size, uint8_t *peerMac) |
| 4037 | { |
| 4038 | int32_t nRes = -1; |
| 4039 | int i; |
| 4040 | |
| 4041 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4042 | "add acl entered"); |
| 4043 | |
| 4044 | if (NULL == macList || *size == 0 || *size > MAX_ACL_MAC_ADDRESS) { |
| 4045 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4046 | FL("either buffer is NULL or size = %d is incorrect."), |
| 4047 | *size); |
| 4048 | return; |
| 4049 | } |
| 4050 | |
| 4051 | for (i = ((*size) - 1); i >= 0; i--) { |
| 4052 | nRes = |
| 4053 | cdf_mem_compare2(&macList[i], peerMac, CDF_MAC_ADDR_SIZE); |
| 4054 | if (nRes > 0) { |
| 4055 | /* Move alphabetically greater mac addresses one index down to allow for insertion |
| 4056 | of new mac in sorted order */ |
| 4057 | cdf_mem_copy((macList + i + 1)->bytes, |
| 4058 | (macList + i)->bytes, CDF_MAC_ADDR_SIZE); |
| 4059 | } else { |
| 4060 | break; |
| 4061 | } |
| 4062 | } |
| 4063 | /* This should also take care of if the element is the first to be added in the list */ |
| 4064 | cdf_mem_copy((macList + i + 1)->bytes, peerMac, CDF_MAC_ADDR_SIZE); |
| 4065 | /* increment the list size */ |
| 4066 | (*size)++; |
| 4067 | } |
| 4068 | |
| 4069 | void sap_remove_mac_from_acl(struct cdf_mac_addr *macList, |
| 4070 | uint8_t *size, uint8_t index) |
| 4071 | { |
| 4072 | int i; |
| 4073 | |
| 4074 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4075 | "remove acl entered"); |
| 4076 | /* |
| 4077 | * Return if the list passed is empty. Ideally this should never happen |
| 4078 | * since this funcn is always called after sap_search_mac_list to get |
| 4079 | * the index of the mac addr to be removed and this will only get |
| 4080 | * called if the search is successful. Still no harm in having the check |
| 4081 | */ |
| 4082 | if ((macList == NULL) || (*size == 0) || |
| 4083 | (*size > MAX_ACL_MAC_ADDRESS)) { |
| 4084 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4085 | FL("either buffer is NULL or size %d is incorrect."), |
| 4086 | *size); |
| 4087 | return; |
| 4088 | } |
| 4089 | for (i = index; i < ((*size) - 1); i++) { |
| 4090 | /* Move mac addresses starting from "index" passed one index up to delete the void |
| 4091 | created by deletion of a mac address in ACL */ |
| 4092 | cdf_mem_copy((macList + i)->bytes, (macList + i + 1)->bytes, |
| 4093 | CDF_MAC_ADDR_SIZE); |
| 4094 | } |
| 4095 | /* The last space should be made empty since all mac addesses moved one step up */ |
| 4096 | cdf_mem_zero((macList + (*size) - 1)->bytes, CDF_MAC_ADDR_SIZE); |
| 4097 | /* reduce the list size by 1 */ |
| 4098 | (*size)--; |
| 4099 | } |
| 4100 | |
| 4101 | void sap_print_acl(struct cdf_mac_addr *macList, uint8_t size) |
| 4102 | { |
| 4103 | int i; |
| 4104 | uint8_t *macArray; |
| 4105 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4106 | "print acl entered"); |
| 4107 | |
| 4108 | if ((NULL == macList) || (size == 0) || (size >= MAX_ACL_MAC_ADDRESS)) { |
| 4109 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4110 | "In %s, either buffer is NULL or size %d is incorrect.", |
| 4111 | __func__, size); |
| 4112 | return; |
| 4113 | } |
| 4114 | |
| 4115 | for (i = 0; i < size; i++) { |
| 4116 | macArray = (macList + i)->bytes; |
| 4117 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4118 | "** ACL entry %i - " MAC_ADDRESS_STR, i, |
| 4119 | MAC_ADDR_ARRAY(macArray)); |
| 4120 | } |
| 4121 | return; |
| 4122 | } |
| 4123 | |
| 4124 | CDF_STATUS sap_is_peer_mac_allowed(ptSapContext sapContext, uint8_t *peerMac) |
| 4125 | { |
| 4126 | if (eSAP_ALLOW_ALL == sapContext->eSapMacAddrAclMode) |
| 4127 | return CDF_STATUS_SUCCESS; |
| 4128 | |
| 4129 | if (sap_search_mac_list |
| 4130 | (sapContext->acceptMacList, sapContext->nAcceptMac, peerMac, NULL)) |
| 4131 | return CDF_STATUS_SUCCESS; |
| 4132 | |
| 4133 | if (sap_search_mac_list |
| 4134 | (sapContext->denyMacList, sapContext->nDenyMac, peerMac, NULL)) { |
| 4135 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4136 | "In %s, Peer " MAC_ADDRESS_STR " in deny list", |
| 4137 | __func__, MAC_ADDR_ARRAY(peerMac)); |
| 4138 | return CDF_STATUS_E_FAILURE; |
| 4139 | } |
| 4140 | /* A new station CAN associate, unless in deny list. Less stringent mode */ |
| 4141 | if (eSAP_ACCEPT_UNLESS_DENIED == sapContext->eSapMacAddrAclMode) |
| 4142 | return CDF_STATUS_SUCCESS; |
| 4143 | |
| 4144 | /* A new station CANNOT associate, unless in accept list. More stringent mode */ |
| 4145 | if (eSAP_DENY_UNLESS_ACCEPTED == sapContext->eSapMacAddrAclMode) { |
| 4146 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4147 | "In %s, Peer " MAC_ADDRESS_STR |
| 4148 | " denied, Mac filter mode is eSAP_DENY_UNLESS_ACCEPTED", |
| 4149 | __func__, MAC_ADDR_ARRAY(peerMac)); |
| 4150 | return CDF_STATUS_E_FAILURE; |
| 4151 | } |
| 4152 | |
| 4153 | /* The new STA is neither in accept list nor in deny list. In this case, deny the association |
| 4154 | * but send a wifi event notification indicating the mac address being denied |
| 4155 | */ |
| 4156 | if (eSAP_SUPPORT_ACCEPT_AND_DENY == sapContext->eSapMacAddrAclMode) { |
| 4157 | sap_signal_hdd_event(sapContext, NULL, eSAP_UNKNOWN_STA_JOIN, |
| 4158 | (void *) peerMac); |
| 4159 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_HIGH, |
| 4160 | "In %s, Peer " MAC_ADDRESS_STR |
| 4161 | " denied, Mac filter mode is eSAP_SUPPORT_ACCEPT_AND_DENY", |
| 4162 | __func__, MAC_ADDR_ARRAY(peerMac)); |
| 4163 | return CDF_STATUS_E_FAILURE; |
| 4164 | } |
| 4165 | return CDF_STATUS_SUCCESS; |
| 4166 | } |
| 4167 | |
| 4168 | #ifdef SOFTAP_CHANNEL_RANGE |
| 4169 | /** |
| 4170 | * sap_get_channel_list() - get the list of channels |
| 4171 | * @sap_ctx: sap context |
| 4172 | * @ch_list: pointer to channel list array |
| 4173 | * @num_ch: pointer to number of channels. |
| 4174 | * |
| 4175 | * This function populates the list of channels for scanning. |
| 4176 | * |
| 4177 | * Return: CDF_STATUS |
| 4178 | */ |
| 4179 | static CDF_STATUS sap_get_channel_list(ptSapContext sap_ctx, |
| 4180 | uint8_t **ch_list, |
| 4181 | uint8_t *num_ch) |
| 4182 | { |
| 4183 | uint8_t loop_count; |
| 4184 | uint8_t *list; |
| 4185 | uint8_t ch_count; |
| 4186 | uint8_t start_ch_num, band_start_ch; |
| 4187 | uint8_t end_ch_num, band_end_ch; |
| 4188 | uint32_t en_lte_coex; |
| 4189 | tHalHandle hal = CDS_GET_HAL_CB(sap_ctx->p_cds_gctx); |
| 4190 | #ifdef FEATURE_WLAN_CH_AVOID |
| 4191 | uint8_t i; |
| 4192 | #endif |
| 4193 | tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); |
| 4194 | |
| 4195 | if (NULL == hal) { |
| 4196 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4197 | FL("Invalid HAL pointer from p_cds_gctx")); |
| 4198 | *num_ch = 0; |
| 4199 | *ch_list = NULL; |
| 4200 | return CDF_STATUS_E_FAULT; |
| 4201 | } |
| 4202 | |
| 4203 | start_ch_num = sap_ctx->acs_cfg->start_ch; |
| 4204 | end_ch_num = sap_ctx->acs_cfg->end_ch; |
| 4205 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 4206 | FL("startChannel %d, EndChannel %d, HW:%d"), |
| 4207 | start_ch_num, end_ch_num, |
| 4208 | sap_ctx->acs_cfg->hw_mode); |
| 4209 | |
| 4210 | wlansap_extend_to_acs_range(&start_ch_num, &end_ch_num, |
| 4211 | &band_start_ch, &band_end_ch); |
| 4212 | |
| 4213 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 4214 | FL("expanded startChannel %d,EndChannel %d"), |
| 4215 | start_ch_num, end_ch_num); |
| 4216 | |
| 4217 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO, |
| 4218 | FL("band_start_ch %d, band_end_ch %d"), |
| 4219 | band_start_ch, band_end_ch); |
| 4220 | |
| 4221 | sme_cfg_get_int(hal, WNI_CFG_ENABLE_LTE_COEX, &en_lte_coex); |
| 4222 | |
| 4223 | /* Check if LTE coex is enabled and 2.4GHz is selected */ |
| 4224 | if (en_lte_coex && (band_start_ch == RF_CHAN_1) && |
| 4225 | (band_end_ch == RF_CHAN_14)) { |
| 4226 | /* Set 2.4GHz upper limit to channel 9 for LTE COEX */ |
| 4227 | band_end_ch = RF_CHAN_9; |
| 4228 | } |
| 4229 | |
| 4230 | /* Allocate the max number of channel supported */ |
| 4231 | list = (uint8_t *) cdf_mem_malloc(NUM_5GHZ_CHANNELS + |
| 4232 | NUM_24GHZ_CHANNELS); |
| 4233 | if (NULL == list) { |
| 4234 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4235 | FL("Unable to allocate channel list")); |
| 4236 | *num_ch = 0; |
| 4237 | *ch_list = NULL; |
| 4238 | return CDF_STATUS_E_NOMEM; |
| 4239 | } |
| 4240 | |
| 4241 | /* Search for the Active channels in the given range */ |
| 4242 | ch_count = 0; |
| 4243 | for (loop_count = band_start_ch; loop_count <= band_end_ch; |
| 4244 | loop_count++) { |
| 4245 | /* go to next channel if rf_channel is out of range */ |
| 4246 | if ((start_ch_num > rf_channels[loop_count].channelNum) || |
| 4247 | (end_ch_num < rf_channels[loop_count].channelNum)) |
| 4248 | continue; |
| 4249 | /* |
| 4250 | * go to next channel if none of these condition pass |
| 4251 | * - DFS scan enabled and chan not in CHANNEL_STATE_DISABLE |
| 4252 | * - DFS scan disable but chan in CHANNEL_STATE_ENABLE |
| 4253 | */ |
| 4254 | if (!(((eSAP_TRUE == mac_ctx->scan.fEnableDFSChnlScan) && |
| 4255 | (reg_channels[loop_count].enabled)) || |
| 4256 | ((eSAP_FALSE == mac_ctx->scan.fEnableDFSChnlScan) && |
| 4257 | (CHANNEL_STATE_ENABLE == |
| 4258 | reg_channels[loop_count].enabled)))) |
| 4259 | continue; |
| 4260 | |
| 4261 | #ifdef FEATURE_WLAN_CH_AVOID |
| 4262 | for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++) { |
| 4263 | if ((safe_channels[i].channelNumber == |
| 4264 | rf_channels[loop_count].channelNum)) { |
| 4265 | /* Check if channel is safe */ |
| 4266 | if (true == safe_channels[i].isSafe) { |
| 4267 | #endif |
| 4268 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 4269 | uint8_t ch; |
| 4270 | ch = rf_channels[loop_count].channelNum; |
| 4271 | if ((sap_ctx->acs_cfg->skip_scan_status == |
| 4272 | eSAP_DO_PAR_ACS_SCAN)) { |
| 4273 | if ((ch >= sap_ctx->acs_cfg->skip_scan_range1_stch && |
| 4274 | ch <= sap_ctx->acs_cfg->skip_scan_range1_endch) || |
| 4275 | (ch >= sap_ctx->acs_cfg->skip_scan_range2_stch && |
| 4276 | ch <= sap_ctx->acs_cfg->skip_scan_range2_endch)) { |
| 4277 | list[ch_count] = |
| 4278 | rf_channels[loop_count].channelNum; |
| 4279 | ch_count++; |
| 4280 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4281 | CDF_TRACE_LEVEL_INFO, |
| 4282 | FL("%d %d added to ACS ch range"), |
| 4283 | ch_count, ch); |
| 4284 | } else { |
| 4285 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4286 | CDF_TRACE_LEVEL_INFO_HIGH, |
| 4287 | FL("%d %d skipped from ACS ch range"), |
| 4288 | ch_count, ch); |
| 4289 | } |
| 4290 | } else { |
| 4291 | list[ch_count] = |
| 4292 | rf_channels[loop_count].channelNum; |
| 4293 | ch_count++; |
| 4294 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4295 | CDF_TRACE_LEVEL_INFO, |
| 4296 | FL("%d %d added to ACS ch range"), |
| 4297 | ch_count, ch); |
| 4298 | } |
| 4299 | #else |
| 4300 | list[ch_count] = rf_channels[loop_count].channelNum; |
| 4301 | ch_count++; |
| 4302 | #endif |
| 4303 | #ifdef FEATURE_WLAN_CH_AVOID |
| 4304 | } |
| 4305 | break; |
| 4306 | } |
| 4307 | } |
| 4308 | #endif |
| 4309 | } |
| 4310 | if (0 == ch_count) { |
| 4311 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4312 | FL("No active channels present for the current region")); |
| 4313 | /* |
| 4314 | * LTE COEX: channel range outside the restricted 2.4GHz |
| 4315 | * band limits |
| 4316 | */ |
| 4317 | if (en_lte_coex && (start_ch_num > band_end_ch)) |
| 4318 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_FATAL, |
| 4319 | FL("SAP can't be started as due to LTE COEX")); |
| 4320 | } |
| 4321 | |
| 4322 | /* return the channel list and number of channels to scan */ |
| 4323 | *num_ch = ch_count; |
| 4324 | if (ch_count != 0) { |
| 4325 | *ch_list = list; |
| 4326 | } else { |
| 4327 | *ch_list = NULL; |
| 4328 | cdf_mem_free(list); |
| 4329 | } |
| 4330 | |
| 4331 | for (loop_count = 0; loop_count < ch_count; loop_count++) { |
| 4332 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_DEBUG, |
| 4333 | FL("channel number: %d"), list[loop_count]); |
| 4334 | } |
| 4335 | return CDF_STATUS_SUCCESS; |
| 4336 | } |
| 4337 | #endif |
| 4338 | |
| 4339 | /* |
| 4340 | * Function for initializing list of 2.4/5 Ghz [NON-DFS/DFS] |
| 4341 | * available channels in the current regulatory domain. |
| 4342 | */ |
| 4343 | static CDF_STATUS sap_get5_g_hz_channel_list(ptSapContext sapContext) |
| 4344 | { |
| 4345 | uint8_t count = 0; |
| 4346 | int i; |
| 4347 | if (NULL == sapContext) { |
| 4348 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4349 | "Invalid sapContext pointer on sap_get_channel_list"); |
| 4350 | return CDF_STATUS_E_FAULT; |
| 4351 | } |
| 4352 | |
| 4353 | if (sapContext->SapAllChnlList.channelList) { |
| 4354 | cdf_mem_free(sapContext->SapAllChnlList.channelList); |
| 4355 | sapContext->SapAllChnlList.channelList = NULL; |
| 4356 | } |
| 4357 | |
| 4358 | sapContext->SapAllChnlList.channelList = |
| 4359 | (tChannelInfo *) cdf_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN * |
| 4360 | sizeof(tChannelInfo)); |
| 4361 | if (NULL == sapContext->SapAllChnlList.channelList) { |
| 4362 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4363 | " Memory Allocation failed sap_get_channel_list"); |
| 4364 | return CDF_STATUS_E_NOMEM; |
| 4365 | } |
| 4366 | |
| 4367 | for (i = RF_CHAN_36; i <= RF_CHAN_165; i++) { |
| 4368 | if (reg_channels[i].enabled == CHANNEL_STATE_ENABLE || |
| 4369 | reg_channels[i].enabled == CHANNEL_STATE_DFS) { |
| 4370 | sapContext->SapAllChnlList.channelList[count].channel = |
| 4371 | rf_channels[i].channelNum; |
| 4372 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 4373 | "%s[%d] CHANNEL = %d", __func__, __LINE__, |
| 4374 | sapContext->SapAllChnlList.channelList[count]. |
| 4375 | channel); |
| 4376 | sapContext->SapAllChnlList.channelList[count].valid = |
| 4377 | true; |
| 4378 | count++; |
| 4379 | } |
| 4380 | } |
| 4381 | |
| 4382 | sapContext->SapAllChnlList.numChannel = count; |
| 4383 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 4384 | "%s[%d] NUMBER OF CHANNELS count = %d" |
| 4385 | "sapContext->SapAllChnlList.numChannel = %d", |
| 4386 | __func__, __LINE__, count, |
| 4387 | sapContext->SapAllChnlList.numChannel); |
| 4388 | return CDF_STATUS_SUCCESS; |
| 4389 | } |
| 4390 | |
| 4391 | /* |
| 4392 | * This function randomly selects the channel to switch after the detection |
| 4393 | * of radar |
| 4394 | * param sapContext - sap context |
| 4395 | * dfs_event - Dfs information from DFS |
| 4396 | * return - channel to which AP wishes to switch |
| 4397 | */ |
| 4398 | uint8_t sap_indicate_radar(ptSapContext sapContext, |
| 4399 | tSirSmeDfsEventInd *dfs_event) |
| 4400 | { |
| 4401 | uint8_t target_channel = 0; |
| 4402 | tHalHandle hHal; |
| 4403 | tpAniSirGlobal pMac; |
| 4404 | |
| 4405 | if (NULL == sapContext || NULL == dfs_event) { |
| 4406 | /* Invalid sap context of dfs event passed */ |
| 4407 | return 0; |
| 4408 | } |
| 4409 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 4410 | |
| 4411 | if (NULL == hHal) { |
| 4412 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4413 | "In %s invalid hHal", __func__); |
| 4414 | return 0; |
| 4415 | } |
| 4416 | pMac = PMAC_STRUCT(hHal); |
| 4417 | |
| 4418 | if (!dfs_event->dfs_radar_status) { |
| 4419 | /*dfs status does not indicate a radar on the channel-- False Alarm */ |
| 4420 | return 0; |
| 4421 | } |
| 4422 | |
| 4423 | /* |
| 4424 | * SAP needs to generate Channel Switch IE |
| 4425 | * if the radar is found in the STARTED state |
| 4426 | */ |
| 4427 | if (eSAP_STARTED == sapContext->sapsMachine) |
| 4428 | pMac->sap.SapDfsInfo.csaIERequired = eSAP_TRUE; |
| 4429 | |
| 4430 | if (sapContext->csr_roamProfile.disableDFSChSwitch) { |
| 4431 | return sapContext->channel; |
| 4432 | } |
| 4433 | |
| 4434 | /* set the Radar Found flag in SapDfsInfo */ |
| 4435 | pMac->sap.SapDfsInfo.sap_radar_found_status = true; |
| 4436 | |
| 4437 | sap_get5_g_hz_channel_list(sapContext); |
| 4438 | |
| 4439 | if (dfs_event->chan_list.nchannels > SIR_DFS_MAX_20M_SUB_CH) { |
| 4440 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_WARN, |
| 4441 | FL("nchannels >SIR_DFS_MAX_20M_SUB_CH so resetting")); |
| 4442 | dfs_event->chan_list.nchannels = SIR_DFS_MAX_20M_SUB_CH; |
| 4443 | } |
| 4444 | |
| 4445 | sap_mark_dfs_channels(sapContext, dfs_event->chan_list.channels, |
| 4446 | dfs_event->chan_list.nchannels, |
| 4447 | cds_get_monotonic_boottime()); |
| 4448 | |
| 4449 | /* |
| 4450 | * (1) skip static turbo channel as it will require STA to be in |
| 4451 | * static turbo to work. |
| 4452 | * (2) skip channel which's marked with radar detction |
| 4453 | * (3) WAR: we allow user to config not to use any DFS channel |
| 4454 | * (4) When we pick a channel, skip excluded 11D channels |
| 4455 | * (5) Create the available channel list with the above rules |
| 4456 | */ |
| 4457 | |
| 4458 | target_channel = sap_random_channel_sel(sapContext); |
| 4459 | if (0 == target_channel) { |
| 4460 | sap_signal_hdd_event(sapContext, NULL, |
| 4461 | eSAP_DFS_NO_AVAILABLE_CHANNEL, |
| 4462 | (void *) eSAP_STATUS_SUCCESS); |
| 4463 | } |
| 4464 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_WARN, |
| 4465 | FL("sapdfs: New selected target channel is [%d]"), |
| 4466 | target_channel); |
| 4467 | return target_channel; |
| 4468 | } |
| 4469 | |
| 4470 | /* |
| 4471 | * CAC timer callback function. |
| 4472 | * Post eSAP_DFS_CHANNEL_CAC_END event to sap_fsm(). |
| 4473 | */ |
| 4474 | void sap_dfs_cac_timer_callback(void *data) |
| 4475 | { |
| 4476 | ptSapContext sapContext; |
| 4477 | tWLAN_SAPEvent sapEvent; |
| 4478 | tHalHandle hHal = (tHalHandle) data; |
| 4479 | tpAniSirGlobal pMac; |
| 4480 | |
| 4481 | if (NULL == hHal) { |
| 4482 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4483 | "In %s invalid hHal", __func__); |
| 4484 | return; |
| 4485 | } |
| 4486 | pMac = PMAC_STRUCT(hHal); |
| 4487 | sapContext = sap_find_valid_concurrent_session(hHal); |
| 4488 | |
| 4489 | if (NULL == sapContext) { |
| 4490 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4491 | "In %s no SAP contexts are found", __func__); |
| 4492 | return; |
| 4493 | } |
| 4494 | |
| 4495 | /* Check to ensure that SAP is in DFS WAIT state */ |
| 4496 | if (sapContext->sapsMachine == eSAP_DFS_CAC_WAIT) { |
| 4497 | cdf_mc_timer_destroy(&pMac->sap.SapDfsInfo.sap_dfs_cac_timer); |
| 4498 | pMac->sap.SapDfsInfo.is_dfs_cac_timer_running = false; |
| 4499 | |
| 4500 | /* |
| 4501 | * CAC Complete, post eSAP_DFS_CHANNEL_CAC_END to sap_fsm |
| 4502 | */ |
| 4503 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 4504 | "sapdfs: Sending eSAP_DFS_CHANNEL_CAC_END for target_channel = %d on sapctx[%p]", |
| 4505 | sapContext->channel, sapContext); |
| 4506 | |
| 4507 | sapEvent.event = eSAP_DFS_CHANNEL_CAC_END; |
| 4508 | sapEvent.params = 0; |
| 4509 | sapEvent.u1 = 0; |
| 4510 | sapEvent.u2 = 0; |
| 4511 | |
| 4512 | sap_fsm(sapContext, &sapEvent); |
| 4513 | } |
| 4514 | |
| 4515 | } |
| 4516 | |
| 4517 | /* |
| 4518 | * Function to stop the DFS CAC Timer |
| 4519 | */ |
| 4520 | static int sap_stop_dfs_cac_timer(ptSapContext sapContext) |
| 4521 | { |
| 4522 | tHalHandle hHal; |
| 4523 | tpAniSirGlobal pMac; |
| 4524 | if (sapContext == NULL) |
| 4525 | return 0; |
| 4526 | |
| 4527 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 4528 | if (NULL == hHal) { |
| 4529 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4530 | "In %s invalid hHal", __func__); |
| 4531 | return 0; |
| 4532 | } |
| 4533 | pMac = PMAC_STRUCT(hHal); |
| 4534 | |
| 4535 | if (CDF_TIMER_STATE_RUNNING != |
| 4536 | cdf_mc_timer_get_current_state(&pMac->sap.SapDfsInfo. |
| 4537 | sap_dfs_cac_timer)) { |
| 4538 | return 0; |
| 4539 | } |
| 4540 | |
| 4541 | cdf_mc_timer_stop(&pMac->sap.SapDfsInfo.sap_dfs_cac_timer); |
| 4542 | pMac->sap.SapDfsInfo.is_dfs_cac_timer_running = 0; |
| 4543 | |
| 4544 | return 0; |
| 4545 | } |
| 4546 | |
| 4547 | |
| 4548 | /** |
| 4549 | * sap_is_channel_bonding_etsi_weather_channel() - check weather chan bonding. |
| 4550 | * @sap_context: SAP context |
| 4551 | * |
| 4552 | * Check if the current SAP operating channel is bonded to weather radar |
| 4553 | * channel in ETSI domain. |
| 4554 | * |
| 4555 | * Return: True if bonded to weather channel in ETSI |
| 4556 | */ |
| 4557 | static bool |
| 4558 | sap_is_channel_bonding_etsi_weather_channel(ptSapContext sap_context) |
| 4559 | { |
| 4560 | if (IS_CH_BONDING_WITH_WEATHER_CH(sap_context->channel) && |
| 4561 | (sap_context->ch_params.ch_width != CH_WIDTH_20MHZ)) |
| 4562 | return true; |
| 4563 | |
| 4564 | return false; |
| 4565 | } |
| 4566 | |
| 4567 | /* |
| 4568 | * Function to start the DFS CAC Timer |
| 4569 | * when SAP is started on a DFS channel |
| 4570 | */ |
| 4571 | int sap_start_dfs_cac_timer(ptSapContext sapContext) |
| 4572 | { |
| 4573 | CDF_STATUS status; |
| 4574 | uint32_t cacTimeOut; |
| 4575 | tHalHandle hHal = NULL; |
| 4576 | tpAniSirGlobal pMac = NULL; |
| 4577 | uint8_t dfs_region; |
| 4578 | |
| 4579 | if (sapContext == NULL) { |
| 4580 | return 0; |
| 4581 | } |
| 4582 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 4583 | |
| 4584 | if (NULL == hHal) { |
| 4585 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4586 | "In %s invalid hHal", __func__); |
| 4587 | return 0; |
| 4588 | } |
| 4589 | pMac = PMAC_STRUCT(hHal); |
| 4590 | |
| 4591 | if (pMac->sap.SapDfsInfo.ignore_cac) { |
| 4592 | /* |
| 4593 | * If User has set to ignore the CAC |
| 4594 | * so, continue without CAC Timer. |
| 4595 | */ |
| 4596 | return 2; |
| 4597 | } |
| 4598 | cacTimeOut = DEFAULT_CAC_TIMEOUT; |
| 4599 | |
| 4600 | cds_get_dfs_region(&dfs_region); |
| 4601 | |
| 4602 | if ((dfs_region == DFS_ETSI_DOMAIN) |
| 4603 | && ((IS_ETSI_WEATHER_CH(sapContext->channel)) || |
| 4604 | (sap_is_channel_bonding_etsi_weather_channel(sapContext)))) { |
| 4605 | cacTimeOut = ETSI_WEATHER_CH_CAC_TIMEOUT; |
| 4606 | } |
| 4607 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_MED, |
| 4608 | "sapdfs: SAP_DFS_CHANNEL_CAC_START on CH - %d, CAC TIMEOUT - %d sec", |
| 4609 | sapContext->channel, cacTimeOut / 1000); |
| 4610 | |
| 4611 | cdf_mc_timer_init(&pMac->sap.SapDfsInfo.sap_dfs_cac_timer, |
| 4612 | CDF_TIMER_TYPE_SW, |
| 4613 | sap_dfs_cac_timer_callback, (void *) hHal); |
| 4614 | |
| 4615 | /*Start the CAC timer */ |
| 4616 | status = |
| 4617 | cdf_mc_timer_start(&pMac->sap.SapDfsInfo.sap_dfs_cac_timer, |
| 4618 | cacTimeOut); |
| 4619 | if (status == CDF_STATUS_SUCCESS) { |
| 4620 | pMac->sap.SapDfsInfo.is_dfs_cac_timer_running = true; |
| 4621 | return 1; |
| 4622 | } else { |
| 4623 | return 0; |
| 4624 | } |
| 4625 | } |
| 4626 | |
| 4627 | /* |
| 4628 | * This function initializes the NOL list |
| 4629 | * parameters required to track the radar |
| 4630 | * found DFS channels in the current Reg. Domain . |
| 4631 | */ |
| 4632 | CDF_STATUS sap_init_dfs_channel_nol_list(ptSapContext sapContext) |
| 4633 | { |
| 4634 | uint8_t count = 0; |
| 4635 | int i; |
| 4636 | bool bFound = false; |
| 4637 | tHalHandle hHal; |
| 4638 | tpAniSirGlobal pMac; |
| 4639 | |
| 4640 | if (NULL == sapContext) { |
| 4641 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4642 | "Invalid sapContext pointer on sap_init_dfs_channel_nol_list"); |
| 4643 | return CDF_STATUS_E_FAULT; |
| 4644 | } |
| 4645 | hHal = CDS_GET_HAL_CB(sapContext->p_cds_gctx); |
| 4646 | |
| 4647 | if (NULL == hHal) { |
| 4648 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_ERROR, |
| 4649 | "In %s invalid hHal", __func__); |
| 4650 | return CDF_STATUS_E_FAULT; |
| 4651 | } |
| 4652 | pMac = PMAC_STRUCT(hHal); |
| 4653 | |
| 4654 | /* to indicate hdd to get cnss dfs nol */ |
| 4655 | if (CDF_STATUS_SUCCESS == sap_signal_hdd_event(sapContext, NULL, |
| 4656 | eSAP_DFS_NOL_GET, |
| 4657 | (void *) |
| 4658 | eSAP_STATUS_SUCCESS)) { |
| 4659 | bFound = true; |
| 4660 | } |
| 4661 | |
| 4662 | for (i = RF_CHAN_36; i <= RF_CHAN_165; i++) { |
| 4663 | if (reg_channels[i].enabled == CHANNEL_STATE_DFS) { |
| 4664 | /* if dfs nol is not found, initialize it */ |
| 4665 | if (!bFound) { |
| 4666 | pMac->sap.SapDfsInfo.sapDfsChannelNolList[count] |
| 4667 | .dfs_channel_number = |
| 4668 | rf_channels[i].channelNum; |
| 4669 | |
| 4670 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4671 | CDF_TRACE_LEVEL_INFO_LOW, |
| 4672 | "%s: CHANNEL = %d", __func__, |
| 4673 | pMac->sap.SapDfsInfo. |
| 4674 | sapDfsChannelNolList[count]. |
| 4675 | dfs_channel_number); |
| 4676 | |
| 4677 | pMac->sap.SapDfsInfo.sapDfsChannelNolList[count] |
| 4678 | .radar_status_flag = |
| 4679 | eSAP_DFS_CHANNEL_USABLE; |
| 4680 | pMac->sap.SapDfsInfo.sapDfsChannelNolList[count] |
| 4681 | .radar_found_timestamp = 0; |
| 4682 | } |
| 4683 | count++; |
| 4684 | } |
| 4685 | } |
| 4686 | |
| 4687 | pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels = count; |
| 4688 | |
| 4689 | CDF_TRACE(CDF_MODULE_ID_SAP, CDF_TRACE_LEVEL_INFO_LOW, |
| 4690 | "%s[%d] NUMBER OF DFS CHANNELS = %d", |
| 4691 | __func__, __LINE__, |
| 4692 | pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels); |
| 4693 | |
| 4694 | return CDF_STATUS_SUCCESS; |
| 4695 | } |
| 4696 | |
| 4697 | /* |
| 4698 | * This function will calculate how many interfaces |
| 4699 | * have sap persona and returns total number of sap persona. |
| 4700 | */ |
| 4701 | uint8_t sap_get_total_number_sap_intf(tHalHandle hHal) |
| 4702 | { |
| 4703 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 4704 | uint8_t intf = 0; |
| 4705 | uint8_t intf_count = 0; |
| 4706 | |
| 4707 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 4708 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 4709 | || |
| 4710 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) |
| 4711 | && pMac->sap.sapCtxList[intf].pSapContext != NULL) { |
| 4712 | intf_count++; |
| 4713 | } |
| 4714 | } |
| 4715 | return intf_count; |
| 4716 | } |
| 4717 | |
| 4718 | /* |
| 4719 | * This function will find the concurrent sap context apart from |
| 4720 | * passed sap context and return its channel change ready status |
| 4721 | */ |
| 4722 | bool is_concurrent_sap_ready_for_channel_change(tHalHandle hHal, |
| 4723 | ptSapContext sapContext) |
| 4724 | { |
| 4725 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 4726 | ptSapContext pSapContext; |
| 4727 | uint8_t intf = 0; |
| 4728 | |
| 4729 | for (intf = 0; intf < SAP_MAX_NUM_SESSION; intf++) { |
| 4730 | if (((CDF_SAP_MODE == pMac->sap.sapCtxList[intf].sapPersona) |
| 4731 | || |
| 4732 | (CDF_P2P_GO_MODE == pMac->sap.sapCtxList[intf].sapPersona)) |
| 4733 | && pMac->sap.sapCtxList[intf].pSapContext != NULL) { |
| 4734 | pSapContext = |
| 4735 | (ptSapContext) pMac->sap.sapCtxList[intf]. |
| 4736 | pSapContext; |
| 4737 | if (pSapContext == sapContext) { |
| 4738 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4739 | CDF_TRACE_LEVEL_ERROR, |
| 4740 | FL("sapCtx matched [%p]"), |
| 4741 | sapContext); |
| 4742 | continue; |
| 4743 | } else { |
| 4744 | CDF_TRACE(CDF_MODULE_ID_SAP, |
| 4745 | CDF_TRACE_LEVEL_ERROR, |
| 4746 | FL |
| 4747 | ("concurrent sapCtx[%p] didn't matche with [%p]"), |
| 4748 | pSapContext, sapContext); |
| 4749 | return pSapContext->is_sap_ready_for_chnl_chng; |
| 4750 | } |
| 4751 | } |
| 4752 | } |
| 4753 | return false; |
| 4754 | } |