TWD/MacServices/ScanSrv.h
changeset 0 10c42ec6c05f
equal deleted inserted replaced
-1:000000000000 0:10c42ec6c05f
       
     1 /*
       
     2  * ScanSrv.h
       
     3  *
       
     4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.      
       
     5  * All rights reserved.      
       
     6  * 
       
     7  * This program and the accompanying materials are made available under the 
       
     8  * terms of the Eclipse Public License v1.0 or BSD License which accompanies
       
     9  * this distribution. The Eclipse Public License is available at
       
    10  * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.                                   
       
    11  *                                                                       
       
    12  * Redistribution and use in source and binary forms, with or without    
       
    13  * modification, are permitted provided that the following conditions    
       
    14  * are met:                                                              
       
    15  *                                                                       
       
    16  *  * Redistributions of source code must retain the above copyright     
       
    17  *    notice, this list of conditions and the following disclaimer.      
       
    18  *  * Redistributions in binary form must reproduce the above copyright  
       
    19  *    notice, this list of conditions and the following disclaimer in    
       
    20  *    the documentation and/or other materials provided with the         
       
    21  *    distribution.                                                      
       
    22  *  * Neither the name Texas Instruments nor the names of its            
       
    23  *    contributors may be used to endorse or promote products derived    
       
    24  *    from this software without specific prior written permission.      
       
    25  *                                                                       
       
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
       
    27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
       
    28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
       
    29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
       
    30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
       
    32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
       
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
       
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
       
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    37  */
       
    38 
       
    39 /** \file ScanSrv.h
       
    40  *  \brief This file include private definitions for the scan SRV module.
       
    41  *
       
    42  *  \see   ScanSrv.c, ScanSrvSM.c, ScanSrvSM.h
       
    43  */
       
    44 
       
    45 
       
    46 #ifndef __SCANSRV_H__
       
    47 #define __SCANSRV_H__
       
    48 
       
    49 #include "TWDriverInternal.h"
       
    50 #include "MacServices_api.h"
       
    51 #include "fsm.h"
       
    52 #include "ScanSrvSM.h"
       
    53 
       
    54 /*
       
    55  ***********************************************************************
       
    56  *  Constant definitions.
       
    57  ***********************************************************************
       
    58  */
       
    59 /* guard time for scan (added to calculated scan duration)
       
    60    Value to support extreme case such as A2DP mode */
       
    61 #define SCAN_SRV_FW_GUARD_TIME_MS                       62000
       
    62 /* module name for driver mode requests */
       
    63 #define SCAN_SRV_NAME                                   "SSRV"
       
    64 
       
    65 
       
    66 /*
       
    67  ***********************************************************************
       
    68  *  Enums.
       
    69  ***********************************************************************
       
    70  */
       
    71 
       
    72 
       
    73 /*
       
    74  ***********************************************************************
       
    75  *  Typedefs.
       
    76  ***********************************************************************
       
    77  */
       
    78 
       
    79 /*
       
    80  ***********************************************************************
       
    81  *  Structure definitions.
       
    82  ***********************************************************************
       
    83  */
       
    84 
       
    85 /** \struct scanSRV_t
       
    86  * \brief This structure contains the scan SRV object data
       
    87  */
       
    88 typedef struct
       
    89 {
       
    90     TI_HANDLE           hOS;                           /**< OS object handle */
       
    91     TI_HANDLE           hReport;                       /**< report object handle */
       
    92     TI_HANDLE           hPowerSrv;                     /**< power Server object handle */
       
    93     TI_HANDLE           hTWD;                          /**< TWD layer handle */
       
    94     TI_HANDLE           hTimer;                        /**< Timer module object handle */
       
    95     TI_HANDLE           hEventMbox;                    /**< EventMbox module object handle */
       
    96     TI_HANDLE           hCmdBld;                       /**< Command builder object handle */
       
    97     TScanSrvCompleteCb  scanCompleteNotificationFunc;  /**< 
       
    98                                                          * upper layer (scan concentrator) scan complete 
       
    99                                                          * callback function
       
   100                                                          */
       
   101     TI_HANDLE           scanCompleteNotificationObj;    /**< 
       
   102                                                          * upper layer (scan concentrator) scan complete
       
   103                                                          * callback function
       
   104                                                          */
       
   105     
       
   106     TCmdResponseCb      commandResponseFunc;            /**<
       
   107                                                          * upper layer command response CB. Passed down into the HAL
       
   108                                                          * and called when the scan command has been received by the FW
       
   109                                                          */
       
   110     TI_HANDLE           commandResponseObj;             /**<
       
   111                                                          * object parameter passed to the commandResposeFunc by the HAL
       
   112                                                          * when it is called 
       
   113                                                          */
       
   114     TFailureEventCb     failureEventFunc;               /**<
       
   115                                                          * upper layer Failure Event CB.
       
   116                                                          * called when the scan command has been Timer Expiry
       
   117                                                          */
       
   118     TI_HANDLE           failureEventObj;                /**<
       
   119                                                          * object parameter passed to the failureEventFunc
       
   120                                                          * when it is called 
       
   121                                                          */
       
   122     TI_UINT16           SPSScanResult;                  /**< 
       
   123                                                          * bitmap indicating which channels were scanned
       
   124                                                          * in an SPS scan
       
   125                                                          */
       
   126     TI_BOOL             bTSFError;                      /** indicates whether a TSF error occured */                                                        /**< 
       
   127                                                          * scan result: indicates a TSF error event and 
       
   128                                                          * which channels were scanned in SPS
       
   129                                                          */
       
   130     TI_BOOL             bDtimOverlapping;               /**< Indicates whether the scan is overlapping DTIM */
       
   131     TI_BOOL             bExitFromDriverMode;            /**< 
       
   132                                                          * Indicates whether to exit driver mode once scan 
       
   133                                                          * is finished
       
   134                                                          */
       
   135     TI_BOOL             bSendNullData;                  /**< 
       
   136                                                          * Indicates whether to send Null data when exiting driver  
       
   137                                                          * mode once scan is finished
       
   138                                                          */
       
   139     TI_BOOL             bScanOnDriverModeFailure;       /**< 
       
   140                                                          * Indicates whether to scan if driver mode entry
       
   141                                                          * wasn't successful
       
   142                                                          */
       
   143     TI_BOOL             bHighPriority;                  /**<
       
   144                                                          * Indicates whether to request high priority 
       
   145                                                          * (overlapping DTIM) scan
       
   146                                                          */
       
   147     TI_BOOL             bSPSScan;                       /**< 
       
   148                                                          * whether the running scan type is SPS (TI_TRUE)
       
   149                                                          * or something else (TI_FALSE). Used to stop a
       
   150                                                          * running scan.
       
   151                                                          */
       
   152     TScanParams*        scanParams;                     /**< scan parameters */
       
   153     EScanResultTag      eScanTag;                       /**< scan result tag */
       
   154     TI_UINT32           uResultCount;                   /**< number of scan results (received from the FW) */
       
   155     TI_HANDLE           hScanSrvTimer;                  /**< scan operation timer */
       
   156     TI_BOOL             bTimerRunning;                  /**< whether the above timer is running */
       
   157     TI_BOOL             bInRequest;                     /**<
       
   158                                                          * Indicates whether the SM is run within
       
   159                                                          * the scan request context (if so, to avoid
       
   160                                                          * re-entrance, the complete function shouldn't
       
   161                                                          * be called on failure, but rather an invalid
       
   162                                                          * status should be returned)
       
   163                                                          */
       
   164     TI_STATUS           returnStatus;                   /**< 
       
   165                                                          * Holds the return code to the upper layer
       
   166                                                          * Used to save errors during SM operation.
       
   167                                                          */
       
   168     /* state machine */
       
   169     fsm_stateMachine_t* SM;                             /**< 
       
   170                                                          * state machines for different
       
   171                                                          * scan types
       
   172                                                          */
       
   173     scan_SRVSMStates_e  SMState;                        /**< 
       
   174                                                          * state machine current states 
       
   175                                                          * for different scan types
       
   176                                                          */
       
   177     E80211PsMode        psRequest;                      /**< 
       
   178                                                          * Indicates if PS was requested or not
       
   179                                                          * for current scan
       
   180                                                          */
       
   181     TI_UINT32           numberOfNoScanCompleteToRecovery;
       
   182                                                         /**< 
       
   183                                                          * The number of consecutive no scan complete
       
   184                                                          * that will trigger a recovery notification
       
   185                                                          */
       
   186     TI_UINT32           currentNumberOfConsecutiveNoScanCompleteEvents;
       
   187                                                         /**<
       
   188                                                          * The number of consecutivre no scan complete 
       
   189                                                          * events at present
       
   190                                                          */
       
   191     TI_BOOL             bNoScanCompleteFlag;            /**<
       
   192                                                          * Indicates if the last event was start scan
       
   193                                                          * (true) or no scan complete (false) to be able
       
   194                                                          * to nullify correctly the above counter */
       
   195     TI_UINT32           uTriggeredScanTimeOut;          /**<
       
   196                                                          * Time out for starting triggered scan between 
       
   197                                                          * 2 channels */
       
   198     TI_UINT8                uDtimPeriod;
       
   199     TI_UINT16               uBeaconInterval;
       
   200 } scanSRV_t;
       
   201 
       
   202 /*
       
   203  ***********************************************************************
       
   204  *  External data definitions.
       
   205  ***********************************************************************
       
   206  */
       
   207 
       
   208 /*
       
   209  ***********************************************************************
       
   210  *  External functions definitions
       
   211  ***********************************************************************
       
   212  */
       
   213 
       
   214 /**
       
   215  * \date 16-Oct-2004\n
       
   216  * \brief Creates the scan SRV object
       
   217  *
       
   218  * Function Scope \e Public.\n
       
   219  * \param hOS - handle to the OS object.\n
       
   220  * \return a handle to the scan SRV object, NULL if an error occurred.\n
       
   221  */
       
   222 TI_HANDLE MacServices_scanSRV_create( TI_HANDLE hOS );
       
   223 
       
   224 /**
       
   225  * \date 29-Dec-2004\n
       
   226  * \brief Finalizes the scan SRV module (releasing memory and timer)
       
   227  *
       
   228  * Function Scope \e Public.\n
       
   229  * \param hScanSRV - handle to the scan SRV object.\n
       
   230  */
       
   231 void MacServices_scanSRV_destroy( TI_HANDLE hScanSRV );
       
   232 
       
   233 /**
       
   234  * \date 29-Dec-2004\n
       
   235  * \brief Initializes the scan SRV module, registers SCAN_COMPLETE to HAL.
       
   236  *
       
   237  * Function Scope \e Public.\n
       
   238  * \param hScanSRV - handle to the scan SRV object.\n
       
   239  * \param Handles of other modules.\n
       
   240   */
       
   241 TI_STATUS MacServices_scanSRV_init (TI_HANDLE hMacServices,
       
   242                                     TI_HANDLE hReport,
       
   243                                     TI_HANDLE hTWD,
       
   244                                     TI_HANDLE hTimer,
       
   245                                     TI_HANDLE hEventMbox,
       
   246                                     TI_HANDLE hCmdBld);
       
   247 
       
   248 /**
       
   249  * \author Ronen Kalish\n
       
   250  * \date 26-July-2006\n
       
   251  * \brief Configures the scan SRV module with initialization values
       
   252  *
       
   253  * Function Scope \e Public.\n
       
   254  * \param hScanSRV - handle to the scan SRV object.\n
       
   255  * \param hReport - handle to the report object.\n
       
   256  * \param hHalCtrl - handle to the HAL ctrl object.\n
       
   257   */
       
   258 void MacServices_scanSrv_config( TI_HANDLE hMacServices, TScanSrvInitParams* pInitParams );
       
   259 
       
   260 /**
       
   261  * \author Ronen Kalish\n
       
   262  * \date 29-Dec-2004\n
       
   263  * \brief Calculates the maximal time required for a scan operation
       
   264  *
       
   265  * Function Scope \e Public.\n
       
   266  * \param hScanSRV - handle to the scan SRV object.\n
       
   267  * \param scanParams - the scan parameters
       
   268  * \param bConsiderDTIM - whether this scan overlaps DTIM
       
   269  * \return the time (in milliseconds)
       
   270  */
       
   271 TI_UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSrv, TScanParams* scanParams, TI_BOOL bConsiderDTIM );
       
   272 
       
   273 /**
       
   274  * \author Ronen Kalish\n
       
   275  * \date 16-Jan-2005\n
       
   276  * \brief Convert time units (1024 usecs) to millisecs
       
   277  *
       
   278  * Function Scope \e Private.\n
       
   279  * \param tu - the time in time units
       
   280  * \return the time in milliseconds
       
   281  */
       
   282 TI_UINT32 MacServices_scanSRVConvertTUToMsec( TI_UINT32 tu );
       
   283 
       
   284 /**
       
   285  * \date 27-Sep-2005\n
       
   286  * \brief This function is the CB which is called as response to 'StartScan' or 'StopScan' \n.
       
   287  *        here we check if there is a GWSI command response , and call it if necessary .\n
       
   288  * Function Scope \e Private.\n
       
   289  * \param hScanSrv - handle to the scan SRV object.\n
       
   290  * \param MboxStatus - mailbox status. \n
       
   291  */
       
   292 
       
   293 void MacServices_scanSRVCommandMailBoxCB(TI_HANDLE hScanSrv,TI_UINT16 MboxStatus);
       
   294 
       
   295 
       
   296 /**
       
   297  * \brief Registers a failure event callback for scan error notifications.
       
   298  *
       
   299  * Function Scope \e Public.\n
       
   300  * \param hMacServices - handle to the MacServices object.\n
       
   301  * \param failureEventCB - the failure event callback function.\n
       
   302  * \param hFailureEventObj - handle to the object passed to the failure event callback function.\n
       
   303  */
       
   304 void scanSRV_registerFailureEventCB( TI_HANDLE hScanSRV, 
       
   305                                      void * failureEventCB, TI_HANDLE hFailureEventObj );
       
   306 
       
   307 void scanSRV_restart( TI_HANDLE hScanSRV);
       
   308 
       
   309 
       
   310 #endif /* __SCANSRV_H__ */