Loading...
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
12enum {
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
28enum {
29 WILC_SET_CFG = 0,
30 WILC_GET_CFG
31};
32
33struct rf_info {
34 u8 link_speed;
35 s8 rssi;
36 u32 tx_cnt;
37 u32 rx_cnt;
38 u32 tx_fail_cnt;
39};
40
41enum host_if_state {
42 HOST_IF_IDLE = 0,
43 HOST_IF_SCANNING = 1,
44 HOST_IF_CONNECTING = 2,
45 HOST_IF_WAITING_CONN_RESP = 3,
46 HOST_IF_CONNECTED = 4,
47 HOST_IF_P2P_LISTEN = 5,
48 HOST_IF_EXTERNAL_AUTH = 6,
49 HOST_IF_FORCE_32BIT = 0xFFFFFFFF
50};
51
52struct cfg_param_attr {
53 u32 flag;
54 u16 short_retry_limit;
55 u16 long_retry_limit;
56 u16 frag_threshold;
57 u16 rts_threshold;
58};
59
60enum cfg_param {
61 WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
62 WILC_CFG_PARAM_RETRY_LONG = BIT(1),
63 WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
64 WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
65};
66
67enum scan_event {
68 SCAN_EVENT_NETWORK_FOUND = 0,
69 SCAN_EVENT_DONE = 1,
70 SCAN_EVENT_ABORTED = 2,
71 SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF
72};
73
74enum conn_event {
75 CONN_DISCONN_EVENT_CONN_RESP = 0,
76 CONN_DISCONN_EVENT_DISCONN_NOTIF = 1,
77 CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF
78};
79
80enum {
81 WILC_HIF_SDIO = 0,
82 WILC_HIF_SPI = BIT(0)
83};
84
85enum {
86 WILC_MAC_STATUS_INIT = -1,
87 WILC_MAC_STATUS_DISCONNECTED = 0,
88 WILC_MAC_STATUS_CONNECTED = 1
89};
90
91struct wilc_rcvd_net_info {
92 s8 rssi;
93 u8 ch;
94 u16 frame_len;
95 struct ieee80211_mgmt *mgmt;
96};
97
98struct wilc_priv;
99struct wilc_user_scan_req {
100 void (*scan_result)(enum scan_event evt,
101 struct wilc_rcvd_net_info *info,
102 struct wilc_priv *priv);
103 struct wilc_priv *priv;
104 u32 ch_cnt;
105};
106
107struct wilc_join_bss_param;
108struct wilc_conn_info {
109 u8 bssid[ETH_ALEN];
110 u8 security;
111 enum authtype auth_type;
112 enum mfptype mfp_type;
113 u8 *req_ies;
114 size_t req_ies_len;
115 u8 *resp_ies;
116 u16 resp_ies_len;
117 u16 status;
118 void (*conn_result)(enum conn_event evt, u8 status,
119 struct wilc_priv *priv);
120 struct wilc_priv *priv;
121 struct wilc_join_bss_param *param;
122};
123
124struct wilc_vif;
125struct wilc_remain_ch {
126 u16 ch;
127 void (*expired)(struct wilc_vif *vif, u64 cookie);
128 struct wilc_vif *vif;
129 u64 cookie;
130};
131
132struct wilc;
133struct host_if_drv {
134 struct wilc_user_scan_req usr_scan_req;
135 struct wilc_conn_info conn_info;
136 struct wilc_remain_ch remain_on_ch;
137 u64 p2p_timeout;
138
139 enum host_if_state hif_state;
140
141 u8 assoc_bssid[ETH_ALEN];
142
143 struct timer_list scan_timer;
144 struct wilc_vif *scan_timer_vif;
145
146 struct timer_list connect_timer;
147 struct wilc_vif *connect_timer_vif;
148
149 struct timer_list remain_on_ch_timer;
150 struct wilc_vif *remain_on_ch_timer_vif;
151
152 bool ifc_up;
153 u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
154};
155
156int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
157 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
158 u8 mode, u8 cipher_mode, u8 index);
159int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
160 const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
161 u8 index);
162s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
163 u32 *out_val);
164int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
165 u8 index, u32 key_rsc_len, const u8 *key_rsc,
166 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
167 u8 cipher_mode);
168int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
169int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
170int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
171int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
172 size_t ies_len);
173int wilc_disconnect(struct wilc_vif *vif);
174int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
175int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
176int wilc_scan(struct wilc_vif *vif, u8 scan_source,
177 u8 scan_type, u8 *ch_freq_list,
178 void (*scan_result_fn)(enum scan_event,
179 struct wilc_rcvd_net_info *,
180 struct wilc_priv *),
181 struct cfg80211_scan_request *request);
182int wilc_hif_set_cfg(struct wilc_vif *vif,
183 struct cfg_param_attr *cfg_param);
184int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
185int wilc_deinit(struct wilc_vif *vif);
186int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
187 struct cfg80211_beacon_data *params);
188int wilc_del_beacon(struct wilc_vif *vif);
189int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
190 struct station_parameters *params);
191int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
192int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
193int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
194 struct station_parameters *params);
195int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
196int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
197 u8 *mc_list);
198int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
199 void (*expired)(struct wilc_vif *, u64));
200int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
201void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
202int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
203 u8 ifc_id);
204int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
205int wilc_get_vif_idx(struct wilc_vif *vif);
206int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
207int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
208void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
209int wilc_set_external_auth_param(struct wilc_vif *vif,
210 struct cfg80211_external_auth_params *param);
211void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
212void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
213void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
214struct wilc_join_bss_param *
215wilc_parse_join_bss_param(struct cfg80211_bss *bss,
216 struct cfg80211_crypto_settings *crypto);
217int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
218void wilc_handle_disconnect(struct wilc_vif *vif);
219
220#endif
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
12enum {
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
28enum {
29 WILC_SET_CFG = 0,
30 WILC_GET_CFG
31};
32
33#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256
34
35struct rf_info {
36 u8 link_speed;
37 s8 rssi;
38 u32 tx_cnt;
39 u32 rx_cnt;
40 u32 tx_fail_cnt;
41};
42
43enum 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_EXTERNAL_AUTH = 6,
51 HOST_IF_FORCE_32BIT = 0xFFFFFFFF
52};
53
54struct cfg_param_attr {
55 u32 flag;
56 u16 short_retry_limit;
57 u16 long_retry_limit;
58 u16 frag_threshold;
59 u16 rts_threshold;
60};
61
62enum cfg_param {
63 WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
64 WILC_CFG_PARAM_RETRY_LONG = BIT(1),
65 WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
66 WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
67};
68
69enum scan_event {
70 SCAN_EVENT_NETWORK_FOUND = 0,
71 SCAN_EVENT_DONE = 1,
72 SCAN_EVENT_ABORTED = 2,
73 SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF
74};
75
76enum conn_event {
77 CONN_DISCONN_EVENT_CONN_RESP = 0,
78 CONN_DISCONN_EVENT_DISCONN_NOTIF = 1,
79 CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF
80};
81
82enum {
83 WILC_HIF_SDIO = 0,
84 WILC_HIF_SPI = BIT(0)
85};
86
87enum {
88 WILC_MAC_STATUS_INIT = -1,
89 WILC_MAC_STATUS_DISCONNECTED = 0,
90 WILC_MAC_STATUS_CONNECTED = 1
91};
92
93struct wilc_rcvd_net_info {
94 s8 rssi;
95 u8 ch;
96 u16 frame_len;
97 struct ieee80211_mgmt *mgmt;
98};
99
100struct wilc_user_scan_req {
101 void (*scan_result)(enum scan_event evt,
102 struct wilc_rcvd_net_info *info, void *priv);
103 void *arg;
104 u32 ch_cnt;
105};
106
107struct wilc_conn_info {
108 u8 bssid[ETH_ALEN];
109 u8 security;
110 enum authtype auth_type;
111 enum mfptype mfp_type;
112 u8 ch;
113 u8 *req_ies;
114 size_t req_ies_len;
115 u8 *resp_ies;
116 u16 resp_ies_len;
117 u16 status;
118 void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
119 void *arg;
120 void *param;
121};
122
123struct wilc_remain_ch {
124 u16 ch;
125 u32 duration;
126 void (*expired)(void *priv, u64 cookie);
127 void *arg;
128 u64 cookie;
129};
130
131struct wilc;
132struct host_if_drv {
133 struct wilc_user_scan_req usr_scan_req;
134 struct wilc_conn_info conn_info;
135 struct wilc_remain_ch remain_on_ch;
136 u64 p2p_timeout;
137
138 enum host_if_state hif_state;
139
140 u8 assoc_bssid[ETH_ALEN];
141
142 struct timer_list scan_timer;
143 struct wilc_vif *scan_timer_vif;
144
145 struct timer_list connect_timer;
146 struct wilc_vif *connect_timer_vif;
147
148 struct timer_list remain_on_ch_timer;
149 struct wilc_vif *remain_on_ch_timer_vif;
150
151 bool ifc_up;
152 u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
153};
154
155struct wilc_vif;
156int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
157 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
158 u8 mode, u8 cipher_mode, u8 index);
159int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
160 const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
161 u8 index);
162s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
163 u32 *out_val);
164int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
165 u8 index, u32 key_rsc_len, const u8 *key_rsc,
166 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
167 u8 cipher_mode);
168int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
169int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
170int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
171int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
172 size_t ies_len);
173int wilc_disconnect(struct wilc_vif *vif);
174int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
175int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
176int 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);
181int wilc_hif_set_cfg(struct wilc_vif *vif,
182 struct cfg_param_attr *cfg_param);
183int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
184int wilc_deinit(struct wilc_vif *vif);
185int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
186 struct cfg80211_beacon_data *params);
187int wilc_del_beacon(struct wilc_vif *vif);
188int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
189 struct station_parameters *params);
190int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
191int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
192int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
193 struct station_parameters *params);
194int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
195int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
196 u8 *mc_list);
197int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
198 u32 duration, u16 chan,
199 void (*expired)(void *, u64),
200 void *user_arg);
201int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
202void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
203int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
204 u8 ifc_id);
205int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
206int wilc_get_vif_idx(struct wilc_vif *vif);
207int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
208int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
209void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
210int wilc_set_external_auth_param(struct wilc_vif *vif,
211 struct cfg80211_external_auth_params *param);
212void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
213void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
214void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
215void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
216 struct cfg80211_crypto_settings *crypto);
217int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
218void wilc_handle_disconnect(struct wilc_vif *vif);
219
220#endif