OSDN Git Service

HAL API to offload passpoint match to wifi chipset
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / gscan.h
index 1db6424..3d7d5da 100644 (file)
@@ -20,7 +20,9 @@ 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;
 
 wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
         int band, int max_channels, wifi_channel *channels, int *num_channels);
@@ -32,10 +34,16 @@ typedef struct {
     int max_rssi_sample_size;                // number of RSSI samples used for averaging RSSI
     int max_scan_reporting_threshold;        // max possible report_threshold as described
                                              // in wifi_scan_cmd_params
-    int max_hotlist_aps;                     // maximum number of entries for hotlist APs
+    int max_hotlist_bssids;                  // maximum number of entries for hotlist BSSIDs
+    int max_hotlist_ssids;                   // maximum number of entries for hotlist SSIDs
     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;            // 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,
@@ -171,7 +179,7 @@ typedef struct {
 
 typedef struct {
     int lost_ap_sample_size;
-    int num_ap;                                 // number of hotlist APs
+    int num_bssid;                                 // number of hotlist APs
     ap_threshold_param ap[MAX_HOTLIST_APS];     // hotlist APs
 } wifi_bssid_hotlist_params;
 
@@ -199,8 +207,8 @@ typedef struct {
 
 typedef struct {
     int lost_ssid_sample_size;
-    int num_ap;                                 // number of hotlist APs
-    ssid_threshold_param ssid[MAX_HOTLIST_APS];     // hotlist APs
+    int num_ssid;                                   // number of hotlist SSIDs
+    ssid_threshold_param ssid[MAX_HOTLIST_SSID];    // hotlist SSIDs
 } wifi_ssid_hotlist_params;
 
 
@@ -211,6 +219,18 @@ wifi_error wifi_set_ssid_hotlist(wifi_request_id id, wifi_interface_handle iface
 /* Clear the SSID Hotlist */
 wifi_error wifi_reset_ssid_hotlist(wifi_request_id id, wifi_interface_handle iface);
 
+
+/* BSSID blacklist */
+typedef struct {
+    int num_bssid;                           // number of blacklisted BSSIDs
+    mac_addr bssids[MAX_BLACKLIST_BSSID];    // blacklisted BSSIDs
+} wifi_bssid_params;
+
+/* Set the BSSID blacklist */
+wifi_error wifi_set_bssid_blacklist(wifi_request_id id, wifi_interface_handle iface,
+        wifi_bssid_params params);
+
+
 /* Significant wifi change */
 typedef struct {
     mac_addr bssid;                     // BSSID
@@ -233,7 +253,7 @@ typedef struct {
     int rssi_sample_size;               // number of samples for averaging RSSI
     int lost_ap_sample_size;            // number of samples to confirm AP loss
     int min_breaching;                  // number of APs breaching threshold
-    int num_ap;                         // max 64
+    int num_bssid;                         // max 64
     ap_threshold_param ap[MAX_SIGNIFICANT_CHANGE_APS];
 } wifi_significant_change_params;
 
@@ -247,9 +267,14 @@ wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interf
 /* Random MAC OUI for PNO */
 wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui);
 
-
-#define WIFI_PNO_FLAG_DIRECTED_SCAN = 1 // whether directed scan needs to be performed (for hidden SSIDs)
-#define WIFI_PNO_FLAG_HASH_PROVIDED = 2 // whether a crc32 hash of the ssid is provided instead of the ssid
+// Whether directed scan needs to be performed (for hidden SSIDs)
+#define WIFI_PNO_FLAG_DIRECTED_SCAN = 1
+// Whether PNO event shall be triggered if the network is found on A band
+#define WIFI_PNO_FLAG_A_BAND = 2
+// Whether PNO event shall be triggered if the network is found on G band
+#define WIFI_PNO_FLAG_G_BAND = 4
+// Whether strict matching is required (i.e. firmware shall not match on the entire SSID)
+#define WIFI_PNO_FLAG_STRICT_MATCH = 8
 
 // Code for matching the beacon AUTH IE - additional codes TBD
 #define WIFI_PNO_AUTH_CODE_OPEN  1 // open
@@ -257,39 +282,35 @@ wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui)
 #define WIFI_PNO_AUTH_CODE_EAPOL 4 // any EAPOL
 
 // Enhanced PNO:
-// for each network framework will either specify a ssid or a crc32
-// if ssid is specified (i.e. ssid[0] != 0) then crc32 field shall be ignored.
+// Enhanced PNO feature is expected to be enabled all of the time (e.g. screen lit) and may thus
+// requires firmware to store a large number of networks, covering the whole list of known network.
+// Therefore, it is acceptable for firmware to store a crc24, crc32 or other short hash of the SSID,
+// such that a low but non-zero probability of collision exist. With that scheme it should be
+// possible for firmware to keep an entry as small as 4 bytes for each pno network.
+// For instance, a firmware pn0 entry can be implemented in the form of:
+//          PNO ENTRY = crc24(3 bytes) | RSSI_THRESHOLD>>3 (5 bits) | auth flags(3 bits)
+//
 // A PNO network shall be reported once, that is, once a network is reported by firmware
-// its entry shall be marked as "done" until framework call wifi_set_epno_list.
- // Calling wifi_set_epno_list shall reset the "done" status of pno networks in firmware.
+// its entry shall be marked as "done" until framework calls wifi_set_epno_list again.
+// Calling wifi_set_epno_list shall reset the "done" status of pno networks in firmware.
 typedef struct {
-    char ssid[32];
-    char rssi_threshold; // threshold for considering this SSID as found
-    char flags;
-    int crc32;  // crc32 of the SSID, this allows for memory size optimization
-                // i.e. not passing the whole SSID
-                // in firmware and instead storing a shorter string
-    char auth_bit_field; // auth bitfield for matching WPA IE
+    char ssid[32+1];
+    char 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
 } wifi_epno_network;
 
 /* PNO list */
 typedef struct {
-    int num_networks;                                // number of SSIDs
+    int num_networks;                 // number of SSIDs
     wifi_epno_network networks[];     // PNO networks
 } wifi_epno_params;
 
 typedef struct {
-    int network_index; // index of the network found in the pno list
-    char ssid[32+1]; // null terminated
-    wifi_channel channel;
-    int rssi;
-} wifi_epno_result;
-
-
-typedef struct {
     // on results
     void (*on_network_found)(wifi_request_id id,
-            unsigned num_results, wifi_epno_result *results);
+            unsigned num_results, wifi_scan_result *results);
 } wifi_epno_handler;
 
 
@@ -301,7 +322,8 @@ wifi_error wifi_set_epno_list(wifi_request_id id, wifi_interface_handle iface,
 /* SSID white list */
 /* Note that this feature requires firmware to be able to indicate to kernel sme and wpa_supplicant
  * that the SSID of the network has changed
- * and thus requires further changed in cfg80211 stack, for instance, the below function would change:
+ * and thus requires further changed in cfg80211 stack, for instance,
+ * the below function would change:
 
  void __cfg80211_roamed(struct wireless_dev *wdev,
                       struct cfg80211_bss *bss,
@@ -374,7 +396,7 @@ typedef struct {
 
     // Hysteresis: ensuring the currently associated BSSID is favored
     // so as to prevent ping-pong situations
-    int lazy_roam_histeresys;       // boost applied to current BSSID
+    int lazy_roam_hysteresis;       // boost applied to current BSSID
 
     // Alert mode enable, i.e. configuring when firmware enters alert mode
     int alert_roam_rssi_trigger;    // RSSI below which "Alert" roam is enabled
@@ -392,7 +414,7 @@ wifi_error wifi_enable_lazy_roam(wifi_request_id id, wifi_interface_handle iface
  * Per BSSID preference
  */
 typedef struct {
-    char bssid[6];
+    mac_addr bssid;
     int rssi_modifier;  // modifier applied to the RSSI of the BSSID for the purpose of comparing
                         // it with other roam candidate
 } wifi_bssid_preference;
@@ -401,13 +423,30 @@ wifi_error wifi_set_bssid_preference(wifi_request_id id, wifi_interface_handle i
                                     int num_bssid, wifi_bssid_preference *prefs);
 
 typedef struct {
-    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 */
-} wifi_roam_autojoin_offload_capabilities;
+    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;
 
-wifi_error wifi_get_roam_autojoin_offload_capabilities(wifi_interface_handle handle,
-        wifi_roam_autojoin_offload_capabilities *capabilities);
+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