bc6ded567e78e6b26f727b26cc9d5c7fdbb793fd
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / mt5931_kk / drv_wlan / include / mgmt / scan.h
1 /*
2 ** $Id: @(#)
3 */
4
5 /*! \file   "scan.h"
6     \brief
7
8 */
9
10 /*******************************************************************************
11 * Copyright (c) 2009 MediaTek Inc.
12 *
13 * All rights reserved. Copying, compilation, modification, distribution
14 * or any other use whatsoever of this material is strictly prohibited
15 * except in accordance with a Software License Agreement with
16 * MediaTek Inc.
17 ********************************************************************************
18 */
19
20 /*******************************************************************************
21 * LEGAL DISCLAIMER
22 *
23 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
24 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
25 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
26 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
27 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
28 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
29 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
30 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
31 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
32 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
33 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
34 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
35 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
36 *
37 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
38 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
39 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
40 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
41 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
42 *
43 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
44 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
45 * OF LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
46 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
47 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
48 * (ICC).
49 ********************************************************************************
50 */
51
52 /*
53 ** $Log: scan.h $
54  *
55  * 01 16 2012 cp.wu
56  * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with corresponding network configuration 
57  * add wlanSetPreferBandByNetwork() for glue layer to invoke for setting preferred band configuration corresponding to network type.
58  *
59  * 08 11 2011 cp.wu
60  * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
61  * sparse channel detection:
62  * driver: collect sparse channel information with scan-done event
63
64  *
65  * 07 18 2011 cp.wu
66  * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
67  * add framework in driver domain for supporting new SCAN_REQ_V2 for more than 1 SSID support as well as uProbeDelay in NDIS 6.x driver model
68  *
69  * 06 27 2011 cp.wu
70  * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky AP which use space character as hidden SSID
71  * allow to have a single BSSID with multiple SSID to be presented in scanning result
72  *
73  * 04 18 2011 terry.wu
74  * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
75  * Remove flag CFG_WIFI_DIRECT_MOVED.
76  *
77  * 02 09 2011 wh.su
78  * [WCXRP00000433] [MT6620 Wi-Fi][Driver] Remove WAPI structure define for avoid P2P module with structure miss-align pointer issue
79  * always pre-allio WAPI related structure for align p2p module.
80  *
81  * 01 14 2011 yuche.tsai
82  * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
83  * Fix compile error.
84  *
85  * 09 08 2010 cp.wu
86  * NULL
87  * use static memory pool for storing IEs of scanning result.
88  *
89  * 09 03 2010 kevin.huang
90  * NULL
91  * Refine #include sequence and solve recursive/nested #include issue
92  *
93  * 08 31 2010 kevin.huang
94  * NULL
95  * Use LINK LIST operation to process SCAN result
96  *
97  * 08 30 2010 cp.wu
98  * NULL
99  * eliminate klockwork errors
100  *
101  * 08 16 2010 cp.wu
102  * NULL
103  * add interface for RLM to trigger OBSS-SCAN.
104  *
105  * 08 12 2010 yuche.tsai
106  * NULL
107  * Add a functio prototype to find p2p descriptor of a bss descriptor directly.
108  *
109  * 08 11 2010 yuche.tsai
110  * NULL
111  * Add function prototype for return channel.
112  * modify data structure for scan specific device ID or TYPE. (Move from P2P Connection Settings to Scan Param)
113  *
114  * 08 05 2010 yuche.tsai
115  * NULL
116  * Check-in P2P Device Discovery Feature.
117  *
118  * 08 02 2010 yuche.tsai
119  * NULL
120  * P2P Group Negotiation Code Check in.
121  *
122  * 07 26 2010 yuche.tsai
123  *
124  * Add a option for channel time extention in scan abort command.
125  *
126  * 07 21 2010 yuche.tsai
127  *
128  * Add for P2P Scan Result Parsing & Saving.
129  *
130  * 07 19 2010 yuche.tsai
131  *
132  * Scan status "FIND" is used for P2P FSM find state.
133  *
134  * 07 19 2010 cp.wu
135  *
136  * [WPD00003833] [MT6620 and MT5931] Driver migration.
137  * SCN module is now able to handle multiple concurrent scanning requests
138  *
139  * 07 14 2010 cp.wu
140  *
141  * [WPD00003833] [MT6620 and MT5931] Driver migration.
142  * pass band with channel number information as scan parameter
143  *
144  * 07 14 2010 cp.wu
145  *
146  * [WPD00003833] [MT6620 and MT5931] Driver migration.
147  * remove timer in DRV-SCN.
148  *
149  * 07 09 2010 cp.wu
150  *
151  * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
152  * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
153  * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
154  *
155  * 07 08 2010 cp.wu
156  *
157  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
158  *
159  * 07 01 2010 cp.wu
160  * [WPD00003833][MT6620 and MT5931] Driver migration
161  * add scan uninitialization procedure
162  *
163  * 07 01 2010 cp.wu
164  * [WPD00003833][MT6620 and MT5931] Driver migration
165  * implementation of DRV-SCN and related mailbox message handling.
166  *
167  * 06 25 2010 cp.wu
168  * [WPD00003833][MT6620 and MT5931] Driver migration
169  * modify Beacon/ProbeResp to complete parsing,
170  * because host software has looser memory usage restriction
171  *
172  * 06 17 2010 yuche.tsai
173  * [WPD00003839][MT6620 5931][P2P] Feature migration
174  * Add P2P related field in SCAN_PARAM_T.
175  *
176  * 06 14 2010 cp.wu
177  * [WPD00003833][MT6620 and MT5931] Driver migration
178  * saa_fsm.c is migrated.
179  *
180  * 06 14 2010 cp.wu
181  * [WPD00003833][MT6620 and MT5931] Driver migration
182  * add management dispatching function table.
183  *
184  * 06 14 2010 cp.wu
185  * [WPD00003833][MT6620 and MT5931] Driver migration
186  * restore utility function invoking via hem_mbox to direct calls
187  *
188  * 06 11 2010 cp.wu
189  * [WPD00003833][MT6620 and MT5931] Driver migration
190  * auth.c is migrated.
191  *
192  * 06 10 2010 cp.wu
193  * [WPD00003833][MT6620 and MT5931] Driver migration
194  * add buildable & linkable ais_fsm.c
195  *
196  * related reference are still waiting to be resolved
197  *
198  * 06 07 2010 cp.wu
199  * [WPD00003833][MT6620 and MT5931] Driver migration
200  * add aa_fsm.h, ais_fsm.h, bss.h, mib.h and scan.h.
201  *
202  * 05 12 2010 kevin.huang
203  * [BORA00000794][WIFISYS][New Feature]Power Management Support
204  * Add Power Management - Legacy PS-POLL support.
205  *
206  * 04 13 2010 kevin.huang
207  * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
208  *
209  * Add new HW CH macro support
210  *
211  * 03 16 2010 kevin.huang
212  * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
213  * Add AdHoc Mode
214  *
215  * 03 10 2010 kevin.huang
216  * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
217  *
218  *  *  *  *  *  * Add Channel Manager for arbitration of JOIN and SCAN Req
219  *
220  * 02 26 2010 kevin.huang
221  * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
222  * Modify scanBuildProbeReqFrameCommonIEs() to support P2P SCAN
223  *
224  * 02 23 2010 wh.su
225  * [BORA00000592][MT6620 Wi-Fi] Adding the security related code for driver
226  * refine the scan procedure, reduce the WPA and WAPI IE parsing, and move the parsing to the time for join.
227  *
228  * 02 23 2010 kevin.huang
229  * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
230  * Add support scan channel 1~14 and update scan result's frequency infou1rwduu`wvpghlqg|n`slk+mpdkb
231  *
232  * 02 04 2010 kevin.huang
233  * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
234  * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
235  *
236  * 01 27 2010 wh.su
237  * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
238  * add and fixed some security function.
239  *
240  * 01 07 2010 kevin.huang
241  * [BORA00000018]Integrate WIFI part into BORA for the 1st time
242  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
243  *
244  * Simplify the process of Beacon during SCAN and remove redundant variable in PRE_BSS_DESC_T
245  *
246  * Dec 7 2009 mtk01088
247  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
248  * adding variable for wapi ap
249  *
250  * Dec 4 2009 mtk01088
251  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
252  * remove non-used secuirty variavle
253  *
254  * Dec 3 2009 mtk01461
255  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
256  * Refine data structure of BSS_DESC_T and PRE_BSS_DESC_T
257  *
258  * Nov 24 2009 mtk01461
259  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
260  * Add eNetType to rScanParam and revise MGMT Handler with Retain Status
261  *
262  * Nov 23 2009 mtk01461
263  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
264  * Add ucAvailablePhyTypeSet to BSS_DESC_T
265  *
266  * Nov 20 2009 mtk01461
267  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
268  * Add aucSrcAddress to SCAN_PARAM_T for P2P's Device Address
269  *
270  * Nov 19 2009 mtk01088
271  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
272  * adding the security related variable
273  *
274  * Nov 18 2009 mtk01088
275  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
276  * adding the security ie filed for scan parsing
277  *
278  * Nov 16 2009 mtk01461
279  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
280  * Add scanSearchBssDescByPolicy()
281  *
282  * Nov 5 2009 mtk01461
283  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
284  * Add function declarations of scan_fsm.c
285  *
286  * Oct 30 2009 mtk01461
287  * [BORA00000018] Integrate WIFI part into BORA for the 1st time
288  * Add scan.h to source control
289 **
290 */
291
292 #ifndef _SCAN_H
293 #define _SCAN_H
294
295 /*******************************************************************************
296 *                         C O M P I L E R   F L A G S
297 ********************************************************************************
298 */
299
300 /*******************************************************************************
301 *                    E X T E R N A L   R E F E R E N C E S
302 ********************************************************************************
303 */
304
305 /*******************************************************************************
306 *                              C O N S T A N T S
307 ********************************************************************************
308 */
309 /*! Maximum buffer size of SCAN list */
310 #define SCN_MAX_BUFFER_SIZE                 (CFG_MAX_NUM_BSS_LIST * ALIGN_4(sizeof(BSS_DESC_T)))
311
312 #define SCN_RM_POLICY_EXCLUDE_CONNECTED     BIT(0) // Remove SCAN result except the connected one.
313 #define SCN_RM_POLICY_TIMEOUT               BIT(1) // Remove the timeout one
314 #define SCN_RM_POLICY_OLDEST_HIDDEN         BIT(2) // Remove the oldest one with hidden ssid
315 #define SCN_RM_POLICY_SMART_WEAKEST         BIT(3) /* If there are more than half BSS which has the
316                                                     * same ssid as connection setting, remove the weakest one from them
317                                                     * Else remove the weakest one.
318                                                     */
319 #define SCN_RM_POLICY_ENTIRE                BIT(4) // Remove entire SCAN result
320
321 #define SCN_BSS_DESC_SAME_SSID_THRESHOLD    3 /* This is used by POLICY SMART WEAKEST,
322                                                * If exceed this value, remove weakest BSS_DESC_T
323                                                * with same SSID first in large network.
324                                                */
325
326 #define SCN_BSS_DESC_REMOVE_TIMEOUT_SEC     5 // Second.
327                                               /* This is used by POLICY TIMEOUT,
328                                                * If exceed this value, remove timeout BSS_DESC_T.
329                                                */
330
331
332
333
334 #define SCN_PROBE_DELAY_MSEC                0
335
336 #define SCN_ADHOC_BSS_DESC_TIMEOUT_SEC      5 // Second.
337
338 /*----------------------------------------------------------------------------*/
339 /* MSG_SCN_SCAN_REQ                                                           */
340 /*----------------------------------------------------------------------------*/
341 #define SCAN_REQ_SSID_WILDCARD              BIT(0)
342 #define SCAN_REQ_SSID_P2P_WILDCARD          BIT(1)
343 #define SCAN_REQ_SSID_SPECIFIED             BIT(2)
344
345
346 /*----------------------------------------------------------------------------*/
347 /* Support Multiple SSID SCAN                                                 */
348 /*----------------------------------------------------------------------------*/
349 #define SCN_SSID_MAX_NUM                        4
350
351
352 /*******************************************************************************
353 *                             D A T A   T Y P E S
354 ********************************************************************************
355 */
356 typedef enum _ENUM_SCAN_TYPE_T {
357     SCAN_TYPE_PASSIVE_SCAN = 0,
358     SCAN_TYPE_ACTIVE_SCAN,
359     SCAN_TYPE_NUM
360 } ENUM_SCAN_TYPE_T, *P_ENUM_SCAN_TYPE_T;
361
362 typedef enum _ENUM_SCAN_STATE_T {
363     SCAN_STATE_IDLE = 0,
364     SCAN_STATE_SCANNING,
365     SCAN_STATE_NUM
366 } ENUM_SCAN_STATE_T;
367
368 typedef enum _ENUM_SCAN_CHANNEL_T {
369     SCAN_CHANNEL_FULL = 0,
370     SCAN_CHANNEL_2G4,
371     SCAN_CHANNEL_5G,
372     SCAN_CHANNEL_P2P_SOCIAL,
373     SCAN_CHANNEL_SPECIFIED,
374     SCAN_CHANNEL_NUM
375 } ENUM_SCAN_CHANNEL, *P_ENUM_SCAN_CHANNEL;
376
377 typedef struct _MSG_SCN_FSM_T {
378     MSG_HDR_T       rMsgHdr;        /* Must be the first member */
379     UINT_32         u4Dummy;
380 } MSG_SCN_FSM_T, *P_MSG_SCN_FSM_T;
381
382
383
384 /*----------------------------------------------------------------------------*/
385 /* BSS Descriptors                                                            */
386 /*----------------------------------------------------------------------------*/
387 struct _BSS_DESC_T {
388     LINK_ENTRY_T            rLinkEntry;
389
390     UINT_8                  aucBSSID[MAC_ADDR_LEN];
391     UINT_8                  aucSrcAddr[MAC_ADDR_LEN]; /* For IBSS, the SrcAddr is different from BSSID */
392
393     BOOLEAN                 fgIsConnecting; /* If we are going to connect to this BSS
394                                              * (JOIN or ROAMING to another BSS), don't
395                                              * remove this record from BSS List.
396                                              */
397     BOOLEAN                 fgIsConnected; /* If we have connected to this BSS (NORMAL_TR),
398                                             * don't removed this record from BSS list.
399                                             */
400
401     BOOLEAN                 fgIsHiddenSSID; /* When this flag is TRUE, means the SSID
402                                              * of this BSS is not known yet.
403                                              */
404     UINT_8                  ucSSIDLen;
405     UINT_8                  aucSSID[ELEM_MAX_LEN_SSID];
406
407     OS_SYSTIME              rUpdateTime;
408
409     ENUM_BSS_TYPE_T         eBSSType;
410
411     UINT_16                 u2CapInfo;
412
413     UINT_16                 u2BeaconInterval;
414     UINT_16                 u2ATIMWindow;
415
416     UINT_16                 u2OperationalRateSet;
417     UINT_16                 u2BSSBasicRateSet;
418     BOOLEAN                 fgIsUnknownBssBasicRate;
419
420     BOOLEAN                 fgIsERPPresent;
421     BOOLEAN                 fgIsHTPresent;
422
423     UINT_8                  ucPhyTypeSet;           /* Available PHY Type Set of this BSS */
424
425     UINT_8                  ucChannelNum;
426
427     ENUM_CHNL_EXT_T         eSco;                   /* Record bandwidth for association process
428                                                        Some AP will send association resp by 40MHz BW */
429     ENUM_BAND_T             eBand;
430
431     UINT_8                  ucDTIMPeriod;
432
433     BOOLEAN                 fgIsLargerTSF; /* This BSS's TimeStamp is larger than us(TCL == 1 in RX_STATUS_T) */
434
435     UINT_8                  ucRCPI;
436 #if CFG_SUPPORT_RSSI_SMOOTH
437 //------------------------------- jbx add 0508-------------------------------------------------
438     UINT_8                  ucRCPI_pre_real;
439
440     UINT_8                  ucRCPI_pre_fake;
441 //------------------------------- jbx add 0508-------------------------------------------------
442 #endif
443     UINT_8                  ucWmmFlag; /* A flag to indicate this BSS's WMM capability */
444
445     /*! \brief The srbiter Search State will matched the scan result,
446                and saved the selected cipher and akm, and report the score,
447                for arbiter join state, join module will carry this target BSS
448                to rsn generate ie function, for gen wpa/rsn ie */
449     UINT_32                 u4RsnSelectedGroupCipher;
450     UINT_32                 u4RsnSelectedPairwiseCipher;
451     UINT_32                 u4RsnSelectedAKMSuite;
452
453     UINT_16                 u2RsnCap;
454
455     RSN_INFO_T              rRSNInfo;
456     RSN_INFO_T              rWPAInfo;
457 #if 1//CFG_SUPPORT_WAPI
458     WAPI_INFO_T             rIEWAPI;
459     BOOL                    fgIEWAPI;
460 #endif
461     BOOL                    fgIERSN;
462     BOOL                    fgIEWPA;
463
464     /*! \brief RSN parameters selected for connection */
465     /*! \brief The Select score for final AP selection,
466                0, no sec, 1,2,3 group cipher is WEP, TKIP, CCMP */
467     UINT_8                  ucEncLevel;
468
469 #if CFG_ENABLE_WIFI_DIRECT
470     BOOLEAN               fgIsP2PPresent;
471     P_P2P_DEVICE_DESC_T  prP2pDesc;
472
473     UINT_8                  aucIntendIfAddr[MAC_ADDR_LEN]; /* For IBSS, the SrcAddr is different from BSSID */
474 //    UINT_8 ucDevCapabilityBitmap;  /* Device Capability Attribute. (P2P_DEV_CAPABILITY_XXXX) */
475 //    UINT_8 ucGroupCapabilityBitmap;  /* Group Capability Attribute. (P2P_GROUP_CAPABILITY_XXXX) */
476
477     LINK_T rP2pDeviceList;
478
479 //    P_LINK_T prP2pDeviceList;
480
481     /* For
482       *    1. P2P Capability.
483       *    2. P2P Device ID. ( in aucSrcAddr[] )
484       *    3. NOA   (TODO:)
485       *    4. Extend Listen Timing. (Probe Rsp)  (TODO:)
486       *    5. P2P Device Info. (Probe Rsp)
487       *    6. P2P Group Info. (Probe Rsp)
488       */
489 #endif
490
491     BOOLEAN                 fgIsIEOverflow; /* The received IE length exceed the maximum IE buffer size */
492     UINT_16                 u2IELength; /* The byte count of aucIEBuf[] */
493
494     ULARGE_INTEGER          u8TimeStamp; /* Place u8TimeStamp before aucIEBuf[1] to force DW align */
495
496     UINT_8                  aucIEBuf[CFG_IE_BUFFER_SIZE];
497 };
498
499
500 typedef struct _SCAN_PARAM_T { /* Used by SCAN FSM */
501     /* Active or Passive */
502     ENUM_SCAN_TYPE_T            eScanType;
503
504     /* Network Type */
505     ENUM_NETWORK_TYPE_INDEX_T   eNetTypeIndex;
506
507     /* Specified SSID Type */
508     UINT_8                      ucSSIDType;
509     UINT_8                      ucSSIDNum;
510
511     /* Length of Specified SSID */
512     UINT_8                      ucSpecifiedSSIDLen[SCN_SSID_MAX_NUM];
513
514     /* Specified SSID */
515     UINT_8                      aucSpecifiedSSID[SCN_SSID_MAX_NUM][ELEM_MAX_LEN_SSID];
516
517 #if CFG_ENABLE_WIFI_DIRECT
518     BOOLEAN                     fgFindSpecificDev;                  /* P2P: Discovery Protocol */
519     UINT_8                      aucDiscoverDevAddr[MAC_ADDR_LEN];
520     BOOLEAN                     fgIsDevType;
521     P2P_DEVICE_TYPE_T           rDiscoverDevType;
522
523     UINT_16                     u2PassiveListenInterval;
524     // TODO: Find Specific Device Type.
525 #endif /* CFG_SUPPORT_P2P */
526
527     BOOLEAN                     fgIsObssScan;
528     BOOLEAN                     fgIsScanV2;
529
530     /* Run time flags */
531     UINT_16                     u2ProbeDelayTime;
532
533     /* channel information */
534     ENUM_SCAN_CHANNEL   eScanChannel;
535     UINT_8              ucChannelListNum;
536     RF_CHANNEL_INFO_T   arChnlInfoList[MAXIMUM_OPERATION_CHANNEL_LIST];
537
538     /* Feedback information */
539     UINT_8              ucSeqNum;
540
541     /* Information Element */
542     UINT_16             u2IELen;
543     UINT_8              aucIE[MAX_IE_LENGTH];
544
545 } SCAN_PARAM_T, *P_SCAN_PARAM_T;
546
547 typedef struct _SCAN_INFO_T {
548     ENUM_SCAN_STATE_T       eCurrentState;  /* Store the STATE variable of SCAN FSM */
549
550     OS_SYSTIME              rLastScanCompletedTime;
551
552     SCAN_PARAM_T            rScanParam;
553
554     UINT_32                 u4NumOfBssDesc;
555
556     UINT_8                  aucScanBuffer[SCN_MAX_BUFFER_SIZE];
557
558     LINK_T                  rBSSDescList;
559
560     LINK_T                  rFreeBSSDescList;
561
562     LINK_T                  rPendingMsgList;
563
564     /* Sparse Channel Detection */
565     BOOLEAN                 fgIsSparseChannelValid;
566     RF_CHANNEL_INFO_T       rSparseChannel;
567
568 } SCAN_INFO_T, *P_SCAN_INFO_T;
569
570
571 /* Incoming Mailbox Messages */
572 typedef struct _MSG_SCN_SCAN_REQ_T {
573     MSG_HDR_T           rMsgHdr;        /* Must be the first member */
574     UINT_8              ucSeqNum;
575     UINT_8              ucNetTypeIndex;
576     ENUM_SCAN_TYPE_T    eScanType;
577     UINT_8              ucSSIDType;     /* BIT(0) wildcard / BIT(1) P2P-wildcard / BIT(2) specific */
578     UINT_8              ucSSIDLength;
579     UINT_8              aucSSID[PARAM_MAX_LEN_SSID];
580 #if CFG_ENABLE_WIFI_DIRECT
581     UINT_16             u2ChannelDwellTime;  /* In TU. 1024us. */
582 #endif
583     ENUM_SCAN_CHANNEL   eScanChannel;
584     UINT_8              ucChannelListNum;
585     RF_CHANNEL_INFO_T   arChnlInfoList[MAXIMUM_OPERATION_CHANNEL_LIST];
586     UINT_16             u2IELen;
587     UINT_8              aucIE[MAX_IE_LENGTH];
588 } MSG_SCN_SCAN_REQ, *P_MSG_SCN_SCAN_REQ;
589
590 typedef struct _MSG_SCN_SCAN_REQ_V2_T {
591     MSG_HDR_T           rMsgHdr;        /* Must be the first member */
592     UINT_8              ucSeqNum;
593     UINT_8              ucNetTypeIndex;
594     ENUM_SCAN_TYPE_T    eScanType;
595     UINT_8              ucSSIDType;     /* BIT(0) wildcard / BIT(1) P2P-wildcard / BIT(2) specific */
596     UINT_8              ucSSIDNum;
597     P_PARAM_SSID_T      prSsid;
598     UINT_16             u2ProbeDelay;
599     UINT_16             u2ChannelDwellTime;  /* In TU. 1024us. */
600     ENUM_SCAN_CHANNEL   eScanChannel;
601     UINT_8              ucChannelListNum;
602     RF_CHANNEL_INFO_T   arChnlInfoList[MAXIMUM_OPERATION_CHANNEL_LIST];
603     UINT_16             u2IELen;
604     UINT_8              aucIE[MAX_IE_LENGTH];
605 } MSG_SCN_SCAN_REQ_V2, *P_MSG_SCN_SCAN_REQ_V2;
606
607
608 typedef struct _MSG_SCN_SCAN_CANCEL_T {
609     MSG_HDR_T           rMsgHdr;        /* Must be the first member */
610     UINT_8              ucSeqNum;
611     UINT_8              ucNetTypeIndex;
612 #if CFG_ENABLE_WIFI_DIRECT
613     BOOLEAN           fgIsChannelExt;
614 #endif
615 } MSG_SCN_SCAN_CANCEL, *P_MSG_SCN_SCAN_CANCEL;
616
617 /* Outgoing Mailbox Messages */
618 typedef enum _ENUM_SCAN_STATUS_T {
619     SCAN_STATUS_DONE = 0,
620     SCAN_STATUS_CANCELLED,
621     SCAN_STATUS_FAIL,
622     SCAN_STATUS_BUSY,
623     SCAN_STATUS_NUM
624 } ENUM_SCAN_STATUS, *P_ENUM_SCAN_STATUS;
625
626 typedef struct _MSG_SCN_SCAN_DONE_T {
627     MSG_HDR_T           rMsgHdr;        /* Must be the first member */
628     UINT_8              ucSeqNum;
629     UINT_8              ucNetTypeIndex;
630     ENUM_SCAN_STATUS    eScanStatus;
631 } MSG_SCN_SCAN_DONE, *P_MSG_SCN_SCAN_DONE;
632
633 /*******************************************************************************
634 *                            P U B L I C   D A T A
635 ********************************************************************************
636 */
637
638 /*******************************************************************************
639 *                           P R I V A T E   D A T A
640 ********************************************************************************
641 */
642
643 /*******************************************************************************
644 *                                 M A C R O S
645 ********************************************************************************
646 */
647
648 /*******************************************************************************
649 *                   F U N C T I O N   D E C L A R A T I O N S
650 ********************************************************************************
651 */
652 /*----------------------------------------------------------------------------*/
653 /* Routines in scan.c                                                         */
654 /*----------------------------------------------------------------------------*/
655 VOID
656 scnInit (
657     IN P_ADAPTER_T prAdapter
658     );
659
660 VOID
661 scnUninit (
662     IN P_ADAPTER_T prAdapter
663     );
664
665 /* BSS-DESC Search */
666 P_BSS_DESC_T
667 scanSearchBssDescByBssid (
668     IN P_ADAPTER_T prAdapter,
669     IN UINT_8 aucBSSID[]
670     );
671
672 P_BSS_DESC_T
673 scanSearchBssDescByBssidAndSsid (
674     IN P_ADAPTER_T prAdapter,
675     IN UINT_8 aucBSSID[],
676     IN BOOLEAN fgCheckSsid,
677     IN P_PARAM_SSID_T prSsid
678     );
679
680 P_BSS_DESC_T
681 scanSearchBssDescByTA (
682     IN P_ADAPTER_T prAdapter,
683     IN UINT_8 aucSrcAddr[]
684     );
685
686 P_BSS_DESC_T
687 scanSearchBssDescByTAAndSsid (
688     IN P_ADAPTER_T prAdapter,
689     IN UINT_8 aucSrcAddr[],
690     IN BOOLEAN fgCheckSsid,
691     IN P_PARAM_SSID_T prSsid
692     );
693
694
695 /* BSS-DESC Search - Alternative */
696 P_BSS_DESC_T
697 scanSearchExistingBssDesc (
698     IN P_ADAPTER_T prAdapter,
699     IN ENUM_BSS_TYPE_T eBSSType,
700     IN UINT_8 aucBSSID[],
701     IN UINT_8 aucSrcAddr[]
702     );
703
704 P_BSS_DESC_T
705 scanSearchExistingBssDescWithSsid (
706     IN P_ADAPTER_T prAdapter,
707     IN ENUM_BSS_TYPE_T eBSSType,
708     IN UINT_8 aucBSSID[],
709     IN UINT_8 aucSrcAddr[],
710     IN BOOLEAN fgCheckSsid,
711     IN P_PARAM_SSID_T prSsid
712     );
713
714
715 /* BSS-DESC Allocation */
716 P_BSS_DESC_T
717 scanAllocateBssDesc (
718     IN P_ADAPTER_T prAdapter
719     );
720
721 /* BSS-DESC Removal */
722 VOID
723 scanRemoveBssDescsByPolicy (
724     IN P_ADAPTER_T prAdapter,
725     IN UINT_32 u4RemovePolicy
726     );
727
728 VOID
729 scanRemoveBssDescByBssid (
730     IN P_ADAPTER_T prAdapter,
731     IN UINT_8 aucBSSID[]
732     );
733
734 VOID
735 scanRemoveBssDescByBandAndNetwork (
736     IN P_ADAPTER_T prAdapter,
737     IN ENUM_BAND_T eBand,
738     IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
739     );
740
741 /* BSS-DESC State Change */
742 VOID
743 scanRemoveConnFlagOfBssDescByBssid (
744     IN P_ADAPTER_T prAdapter,
745     IN UINT_8 aucBSSID[]
746     );
747
748 #if 0
749 /* BSS-DESC Insertion */
750 P_BSS_DESC_T
751 scanAddToInternalScanResult (
752     IN P_ADAPTER_T prAdapter,
753     IN P_SW_RFB_T prSWRfb,
754     IN P_BSS_DESC_T prBssDesc
755     );
756 #endif
757
758 /* BSS-DESC Insertion - ALTERNATIVE */
759 P_BSS_DESC_T
760 scanAddToBssDesc (
761     IN P_ADAPTER_T prAdapter,
762     IN P_SW_RFB_T prSwRfb
763     );
764
765 WLAN_STATUS
766 scanProcessBeaconAndProbeResp (
767     IN P_ADAPTER_T prAdapter,
768     IN P_SW_RFB_T prSWRfb
769     );
770
771 VOID
772 scanBuildProbeReqFrameCommonIEs (
773     IN P_MSDU_INFO_T    prMsduInfo,
774     IN PUINT_8          pucDesiredSsid,
775     IN UINT_32          u4DesiredSsidLen,
776     IN UINT_16          u2SupportedRateSet
777     );
778
779 WLAN_STATUS
780 scanSendProbeReqFrames (
781     IN P_ADAPTER_T prAdapter,
782     IN P_SCAN_PARAM_T prScanParam
783     );
784
785 VOID
786 scanUpdateBssDescForSearch (
787     IN P_ADAPTER_T prAdapter,
788     IN P_BSS_DESC_T prBssDesc
789     );
790
791 P_BSS_DESC_T
792 scanSearchBssDescByPolicy (
793     IN P_ADAPTER_T prAdapter,
794     IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex
795     );
796
797 WLAN_STATUS
798 scanAddScanResult (
799     IN P_ADAPTER_T prAdapter,
800     IN P_BSS_DESC_T prBssDesc,
801     IN P_SW_RFB_T prSwRfb
802     );
803
804 /*----------------------------------------------------------------------------*/
805 /* Routines in scan_fsm.c                                                     */
806 /*----------------------------------------------------------------------------*/
807 VOID
808 scnFsmSteps (
809     IN P_ADAPTER_T prAdapter,
810     IN ENUM_SCAN_STATE_T eNextState
811     );
812
813 /*----------------------------------------------------------------------------*/
814 /* Command Routines                                                           */
815 /*----------------------------------------------------------------------------*/
816 VOID
817 scnSendScanReq (
818     IN P_ADAPTER_T prAdapter
819     );
820
821 VOID
822 scnSendScanReqV2 (
823     IN P_ADAPTER_T prAdapter
824     );
825
826 /*----------------------------------------------------------------------------*/
827 /* RX Event Handling                                                          */
828 /*----------------------------------------------------------------------------*/
829 VOID
830 scnEventScanDone(
831     IN P_ADAPTER_T          prAdapter,
832     IN P_EVENT_SCAN_DONE    prScanDone
833     );
834
835 /*----------------------------------------------------------------------------*/
836 /* Mailbox Message Handling                                                   */
837 /*----------------------------------------------------------------------------*/
838 VOID
839 scnFsmMsgStart (
840     IN P_ADAPTER_T prAdapter,
841     IN P_MSG_HDR_T prMsgHdr
842     );
843
844 VOID
845 scnFsmMsgAbort (
846     IN P_ADAPTER_T prAdapter,
847     IN P_MSG_HDR_T prMsgHdr
848     );
849
850 VOID
851 scnFsmHandleScanMsg (
852     IN P_ADAPTER_T prAdapter,
853     IN P_MSG_SCN_SCAN_REQ prScanReqMsg
854     );
855
856 VOID
857 scnFsmHandleScanMsgV2 (
858     IN P_ADAPTER_T prAdapter,
859     IN P_MSG_SCN_SCAN_REQ_V2 prScanReqMsg
860     );
861
862 VOID
863 scnFsmRemovePendingMsg (
864     IN P_ADAPTER_T  prAdapter,
865     IN UINT_8       ucSeqNum,
866     IN UINT_8       ucNetTypeIndex
867     );
868
869 /*----------------------------------------------------------------------------*/
870 /* Mailbox Message Generation                                                 */
871 /*----------------------------------------------------------------------------*/
872 VOID
873 scnFsmGenerateScanDoneMsg (
874     IN P_ADAPTER_T          prAdapter,
875     IN UINT_8               ucSeqNum,
876     IN UINT_8               ucNetTypeIndex,
877     IN ENUM_SCAN_STATUS     eScanStatus
878     );
879
880 /*----------------------------------------------------------------------------*/
881 /* Query for sparse channel                                                   */
882 /*----------------------------------------------------------------------------*/
883 BOOLEAN
884 scnQuerySparseChannel (
885     IN P_ADAPTER_T      prAdapter,
886     P_ENUM_BAND_T       prSparseBand,
887     PUINT_8             pucSparseChannel
888     );
889
890
891 #endif /* _SCAN_H */
892
893