1 /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions
5  * are met:
6  *  * Redistributions of source code must retain the above copyright
7  *    notice, this list of conditions and the following disclaimer.
8  *  * Redistributions in binary form must reproduce the above
9  *    copyright notice, this list of conditions and the following
10  *    disclaimer in the documentation and/or other materials provided
11  *    with the distribution.
12  *  * Neither the name of The Linux Foundation nor the names of its
13  *    contributors may be used to endorse or promote products derived
14  *    from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __WIFI_HAL_LOWI_INTERNAL_H__
30 #define __WIFI_HAL_LOWI_INTERNAL_H__
31 
32 /*
33  * The file defines the interface by which wifihal can call LOWI for the
34  * purposes of initialization, rtt and gscan.
35  */
36 
37 #include "wifi_hal.h"
38 #include "list.h"
39 #include "sys/un.h"
40 
41 #define WIFIHAL_LOWI_MAJOR_VERSION      2
42 #define WIFIHAL_LOWI_MINOR_VERSION      1
43 #define WIFIHAL_LOWI_MICRO_VERSION      1
44 
45 /* LOWI supported capabilities bit masks */
46 #define ONE_SIDED_RANGING_SUPPORTED   0x00000001
47 #define DUAL_SIDED_RANGING_SUPPORED   0x00000002
48 #define GSCAN_SUPPORTED               0x00000004
49 
50 typedef struct wifihal_mon_sock_s {
51 
52   struct list_head list;
53   //! Family name
54   uint32_t family_name;
55   //! command ID
56   uint32_t cmd_id;
57   //! monitor sock len
58   uint32_t monsock_len;
59   //! monitor sock
60   struct sockaddr_un monsock;
61   //! match buff length
62   uint32_t match_len;
63   //! reserved byte
64   uint32_t reserved[4];
65   //! match buff
66   char match[0];
67 } wifihal_mon_sock_t;
68 
69 /*
70  * This structure is a table of function pointers to the functions
71  * used by the wifihal to interface with LOWI
72  */
73 typedef struct
74 {
75   /* lowi-client interface functions */
76   int (*init)();
77   int (*destroy)();
78   /* rtt functions */
79   int (*get_rtt_capabilities)(wifi_interface_handle iface,
80                               wifi_rtt_capabilities *capabilities);
81   int (*rtt_range_request)(u32 request_id,
82                            wifi_interface_handle iface,
83                            u32 num_rtt_config,
84                            wifi_rtt_config rtt_config[],
85                            wifi_rtt_event_handler handler);
86   int (*rtt_range_cancel)(u32 request_id,
87                           u32 num_devices,
88                           mac_addr addr[]);
89   /* Additional lowi-client interface functions */
90   int (*get_lowi_version) (u16* major_version,
91                            u16* minor_version,
92                            u16* micro_version);
93   int (*get_lowi_capabilities)(u32* capabilities);
94  /* gscan functions */
95   wifi_error (*get_valid_channels)(wifi_interface_handle iface,
96                                    u32 band,
97                                    u32 max_channels,
98                                    wifi_channel *channels,
99                                    int *num_channels);
100 
101   wifi_error (*get_gscan_capabilities)(wifi_interface_handle handle,
102                                        wifi_gscan_capabilities *capabilities);
103 
104   wifi_error (*start_gscan)(wifi_request_id request_id,
105                             wifi_interface_handle iface,
106                             wifi_scan_cmd_params params,
107                             wifi_scan_result_handler handler);
108 
109   wifi_error (*stop_gscan)(wifi_request_id request_id,
110                            wifi_interface_handle iface);
111 
112   wifi_error (*get_cached_gscan_results)(wifi_interface_handle iface,
113                                          byte flush,
114                                          u32 max,
115                                          wifi_cached_scan_results *results,
116                                          int *num);
117 
118   wifi_error (*set_bssid_hotlist)(wifi_request_id request_id,
119                                   wifi_interface_handle iface,
120                                   wifi_bssid_hotlist_params params,
121                                   wifi_hotlist_ap_found_handler handler);
122 
123   wifi_error (*reset_bssid_hotlist)(wifi_request_id request_id,
124                                     wifi_interface_handle iface);
125 
126   wifi_error (*set_significant_change_handler)(wifi_request_id id,
127                                                wifi_interface_handle iface,
128                                                wifi_significant_change_params params,
129                                                wifi_significant_change_handler handler);
130 
131   wifi_error (*reset_significant_change_handler)(wifi_request_id id,
132                                                  wifi_interface_handle iface);
133 
134   wifi_error (*set_ssid_hotlist)(wifi_request_id id,
135                                  wifi_interface_handle iface,
136                                  wifi_ssid_hotlist_params params,
137                                  wifi_hotlist_ssid_handler handler);
138 
139   wifi_error (*reset_ssid_hotlist)(wifi_request_id id,
140                                    wifi_interface_handle iface);
141 
142   // API to configure the LCI. Used in RTT Responder mode only
143   wifi_error (*rtt_set_lci)(wifi_request_id id,
144                             wifi_interface_handle iface,
145                             wifi_lci_information *lci);
146 
147   // API to configure the LCR. Used in RTT Responder mode only.
148   wifi_error (*rtt_set_lcr)(wifi_request_id id,
149                             wifi_interface_handle iface,
150                             wifi_lcr_information *lcr);
151 
152   /**
153    * Get RTT responder information e.g. WiFi channel to enable responder on.
154    */
155   wifi_error (*rtt_get_responder_info)(wifi_interface_handle iface,
156                                        wifi_rtt_responder *responder_info);
157 
158   /**
159    * Enable RTT responder mode.
160    * channel_hint - hint of the channel information where RTT responder should
161    *                be enabled on.
162    * max_duration_seconds - timeout of responder mode.
163    * responder_info - responder information e.g. channel used for RTT responder,
164    *                  NULL if responder is not enabled.
165    */
166   wifi_error (*enable_responder)(wifi_request_id id,
167                                  wifi_interface_handle iface,
168                                  wifi_channel_info channel_hint,
169                                  unsigned max_duration_seconds,
170                                  wifi_rtt_responder *responder_info);
171 
172   /**
173    * Disable RTT responder mode.
174    */
175   wifi_error (*disable_responder)(wifi_request_id id,
176                                   wifi_interface_handle iface);
177 
178 } lowi_cb_table_t;
179 
180 /*
181   * This is a function pointer to a function that gets the table
182   * of callback functions populated by LOWI and to be used by wifihal
183   */
184 typedef lowi_cb_table_t* (getCbTable_t)();
185 
186 #endif
187