1 /** @file mlan_main.h 2 * 3 * @brief This file defines the private and adapter data 4 * structures and declares global function prototypes used 5 * in MLAN module. 6 * 7 * 8 * Copyright 2008-2022 NXP 9 * 10 * This software file (the File) is distributed by NXP 11 * under the terms of the GNU General Public License Version 2, June 1991 12 * (the License). You may use, redistribute and/or modify the File in 13 * accordance with the terms and conditions of the License, a copy of which 14 * is available by writing to the Free Software Foundation, Inc., 15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 16 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 17 * 18 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 20 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 21 * this warranty disclaimer. 22 * 23 */ 24 25 /****************************************************** 26 Change log: 27 10/13/2008: initial version 28 ******************************************************/ 29 30 #ifndef _MLAN_MAIN_H_ 31 #define _MLAN_MAIN_H_ 32 33 #ifdef DEBUG_LEVEL1 34 extern t_void (*print_callback)(t_pvoid pmoal_handle, t_u32 level, 35 char *pformat, IN...); 36 37 extern mlan_status (*get_sys_time_callback)(t_void *pmoal_handle, t_u32 *psec, 38 t_u32 *pusec); 39 40 extern t_u32 mlan_drvdbg; 41 42 #ifdef DEBUG_LEVEL2 43 #define PRINTM_MINFO(msg...) \ 44 do { \ 45 if ((mlan_drvdbg & MINFO) && (print_callback)) \ 46 print_callback(MNULL, MINFO, msg); \ 47 } while (0) 48 #define PRINTM_MWARN(msg...) \ 49 do { \ 50 if ((mlan_drvdbg & MWARN) && (print_callback)) \ 51 print_callback(MNULL, MWARN, msg); \ 52 } while (0) 53 #define PRINTM_MENTRY(msg...) \ 54 do { \ 55 if ((mlan_drvdbg & MENTRY) && (print_callback)) \ 56 print_callback(MNULL, MENTRY, msg); \ 57 } while (0) 58 #define PRINTM_GET_SYS_TIME(level, psec, pusec) \ 59 do { \ 60 if ((level & mlan_drvdbg) && (get_sys_time_callback)) \ 61 get_sys_time_callback(MNULL, psec, pusec); \ 62 } while (0) 63 64 /** Hexdump for level-2 debugging */ 65 #define HEXDUMP(x, y, z) \ 66 do { \ 67 if ((mlan_drvdbg & (MHEX_DUMP | MINFO)) && (print_callback)) \ 68 print_callback(MNULL, MHEX_DUMP | MINFO, x, y, z); \ 69 } while (0) 70 71 #else 72 73 #define PRINTM_MINFO(msg...) \ 74 do { \ 75 } while (0) 76 #define PRINTM_MWARN(msg...) \ 77 do { \ 78 } while (0) 79 #define PRINTM_MENTRY(msg...) \ 80 do { \ 81 } while (0) 82 83 #define PRINTM_GET_SYS_TIME(level, psec, pusec) \ 84 do { \ 85 if ((level & mlan_drvdbg) && (get_sys_time_callback) && \ 86 (level != MINFO) && (level != MWARN)) \ 87 get_sys_time_callback(MNULL, psec, pusec); \ 88 } while (0) 89 90 /** Hexdump for debugging */ 91 #define HEXDUMP(x, y, z) \ 92 do { \ 93 } while (0) 94 95 #endif /* DEBUG_LEVEL2 */ 96 97 #define PRINTM_MFW_D(msg...) \ 98 do { \ 99 if ((mlan_drvdbg & MFW_D) && (print_callback)) \ 100 print_callback(MNULL, MFW_D, msg); \ 101 } while (0) 102 #define PRINTM_MCMD_D(msg...) \ 103 do { \ 104 if ((mlan_drvdbg & MCMD_D) && (print_callback)) \ 105 print_callback(MNULL, MCMD_D, msg); \ 106 } while (0) 107 #define PRINTM_MDAT_D(msg...) \ 108 do { \ 109 if ((mlan_drvdbg & MDAT_D) && (print_callback)) \ 110 print_callback(MNULL, MDAT_D, msg); \ 111 } while (0) 112 #define PRINTM_MIF_D(msg...) \ 113 do { \ 114 if ((mlan_drvdbg & MIF_D) && (print_callback)) \ 115 print_callback(MNULL, MIF_D, msg); \ 116 } while (0) 117 118 #define PRINTM_MIOCTL(msg...) \ 119 do { \ 120 if ((mlan_drvdbg & MIOCTL) && (print_callback)) \ 121 print_callback(MNULL, MIOCTL, msg); \ 122 } while (0) 123 #define PRINTM_MINTR(msg...) \ 124 do { \ 125 if ((mlan_drvdbg & MINTR) && (print_callback)) \ 126 print_callback(MNULL, MINTR, msg); \ 127 } while (0) 128 #define PRINTM_MEVENT(msg...) \ 129 do { \ 130 if ((mlan_drvdbg & MEVENT) && (print_callback)) \ 131 print_callback(MNULL, MEVENT, msg); \ 132 } while (0) 133 #define PRINTM_MCMND(msg...) \ 134 do { \ 135 if ((mlan_drvdbg & MCMND) && (print_callback)) \ 136 print_callback(MNULL, MCMND, msg); \ 137 } while (0) 138 #define PRINTM_MDATA(msg...) \ 139 do { \ 140 if ((mlan_drvdbg & MDATA) && (print_callback)) \ 141 print_callback(MNULL, MDATA, msg); \ 142 } while (0) 143 #define PRINTM_MERROR(msg...) \ 144 do { \ 145 if ((mlan_drvdbg & MERROR) && (print_callback)) \ 146 print_callback(MNULL, MERROR, msg); \ 147 } while (0) 148 #define PRINTM_MFATAL(msg...) \ 149 do { \ 150 if ((mlan_drvdbg & MFATAL) && (print_callback)) \ 151 print_callback(MNULL, MFATAL, msg); \ 152 } while (0) 153 #define PRINTM_MMSG(msg...) \ 154 do { \ 155 if ((mlan_drvdbg & MMSG) && (print_callback)) \ 156 print_callback(MNULL, MMSG, msg); \ 157 } while (0) 158 159 #define PRINTM(level, msg...) PRINTM_##level((char *)msg) 160 161 /** Log debug message */ 162 #ifdef __GNUC__ 163 #define PRINTM_NETINTF(level, pmpriv) \ 164 do { \ 165 if ((mlan_drvdbg & level) && pmpriv && \ 166 pmpriv->adapter->callbacks.moal_print_netintf) \ 167 pmpriv->adapter->callbacks.moal_print_netintf( \ 168 pmpriv->adapter->pmoal_handle, \ 169 pmpriv->bss_index, level); \ 170 } while (0) 171 #endif /* __GNUC__ */ 172 173 /** Max hex dump data length */ 174 #define MAX_DATA_DUMP_LEN 64 175 176 /** Debug hexdump for level-1 debugging */ 177 #define DBG_HEXDUMP(level, x, y, z) \ 178 do { \ 179 if ((mlan_drvdbg & level) && print_callback) \ 180 print_callback(MNULL, MHEX_DUMP | level, x, y, z); \ 181 } while (0) 182 183 #else /* DEBUG_LEVEL1 */ 184 185 #define PRINTM(level, msg...) \ 186 do { \ 187 } while (0) 188 189 #define PRINTM_NETINTF(level, pmpriv) \ 190 do { \ 191 } while (0) 192 193 /** Debug hexdump for level-1 debugging */ 194 #define DBG_HEXDUMP(level, x, y, z) \ 195 do { \ 196 } while (0) 197 198 /** Hexdump for debugging */ 199 #define HEXDUMP(x, y, z) \ 200 do { \ 201 } while (0) 202 203 #define PRINTM_GET_SYS_TIME(level, psec, pusec) \ 204 do { \ 205 } while (0) 206 207 #endif /* DEBUG_LEVEL1 */ 208 209 /* Reason Code 3: STA is leaving (or has left) IBSS or ESS */ 210 #define DEF_DEAUTH_REASON_CODE (0x3) 211 212 /** Log entry point for debugging */ 213 #define ENTER() \ 214 do { \ 215 PRINTM(MENTRY, "Enter: %s\n", __func__); \ 216 } while (0) 217 218 /** Log exit point for debugging */ 219 #define LEAVE() \ 220 do { \ 221 PRINTM(MENTRY, "Leave: %s\n", __func__); \ 222 } while (0) 223 224 /** Find minimum */ 225 #ifndef MIN 226 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 227 #endif 228 229 /** Find maximum */ 230 #ifndef MAX 231 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 232 #endif 233 234 #ifdef memset 235 #undef memset 236 #endif 237 /** Memset routine */ 238 #define memset(adapter, s, c, len) \ 239 (adapter->callbacks.moal_memset(adapter->pmoal_handle, s, c, len)) 240 241 #ifdef memmove 242 #undef memmove 243 #endif 244 /** Memmove routine */ 245 #define memmove(adapter, dest, src, len) \ 246 (adapter->callbacks.moal_memmove(adapter->pmoal_handle, dest, src, len)) 247 248 #ifdef memcpy 249 #undef memcpy 250 #endif 251 /** Memcpy routine */ 252 #define memcpy(adapter, to, from, len) \ 253 (adapter->callbacks.moal_memcpy(adapter->pmoal_handle, to, from, len)) 254 /* memcpy_ext rountine */ 255 #define memcpy_ext(adapter, to, from, len, size) \ 256 (adapter->callbacks.moal_memcpy_ext(adapter->pmoal_handle, to, from, \ 257 len, size)) 258 259 #ifdef memcmp 260 #undef memcmp 261 #endif 262 /** Memcmp routine */ 263 #define memcmp(adapter, s1, s2, len) \ 264 (adapter->callbacks.moal_memcmp(adapter->pmoal_handle, s1, s2, len)) 265 266 /** Find number of elements */ 267 #ifndef NELEMENTS 268 #define NELEMENTS(x) (sizeof(x) / sizeof(x[0])) 269 #endif 270 271 /** SWAP: swap t_u8 */ 272 #define SWAP_U8(a, b) \ 273 { \ 274 t_u8 t; \ 275 t = a; \ 276 a = b; \ 277 b = t; \ 278 } 279 280 /** SWAP: swap t_u8 */ 281 #define SWAP_U16(a, b) \ 282 { \ 283 t_u16 t; \ 284 t = a; \ 285 a = b; \ 286 b = t; \ 287 } 288 289 /** 16 bits byte swap */ 290 #define swap_byte_16(x) \ 291 ((t_u16)((((t_u16)(x)&0x00ffU) << 8) | (((t_u16)(x)&0xff00U) >> 8))) 292 293 /** 32 bits byte swap */ 294 #define swap_byte_32(x) \ 295 ((t_u32)((((t_u32)(x)&0x000000ffUL) << 24) | \ 296 (((t_u32)(x)&0x0000ff00UL) << 8) | \ 297 (((t_u32)(x)&0x00ff0000UL) >> 8) | \ 298 (((t_u32)(x)&0xff000000UL) >> 24))) 299 300 /** 64 bits byte swap */ 301 #define swap_byte_64(x) \ 302 ((t_u64)((t_u64)(((t_u64)(x)&0x00000000000000ffULL) << 56) | \ 303 (t_u64)(((t_u64)(x)&0x000000000000ff00ULL) << 40) | \ 304 (t_u64)(((t_u64)(x)&0x0000000000ff0000ULL) << 24) | \ 305 (t_u64)(((t_u64)(x)&0x00000000ff000000ULL) << 8) | \ 306 (t_u64)(((t_u64)(x)&0x000000ff00000000ULL) >> 8) | \ 307 (t_u64)(((t_u64)(x)&0x0000ff0000000000ULL) >> 24) | \ 308 (t_u64)(((t_u64)(x)&0x00ff000000000000ULL) >> 40) | \ 309 (t_u64)(((t_u64)(x)&0xff00000000000000ULL) >> 56))) 310 311 #ifdef BIG_ENDIAN_SUPPORT 312 /** Convert ulong n/w to host */ 313 #define mlan_ntohl(x) x 314 /** Convert host ulong to n/w */ 315 #define mlan_htonl(x) x 316 /** Convert n/w to host */ 317 #define mlan_ntohs(x) x 318 /** Convert host to n/w */ 319 #define mlan_htons(x) x 320 /** Convert from 16 bit little endian format to CPU format */ 321 #define wlan_le16_to_cpu(x) swap_byte_16(x) 322 /** Convert from 32 bit little endian format to CPU format */ 323 #define wlan_le32_to_cpu(x) swap_byte_32(x) 324 /** Convert from 64 bit little endian format to CPU format */ 325 #define wlan_le64_to_cpu(x) swap_byte_64(x) 326 /** Convert to 16 bit little endian format from CPU format */ 327 #define wlan_cpu_to_le16(x) swap_byte_16(x) 328 /** Convert to 32 bit little endian format from CPU format */ 329 #define wlan_cpu_to_le32(x) swap_byte_32(x) 330 /** Convert to 64 bit little endian format from CPU format */ 331 #define wlan_cpu_to_le64(x) swap_byte_64(x) 332 333 /** Convert TxPD to little endian format from CPU format */ 334 #define endian_convert_TxPD(x) \ 335 { \ 336 (x)->tx_pkt_length = wlan_cpu_to_le16((x)->tx_pkt_length); \ 337 (x)->tx_pkt_offset = wlan_cpu_to_le16((x)->tx_pkt_offset); \ 338 (x)->tx_pkt_type = wlan_cpu_to_le16((x)->tx_pkt_type); \ 339 (x)->tx_control = wlan_cpu_to_le32((x)->tx_control); \ 340 (x)->tx_control_1 = wlan_cpu_to_le32((x)->tx_control_1); \ 341 } 342 /** Convert RxPD from little endian format to CPU format */ 343 #define endian_convert_RxPD(x) \ 344 { \ 345 (x)->rx_pkt_length = wlan_le16_to_cpu((x)->rx_pkt_length); \ 346 (x)->rx_pkt_offset = wlan_le16_to_cpu((x)->rx_pkt_offset); \ 347 (x)->rx_pkt_type = wlan_le16_to_cpu((x)->rx_pkt_type); \ 348 (x)->seq_num = wlan_le16_to_cpu((x)->seq_num); \ 349 (x)->rx_info = wlan_le32_to_cpu((x)->rx_info); 350 } 351 352 /** Convert RxPD extra header from little endian format to CPU format */ 353 #define endian_convert_RxPD_extra_header(x) \ 354 do { \ 355 (x)->channel_flags = wlan_le16_to_cpu((x)->channel_flags); \ 356 (x)->vht_sig1 = wlan_le32_to_cpu((x)->vht_sig1); \ 357 (x)->vht_sig2 = wlan_le32_to_cpu((x)->vht_sig2); \ 358 } while (0) 359 #else 360 /** Convert ulong n/w to host */ 361 #define mlan_ntohl(x) swap_byte_32(x) 362 /** Convert host ulong to n/w */ 363 #define mlan_htonl(x) swap_byte_32(x) 364 /** Convert n/w to host */ 365 #define mlan_ntohs(x) swap_byte_16(x) 366 /** Convert host to n/w */ 367 #define mlan_htons(x) swap_byte_16(x) 368 /** Do nothing */ 369 #define wlan_le16_to_cpu(x) x 370 /** Do nothing */ 371 #define wlan_le32_to_cpu(x) x 372 /** Do nothing */ 373 #define wlan_le64_to_cpu(x) x 374 /** Do nothing */ 375 #define wlan_cpu_to_le16(x) x 376 /** Do nothing */ 377 #define wlan_cpu_to_le32(x) x 378 /** Do nothing */ 379 #define wlan_cpu_to_le64(x) x 380 381 /** Convert TxPD to little endian format from CPU format */ 382 #define endian_convert_TxPD(x) \ 383 do { \ 384 } while (0) 385 /** Convert RxPD from little endian format to CPU format */ 386 #define endian_convert_RxPD(x) \ 387 do { \ 388 } while (0) 389 /** Convert RxPD extra header from little endian format to CPU format */ 390 #define endian_convert_RxPD_extra_header(x) \ 391 do { \ 392 } while (0) 393 #endif /* BIG_ENDIAN_SUPPORT */ 394 395 /** Global moal_assert_callback */ 396 extern t_void (*assert_callback)(t_void *pmoal_handle, t_u32 cond); 397 398 /** Assertion */ 399 #define MASSERT(cond) \ 400 do { \ 401 if (!(cond)) { \ 402 PRINTM(MFATAL, "ASSERT: %s: %i\n", __func__, \ 403 __LINE__); \ 404 if (assert_callback) { \ 405 assert_callback(MNULL, (t_ptr)(cond)); \ 406 } else { \ 407 do { \ 408 } while (1); \ 409 } \ 410 } \ 411 } while (0) 412 413 /** Maximum event buffer size */ 414 #define MAX_EVENT_SIZE (3 * 1024) 415 416 #ifdef STA_SUPPORT 417 /** Maximum buffer size for ARP filter */ 418 #define ARP_FILTER_MAX_BUF_SIZE 68 419 #endif /* STA_SUPPORT */ 420 421 /** 60 seconds */ 422 #define MRVDRV_TIMER_60S 60000 423 /** 10 seconds */ 424 #define MRVDRV_TIMER_10S 10000 425 /** 5 seconds */ 426 #define MRVDRV_TIMER_5S 5000 427 /** 3 seconds */ 428 #define MRVDRV_TIMER_3S 3000 429 /** 1 second */ 430 #define MRVDRV_TIMER_1S 1000 431 432 /** Maximum size of multicast list */ 433 #define MRVDRV_MAX_MULTICAST_LIST_SIZE 32 434 /** Maximum size of channel */ 435 #define MRVDRV_MAX_CHANNEL_SIZE 14 436 /** Maximum length of SSID */ 437 #define MRVDRV_MAX_SSID_LENGTH 32 438 /** WEP list macros & data structures */ 439 /** Size of key buffer in bytes */ 440 #define MRVL_KEY_BUFFER_SIZE_IN_BYTE 16 441 /** Maximum length of WPA key */ 442 #define MRVL_MAX_KEY_WPA_KEY_LENGTH 32 443 444 /** Default listen interval */ 445 #define MLAN_DEFAULT_LISTEN_INTERVAL 20 446 447 /** Maximum number of region codes */ 448 #define MRVDRV_MAX_REGION_CODE 9 449 450 /** Maximum number of CFP codes for BG */ 451 #define MRVDRV_MAX_CFP_CODE_BG 0 452 /** Maximum number of CFP codes for A */ 453 #define MRVDRV_MAX_CFP_CODE_A 5 454 455 /** high rx pending packets */ 456 #define HIGH_RX_PENDING 1000 457 /** low rx pending packets */ 458 #define LOW_RX_PENDING 800 459 460 /** Default region code */ 461 #define MRVDRV_DEFAULT_REGION_CODE 0x10 462 /** Default country code */ 463 #define MRVDRV_DEFAULT_COUNTRY_CODE "US" 464 465 /** Japan country code */ 466 #define COUNTRY_CODE_JP_40 0x40 467 /** Japan special country code */ 468 #define COUNTRY_CODE_JP_FF 0xFF 469 470 /** Default factor for calculating beacon average */ 471 #define DEFAULT_BCN_AVG_FACTOR 8 472 /** Default factor for calculating data average */ 473 #define DEFAULT_DATA_AVG_FACTOR 8 474 475 /** The first valid channel for use */ 476 #define FIRST_VALID_CHANNEL 0xff 477 /** Default Ad-Hoc channel */ 478 #define DEFAULT_AD_HOC_CHANNEL 6 479 /** Default Ad-Hoc channel A */ 480 #define DEFAULT_AD_HOC_CHANNEL_A 36 481 482 /** Number of WEP keys */ 483 #define MRVL_NUM_WEP_KEY (4) 484 485 /** Default multiple DTIM */ 486 #define MRVDRV_DEFAULT_MULTIPLE_DTIM 1 487 488 /** Default beacon missing timeout */ 489 #define DEFAULT_BCN_MISS_TIMEOUT 10 490 491 /** Maximum buffer space for beacons retrieved from scan responses */ 492 #define MAX_SCAN_BEACON_BUFFER 102400 493 /** Default buffer space for beacons retrieved from scan responses */ 494 #define DEFAULT_SCAN_BEACON_BUFFER 4096 495 496 /** 497 * @brief Buffer pad space for newly allocated beacons/probe responses 498 * 499 * Beacons are typically 6 bytes longer than an equivalent probe response. 500 * For each scan response stored, allocate an extra byte pad at the end to 501 * allow easy expansion to store a beacon in the same memory a probe response 502 * previously contained 503 */ 504 #define SCAN_BEACON_ENTRY_PAD 6 505 506 /** Scan time specified in the channel TLV 507 * for each channel for passive scans 508 */ 509 #define MRVDRV_PASSIVE_SCAN_CHAN_TIME 200 510 511 /** Scan time specified in the channel TLV 512 * for each channel for active scans 513 */ 514 #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 200 515 516 /** Scan time specified in the channel TLV 517 * for each channel for specific scans 518 */ 519 #define MRVDRV_SPECIFIC_SCAN_CHAN_TIME 110 520 521 /** 522 * Max total scan time in milliseconds 523 * The total scan time should be less than scan command timeout value (20s) 524 */ 525 #define MRVDRV_MAX_TOTAL_SCAN_TIME (MRVDRV_TIMER_10S * 2 - MRVDRV_TIMER_1S) 526 527 /** Offset for GTK as it has version to skip past for GTK */ 528 #define RSN_GTK_OUI_OFFSET 2 529 530 /** If OUI is not found */ 531 #define MLAN_OUI_NOT_PRESENT 0 532 /** If OUI is found */ 533 #define MLAN_OUI_PRESENT 1 534 535 /** Is cmd_resp, event or data packet received? */ 536 #define IS_CARD_RX_RCVD(adapter) \ 537 (adapter->cmd_resp_received || adapter->event_received || \ 538 adapter->data_received) 539 #ifdef USB 540 /** Type length */ 541 #define MLAN_TYPE_LEN 4 542 /** Type Command */ 543 #define MLAN_USB_TYPE_CMD 0xF00DFACE 544 /** Type VDLL */ 545 #define MLAN_USB_TYPE_VDLL 0xF00DC0DE 546 /** Type Data */ 547 #define MLAN_USB_TYPE_DATA 0xBEADC0DE 548 /** Type Event */ 549 #define MLAN_USB_TYPE_EVENT 0xBEEFFACE 550 #endif /* USB */ 551 /** Type command */ 552 #define MLAN_TYPE_CMD 1 553 /** Type data */ 554 #define MLAN_TYPE_DATA 0 555 /** Type event */ 556 #define MLAN_TYPE_EVENT 3 557 /** Type vdll */ 558 #define MLAN_TYPE_VDLL 4 559 #ifdef SDIO 560 /** Type single port aggr data */ 561 #define MLAN_TYPE_SPA_DATA 10 562 /** OFFSET of 512 block number */ 563 #define OFFSET_OF_BLOCK_NUMBER 15 564 /** OFFSET of SDIO Header */ 565 #define OFFSET_OF_SDIO_HEADER 28 566 /** sdio max rx size for cmd53, 255 * 256, reserve 1 block for DMA alignment */ 567 #define SDIO_CMD53_MAX_SIZE 65280 568 #define MAX_SUPPORT_AMSDU_SIZE 4096 569 /** Maximum numbfer of registers to read for multiple port */ 570 #if defined(SD8887) || defined(SD8997) || defined(SD8977) || \ 571 defined(SD8987) || defined(SD9098) || defined(SD9097) || \ 572 defined(SDNW62X) || defined(SD8978) || defined(SD9177) 573 #define MAX_MP_REGS 196 574 #else 575 /* upto 0xB7 */ 576 #define MAX_MP_REGS 184 577 #endif 578 /** Maximum port */ 579 #define MAX_PORT 32 580 /** Maximum port 16 */ 581 #define MAX_PORT_16 (16) 582 583 /** max MP REGS */ 584 #define MAX_MP_REGS_MAX (196) 585 586 /** Multi port TX aggregation buffer size */ 587 #define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (65280) /* 64K - 256 */ 588 589 /** Multi port RX aggregation buffer size */ 590 #define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (65280) /* 64K - 256 */ 591 592 #endif /* SDIO */ 593 594 /** Minimum BA threshold */ 595 #define MIN_BA_THRESHOLD 16 596 597 /** High threshold at which to start drop packets */ 598 #define RX_HIGH_THRESHOLD 1024 599 /** Low threshold to allow Rx BA */ 600 #define RX_LOW_THRESHOLD 128 601 602 #define MFG_CMD_SET_TEST_MODE 1 603 #define MFG_CMD_UNSET_TEST_MODE 0 604 #define MFG_CMD_TX_ANT 0x1004 605 #define MFG_CMD_RX_ANT 0x1005 606 #define MFG_CMD_TX_CONT 0x1009 607 #define MFG_CMD_RF_CHAN 0x100A 608 #define MFG_CMD_CLR_RX_ERR 0x1010 609 #define MFG_CMD_TX_FRAME 0x1021 610 #define MFG_CMD_RF_BAND_AG 0x1034 611 #define MFG_CMD_RF_CHANNELBW 0x1044 612 #define MFG_CMD_RADIO_MODE_CFG 0x1211 613 #define MFG_CMD_CONFIG_MAC_HE_TB_TX 0x110A 614 615 /** Debug command number */ 616 #define DBG_CMD_NUM 10 617 618 /** Info for debug purpose */ 619 typedef struct _wlan_dbg { 620 /** Number of host to card command failures */ 621 t_u32 num_cmd_host_to_card_failure; 622 /** Number of host to card sleep confirm failures */ 623 t_u32 num_cmd_sleep_cfm_host_to_card_failure; 624 /** Number of host to card Tx failures */ 625 t_u32 num_tx_host_to_card_failure; 626 /** Number of card to host command/event failures */ 627 t_u32 num_cmdevt_card_to_host_failure; 628 /** Number of card to host Rx failures */ 629 t_u32 num_rx_card_to_host_failure; 630 /** Number of interrupt read failures */ 631 t_u32 num_int_read_failure; 632 /** Last interrupt status */ 633 t_u32 last_int_status; 634 /** Number of allocate buffer failure */ 635 t_u32 num_alloc_buffer_failure; 636 /** Number of pkt dropped */ 637 t_u32 num_pkt_dropped; 638 /** Number of deauthentication events */ 639 t_u32 num_event_deauth; 640 /** Number of disassosiation events */ 641 t_u32 num_event_disassoc; 642 /** Number of link lost events */ 643 t_u32 num_event_link_lost; 644 /** Number of deauthentication commands */ 645 t_u32 num_cmd_deauth; 646 /** Number of association comamnd successes */ 647 t_u32 num_cmd_assoc_success; 648 /** Number of association command failures */ 649 t_u32 num_cmd_assoc_failure; 650 /** Number of consecutive association command failures */ 651 t_u32 num_cons_assoc_failure; 652 653 /** Timeout command ID */ 654 t_u16 timeout_cmd_id; 655 /** Timeout command action */ 656 t_u16 timeout_cmd_act; 657 /** List of last command IDs */ 658 t_u16 last_cmd_id[DBG_CMD_NUM]; 659 /** List of last command actions */ 660 t_u16 last_cmd_act[DBG_CMD_NUM]; 661 /** Last command index */ 662 t_u16 last_cmd_index; 663 /** List of last command response IDs */ 664 t_u16 last_cmd_resp_id[DBG_CMD_NUM]; 665 /** Last command response index */ 666 t_u16 last_cmd_resp_index; 667 /** List of last events */ 668 t_u16 last_event[DBG_CMD_NUM]; 669 /** Last event index */ 670 t_u16 last_event_index; 671 /** Number of no free command node */ 672 t_u16 num_no_cmd_node; 673 } wlan_dbg; 674 675 /** Hardware status codes */ 676 typedef enum _WLAN_HARDWARE_STATUS { 677 WlanHardwareStatusReady, 678 WlanHardwareStatusGetHwSpec, 679 WlanHardwareStatusGetHwSpecdone, 680 WlanHardwareStatusInitializing, 681 WlanHardwareStatusInitdone, 682 WlanHardwareStatusReset, 683 WlanHardwareStatusClosing, 684 WlanHardwareStatusNotReady 685 } WLAN_HARDWARE_STATUS; 686 687 /** WLAN_802_11_POWER_MODE */ 688 typedef enum _WLAN_802_11_POWER_MODE { 689 Wlan802_11PowerModeCAM, 690 Wlan802_11PowerModePSP 691 } WLAN_802_11_POWER_MODE; 692 693 /** tx param */ 694 typedef struct _mlan_tx_param { 695 /** next packet length */ 696 t_u32 next_pkt_len; 697 } mlan_tx_param; 698 699 /** PS_STATE */ 700 typedef enum _PS_STATE { 701 PS_STATE_AWAKE, 702 PS_STATE_PRE_SLEEP, 703 PS_STATE_SLEEP_CFM, 704 PS_STATE_SLEEP 705 } PS_STATE; 706 707 /** Minimum flush timer for win size of 1 is 50 ms */ 708 #define MIN_FLUSH_TIMER_MS 50 709 /** Minimum flush timer for win size of 1 is 15 ms */ 710 #define MIN_FLUSH_TIMER_15_MS 15 711 712 /** Tx BA stream table */ 713 typedef struct _TxBAStreamTbl TxBAStreamTbl; 714 715 /** Add BA parameter data structure */ 716 typedef struct { 717 /** Window size for initiator */ 718 t_u32 tx_win_size; 719 /** Window size for receiver */ 720 t_u32 rx_win_size; 721 /** Block ack timeout */ 722 t_u32 timeout; 723 /** amsdu support for ADDBA request */ 724 t_u8 tx_amsdu; 725 /** amsdu support for ADDBA response */ 726 t_u8 rx_amsdu; 727 } add_ba_param_t; 728 729 /** Tx aggregation data structure */ 730 typedef struct _txAggr_t { 731 /** AMPDU user */ 732 t_u8 ampdu_user; 733 /** AMPDU AP */ 734 t_u8 ampdu_ap; 735 /** AMSDU */ 736 t_u8 amsdu; 737 } tx_aggr_t; 738 739 /** del ba threshold */ 740 #define DEL_BA_THRESHOLD 10 741 /** BA stream status */ 742 typedef enum _baStatus_e { 743 BA_STREAM_NOT_SETUP = 0, 744 BA_STREAM_SETUP_INPROGRESS, 745 BA_STREAM_SETUP_COMPLETE 746 } baStatus_e; 747 748 /** RA list table */ 749 typedef struct _raListTbl raListTbl, *praListTbl; 750 751 /** RA list table */ 752 struct _raListTbl { 753 /** Pointer to previous node */ 754 raListTbl *pprev; 755 /** Pointer to next node */ 756 raListTbl *pnext; 757 /** Buffer list head */ 758 mlan_list_head buf_head; 759 /** RA list buffer */ 760 t_u8 ra[MLAN_MAC_ADDR_LENGTH]; 761 /** total packets in RA list */ 762 t_u16 total_pkts; 763 /** packets received */ 764 t_u16 packet_count; 765 /** packet count threshold to setup BA */ 766 t_u8 ba_packet_threshold; 767 /** is 11n enabled */ 768 t_u8 is_wmm_enabled; 769 /** max amsdu size */ 770 t_u16 max_amsdu; 771 /** BA stream status */ 772 baStatus_e ba_status; 773 /** del ba count */ 774 t_u8 del_ba_count; 775 /** amsdu in ampdu flag */ 776 t_u8 amsdu_in_ampdu; 777 /** tdls flag */ 778 t_u8 is_tdls_link; 779 /** tx_pause flag */ 780 t_u8 tx_pause; 781 }; 782 783 /** TID table */ 784 typedef struct _tidTbl { 785 /** RA list head */ 786 mlan_list_head ra_list; 787 /** Current RA list */ 788 raListTbl *ra_list_curr; 789 } tid_tbl_t; 790 791 /** Highest priority setting for a packet (uses voice AC) */ 792 #define WMM_HIGHEST_PRIORITY 7 793 /** Highest priority TID */ 794 #define HIGH_PRIO_TID 7 795 /** Lowest priority TID */ 796 #define LOW_PRIO_TID 0 797 /** No packet priority (< lowest) */ 798 #define NO_PKT_PRIO_TID -1 799 800 /** Max driver packet delay in msec */ 801 #define WMM_DRV_DELAY_MAX 510 802 803 /** Struct of WMM DESC */ 804 typedef struct _wmm_desc { 805 /** TID table */ 806 tid_tbl_t tid_tbl_ptr[MAX_NUM_TID]; 807 /** Packets out */ 808 t_u32 packets_out[MAX_NUM_TID]; 809 /** Packets queued */ 810 t_u32 pkts_queued[MAX_NUM_TID]; 811 /** Packets paused */ 812 t_u32 pkts_paused[MAX_NUM_TID]; 813 /** Spin lock to protect ra_list */ 814 t_void *ra_list_spinlock; 815 816 /** AC status */ 817 WmmAcStatus_t ac_status[MAX_AC_QUEUES]; 818 /** AC downgraded values */ 819 mlan_wmm_ac_e ac_down_graded_vals[MAX_AC_QUEUES]; 820 821 /** Max driver packet delay sent to the firmware for expiry eval */ 822 t_u32 drv_pkt_delay_max; 823 824 /** WMM queue priority table */ 825 t_u8 queue_priority[MAX_AC_QUEUES]; 826 /** User priority packet transmission control */ 827 t_u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */ 828 829 /** Number of transmit packets queued */ 830 mlan_scalar tx_pkts_queued; 831 /** Tracks highest priority with a packet queued */ 832 mlan_scalar highest_queued_prio; 833 } wmm_desc_t; 834 835 /** Security structure */ 836 typedef struct _wlan_802_11_security_t { 837 /** WPA enabled flag */ 838 t_u8 wpa_enabled; 839 /** E-Supplicant enabled flag */ 840 t_u8 ewpa_enabled; 841 /** WPA2 enabled flag */ 842 t_u8 wpa2_enabled; 843 /** WAPI enabled flag */ 844 t_u8 wapi_enabled; 845 /** WAPI key on flag */ 846 t_u8 wapi_key_on; 847 /** WEP status */ 848 WLAN_802_11_WEP_STATUS wep_status; 849 /** Authentication mode */ 850 t_u32 authentication_mode; 851 /** Encryption mode */ 852 t_u32 encryption_mode; 853 /** Hotspot OSEN enabled */ 854 t_u8 osen_enabled; 855 } wlan_802_11_security_t; 856 857 /** Current Basic Service Set State Structure */ 858 typedef struct { 859 /** BSS descriptor */ 860 BSSDescriptor_t bss_descriptor; 861 /** WMM enable? */ 862 t_u8 wmm_enabled; 863 /** Uapsd enable?*/ 864 t_u8 wmm_uapsd_enabled; 865 /** Band */ 866 t_u16 band; 867 /** Number of rates supported */ 868 t_u32 num_of_rates; 869 /** Supported rates*/ 870 t_u8 data_rates[WLAN_SUPPORTED_RATES]; 871 /** Host MLME flag*/ 872 t_u8 host_mlme; 873 mlan_802_11_mac_addr prev_bssid; 874 t_u8 use_mfp; 875 } current_bss_params_t; 876 877 /** Sleep_params */ 878 typedef struct _sleep_params_t { 879 /** Sleep parameter error */ 880 t_u16 sp_error; 881 /** Sleep parameter offset */ 882 t_u16 sp_offset; 883 /** Sleep parameter stable time */ 884 t_u16 sp_stable_time; 885 /** Sleep parameter calibration control */ 886 t_u8 sp_cal_control; 887 /** Sleep parameter external sleep clock */ 888 t_u8 sp_ext_sleep_clk; 889 /** Sleep parameter reserved */ 890 t_u16 sp_reserved; 891 } sleep_params_t; 892 893 /** Sleep_period */ 894 typedef struct sleep_period_t { 895 /** Sleep period */ 896 t_u16 period; 897 /** Reserved */ 898 t_u16 reserved; 899 } sleep_period_t; 900 901 /** mrvl_wep_key_t */ 902 typedef struct _mrvl_wep_key_t { 903 /** Length */ 904 t_u32 length; 905 /** WEP key index */ 906 t_u32 key_index; 907 /** WEP key length */ 908 t_u32 key_length; 909 /** WEP keys */ 910 t_u8 key_material[MRVL_KEY_BUFFER_SIZE_IN_BYTE]; 911 } mrvl_wep_key_t; 912 913 /** Maximum number of region channel */ 914 #define MAX_REGION_CHANNEL_NUM 2 915 916 /** Region-band mapping table */ 917 typedef struct _region_chan_t { 918 /** TRUE if this entry is valid */ 919 t_u8 valid; 920 /** Region code for US, Japan ... */ 921 t_u8 region; 922 /** Band B/G/A, used for BAND_CONFIG cmd */ 923 t_u16 band; 924 /** Actual No. of elements in the array below */ 925 t_u8 num_cfp; 926 /** chan-freq-txpower mapping table */ 927 chan_freq_power_t *pcfp; 928 } region_chan_t; 929 930 /** State of 11d */ 931 typedef enum _state_11d_t { 932 DISABLE_11D = 0, 933 ENABLE_11D = 1, 934 } state_11d_t; 935 936 #define DEFAULT_11D_STATE DISABLE_11D 937 938 /** Domain regulatory information */ 939 typedef struct _wlan_802_11d_domain_reg { 940 /** dfs_region */ 941 t_u8 dfs_region; 942 /** Country Code */ 943 t_u8 country_code[COUNTRY_CODE_LEN]; 944 /** band that channels in sub_band belong to */ 945 t_u16 band; 946 /** No. of subband in below */ 947 t_u8 no_of_sub_band; 948 /** Subband data to send/last sent */ 949 IEEEtypes_SubbandSet_t sub_band[MRVDRV_MAX_SUBBAND_802_11D]; 950 } wlan_802_11d_domain_reg_t; 951 952 /** Data for state machine */ 953 typedef struct _wlan_802_11d_state { 954 /** True for enabling 11D */ 955 state_11d_t enable_11d; 956 /** True for user enabling 11D */ 957 state_11d_t user_enable_11d; 958 } wlan_802_11d_state_t; 959 960 /** 802.11h State information kept in the 'mlan_private' driver structure */ 961 typedef struct { 962 /** Indicate 11h is enabled from host */ 963 t_bool is_11h_host; 964 /** Indicates whether 11h is enabled in the driver */ 965 t_bool is_11h_enabled; 966 /** Indicates whether 11h is active in the firmware */ 967 t_bool is_11h_active; 968 /** Master device using automatic channel select */ 969 t_bool adhoc_auto_sel_chan; 970 /** Set when driver receives a STOP TX event from fw */ 971 t_bool tx_disabled; 972 /** Channel that ChanSwAnn was received for, non-zero = active */ 973 t_u8 dfs_slave_csa_chan; 974 /** Expiry for above variable, seconds in system time */ 975 t_u32 dfs_slave_csa_expire_at_sec; 976 } wlan_11h_interface_state_t; 977 978 #if defined(UAP_SUPPORT) 979 /** UAP get info callback state kept in the 'mlan_private' driver structure */ 980 typedef struct { 981 /** UAP internal callback after wlan_uap_get_channel */ 982 /** (parameter is really pointer to mlan_private) */ 983 mlan_status (*get_chan_callback)(t_void *); 984 /** current ioctl_req (to be completed in callback) */ 985 pmlan_ioctl_req pioctl_req_curr; 986 /** band config from MrvlIEtypes_channel_band_t */ 987 Band_Config_t bandcfg; 988 /** channel from MrvlIEtypes_channel_band_t */ 989 t_u8 channel; 990 /** beacon period (in msec) from MrvlIEtypes_beacon_period_t */ 991 t_u16 beacon_period; 992 /** dtim period (no unit) from MrvlIEtypes_dtim_period_t */ 993 t_u8 dtim_period; 994 } wlan_uap_get_info_cb_t; 995 #endif 996 997 /** Data structure for WPS information */ 998 typedef struct { 999 /** WPS IE */ 1000 IEEEtypes_VendorSpecific_t wps_ie; 1001 /** Session enable flag */ 1002 t_u8 session_enable; 1003 } wps_t; 1004 1005 /** mlan_operations data structure */ 1006 typedef struct _mlan_operations { 1007 /** cmd init handler */ 1008 mlan_status (*init_cmd)(t_void *priv, t_u8 first_bss); 1009 /** ioctl handler */ 1010 mlan_status (*ioctl)(t_void *adapter, pmlan_ioctl_req pioctl_req); 1011 /** cmd handler */ 1012 mlan_status (*prepare_cmd)(t_void *priv, t_u16 cmd_no, t_u16 cmd_action, 1013 t_u32 cmd_oid, t_void *pioctl_buf, 1014 t_void *pdata_buf, t_void *pcmd_buf); 1015 /** cmdresp handler */ 1016 mlan_status (*process_cmdresp)(t_void *priv, t_u16 cmdresp_no, 1017 t_void *pcmd_buf, t_void *pioctl); 1018 /** rx handler */ 1019 mlan_status (*process_rx_packet)(t_void *adapter, pmlan_buffer pmbuf); 1020 /** event handler */ 1021 mlan_status (*process_event)(t_void *priv); 1022 /** txpd handler */ 1023 t_void *(*process_txpd)(t_void *priv, pmlan_buffer pmbuf); 1024 /** BSS role */ 1025 mlan_bss_role bss_role; 1026 } mlan_operations, *pmlan_operations; 1027 1028 /** Private structure for MLAN */ 1029 typedef struct _mlan_private { 1030 /** Pointer to mlan_adapter */ 1031 struct _mlan_adapter *adapter; 1032 /** BSS index */ 1033 t_u8 bss_index; 1034 /** BSS type */ 1035 t_u8 bss_type; 1036 /** BSS role */ 1037 t_u8 bss_role; 1038 /** BSS virtual flag */ 1039 t_u8 bss_virtual; 1040 /** BSS Priority */ 1041 t_u8 bss_priority; 1042 /** BSS number */ 1043 t_u8 bss_num; 1044 /** Frame type */ 1045 t_u8 frame_type; 1046 /** MAC address information */ 1047 t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH]; 1048 /** Media connection status */ 1049 t_bool media_connected; 1050 1051 /** Current packet filter */ 1052 t_u32 curr_pkt_filter; 1053 /** Infrastructure mode */ 1054 t_u32 bss_mode; 1055 1056 /** Tx packet control */ 1057 t_u32 pkt_tx_ctrl; 1058 1059 /** Tx power level */ 1060 t_s16 tx_power_level; 1061 /** Maximum Tx power level */ 1062 t_s8 max_tx_power_level; 1063 /** Minimum Tx power level */ 1064 t_s8 min_tx_power_level; 1065 /** Tx rate */ 1066 t_u8 tx_rate; 1067 t_u8 tx_rate_info; 1068 /*HE tx tone mode and DCM info*/ 1069 t_u8 ext_tx_rate_info; 1070 /*HE rx tone mode and DCM info*/ 1071 t_u8 rxpd_rx_info; 1072 /** rxpd_htinfo */ 1073 t_u8 rxpd_rate_info; 1074 /** max amsdu size */ 1075 t_u16 max_amsdu; 1076 /** amsdu disable flag */ 1077 t_u8 amsdu_disable; 1078 /** 802.11n Device Capabilities for 2.4GHz */ 1079 t_u32 usr_dot_11n_dev_cap_bg; 1080 /** 802.11n Device Capabilities for 5GHz */ 1081 t_u32 usr_dot_11n_dev_cap_a; 1082 /** MIMO abstraction of MCSs supported by device */ 1083 t_u8 usr_dev_mcs_support; 1084 #ifdef UAP_SUPPORT 1085 /** UAP 11n flag */ 1086 t_u8 is_11n_enabled; 1087 #endif /* UAP_SUPPORT */ 1088 /** UAP 11ac flag */ 1089 t_u8 is_11ac_enabled; 1090 /** UAP 11ax flag */ 1091 t_u8 is_11ax_enabled; 1092 /** tx vht_info */ 1093 t_u8 tx_vhtinfo; 1094 /** rxpd_vhtinfo */ 1095 t_u8 rxpd_vhtinfo; 1096 /** 802.11ac Device Capabilities for 2.4GHz */ 1097 t_u32 usr_dot_11ac_dev_cap_bg; 1098 /** 802.11ac Device Capabilities for 5GHz */ 1099 t_u32 usr_dot_11ac_dev_cap_a; 1100 /** MIMO abstraction of MCSs supported by device */ 1101 t_u32 usr_dot_11ac_mcs_support; 1102 /** user dot 11ac_BW */ 1103 t_u8 usr_dot_11ac_bw; 1104 /** user dot 11ac_opermode_BW */ 1105 t_u8 usr_dot_11ac_opermode_bw; 1106 /** user dot 11ac_opermode_nss */ 1107 t_u8 usr_dot_11ac_opermode_nss; 1108 /** length of hw he capability */ 1109 t_u8 user_hecap_len; 1110 /** user configured 802.11ax HE capability */ 1111 t_u8 user_he_cap[54]; 1112 /** length of hw he capability */ 1113 t_u8 user_2g_hecap_len; 1114 /** user configured 802.11ax HE capability */ 1115 t_u8 user_2g_he_cap[54]; 1116 /** dropped pkts */ 1117 t_u32 num_drop_pkts; 1118 #ifdef UAP_SUPPORT 1119 /** packet forward control */ 1120 t_u8 pkt_fwd; 1121 #endif 1122 /** TX beamforming capability */ 1123 t_u32 tx_bf_cap; 1124 /** Rx PD rate */ 1125 t_u8 rxpd_rate; 1126 /** Bitmap rates */ 1127 t_u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; 1128 /** Data rate */ 1129 t_u32 data_rate; 1130 /** Automatic data rate flag */ 1131 t_u8 is_data_rate_auto; 1132 /** Factor for calculating beacon average */ 1133 t_u16 bcn_avg_factor; 1134 /** Factor for calculating data average */ 1135 t_u16 data_avg_factor; 1136 /** SNR */ 1137 t_s8 snr; 1138 /** Noise Floor */ 1139 t_s8 nf; 1140 /** Last data RSSI */ 1141 t_s16 data_rssi_last; 1142 /** Last data Noise Floor */ 1143 t_s16 data_nf_last; 1144 /** Average data RSSI */ 1145 t_s16 data_rssi_avg; 1146 /** Averag data Noise Floor */ 1147 t_s16 data_nf_avg; 1148 /** Last beacon RSSI */ 1149 t_s16 bcn_rssi_last; 1150 /** Last beacon Noise Floor */ 1151 t_s16 bcn_nf_last; 1152 /** Average beacon RSSI */ 1153 t_s16 bcn_rssi_avg; 1154 /** Average beacon Noise Floor */ 1155 t_s16 bcn_nf_avg; 1156 /** Attempted BSS descriptor */ 1157 BSSDescriptor_t *pattempted_bss_desc; 1158 1159 /** GTK rekey data*/ 1160 mlan_ds_misc_gtk_rekey_data gtk_rekey; 1161 1162 /** Current SSID/BSSID related parameters*/ 1163 current_bss_params_t curr_bss_params; 1164 /** current channel flags */ 1165 t_u32 curr_chan_flags; 1166 /** User selected bands */ 1167 t_u16 config_bands; 1168 1169 /** Beacon period */ 1170 t_u16 beacon_period; 1171 /** Listen interval */ 1172 t_u16 listen_interval; 1173 /** ATIM window */ 1174 t_u16 atim_window; 1175 1176 /** AdHoc channel */ 1177 t_u8 adhoc_channel; 1178 /** AdHoc link sensed flag */ 1179 t_u8 adhoc_is_link_sensed; 1180 /** AdHoc operating state */ 1181 t_u8 adhoc_state; 1182 #if defined(STA_SUPPORT) 1183 /** AdHoc operating state backup */ 1184 t_u8 adhoc_state_prev; 1185 /** AdHoc previous ssid used for Start */ 1186 mlan_802_11_ssid adhoc_last_start_ssid; 1187 #endif 1188 mlan_ds_11h_chan_rep_req chan_rep_req; 1189 /** FSM variable for 11d support */ 1190 wlan_802_11d_state_t state_11d; 1191 /** FSM variable for 11h support */ 1192 wlan_11h_interface_state_t intf_state_11h; 1193 #ifdef UAP_SUPPORT 1194 /** Whether UAP interface has started */ 1195 t_bool uap_bss_started; 1196 /** Whether UAP interface start from hostapd */ 1197 t_bool uap_host_based; 1198 /**UAP operating channel*/ 1199 t_u8 uap_channel; 1200 /**UAP bandwidth*/ 1201 t_u8 uap_bandwidth; 1202 /** state variable for UAP Get Info callback */ 1203 wlan_uap_get_info_cb_t uap_state_chan_cb; 1204 #endif /* UAP_SUPPORT */ 1205 1206 /** Security related */ 1207 /** Encryption parameter */ 1208 wlan_802_11_security_t sec_info; 1209 /** WEP keys */ 1210 mrvl_wep_key_t wep_key[MRVL_NUM_WEP_KEY]; 1211 /** Current WEP key index */ 1212 t_u16 wep_key_curr_index; 1213 /** EWPA query 0: disable, 1: enable */ 1214 t_u8 ewpa_query; 1215 /** Encryption Key*/ 1216 t_u8 wpa_ie[256]; 1217 /** WPA IE length */ 1218 t_u8 wpa_ie_len; 1219 /** GTK set flag */ 1220 t_u8 wpa_is_gtk_set; 1221 /** AES key material */ 1222 mlan_ds_encrypt_key aes_key; 1223 #if defined(STA_SUPPORT) 1224 /* Mgmt Frame Protection config */ 1225 mlan_ds_misc_pmfcfg pmfcfg; 1226 #endif 1227 /** WAPI IE */ 1228 t_u8 wapi_ie[256]; 1229 /** WAPI IE length */ 1230 t_u8 wapi_ie_len; 1231 /** OSEN IE */ 1232 t_u8 osen_ie[256]; 1233 /** OSEN IE length */ 1234 t_u8 osen_ie_len; 1235 /** Pointer to the station table */ 1236 mlan_list_head sta_list; 1237 /** tdls pending queue */ 1238 mlan_list_head tdls_pending_txq; 1239 t_u16 tdls_idle_time; 1240 1241 /** MGMT IE */ 1242 custom_ie mgmt_ie[MAX_MGMT_IE_INDEX]; 1243 /** mgmt frame passthru mask */ 1244 t_u32 mgmt_frame_passthru_mask; 1245 /** WMM required */ 1246 t_u8 wmm_required; 1247 /** WMM enabled */ 1248 t_u8 wmm_enabled; 1249 /** WMM qos info */ 1250 t_u8 wmm_qosinfo; 1251 /** saved WMM qos info */ 1252 t_u8 saved_wmm_qosinfo; 1253 /**host tdls uapsd support*/ 1254 t_u8 host_tdls_uapsd_support; 1255 /**host tdls channel switch support*/ 1256 t_u8 host_tdls_cs_support; 1257 /**supported channel IE len*/ 1258 t_u8 chan_supp_len; 1259 /**save channel support IE*/ 1260 t_u8 chan_supp[MAX_IE_SIZE]; 1261 /**supported regulatory classl IE len*/ 1262 t_u8 supp_regulatory_class_len; 1263 /**save support channel regulatory class IE*/ 1264 t_u8 supp_regulatory_class[MAX_IE_SIZE]; 1265 /**tdls cs off channel*/ 1266 t_u8 tdls_cs_channel; 1267 /** WMM related variable*/ 1268 wmm_desc_t wmm; 1269 1270 /** Pointer to the Transmit BA stream table*/ 1271 mlan_list_head tx_ba_stream_tbl_ptr; 1272 /** Pointer to the priorities for AMSDU/AMPDU table*/ 1273 tx_aggr_t aggr_prio_tbl[MAX_NUM_TID]; 1274 /** Pointer to the priorities for AMSDU/AMPDU table*/ 1275 t_u8 addba_reject[MAX_NUM_TID]; 1276 /** Pointer to the priorities for AMSDU/AMPDU table*/ 1277 t_u8 ibss_ampdu[MAX_NUM_TID]; 1278 /** Pointer to the priorities for AMSDU/AMPDU table*/ 1279 t_u8 ibss_addba_reject[MAX_NUM_TID]; 1280 /** Struct to store ADDBA parameters */ 1281 add_ba_param_t add_ba_param; 1282 /** user rx_win_size */ 1283 t_u32 user_rxwinsize; 1284 /** last rx_seq */ 1285 t_u16 rx_seq[MAX_NUM_TID]; 1286 /** Pointer to the Receive Reordering table*/ 1287 mlan_list_head rx_reorder_tbl_ptr; 1288 /** Lock for Rx packets */ 1289 t_void *rx_pkt_lock; 1290 1291 #ifdef STA_SUPPORT 1292 /** Buffer to store the association response for application retrieval 1293 */ 1294 t_u8 assoc_rsp_buf[MRVDRV_ASSOC_RSP_BUF_SIZE]; 1295 /** Length of the data stored in assoc_rsp_buf */ 1296 t_u32 assoc_rsp_size; 1297 /** Buffer to store the association req IEs */ 1298 t_u8 assoc_req_buf[MRVDRV_ASSOC_RSP_BUF_SIZE]; 1299 /** Length of the data stored in assoc_rsp_buf */ 1300 t_u32 assoc_req_size; 1301 /** Generic IEEE IEs passed from the application to be inserted into the 1302 * association request to firmware 1303 */ 1304 t_u8 gen_ie_buf[MRVDRV_GENIE_BUF_SIZE]; 1305 /** Length of the data stored in gen_ie_buf */ 1306 t_u8 gen_ie_buf_len; 1307 1308 /** disconnect reason code*/ 1309 t_u16 disconnect_reason_code; 1310 t_u8 *pcurr_bcn_buf; 1311 t_u32 curr_bcn_size; 1312 t_void *curr_bcn_buf_lock; 1313 1314 /** WPS */ 1315 wps_t wps; 1316 #endif /* STA_SUPPORT */ 1317 1318 /** function table */ 1319 mlan_operations ops; 1320 /** tx pause flag */ 1321 t_u8 tx_pause; 1322 /** Port Control mode */ 1323 t_u8 port_ctrl_mode; 1324 1325 /** Port open flag */ 1326 t_u8 port_open; 1327 1328 /** Port open flag state at time of association attempt */ 1329 t_u8 prior_port_status; 1330 /** Bypass TX queue */ 1331 mlan_list_head bypass_txq; 1332 /** IP address operation */ 1333 t_u32 op_code; 1334 /** IP address */ 1335 t_u8 ip_addr[IPADDR_LEN]; 1336 t_u32 hotspot_cfg; 1337 #ifdef STA_SUPPORT 1338 ExtCap_t ext_cap; 1339 ExtCap_t def_ext_cap; 1340 #endif 1341 /** interface header len */ 1342 t_u8 intf_hr_len; 1343 #ifdef USB 1344 /** USB data port */ 1345 t_u32 port; 1346 #endif 1347 /** Control TX AMPDU on infra link */ 1348 t_u8 txaggrctrl; 1349 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT) 1350 t_void *psapriv; 1351 #endif 1352 /** rx per packet info */ 1353 t_u8 rx_pkt_info; 1354 /** received amsdu count*/ 1355 t_u32 amsdu_rx_cnt; 1356 /** received msdu count in amsdu*/ 1357 t_u32 msdu_in_rx_amsdu_cnt; 1358 /** tx amsdu count*/ 1359 t_u32 amsdu_tx_cnt; 1360 /** tx msdu count in amsdu*/ 1361 t_u32 msdu_in_tx_amsdu_cnt; 1362 /** channel load info for current channel */ 1363 t_u16 ch_load_param; 1364 /** Noise floor value for current channel */ 1365 t_s16 noise; 1366 /** rx quality info */ 1367 t_u16 rx_quality; 1368 } mlan_private, *pmlan_private; 1369 1370 typedef struct _assoc_logger { 1371 /** vendor specific */ 1372 t_u8 oui[3]; 1373 t_u8 bssid[MLAN_MAC_ADDR_LENGTH]; 1374 t_u8 ssid[MLAN_MAX_SSID_LENGTH]; 1375 t_s32 rssi; 1376 t_u32 channel; 1377 } assoc_logger_data; 1378 1379 /** Tx BA stream table */ 1380 struct _TxBAStreamTbl { 1381 /** TxBAStreamTbl previous node */ 1382 TxBAStreamTbl *pprev; 1383 /** TxBAStreamTbl next node */ 1384 TxBAStreamTbl *pnext; 1385 /** TID */ 1386 int tid; 1387 /** RA */ 1388 t_u8 ra[MLAN_MAC_ADDR_LENGTH]; 1389 /** BA stream status */ 1390 baStatus_e ba_status; 1391 t_u8 amsdu; 1392 }; 1393 1394 /** RX reorder table */ 1395 typedef struct _RxReorderTbl RxReorderTbl; 1396 1397 typedef struct { 1398 /** Timer for flushing */ 1399 t_void *timer; 1400 /** Timer set flag */ 1401 t_u8 timer_is_set; 1402 /** RxReorderTbl ptr */ 1403 RxReorderTbl *ptr; 1404 /** Priv pointer */ 1405 mlan_private *priv; 1406 } reorder_tmr_cnxt_t; 1407 1408 /** RX reorder table */ 1409 struct _RxReorderTbl { 1410 /** RxReorderTbl previous node */ 1411 RxReorderTbl *pprev; 1412 /** RxReorderTbl next node */ 1413 RxReorderTbl *pnext; 1414 /** TID */ 1415 int tid; 1416 /** TA */ 1417 t_u8 ta[MLAN_MAC_ADDR_LENGTH]; 1418 /** Start window */ 1419 int start_win; 1420 /** last_seq */ 1421 int last_seq; 1422 /** Window size */ 1423 int win_size; 1424 /** Pointer to pointer to RxReorderTbl */ 1425 t_void **rx_reorder_ptr; 1426 /** Timer context */ 1427 reorder_tmr_cnxt_t timer_context; 1428 /** BA stream status */ 1429 baStatus_e ba_status; 1430 t_u8 amsdu; 1431 /** no packet drop flag for rx_reorder_tbl */ 1432 t_u8 force_no_drop; 1433 /** flag for check start win */ 1434 t_u8 check_start_win; 1435 /** pkt receive after BA setup */ 1436 t_u8 pkt_count; 1437 /** flush data flag */ 1438 t_u8 flush_data; 1439 }; 1440 1441 /** BSS priority node */ 1442 typedef struct _mlan_bssprio_node mlan_bssprio_node; 1443 1444 /** BSS priority node */ 1445 struct _mlan_bssprio_node { 1446 /** Pointer to previous node */ 1447 mlan_bssprio_node *pprev; 1448 /** Pointer to next node */ 1449 mlan_bssprio_node *pnext; 1450 /** Pointer to priv */ 1451 pmlan_private priv; 1452 }; 1453 1454 /** BSS priority table */ 1455 typedef struct _mlan_bssprio_tbl mlan_bssprio_tbl; 1456 1457 /** BSS priority table */ 1458 struct _mlan_bssprio_tbl { 1459 /** BSS priority list head */ 1460 mlan_list_head bssprio_head; 1461 /** Current priority node */ 1462 mlan_bssprio_node *bssprio_cur; 1463 }; 1464 1465 /** cmd_ctrl_node */ 1466 typedef struct _cmd_ctrl_node cmd_ctrl_node; 1467 1468 /** _cmd_ctrl_node */ 1469 struct _cmd_ctrl_node { 1470 /** Pointer to previous node */ 1471 cmd_ctrl_node *pprev; 1472 /** Pointer to next node */ 1473 cmd_ctrl_node *pnext; 1474 /** Pointer to priv */ 1475 pmlan_private priv; 1476 /** Command number */ 1477 t_u32 cmd_no; 1478 /** Command flag */ 1479 t_u32 cmd_flag; 1480 /** Pointer to mlan_buffer */ 1481 mlan_buffer *cmdbuf; 1482 /** Pointer to mlan_buffer */ 1483 mlan_buffer *respbuf; 1484 /** Command parameter */ 1485 t_void *pdata_buf; 1486 /** Pointer to mlan_ioctl_req if command is from IOCTL */ 1487 t_void *pioctl_buf; 1488 #if defined(PCIE) || defined(SDIO) 1489 /** pre_allocated mlan_buffer for cmd */ 1490 mlan_buffer *pmbuf; 1491 #endif 1492 }; 1493 1494 /** default tdls wmm qosinfo */ 1495 #define DEFAULT_TDLS_WMM_QOS_INFO 15 1496 /** default tdls sleep period */ 1497 #define DEFAULT_TDLS_SLEEP_PERIOD 30 1498 1499 /** TDLS status */ 1500 typedef enum _tdlsStatus_e { 1501 TDLS_NOT_SETUP = 0, 1502 TDLS_SETUP_INPROGRESS, 1503 TDLS_SETUP_COMPLETE, 1504 TDLS_SETUP_FAILURE, 1505 TDLS_TEAR_DOWN, 1506 TDLS_SWITCHING_CHANNEL, 1507 TDLS_IN_BASE_CHANNEL, 1508 TDLS_IN_OFF_CHANNEL, 1509 } tdlsStatus_e; 1510 /** station node */ 1511 typedef struct _sta_node sta_node, *psta_node; 1512 1513 /** station node*/ 1514 struct _sta_node { 1515 /** previous node */ 1516 sta_node *pprev; 1517 /** next node */ 1518 sta_node *pnext; 1519 /** station mac address */ 1520 t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH]; 1521 /** wmm flag */ 1522 t_u8 is_wmm_enabled; 1523 /** 11n flag */ 1524 t_u8 is_11n_enabled; 1525 /** AMPDU STA */ 1526 t_u8 ampdu_sta[MAX_NUM_TID]; 1527 /** last rx_seq */ 1528 t_u16 rx_seq[MAX_NUM_TID]; 1529 /** max amsdu size */ 1530 t_u16 max_amsdu; 1531 /** HT cap */ 1532 IEEEtypes_HTCap_t HTcap; 1533 /** 11ac flag */ 1534 t_u8 is_11ac_enabled; 1535 /** UAP 11ax flag */ 1536 t_u8 is_11ax_enabled; 1537 IEEEtypes_HECap_t he_cap; 1538 /** SNR */ 1539 t_s8 snr; 1540 /** Noise Floor */ 1541 t_s8 nf; 1542 /** peer capability */ 1543 t_u16 capability; 1544 /** tdls status */ 1545 tdlsStatus_e status; 1546 /** flag for host based tdls */ 1547 t_u8 external_tdls; 1548 /** peer support rates */ 1549 t_u8 support_rate[32]; 1550 /** rate size */ 1551 t_u8 rate_len; 1552 /*Qos capability info*/ 1553 t_u8 qos_info; 1554 /** HT info in TDLS setup confirm*/ 1555 IEEEtypes_HTInfo_t HTInfo; 1556 /** peer BSSCO_20_40*/ 1557 IEEEtypes_2040BSSCo_t BSSCO_20_40; 1558 /*Extended capability*/ 1559 IEEEtypes_ExtCap_t ExtCap; 1560 /*RSN IE*/ 1561 IEEEtypes_Generic_t rsn_ie; 1562 /**Link ID*/ 1563 IEEEtypes_LinkIDElement_t link_ie; 1564 /** AID info */ 1565 IEEEtypes_AID_t aid_info; 1566 /** VHT Capabilities IE */ 1567 IEEEtypes_VHTCap_t vht_cap; 1568 /** VHT Operations IE */ 1569 IEEEtypes_VHTOprat_t vht_oprat; 1570 /** HE Capabilities IE */ 1571 IEEEtypes_HECap_t tdls_he_cap; 1572 /** HE Operations IE */ 1573 IEEEtypes_HeOp_t he_op; 1574 /** wapi key on off flag */ 1575 t_u8 wapi_key_on; 1576 /** tx pause status */ 1577 t_u8 tx_pause; 1578 /** station band mode */ 1579 t_u16 bandmode; 1580 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT) 1581 t_void *cm_connectioninfo; 1582 #endif 1583 sta_stats stats; 1584 }; 1585 1586 /** 802.11h State information kept in the 'mlan_adapter' driver structure */ 1587 typedef struct { 1588 /** Min TX Power capability sent to FW for 11h use and fw power control 1589 */ 1590 t_s8 min_tx_power_capability; 1591 /** Max TX Power capability sent to FW for 11h use and fw power control 1592 */ 1593 t_s8 max_tx_power_capability; 1594 /** User provisioned local power constraint sent in association requests 1595 */ 1596 t_s8 usr_def_power_constraint; 1597 /** Received CHANNEL_SWITCH_ANN event */ 1598 t_bool recvd_chanswann_event; 1599 /** Indicates an interface wants to enable master radar detection */ 1600 t_bool master_radar_det_enable_pending; 1601 /** Indicates an interface wants to enable slave radar detection */ 1602 t_bool slave_radar_det_enable_pending; 1603 /** Indicates whether master radar detection active in the firmware */ 1604 t_bool is_master_radar_det_active; 1605 /** Indicates whether slave radar detection active in the firmware */ 1606 t_bool is_slave_radar_det_active; 1607 /** Quiet IE */ 1608 IEEEtypes_Quiet_t quiet_ie; 1609 } wlan_11h_device_state_t; 1610 1611 /** Enumeration for DFS Timestamp represents field */ 1612 enum _dfs_timestamp_repr_e { 1613 /** Ignore entry */ 1614 DFS_TS_REPR_NOT_IN_USE = 0, 1615 /** NOP (Non-Occupancy Period) start time */ 1616 DFS_TS_REPR_NOP_START = 1, 1617 /** CAC (Channel Availability Check) completion time */ 1618 DFS_TS_REPR_CAC_COMPLETION 1619 }; 1620 1621 /** DFS Timestamp type used for marking NOP/CAC events */ 1622 typedef struct _wlan_dfs_timestamp_t wlan_dfs_timestamp_t; 1623 1624 /** DFS Timestamp type used for marking NOP/CAC events */ 1625 struct _wlan_dfs_timestamp_t { 1626 /** Pointer to previous node */ 1627 wlan_dfs_timestamp_t *pprev; 1628 /** Pointer to next node */ 1629 wlan_dfs_timestamp_t *pnext; 1630 /** WLAN Channel number */ 1631 t_u8 channel; 1632 /** What this timestamp represents */ 1633 t_u8 represents; 1634 /** reserved field */ 1635 t_u16 reserved; 1636 /** timestamp - seconds */ 1637 t_u32 ts_sec; 1638 /** timestamp - microseconds */ 1639 t_u32 ts_usec; 1640 }; 1641 1642 /** DFS State information kept in the 'mlan_adapter' driver structure */ 1643 typedef struct { 1644 /** Indicates whether DFS channel check is occurring in firmware */ 1645 t_bool dfs_check_pending; 1646 /** Indicates whether DFS channel check found radar */ 1647 t_bool dfs_radar_found; 1648 /** Channel radar is being checked on. BAND_A is assumed. */ 1649 t_u8 dfs_check_channel; 1650 /** Channel radar is being checked on bandwidth*/ 1651 t_u8 dfs_check_bandwidth; 1652 /** point to the priv which start the DFS check */ 1653 t_void *dfs_check_priv; 1654 /** Timestamp when we got last report, 1655 * to determine if data is old or not. 1656 */ 1657 t_u32 dfs_report_time_sec; 1658 /** List for holding dfs_timestamps for NOP/CAC events */ 1659 mlan_list_head dfs_ts_head; 1660 } wlan_dfs_device_state_t; 1661 1662 /** Enumeration for mlan_ds_11h_radar_det_hndlg stages */ 1663 enum _mlan_ds_11h_rdh_stages { 1664 RDH_OFF = 0, 1665 RDH_CHK_INTFS = 1, 1666 RDH_STOP_TRAFFIC, 1667 RDH_GET_INFO_CHANNEL, 1668 RDH_GET_INFO_BEACON_DTIM, 1669 RDH_SET_CUSTOM_IE, 1670 RDH_REM_CUSTOM_IE, 1671 RDH_STOP_INTFS, 1672 RDH_SET_NEW_CHANNEL, 1673 RDH_RESTART_INTFS, 1674 RDH_RESTART_TRAFFIC 1675 }; 1676 1677 /** State info for Radar Detected Handling kept in 'mlan_adapter' */ 1678 typedef struct { 1679 /** Stage (of Operation) */ 1680 t_u8 stage; 1681 /** Number of interfaces to handle */ 1682 t_u8 priv_list_count; 1683 /** Index of interface in process (used by some stages) */ 1684 t_u8 priv_curr_idx; 1685 /** Current Channel (to leave) */ 1686 t_u8 curr_channel; 1687 /** New Channel (to switch to) */ 1688 t_u8 new_channel; 1689 /** UAP band_config */ 1690 Band_Config_t uap_band_cfg; 1691 /** BEACON*DTIM period (in msec; max of STA/UAP) */ 1692 t_u16 max_bcn_dtim_ms; 1693 /** tx block flag */ 1694 t_u8 tx_block; 1695 /** List of interfaces to handle */ 1696 mlan_private *priv_list[MLAN_MAX_BSS_NUM]; 1697 } wlan_radar_det_hndlg_state_t; 1698 1699 /** DFS/RDH testing exception settings kept in 'mlan_adapter' */ 1700 typedef struct { 1701 /** user-configured CAC period (in msec) */ 1702 t_u32 user_cac_period_msec; 1703 /** user-configured NOP period (in sec) */ 1704 t_u16 user_nop_period_sec; 1705 /** user-configured skip channel change on radar */ 1706 t_bool no_channel_change_on_radar; 1707 /** user-configured new channel to change to on radar */ 1708 t_u8 fixed_new_channel_on_radar; 1709 /** user-configured cac restart */ 1710 t_u8 cac_restart; 1711 /** cac channel */ 1712 t_u8 chan; 1713 /** band cfg */ 1714 Band_Config_t bandcfg; 1715 /** cac time */ 1716 t_u32 millisec_dwell_time; 1717 } wlan_dfs_testing_settings_t; 1718 1719 /** 1720 * @brief Driver measurement state held in 'mlan_adapter' structure 1721 * 1722 * Used to record a measurement request that the driver is pending on 1723 * the result (received measurement report). 1724 */ 1725 typedef struct { 1726 /** 1727 * Dialog token of a pending measurement request/report. Used to 1728 * block execution while waiting for the specific dialog token 1729 */ 1730 t_u8 meas_rpt_pend_on; 1731 1732 /** 1733 * Measurement report received from the firmware that we were pending on 1734 */ 1735 HostCmd_DS_MEASUREMENT_REPORT meas_rpt_returned; 1736 1737 } wlan_meas_state_t; 1738 1739 #ifdef SDIO 1740 /** 1741 * @brief Link buffer into aggregate head buffer 1742 * 1743 * @param pmbuf_aggr Pointer to aggregation buffer 1744 * @param pmbuf Pointer to buffer to copy 1745 */ 1746 static inline t_void wlan_link_buf_to_aggr(pmlan_buffer pmbuf_aggr, 1747 pmlan_buffer pmbuf) 1748 { 1749 /* link new buf at end of list */ 1750 pmbuf->pnext = pmbuf_aggr; 1751 pmbuf->pprev = pmbuf_aggr->pprev; 1752 pmbuf->pparent = pmbuf_aggr; 1753 pmbuf_aggr->pprev->pnext = pmbuf; 1754 pmbuf_aggr->pprev = pmbuf; 1755 pmbuf_aggr->use_count++; 1756 } 1757 1758 /** data structure for SDIO MPA TX */ 1759 typedef struct _sdio_mpa_tx { 1760 /** allocated buf for tx aggreation */ 1761 t_u8 *head_ptr; 1762 /** multiport tx aggregation buffer pointer */ 1763 t_u8 *buf; 1764 /** multiport tx aggregation buffer length */ 1765 t_u32 buf_len; 1766 /** multiport tx aggregation packet count */ 1767 t_u32 pkt_cnt; 1768 /** multiport tx aggregation ports */ 1769 t_u32 ports; 1770 /** multiport tx aggregation starting port */ 1771 t_u16 start_port; 1772 /** multiport tx aggregation enable/disable flag */ 1773 t_u8 enabled; 1774 /** multiport tx aggregation buffer size */ 1775 t_u32 buf_size; 1776 /** multiport tx aggregation pkt aggr limit */ 1777 t_u32 pkt_aggr_limit; 1778 /** multiport write info */ 1779 t_u16 mp_wr_info[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 1780 /** multiport rx aggregation mbuf array */ 1781 pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 1782 } sdio_mpa_tx; 1783 1784 /** data structure for SDIO MPA RX */ 1785 typedef struct _sdio_mpa_rx { 1786 /** allocated buf for rx aggreation */ 1787 t_u8 *head_ptr; 1788 /** multiport rx aggregation buffer pointer */ 1789 t_u8 *buf; 1790 /** multiport rx aggregation buffer length */ 1791 t_u32 buf_len; 1792 /** multiport rx aggregation packet count */ 1793 t_u32 pkt_cnt; 1794 /** multiport rx aggregation ports */ 1795 t_u32 ports; 1796 /** multiport rx aggregation starting port */ 1797 t_u16 start_port; 1798 1799 /** multiport rx aggregation mbuf array */ 1800 pmlan_buffer mbuf_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 1801 /** multiport rx aggregation pkt len array */ 1802 t_u32 len_arr[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 1803 1804 /** multiport rx aggregation enable/disable flag */ 1805 t_u8 enabled; 1806 /** multiport rx aggregation buffer size */ 1807 t_u32 buf_size; 1808 /** multiport rx aggregation pkt aggr limit */ 1809 t_u32 pkt_aggr_limit; 1810 } sdio_mpa_rx; 1811 #endif 1812 1813 #ifdef USB 1814 /** data structure for USB Rx Deaggregation */ 1815 typedef struct _usb_rx_deaggr_params { 1816 /** Rx aggregation control */ 1817 usb_aggr_ctrl_cfg aggr_ctrl; 1818 } usb_rx_deaggr_params; 1819 1820 #define MAX_USB_TX_PORT_NUM 1 1821 /** data structure for USB Tx Aggregation */ 1822 typedef struct _usb_tx_aggr_params { 1823 /** Tx aggregation control */ 1824 usb_aggr_ctrl_cfg aggr_ctrl; 1825 /** allocated pmbuf for tx aggreation */ 1826 pmlan_buffer pmbuf_aggr; 1827 /** packet len used in pmbuf_aggr */ 1828 t_u32 aggr_len; 1829 /** usb_tx_aggr timer */ 1830 t_void *paggr_hold_timer; 1831 /** usb_tx_aggr timer set flag */ 1832 t_u8 aggr_hold_timer_is_set; 1833 /** Timeout duration in milliseconds to wait for aggregation */ 1834 t_u32 hold_timeout_msec; 1835 /** lock for transmission */ 1836 t_void *paggr_lock; 1837 /** port for data transmission */ 1838 t_u32 port; 1839 /** pointer to moal_adatper structure */ 1840 t_void *phandle; 1841 } usb_tx_aggr_params, *pusb_tx_aggr_params; 1842 #endif 1843 1844 /** Type definition of mef_entry*/ 1845 typedef struct _mef_cfg_data { 1846 /** criteria*/ 1847 t_u32 criteria; 1848 /** entry num*/ 1849 t_u16 entry_num; 1850 /** entry pointer*/ 1851 mef_entry_t *pentry; 1852 } mef_cfg_data; 1853 1854 /** Type definition of mef_entry*/ 1855 typedef struct _mef_entry { 1856 /** Flag for auto arp entry*/ 1857 int enable_autoarp_entry; 1858 /** Num for wowlan entry*/ 1859 int num_wowlan_entry; 1860 /** Num for IPv6 neighbor solicitation message offload */ 1861 int num_ipv6_ns_offload; 1862 int clear_mef_entry; 1863 /** criteria*/ 1864 t_u32 criteria; 1865 /** MEF CFG Array to store etted_entry_bitmap; 1866 * Caution: 0-3 is for NVIDIA WHITE/BLACK list entries 1867 * Caution: 4 is for NVIDIA ping entry 1868 * Caution: 5 is for Auto Arp Entry 1869 * Caution: 6 is for wowlan Entry 1870 * Caution: 7 is for IPv6 Neighbor Solicitation offload Entry 1871 */ 1872 mef_entry_t entry[MAX_NUM_ENTRIES]; 1873 } mef_entry; 1874 1875 /** vdll_dnld_ctrl structure */ 1876 typedef struct _vdll_dnld_ctrl { 1877 /** pending VDLL block */ 1878 t_u8 *pending_block; 1879 /* pending VDLL block len */ 1880 t_u16 pending_block_len; 1881 /** memory for VDLL fw image */ 1882 t_u8 *vdll_mem; 1883 /** VDLL fw image len */ 1884 t_u32 vdll_len; 1885 #if defined(SDIO) || defined(PCIE) 1886 /** mlan_buffer for VDLL download */ 1887 mlan_buffer *cmd_buf; 1888 #endif 1889 } vdll_dnld_ctrl, *pvdll_dnld_ctrl; 1890 1891 /** mlan_init_para structure */ 1892 typedef struct _mlan_init_para { 1893 #ifdef MFG_CMD_SUPPORT 1894 /** MFG mode */ 1895 t_u32 mfg_mode; 1896 #endif 1897 #ifdef SDIO 1898 /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */ 1899 t_u32 int_mode; 1900 /** GPIO interrupt pin number */ 1901 t_u32 gpio_pin; 1902 /** SDIO MPA Tx */ 1903 t_u32 mpa_tx_cfg; 1904 /** SDIO MPA Rx */ 1905 t_u32 mpa_rx_cfg; 1906 #endif 1907 /** Auto deep sleep */ 1908 t_u32 auto_ds; 1909 /** IEEE PS mode */ 1910 t_u32 ps_mode; 1911 /** Max Tx buffer size */ 1912 t_u32 max_tx_buf; 1913 /** 802.11d configuration */ 1914 t_u32 cfg_11d; 1915 /** 802.11H DFS Master Radar Detect */ 1916 t_u32 dfs_master_radar_det_en; 1917 /** 802.11H DFS Slave Radar Detect */ 1918 t_u32 dfs_slave_radar_det_en; 1919 /** dev cap mask */ 1920 t_u32 dev_cap_mask; 1921 /** oob independent reset mode */ 1922 t_u32 indrstcfg; 1923 /** passive to active scan */ 1924 t_u8 passive_to_active_scan; 1925 /** uap max sta */ 1926 t_u8 uap_max_sta; 1927 /** dfs w53 cfg */ 1928 t_u8 dfs53cfg; 1929 /** dfs_offload */ 1930 t_u8 dfs_offload; 1931 #ifdef PCIE 1932 /** adma ring size */ 1933 t_u16 ring_size; 1934 #endif 1935 t_u8 ext_scan; 1936 t_u8 mcs32; 1937 } mlan_init_para, *pmlan_init_para; 1938 1939 #ifdef SDIO 1940 typedef struct _mlan_sdio_card_reg { 1941 t_u8 start_rd_port; 1942 t_u8 start_wr_port; 1943 t_u8 base_0_reg; 1944 t_u8 base_1_reg; 1945 t_u8 poll_reg; 1946 t_u8 host_int_enable; 1947 t_u8 host_int_status; 1948 t_u8 status_reg_0; 1949 t_u8 status_reg_1; 1950 t_u8 sdio_int_mask; 1951 t_u32 data_port_mask; 1952 t_u8 max_mp_regs; 1953 t_u8 rd_bitmap_l; 1954 t_u8 rd_bitmap_u; 1955 t_u8 rd_bitmap_1l; 1956 t_u8 rd_bitmap_1u; 1957 t_u8 wr_bitmap_l; 1958 t_u8 wr_bitmap_u; 1959 t_u8 wr_bitmap_1l; 1960 t_u8 wr_bitmap_1u; 1961 t_u8 rd_len_p0_l; 1962 t_u8 rd_len_p0_u; 1963 t_u8 card_config_2_1_reg; 1964 t_u8 cmd_config_0; 1965 t_u8 cmd_config_1; 1966 t_u8 cmd_config_2; 1967 t_u8 cmd_config_3; 1968 t_u8 cmd_rd_len_0; 1969 t_u8 cmd_rd_len_1; 1970 t_u8 cmd_rd_len_2; 1971 t_u8 cmd_rd_len_3; 1972 t_u8 io_port_0_reg; 1973 t_u8 io_port_1_reg; 1974 t_u8 io_port_2_reg; 1975 t_u8 host_int_rsr_reg; 1976 t_u8 host_int_mask_reg; 1977 t_u8 host_int_status_reg; 1978 t_u8 host_restart_reg; 1979 t_u8 card_to_host_event_reg; 1980 t_u8 host_interrupt_mask_reg; 1981 t_u8 card_interrupt_status_reg; 1982 t_u8 card_interrupt_rsr_reg; 1983 t_u8 card_revision_reg; 1984 t_u8 card_ocr_0_reg; 1985 t_u8 card_ocr_1_reg; 1986 t_u8 card_ocr_3_reg; 1987 t_u8 card_config_reg; 1988 t_u8 card_misc_cfg_reg; 1989 t_u8 debug_0_reg; 1990 t_u8 debug_1_reg; 1991 t_u8 debug_2_reg; 1992 t_u8 debug_3_reg; 1993 t_u32 fw_reset_reg; 1994 t_u8 fw_reset_val; 1995 t_u8 fw_dnld_offset_0_reg; 1996 t_u8 fw_dnld_offset_1_reg; 1997 t_u8 fw_dnld_offset_2_reg; 1998 t_u8 fw_dnld_offset_3_reg; 1999 t_u8 fw_dnld_status_0_reg; 2000 t_u8 fw_dnld_status_1_reg; 2001 t_u8 winner_check_reg; 2002 } mlan_sdio_card_reg, *pmlan_sdio_card_reg; 2003 2004 typedef struct _mlan_sdio_card { 2005 const mlan_sdio_card_reg *reg; 2006 /** maximum ports */ 2007 t_u8 max_ports; 2008 /** mp aggregation packet limit */ 2009 t_u8 mp_aggr_pkt_limit; 2010 /** sdio new mode support */ 2011 t_bool supports_sdio_new_mode; 2012 /** max tx aggr buf size */ 2013 t_u32 mp_tx_aggr_buf_size; 2014 /** max rx aggr buf size */ 2015 t_u32 mp_rx_aggr_buf_size; 2016 /** IO port */ 2017 t_u32 ioport; 2018 /** number of interrupt receive */ 2019 t_u32 num_of_irq; 2020 /** max SDIO single port tx size */ 2021 t_u16 max_sp_tx_size; 2022 /** max SDIO single port rx size */ 2023 t_u16 max_sp_rx_size; 2024 /** SDIO multiple port read bitmap */ 2025 t_u32 mp_rd_bitmap; 2026 /** SDIO multiple port write bitmap */ 2027 t_u32 mp_wr_bitmap; 2028 /** SDIO end port from txbufcfg */ 2029 t_u16 mp_end_port; 2030 /** SDIO port mask calculated based on txbufcfg end port */ 2031 t_u32 mp_data_port_mask; 2032 /** Current available port for read */ 2033 t_u8 curr_rd_port; 2034 /** Current available port for write */ 2035 t_u8 curr_wr_port; 2036 /** FW update port number */ 2037 t_u32 mp_update[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX * 2]; 2038 /** Invalid port update count */ 2039 t_u32 mp_invalid_update; 2040 /** Array to store values of SDIO multiple port group registers */ 2041 t_u8 *mp_regs; 2042 /** allocated buf to read SDIO multiple port group registers */ 2043 t_u8 *mp_regs_buf; 2044 /** buffer to handle receive packet */ 2045 t_u8 *rx_buf; 2046 /** allocated buf for receive */ 2047 t_u8 *rx_buffer; 2048 /* see blk_queue_max_segment_size */ 2049 t_u32 max_seg_size; 2050 /* see blk_queue_max_segments */ 2051 t_u16 max_segs; 2052 2053 /** data structure for SDIO MPA TX */ 2054 sdio_mpa_tx mpa_tx; 2055 /** packet number for tx aggr */ 2056 t_u32 mpa_tx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 2057 /** no more packets count*/ 2058 t_u32 mpa_sent_last_pkt; 2059 /** no write_ports count */ 2060 t_u32 mpa_sent_no_ports; 2061 /** last wr_bitmap from FW */ 2062 t_u32 last_recv_wr_bitmap; 2063 /** last wr_bitmap from FW */ 2064 t_u32 last_recv_rd_bitmap; 2065 /** last mp_wr_bitmap */ 2066 t_u32 last_mp_wr_bitmap[SDIO_MP_DBG_NUM]; 2067 /** last ports for cmd53 write data */ 2068 t_u32 last_mp_wr_ports[SDIO_MP_DBG_NUM]; 2069 /** last length for cmd53 write data */ 2070 t_u32 last_mp_wr_len[SDIO_MP_DBG_NUM]; 2071 /** length info for cmd53 write data */ 2072 t_u16 last_mp_wr_info[SDIO_MP_DBG_NUM * SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 2073 /** last curr_wr_port */ 2074 t_u8 last_curr_wr_port[SDIO_MP_DBG_NUM]; 2075 2076 /** buffer for mp debug */ 2077 t_u8 *mpa_buf; 2078 /** length info for mp buf size */ 2079 t_u32 mpa_buf_size; 2080 2081 /** last mp_index */ 2082 t_u8 last_mp_index; 2083 2084 /** data structure for SDIO MPA RX */ 2085 sdio_mpa_rx mpa_rx; 2086 /** packet number for tx aggr */ 2087 t_u32 mpa_rx_count[SDIO_MP_AGGR_DEF_PKT_LIMIT_MAX]; 2088 2089 /** SDIO interrupt mode (0: INT_MODE_SDIO, 1: INT_MODE_GPIO) */ 2090 t_u32 int_mode; 2091 /** GPIO interrupt pin number */ 2092 t_u32 gpio_pin; 2093 2094 /** flag for sdio rx aggr */ 2095 t_bool sdio_rx_aggr_enable; 2096 /** fw rx block size */ 2097 t_u16 sdio_rx_block_size; 2098 } mlan_sdio_card, *pmlan_sdio_card; 2099 #endif 2100 2101 #ifdef PCIE 2102 #define MAX_TXRX_BD 32 2103 #define ADMA_MAX_TXRX_BD 512 2104 #define ADMA_DEF_TXRX_BD 128 2105 /** 128 entry will mapping to 7*/ 2106 #define TXRX_DEF_NUM_DESC 7 2107 /** 8 entry will mapping to 3 */ 2108 #define EVT_NUM_DESC 3 2109 #define MLAN_MAX_TXRX_BD MAX(ADMA_MAX_TXRX_BD, MAX_TXRX_BD) 2110 /** 8 Event buffer ring */ 2111 #define MLAN_MAX_EVT_BD 0x08 2112 typedef struct _mlan_pcie_card_reg { 2113 /* TX buffer description rd pointer */ 2114 t_u32 reg_txbd_rdptr; 2115 /* TX buffer description wr pointer */ 2116 t_u32 reg_txbd_wrptr; 2117 /* RX buffer description rd pointer */ 2118 t_u32 reg_rxbd_rdptr; 2119 /* RX buffer description wr pointer */ 2120 t_u32 reg_rxbd_wrptr; 2121 /** evtbd rdptr register */ 2122 t_u32 reg_evtbd_rdptr; 2123 /** evtbd wrptr register */ 2124 t_u32 reg_evtbd_wrptr; 2125 /** host int mask register */ 2126 t_u16 reg_host_int_mask; 2127 /** host int status mask register*/ 2128 t_u16 reg_host_int_status_mask; 2129 /** host int status register */ 2130 t_u16 reg_host_int_status; 2131 /** host int status clr selection */ 2132 t_u32 reg_host_int_clr_sel; 2133 /** cpu int event register */ 2134 t_u16 reg_cpu_int_event; 2135 /** ip revision register */ 2136 t_u16 reg_ip_rev; 2137 /** revision id register */ 2138 t_u32 reg_rev_id; 2139 /** driver ready register */ 2140 t_u16 reg_drv_ready; 2141 /** cpu int status register */ 2142 t_u16 reg_cpu_int_status; 2143 /** scratch 0 register */ 2144 t_u16 reg_scratch_0; 2145 /** scratch 1 register */ 2146 t_u16 reg_scratch_1; 2147 /** scratch 2 register */ 2148 t_u16 reg_scratch_2; 2149 /** scratch 3 register */ 2150 t_u16 reg_scratch_3; 2151 /** scratch 6 register */ 2152 t_u16 reg_scratch_6; 2153 /** scratch 7 register */ 2154 t_u16 reg_scratch_7; 2155 /** host interrupt mask*/ 2156 t_u32 host_intr_mask; 2157 /** data send interrupt for host*/ 2158 t_u32 host_intr_dnld_done; 2159 /** Data receive interrupt for host */ 2160 t_u32 host_intr_upld_rdy; 2161 /** Command sent interrupt for host */ 2162 t_u32 host_intr_cmd_done; 2163 /** Event ready interrupt for host */ 2164 t_u32 host_intr_event_rdy; 2165 t_u32 host_intr_cmd_dnld; 2166 /* TX/RX buffer description mask */ 2167 t_u32 txrx_rw_ptr_mask; 2168 /* TX/RX buffer description wrap mask */ 2169 t_u32 txrx_rw_ptr_wrap_mask; 2170 /* TX/RX buffer description indication */ 2171 t_u32 txrx_rw_ptr_rollover_ind; 2172 /** ADMA feature */ 2173 t_u8 use_adma; 2174 /** write to clear interrupt status flag */ 2175 t_u8 msi_int_wr_clr; 2176 } mlan_pcie_card_reg, *pmlan_pcie_card_reg; 2177 2178 typedef struct _mlan_pcie_card { 2179 const mlan_pcie_card_reg *reg; 2180 /** PCIE interrupt modes 0: Legacy, 1: MSI, 2:MSI-X */ 2181 t_u32 pcie_int_mode; 2182 /** PCIE function number */ 2183 t_u8 func_num; 2184 /** pending num of tx ring buffer in firmware */ 2185 t_u8 txbd_pending; 2186 /** Write pointer for TXBD ring */ 2187 t_u32 txbd_wrptr; 2188 /** Shadow copy of TXBD read pointer */ 2189 t_u32 txbd_rdptr; 2190 /** TXBD ring size */ 2191 t_u32 txbd_ring_size; 2192 /** Lock for protecting the TX ring */ 2193 t_void *tx_ring_lock; 2194 /** Virtual base address of txbd_ring */ 2195 t_u8 *txbd_ring_vbase; 2196 /** Physical base address of txbd_ring */ 2197 t_u64 txbd_ring_pbase; 2198 /** Ring of buffer descriptors for TX */ 2199 t_void *txbd_ring[MLAN_MAX_TXRX_BD]; 2200 /** A list of mlan_buffer objects used for data tx */ 2201 mlan_buffer *tx_buf_list[MLAN_MAX_TXRX_BD]; 2202 /** Flush indicator for txbd_ring */ 2203 t_bool txbd_flush; 2204 /** txrx data dma ring size */ 2205 t_u16 txrx_bd_size; 2206 /** txrx num desc */ 2207 t_u16 txrx_num_desc; 2208 2209 /** Shadow copy of RXBD write pointer */ 2210 t_u32 rxbd_wrptr; 2211 /** RxBD read pointer */ 2212 t_u32 rxbd_rdptr; 2213 /** RXBD ring size */ 2214 t_u32 rxbd_ring_size; 2215 /** A spinlock for rxbd_ring */ 2216 t_void *rx_ring_lock; 2217 /** Virtual base address of rxbd_ring */ 2218 t_u8 *rxbd_ring_vbase; 2219 /** Physical base address of rxbd_ring */ 2220 t_u64 rxbd_ring_pbase; 2221 /** Ring of buffer descriptors for RX */ 2222 t_void *rxbd_ring[MLAN_MAX_TXRX_BD]; 2223 /** A list of mlan_buffer objects used for data rx */ 2224 mlan_buffer *rx_buf_list[MLAN_MAX_TXRX_BD]; 2225 2226 /** Shadow copy of cmdrsp/evt write pointer */ 2227 t_u32 evtbd_wrptr; 2228 /** Read pointer for cmdrsp/evt ring */ 2229 t_u32 evtbd_rdptr; 2230 /** Size of the cmdrsp/evt ring */ 2231 t_u32 evtbd_ring_size; 2232 /** Virtual base address of evtbd_bd_ring */ 2233 t_u8 *evtbd_ring_vbase; 2234 /** Physical base address of evtbd_bd_ring */ 2235 t_u64 evtbd_ring_pbase; 2236 /** Ring of buffer descriptors for EVENT */ 2237 t_void *evtbd_ring[MLAN_MAX_EVT_BD]; 2238 /** A list of mlan_buffer objects used for EVENT */ 2239 mlan_buffer *evt_buf_list[MLAN_MAX_EVT_BD]; 2240 2241 /** Command buffer */ 2242 mlan_buffer *cmd_buf; 2243 /** Command response buffer */ 2244 mlan_buffer *cmdrsp_buf; 2245 /** Command buffer */ 2246 mlan_buffer *vdll_cmd_buf; 2247 /** last tx_pkt_size */ 2248 t_u32 last_tx_pkt_size[MLAN_MAX_TXRX_BD]; 2249 } mlan_pcie_card, *pmlan_pcie_card; 2250 #endif 2251 2252 #ifdef USB 2253 typedef struct _mlan_usb_card { 2254 /** data structure for USB Rx Deaggregation */ 2255 usb_rx_deaggr_params usb_rx_deaggr; 2256 /** data structure for USB Tx Aggregation */ 2257 usb_tx_aggr_params usb_tx_aggr[MAX_USB_TX_PORT_NUM]; 2258 /** USB sggregation supported by FW */ 2259 t_u8 fw_usb_aggr; 2260 2261 } mlan_usb_card, *pmlan_usb_card; 2262 2263 #endif 2264 2265 typedef struct _mlan_card_info { 2266 /** Max Tx buffer size */ 2267 t_u32 max_tx_buf_size; 2268 /** support V14_FW_API */ 2269 t_u8 v14_fw_api; 2270 /** support V16_FW_API */ 2271 t_u8 v16_fw_api; 2272 /** support V17_FW_API */ 2273 t_u8 v17_fw_api; 2274 /** suppress PS handshake */ 2275 t_u8 supp_ps_handshake; 2276 /** DEFAULT_11N_TX_BF_CAP */ 2277 t_u32 default_11n_tx_bf_cap; 2278 } mlan_card_info, *pmlan_card_info; 2279 2280 typedef struct _mlan_adapter mlan_adapter, *pmlan_adapter; 2281 2282 /**Adapter_operations data structure*/ 2283 typedef struct _adapter_operations { 2284 /**firmware download handler*/ 2285 mlan_status (*dnld_fw)(pmlan_adapter pmadapter, pmlan_fw_image pmfw); 2286 /**interrupt handler*/ 2287 mlan_status (*interrupt)(t_u16 msg_id, pmlan_adapter pmadapter); 2288 /**INT process handler*/ 2289 mlan_status (*process_int_status)(pmlan_adapter pmadapter); 2290 /**host to card handler*/ 2291 mlan_status (*host_to_card)(pmlan_private pmpriv, t_u8 type, 2292 mlan_buffer *pmbuf, 2293 mlan_tx_param *tx_param); 2294 /*wakeup card*/ 2295 mlan_status (*wakeup_card)(pmlan_adapter pmadapter, t_u8 timeout); 2296 /*reset the PM setting of card*/ 2297 mlan_status (*reset_card)(pmlan_adapter adapter); 2298 /** Handle event/cmd complete*/ 2299 mlan_status (*event_complete)(mlan_adapter *pmlan_adapter, 2300 pmlan_buffer pmbuf, mlan_status status); 2301 /** Handle complete receiving data */ 2302 mlan_status (*data_complete)(mlan_adapter *pmlan_adapter, 2303 pmlan_buffer pmbuf, mlan_status status); 2304 /** Handle command response complete */ 2305 mlan_status (*cmdrsp_complete)(mlan_adapter *pmlan_adapter, 2306 pmlan_buffer pmbuf, mlan_status status); 2307 /** Handle rx packet */ 2308 mlan_status (*handle_rx_packet)(mlan_adapter *pmadapter, 2309 pmlan_buffer pmbuf); 2310 /** handle dump interface specific info */ 2311 mlan_status (*debug_dump)(mlan_adapter *pmadapter); 2312 /** disable host interrupt */ 2313 mlan_status (*disable_host_int)(mlan_adapter *pmadapter); 2314 /** enable host interrupt */ 2315 mlan_status (*enable_host_int)(mlan_adapter *pmadapter); 2316 /**Interface header length*/ 2317 t_u32 intf_header_len; 2318 } mlan_adapter_operations; 2319 2320 /** Adapter data structure for MLAN */ 2321 struct _mlan_adapter { 2322 /** MOAL handle structure */ 2323 t_void *pmoal_handle; 2324 /** BSS Attributes */ 2325 mlan_bss_attr bss_attr[MLAN_MAX_BSS_NUM]; 2326 /** Private pointer */ 2327 pmlan_private priv[MLAN_MAX_BSS_NUM]; 2328 /** Total number of Priv number */ 2329 t_u8 priv_num; 2330 /** Priority table for bss */ 2331 mlan_bssprio_tbl bssprio_tbl[MLAN_MAX_BSS_NUM]; 2332 /** Callback table */ 2333 mlan_callbacks callbacks; 2334 /** Init parameters */ 2335 mlan_init_para init_para; 2336 /** mlan_lock for init/shutdown */ 2337 t_void *pmlan_lock; 2338 /** main_proc_lock for main_process */ 2339 t_void *pmain_proc_lock; 2340 /** mlan_processing */ 2341 t_u32 mlan_processing; 2342 /** main_process_cnt */ 2343 t_u32 main_process_cnt; 2344 /** mlan_rx_processing */ 2345 t_u32 mlan_rx_processing; 2346 /** rx_proc_lock for main_rx_process */ 2347 t_void *prx_proc_lock; 2348 /** more_rx_task_flag */ 2349 t_u32 more_rx_task_flag; 2350 /** rx work enable flag */ 2351 t_u8 rx_work_flag; 2352 /* number of rx pkts queued */ 2353 t_u16 rx_pkts_queued; 2354 /** more task flag */ 2355 t_u32 more_task_flag; 2356 /** delay task flag */ 2357 t_u32 delay_task_flag; 2358 /** Max tx buf size */ 2359 t_u16 max_tx_buf_size; 2360 /** Tx buf size */ 2361 t_u16 tx_buf_size; 2362 /** current tx buf size in fw */ 2363 t_u16 curr_tx_buf_size; 2364 /** flush data flag */ 2365 t_u8 flush_data; 2366 /** STATUS variables */ 2367 WLAN_HARDWARE_STATUS hw_status; 2368 /** PnP SUPPORT */ 2369 t_u8 surprise_removed; 2370 /** FW hang report */ 2371 t_u8 fw_hang_report; 2372 2373 /** ECSA support */ 2374 t_u8 ecsa_enable; 2375 2376 /** Get log support */ 2377 t_u8 getlog_enable; 2378 2379 /** Radio on flag */ 2380 t_u16 radio_on; 2381 2382 /** Firmware release number */ 2383 t_u32 fw_release_number; 2384 /** firmware version */ 2385 t_u8 fw_ver; 2386 /** firmware minor version */ 2387 t_u8 fw_min_ver; 2388 /** firmare hotfix version */ 2389 t_u8 fw_hotfix_ver; 2390 /** uap firmware version */ 2391 t_u8 uap_fw_ver; 2392 /** mac address retrun from get_hw_spec */ 2393 t_u8 permanent_addr[MLAN_MAC_ADDR_LENGTH]; 2394 /** Number of antenna used */ 2395 t_u16 number_of_antenna; 2396 /** antenna info */ 2397 t_u8 antinfo; 2398 /** Firmware capability information */ 2399 t_u32 fw_cap_info; 2400 /** Extended firmware capability information */ 2401 t_u32 fw_cap_ext; 2402 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \ 2403 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \ 2404 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X) 2405 /** High byte for 5G, low byte for 2G, like 0x2211 0x22 for 5G, 0x11 for 2406 * 2G */ 2407 t_u16 user_htstream; 2408 #endif 2409 /** vdll ctrl */ 2410 vdll_dnld_ctrl vdll_ctrl; 2411 #if defined(SDIO) || defined(PCIE) 2412 /** pint_lock for interrupt handling */ 2413 t_void *pint_lock; 2414 /** Interrupt status */ 2415 t_u32 ireg; 2416 #endif 2417 /** card type */ 2418 t_u16 card_type; 2419 /** card rev */ 2420 t_u8 card_rev; 2421 const mlan_card_info *pcard_info; 2422 #ifdef SDIO 2423 pmlan_sdio_card pcard_sd; 2424 #endif 2425 #ifdef PCIE 2426 pmlan_pcie_card pcard_pcie; 2427 #endif 2428 #ifdef USB 2429 pmlan_usb_card pcard_usb; 2430 #endif 2431 2432 /** Event cause */ 2433 t_u32 event_cause; 2434 /** Event buffer */ 2435 pmlan_buffer pmlan_buffer_event; 2436 /** Upload length */ 2437 t_u32 upld_len; 2438 /** Upload buffer*/ 2439 t_u8 upld_buf[WLAN_UPLD_SIZE]; 2440 /** Data sent: 2441 * TRUE - Data is sent to fw, no Tx Done received 2442 * FALSE - Tx done received for previous Tx 2443 */ 2444 t_u8 data_sent; 2445 /** Data sent cnt */ 2446 t_u32 data_sent_cnt; 2447 /** CMD sent: 2448 * TRUE - CMD is sent to fw, no CMD Done received 2449 * FALSE - CMD done received for previous CMD 2450 */ 2451 t_u8 cmd_sent; 2452 /** CMD Response received: 2453 * TRUE - CMD is response is received from fw, and yet to process 2454 * FALSE - No cmd response to process 2455 */ 2456 t_u8 cmd_resp_received; 2457 /** Event received: 2458 * TRUE - Event received from fw, and yet to process 2459 * FALSE - No events to process 2460 */ 2461 t_u8 event_received; 2462 2463 /** Data received: 2464 * TRUE - Data received from fw 2465 * FALSE - No Data received 2466 */ 2467 t_u8 data_received; 2468 2469 /** Command-related variables */ 2470 /** Command sequence number */ 2471 t_u16 seq_num; 2472 /** Command controller nodes */ 2473 cmd_ctrl_node *cmd_pool; 2474 /** Current Command */ 2475 cmd_ctrl_node *curr_cmd; 2476 /** mlan_lock for command */ 2477 t_void *pmlan_cmd_lock; 2478 /** Number of command timeouts */ 2479 t_u32 num_cmd_timeout; 2480 /** Last init fw command id */ 2481 t_u16 last_init_cmd; 2482 /** Command timer */ 2483 t_void *pmlan_cmd_timer; 2484 /** Command timer set flag */ 2485 t_u8 cmd_timer_is_set; 2486 /** time stamp for command dnld */ 2487 t_u32 dnld_cmd_in_secs; 2488 2489 /** Command Queues */ 2490 /** Free command buffers */ 2491 mlan_list_head cmd_free_q; 2492 /** Pending command buffers */ 2493 mlan_list_head cmd_pending_q; 2494 /** Command queue for scanning */ 2495 mlan_list_head scan_pending_q; 2496 /** Command pending queue while scanning */ 2497 mlan_list_head ext_cmd_pending_q; 2498 /** ioctl pending queue */ 2499 mlan_list_head ioctl_pending_q; 2500 /** pending_ioctl flag */ 2501 t_u8 pending_ioctl; 2502 pmlan_private pending_disconnect_priv; 2503 /** mlan_processing */ 2504 t_u32 scan_processing; 2505 /** scan state */ 2506 t_u32 scan_state; 2507 /** firmware support for roaming*/ 2508 t_u8 fw_roaming; 2509 /** User set passphrase*/ 2510 t_u8 userset_passphrase; 2511 /** ext_scan enh support flag */ 2512 t_u8 ext_scan_enh; 2513 /** scan type: 0 legacy, 1: enhance scan*/ 2514 t_u8 ext_scan_type; 2515 /** ext scan timeout */ 2516 t_u8 ext_scan_timeout; 2517 /** coex scan flag */ 2518 t_u8 coex_scan; 2519 /** coex min scan time */ 2520 t_u8 coex_min_scan_time; 2521 /** coex max scan time */ 2522 t_u8 coex_max_scan_time; 2523 /** coex win size flag */ 2524 t_u8 coex_win_size; 2525 /** coex amdpdu tx win size */ 2526 t_u8 coex_tx_win_size; 2527 /** coex ampdu rx win size */ 2528 t_u8 coex_rx_win_size; 2529 /** Region code */ 2530 t_u16 region_code; 2531 /** Region Channel data */ 2532 region_chan_t region_channel[MAX_REGION_CHANNEL_NUM]; 2533 /** CFP table code for 2.4GHz */ 2534 t_u8 cfp_code_bg; 2535 /** CFP table code for 5GHz */ 2536 t_u8 cfp_code_a; 2537 wmm_ac_parameters_t ac_params[MAX_AC_QUEUES]; 2538 /** Minimum BA Threshold */ 2539 t_u8 min_ba_threshold; 2540 #ifdef STA_SUPPORT 2541 /** Universal Channel data */ 2542 region_chan_t universal_channel[MAX_REGION_CHANNEL_NUM]; 2543 /** Parsed region channel */ 2544 parsed_region_chan_11d_t parsed_region_chan; 2545 #endif /* STA_SUPPORT */ 2546 /** 11D and Domain Regulatory Data */ 2547 wlan_802_11d_domain_reg_t domain_reg; 2548 /** Country Code */ 2549 t_u8 country_code[COUNTRY_CODE_LEN]; 2550 /** FSM variable for 11h support */ 2551 wlan_11h_device_state_t state_11h; 2552 /** FSM variable for DFS support */ 2553 wlan_dfs_device_state_t state_dfs; 2554 /** FSM variable for RDH support */ 2555 wlan_radar_det_hndlg_state_t state_rdh; 2556 /** variable to configure dfs channel switch count */ 2557 t_s8 dfs_cs_count; 2558 /** User configured settings for DFS testing */ 2559 wlan_dfs_testing_settings_t dfs_test_params; 2560 /** dfs w53 cfg */ 2561 t_u8 dfs53cfg; 2562 /** dfs_mode */ 2563 t_u8 dfs_mode; 2564 /** FSM variable for MEAS support */ 2565 wlan_meas_state_t state_meas; 2566 /** Scan table */ 2567 BSSDescriptor_t *pscan_table; 2568 /** scan age in secs */ 2569 t_u32 age_in_secs; 2570 /** Active scan for hidden ssid triggered */ 2571 t_u8 active_scan_triggered; 2572 /** channel statstics */ 2573 ChanStatistics_t *pchan_stats; 2574 /** Number of records in the chan_stats */ 2575 t_u32 num_in_chan_stats; 2576 /** index of chan stats */ 2577 t_u32 idx_chan_stats; 2578 t_u8 bgscan_reported; 2579 2580 /** Number of records in the scan table */ 2581 t_u32 num_in_scan_table; 2582 /** Scan probes */ 2583 t_u16 scan_probes; 2584 2585 /** Scan type */ 2586 t_u8 scan_type; 2587 /** Scan mode */ 2588 t_u32 scan_mode; 2589 /** Specific scan time */ 2590 t_u16 specific_scan_time; 2591 /** Active scan time */ 2592 t_u16 active_scan_time; 2593 /** Passive scan time */ 2594 t_u16 passive_scan_time; 2595 /** Passive scan to active scan */ 2596 t_u8 passive_to_active_scan; 2597 /** scan channel gap time */ 2598 t_u16 scan_chan_gap; 2599 /** Scan block flag */ 2600 t_u8 scan_block; 2601 /** Extended scan or legacy scan */ 2602 t_u8 ext_scan; 2603 t_u32 bcn_buf_size; 2604 /** Beacon buffer */ 2605 t_u8 *bcn_buf; 2606 /** Pointer to valid beacon buffer end */ 2607 t_u8 *pbcn_buf_end; 2608 /** allocate fixed scan beacon buffer size*/ 2609 t_u32 fixed_beacon_buffer; 2610 2611 /** F/W supported bands */ 2612 t_u16 fw_bands; 2613 /** User selected band to start adhoc network */ 2614 t_u16 adhoc_start_band; 2615 /** User selected bands */ 2616 t_u16 config_bands; 2617 /** Pointer to channel list last sent to the firmware for scanning */ 2618 ChanScanParamSet_t *pscan_channels; 2619 2620 /** Tx lock flag */ 2621 t_u8 tx_lock_flag; 2622 /** Rx lock flag */ 2623 t_u8 rx_lock_flag; 2624 /** main lock flag */ 2625 t_u8 main_lock_flag; 2626 #ifdef USB 2627 /** Tx CMD endpoint address */ 2628 t_u8 tx_cmd_ep; 2629 /** Rx CMD/EVT endpoint address */ 2630 t_u8 rx_cmd_ep; 2631 /** Rx data endpoint address */ 2632 t_u8 rx_data_ep; 2633 /** Tx data endpoint address */ 2634 t_u8 tx_data_ep; 2635 #endif 2636 2637 /** sleep_params_t */ 2638 sleep_params_t sleep_params; 2639 /** sleep_period_t (Enhanced Power Save) */ 2640 sleep_period_t sleep_period; 2641 /** saved sleep_period_t (Enhanced Power Save) */ 2642 sleep_period_t saved_sleep_period; 2643 2644 /** Power Save mode */ 2645 /** 2646 * Wlan802_11PowerModeCAM = disable 2647 * Wlan802_11PowerModePSP = enable 2648 */ 2649 t_u16 ps_mode; 2650 /** Power Save state */ 2651 t_u32 ps_state; 2652 /** Need to wakeup flag */ 2653 t_u8 need_to_wakeup; 2654 /** keep_wakeup */ 2655 t_u8 keep_wakeup; 2656 2657 /** Multiple DTIM */ 2658 t_u16 multiple_dtim; 2659 /** Local listen interval */ 2660 t_u16 local_listen_interval; 2661 /** Null packet interval */ 2662 t_u16 null_pkt_interval; 2663 2664 /** IEEE ps inactivity timout value */ 2665 t_u16 inact_tmo; 2666 /** Power save confirm sleep command buffer */ 2667 pmlan_buffer psleep_cfm; 2668 /** Beacon miss timeout */ 2669 t_u16 bcn_miss_time_out; 2670 2671 /** Deep Sleep flag */ 2672 t_u8 is_deep_sleep; 2673 /** Idle time */ 2674 t_u16 idle_time; 2675 /** Auto Deep Sleep enabled at init time */ 2676 t_u8 init_auto_ds; 2677 2678 /** delay null pkt flag */ 2679 t_u8 delay_null_pkt; 2680 /** Delay to PS in milliseconds */ 2681 t_u16 delay_to_ps; 2682 /** Enhanced PS mode */ 2683 t_u16 enhanced_ps_mode; 2684 /** Device wakeup required flag */ 2685 t_u8 pm_wakeup_card_req; 2686 2687 /** Gen NULL pkg */ 2688 t_u16 gen_null_pkt; 2689 2690 /** PPS/UAPSD mode flag */ 2691 t_u16 pps_uapsd_mode; 2692 /** Number of wakeup tries */ 2693 t_u32 pm_wakeup_fw_try; 2694 /** time stamp when host try to wake up firmware */ 2695 t_u32 pm_wakeup_in_secs; 2696 /** Card wakeup timer */ 2697 t_void *pwakeup_fw_timer; 2698 /** Card wakeup timer */ 2699 t_u8 wakeup_fw_timer_is_set; 2700 /** Number of wake up timeouts */ 2701 t_u32 pm_wakeup_timeout; 2702 2703 /** Host Sleep configured flag */ 2704 t_u8 is_hs_configured; 2705 /** Host Sleep configuration */ 2706 hs_config_param hs_cfg; 2707 /** Host Sleep activated flag */ 2708 t_u8 hs_activated; 2709 /** mef_flt_cfg_mef configuration */ 2710 mef_entry entry_cfg; 2711 /** Event body */ 2712 t_u8 event_body[MAX_EVENT_SIZE]; 2713 /** 802.11n device capabilities */ 2714 t_u32 hw_dot_11n_dev_cap; 2715 /** Device support for MIMO abstraction of MCSs */ 2716 t_u8 hw_dev_mcs_support; 2717 #ifdef STA_SUPPORT 2718 /** Adhoc Secondary Channel Bandwidth */ 2719 t_u8 chan_bandwidth; 2720 #endif /* STA_SUPPORT */ 2721 2722 /** 802.11ac device capabilities */ 2723 t_u32 hw_dot_11ac_dev_cap; 2724 /** 802.11ac device support for MIMO abstraction of MCSs */ 2725 t_u32 hw_dot_11ac_mcs_support; 2726 /** length of hw he capability */ 2727 t_u8 hw_hecap_len; 2728 /** 802.11ax HE capability */ 2729 t_u8 hw_he_cap[54]; 2730 /** length of hw 2.4G he capability */ 2731 t_u8 hw_2g_hecap_len; 2732 /** 802.11ax 2.4G HE capability */ 2733 t_u8 hw_2g_he_cap[54]; 2734 /** max mgmt IE index in device */ 2735 t_u16 max_mgmt_ie_index; 2736 /** Head of Rx data queue */ 2737 mlan_list_head rx_data_queue; 2738 #ifdef MFG_CMD_SUPPORT 2739 t_u32 mfg_mode; 2740 #endif 2741 /** Debug */ 2742 wlan_dbg dbg; 2743 2744 /** RX pending for forwarding packets */ 2745 mlan_scalar pending_bridge_pkts; 2746 2747 #ifdef STA_SUPPORT 2748 /** ARP filter buffer */ 2749 t_u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE]; 2750 /** ARP filter buffer size */ 2751 t_u32 arp_filter_size; 2752 #endif /* STA_SUPPORT */ 2753 /** Minimum delay between HsActive and HostWake (in msec) */ 2754 t_u16 min_wake_holdoff; 2755 /** Host sleep wake interval(in msec) */ 2756 t_u32 hs_wake_interval; 2757 /** Host sleep inactivity timeout (in msec) */ 2758 t_u32 hs_inactivity_timeout; 2759 /** Parameter type for indication gpio*/ 2760 t_u8 param_type_ind; 2761 /** GPIO pin for indication wakeup source */ 2762 t_u32 ind_gpio; 2763 /** Level on ind_gpio pin for indication normal wakeup source */ 2764 t_u32 level; 2765 /** Parameter type for extend hscfg*/ 2766 t_u8 param_type_ext; 2767 /** Events that will be forced ignore */ 2768 t_u32 event_force_ignore; 2769 /** Events that will use extend gap to inform host*/ 2770 t_u32 event_use_ext_gap; 2771 /** Extend gap*/ 2772 t_u8 ext_gap; 2773 /** GPIO wave level for extend hscfg */ 2774 t_u8 gpio_wave; 2775 /** Dynamic MIMO-SISO switch for hscfg*/ 2776 t_u8 hs_mimo_switch; 2777 /** management frame wakeup filter config */ 2778 mlan_mgmt_frame_wakeup mgmt_filter[MAX_MGMT_FRAME_FILTER]; 2779 /** Bypass TX queue pkt count */ 2780 t_u32 bypass_pkt_count; 2781 #ifdef STA_SUPPORT 2782 /** warm-reset IOCTL request buffer pointer */ 2783 pmlan_ioctl_req pwarm_reset_ioctl_req; 2784 #endif 2785 /** SCAN IOCTL request buffer pointer */ 2786 pmlan_ioctl_req pscan_ioctl_req; 2787 /** DPD data pointer */ 2788 t_u8 *pdpd_data; 2789 /** DPD data length */ 2790 t_u32 dpd_data_len; 2791 /** region txpowerlimit cfg data buf pointer */ 2792 t_u8 *ptxpwr_data; 2793 /** region txpowerlimit cfg data len */ 2794 t_u32 txpwr_data_len; 2795 /** Cal data pointer */ 2796 t_u8 *pcal_data; 2797 /** Cal data length */ 2798 t_u32 cal_data_len; 2799 /** tdls status */ 2800 /* TDLS_NOT_SETUP|TDLS_SWITCHING_CHANNEL|TDLS_IN_BASE_CHANNEL|TDLS_IN_SWITCH_CHANNEL*/ 2801 tdlsStatus_e tdls_status; 2802 /** NetMon enabled */ 2803 t_u32 enable_net_mon; 2804 /** Feature control bitmask */ 2805 t_u32 feature_control; 2806 2807 /** Control coex RX window size configuration */ 2808 t_u8 coex_rx_winsize; 2809 t_bool dfs_repeater; 2810 t_u32 dfsr_channel; 2811 t_u8 chanrpt_param_bandcfg; 2812 #if defined(PCIE) 2813 mlan_buffer *ssu_buf; 2814 #endif 2815 t_u8 csi_enabled; 2816 /** maximum sta connection */ 2817 t_u8 max_sta_conn; 2818 otp_region_info_t *otp_region; 2819 chan_freq_power_t *cfp_otp_bg; 2820 t_u8 *tx_power_table_bg; 2821 t_u32 tx_power_table_bg_size; 2822 t_u8 tx_power_table_bg_rows; 2823 t_u8 tx_power_table_bg_cols; 2824 chan_freq_power_t *cfp_otp_a; 2825 t_u8 *tx_power_table_a; 2826 t_u32 tx_power_table_a_size; 2827 t_u8 tx_power_table_a_rows; 2828 t_u8 tx_power_table_a_cols; 2829 /**mlan adapter operations*/ 2830 mlan_adapter_operations ops; 2831 #ifdef DRV_EMBEDDED_AUTHENTICATOR 2832 /** authenticator_priv */ 2833 pmlan_private authenticator_priv; 2834 #endif 2835 /** TP accounting mode 1-enable 0-disable */ 2836 t_u32 tp_state_on; 2837 /** Packet drop point */ 2838 t_u32 tp_state_drop_point; 2839 /* lower 8 bytes of uuid */ 2840 t_u64 uuid_lo; 2841 2842 /* higher 8 bytes of uuid */ 2843 t_u64 uuid_hi; 2844 }; 2845 2846 /** Check if stream 2X2 enabled */ 2847 #define IS_STREAM_2X2(x) ((x)&FEATURE_CTRL_STREAM_2X2) 2848 /** Check if DFS support enabled */ 2849 #define IS_DFS_SUPPORT(x) ((x)&FEATURE_CTRL_DFS_SUPPORT) 2850 #ifdef USB 2851 /** Check if winner check & not wait for FW ready event */ 2852 #define IS_USB_NEW_INIT(x) ((x)&FEATURE_CTRL_USB_NEW_INIT) 2853 #endif 2854 2855 /** Ethernet packet type for EAPOL */ 2856 #define MLAN_ETHER_PKT_TYPE_EAPOL (0x888E) 2857 #define MLAN_ETHER_PKT_TYPE_ARP (0x0806) 2858 /** Ethernet packet type for WAPI */ 2859 #define MLAN_ETHER_PKT_TYPE_WAPI (0x88B4) 2860 /** Ethernet packet type offset */ 2861 #define MLAN_ETHER_PKT_TYPE_OFFSET (12) 2862 2863 mlan_status wlan_cmd_net_monitor(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 2864 t_u16 cmd_action, t_void *pdata_buf); 2865 2866 mlan_status wlan_ret_net_monitor(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 2867 mlan_ioctl_req *pioctl_buf); 2868 2869 mlan_status wlan_misc_ioctl_net_monitor(pmlan_adapter pmadapter, 2870 pmlan_ioctl_req pioctl_req); 2871 2872 void wlan_rxpdinfo_to_radiotapinfo(pmlan_private priv, RxPD *prx_pd, 2873 radiotap_info *prt_info); 2874 2875 mlan_status wlan_init_lock_list(pmlan_adapter pmadapter); 2876 mlan_status wlan_init_priv_lock_list(pmlan_adapter pmadapter, t_u8 start_index); 2877 t_void wlan_free_lock_list(pmlan_adapter pmadapter); 2878 mlan_status wlan_init_timer(pmlan_adapter pmadapter); 2879 t_void wlan_free_timer(pmlan_adapter pmadapter); 2880 2881 /* Function prototype */ 2882 /** Initialize firmware */ 2883 mlan_status wlan_init_fw(pmlan_adapter pmadapter); 2884 2885 /** get hw spec complete */ 2886 mlan_status wlan_get_hw_spec_complete(pmlan_adapter pmadapter); 2887 2888 /** Initialize firmware complete */ 2889 mlan_status wlan_init_fw_complete(pmlan_adapter pmadapter); 2890 2891 /** Shutdown firmware complete */ 2892 mlan_status wlan_shutdown_fw_complete(pmlan_adapter pmadapter); 2893 2894 /** Receive event */ 2895 mlan_status wlan_recv_event(pmlan_private priv, mlan_event_id event_id, 2896 t_void *pmevent); 2897 2898 /** Initialize mlan_adapter structure */ 2899 t_void wlan_init_adapter(pmlan_adapter pmadapter); 2900 2901 /** Initialize mlan_private structure */ 2902 mlan_status wlan_init_priv(pmlan_private priv); 2903 #ifdef USB 2904 /** get pcie device from card type */ 2905 mlan_status wlan_get_usb_device(pmlan_adapter pmadapter); 2906 #endif 2907 mlan_status wlan_download_vdll_block(mlan_adapter *pmadapter, t_u8 *block, 2908 t_u16 block_len); 2909 mlan_status wlan_process_vdll_event(pmlan_private pmpriv, pmlan_buffer pevent); 2910 /** Process event */ 2911 mlan_status wlan_process_event(pmlan_adapter pmadapter); 2912 2913 /** Prepare command */ 2914 mlan_status wlan_prepare_cmd(pmlan_private priv, t_u16 cmd_no, t_u16 cmd_action, 2915 t_u32 cmd_oid, t_void *pioctl_buf, 2916 t_void *pdata_buf); 2917 2918 /** cmd timeout handler */ 2919 t_void wlan_cmd_timeout_func(t_void *function_context); 2920 2921 /** 2922 * @brief check if Tx pending 2923 * 2924 * @param pmadapter Pointer to mlan_adapter 2925 * @return MTRUE/MFALSE; 2926 */ 2927 static inline t_u8 wlan_is_tx_pending(mlan_adapter *pmadapter) 2928 { 2929 #ifdef PCIE 2930 if (IS_PCIE(pmadapter->card_type) && 2931 pmadapter->pcard_pcie->txbd_pending) 2932 return MTRUE; 2933 #endif 2934 return MFALSE; 2935 } 2936 2937 /** process host cmd */ 2938 mlan_status wlan_misc_ioctl_host_cmd(pmlan_adapter pmadapter, 2939 pmlan_ioctl_req pioctl_req); 2940 /** process init/shutdown cmd*/ 2941 mlan_status wlan_misc_ioctl_init_shutdown(pmlan_adapter pmadapter, 2942 pmlan_ioctl_req pioctl_req); 2943 /** process debug info */ 2944 mlan_status wlan_get_info_debug_info(pmlan_adapter pmadapter, 2945 pmlan_ioctl_req pioctl_req); 2946 2947 #if defined(STA_SUPPORT) || defined(UAP_SUPPORT) 2948 extern pmlan_operations mlan_ops[]; 2949 /** Set/Get BSS role */ 2950 mlan_status wlan_bss_ioctl_bss_role(pmlan_adapter pmadapter, 2951 pmlan_ioctl_req pioctl_req); 2952 #endif 2953 2954 #if defined(PCIE) 2955 mlan_status wlan_misc_ssu(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req); 2956 #endif 2957 2958 mlan_status wlan_misc_csi(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req); 2959 mlan_status wlan_process_csi_event(pmlan_private pmpriv); 2960 2961 mlan_status wlan_misc_hal_phy_cfg(pmlan_adapter pmadapter, 2962 pmlan_ioctl_req pioctl_req); 2963 2964 mlan_status wlan_set_ewpa_mode(mlan_private *priv, pmlan_ds_passphrase psec_pp); 2965 mlan_status wlan_find_bss(mlan_private *pmpriv, pmlan_ioctl_req pioctl_req); 2966 2967 /* block main process */ 2968 void mlan_block_main_process(mlan_adapter *pmadapter, t_u8 block); 2969 /* block rx process */ 2970 void mlan_block_rx_process(mlan_adapter *pmadapter, t_u8 block); 2971 /** check pending command */ 2972 int wlan_check_pending_cmd(mlan_adapter *pmadapter); 2973 /** Allocate memory for adapter structure members */ 2974 mlan_status wlan_allocate_adapter(pmlan_adapter pmadapter); 2975 /** Free adapter */ 2976 t_void wlan_free_adapter(pmlan_adapter pmadapter); 2977 /** Free priv */ 2978 t_void wlan_free_priv(mlan_private *pmpriv); 2979 /** Allocate command buffer */ 2980 mlan_status wlan_alloc_cmd_buffer(mlan_adapter *pmadapter); 2981 /** Free command buffer */ 2982 mlan_status wlan_free_cmd_buffer(mlan_adapter *pmadapter); 2983 /** Request command lock */ 2984 t_void wlan_request_cmd_lock(mlan_adapter *pmadapter); 2985 /** Release command lock */ 2986 t_void wlan_release_cmd_lock(mlan_adapter *pmadapter); 2987 #ifdef STA_SUPPORT 2988 /** Flush the scan pending queue */ 2989 t_void wlan_flush_scan_queue(pmlan_adapter pmadapter); 2990 t_void wlan_move_cmd_to_cmd_pending_q(pmlan_adapter pmadapter); 2991 mlan_status wlan_cancel_pending_scan_cmd(pmlan_adapter pmadapter, 2992 pmlan_ioctl_req pioctl_req); 2993 #endif 2994 /**Cancel pending command */ 2995 t_void wlan_cancel_all_pending_cmd(pmlan_adapter pmadapter, t_u8 flag); 2996 /**Cancel pending ioctl */ 2997 t_void wlan_cancel_pending_ioctl(pmlan_adapter pmadapter, 2998 pmlan_ioctl_req pioctl_req); 2999 /**Cancel bss pending ioctl */ 3000 t_void wlan_cancel_bss_pending_cmd(pmlan_adapter pmadapter, t_u32 bss_index); 3001 3002 /** Insert command to free queue */ 3003 t_void wlan_insert_cmd_to_free_q(mlan_adapter *pmadapter, 3004 cmd_ctrl_node *pcmd_node); 3005 3006 /** Insert command to pending queue */ 3007 t_void wlan_insert_cmd_to_pending_q(mlan_adapter *pmadapter, 3008 cmd_ctrl_node *pcmd_node, t_u32 addtail); 3009 3010 /** Execute next command */ 3011 mlan_status wlan_exec_next_cmd(mlan_adapter *pmadapter); 3012 /** Proecess command response */ 3013 mlan_status wlan_process_cmdresp(mlan_adapter *pmadapter); 3014 /** Handle received packet, has extra handling for aggregate packets */ 3015 mlan_status wlan_handle_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf); 3016 /** Process transmission */ 3017 mlan_status wlan_process_tx(pmlan_private priv, pmlan_buffer pmbuf, 3018 mlan_tx_param *tx_param); 3019 /** Transmit a null data packet */ 3020 mlan_status wlan_send_null_packet(pmlan_private priv, t_u8 flags); 3021 3022 #ifdef SDIO 3023 mlan_status wlan_alloc_sdio_mpa_buffers(mlan_adapter *pmadapter, 3024 t_u32 mpa_tx_buf_size, 3025 t_u32 mpa_rx_buf_size); 3026 3027 mlan_status wlan_free_sdio_mpa_buffers(mlan_adapter *pmadapter); 3028 #endif 3029 3030 /** Process write data complete */ 3031 mlan_status wlan_write_data_complete(pmlan_adapter pmlan_adapter, 3032 pmlan_buffer pmbuf, mlan_status status); 3033 3034 #ifdef USB 3035 mlan_status wlan_usb_deaggr_rx_pkt(pmlan_adapter pmadapter, pmlan_buffer pmbuf); 3036 3037 /** 3038 * @brief This function resets USB Tx Aggregation buffers 3039 * 3040 * @param pmadapter A pointer to mlan_adapter 3041 * 3042 * @return N/A 3043 */ 3044 static INLINE t_void wlan_reset_usb_tx_aggr(pmlan_adapter pmadapter) 3045 { 3046 t_s32 i = 0; 3047 pmlan_callbacks pcb = &pmadapter->callbacks; 3048 ENTER(); 3049 for (i = 0; i < MAX_USB_TX_PORT_NUM; i++) { 3050 pcb->moal_spin_lock( 3051 pmadapter->pmoal_handle, 3052 pmadapter->pcard_usb->usb_tx_aggr[i].paggr_lock); 3053 if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_hold_timer_is_set) { 3054 pcb->moal_stop_timer(pmadapter->pmoal_handle, 3055 pmadapter->pcard_usb 3056 ->usb_tx_aggr[i] 3057 .paggr_hold_timer); 3058 pmadapter->pcard_usb->usb_tx_aggr[i] 3059 .aggr_hold_timer_is_set = MFALSE; 3060 } 3061 if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_ctrl.enable && 3062 pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr != MNULL) { 3063 wlan_write_data_complete( 3064 pmadapter, 3065 pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr, 3066 MLAN_STATUS_FAILURE); /* did not get sent */ 3067 pmadapter->pcard_usb->usb_tx_aggr[i].pmbuf_aggr = MNULL; 3068 pmadapter->pcard_usb->usb_tx_aggr[i].aggr_len = 0; 3069 } 3070 pcb->moal_spin_unlock( 3071 pmadapter->pmoal_handle, 3072 pmadapter->pcard_usb->usb_tx_aggr[i].paggr_lock); 3073 } 3074 LEAVE(); 3075 } 3076 3077 /** 3078 * @brief This function get usb_tx_aggr_params 3079 * 3080 * @param pmadapter A pointer to mlan_adapter 3081 * @param port port for TX 3082 * 3083 * @return A pointer to usb_tx_aggr_params 3084 */ 3085 static INLINE usb_tx_aggr_params * 3086 wlan_get_usb_tx_aggr_params(pmlan_adapter pmadapter, t_u32 port) 3087 { 3088 int i; 3089 ENTER(); 3090 for (i = 0; i < MAX_USB_TX_PORT_NUM; i++) { 3091 if (pmadapter->pcard_usb->usb_tx_aggr[i].aggr_ctrl.enable && 3092 pmadapter->pcard_usb->usb_tx_aggr[i].port == port) 3093 return &pmadapter->pcard_usb->usb_tx_aggr[i]; 3094 } 3095 LEAVE(); 3096 return MNULL; 3097 } 3098 3099 t_void wlan_usb_tx_aggr_timeout_func(t_void *function_context); 3100 mlan_status wlan_usb_host_to_card_aggr(pmlan_adapter pmadapter, 3101 pmlan_buffer pmbuf, 3102 mlan_tx_param *tx_param, 3103 usb_tx_aggr_params *aggr_params); 3104 #endif 3105 3106 /** Process receive packet complete */ 3107 mlan_status wlan_recv_packet_complete(pmlan_adapter pmadapter, 3108 pmlan_buffer pmbuf, mlan_status status); 3109 /** Clean Tx Rx queues */ 3110 t_void wlan_clean_txrx(pmlan_private priv); 3111 3112 t_void wlan_add_buf_bypass_txqueue(mlan_adapter *pmadapter, pmlan_buffer pmbuf); 3113 t_void wlan_process_bypass_tx(mlan_adapter *pmadapter); 3114 t_void wlan_cleanup_bypass_txq(pmlan_private priv); 3115 t_u8 wlan_bypass_tx_list_empty(mlan_adapter *pmadapter); 3116 3117 /** Check if this is the last packet */ 3118 t_u8 wlan_check_last_packet_indication(pmlan_private priv); 3119 3120 #define MOAL_ALLOC_MLAN_BUFFER MBIT(0) 3121 #define MOAL_MALLOC_BUFFER MBIT(1) 3122 #define MOAL_MEM_FLAG_ATOMIC MBIT(2) 3123 3124 #ifdef PCIE 3125 /* This defines the direction arg to the DMA mapping routines. */ 3126 #define PCI_DMA_BIDIRECTIONAL 0 3127 #define PCI_DMA_TODEVICE 1 3128 #define PCI_DMA_FROMDEVICE 2 3129 #define PCI_DMA_NONE 3 3130 #endif 3131 3132 /** function to allocate a mlan_buffer */ 3133 pmlan_buffer wlan_alloc_mlan_buffer(mlan_adapter *pmadapter, t_u32 data_len, 3134 t_u32 head_room, t_u32 malloc_flag); 3135 /** function to free a mlan_buffer */ 3136 t_void wlan_free_mlan_buffer(mlan_adapter *pmadapter, pmlan_buffer pmbuf); 3137 3138 /** command resp handler for version ext */ 3139 mlan_status wlan_ret_ver_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3140 mlan_ioctl_req *pioctl_buf); 3141 3142 /** command resp handler for rx mgmt forward registration */ 3143 mlan_status wlan_ret_rx_mgmt_ind(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3144 mlan_ioctl_req *pioctl_buf); 3145 3146 /** Check Power Save condition */ 3147 t_void wlan_check_ps_cond(mlan_adapter *pmadapter); 3148 3149 /** handle command for enhanced power save mode */ 3150 mlan_status wlan_cmd_enh_power_mode(pmlan_private pmpriv, 3151 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3152 t_u16 ps_bitmap, t_void *pdata_buf); 3153 /** handle command resp for enhanced power save mode */ 3154 mlan_status wlan_ret_enh_power_mode(pmlan_private pmpriv, 3155 HostCmd_DS_COMMAND *resp, 3156 mlan_ioctl_req *pioctl_buf); 3157 3158 /** handle commnand for cfg data */ 3159 mlan_status wlan_cmd_cfg_data(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd, 3160 t_u16 cmd_action, t_u32 cmd_oid, 3161 t_void *pdata_buf); 3162 /** handle command resp for cfg data */ 3163 mlan_status wlan_ret_cfg_data(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3164 t_void *pioctl_buf); 3165 3166 /** Process sleep confirm command response */ 3167 void wlan_process_sleep_confirm_resp(pmlan_adapter pmadapter, t_u8 *pbuf, 3168 t_u32 len); 3169 3170 /** Perform hs related activities on receving the power up interrupt */ 3171 void wlan_process_hs_config(pmlan_adapter pmadapter); 3172 3173 t_void wlan_wakeup_card_timeout_func(void *function_context); 3174 3175 mlan_status wlan_process_802dot11_mgmt_pkt(mlan_private *priv, t_u8 *payload, 3176 t_u32 payload_len, RxPD *prx_pd); 3177 3178 mlan_status wlan_pm_ioctl_hscfg(pmlan_adapter pmadapter, 3179 pmlan_ioctl_req pioctl_req); 3180 3181 mlan_status wlan_radio_ioctl_remain_chan_cfg(pmlan_adapter pmadapter, 3182 pmlan_ioctl_req pioctl_req); 3183 mlan_status wlan_cmd_remain_on_channel(pmlan_private pmpriv, 3184 HostCmd_DS_COMMAND *cmd, 3185 t_u16 cmd_action, t_void *pdata_buf); 3186 mlan_status wlan_ret_remain_on_channel(pmlan_private pmpriv, 3187 HostCmd_DS_COMMAND *resp, 3188 mlan_ioctl_req *pioctl_buf); 3189 3190 #ifdef WIFI_DIRECT_SUPPORT 3191 mlan_status wlan_bss_ioctl_wifi_direct_mode(pmlan_adapter pmadapter, 3192 pmlan_ioctl_req pioctl_req); 3193 3194 mlan_status wlan_cmd_wifi_direct_mode(pmlan_private pmpriv, 3195 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3196 t_void *pdata_buf); 3197 mlan_status wlan_ret_wifi_direct_mode(pmlan_private pmpriv, 3198 HostCmd_DS_COMMAND *resp, 3199 mlan_ioctl_req *pioctl_buf); 3200 mlan_status wlan_cmd_p2p_params_config(pmlan_private pmpriv, 3201 HostCmd_DS_COMMAND *cmd, 3202 t_u16 cmd_action, t_void *pdata_buf); 3203 mlan_status wlan_ret_p2p_params_config(pmlan_private pmpriv, 3204 HostCmd_DS_COMMAND *resp, 3205 mlan_ioctl_req *pioctl_buf); 3206 mlan_status wlan_misc_p2p_config(pmlan_adapter pmadapter, 3207 pmlan_ioctl_req pioctl_req); 3208 #endif 3209 mlan_status wlan_cmd_gpio_tsf_latch(pmlan_private pmpriv, 3210 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3211 mlan_ioctl_req *pioctl_buf, 3212 t_void *pdata_buf); 3213 mlan_status wlan_ret_gpio_tsf_latch(pmlan_private pmpriv, 3214 HostCmd_DS_COMMAND *resp, 3215 mlan_ioctl_req *pioctl_buf); 3216 mlan_status wlan_misc_gpio_tsf_latch_config(pmlan_adapter pmadapter, 3217 pmlan_ioctl_req pioctl_req); 3218 mlan_status wlan_misc_get_tsf_info(pmlan_adapter pmadapter, 3219 pmlan_ioctl_req pioctl_req); 3220 /** get ralist info */ 3221 int wlan_get_ralist_info(mlan_private *priv, pralist_info buf); 3222 /** dump ralist */ 3223 void wlan_dump_ralist(mlan_private *priv); 3224 3225 /** get pm info */ 3226 mlan_status wlan_get_pm_info(pmlan_adapter pmadapter, 3227 pmlan_ioctl_req pioctl_req); 3228 3229 mlan_status wlan_bss_ioctl_bss_remove(pmlan_adapter pmadapter, 3230 pmlan_ioctl_req pioctl_req); 3231 3232 mlan_status wlan_radio_ioctl_mimo_switch_cfg(pmlan_adapter pmadapter, 3233 pmlan_ioctl_req pioctl_req); 3234 mlan_status wlan_cmd_802_11_mimo_switch(pmlan_private pmpriv, 3235 HostCmd_DS_COMMAND *cmd, 3236 t_void *pdata_buf); 3237 3238 mlan_status wlan_misc_per_pkt_cfg(pmlan_adapter pmadapter, 3239 pmlan_ioctl_req pioctl_req); 3240 3241 mlan_status wlan_config_mgmt_filter(pmlan_adapter pmadapter, 3242 pmlan_ioctl_req pioctl_req); 3243 mlan_status wlan_get_hs_wakeup_reason(pmlan_adapter pmadapter, 3244 pmlan_ioctl_req pioctl_req); 3245 3246 mlan_status wlan_cmd_hs_wakeup_reason(pmlan_private pmpriv, 3247 HostCmd_DS_COMMAND *cmd, 3248 t_void *pdata_buf); 3249 3250 mlan_status wlan_ret_hs_wakeup_reason(pmlan_private pmpriv, 3251 HostCmd_DS_COMMAND *resp, 3252 mlan_ioctl_req *pioctl_buf); 3253 3254 mlan_status wlan_get_tx_rx_histogram(pmlan_adapter pmadapter, 3255 pmlan_ioctl_req pioctl_req); 3256 mlan_status wlan_cmd_tx_rx_pkt_stats(pmlan_private pmpriv, 3257 HostCmd_DS_COMMAND *cmd, 3258 pmlan_ioctl_req pioctl_buf, 3259 t_void *pdata_buf); 3260 mlan_status wlan_ret_tx_rx_pkt_stats(pmlan_private pmpriv, 3261 HostCmd_DS_COMMAND *resp, 3262 mlan_ioctl_req *pioctl_buf); 3263 3264 mlan_status wlan_radio_ioctl_radio_ctl(pmlan_adapter pmadapter, 3265 pmlan_ioctl_req pioctl_req); 3266 3267 mlan_status wlan_radio_ioctl_ant_cfg(pmlan_adapter pmadapter, 3268 pmlan_ioctl_req pioctl_req); 3269 3270 mlan_status wlan_cmd_tx_rate_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3271 t_u16 cmd_action, t_void *pdata_buf, 3272 mlan_ioctl_req *pioctl_buf); 3273 mlan_status wlan_ret_tx_rate_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3274 mlan_ioctl_req *pioctl_buf); 3275 3276 mlan_status wlan_rate_ioctl_cfg(pmlan_adapter pmadapter, 3277 pmlan_ioctl_req pioctl_req); 3278 mlan_status wlan_ret_802_11_tx_rate_query(pmlan_private pmpriv, 3279 HostCmd_DS_COMMAND *resp, 3280 mlan_ioctl_req *pioctl_buf); 3281 3282 mlan_status wlan_rate_ioctl_get_data_rate(pmlan_adapter pmadapter, 3283 pmlan_ioctl_req pioctl_req); 3284 3285 t_void wlan_host_sleep_activated_event(pmlan_private priv, t_u8 activated); 3286 /** Handles the command response of hs_cfg */ 3287 mlan_status wlan_ret_802_11_hs_cfg(pmlan_private pmpriv, 3288 HostCmd_DS_COMMAND *resp, 3289 mlan_ioctl_req *pioctl_buf); 3290 /** Sends HS_WAKEUP event to applications */ 3291 t_void wlan_host_sleep_wakeup_event(pmlan_private priv); 3292 3293 /** Prepares command of robustcoex */ 3294 mlan_status wlan_cmd_robustcoex(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3295 t_u16 cmd_action, t_u16 *pdata_buf); 3296 /** Set Robustcoex gpiocfg */ 3297 mlan_status wlan_misc_robustcoex(pmlan_adapter pmadapter, 3298 pmlan_ioctl_req pioctl_req); 3299 3300 /** Set mapping policy/get DMCS status */ 3301 mlan_status wlan_misc_dmcs_config(pmlan_adapter pmadapter, 3302 pmlan_ioctl_req pioctl_req); 3303 /** Prepares command of DMCS config */ 3304 mlan_status wlan_cmd_dmcs_config(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3305 t_u16 cmd_action, t_void *pdata_buf); 3306 /** Handles command response of DMCS config */ 3307 mlan_status wlan_ret_dmcs_config(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3308 mlan_ioctl_req *pioctl_buf); 3309 3310 #if defined(PCIE) 3311 mlan_status wlan_cmd_ssu(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3312 t_u16 cmd_action, t_u16 *pdata_buf); 3313 #endif 3314 3315 /** send get hw spec command to firmware */ 3316 mlan_status wlan_adapter_get_hw_spec(pmlan_adapter pmadapter); 3317 /** send adapter specific init cmd to firmware */ 3318 mlan_status wlan_adapter_init_cmd(pmlan_adapter pmadapter); 3319 /** get/set bandcfg */ 3320 mlan_status wlan_radio_ioctl_band_cfg(pmlan_adapter pmadapter, 3321 pmlan_ioctl_req pioctl_req); 3322 3323 #ifdef RX_PACKET_COALESCE 3324 mlan_status wlan_cmd_rx_pkt_coalesce_cfg(pmlan_private pmpriv, 3325 HostCmd_DS_COMMAND *cmd, 3326 t_u16 cmd_action, t_void *pdata_buf); 3327 mlan_status wlan_ret_rx_pkt_coalesce_cfg(pmlan_private pmpriv, 3328 const HostCmd_DS_COMMAND *resp, 3329 mlan_ioctl_req *pioctl_buf); 3330 #endif 3331 3332 #ifdef STA_SUPPORT 3333 /** warm reset */ 3334 mlan_status wlan_misc_ioctl_warm_reset(pmlan_adapter pmadapter, 3335 pmlan_ioctl_req pioctl_req); 3336 /** Process received packet */ 3337 mlan_status wlan_process_rx_packet(pmlan_adapter pmadapter, pmlan_buffer pmbuf); 3338 /** ioctl handler for station mode */ 3339 mlan_status wlan_ops_sta_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req); 3340 3341 /** cmd handler for station mode */ 3342 mlan_status wlan_ops_sta_prepare_cmd(t_void *priv, t_u16 cmd_no, 3343 t_u16 cmd_action, t_u32 cmd_oid, 3344 t_void *pioctl_buf, t_void *pdata_buf, 3345 t_void *pcmd_buf); 3346 3347 /** cmdresp handler for station mode */ 3348 mlan_status wlan_ops_sta_process_cmdresp(t_void *priv, t_u16 cmdresp_no, 3349 t_void *pcmd_buf, t_void *pioctl); 3350 3351 /** rx handler for station mode */ 3352 mlan_status wlan_ops_sta_process_rx_packet(t_void *adapter, pmlan_buffer pmbuf); 3353 3354 /** event handler for station mode */ 3355 mlan_status wlan_ops_sta_process_event(t_void *priv); 3356 3357 /** fill txpd for station mode */ 3358 t_void *wlan_ops_sta_process_txpd(t_void *priv, pmlan_buffer pmbuf); 3359 3360 /** send init cmd to firmware for station mode */ 3361 mlan_status wlan_ops_sta_init_cmd(t_void *priv, t_u8 first_bss); 3362 3363 /** Flush the scan table */ 3364 mlan_status wlan_flush_scan_table(pmlan_adapter pmadapter); 3365 3366 /** Scan for networks */ 3367 mlan_status wlan_scan_networks(mlan_private *pmpriv, t_void *pioctl_buf, 3368 wlan_user_scan_cfg *puser_scan_in); 3369 3370 /** Scan for specific SSID */ 3371 mlan_status wlan_scan_specific_ssid(mlan_private *pmpriv, t_void *pioctl_buf, 3372 mlan_802_11_ssid *preq_ssid); 3373 3374 /** Scan command handler */ 3375 mlan_status wlan_cmd_802_11_scan(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd, 3376 t_void *pdata_buf); 3377 3378 /** Handler for scan command response */ 3379 mlan_status wlan_ret_802_11_scan(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3380 t_void *pioctl_buf); 3381 3382 t_u8 wlan_get_ext_scan_state(HostCmd_DS_COMMAND *pcmd); 3383 /** Extended scan command handler */ 3384 mlan_status wlan_cmd_802_11_scan_ext(pmlan_private pmpriv, 3385 HostCmd_DS_COMMAND *pcmd, 3386 t_void *pdata_buf); 3387 /** Handler for extended scan command response */ 3388 mlan_status wlan_ret_802_11_scan_ext(pmlan_private pmpriv, 3389 HostCmd_DS_COMMAND *resp, 3390 t_void *pioctl_buf); 3391 /** Handler event for extended scan report */ 3392 mlan_status wlan_handle_event_ext_scan_report(mlan_private *pmpriv, 3393 mlan_buffer *pmbuf); 3394 mlan_status wlan_handle_event_ext_scan_status(mlan_private *pmpriv, 3395 mlan_buffer *pmbuf); 3396 3397 /** check network compatibility */ 3398 t_s32 wlan_is_network_compatible(mlan_private *pmpriv, t_u32 index, t_u32 mode); 3399 3400 /** Find an SSID in a list */ 3401 t_s32 wlan_find_ssid_in_list(pmlan_private pmpriv, mlan_802_11_ssid *ssid, 3402 t_u8 *bssid, t_u32 mode); 3403 3404 /** Find a BSSID in a list */ 3405 t_s32 wlan_find_bssid_in_list(mlan_private *pmpriv, t_u8 *bssid, t_u32 mode); 3406 3407 /** Find best network */ 3408 mlan_status wlan_find_best_network(mlan_private *pmpriv, 3409 mlan_ssid_bssid *preq_ssid_bssid); 3410 3411 /** Compare two SSIDs */ 3412 t_s32 wlan_ssid_cmp(pmlan_adapter pmadapter, mlan_802_11_ssid *ssid1, 3413 mlan_802_11_ssid *ssid2); 3414 3415 /** Associate */ 3416 mlan_status wlan_associate(mlan_private *pmpriv, IN t_void *pioctl_buf, 3417 IN BSSDescriptor_t *pBSSDesc); 3418 3419 /** Associate command handler */ 3420 mlan_status wlan_cmd_802_11_associate(mlan_private *pmpriv, 3421 HostCmd_DS_COMMAND *cmd, 3422 t_void *pdata_buf); 3423 3424 /** Handler for association command response */ 3425 mlan_status wlan_ret_802_11_associate(mlan_private *pmpriv, 3426 HostCmd_DS_COMMAND *resp, 3427 t_void *pioctl_buf); 3428 3429 /** Reset connected state */ 3430 t_void wlan_reset_connect_state(pmlan_private priv, t_u8 drv_disconnect); 3431 3432 t_void wlan_2040_coex_event(pmlan_private pmpriv); 3433 3434 /** convert band to radio type */ 3435 t_u8 wlan_band_to_radio_type(t_u16 band); 3436 /** convert radio_type to band */ 3437 t_u16 radio_type_to_band(t_u8 chanBand); 3438 3439 /** Disconnect */ 3440 mlan_status wlan_disconnect(mlan_private *pmpriv, mlan_ioctl_req *pioctl_req, 3441 mlan_deauth_param *deauth_param); 3442 3443 /** Ad-Hoc start */ 3444 mlan_status wlan_adhoc_start(mlan_private *pmpriv, t_void *pioctl_buf, 3445 mlan_802_11_ssid *padhoc_ssid); 3446 3447 /** Ad-Hoc join */ 3448 mlan_status wlan_adhoc_join(mlan_private *pmpriv, t_void *pioctl_buf, 3449 BSSDescriptor_t *pBSSDesc); 3450 3451 /** Ad-Hoc start command handler */ 3452 mlan_status wlan_cmd_802_11_ad_hoc_start(mlan_private *pmpriv, 3453 HostCmd_DS_COMMAND *cmd, 3454 t_void *pdata_buf); 3455 3456 /** Ad-Hoc command handler */ 3457 mlan_status wlan_cmd_802_11_ad_hoc_join(mlan_private *pmpriv, 3458 HostCmd_DS_COMMAND *cmd, 3459 t_void *pdata_buf); 3460 3461 /** Handler for Ad-Hoc commands */ 3462 mlan_status wlan_ret_802_11_ad_hoc(mlan_private *pmpriv, 3463 HostCmd_DS_COMMAND *resp, 3464 t_void *pioctl_buf); 3465 3466 /** Handler for bgscan query commands */ 3467 mlan_status wlan_cmd_802_11_bg_scan_query(mlan_private *pmpriv, 3468 HostCmd_DS_COMMAND *pcmd, 3469 t_void *pdata_buf); 3470 /** Handler for bgscan config command */ 3471 mlan_status wlan_cmd_bgscan_config(mlan_private *pmpriv, 3472 HostCmd_DS_COMMAND *pcmd, t_void *pdata_buf); 3473 /** Hander for bgscan config command response */ 3474 mlan_status wlan_ret_bgscan_config(mlan_private *pmpriv, 3475 HostCmd_DS_COMMAND *resp, 3476 mlan_ioctl_req *pioctl_buf); 3477 mlan_status wlan_ret_802_11_bgscan_query(mlan_private *pmpriv, 3478 HostCmd_DS_COMMAND *resp, 3479 mlan_ioctl_req *pioctl_buf); 3480 3481 /** Get Channel-Frequency-Power by band and channel */ 3482 chan_freq_power_t * 3483 wlan_get_cfp_by_band_and_channel(pmlan_adapter pmadapter, t_u16 band, 3484 t_u16 channel, region_chan_t *region_channel); 3485 /** Find Channel-Frequency-Power by band and channel */ 3486 chan_freq_power_t *wlan_find_cfp_by_band_and_channel(mlan_adapter *pmadapter, 3487 t_u16 band, t_u16 channel); 3488 /** Find Channel-Frequency-Power by band and frequency */ 3489 chan_freq_power_t *wlan_find_cfp_by_band_and_freq(mlan_adapter *pmadapter, 3490 t_u16 band, t_u32 freq); 3491 /** Get Tx power of channel from Channel-Frequency-Power */ 3492 t_u8 wlan_get_txpwr_of_chan_from_cfp(mlan_private *pmpriv, t_u16 band, 3493 t_u8 channel); 3494 /** find frequency from band and channel */ 3495 t_u32 wlan_find_freq_from_band_chan(t_u16 band, t_u8 chan); 3496 3497 /* Save a beacon buffer of the current bss descriptor */ 3498 t_void wlan_save_curr_bcn(mlan_private *pmpriv); 3499 /* Free a beacon buffer of the current bss descriptor */ 3500 t_void wlan_free_curr_bcn(mlan_private *pmpriv); 3501 3502 #endif /* STA_SUPPORT */ 3503 3504 /* Rate related functions */ 3505 t_u8 wlan_convert_v14_tx_rate_info(pmlan_private pmpriv, t_u8 v14_rate_info); 3506 t_u8 wlan_convert_v14_rx_rate_info(pmlan_private pmpriv, t_u8 v14_rate_info); 3507 /** Convert index into data rate */ 3508 t_u32 wlan_index_to_data_rate(pmlan_adapter pmadapter, t_u8 index, 3509 t_u8 rate_info, t_u8 ext_rate_info); 3510 /** Get active data rates */ 3511 t_u32 wlan_get_active_data_rates(mlan_private *pmpriv, t_u32 bss_mode, 3512 t_u16 config_bands, WLAN_802_11_RATES rates); 3513 /** Get supported data rates */ 3514 t_u32 wlan_get_supported_rates(mlan_private *pmpriv, t_u32 bss_mode, 3515 t_u16 config_bands, WLAN_802_11_RATES rates); 3516 /** Convert data rate to index */ 3517 t_u8 wlan_data_rate_to_index(pmlan_adapter pmadapter, t_u32 rate); 3518 /** Check if rate is auto */ 3519 t_u8 wlan_is_rate_auto(mlan_private *pmpriv); 3520 /** Get rate index */ 3521 int wlan_get_rate_index(pmlan_adapter pmadapter, t_u16 *rateBitmap, int size); 3522 mlan_status wlan_cmd_rxabortcfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3523 t_u16 cmd_action, t_void *pdata_buf); 3524 mlan_status wlan_ret_rxabortcfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3525 mlan_ioctl_req *pioctl_buf); 3526 mlan_status wlan_cmd_rxabortcfg_ext(pmlan_private pmpriv, 3527 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3528 t_void *pdata_buf); 3529 mlan_status wlan_ret_rxabortcfg_ext(pmlan_private pmpriv, 3530 HostCmd_DS_COMMAND *resp, 3531 mlan_ioctl_req *pioctl_buf); 3532 mlan_status wlan_cmd_tx_ampdu_prot_mode(pmlan_private pmpriv, 3533 HostCmd_DS_COMMAND *cmd, 3534 t_u16 cmd_action, t_void *pdata_buf); 3535 mlan_status wlan_ret_tx_ampdu_prot_mode(pmlan_private pmpriv, 3536 HostCmd_DS_COMMAND *resp, 3537 mlan_ioctl_req *pioctl_buf); 3538 mlan_status wlan_cmd_dot11mc_unassoc_ftm_cfg(pmlan_private pmpriv, 3539 HostCmd_DS_COMMAND *cmd, 3540 t_u16 cmd_action, 3541 t_void *pdata_buf); 3542 mlan_status wlan_ret_dot11mc_unassoc_ftm_cfg(pmlan_private pmpriv, 3543 HostCmd_DS_COMMAND *resp, 3544 mlan_ioctl_req *pioctl_buf); 3545 mlan_status wlan_cmd_hal_phy_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3546 t_u16 cmd_action, t_u16 *pdata_buf); 3547 mlan_status wlan_ret_hal_phy_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3548 mlan_ioctl_req *pioctl_buf); 3549 mlan_status wlan_cmd_ips_config(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3550 t_u16 cmd_action, t_void *pdata_buf); 3551 mlan_status wlan_ret_ips_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3552 mlan_ioctl_req *pioctl_buf); 3553 mlan_status wlan_cmd_rate_adapt_cfg(pmlan_private pmpriv, 3554 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3555 t_void *pdata_buf); 3556 mlan_status wlan_ret_rate_adapt_cfg(pmlan_private pmpriv, 3557 HostCmd_DS_COMMAND *resp, 3558 mlan_ioctl_req *pioctl_buf); 3559 mlan_status wlan_cmd_cck_desense_cfg(pmlan_private pmpriv, 3560 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3561 t_void *pdata_buf); 3562 3563 mlan_status wlan_ret_cck_desense_cfg(pmlan_private pmpriv, 3564 HostCmd_DS_COMMAND *resp, 3565 mlan_ioctl_req *pioctl_buf); 3566 3567 mlan_status wlan_cmd_arb_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3568 t_u16 cmd_action, t_void *pdata_buf); 3569 mlan_status wlan_ret_arb_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3570 mlan_ioctl_req *pioctl_buf); 3571 3572 mlan_status wlan_misc_ioctl_rxabortcfg(pmlan_adapter pmadapter, 3573 pmlan_ioctl_req pioctl_req); 3574 mlan_status wlan_misc_ioctl_rxabortcfg_ext(pmlan_adapter pmadapter, 3575 pmlan_ioctl_req pioctl_req); 3576 mlan_status wlan_misc_ioctl_tx_ampdu_prot_mode(pmlan_adapter pmadapter, 3577 pmlan_ioctl_req pioctl_req); 3578 mlan_status wlan_misc_ioctl_dot11mc_unassoc_ftm_cfg(pmlan_adapter pmadapter, 3579 pmlan_ioctl_req pioctl_req); 3580 mlan_status wlan_misc_ioctl_rate_adapt_cfg(pmlan_adapter pmadapter, 3581 pmlan_ioctl_req pioctl_req); 3582 mlan_status wlan_misc_ioctl_cck_desense_cfg(pmlan_adapter pmadapter, 3583 pmlan_ioctl_req pioctl_req); 3584 mlan_status wlan_cmd_mfg(pmlan_private pmpriv, pHostCmd_DS_COMMAND cmd, 3585 t_u16 cmd_action, t_pvoid pdata_buf); 3586 mlan_status wlan_ret_mfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3587 mlan_ioctl_req *pioctl_buf); 3588 mlan_status wlan_misc_ioctl_rf_test_cfg(pmlan_adapter pmadapter, 3589 pmlan_ioctl_req pioctl_req); 3590 mlan_status wlan_misc_ioctl_range_ext(pmlan_adapter pmadapter, 3591 pmlan_ioctl_req pioctl_req); 3592 mlan_status wlan_misc_ioctl_arb_cfg(pmlan_adapter pmadapter, 3593 pmlan_ioctl_req pioctl_req); 3594 mlan_status wlan_misc_ioctl_tp_state(pmlan_adapter pmadapter, 3595 pmlan_ioctl_req pioctl_req); 3596 /* CFP related functions */ 3597 /** Region code index table */ 3598 extern t_u16 region_code_index[MRVDRV_MAX_REGION_CODE]; 3599 /** The table to keep CFP code for A */ 3600 extern t_u16 cfp_code_index_a[MRVDRV_MAX_CFP_CODE_A]; 3601 3602 /** Set region table */ 3603 mlan_status wlan_set_regiontable(mlan_private *pmpriv, t_u8 region, t_u16 band); 3604 /** Get radar detection requirements*/ 3605 t_bool wlan_get_cfp_radar_detect(mlan_private *priv, t_u8 chnl); 3606 /** check if scan type is passive for b/g band*/ 3607 t_bool wlan_bg_scan_type_is_passive(mlan_private *priv, t_u8 chnl); 3608 /** check if channel is NO_IR (passive) */ 3609 t_bool wlan_is_chan_passive(mlan_private *priv, t_u16 band, t_u8 chan); 3610 /** check if channel is disabled */ 3611 t_bool wlan_is_chan_disabled(mlan_private *priv, t_u16 band, t_u8 chan); 3612 /** check if channel is blacklisted */ 3613 t_bool wlan_is_chan_blacklisted(mlan_private *priv, t_u16 band, t_u8 chan); 3614 /** set blacklist setting for a channel */ 3615 t_bool wlan_set_chan_blacklist(mlan_private *priv, t_u16 band, t_u8 chan, 3616 t_bool bl); 3617 3618 dfs_state_t wlan_get_chan_dfs_state(mlan_private *priv, t_u16 band, t_u8 chan); 3619 t_void wlan_set_chan_dfs_state(mlan_private *priv, t_u16 band, t_u8 chan, 3620 dfs_state_t dfs_state); 3621 t_void wlan_reset_all_chan_dfs_state(mlan_private *priv, t_u16 band, 3622 dfs_state_t dfs_state); 3623 /* 802.11D related functions */ 3624 /** Initialize 11D */ 3625 t_void wlan_11d_priv_init(mlan_private *pmpriv); 3626 /** Initialize 11D */ 3627 t_void wlan_11d_init(mlan_adapter *pmadapter); 3628 /** Enable 11D */ 3629 mlan_status wlan_11d_enable(mlan_private *pmpriv, t_void *pioctl_buf, 3630 state_11d_t flag); 3631 /** Get if 11D is enabled */ 3632 t_bool wlan_11d_is_enabled(mlan_private *pmpriv); 3633 /** Get if FW 11D is enabled */ 3634 t_bool wlan_fw_11d_is_enabled(mlan_private *pmpriv); 3635 /** Get if priv is station */ 3636 t_bool wlan_is_station(mlan_private *pmpriv); 3637 /** Command handler for 11D country info */ 3638 mlan_status wlan_cmd_802_11d_domain_info(mlan_private *pmpriv, 3639 HostCmd_DS_COMMAND *pcmd, 3640 t_u16 cmd_action); 3641 /** Handler for 11D country info command response */ 3642 mlan_status wlan_ret_802_11d_domain_info(mlan_private *pmpriv, 3643 HostCmd_DS_COMMAND *resp); 3644 /** Convert channel to frequency */ 3645 t_u32 wlan_11d_chan_2_freq(pmlan_adapter pmadapter, t_u8 chan, t_u16 band); 3646 #ifdef STA_SUPPORT 3647 /** Set 11D universal table */ 3648 mlan_status wlan_11d_set_universaltable(mlan_private *pmpriv, t_u16 band); 3649 /** Clear 11D region table */ 3650 mlan_status wlan_11d_clear_parsedtable(mlan_private *pmpriv); 3651 /** Create 11D country information for downloading */ 3652 mlan_status wlan_11d_create_dnld_countryinfo(mlan_private *pmpriv, t_u16 band); 3653 /** Get scan type from 11D info */ 3654 t_u8 wlan_11d_get_scan_type(pmlan_adapter pmadapter, t_u16 band, t_u8 chan, 3655 parsed_region_chan_11d_t *parsed_region_chan); 3656 /** Parse 11D country info */ 3657 mlan_status wlan_11d_parse_dnld_countryinfo(mlan_private *pmpriv, 3658 BSSDescriptor_t *pBSSDesc); 3659 /** Prepare 11D domain information for download */ 3660 mlan_status wlan_11d_prepare_dnld_domain_info_cmd(mlan_private *pmpriv); 3661 /** Parse 11D country information into domain info */ 3662 mlan_status wlan_11d_parse_domain_info( 3663 pmlan_adapter pmadapter, IEEEtypes_CountryInfoFullSet_t *country_info, 3664 t_u16 band, parsed_region_chan_11d_t *parsed_region_chan); 3665 #endif /* STA_SUPPORT */ 3666 #ifdef UAP_SUPPORT 3667 /** Handle 11D domain information from UAP */ 3668 mlan_status wlan_11d_handle_uap_domain_info(mlan_private *pmpriv, t_u16 band, 3669 t_u8 *domain_tlv, 3670 t_void *pioctl_buf); 3671 #endif 3672 /** Configure 11D domain info command */ 3673 mlan_status wlan_11d_cfg_domain_info(pmlan_adapter pmadapter, 3674 mlan_ioctl_req *pioctl_req); 3675 3676 /** This function converts region string to CFP table code */ 3677 mlan_status wlan_misc_country_2_cfp_table_code(pmlan_adapter pmadapter, 3678 t_u8 *country_code, t_u8 *cfp_bg, 3679 t_u8 *cfp_a); 3680 3681 /** This function finds if given country code is in EU table */ 3682 t_bool wlan_is_etsi_country(pmlan_adapter pmadapter, t_u8 *country_code); 3683 3684 /** check if station list is empty */ 3685 t_u8 wlan_is_station_list_empty(mlan_private *priv); 3686 /** get station node */ 3687 sta_node *wlan_get_station_entry(mlan_private *priv, t_u8 *mac); 3688 /** delete station list */ 3689 t_void wlan_delete_station_list(pmlan_private priv); 3690 /** delete station entry */ 3691 t_void wlan_delete_station_entry(mlan_private *priv, t_u8 *mac); 3692 /** add station entry */ 3693 sta_node *wlan_add_station_entry(mlan_private *priv, t_u8 *mac); 3694 /** process uap rx packet */ 3695 3696 void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent, 3697 sta_node *sta_ptr); 3698 /** find specific ie */ 3699 t_u8 *wlan_get_specific_ie(pmlan_private priv, t_u8 *ie_buf, t_u8 ie_len, 3700 IEEEtypes_ElementId_e id, t_u8 ext_id); 3701 t_u8 wlan_is_wmm_ie_present(pmlan_adapter pmadapter, t_u8 *pbuf, t_u16 buf_len); 3702 3703 /** 3704 * @brief This function checks whether a station TDLS link is enabled or not 3705 * 3706 * @param priv A pointer to mlan_private 3707 * @param mac station mac address 3708 * @return 3709 * TDLS_NOT_SETUP/TDLS_SETUP_INPROGRESS/TDLS_SETUP_COMPLETE/TDLS_SETUP_FAILURE/TDLS_TEAR_DOWN 3710 */ 3711 static INLINE tdlsStatus_e wlan_get_tdls_link_status(mlan_private *priv, 3712 t_u8 *mac) 3713 { 3714 sta_node *sta_ptr = MNULL; 3715 sta_ptr = wlan_get_station_entry(priv, mac); 3716 if (sta_ptr) 3717 return sta_ptr->status; 3718 return TDLS_NOT_SETUP; 3719 } 3720 3721 /** 3722 * @brief This function checks if TDLS link is in channel switching 3723 * 3724 * @param status tdls link status 3725 * @return MTRUE/MFALSE 3726 */ 3727 static INLINE int wlan_is_tdls_link_chan_switching(tdlsStatus_e status) 3728 { 3729 return (status == TDLS_SWITCHING_CHANNEL) ? MTRUE : MFALSE; 3730 } 3731 3732 /** 3733 * @brief This function checks if send command to firmware is allowed 3734 * 3735 * @param status tdls link status 3736 * @return MTRUE/MFALSE 3737 */ 3738 static INLINE int wlan_is_send_cmd_allowed(tdlsStatus_e status) 3739 { 3740 int ret = MTRUE; 3741 switch (status) { 3742 case TDLS_SWITCHING_CHANNEL: 3743 case TDLS_IN_OFF_CHANNEL: 3744 ret = MFALSE; 3745 break; 3746 default: 3747 break; 3748 } 3749 return ret; 3750 } 3751 3752 /** 3753 * @brief This function checks if TDLS link is setup 3754 * 3755 * @param status tdls link status 3756 * @return MTRUE/MFALSE 3757 */ 3758 static INLINE int wlan_is_tdls_link_setup(tdlsStatus_e status) 3759 { 3760 int ret = MFALSE; 3761 switch (status) { 3762 case TDLS_SWITCHING_CHANNEL: 3763 case TDLS_IN_OFF_CHANNEL: 3764 case TDLS_IN_BASE_CHANNEL: 3765 case TDLS_SETUP_COMPLETE: 3766 ret = MTRUE; 3767 break; 3768 default: 3769 break; 3770 } 3771 return ret; 3772 } 3773 3774 /** 3775 * @brief This function checks tx_pause flag for peer 3776 * 3777 * @param priv A pointer to mlan_private 3778 * @param ra Address of the receiver STA 3779 * 3780 * @return MTRUE or MFALSE 3781 */ 3782 static INLINE int wlan_is_tx_pause(mlan_private *priv, t_u8 *ra) 3783 { 3784 sta_node *sta_ptr = MNULL; 3785 sta_ptr = wlan_get_station_entry(priv, ra); 3786 if (sta_ptr) 3787 return sta_ptr->tx_pause; 3788 return MFALSE; 3789 } 3790 t_u16 wlan_update_ralist_tx_pause(pmlan_private priv, t_u8 *mac, t_u8 tx_pause); 3791 3792 #ifdef UAP_SUPPORT 3793 mlan_status wlan_process_uap_rx_packet(mlan_private *priv, pmlan_buffer pmbuf); 3794 t_void wlan_drop_tx_pkts(pmlan_private priv); 3795 #endif /* UAP_SUPPORT */ 3796 3797 #ifdef UAP_SUPPORT 3798 /* process the recevied packet and bridge the packet */ 3799 mlan_status wlan_uap_recv_packet(mlan_private *priv, pmlan_buffer pmbuf); 3800 #endif /* UAP_SUPPORT */ 3801 3802 mlan_status wlan_misc_ioctl_custom_ie_list(pmlan_adapter pmadapter, 3803 pmlan_ioctl_req pioctl_req, 3804 t_bool send_ioctl); 3805 3806 mlan_status wlan_cmd_get_hw_spec(pmlan_private pmpriv, 3807 HostCmd_DS_COMMAND *pcmd); 3808 mlan_status wlan_ret_get_hw_spec(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3809 t_void *pioctl_buf); 3810 #ifdef SDIO 3811 mlan_status wlan_cmd_sdio_rx_aggr_cfg(HostCmd_DS_COMMAND *pcmd, 3812 t_u16 cmd_action, t_void *pdata_buf); 3813 mlan_status wlan_ret_sdio_rx_aggr_cfg(pmlan_private pmpriv, 3814 HostCmd_DS_COMMAND *resp); 3815 #endif 3816 3817 mlan_status wlan_misc_ioctl_mac_control(pmlan_adapter pmadapter, 3818 pmlan_ioctl_req pioctl_req); 3819 mlan_status wlan_cmd_mac_control(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd, 3820 t_u16 cmd_action, t_void *pdata_buf); 3821 mlan_status wlan_ret_mac_control(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3822 mlan_ioctl_req *pioctl_buf); 3823 3824 mlan_status wlan_cmd_cw_mode_ctrl(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3825 t_u16 cmd_action, t_void *pdata_buf); 3826 mlan_status wlan_ret_cw_mode_ctrl(pmlan_private pmpriv, 3827 HostCmd_DS_COMMAND *resp, 3828 mlan_ioctl_req *pioctl_buf); 3829 3830 mlan_status wlan_cmd_802_11_radio_control(pmlan_private pmpriv, 3831 HostCmd_DS_COMMAND *cmd, 3832 t_u16 cmd_action, t_void *pdata_buf); 3833 mlan_status wlan_ret_802_11_radio_control(pmlan_private pmpriv, 3834 HostCmd_DS_COMMAND *resp, 3835 mlan_ioctl_req *pioctl_buf); 3836 3837 mlan_status wlan_cmd_802_11_rf_antenna(pmlan_private pmpriv, 3838 HostCmd_DS_COMMAND *cmd, 3839 t_u16 cmd_action, t_void *pdata_buf); 3840 mlan_status wlan_ret_802_11_rf_antenna(pmlan_private pmpriv, 3841 HostCmd_DS_COMMAND *resp, 3842 mlan_ioctl_req *pioctl_buf); 3843 3844 mlan_status wlan_ret_reg_access(mlan_adapter *pmadapter, t_u16 type, 3845 HostCmd_DS_COMMAND *resp, 3846 mlan_ioctl_req *pioctl_buf); 3847 mlan_status wlan_ret_mem_access(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3848 mlan_ioctl_req *pioctl_buf); 3849 3850 mlan_status wlan_reg_mem_ioctl_reg_rw(pmlan_adapter pmadapter, 3851 pmlan_ioctl_req pioctl_req); 3852 mlan_status wlan_reg_mem_ioctl_read_eeprom(pmlan_adapter pmadapter, 3853 pmlan_ioctl_req pioctl_req); 3854 mlan_status wlan_reg_mem_ioctl_mem_rw(pmlan_adapter pmadapter, 3855 pmlan_ioctl_req pioctl_req); 3856 mlan_status wlan_cmd_reg_access(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3857 t_u16 cmd_action, t_void *pdata_buf); 3858 mlan_status wlan_cmd_mem_access(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3859 t_void *pdata_buf); 3860 mlan_status wlan_cmd_802_11_mac_address(pmlan_private pmpriv, 3861 HostCmd_DS_COMMAND *cmd, 3862 t_u16 cmd_action); 3863 mlan_status wlan_ret_802_11_mac_address(pmlan_private pmpriv, 3864 HostCmd_DS_COMMAND *resp, 3865 mlan_ioctl_req *pioctl_buf); 3866 3867 int wlan_get_tdls_list(mlan_private *priv, tdls_peer_info *buf); 3868 t_void wlan_hold_tdls_packets(pmlan_private priv, t_u8 *mac); 3869 t_void wlan_restore_tdls_packets(pmlan_private priv, t_u8 *mac, 3870 tdlsStatus_e status); 3871 t_void wlan_update_non_tdls_ralist(mlan_private *priv, t_u8 *mac, 3872 t_u8 tx_pause); 3873 mlan_status wlan_misc_ioctl_tdls_config(pmlan_adapter pmadapter, 3874 pmlan_ioctl_req pioctl_req); 3875 void wlan_11n_send_delba_to_peer(mlan_private *priv, t_u8 *ra); 3876 void wlan_process_tdls_action_frame(pmlan_private priv, t_u8 *pbuf, t_u32 len); 3877 mlan_status wlan_misc_ioctl_tdls_oper(pmlan_adapter pmadapter, 3878 pmlan_ioctl_req pioctl_req); 3879 3880 mlan_status wlan_misc_ioctl_tdls_get_ies(pmlan_adapter pmadapter, 3881 pmlan_ioctl_req pioctl_req); 3882 mlan_status wlan_misc_ioctl_tdls_idle_time(pmlan_adapter pmadapter, 3883 pmlan_ioctl_req pioctl_req); 3884 3885 t_void wlan_tdls_config(pmlan_private pmpriv, t_u8 enable); 3886 mlan_status wlan_misc_ioctl_tdls_cs_channel(pmlan_adapter pmadapter, 3887 pmlan_ioctl_req pioctl_req); 3888 3889 mlan_status wlan_get_info_ver_ext(pmlan_adapter pmadapter, 3890 pmlan_ioctl_req pioctl_req); 3891 3892 mlan_status wlan_ioctl_link_statistic(mlan_private *pmpriv, 3893 pmlan_ioctl_req pioctl_req); 3894 3895 mlan_status wlan_cmd_802_11_link_statistic(pmlan_private pmpriv, 3896 HostCmd_DS_COMMAND *cmd, 3897 t_u16 cmd_action, 3898 mlan_ioctl_req *pioctl_buf); 3899 3900 mlan_status wlan_ret_get_link_statistic(pmlan_private pmpriv, 3901 HostCmd_DS_COMMAND *resp, 3902 mlan_ioctl_req *pioctl_buf); 3903 3904 mlan_status wlan_reg_rx_mgmt_ind(pmlan_adapter pmadapter, 3905 pmlan_ioctl_req pioctl_req); 3906 3907 #ifdef DEBUG_LEVEL1 3908 mlan_status wlan_set_drvdbg(pmlan_adapter pmadapter, 3909 pmlan_ioctl_req pioctl_req); 3910 #endif 3911 3912 mlan_status wlan_misc_hotspot_cfg(pmlan_adapter pmadapter, 3913 pmlan_ioctl_req pioctl_req); 3914 3915 #ifdef STA_SUPPORT 3916 mlan_status wlan_misc_ext_capa_cfg(pmlan_adapter pmadapter, 3917 pmlan_ioctl_req pioctl_req); 3918 3919 t_u32 wlan_is_ext_capa_support(mlan_private *pmpriv); 3920 #endif 3921 3922 #ifdef STA_SUPPORT 3923 void wlan_add_ext_capa_info_ie(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc, 3924 t_u8 **pptlv_out); 3925 #endif 3926 3927 mlan_status wlan_cmd_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3928 t_u16 cmd_action, t_void *pdata_buf); 3929 3930 mlan_status wlan_ret_boot_sleep(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3931 mlan_ioctl_req *pioctl_buf); 3932 3933 #if defined(DRV_EMBEDDED_AUTHENTICATOR) || defined(DRV_EMBEDDED_SUPPLICANT) 3934 mlan_status wlan_cmd_crypto(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 3935 t_u16 cmd_action, t_u16 *pdata_buf); 3936 3937 mlan_status wlan_ret_crypto(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 3938 mlan_ioctl_req *pioctl_buf); 3939 #endif 3940 3941 #define BW_20MHZ 0 3942 #define BW_40MHZ 1 3943 #define BW_80MHZ 2 3944 #define BW_160MHZ 3 3945 int wlan_add_supported_oper_class_ie(mlan_private *pmpriv, t_u8 **pptlv_out, 3946 t_u8 curr_oper_class); 3947 mlan_status wlan_get_curr_oper_class(mlan_private *pmpriv, t_u8 channel, 3948 t_u8 bw, t_u8 *oper_class); 3949 mlan_status wlan_check_operclass_validation(mlan_private *pmpriv, t_u8 channel, 3950 t_u8 oper_class); 3951 mlan_status wlan_misc_ioctl_operclass_validation(pmlan_adapter pmadapter, 3952 mlan_ioctl_req *pioctl_req); 3953 mlan_status wlan_misc_ioctl_oper_class(pmlan_adapter pmadapter, 3954 mlan_ioctl_req *pioctl_req); 3955 3956 t_u16 wlan_adjust_data_rate(mlan_private *priv, t_u8 rx_rate, t_u8 rate_info); 3957 t_u8 wlan_adjust_antenna(pmlan_private priv, RxPD *prx_pd); 3958 3959 mlan_status wlan_misc_otp_user_data(pmlan_adapter pmadapter, 3960 pmlan_ioctl_req pioctl_req); 3961 3962 #ifdef USB 3963 extern mlan_adapter_operations mlan_usb_ops; 3964 3965 mlan_status wlan_misc_ioctl_usb_aggr_ctrl(pmlan_adapter pmadapter, 3966 pmlan_ioctl_req pioctl_req); 3967 #endif 3968 3969 mlan_status wlan_misc_ioctl_aggr_ctrl(pmlan_adapter pmadapter, 3970 pmlan_ioctl_req pioctl_req); 3971 mlan_status wlan_cmd_packet_aggr_ctrl(pmlan_private pmpriv, 3972 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 3973 t_void *pdata_buf); 3974 mlan_status wlan_ret_packet_aggr_ctrl(pmlan_private pmpriv, 3975 HostCmd_DS_COMMAND *resp, 3976 mlan_ioctl_req *pioctl_buf); 3977 mlan_status wlan_misc_ioctl_txcontrol(pmlan_adapter pmadapter, 3978 pmlan_ioctl_req pioctl_req); 3979 3980 mlan_status wlan_misc_ioctl_region(pmlan_adapter pmadapter, 3981 pmlan_ioctl_req pioctl_req); 3982 3983 #ifdef RX_PACKET_COALESCE 3984 mlan_status wlan_misc_ioctl_rx_pkt_coalesce_config(pmlan_adapter pmadapter, 3985 pmlan_ioctl_req pioctl_req); 3986 #endif 3987 3988 void wlan_bt_coex_wlan_param_update_event(pmlan_private priv, 3989 pmlan_buffer pevent); 3990 3991 mlan_status wlan_misc_ioctl_dfs_repeater_cfg(pmlan_adapter pmadapter, 3992 pmlan_ioctl_req pioctl_req); 3993 3994 t_bool wlan_check_interface_active(mlan_adapter *pmadapter); 3995 3996 mlan_status wlan_misc_ioctl_coalesce_cfg(pmlan_adapter pmadapter, 3997 pmlan_ioctl_req pioctl_req); 3998 3999 mlan_status wlan_misc_ioctl_low_pwr_mode(pmlan_adapter pmadapter, 4000 pmlan_ioctl_req pioctl_req); 4001 4002 mlan_status wlan_misc_ioctl_pmic_configure(pmlan_adapter pmadapter, 4003 pmlan_ioctl_req pioctl_req); 4004 4005 mlan_status wlan_misc_ioctl_cwmode_ctrl(pmlan_adapter pmadapter, 4006 pmlan_ioctl_req pioctl_req); 4007 4008 mlan_status wlan_set_mef_entry(mlan_private *pmpriv, pmlan_adapter pmadapter, 4009 mef_cfg_data *pmef); 4010 mlan_status wlan_process_mef_cfg_cmd(mlan_private *pmpriv, 4011 pmlan_adapter pmadapter); 4012 mlan_status wlan_misc_ioctl_mef_flt_cfg(pmlan_adapter pmadapter, 4013 pmlan_ioctl_req pioctl_req); 4014 4015 mlan_status wlan_misc_ioctl_ind_rst_cfg(pmlan_adapter pmadapter, 4016 pmlan_ioctl_req pioctl_req); 4017 mlan_status wlan_cmd_ind_rst_cfg(HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 4018 t_void *pdata_buf); 4019 mlan_status wlan_ret_ind_rst_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4020 mlan_ioctl_req *pioctl_buf); 4021 4022 mlan_status wlan_cmd_802_11_supplicant_pmk(pmlan_private pmpriv, 4023 HostCmd_DS_COMMAND *cmd, 4024 t_u16 cmd_action, t_void *pdata_buf); 4025 4026 mlan_status wlan_ret_802_11_supplicant_pmk(pmlan_private pmpriv, 4027 HostCmd_DS_COMMAND *resp, 4028 mlan_ioctl_req *pioctl_buf); 4029 4030 mlan_status wlan_sec_ioctl_passphrase(pmlan_adapter pmadapter, 4031 pmlan_ioctl_req pioctl_req); 4032 4033 mlan_status wlan_cmd_mc_aggr_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 4034 t_u16 cmd_action, t_void *pdata_buf); 4035 mlan_status wlan_ret_mc_aggr_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4036 mlan_ioctl_req *pioctl_buf); 4037 mlan_status wlan_misc_ioctl_mc_aggr_cfg(pmlan_adapter pmadapter, 4038 mlan_ioctl_req *pioctl_req); 4039 mlan_status wlan_misc_ioctl_ch_load(pmlan_adapter pmadapter, 4040 mlan_ioctl_req *pioctl_req); 4041 mlan_status wlan_misc_ioctl_ch_load_results(pmlan_adapter pmadapter, 4042 mlan_ioctl_req *pioctl_req); 4043 mlan_status wlan_cmd_get_ch_load(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 4044 t_u16 cmd_action, t_void *pdata_buf); 4045 mlan_status wlan_ret_ch_load(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4046 mlan_ioctl_req *pioctl_buf); 4047 4048 mlan_status wlan_misc_ioctl_get_tsf(pmlan_adapter pmadapter, 4049 pmlan_ioctl_req pioctl_req); 4050 void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left); 4051 4052 void wlan_free_fw_cfp_tables(mlan_adapter *pmadapter); 4053 4054 mlan_status wlan_misc_chan_reg_cfg(pmlan_adapter pmadapter, 4055 pmlan_ioctl_req pioctl_req); 4056 4057 mlan_status wlan_get_cfp_table(pmlan_adapter pmadapter, 4058 pmlan_ioctl_req pioctl_req); 4059 mlan_status wlan_get_cfpinfo(pmlan_adapter pmadapter, 4060 pmlan_ioctl_req pioctl_req); 4061 4062 mlan_status wlan_cmd_get_tsf(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 4063 t_u16 cmd_action); 4064 mlan_status wlan_ret_get_tsf(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4065 mlan_ioctl_req *pioctl_buf); 4066 4067 t_u8 wlan_ft_akm_is_used(mlan_private *pmpriv, t_u8 *rsn_ie); 4068 4069 mlan_status wlan_clear_fw_roaming_pmk(pmlan_private pmpriv); 4070 4071 mlan_status wlan_get_rgchnpwr_cfg(pmlan_adapter pmadapter, 4072 mlan_ioctl_req *pioctl_req); 4073 mlan_status wlan_get_chan_trpc_cfg(pmlan_adapter pmadapter, 4074 mlan_ioctl_req *pioctl_req); 4075 mlan_status wlan_cmd_get_chan_trpc_config(pmlan_private pmpriv, 4076 HostCmd_DS_COMMAND *cmd, 4077 t_u16 cmd_action, t_void *pdata_buf); 4078 mlan_status wlan_ret_get_chan_trpc_config(pmlan_private pmpriv, 4079 HostCmd_DS_COMMAND *resp, 4080 mlan_ioctl_req *pioctl_buf); 4081 4082 mlan_status wlan_cmd_ps_inactivity_timeout(pmlan_private pmpriv, 4083 HostCmd_DS_COMMAND *cmd, 4084 t_u16 cmd_action, t_void *pdata_buf); 4085 4086 t_u8 wlan_ieee_rateid_to_mrvl_rateid(mlan_private *priv, t_u16 IeeeMacRate, 4087 t_u8 *dst_mac); 4088 t_u8 wlan_mrvl_rateid_to_ieee_rateid(t_u8 rate); 4089 4090 t_u8 wlan_get_center_freq_idx(mlan_private *pmpriv, t_u16 band, t_u32 pri_chan, 4091 t_u8 chan_bw); 4092 4093 mlan_status wlan_ret_chan_region_cfg(pmlan_private pmpriv, 4094 HostCmd_DS_COMMAND *resp, 4095 mlan_ioctl_req *pioctl_buf); 4096 4097 mlan_status wlan_misc_ioctl_fw_dump_event(pmlan_adapter pmadapter, 4098 mlan_ioctl_req *pioctl_req); 4099 mlan_status wlan_cmd_fw_dump_event(pmlan_private pmpriv, 4100 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 4101 t_void *pdata_buf); 4102 4103 mlan_status wlan_misc_bootsleep(pmlan_adapter pmadapter, 4104 pmlan_ioctl_req pioctl_req); 4105 4106 mlan_status wlan_misc_ioctl_dyn_bw(pmlan_adapter pmadapter, 4107 mlan_ioctl_req *pioctl_req); 4108 mlan_status wlan_cmd_config_dyn_bw(pmlan_private pmpriv, 4109 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action, 4110 t_void *pdata_buf); 4111 mlan_status wlan_ret_dyn_bw(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4112 mlan_ioctl_req *pioctl_buf); 4113 4114 #ifdef UAP_SUPPORT 4115 /** wacp mode misc ioctl */ 4116 mlan_status wlan_misc_ioctl_wacp_mode(pmlan_adapter pmadapter, 4117 mlan_ioctl_req *pioctl_req); 4118 #endif 4119 4120 mlan_status wlan_power_ioctl_set_get_lpm(pmlan_adapter pmadapter, 4121 pmlan_ioctl_req pioctl_req); 4122 mlan_status wlan_cmd_set_get_low_power_mode_cfg(pmlan_private pmpriv, 4123 HostCmd_DS_COMMAND *cmd, 4124 t_u16 cmd_action, 4125 t_void *pdata_buf); 4126 mlan_status wlan_ret_set_get_low_power_mode_cfg(pmlan_private pmpriv, 4127 HostCmd_DS_COMMAND *resp, 4128 mlan_ioctl_req *pioctl_buf); 4129 4130 mlan_status wlan_cmd_range_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd, 4131 t_u16 cmd_action, t_void *pdata_buf); 4132 mlan_status wlan_ret_range_ext(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp, 4133 mlan_ioctl_req *pioctl_buf); 4134 4135 mlan_status wlan_misc_ioctl_get_sensor_temp(pmlan_adapter pmadapter, 4136 pmlan_ioctl_req pioctl_req); 4137 mlan_status wlan_cmd_get_sensor_temp(pmlan_private pmpriv, 4138 HostCmd_DS_COMMAND *cmd, t_u16 cmd_action); 4139 mlan_status wlan_ret_get_sensor_temp(pmlan_private pmpriv, 4140 HostCmd_DS_COMMAND *resp, 4141 mlan_ioctl_req *pioctl_buf); 4142 4143 /** 4144 * @brief RA based queueing 4145 * 4146 * @param priv A pointer to mlan_private structure 4147 * 4148 * @return MTRUE or MFALSE 4149 */ 4150 static INLINE t_u8 queuing_ra_based(pmlan_private priv) 4151 { 4152 /* 4153 * Currently we assume if we are in Infra, then DA=RA. This might not be 4154 * true in the future 4155 */ 4156 if ((priv->bss_mode == MLAN_BSS_MODE_INFRA) && 4157 (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA)) 4158 return MFALSE; 4159 4160 return MTRUE; 4161 } 4162 4163 /** 4164 * @brief Copy Rates 4165 * 4166 * @param dest A pointer to Dest Buf 4167 * @param pos The position for copy 4168 * @param src A pointer to Src Buf 4169 * @param len The len of Src Buf 4170 * 4171 * @return Number of Rates copied 4172 */ 4173 static INLINE t_u32 wlan_copy_rates(t_u8 *dest, t_u32 pos, t_u8 *src, int len) 4174 { 4175 int i; 4176 4177 for (i = 0; i < len && src[i]; i++, pos++) { 4178 if (pos >= sizeof(WLAN_802_11_RATES)) 4179 break; 4180 dest[pos] = src[i]; 4181 } 4182 4183 return pos; 4184 } 4185 4186 /** 4187 * @brief strlen 4188 * 4189 * @param str A pointer to string 4190 * 4191 * @return Length of string 4192 */ 4193 static INLINE t_u32 wlan_strlen(const char *str) 4194 { 4195 t_u32 i; 4196 4197 for (i = 0; str[i] != 0; i++) 4198 ; 4199 4200 return i; 4201 } 4202 4203 /** 4204 * @brief iscdigit 4205 * 4206 * @param chr A char 4207 * 4208 * @return Non zero if chr is a hex, else 0 4209 */ 4210 static INLINE t_u32 wlan_isxdigit(t_u8 chr) 4211 { 4212 return (chr <= 'f' && chr >= 'a') || (chr <= 'F' && chr >= 'A') || 4213 (chr <= '9' && chr >= '0'); 4214 } 4215 4216 /** 4217 * @brief isspace 4218 * 4219 * @param A chr 4220 * 4221 * @return Non zero if chr is space etc, else 0 4222 */ 4223 static INLINE t_u32 wlan_isspace(t_u8 chr) 4224 { 4225 return chr <= ' ' && (chr == ' ' || (chr <= 13 && chr >= 9)); 4226 } 4227 4228 /** delay unit */ 4229 typedef enum _delay_unit { 4230 USEC, 4231 MSEC, 4232 SEC, 4233 } t_delay_unit; 4234 4235 /** delay function */ 4236 t_void wlan_delay_func(mlan_adapter *pmadapter, t_u32 delay, t_delay_unit u); 4237 4238 /** delay function wrapper */ 4239 #define wlan_delay(p, n) wlan_delay_func(p, n, SEC) 4240 /** delay function wrapper */ 4241 #define wlan_mdelay(p, n) wlan_delay_func(p, n, MSEC) 4242 /** delay function wrapper */ 4243 #define wlan_udelay(p, n) wlan_delay_func(p, n, USEC) 4244 4245 /** 4246 * @brief This function check if there are pending cmd 4247 * in cmd pending Q 4248 * 4249 * @param pmadapter A pointer to mlan_adapter structure 4250 * 4251 * @return MTRUE -- cmd pending 4252 * MFALSE -- no pending cmd 4253 */ 4254 static INLINE int wlan_is_cmd_pending(mlan_adapter *pmadapter) 4255 { 4256 int ret; 4257 cmd_ctrl_node *pcmd_node = MNULL; 4258 wlan_request_cmd_lock(pmadapter); 4259 pcmd_node = (cmd_ctrl_node *)util_peek_list(pmadapter->pmoal_handle, 4260 &pmadapter->cmd_pending_q, 4261 MNULL, MNULL); 4262 if (pcmd_node) 4263 ret = MTRUE; 4264 else 4265 ret = MFALSE; 4266 wlan_release_cmd_lock(pmadapter); 4267 return ret; 4268 } 4269 4270 /** Get BSS number from priv */ 4271 #define GET_BSS_NUM(priv) ((priv)->bss_num) 4272 4273 /** 4274 * @brief This function returns priv based on the BSS num and BSS type 4275 * 4276 * @param pmadapter A pointer to mlan_adapter 4277 * @param bss_num BSS number 4278 * @param bss_type BSS type 4279 * 4280 * @return Pointer to mlan_private 4281 */ 4282 static INLINE mlan_private *wlan_get_priv_by_id(mlan_adapter *pmadapter, 4283 t_u32 bss_num, t_u32 bss_type) 4284 { 4285 int i; 4286 4287 for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) { 4288 if (pmadapter->priv[i]) { 4289 if ((pmadapter->priv[i]->bss_num == bss_num) && 4290 (pmadapter->priv[i]->bss_type == bss_type)) 4291 return pmadapter->priv[i]; 4292 } 4293 } 4294 return MNULL; 4295 } 4296 4297 /** 4298 * @brief This function returns first available priv 4299 * based on the BSS role 4300 * 4301 * @param pmadapter A pointer to mlan_adapter 4302 * @param bss_role BSS role or MLAN_BSS_ROLE_ANY 4303 * 4304 * @return Pointer to mlan_private 4305 */ 4306 static INLINE mlan_private *wlan_get_priv(mlan_adapter *pmadapter, 4307 mlan_bss_role bss_role) 4308 { 4309 int i; 4310 4311 for (i = 0; i < MIN(pmadapter->priv_num, MLAN_MAX_BSS_NUM); i++) { 4312 if (pmadapter->priv[i]) { 4313 if (bss_role == MLAN_BSS_ROLE_ANY || 4314 GET_BSS_ROLE(pmadapter->priv[i]) == bss_role) 4315 return pmadapter->priv[i]; 4316 } 4317 } 4318 return MNULL; 4319 } 4320 4321 /** 4322 * @brief This function counts the number of occurences for a certain 4323 * condition among privs. Which privs are checked can be configured 4324 * via a second condition. 4325 * 4326 * @param pmadapter A pointer to mlan_adapter 4327 * @param count_cond Function pointer to condition to count on privs 4328 * @param check_cond Function pointer to condition to decide whether priv 4329 * should be counted or not. Use MNULL to check all privs. 4330 * 4331 * @return Count of privs where count_cond returned MTRUE. 4332 */ 4333 static INLINE int 4334 wlan_count_priv_cond(mlan_adapter *pmadapter, 4335 t_bool (*count_cond)(pmlan_private pmpriv), 4336 t_bool (*check_cond)(pmlan_private pmpriv)) 4337 { 4338 pmlan_private pmpriv; 4339 int count = 0; 4340 int i; 4341 4342 if (pmadapter == MNULL || count_cond == MNULL) 4343 return 0; 4344 4345 for (i = 0; i < pmadapter->priv_num; i++) { 4346 pmpriv = pmadapter->priv[i]; 4347 if (pmpriv) { 4348 if ((check_cond == MNULL) || 4349 (check_cond && check_cond(pmpriv))) { 4350 if (count_cond(pmpriv)) 4351 count++; 4352 } 4353 } 4354 } 4355 4356 return count; 4357 } 4358 4359 /** 4360 * @brief This function runs a procedure on each priv. 4361 * Which privs it is run on can be configured via a condition. 4362 * 4363 * @param pmadapter A pointer to mlan_adapter 4364 * @param operation Function pointer to produedure to operate on priv 4365 * @param check_cond Function pointer to condition to decide whether priv 4366 * operated on or not. Use MNULL to run on all privs. 4367 * 4368 * @return Number of privs that operation was run on. 4369 */ 4370 static INLINE int 4371 wlan_do_task_on_privs(mlan_adapter *pmadapter, 4372 t_void (*operation)(pmlan_private pmpriv), 4373 t_bool (*check_cond)(pmlan_private pmpriv)) 4374 { 4375 pmlan_private pmpriv; 4376 int count = 0; 4377 int i; 4378 4379 if (pmadapter == MNULL || operation == MNULL) 4380 return 0; 4381 4382 for (i = 0; i < pmadapter->priv_num; i++) { 4383 pmpriv = pmadapter->priv[i]; 4384 if (pmpriv) { 4385 if ((check_cond == MNULL) || 4386 (check_cond && check_cond(pmpriv))) { 4387 operation(pmpriv); 4388 count++; 4389 } 4390 } 4391 } 4392 4393 return count; 4394 } 4395 4396 /** 4397 * @brief This function builds a list of privs that test for a condition 4398 * This is useful if you need to do a number of operations on the same set 4399 * of privs. For one-off tasks, the above two functions might be better. 4400 * 4401 * @param pmadapter A pointer to mlan_adapter 4402 * @param check_cond Function pointer to condition to decide whether priv 4403 * should be placed in the list. 4404 * @param ppriv_list Output param. Externally supplied array of mlan_private* 4405 * to hold priv's that test positive with check_cond. 4406 * Array size should be at least pmadapter->priv_num. 4407 * 4408 * @return Number of privs in ppriv_list 4409 * 4410 * @sa wlan_count_priv_cond 4411 */ 4412 static INLINE int 4413 wlan_get_privs_by_cond(mlan_adapter *pmadapter, 4414 t_bool (*check_cond)(pmlan_private pmpriv), 4415 mlan_private **ppriv_list) 4416 { 4417 pmlan_private pmpriv; 4418 int count = 0; 4419 int i; 4420 4421 if (pmadapter == MNULL || check_cond == MNULL || ppriv_list == MNULL) 4422 return 0; 4423 4424 for (i = 0; i < pmadapter->priv_num; i++) { 4425 pmpriv = pmadapter->priv[i]; 4426 if (pmpriv) { 4427 if (check_cond(pmpriv)) 4428 ppriv_list[count++] = pmpriv; 4429 } 4430 } 4431 4432 return count; 4433 } 4434 4435 /** 4436 * @brief This function builds a list of privs that test against two conditions 4437 * This is useful if you need to do a number of operations on the same set 4438 * of privs. Can choose whether both conditions (AND) or either condition (OR) 4439 * is required. 4440 * 4441 * @param pmadapter A pointer to mlan_adapter 4442 * @param check_cond Function pointer to condition to decide whether priv 4443 * should be placed in the list. 4444 * @param check_cond_2 Function pointer to second condition to check. 4445 * @param and_conditions If MTRUE, both conditions must be met (AND), 4446 * else either condition can be met (OR). 4447 * @param ppriv_list Output param. Externally supplied array of 4448 * mlan_private* to hold priv's that test positive with check_cond. Array size 4449 * should be at least pmadapter->priv_num. 4450 * 4451 * @return Number of privs in ppriv_list 4452 * 4453 * @sa wlan_count_priv_cond, wlan_get_privs_by_cond 4454 */ 4455 static INLINE int 4456 wlan_get_privs_by_two_cond(mlan_adapter *pmadapter, 4457 t_bool (*check_cond)(pmlan_private pmpriv), 4458 t_bool (*check_cond_2)(pmlan_private pmpriv), 4459 t_bool and_conditions, mlan_private **ppriv_list) 4460 { 4461 pmlan_private pmpriv; 4462 int count = 0; 4463 int i; 4464 4465 if (pmadapter == MNULL || check_cond == MNULL || 4466 check_cond_2 == MNULL || ppriv_list == MNULL) 4467 return 0; 4468 4469 for (i = 0; i < pmadapter->priv_num; i++) { 4470 pmpriv = pmadapter->priv[i]; 4471 if (pmpriv) { 4472 if (and_conditions) { 4473 if (check_cond(pmpriv) && check_cond_2(pmpriv)) 4474 ppriv_list[count++] = pmpriv; 4475 } else { 4476 if (check_cond(pmpriv) || check_cond_2(pmpriv)) 4477 ppriv_list[count++] = pmpriv; 4478 } 4479 } 4480 } 4481 4482 return count; 4483 } 4484 #endif /* !_MLAN_MAIN_H_ */ 4485