OSDN Git Service

change wifi_logger header file
[android-x86/hardware-libhardware_legacy.git] / include / hardware_legacy / wifi_hal.h
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __WIFI_HAL_H__
18 #define __WIFI_HAL_H__
19
20 #include <stdint.h>
21
22 /* WiFi Common definitions */
23 /* channel operating width */
24 typedef enum {
25     WIFI_CHAN_WIDTH_20    = 0,
26     WIFI_CHAN_WIDTH_40    = 1,
27     WIFI_CHAN_WIDTH_80    = 2,
28     WIFI_CHAN_WIDTH_160   = 3,
29     WIFI_CHAN_WIDTH_80P80 = 4,
30     WIFI_CHAN_WIDTH_5     = 5,
31     WIFI_CHAN_WIDTH_10    = 6,
32     WIFI_CHAN_WIDTH_INVALID = -1
33 } wifi_channel_width;
34
35 typedef int wifi_radio;
36 typedef int wifi_channel;
37
38 typedef struct {
39     wifi_channel_width width;
40     int center_frequency0;
41     int center_frequency1;
42     int primary_frequency;
43 } wifi_channel_spec;
44
45 typedef enum {
46     WIFI_SUCCESS = 0,
47     WIFI_ERROR_NONE = 0,
48     WIFI_ERROR_UNKNOWN = -1,
49     WIFI_ERROR_UNINITIALIZED = -2,
50     WIFI_ERROR_NOT_SUPPORTED = -3,
51     WIFI_ERROR_NOT_AVAILABLE = -4,              // Not available right now, but try later
52     WIFI_ERROR_INVALID_ARGS = -5,
53     WIFI_ERROR_INVALID_REQUEST_ID = -6,
54     WIFI_ERROR_TIMED_OUT = -7,
55     WIFI_ERROR_TOO_MANY_REQUESTS = -8,          // Too many instances of this request
56     WIFI_ERROR_OUT_OF_MEMORY = -9
57 } wifi_error;
58
59 typedef unsigned char byte;
60 typedef unsigned char u8;
61 typedef signed char s8;
62 typedef uint16_t u16;
63 typedef uint32_t u32;
64 typedef int32_t s32;
65 typedef uint64_t u64;
66 typedef int64_t s64;
67 typedef int wifi_request_id;
68 typedef int wifi_channel;                       // indicates channel frequency in MHz
69 typedef int wifi_rssi;
70 typedef byte mac_addr[6];
71 typedef byte oui[3];
72 typedef int64_t wifi_timestamp;                 // In microseconds (us)
73 typedef int64_t wifi_timespan;                  // In nanoseconds  (ns)
74
75 struct wifi_info;
76 typedef wifi_info *wifi_handle;
77 struct wifi_interface_info;
78 typedef wifi_interface_info *wifi_interface_handle;
79
80 /* Initialize/Cleanup */
81
82 wifi_error wifi_initialize(wifi_handle *handle);
83 typedef void (*wifi_cleaned_up_handler) (wifi_handle handle);
84 void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler);
85 void wifi_event_loop(wifi_handle handle);
86
87 /* Error handling */
88 void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string
89
90 /* Feature enums */
91 #define WIFI_FEATURE_INFRA              0x0001      // Basic infrastructure mode
92 #define WIFI_FEATURE_INFRA_5G           0x0002      // Support for 5 GHz Band
93 #define WIFI_FEATURE_HOTSPOT            0x0004      // Support for GAS/ANQP
94 #define WIFI_FEATURE_P2P                0x0008      // Wifi-Direct
95 #define WIFI_FEATURE_SOFT_AP            0x0010      // Soft AP
96 #define WIFI_FEATURE_GSCAN              0x0020      // Google-Scan APIs
97 #define WIFI_FEATURE_NAN                0x0040      // Neighbor Awareness Networking
98 #define WIFI_FEATURE_D2D_RTT            0x0080      // Device-to-device RTT
99 #define WIFI_FEATURE_D2AP_RTT           0x0100      // Device-to-AP RTT
100 #define WIFI_FEATURE_BATCH_SCAN         0x0200      // Batched Scan (legacy)
101 #define WIFI_FEATURE_PNO                0x0400      // Preferred network offload
102 #define WIFI_FEATURE_ADDITIONAL_STA     0x0800      // Support for two STAs
103 #define WIFI_FEATURE_TDLS               0x1000      // Tunnel directed link setup
104 #define WIFI_FEATURE_TDLS_OFFCHANNEL    0x2000      // Support for TDLS off channel
105 #define WIFI_FEATURE_EPR                0x4000      // Enhanced power reporting
106 #define WIFI_FEATURE_AP_STA             0x8000      // Support for AP STA Concurrency
107 #define WIFI_FEATURE_LINK_LAYER_STATS  0x10000      // Link layer stats collection
108 #define WIFI_FEATURE_LOGGER            0x20000      // WiFi Logger
109 #define WIFI_FEATURE_HAL_EPNO          0x40000      // WiFi PNO enhanced
110
111 // Add more features here
112
113
114 typedef int feature_set;
115
116 #define IS_MASK_SET(mask, flags)        ((flags & mask) == mask)
117 #define IS_MASK_RESET(mask, flags)      ((flags & mask) == 0)
118
119 #define IS_SUPPORTED_FEATURE(feature, featureSet)       IS_MASK_SET(feature, fetureSet)
120 #define IS_UNSUPPORTED_FEATURE(feature, featureSet)     IS_MASK_RESET(feature, fetureSet)
121
122 /* Feature set */
123 wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *set);
124
125 /*
126  * Each row represents a valid feature combination;
127  * all other combinations are invalid!
128  */
129 wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max,
130         feature_set set[], int *set_size);
131
132 /* multiple interface support */
133
134 wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces);
135 wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
136
137 /* Configuration events */
138
139 typedef struct {
140     void (*on_country_code_changed)(char code[2]);      // We can get this from supplicant too
141
142     // More event handlers
143 } wifi_event_handler;
144
145 wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
146 wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
147
148 wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs);
149
150 /* include various feature headers */
151
152 #include "gscan.h"
153 #include "link_layer_stats.h"
154 #include "rtt.h"
155 #include "tdls.h"
156 #include "wifi_logger.h"
157 #include "wifi_config.h"
158 #include "wifi_nan.h"
159
160 //wifi HAL function pointer table
161 typedef struct {
162     wifi_error (* wifi_initialize) (wifi_handle *);
163     void (* wifi_cleanup) (wifi_handle, wifi_cleaned_up_handler);
164     void (*wifi_event_loop)(wifi_handle);
165     void (* wifi_get_error_info) (wifi_error , const char **);
166     wifi_error (* wifi_get_supported_feature_set) (wifi_interface_handle, feature_set *);
167     wifi_error (* wifi_get_concurrency_matrix) (wifi_interface_handle, int, feature_set *, int *);
168     wifi_error (* wifi_set_scanning_mac_oui) (wifi_interface_handle, unsigned char *);
169     wifi_error (* wifi_get_supported_channels)(wifi_handle, int *, wifi_channel *);
170     wifi_error (* wifi_is_epr_supported)(wifi_handle);
171     wifi_error (* wifi_get_ifaces) (wifi_handle , int *, wifi_interface_handle **);
172     wifi_error (* wifi_get_iface_name) (wifi_interface_handle, char *name, size_t);
173     wifi_error (* wifi_set_iface_event_handler) (wifi_request_id,wifi_interface_handle ,
174             wifi_event_handler);
175     wifi_error (* wifi_reset_iface_event_handler) (wifi_request_id, wifi_interface_handle);
176     wifi_error (* wifi_start_gscan) (wifi_request_id, wifi_interface_handle, wifi_scan_cmd_params,
177             wifi_scan_result_handler);
178     wifi_error (* wifi_stop_gscan)(wifi_request_id, wifi_interface_handle);
179     wifi_error (* wifi_get_cached_gscan_results)(wifi_interface_handle, byte, int,
180             wifi_cached_scan_results *, int *);
181     wifi_error (* wifi_set_bssid_hotlist)(wifi_request_id, wifi_interface_handle,
182             wifi_bssid_hotlist_params, wifi_hotlist_ap_found_handler);
183     wifi_error (* wifi_reset_bssid_hotlist)(wifi_request_id, wifi_interface_handle);
184     wifi_error (* wifi_set_significant_change_handler)(wifi_request_id, wifi_interface_handle,
185             wifi_significant_change_params, wifi_significant_change_handler);
186     wifi_error (* wifi_reset_significant_change_handler)(wifi_request_id, wifi_interface_handle);
187     wifi_error (* wifi_get_gscan_capabilities)(wifi_interface_handle, wifi_gscan_capabilities *);
188     wifi_error (* wifi_set_link_stats) (wifi_interface_handle, wifi_link_layer_params);
189     wifi_error (* wifi_get_link_stats) (wifi_request_id,wifi_interface_handle,
190             wifi_stats_result_handler);
191     wifi_error (* wifi_clear_link_stats)(wifi_interface_handle,u32, u32 *, u8, u8 *);
192     wifi_error (* wifi_get_valid_channels)(wifi_interface_handle,int, int, wifi_channel *, int *);
193     wifi_error (* wifi_rtt_range_request)(wifi_request_id, wifi_interface_handle, unsigned,
194             wifi_rtt_config[], wifi_rtt_event_handler);
195     wifi_error (* wifi_rtt_range_cancel)(wifi_request_id,  wifi_interface_handle, unsigned,
196             mac_addr[]);
197     wifi_error (* wifi_get_rtt_capabilities)(wifi_interface_handle, wifi_rtt_capabilities *);
198     wifi_error (* wifi_set_nodfs_flag)(wifi_interface_handle, u32);
199     wifi_error (* wifi_start_logging)(wifi_interface_handle, u32, u32, u32, u32, char *);
200     wifi_error (* wifi_set_epno_list)(int, wifi_interface_info *, int, wifi_epno_network *,
201             wifi_epno_handler);
202     wifi_error (* wifi_set_country_code)(wifi_interface_handle, const char *);
203 } wifi_hal_fn;
204 wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn);
205
206 #endif
207