Home | History | Annotate | Download | only in hardware_legacy
      1 
      2 #include "wifi_hal.h"
      3 
      4 #ifndef __WIFI_HAL_GSCAN_H__
      5 #define __WIFI_HAL_GSCAN_H__
      6 
      7 /* AP Scans */
      8 
      9 typedef enum {
     10     WIFI_BAND_UNSPECIFIED,
     11     WIFI_BAND_BG = 1,                       // 2.4 GHz
     12     WIFI_BAND_A = 2,                        // 5 GHz without DFS
     13     WIFI_BAND_A_DFS = 4,                    // 5 GHz DFS only
     14     WIFI_BAND_A_WITH_DFS = 6,               // 5 GHz with DFS
     15     WIFI_BAND_ABG = 3,                      // 2.4 GHz + 5 GHz; no DFS
     16     WIFI_BAND_ABG_WITH_DFS = 7,             // 2.4 GHz + 5 GHz with DFS
     17 } wifi_band;
     18 
     19 const unsigned MAX_CHANNELS                = 16;
     20 const unsigned MAX_BUCKETS                 = 16;
     21 const unsigned MAX_HOTLIST_APS             = 128;
     22 const unsigned MAX_SIGNIFICANT_CHANGE_APS  = 64;
     23 
     24 wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
     25         int band, int max_channels, wifi_channel *channels, int *num_channels);
     26 
     27 typedef struct {
     28     int max_scan_cache_size;                 // total space allocated for scan (in bytes)
     29     int max_scan_buckets;                    // maximum number of channel buckets
     30     int max_ap_cache_per_scan;               // maximum number of APs that can be stored per scan
     31     int max_rssi_sample_size;                // number of RSSI samples used for averaging RSSI
     32     int max_scan_reporting_threshold;        // max possible report_threshold as described
     33                                              // in wifi_scan_cmd_params
     34     int max_hotlist_aps;                     // maximum number of entries for hotlist APs
     35     int max_significant_wifi_change_aps;     // maximum number of entries for
     36                                              // significant wifi change APs
     37     int max_bssid_history_entries;           // number of BSSID/RSSI entries that device can hold
     38 } wifi_gscan_capabilities;
     39 
     40 wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
     41         wifi_gscan_capabilities *capabilities);
     42 
     43 typedef enum {
     44    WIFI_SCAN_BUFFER_FULL,
     45    WIFI_SCAN_COMPLETE,
     46 } wifi_scan_event;
     47 
     48 
     49 /* Format of information elements found in the beacon */
     50 typedef struct {
     51     byte id;                            // element identifier
     52     byte len;                           // number of bytes to follow
     53     byte data[];
     54 } wifi_information_element;
     55 
     56 typedef struct {
     57     wifi_timestamp ts;                  // time since boot (in microsecond) when the result was
     58                                         // retrieved
     59     char ssid[32+1];                    // null terminated
     60     mac_addr bssid;
     61     wifi_channel channel;               // channel frequency in MHz
     62     wifi_rssi rssi;                     // in db
     63     wifi_timespan rtt;                  // in nanoseconds
     64     wifi_timespan rtt_sd;               // standard deviation in rtt
     65     unsigned short beacon_period;       // period advertised in the beacon
     66     unsigned short capability;          // capabilities advertised in the beacon
     67     unsigned int ie_length;             // size of the ie_data blob
     68     char         ie_data[1];            // blob of all the information elements found in the
     69                                         // beacon; this data should be a packed list of
     70                                         // wifi_information_element objects, one after the other.
     71     // other fields
     72 } wifi_scan_result;
     73 
     74 typedef struct {
     75     /* reported when report_threshold is reached in scan cache */
     76     void (*on_scan_results_available) (wifi_request_id id, unsigned num_results_available);
     77 
     78     /* reported when each probe response is received, if report_events
     79      * enabled in wifi_scan_cmd_params */
     80     void (*on_full_scan_result) (wifi_request_id id, wifi_scan_result *result);
     81 
     82     /* optional event - indicates progress of scanning statemachine */
     83     void (*on_scan_event) (wifi_scan_event event, unsigned status);
     84 
     85 } wifi_scan_result_handler;
     86 
     87 typedef struct {
     88     wifi_channel channel;               // frequency
     89     int dwellTimeMs;                    // dwell time hint
     90     int passive;                        // 0 => active, 1 => passive scan; ignored for DFS
     91     /* Add channel class */
     92 } wifi_scan_channel_spec;
     93 
     94 
     95 typedef struct {
     96     int bucket;                         // bucket index, 0 based
     97     wifi_band band;                     // when UNSPECIFIED, use channel list
     98     int period;                         // desired period, in millisecond; if this is too
     99                                         // low, the firmware should choose to generate results as
    100                                         // fast as it can instead of failing the command
    101     /* report_events semantics -
    102      *  0 => report only when scan history is % full
    103      *  1 => same as 0 + report a scan completion event after scanning this bucket
    104      *  2 => same as 1 + forward scan results (beacons/probe responses + IEs) in real time to HAL
    105      *  3 => same as 2 + forward scan results (beacons/probe responses + IEs) in real time to
    106              supplicant as well (optional) . */
    107     byte report_events;
    108 
    109     int num_channels;
    110     wifi_scan_channel_spec channels[MAX_CHANNELS];  // channels to scan; these may include DFS channels
    111 } wifi_scan_bucket_spec;
    112 
    113 typedef struct {
    114     int base_period;                    // base timer period in ms
    115     int max_ap_per_scan;                // number of APs to store in each scan in the
    116                                         // BSSID/RSSI history buffer (keep the highest RSSI APs)
    117     int report_threshold;               // in %, when scan buffer is this much full, wake up AP
    118     int num_buckets;
    119     wifi_scan_bucket_spec buckets[MAX_BUCKETS];
    120 } wifi_scan_cmd_params;
    121 
    122 /* Start periodic GSCAN */
    123 wifi_error wifi_start_gscan(wifi_request_id id, wifi_interface_handle iface,
    124         wifi_scan_cmd_params params, wifi_scan_result_handler handler);
    125 
    126 /* Stop periodic GSCAN */
    127 wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface);
    128 
    129 /* Get the GSCAN cached scan results */
    130 wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
    131         int max, wifi_scan_result *results, int *num);
    132 
    133 /* BSSID Hotlist */
    134 typedef struct {
    135     void (*on_hotlist_ap_found)(wifi_request_id id,
    136             unsigned num_results, wifi_scan_result *results);
    137     void (*on_hotlist_ap_lost)(wifi_request_id id,
    138             unsigned num_results, wifi_scan_result *results);
    139 } wifi_hotlist_ap_found_handler;
    140 
    141 typedef struct {
    142     mac_addr  bssid;                    // AP BSSID
    143     wifi_rssi low;                      // low threshold
    144     wifi_rssi high;                     // high threshold
    145     wifi_channel channel;               // channel hint
    146 } ap_threshold_param;
    147 
    148 typedef struct {
    149     int lost_ap_sample_size;
    150     int num_ap;                                 // number of hotlist APs
    151     ap_threshold_param ap[MAX_HOTLIST_APS];     // hotlist APs
    152 } wifi_bssid_hotlist_params;
    153 
    154 /* Set the BSSID Hotlist */
    155 wifi_error wifi_set_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface,
    156         wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler);
    157 
    158 /* Clear the BSSID Hotlist */
    159 wifi_error wifi_reset_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface);
    160 
    161 /* Significant wifi change*/
    162 typedef struct {
    163     mac_addr bssid;                     // BSSID
    164     wifi_channel channel;               // channel frequency in MHz
    165     int num_rssi;                       // number of rssi samples
    166     wifi_rssi rssi[];                   // RSSI history in db
    167 } wifi_significant_change_result;
    168 
    169 typedef struct {
    170     void (*on_significant_change)(wifi_request_id id,
    171             unsigned num_results, wifi_significant_change_result **results);
    172 } wifi_significant_change_handler;
    173 
    174 typedef struct {
    175     int rssi_sample_size;               // number of samples for averaging RSSI
    176     int lost_ap_sample_size;            // number of samples to confirm AP loss
    177     int min_breaching;                  // number of APs breaching threshold
    178     int num_ap;                         // max 64
    179     ap_threshold_param ap[MAX_SIGNIFICANT_CHANGE_APS];
    180 } wifi_significant_change_params;
    181 
    182 /* Set the Signifcant AP change list */
    183 wifi_error wifi_set_significant_change_handler(wifi_request_id id, wifi_interface_handle iface,
    184         wifi_significant_change_params params, wifi_significant_change_handler handler);
    185 
    186 /* Clear the Signifcant AP change list */
    187 wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interface_handle iface);
    188 
    189 /* Random MAC OUI for PNO */
    190 wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui);
    191 
    192 #endif
    193 
    194