Linux-libre 5.7.3-gnu
[librecmc/linux-libre.git] / drivers / staging / wilc1000 / hif.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
4  * All rights reserved.
5  */
6
7 #ifndef WILC_HIF_H
8 #define WILC_HIF_H
9 #include <linux/ieee80211.h>
10 #include "wlan_if.h"
11
12 enum {
13         WILC_IDLE_MODE = 0x0,
14         WILC_AP_MODE = 0x1,
15         WILC_STATION_MODE = 0x2,
16         WILC_GO_MODE = 0x3,
17         WILC_CLIENT_MODE = 0x4
18 };
19
20 #define WILC_MAX_NUM_PROBED_SSID                10
21
22 #define WILC_TX_MIC_KEY_LEN                     8
23 #define WILC_RX_MIC_KEY_LEN                     8
24
25 #define WILC_ADD_STA_LENGTH                     40
26 #define WILC_NUM_CONCURRENT_IFC                 2
27
28 enum {
29         WILC_SET_CFG = 0,
30         WILC_GET_CFG
31 };
32
33 #define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
34
35 struct rf_info {
36         u8 link_speed;
37         s8 rssi;
38         u32 tx_cnt;
39         u32 rx_cnt;
40         u32 tx_fail_cnt;
41 };
42
43 enum host_if_state {
44         HOST_IF_IDLE                    = 0,
45         HOST_IF_SCANNING                = 1,
46         HOST_IF_CONNECTING              = 2,
47         HOST_IF_WAITING_CONN_RESP       = 3,
48         HOST_IF_CONNECTED               = 4,
49         HOST_IF_P2P_LISTEN              = 5,
50         HOST_IF_FORCE_32BIT             = 0xFFFFFFFF
51 };
52
53 struct cfg_param_attr {
54         u32 flag;
55         u16 short_retry_limit;
56         u16 long_retry_limit;
57         u16 frag_threshold;
58         u16 rts_threshold;
59 };
60
61 enum cfg_param {
62         WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
63         WILC_CFG_PARAM_RETRY_LONG = BIT(1),
64         WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
65         WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
66 };
67
68 enum scan_event {
69         SCAN_EVENT_NETWORK_FOUND        = 0,
70         SCAN_EVENT_DONE                 = 1,
71         SCAN_EVENT_ABORTED              = 2,
72         SCAN_EVENT_FORCE_32BIT          = 0xFFFFFFFF
73 };
74
75 enum conn_event {
76         CONN_DISCONN_EVENT_CONN_RESP            = 0,
77         CONN_DISCONN_EVENT_DISCONN_NOTIF        = 1,
78         CONN_DISCONN_EVENT_FORCE_32BIT          = 0xFFFFFFFF
79 };
80
81 enum {
82         WILC_HIF_SDIO = 0,
83         WILC_HIF_SPI = BIT(0)
84 };
85
86 enum {
87         WILC_MAC_STATUS_INIT = -1,
88         WILC_MAC_STATUS_DISCONNECTED = 0,
89         WILC_MAC_STATUS_CONNECTED = 1
90 };
91
92 struct wilc_rcvd_net_info {
93         s8 rssi;
94         u8 ch;
95         u16 frame_len;
96         struct ieee80211_mgmt *mgmt;
97 };
98
99 struct wilc_user_scan_req {
100         void (*scan_result)(enum scan_event evt,
101                             struct wilc_rcvd_net_info *info, void *priv);
102         void *arg;
103         u32 ch_cnt;
104 };
105
106 struct wilc_conn_info {
107         u8 bssid[ETH_ALEN];
108         u8 security;
109         enum authtype auth_type;
110         u8 ch;
111         u8 *req_ies;
112         size_t req_ies_len;
113         u8 *resp_ies;
114         u16 resp_ies_len;
115         u16 status;
116         void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
117         void *arg;
118         void *param;
119 };
120
121 struct wilc_remain_ch {
122         u16 ch;
123         u32 duration;
124         void (*expired)(void *priv, u64 cookie);
125         void *arg;
126         u32 cookie;
127 };
128
129 struct wilc;
130 struct host_if_drv {
131         struct wilc_user_scan_req usr_scan_req;
132         struct wilc_conn_info conn_info;
133         struct wilc_remain_ch remain_on_ch;
134         u64 p2p_timeout;
135
136         enum host_if_state hif_state;
137
138         u8 assoc_bssid[ETH_ALEN];
139
140         struct timer_list scan_timer;
141         struct wilc_vif *scan_timer_vif;
142
143         struct timer_list connect_timer;
144         struct wilc_vif *connect_timer_vif;
145
146         struct timer_list remain_on_ch_timer;
147         struct wilc_vif *remain_on_ch_timer_vif;
148
149         bool ifc_up;
150         u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
151 };
152
153 struct wilc_vif;
154 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
155 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
156 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
157                              u8 index);
158 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
159                             u8 index, u8 mode, enum authtype auth_type);
160 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
161                  const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
162                  u8 mode, u8 cipher_mode, u8 index);
163 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
164                            u32 *out_val);
165 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
166                     u8 index, u32 key_rsc_len, const u8 *key_rsc,
167                     const u8 *rx_mic, const u8 *tx_mic, u8 mode,
168                     u8 cipher_mode);
169 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
170 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
171 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
172                       size_t ies_len);
173 int wilc_disconnect(struct wilc_vif *vif);
174 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
175 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
176 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
177               u8 *ch_freq_list, u8 ch_list_len,
178               void (*scan_result_fn)(enum scan_event,
179                                      struct wilc_rcvd_net_info *, void *),
180               void *user_arg, struct cfg80211_scan_request *request);
181 int wilc_hif_set_cfg(struct wilc_vif *vif,
182                      struct cfg_param_attr *cfg_param);
183 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
184 int wilc_deinit(struct wilc_vif *vif);
185 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
186                     struct cfg80211_beacon_data *params);
187 int wilc_del_beacon(struct wilc_vif *vif);
188 int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
189                      struct station_parameters *params);
190 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
191 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
192 int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
193                       struct station_parameters *params);
194 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
195 int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
196                                 u8 *mc_list);
197 int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
198                            u32 duration, u16 chan,
199                            void (*expired)(void *, u64),
200                            void *user_arg);
201 int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
202 void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
203 int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
204                             u8 ifc_id);
205 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
206 int wilc_get_vif_idx(struct wilc_vif *vif);
207 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
208 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
209 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
210 void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
211 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
212 void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
213                                 struct cfg80211_crypto_settings *crypto);
214 #endif