OSDN Git Service

WiFi exponential back off scan enhancement
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / gscan.h
index 5044ecc..d43fa28 100644 (file)
@@ -20,9 +20,10 @@ const unsigned MAX_CHANNELS                = 16;
 const unsigned MAX_BUCKETS                 = 16;
 const unsigned MAX_HOTLIST_APS             = 128;
 const unsigned MAX_SIGNIFICANT_CHANGE_APS  = 64;
-const unsigned MAX_PNO_SSID                = 128;
+const unsigned MAX_PNO_SSID                = 64;
 const unsigned MAX_HOTLIST_SSID            = 8;
 const unsigned MAX_BLACKLIST_BSSID         = 16;
+const unsigned MAX_AP_CACHE_PER_SCAN       = 32;
 
 wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
         int band, int max_channels, wifi_channel *channels, int *num_channels);
@@ -39,9 +40,11 @@ typedef struct {
     int max_significant_wifi_change_aps;     // maximum number of entries for
                                              // significant wifi change APs
     int max_bssid_history_entries;           // number of BSSID/RSSI entries that device can hold
-    int max_number_epno_networks_by_crc32;   //max number of epno entries if crc32 is specified
-    int max_number_epno_networks_by_ssid;    //max number of epno entries if ssid is specified
-    int max_number_of_white_losted_ssid;     //max number of white listed SSIDs, M target is 2 to 4 */
+    int max_number_epno_networks;            // max number of epno entries
+    int max_number_epno_networks_by_ssid;    // max number of epno entries if ssid is specified,
+                                             // that is, epno entries for which an exact match is
+                                             // required, or entries corresponding to hidden ssids
+    int max_number_of_white_listed_ssid;     // max number of white listed SSIDs, M target is 2 to 4
 } wifi_gscan_capabilities;
 
 wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
@@ -98,6 +101,10 @@ typedef struct {
     /* Add channel class */
 } wifi_scan_channel_spec;
 
+#define REPORT_EVENTS_BUFFER_FULL      0
+#define REPORT_EVENTS_EACH_SCAN        1
+#define REPORT_EVENTS_FULL_RESULTS     2
+#define REPORT_EVENTS_NO_BATCH         4
 
 typedef struct {
     int bucket;                         // bucket index, 0 based
@@ -107,20 +114,23 @@ typedef struct {
                                         // fast as it can instead of failing the command.
                                         // for exponential backoff bucket this is the min_period
     /* report_events semantics -
-     *  0 => report only when scan history is % full
-     *  1 => same as 0 + report a scan completion event after scanning this bucket
-     *  2 => same as 1 + forward scan results (beacons/probe responses + IEs) in real time to HAL
-     *  3 => same as 2 + forward scan results (beacons/probe responses + IEs) in real time to
-             supplicant as well (optional) .
+     *  This is a bit field; which defines following bits -
+     *  REPORT_EVENTS_BUFFER_FULL  => report only when scan history is % full
+     *  REPORT_EVENTS_EACH_SCAN    => report a scan completion event after scan
+     *  REPORT_EVENTS_FULL_RESULTS => forward scan results (beacons/probe responses + IEs)
+     *                                 in real time to HAL, in addition to completion events
+     *                                 Note: To keep backward compatibility, fire completion
+     *                                 events regardless of REPORT_EVENTS_EACH_SCAN.
+     *  REPORT_EVENTS_NO_BATCH     => controls batching, 0 => batching, 1 => no batching
      */
     byte report_events;
     int max_period; // if max_period is non zero or different than period, then this bucket is
                     // an exponential backoff bucket and the scan period will grow exponentially
-                    // as per formula: actual_period(N) = period ^ (N/(step_count+1))
+                    // as per formula: actual_period(N) = period * (base ^ (N/step_count))
                     // to a maximum period of max_period
-    int exponent; // for exponential back off bucket: multiplier: new_period = old_period * exponent
-    int step_count; // for exponential back off bucket, number of scans performed at a given
-                    // period and until the exponent is applied
+    int base;       // for exponential back off bucket: multiplier: new_period=old_period*base
+    int step_count; // for exponential back off bucket, number of scans to perform for a given
+                    // period
 
     int num_channels;
     // channels to scan; these may include DFS channels
@@ -130,9 +140,11 @@ typedef struct {
 
 typedef struct {
     int base_period;                    // base timer period in ms
-    int max_ap_per_scan;                // number of APs to store in each scan ientryn the
-                                        // BSSID/RSSI history buffer (keep the highest RSSI APs)
-    int report_threshold_percent;       // in %, when scan buffer is this much full, wake up AP
+    int max_ap_per_scan;                // number of access points to store in each scan entry in
+                                        // the BSSID/RSSI history buffer (keep the highest RSSI
+                                        // access points)
+    int report_threshold_percent;       // in %, when scan buffer is this much full, wake up apps
+                                        // processor
     int report_threshold_num_scans;     // in number of scans, wake up AP after these many scans
     int num_buckets;
     wifi_scan_bucket_spec buckets[MAX_BUCKETS];
@@ -152,10 +164,11 @@ typedef enum {
 
 /* Get the GSCAN cached scan results */
 typedef struct {
-    int scan_id;                        // a unique identifier for the scan unit
-    int flags;                          // a bitmask with additional information about scan
-    int num_results;                    // number of bssids retrieved by the scan
-    wifi_scan_result *results;          // scan results - one for each bssid
+    int scan_id;                                     // a unique identifier for the scan unit
+    int flags;                                       // a bitmask with additional 
+                                                     // information about scan
+    int num_results;                                 // number of bssids retrieved by the scan
+    wifi_scan_result results[MAX_AP_CACHE_PER_SCAN]; // scan results - one for each bssid
 } wifi_cached_scan_results;
 
 wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
@@ -293,10 +306,10 @@ wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui)
 // Calling wifi_set_epno_list shall reset the "done" status of pno networks in firmware.
 typedef struct {
     char ssid[32+1];
-    char rssi_threshold; // threshold for considering this SSID as found, required granularity for
+    byte rssi_threshold; // threshold for considering this SSID as found, required granularity for
                          // this threshold is 4dBm to 8dBm
-    char flags;          //  WIFI_PNO_FLAG_XXX
-    char auth_bit_field; // auth bit field for matching WPA IE
+    byte flags;          //  WIFI_PNO_FLAG_XXX
+    byte auth_bit_field; // auth bit field for matching WPA IE
 } wifi_epno_network;
 
 /* PNO list */
@@ -420,5 +433,31 @@ typedef struct {
 wifi_error wifi_set_bssid_preference(wifi_request_id id, wifi_interface_handle iface,
                                     int num_bssid, wifi_bssid_preference *prefs);
 
+typedef struct {
+    int  id;                            // identifier of this network block, report this in event
+    char realm[256];                    // null terminated UTF8 encoded realm, 0 if unspecified
+    int64_t roamingConsortiumIds[16];   // roaming consortium ids to match, 0s if unspecified
+    byte plmn[3];                       // mcc/mnc combination as per rules, 0s if unspecified
+} wifi_passpoint_network;
+
+typedef struct {
+    void (*on_passpoint_network_found)(
+            wifi_request_id id,
+            int net_id,                        // network block identifier for the matched network
+            wifi_scan_result *result,          // scan result, with channel and beacon information
+            int anqp_len,                      // length of ANQP blob
+            byte *anqp                         // ANQP data, in the information_element format
+            );
+} wifi_passpoint_event_handler;
+
+/* Sets a list for passpoint networks for PNO purposes; it should be matched
+ * against any passpoint networks (designated by Interworking element) found
+ * during regular PNO scan. */
+wifi_error wifi_set_passpoint_list(wifi_request_id id, wifi_interface_handle iface, int num,
+        wifi_passpoint_network *networks, wifi_passpoint_event_handler handler);
+
+/* Reset passpoint network list - no Passpoint networks should be matched after this */
+wifi_error wifi_reset_passpoint_list(wifi_request_id id, wifi_interface_handle iface);
+
 #endif