blob: 59db1d5ca88e4a46a6845ac6296956ae3fe018f7 [file] [log] [blame]
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001/*!
2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
4 * @author aabouzaeid
5 * mabubakr
6 * mdaftedar
7 * zsalah
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
9 * @date 31 Aug 2010
10 * @version 1.0
11 */
12
13#include "wilc_wfi_cfgoperations.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090014#ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +090015#include "linux_wlan_sdio.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090016#endif
Leo Kim7ae43362015-09-16 18:35:59 +090017#include <linux/errno.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +090018
19#define IS_MANAGMEMENT 0x100
20#define IS_MANAGMEMENT_CALLBACK 0x080
21#define IS_MGMT_STATUS_SUCCES 0x040
22#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
23
Johnny Kimc5c77ba2015-05-11 14:30:56 +090024extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
Dean Lee72ed4dc2015-06-12 14:11:44 +090025extern u16 Set_machw_change_vir_if(bool bValue);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090026
27extern int mac_open(struct net_device *ndev);
28extern int mac_close(struct net_device *ndev);
29
30tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090031u32 u32LastScannedNtwrksCountShadow;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070032struct timer_list hDuringIpTimer;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070033struct timer_list hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090034static u8 op_ifcs;
35extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090036
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090037u8 g_wilc_initialized = 1;
Dean Lee72ed4dc2015-06-12 14:11:44 +090038extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090039
40#define CHAN2G(_channel, _freq, _flags) { \
41 .band = IEEE80211_BAND_2GHZ, \
42 .center_freq = (_freq), \
43 .hw_value = (_channel), \
44 .flags = (_flags), \
45 .max_antenna_gain = 0, \
46 .max_power = 30, \
47}
48
49/*Frequency range for channels*/
50static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
51 CHAN2G(1, 2412, 0),
52 CHAN2G(2, 2417, 0),
53 CHAN2G(3, 2422, 0),
54 CHAN2G(4, 2427, 0),
55 CHAN2G(5, 2432, 0),
56 CHAN2G(6, 2437, 0),
57 CHAN2G(7, 2442, 0),
58 CHAN2G(8, 2447, 0),
59 CHAN2G(9, 2452, 0),
60 CHAN2G(10, 2457, 0),
61 CHAN2G(11, 2462, 0),
62 CHAN2G(12, 2467, 0),
63 CHAN2G(13, 2472, 0),
64 CHAN2G(14, 2484, 0),
65};
66
67#define RATETAB_ENT(_rate, _hw_value, _flags) { \
68 .bitrate = (_rate), \
69 .hw_value = (_hw_value), \
70 .flags = (_flags), \
71}
72
73
74/* Table 6 in section 3.2.1.1 */
75static struct ieee80211_rate WILC_WFI_rates[] = {
76 RATETAB_ENT(10, 0, 0),
77 RATETAB_ENT(20, 1, 0),
78 RATETAB_ENT(55, 2, 0),
79 RATETAB_ENT(110, 3, 0),
80 RATETAB_ENT(60, 9, 0),
81 RATETAB_ENT(90, 6, 0),
82 RATETAB_ENT(120, 7, 0),
83 RATETAB_ENT(180, 8, 0),
84 RATETAB_ENT(240, 9, 0),
85 RATETAB_ENT(360, 10, 0),
86 RATETAB_ENT(480, 11, 0),
87 RATETAB_ENT(540, 12, 0),
88};
89
Johnny Kimc5c77ba2015-05-11 14:30:56 +090090struct p2p_mgmt_data {
91 int size;
92 u8 *buff;
93};
94
95/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090096u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090097
Chaehyun Lim866a2c22015-10-02 16:41:21 +090098u8 curr_channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090099
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900100u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
101u8 u8P2Plocalrandom = 0x01;
102u8 u8P2Precvrandom = 0x00;
103u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200104bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900105
106static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
107 .channels = WILC_WFI_2ghz_channels,
108 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
109 .bitrates = WILC_WFI_rates,
110 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
111};
112
113
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900114struct add_key_params {
115 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900116 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900117 u8 *mac_addr;
118};
119struct add_key_params g_add_gtk_key_params;
120struct wilc_wfi_key g_key_gtk_params;
121struct add_key_params g_add_ptk_key_params;
122struct wilc_wfi_key g_key_ptk_params;
123struct wilc_wfi_wep_key g_key_wep_params;
Daniel Machon7fc80962015-08-05 00:09:35 +0200124bool g_ptk_keys_saved;
125bool g_gtk_keys_saved;
126bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900127
128#define AGING_TIME (9 * 1000)
129#define duringIP_TIME 15000
130
131void clear_shadow_scan(void *pUserVoid)
132{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900133 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900134
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900135 if (op_ifcs == 0) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -0700136 del_timer_sync(&hAgingTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900137 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
138
139 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
140 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900141 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900142 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
143 }
144
145 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
146 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
147 }
148 u32LastScannedNtwrksCountShadow = 0;
149 }
150
151}
152
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900153u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900154{
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900155 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900156 int rssi_v = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900157 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900158
159 for (i = 0; i < num_rssi; i++)
160 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
161
162 rssi_v /= num_rssi;
163 return rssi_v;
164}
165
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900166void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900167{
Chaehyun Lim27268872015-09-15 14:06:13 +0900168 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900169 struct wiphy *wiphy;
170 struct cfg80211_bss *bss = NULL;
171 int i;
172 int rssi = 0;
173
Chaehyun Lim27268872015-09-15 14:06:13 +0900174 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900175 wiphy = priv->dev->ieee80211_ptr->wiphy;
176
177 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
178 tstrNetworkInfo *pstrNetworkInfo;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900179
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900180 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
181
182
183 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900184 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900185 struct ieee80211_channel *channel;
186
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900187 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900188
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900189 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900190 channel = ieee80211_get_channel(wiphy, s32Freq);
191
192 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900193 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900194 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
195 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900196 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900197 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 }
199 }
200
201 }
202 }
203
204}
205
206void reset_shadow_found(void *pUserVoid)
207{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900208 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900209
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900210 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
211 astrLastScannedNtwrksShadow[i].u8Found = 0;
212
213 }
214}
215
216void update_scan_time(void *pUserVoid)
217{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900218 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900219
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900220 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
221 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
222 }
223}
224
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700225static void remove_network_from_shadow(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900226{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900227 unsigned long now = jiffies;
228 int i, j;
229
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900230
231 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
232 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530233 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900234
Shraddha Barkecccfc392015-10-12 20:49:19 +0530235 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
236 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900237
238 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
239
240 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
241 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
242 }
243 u32LastScannedNtwrksCountShadow--;
244 }
245 }
246
247 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700248 if (u32LastScannedNtwrksCountShadow != 0) {
249 hAgingTimer.data = arg;
250 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
251 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900252 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700253 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900254}
255
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700256static void clear_duringIP(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900257{
258 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900259 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260}
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900261
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900262int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900264 int state = -1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900265 int i;
266
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900267 if (u32LastScannedNtwrksCountShadow == 0) {
268 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700269 hAgingTimer.data = (unsigned long)pUserVoid;
270 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271 state = -1;
272 } else {
273 /* Linear search for now */
274 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900275 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900276 pstrNetworkInfo->au8bssid, 6) == 0) {
277 state = i;
278 break;
279 }
280 }
281 }
282 return state;
283}
284
285void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
286{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900287 int ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900288 u32 ap_index = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900289 u8 rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900290
291 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
292 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
293 return;
294 }
295 if (ap_found == -1) {
296 ap_index = u32LastScannedNtwrksCountShadow;
297 u32LastScannedNtwrksCountShadow++;
298
299 } else {
300 ap_index = ap_found;
301 }
302 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
303 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
304 if (rssi_index == NUM_RSSI) {
305 rssi_index = 0;
306 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
307 }
308 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
309
310 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
311 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
312
313 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900314 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900315 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
316
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900317 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900318 pstrNetworkInfo->au8bssid, ETH_ALEN);
319
320 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
321 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
322 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
323
324 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
325 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
326 if (ap_found != -1)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900327 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Glen Leef3052582015-09-10 12:03:04 +0900329 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900330 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900331 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
332
333 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
334 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
335 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
336 if (ap_found != -1)
337 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
338 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
339
340}
341
342
343/**
344 * @brief CfgScanResult
345 * @details Callback function which returns the scan results found
346 *
347 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
348 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
349 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
350 * void* pUserVoid: Private structure associated with the wireless interface
351 * @return NONE
352 * @author mabubakr
353 * @date
354 * @version 1.0
355 */
Leo Kim1ec38152015-10-12 16:55:59 +0900356static void CfgScanResult(enum scan_event enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900357{
Chaehyun Lim27268872015-09-15 14:06:13 +0900358 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900359 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900360 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361 struct ieee80211_channel *channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900362 struct cfg80211_bss *bss = NULL;
363
Chaehyun Lim27268872015-09-15 14:06:13 +0900364 priv = (struct wilc_priv *)pUserVoid;
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +0100365 if (priv->bCfgScanning) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900366 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
367 wiphy = priv->dev->ieee80211_ptr->wiphy;
Leo Kim7ae43362015-09-16 18:35:59 +0900368
369 if (!wiphy)
370 return;
371
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900372 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
373 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900374 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900375 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900376 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377 ) {
Leo Kim24db7132015-09-16 18:36:01 +0900378 PRINT_ER("wiphy signal type fial\n");
379 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900380 }
381
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900382 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900383 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900384 channel = ieee80211_get_channel(wiphy, s32Freq);
385
Leo Kim7ae43362015-09-16 18:35:59 +0900386 if (!channel)
387 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900388
389 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530390 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
392
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +0100393 if (pstrNetworkInfo->bNewNetwork) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900394 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
395 /* max_scan_ssids */
396 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
397
398
399 priv->u32RcvdChCount++;
400
401
402
403 if (pJoinParams == NULL) {
404 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
405 }
406 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
407
408 /*P2P peers are sent to WPA supplicant and added to shadow table*/
409
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900410 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900411 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
412 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900413 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900414 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900415 }
416
417
418 } else {
419 PRINT_ER("Discovered networks exceeded the max limit\n");
420 }
421 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900422 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900423 /* So this network is discovered before, we'll just update its RSSI */
424 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900425 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530426 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900427
428 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
429 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
430 break;
431 }
432 }
433 }
434 }
435 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530436 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
437 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900438 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900439
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530440 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530441 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530442 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530443 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900444
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200445 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900446
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900447 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900448 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900449 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900450 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900451 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900452 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200453 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454
455 }
456 /*Aborting any scan operation during mac close*/
457 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200458 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900459
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530460 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900461 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900462
463 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900464 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900465
Dean Lee72ed4dc2015-06-12 14:11:44 +0900466 cfg80211_scan_done(priv->pstrScanReq, false);
467 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900468 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200470 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900471 }
472 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900473}
474
475
476/**
477 * @brief WILC_WFI_Set_PMKSA
478 * @details Check if pmksa is cached and set it.
479 * @param[in]
480 * @return int : Return 0 on Success
481 * @author mdaftedar
482 * @date 01 MAR 2012
483 * @version 1.0
484 */
Chaehyun Lim27268872015-09-15 14:06:13 +0900485int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900486{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900487 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900488 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489
490
491 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
492
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900493 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900494 ETH_ALEN)) {
495 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
496
497 /*If bssid is found, set the values*/
498 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
499
Leo Kime6e12662015-09-16 18:36:03 +0900500 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501 PRINT_ER("Error in pmkid\n");
502
503 break;
504 }
505 }
506
507 return s32Error;
508
509
510}
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900511int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512
513
514/**
515 * @brief CfgConnectResult
516 * @details
517 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
518 * connection response or disconnection notification.
519 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900520 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900521 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
522 * void* pUserVoid: Private data associated with wireless interface
523 * @return NONE
524 * @author mabubakr
525 * @date 01 MAR 2012
526 * @version 1.0
527 */
528int connecting;
529
Leo Kimed3f0372015-10-12 16:56:01 +0900530static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900531 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900532 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900533 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
534 void *pUserVoid)
535{
Chaehyun Lim27268872015-09-15 14:06:13 +0900536 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900537 struct net_device *dev;
Leo Kim441dc602015-10-12 16:55:35 +0900538 struct host_if_drv *pstrWFIDrv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900539 u8 NullBssid[ETH_ALEN] = {0};
Glen Leec1ec2c12015-10-20 17:13:58 +0900540 struct wilc *wl;
541 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900542
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543 connecting = 0;
544
Chaehyun Lim27268872015-09-15 14:06:13 +0900545 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900546 dev = priv->dev;
Glen Leec1ec2c12015-10-20 17:13:58 +0900547 nic = netdev_priv(dev);
548 wl = nic->wilc;
Leo Kim441dc602015-10-12 16:55:35 +0900549 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900550
551 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
552 /*Initialization*/
Amitoj Kaur Chawlababa7c72015-10-15 13:48:29 +0530553 u16 u16ConnectStatus;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900554
555 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
556
557 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
558
559 if ((u8MacStatus == MAC_DISCONNECTED) &&
560 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
561 /* The case here is that our station was waiting for association response frame and has just received it containing status code
562 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
563 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
564 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530565 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900566
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900567 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900568 if (!pstrWFIDrv->u8P2PConnect)
569 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530571 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900572 }
573
574 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900575 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900576 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900577
578 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
579 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900580 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900581
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900582
583 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900584 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900585 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
586 unsigned long now = jiffies;
587
588 if (time_after(now,
589 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900590 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591 }
592
593 break;
594 }
595 }
596
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000597 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900598 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900599 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600
601 }
602
603 }
604
605
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530606 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900607
608 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
609
610 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
611 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
612 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
613 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
614 /* be replaced by pstrConnectInfo->u16ConnectStatus */
615 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900616 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900617 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
618 pstrDisconnectNotifInfo->u16reason, priv->dev);
619 u8P2Plocalrandom = 0x01;
620 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900621 bWilc_ie = false;
Shraddha Barkebcf02652015-10-05 17:00:32 +0530622 eth_zero_addr(priv->au8AssociatedBss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900623 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530624 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900625
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900626 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900627 if (!pstrWFIDrv->u8P2PConnect)
628 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
630 * virtual interface to station*/
Glen Leec1ec2c12015-10-20 17:13:58 +0900631 if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900632 pstrDisconnectNotifInfo->u16reason = 3;
633 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900634 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
635 * to scan again and retry the connection*/
Glen Leec1ec2c12015-10-20 17:13:58 +0900636 else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900637 pstrDisconnectNotifInfo->u16reason = 1;
638 }
639 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530640 pstrDisconnectNotifInfo->ie_len, false,
641 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900642
643 }
644
645}
646
647
648/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900649 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900650 * @details Set channel for a given wireless interface. Some devices
651 * may support multi-channel operation (by channel hopping) so cfg80211
652 * doesn't verify much. Note, however, that the passed netdev may be
653 * %NULL as well if the user requested changing the channel for the
654 * device itself, or for a monitor interface.
655 * @param[in]
656 * @return int : Return 0 on Success
657 * @author mdaftedar
658 * @date 01 MAR 2012
659 * @version 1.0
660 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900661static int set_channel(struct wiphy *wiphy,
662 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900664 u32 channelnum = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +0900665 struct wilc_priv *priv;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900666 int result = 0;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900667
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900668 priv = wiphy_priv(wiphy);
669
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900670 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
671 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900673 curr_channel = channelnum;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900674 result = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900675
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900676 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900677 PRINT_ER("Error in setting channel %d\n", channelnum);
678
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900679 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900680}
681
682/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900683 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900684 * @details Request to do a scan. If returning zero, the scan request is given
685 * the driver, and will be valid until passed to cfg80211_scan_done().
686 * For scan results, call cfg80211_inform_bss(); you can call this outside
687 * the scan/scan_done bracket too.
688 * @param[in]
689 * @return int : Return 0 on Success
690 * @author mabubakr
691 * @date 01 MAR 2012
692 * @version 1.0
693 */
694
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900695static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900696{
Chaehyun Lim27268872015-09-15 14:06:13 +0900697 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900698 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900699 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900700 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Leo Kim607db442015-10-05 15:25:37 +0900701 struct hidden_network strHiddenNetwork;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900702
703 priv = wiphy_priv(wiphy);
704
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900705 priv->pstrScanReq = request;
706
707 priv->u32RcvdChCount = 0;
708
Johnny Kim218dc402015-08-13 13:41:19 +0900709 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900710
711
712 reset_shadow_found(priv);
713
Dean Lee72ed4dc2015-06-12 14:11:44 +0900714 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900715 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
716 /* max_scan_ssids */
717 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900718 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900719 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
720 }
721
722 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530723 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900724
725 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
726
727 if (request->n_ssids >= 1) {
728
729
Leo Kim607db442015-10-05 15:25:37 +0900730 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 strHiddenNetwork.u8ssidnum = request->n_ssids;
732
733
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900734 for (i = 0; i < request->n_ssids; i++) {
735
736 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900737 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900738 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900739 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
740 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530741 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900742 strHiddenNetwork.u8ssidnum -= 1;
743 }
744 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530745 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
747 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900748 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 CfgScanResult, (void *)priv, &strHiddenNetwork);
750 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530751 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
753 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900754 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755 CfgScanResult, (void *)priv, NULL);
756 }
757
758 } else {
759 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530760 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900761 }
762
Leo Kime6e12662015-09-16 18:36:03 +0900763 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900764 s32Error = -EBUSY;
765 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
766 }
767
768 return s32Error;
769}
770
771/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900772 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773 * @details Connect to the ESS with the specified parameters. When connected,
774 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
775 * If the connection fails for some reason, call cfg80211_connect_result()
776 * with the status from the AP.
777 * @param[in]
778 * @return int : Return 0 on Success
779 * @author mabubakr
780 * @date 01 MAR 2012
781 * @version 1.0
782 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900783static int connect(struct wiphy *wiphy, struct net_device *dev,
784 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900785{
Leo Kime6e12662015-09-16 18:36:03 +0900786 s32 s32Error = 0;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900787 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900788 u8 u8security = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +0900789 enum AUTHTYPE tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900790 char *pcgroup_encrypt_val = NULL;
791 char *pccipher_group = NULL;
792 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900793
Chaehyun Lim27268872015-09-15 14:06:13 +0900794 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +0900795 struct host_if_drv *pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 tstrNetworkInfo *pstrNetworkInfo = NULL;
797
798
799 connecting = 1;
800 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +0900801 pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900802
Johnny Kim218dc402015-08-13 13:41:19 +0900803 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900804
Johnny Kim8a143302015-06-10 17:06:46 +0900805 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
Chaehyun Lim3f882892015-08-10 11:33:17 +0900806 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900807 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
808 pstrWFIDrv->u8P2PConnect = 1;
809 } else
810 pstrWFIDrv->u8P2PConnect = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530811 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812
813 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
814 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900815 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900816 sme->ssid,
817 sme->ssid_len) == 0) {
818 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
819 if (sme->bssid == NULL) {
820 /* BSSID is not passed from the user, so decision of matching
821 * is done by SSID only */
822 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
823 break;
824 } else {
825 /* BSSID is also passed from the user, so decision of matching
826 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900827 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900828 sme->bssid,
829 ETH_ALEN) == 0) {
830 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
831 break;
832 }
833 }
834 }
835 }
836
837 if (i < u32LastScannedNtwrksCountShadow) {
838 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
839
840 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
841
842 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
843 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
844 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
845 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
846 } else {
847 s32Error = -ENOENT;
848 if (u32LastScannedNtwrksCountShadow == 0)
849 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
850 else
851 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
852
853 goto done;
854 }
855
856 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900857 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
858 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900859
860 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
861 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
862
863 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
864
865 if (INFO) {
866 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
867 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
868 }
869
870 if (sme->crypto.cipher_group != NO_ENCRYPT) {
871 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
872 * we will add to it the pairwise cipher suite(s) */
873 pcwpa_version = "Default";
874 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900875 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900876 u8security = ENCRYPT_ENABLED | WEP;
877 pcgroup_encrypt_val = "WEP40";
878 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
879 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
880
881 if (INFO) {
882 for (i = 0; i < sme->key_len; i++)
883 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
884 }
885 priv->WILC_WFI_wep_default = sme->key_idx;
886 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900887 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900888
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900889 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900890 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900891 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
892 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900893 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900894
895 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
896 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
897 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
899 pcgroup_encrypt_val = "WEP104";
900 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
901
902 priv->WILC_WFI_wep_default = sme->key_idx;
903 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900904 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900905
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900907 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
909 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900910 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900911
912 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
913 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
914 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900915 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900916 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
917 pcgroup_encrypt_val = "WPA2_TKIP";
918 pccipher_group = "TKIP";
919 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
920 /* tenuSecurity_t = WPA2_AES; */
921 u8security = ENCRYPT_ENABLED | WPA2 | AES;
922 pcgroup_encrypt_val = "WPA2_AES";
923 pccipher_group = "AES";
924 }
925 pcwpa_version = "WPA_VERSION_2";
926 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
927 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900928 u8security = ENCRYPT_ENABLED | WPA | TKIP;
929 pcgroup_encrypt_val = "WPA_TKIP";
930 pccipher_group = "TKIP";
931 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
932 /* tenuSecurity_t = WPA_AES; */
933 u8security = ENCRYPT_ENABLED | WPA | AES;
934 pcgroup_encrypt_val = "WPA_AES";
935 pccipher_group = "AES";
936
937 }
938 pcwpa_version = "WPA_VERSION_1";
939
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900940 } else {
941 s32Error = -ENOTSUPP;
942 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
943
944 goto done;
945 }
946
947 }
948
949 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
950 * add to it the pairwise cipher suite(s) */
951 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
952 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
953 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
954 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
955 u8security = u8security | TKIP;
956 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
957 u8security = u8security | AES;
958 }
959 }
960 }
961
962 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
963
964 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
965 switch (sme->auth_type) {
966 case NL80211_AUTHTYPE_OPEN_SYSTEM:
967 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
968 tenuAuth_type = OPEN_SYSTEM;
969 break;
970
971 case NL80211_AUTHTYPE_SHARED_KEY:
972 tenuAuth_type = SHARED_KEY;
973 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
974 break;
975
976 default:
977 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
978 }
979
980
981 /* ai: key_mgmt: enterprise case */
982 if (sme->crypto.n_akm_suites) {
983 switch (sme->crypto.akm_suites[0]) {
984 case WLAN_AKM_SUITE_8021X:
985 tenuAuth_type = IEEE8021;
986 break;
987
988 default:
989 break;
990 }
991 }
992
993
994 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
995
996 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
997 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
998
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900999 curr_channel = pstrNetworkInfo->u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001000
1001 if (!pstrWFIDrv->u8P2PConnect) {
1002 u8WLANChannel = pstrNetworkInfo->u8channel;
1003 }
1004
1005 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1006
1007 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1008 sme->ssid_len, sme->ie, sme->ie_len,
1009 CfgConnectResult, (void *)priv, u8security,
1010 tenuAuth_type, pstrNetworkInfo->u8channel,
1011 pstrNetworkInfo->pJoinParams);
Leo Kime6e12662015-09-16 18:36:03 +09001012 if (s32Error != 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301013 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001014 s32Error = -ENOENT;
1015 goto done;
1016 }
1017
1018done:
1019
1020 return s32Error;
1021}
1022
1023
1024/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001025 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001026 * @details Disconnect from the BSS/ESS.
1027 * @param[in]
1028 * @return int : Return 0 on Success
1029 * @author mdaftedar
1030 * @date 01 MAR 2012
1031 * @version 1.0
1032 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001033static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001034{
Leo Kime6e12662015-09-16 18:36:03 +09001035 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09001036 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09001037 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim51e825f2015-09-15 14:06:14 +09001038 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001039
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001040 connecting = 0;
1041 priv = wiphy_priv(wiphy);
1042
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001043 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Leo Kim441dc602015-10-12 16:55:35 +09001044 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001045 if (!pstrWFIDrv->u8P2PConnect)
1046 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001047 linux_wlan_set_bssid(priv->dev, NullBssid);
1048
1049 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1050
1051 u8P2Plocalrandom = 0x01;
1052 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001053 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001055
1056 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
Leo Kime6e12662015-09-16 18:36:03 +09001057 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001058 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1059 s32Error = -EINVAL;
1060 }
1061
1062 return s32Error;
1063}
1064
1065/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001066 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 * @details Add a key with the given parameters. @mac_addr will be %NULL
1068 * when adding a group key.
1069 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1070 * @return int : Return 0 on Success
1071 * @author mdaftedar
1072 * @date 01 MAR 2012
1073 * @version 1.0
1074 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001075static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1076 bool pairwise,
1077 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001078
1079{
Leo Kime6e12662015-09-16 18:36:03 +09001080 s32 s32Error = 0, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001081 u32 i;
Chaehyun Lim27268872015-09-15 14:06:13 +09001082 struct wilc_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001083 const u8 *pu8RxMic = NULL;
1084 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001085 u8 u8mode = NO_ENCRYPT;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001086 u8 u8gmode = NO_ENCRYPT;
1087 u8 u8pmode = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +09001088 enum AUTHTYPE tenuAuth_type = ANY;
Glen Lee76469202015-10-20 17:13:59 +09001089 struct wilc *wl;
1090 perInterface_wlan_t *nic;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001091
1092 priv = wiphy_priv(wiphy);
Glen Lee76469202015-10-20 17:13:59 +09001093 nic = netdev_priv(netdev);
1094 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095
1096 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1097
Johnny Kim8a143302015-06-10 17:06:46 +09001098 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099
1100 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1101 params->key[1],
1102 params->key[2]);
1103
1104
1105 switch (params->cipher) {
1106 case WLAN_CIPHER_SUITE_WEP40:
1107 case WLAN_CIPHER_SUITE_WEP104:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001108 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1109
1110 priv->WILC_WFI_wep_default = key_index;
1111 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001112 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001113
1114 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1115 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1116
1117 for (i = 0; i < params->key_len; i++)
1118 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1119
1120 tenuAuth_type = OPEN_SYSTEM;
1121
1122 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1123 u8mode = ENCRYPT_ENABLED | WEP;
1124 else
1125 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1126
1127 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1128 break;
1129 }
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001130 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 priv->WILC_WFI_wep_default = key_index;
1132 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001133 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001134
1135 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1136 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1137 if (INFO) {
1138 for (i = 0; i < params->key_len; i++)
1139 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1140 }
1141 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1142 }
1143
1144 break;
1145
1146 case WLAN_CIPHER_SUITE_TKIP:
1147 case WLAN_CIPHER_SUITE_CCMP:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1149
1150 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001151 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001152 priv->wilc_gtk[key_index]->key = NULL;
1153 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154
1155 }
1156 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001157 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001158 priv->wilc_ptk[key_index]->key = NULL;
1159 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001160 }
1161
1162
1163
Daniel Machon19132212015-08-05 08:18:31 +02001164 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001165 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1166 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1167 else
1168 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1169
1170 priv->wilc_groupkey = u8gmode;
1171
1172 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1173
1174 pu8TxMic = params->key + 24;
1175 pu8RxMic = params->key + 16;
1176 KeyLen = params->key_len - 16;
1177 }
1178 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301179 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180
Glen Leef3052582015-09-10 12:03:04 +09001181 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001182 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001183
1184 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301185 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001186
1187 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001188 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001189 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001190 }
1191
1192 priv->wilc_gtk[key_index]->cipher = params->cipher;
1193 priv->wilc_gtk[key_index]->key_len = params->key_len;
1194 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1195
1196 if (INFO) {
1197 for (i = 0; i < params->key_len; i++)
1198 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1199 for (i = 0; i < params->seq_len; i++)
1200 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1201 }
1202
1203
1204 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1205 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1206
1207 } else {
1208 PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
1209
1210 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1211 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1212 else
1213 u8pmode = priv->wilc_groupkey | AES;
1214
1215
1216 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1217
1218 pu8TxMic = params->key + 24;
1219 pu8RxMic = params->key + 16;
1220 KeyLen = params->key_len - 16;
1221 }
1222
Shraddha Barkecccfc392015-10-12 20:49:19 +05301223 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224
Glen Leef3052582015-09-10 12:03:04 +09001225 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226
Shraddha Barkecccfc392015-10-12 20:49:19 +05301227 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001228
1229 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001230 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231
1232 if (INFO) {
1233 for (i = 0; i < params->key_len; i++)
1234 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1235
1236 for (i = 0; i < params->seq_len; i++)
1237 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1238 }
1239
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001240 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001241
1242 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001243 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001244
1245 priv->wilc_ptk[key_index]->cipher = params->cipher;
1246 priv->wilc_ptk[key_index]->key_len = params->key_len;
1247 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1248
1249 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1250 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1251 }
1252 break;
1253 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001254
1255 {
1256 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001257 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001258 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1259 /* swap the tx mic by rx mic */
1260 pu8RxMic = params->key + 24;
1261 pu8TxMic = params->key + 16;
1262 KeyLen = params->key_len - 16;
1263 }
1264
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001265 /*save keys only on interface 0 (wifi interface)*/
Glen Lee76469202015-10-20 17:13:59 +09001266 if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001268 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001269 if (!mac_addr) {
1270 g_add_gtk_key_params.mac_addr = NULL;
1271 } else {
Glen Leef3052582015-09-10 12:03:04 +09001272 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001273 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1274 }
1275 g_key_gtk_params.key_len = params->key_len;
1276 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001277 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1279 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001280 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001281 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1282 }
1283 g_key_gtk_params.cipher = params->cipher;
1284
1285 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1286 g_key_gtk_params.key[1],
1287 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001288 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289 }
1290
1291 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1292 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001293 } else {
1294 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1295 /* swap the tx mic by rx mic */
1296 pu8RxMic = params->key + 24;
1297 pu8TxMic = params->key + 16;
1298 KeyLen = params->key_len - 16;
1299 }
1300
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001301 /*save keys only on interface 0 (wifi interface)*/
Glen Lee76469202015-10-20 17:13:59 +09001302 if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001303 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001304 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001305 if (!mac_addr) {
1306 g_add_ptk_key_params.mac_addr = NULL;
1307 } else {
Glen Leef3052582015-09-10 12:03:04 +09001308 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001309 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1310 }
1311 g_key_ptk_params.key_len = params->key_len;
1312 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001313 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001314 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1315 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001316 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001317 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1318 }
1319 g_key_ptk_params.cipher = params->cipher;
1320
1321 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1322 g_key_ptk_params.key[1],
1323 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001324 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001325 }
1326
1327 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1328 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1329 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1330 if (INFO) {
1331 for (i = 0; i < params->key_len; i++)
1332 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1333 }
1334 }
1335 }
1336 break;
1337
1338 default:
1339 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1340 s32Error = -ENOTSUPP;
1341
1342 }
1343
1344 return s32Error;
1345}
1346
1347/**
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001348 * @brief del_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 * @details Remove a key given the @mac_addr (%NULL for a group key)
1350 * and @key_index, return -ENOENT if the key doesn't exist.
1351 * @param[in]
1352 * @return int : Return 0 on Success
1353 * @author mdaftedar
1354 * @date 01 MAR 2012
1355 * @version 1.0
1356 */
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001357static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1358 u8 key_index,
1359 bool pairwise,
1360 const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361{
Chaehyun Lim27268872015-09-15 14:06:13 +09001362 struct wilc_priv *priv;
Glen Lee692e2ac2015-10-20 17:14:00 +09001363 struct wilc *wl;
1364 perInterface_wlan_t *nic;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365
1366 priv = wiphy_priv(wiphy);
Glen Lee692e2ac2015-10-20 17:14:00 +09001367 nic = netdev_priv(netdev);
1368 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001369
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001370 /*delete saved keys, if any*/
Glen Lee692e2ac2015-10-20 17:14:00 +09001371 if (netdev == wl->vif[0].ndev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001372 g_ptk_keys_saved = false;
1373 g_gtk_keys_saved = false;
1374 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375
1376 /*Delete saved WEP keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301377 kfree(g_key_wep_params.key);
1378 g_key_wep_params.key = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001379
1380 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1381
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382 if ((priv->wilc_gtk[key_index]) != NULL) {
1383
Shraddha Barkecccfc392015-10-12 20:49:19 +05301384 kfree(priv->wilc_gtk[key_index]->key);
1385 priv->wilc_gtk[key_index]->key = NULL;
1386 kfree(priv->wilc_gtk[key_index]->seq);
1387 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001388
Chaehyun Lim49188af2015-08-11 10:32:41 +09001389 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390 priv->wilc_gtk[key_index] = NULL;
1391
1392 }
1393
1394 if ((priv->wilc_ptk[key_index]) != NULL) {
1395
Shraddha Barkecccfc392015-10-12 20:49:19 +05301396 kfree(priv->wilc_ptk[key_index]->key);
1397 priv->wilc_ptk[key_index]->key = NULL;
1398 kfree(priv->wilc_ptk[key_index]->seq);
1399 priv->wilc_ptk[key_index]->seq = NULL;
Chaehyun Lim49188af2015-08-11 10:32:41 +09001400 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001401 priv->wilc_ptk[key_index] = NULL;
1402 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403
1404 /*Delete saved PTK and GTK keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301405 kfree(g_key_ptk_params.key);
1406 g_key_ptk_params.key = NULL;
1407 kfree(g_key_ptk_params.seq);
1408 g_key_ptk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001409
Shraddha Barkecccfc392015-10-12 20:49:19 +05301410 kfree(g_key_gtk_params.key);
1411 g_key_gtk_params.key = NULL;
1412 kfree(g_key_gtk_params.seq);
1413 g_key_gtk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001414
1415 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001416 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417 }
1418
1419 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001420 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421 priv->WILC_WFI_wep_key_len[key_index] = 0;
1422
1423 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1424 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1425 } else {
1426 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1427 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1428 }
1429
Leo Kimaaed3292015-10-12 16:55:38 +09001430 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431}
1432
1433/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001434 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001435 * @details Get information about the key with the given parameters.
1436 * @mac_addr will be %NULL when requesting information for a group
1437 * key. All pointers given to the @callback function need not be valid
1438 * after it returns. This function should return an error if it is
1439 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1440 * @param[in]
1441 * @return int : Return 0 on Success
1442 * @author mdaftedar
1443 * @date 01 MAR 2012
1444 * @version 1.0
1445 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001446static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1447 bool pairwise,
1448 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449{
Chaehyun Lim27268872015-09-15 14:06:13 +09001450 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001451 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001452 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001453
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454 priv = wiphy_priv(wiphy);
1455
1456
Alison Schofield3604af52015-10-12 13:22:44 -07001457 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001458 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1459
1460 key_params.key = priv->wilc_gtk[key_index]->key;
1461 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1462 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1463 key_params.seq = priv->wilc_gtk[key_index]->seq;
1464 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1465 if (INFO) {
1466 for (i = 0; i < key_params.key_len; i++)
1467 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1468 }
1469 } else {
1470 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1471
1472 key_params.key = priv->wilc_ptk[key_index]->key;
1473 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1474 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1475 key_params.seq = priv->wilc_ptk[key_index]->seq;
1476 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1477 }
1478
1479 callback(cookie, &key_params);
1480
Leo Kimaaed3292015-10-12 16:55:38 +09001481 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001482}
1483
1484/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001485 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 * @details Set the default management frame key on an interface
1487 * @param[in]
1488 * @return int : Return 0 on Success.
1489 * @author mdaftedar
1490 * @date 01 MAR 2012
1491 * @version 1.0
1492 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001493static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1494 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001495{
Chaehyun Lim27268872015-09-15 14:06:13 +09001496 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001497
1498
1499 priv = wiphy_priv(wiphy);
1500
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301501 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001502
1503 if (key_index != priv->WILC_WFI_wep_default) {
1504
1505 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1506 }
1507
Leo Kimaaed3292015-10-12 16:55:38 +09001508 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509}
1510
1511/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001512 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001513 * @details Get station information for the station identified by @mac
1514 * @param[in] NONE
1515 * @return int : Return 0 on Success.
1516 * @author mdaftedar
1517 * @date 01 MAR 2012
1518 * @version 1.0
1519 */
1520
Chaehyun Limf06f5622015-09-14 12:24:18 +09001521static int get_station(struct wiphy *wiphy, struct net_device *dev,
1522 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001523{
Chaehyun Lim27268872015-09-15 14:06:13 +09001524 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001526 u32 i = 0;
1527 u32 associatedsta = 0;
1528 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001529 priv = wiphy_priv(wiphy);
1530 nic = netdev_priv(dev);
1531
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1533 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1534
1535 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1536
1537 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1538
1539 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1540 associatedsta = i;
1541 break;
1542 }
1543
1544 }
1545
1546 if (associatedsta == -1) {
Leo Kimaaed3292015-10-12 16:55:38 +09001547 PRINT_ER("Station required is not associated\n");
1548 return -ENOENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001549 }
1550
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001552
1553 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1554 sinfo->inactive_time = 1000 * inactive_time;
1555 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1556
1557 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558
1559 if (nic->iftype == STATION_MODE) {
Leo Kim03e7b9c2015-10-12 16:55:58 +09001560 struct rf_info strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001561
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001562 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1563
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001564 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301565 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001566 BIT(NL80211_STA_INFO_TX_PACKETS) |
1567 BIT(NL80211_STA_INFO_TX_FAILED) |
1568 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001569
1570 sinfo->signal = strStatistics.s8RSSI;
1571 sinfo->rx_packets = strStatistics.u32RxCount;
1572 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001573 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001574 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1575
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301576 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001577 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301578 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001579 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001580
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1582 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583 }
Leo Kimaaed3292015-10-12 16:55:38 +09001584 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001585}
1586
1587
1588/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001589 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001590 * @details Modify parameters for a given BSS.
1591 * @param[in]
1592 * -use_cts_prot: Whether to use CTS protection
1593 * (0 = no, 1 = yes, -1 = do not change)
1594 * -use_short_preamble: Whether the use of short preambles is allowed
1595 * (0 = no, 1 = yes, -1 = do not change)
1596 * -use_short_slot_time: Whether the use of short slot time is allowed
1597 * (0 = no, 1 = yes, -1 = do not change)
1598 * -basic_rates: basic rates in IEEE 802.11 format
1599 * (or NULL for no change)
1600 * -basic_rates_len: number of basic rates
1601 * -ap_isolate: do not forward packets between connected stations
1602 * -ht_opmode: HT Operation mode
1603 * (u16 = opmode, -1 = do not change)
1604 * @return int : Return 0 on Success.
1605 * @author mdaftedar
1606 * @date 01 MAR 2012
1607 * @version 1.0
1608 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001609static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1610 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001611{
1612 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1613 return 0;
1614}
1615
1616/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001617 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001618 * @details Notify that wiphy parameters have changed;
1619 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1620 * have changed.
1621 * @return int : Return 0 on Success
1622 * @author mdaftedar
1623 * @date 01 MAR 2012
1624 * @version 1.0
1625 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001626static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001627{
Leo Kime6e12662015-09-16 18:36:03 +09001628 s32 s32Error = 0;
Leo Kim95296502015-10-05 15:25:46 +09001629 struct cfg_param_val pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001630 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001631
1632 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633
Tony Cho87c05b22015-10-12 16:56:07 +09001634 pstrCfgParamVal.flag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301635 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001636
1637 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1638 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1639 priv->dev->ieee80211_ptr->wiphy->retry_short);
Tony Cho87c05b22015-10-12 16:56:07 +09001640 pstrCfgParamVal.flag |= RETRY_SHORT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1642 }
1643 if (changed & WIPHY_PARAM_RETRY_LONG) {
1644
1645 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
Tony Cho87c05b22015-10-12 16:56:07 +09001646 pstrCfgParamVal.flag |= RETRY_LONG;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001647 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1648
1649 }
1650 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1651 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
Tony Cho87c05b22015-10-12 16:56:07 +09001652 pstrCfgParamVal.flag |= FRAG_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001653 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1654
1655 }
1656
1657 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1658 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1659
Tony Cho87c05b22015-10-12 16:56:07 +09001660 pstrCfgParamVal.flag |= RTS_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1662
1663 }
1664
1665 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1666 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1667 if (s32Error)
1668 PRINT_ER("Error in setting WIPHY PARAMS\n");
1669
1670
1671 return s32Error;
1672}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001673
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001674/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001675 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001676 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1677 * devices running firmwares capable of generating the (re) association
1678 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1679 * @param[in]
1680 * @return int : Return 0 on Success
1681 * @author mdaftedar
1682 * @date 01 MAR 2012
1683 * @version 1.0
1684 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001685static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1686 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001688 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001689 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001690 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691
Chaehyun Lim27268872015-09-15 14:06:13 +09001692 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001693
1694 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1695
1696
1697 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001698 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001699 ETH_ALEN)) {
1700 /*If bssid already exists and pmkid value needs to reset*/
1701 flag = PMKID_FOUND;
1702 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1703 break;
1704 }
1705 }
1706 if (i < WILC_MAX_NUM_PMKIDS) {
1707 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001708 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001709 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001710 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001711 PMKID_LEN);
1712 if (!(flag == PMKID_FOUND))
1713 priv->pmkid_list.numpmkid++;
1714 } else {
1715 PRINT_ER("Invalid PMKID index\n");
1716 s32Error = -EINVAL;
1717 }
1718
1719 if (!s32Error) {
1720 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1721 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1722 }
1723 return s32Error;
1724}
1725
1726/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001727 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001728 * @details Delete a cached PMKID.
1729 * @param[in]
1730 * @return int : Return 0 on Success
1731 * @author mdaftedar
1732 * @date 01 MAR 2012
1733 * @version 1.0
1734 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001735static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1736 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001737{
1738
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001739 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001740 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001741
Chaehyun Lim27268872015-09-15 14:06:13 +09001742 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001743
1744 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1745
1746 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001747 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001748 ETH_ALEN)) {
1749 /*If bssid is found, reset the values*/
1750 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Leo Kimcd1e6cb2015-10-05 15:25:45 +09001751 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001752 break;
1753 }
1754 }
1755
1756 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1757 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001758 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001759 priv->pmkid_list.pmkidlist[i + 1].bssid,
1760 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001761 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001762 priv->pmkid_list.pmkidlist[i].pmkid,
1763 PMKID_LEN);
1764 }
1765 priv->pmkid_list.numpmkid--;
1766 } else {
1767 s32Error = -EINVAL;
1768 }
1769
1770 return s32Error;
1771}
1772
1773/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001774 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001775 * @details Flush all cached PMKIDs.
1776 * @param[in]
1777 * @return int : Return 0 on Success
1778 * @author mdaftedar
1779 * @date 01 MAR 2012
1780 * @version 1.0
1781 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001782static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001783{
Chaehyun Lim27268872015-09-15 14:06:13 +09001784 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001785
1786 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1787
1788 /*Get cashed Pmkids and set all with zeros*/
Leo Kima949f902015-10-05 15:25:44 +09001789 memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790
1791 return 0;
1792}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001793
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001794
1795/**
1796 * @brief WILC_WFI_CfgParseRxAction
1797 * @details Function parses the received frames and modifies the following attributes:
1798 * -GO Intent
1799 * -Channel list
1800 * -Operating Channel
1801 *
1802 * @param[in] u8* Buffer, u32 length
1803 * @return NONE.
1804 * @author mdaftedar
1805 * @date 12 DEC 2012
1806 * @version
1807 */
1808
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001809void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001810{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001811 u32 index = 0;
1812 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001813
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001814 u8 op_channel_attr_index = 0;
1815 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816
1817 while (index < len) {
1818 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820 }
1821
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301822 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001823 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301824 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001826 index += buf[index + 1] + 3; /* ID,Length byte */
1827 }
Alison Schofield3604af52015-10-12 13:22:44 -07001828 if (u8WLANChannel != INVALID_CHANNEL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001829
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830 /*Modify channel list attribute*/
1831 if (channel_list_attr_index) {
1832 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1833 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1834 if (buf[i] == 0x51) {
1835 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1836 buf[j] = u8WLANChannel;
1837 }
1838 break;
1839 }
1840 }
1841 }
1842 /*Modify operating channel attribute*/
1843 if (op_channel_attr_index) {
1844 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1845 buf[op_channel_attr_index + 6] = 0x51;
1846 buf[op_channel_attr_index + 7] = u8WLANChannel;
1847 }
1848 }
1849}
1850
1851/**
1852 * @brief WILC_WFI_CfgParseTxAction
1853 * @details Function parses the transmitted action frames and modifies the
1854 * GO Intent attribute
1855 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1856 * @return NONE.
1857 * @author mdaftedar
1858 * @date 12 DEC 2012
1859 * @version
1860 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09001861void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001863 u32 index = 0;
1864 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001865
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001866 u8 op_channel_attr_index = 0;
1867 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868
1869 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001872
1873 break;
1874 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301876 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001877 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301878 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001880 index += buf[index + 1] + 3; /* ID,Length byte */
1881 }
Alison Schofield3604af52015-10-12 13:22:44 -07001882 if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001883
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001884 /*Modify channel list attribute*/
1885 if (channel_list_attr_index) {
1886 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1887 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1888 if (buf[i] == 0x51) {
1889 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1890 buf[j] = u8WLANChannel;
1891 }
1892 break;
1893 }
1894 }
1895 }
1896 /*Modify operating channel attribute*/
1897 if (op_channel_attr_index) {
1898 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1899 buf[op_channel_attr_index + 6] = 0x51;
1900 buf[op_channel_attr_index + 7] = u8WLANChannel;
1901 }
1902 }
1903}
1904
1905/* @brief WILC_WFI_p2p_rx
1906 * @details
1907 * @param[in]
1908 *
1909 * @return None
1910 * @author Mai Daftedar
1911 * @date 2 JUN 2013
1912 * @version 1.0
1913 */
1914
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09001915void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916{
1917
Chaehyun Lim27268872015-09-15 14:06:13 +09001918 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001919 u32 header, pkt_offset;
Leo Kim441dc602015-10-12 16:55:35 +09001920 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001921 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001922 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001923
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001924 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09001925 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001926
1927 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001928 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929
1930 /* The packet offset field conain info about what type of managment frame */
1931 /* we are dealing with and ack status */
1932 pkt_offset = GET_PKT_OFFSET(header);
1933
1934 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
1935 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
1936 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001937 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001938 return;
1939 } else {
1940 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
1941 PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
1942 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001943 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 } else {
1945 PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
1946 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001947 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948 }
1949 return;
1950 }
1951 } else {
1952
1953 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
1954
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001955 /*Upper layer is informed that the frame is received on this freq*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09001956 s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001957
1958 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
1959 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
1960
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01001961 if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001962 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
1963 return;
1964 }
1965 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
1966
1967 switch (buff[ACTION_SUBTYPE_ID]) {
1968 case GAS_INTIAL_REQ:
1969 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
1970 break;
1971
1972 case GAS_INTIAL_RSP:
1973 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
1974 break;
1975
1976 case PUBLIC_ACT_VENDORSPEC:
1977 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
1978 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001979 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001980 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
1981 if (!bWilc_ie) {
1982 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001983 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09001985 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001986 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
1987 break;
1988 }
1989 }
1990 }
1991 }
1992 if (u8P2Plocalrandom > u8P2Precvrandom) {
1993 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
1994 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
1995 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001996 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001997 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
1998 break;
1999 }
2000 }
2001 }
2002 } else
2003 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2004 }
2005
2006
2007 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2008 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2009 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002010 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002011 return;
2012 }
2013 break;
2014
2015 default:
2016 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2017 break;
2018 }
2019 }
2020 }
2021
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002023 }
2024}
2025
2026/**
2027 * @brief WILC_WFI_mgmt_tx_complete
2028 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2029 * @param[in] priv
2030 * transmitting status
2031 * @return None
2032 * @author Amr Abdelmoghny
2033 * @date 20 MAY 2013
2034 * @version 1.0
2035 */
2036static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2037{
2038 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2039
2040
2041 kfree(pv_data->buff);
2042 kfree(pv_data);
2043}
2044
2045/**
2046 * @brief WILC_WFI_RemainOnChannelReady
2047 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2048 * @param
2049 * @return none
2050 * @author Amr abdelmoghny
2051 * @date 9 JUNE 2013
2052 * @version
2053 */
2054
2055static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2056{
Chaehyun Lim27268872015-09-15 14:06:13 +09002057 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002058
Chaehyun Lim27268872015-09-15 14:06:13 +09002059 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002060
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302061 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062
Dean Lee72ed4dc2015-06-12 14:11:44 +09002063 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002064
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002065 cfg80211_ready_on_channel(priv->wdev,
2066 priv->strRemainOnChanParams.u64ListenCookie,
2067 priv->strRemainOnChanParams.pstrListenChan,
2068 priv->strRemainOnChanParams.u32ListenDuration,
2069 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002070}
2071
2072/**
2073 * @brief WILC_WFI_RemainOnChannelExpired
2074 * @details Callback function, called on expiration of remain-on-channel duration
2075 * @param
2076 * @return none
2077 * @author Amr abdelmoghny
2078 * @date 15 MAY 2013
2079 * @version
2080 */
2081
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002082static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083{
Chaehyun Lim27268872015-09-15 14:06:13 +09002084 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002085
Chaehyun Lim27268872015-09-15 14:06:13 +09002086 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002087
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302089 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002090
Dean Lee72ed4dc2015-06-12 14:11:44 +09002091 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002092
2093 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002094 cfg80211_remain_on_channel_expired(priv->wdev,
2095 priv->strRemainOnChanParams.u64ListenCookie,
2096 priv->strRemainOnChanParams.pstrListenChan,
2097 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002098 } else {
2099 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2100 , priv->strRemainOnChanParams.u32ListenSessionID);
2101 }
2102}
2103
2104
2105/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002106 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002107 * @details Request the driver to remain awake on the specified
2108 * channel for the specified duration to complete an off-channel
2109 * operation (e.g., public action frame exchange). When the driver is
2110 * ready on the requested channel, it must indicate this with an event
2111 * notification by calling cfg80211_ready_on_channel().
2112 * @param[in]
2113 * @return int : Return 0 on Success
2114 * @author mdaftedar
2115 * @date 01 MAR 2012
2116 * @version 1.0
2117 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002118static int remain_on_channel(struct wiphy *wiphy,
2119 struct wireless_dev *wdev,
2120 struct ieee80211_channel *chan,
2121 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122{
Leo Kime6e12662015-09-16 18:36:03 +09002123 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002124 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002125
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002126 priv = wiphy_priv(wiphy);
2127
2128 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2129
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002130
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131 if (wdev->iftype == NL80211_IFTYPE_AP) {
2132 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2133 return s32Error;
2134 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002135
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002136 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002137
2138 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2139 priv->strRemainOnChanParams.pstrListenChan = chan;
2140 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002141 priv->strRemainOnChanParams.u32ListenDuration = duration;
2142 priv->strRemainOnChanParams.u32ListenSessionID++;
2143
2144 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2145 , priv->strRemainOnChanParams.u32ListenSessionID
2146 , duration
2147 , chan->hw_value
2148 , WILC_WFI_RemainOnChannelExpired
2149 , WILC_WFI_RemainOnChannelReady
2150 , (void *)priv);
2151
2152 return s32Error;
2153}
2154
2155/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002156 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002157 * @details Cancel an on-going remain-on-channel operation.
2158 * This allows the operation to be terminated prior to timeout based on
2159 * the duration value.
2160 * @param[in] struct wiphy *wiphy,
2161 * @param[in] struct net_device *dev
2162 * @param[in] u64 cookie,
2163 * @return int : Return 0 on Success
2164 * @author mdaftedar
2165 * @date 01 MAR 2012
2166 * @version 1.0
2167 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002168static int cancel_remain_on_channel(struct wiphy *wiphy,
2169 struct wireless_dev *wdev,
2170 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171{
Leo Kime6e12662015-09-16 18:36:03 +09002172 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002173 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002174
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002175 priv = wiphy_priv(wiphy);
2176
2177 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2178
2179 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2180 return s32Error;
2181}
2182/**
2183 * @brief WILC_WFI_add_wilcvendorspec
2184 * @details Adding WILC information elemet to allow two WILC devices to
2185 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002186 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002187 * @return void
2188 * @author mdaftedar
2189 * @date 01 JAN 2014
2190 * @version 1.0
2191 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002192void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002193{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002194 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195}
2196/**
2197 * @brief WILC_WFI_mgmt_tx_frame
2198 * @details
2199 *
2200 * @param[in]
2201 * @return NONE.
2202 * @author mdaftedar
2203 * @date 01 JUL 2012
2204 * @version
2205 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002206extern bool bEnablePS;
Chaehyun Limc1560322015-09-22 18:34:51 +09002207static int mgmt_tx(struct wiphy *wiphy,
2208 struct wireless_dev *wdev,
2209 struct cfg80211_mgmt_tx_params *params,
2210 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002212 struct ieee80211_channel *chan = params->chan;
2213 unsigned int wait = params->wait;
2214 const u8 *buf = params->buf;
2215 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002216 const struct ieee80211_mgmt *mgmt;
2217 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002218 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002219 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002220 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002222 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002226 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002227
2228 *cookie = (unsigned long)buf;
2229 priv->u64tx_cookie = *cookie;
2230 mgmt = (const struct ieee80211_mgmt *) buf;
2231
2232 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2233
2234 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002235 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236 if (mgmt_tx == NULL) {
2237 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
Leo Kime6e12662015-09-16 18:36:03 +09002238 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002239 }
Glen Leef3052582015-09-10 12:03:04 +09002240 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002241 if (mgmt_tx->buff == NULL) {
2242 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002243 kfree(mgmt_tx);
Leo Kime6e12662015-09-16 18:36:03 +09002244 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002245 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002246 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002247 mgmt_tx->size = len;
2248
2249
2250 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2251 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2252 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2253 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2254 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002255 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002256 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002257 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002258
2259
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002260 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261 /*Only set the channel, if not a negotiation confirmation frame
2262 * (If Negotiation confirmation frame, force it
2263 * to be transmitted on the same negotiation channel)*/
2264
2265 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2266 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2267 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2268 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2269 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002270 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002271 }
2272 switch (buf[ACTION_SUBTYPE_ID]) {
2273 case GAS_INTIAL_REQ:
2274 {
2275 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2276 break;
2277 }
2278
2279 case GAS_INTIAL_RSP:
2280 {
2281 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2282 break;
2283 }
2284
2285 case PUBLIC_ACT_VENDORSPEC:
2286 {
2287 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2288 * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002289 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002290 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2291 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2292 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2293 get_random_bytes(&u8P2Plocalrandom, 1);
2294 /*Increment the number to prevent if its 0*/
2295 u8P2Plocalrandom++;
2296 }
2297 }
2298
2299 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2300 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2301 if (u8P2Plocalrandom > u8P2Precvrandom) {
2302 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2303
2304 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2305 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002306 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002307 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002308 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310 /*If using supplicant go intent, no need at all*/
2311 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002312 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002313 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002314 break;
2315 }
2316 }
2317
2318 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2319 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2320 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2321 mgmt_tx->size = buf_len;
2322 }
2323 } else
2324 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2325 }
2326
2327 } else {
2328 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2329 }
2330
2331 break;
2332 }
2333
2334 default:
2335 {
2336 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2337 break;
2338 }
2339 }
2340
2341 }
2342
2343 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2344 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2345
2346 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2347
2348 }
2349
Glen Leec9d48342015-10-01 16:03:43 +09002350 wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff,
2351 mgmt_tx->size,
2352 WILC_WFI_mgmt_tx_complete);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002353 } else {
2354 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2355 }
Leo Kimaaed3292015-10-12 16:55:38 +09002356 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357}
2358
Chaehyun Lim85c587a2015-09-22 18:34:50 +09002359static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2360 struct wireless_dev *wdev,
2361 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002362{
Chaehyun Lim27268872015-09-15 14:06:13 +09002363 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002364 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002365
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002366 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002367 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368
2369
2370 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2371 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2372
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01002373 if (!priv->bInP2PlistenState) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002374 cfg80211_remain_on_channel_expired(priv->wdev,
2375 priv->strRemainOnChanParams.u64ListenCookie,
2376 priv->strRemainOnChanParams.pstrListenChan,
2377 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378 }
2379
2380 return 0;
2381}
2382
2383/**
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002384 * @brief wilc_mgmt_frame_register
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002385 * @details Notify driver that a management frame type was
2386 * registered. Note that this callback may not sleep, and cannot run
2387 * concurrently with itself.
2388 * @param[in]
2389 * @return NONE.
2390 * @author mdaftedar
2391 * @date 01 JUL 2012
2392 * @version
2393 */
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002394void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
2395 u16 frame_type, bool reg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002396{
2397
Chaehyun Lim27268872015-09-15 14:06:13 +09002398 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399 perInterface_wlan_t *nic;
Glen Lee1b869352015-10-20 17:14:01 +09002400 struct wilc *wl;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002401
2402 priv = wiphy_priv(wiphy);
2403 nic = netdev_priv(priv->wdev->netdev);
Glen Lee1b869352015-10-20 17:14:01 +09002404 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002406 if (!frame_type)
2407 return;
2408
2409 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2410 switch (frame_type) {
2411 case PROBE_REQ:
2412 {
2413 nic->g_struct_frame_reg[0].frame_type = frame_type;
2414 nic->g_struct_frame_reg[0].reg = reg;
2415 }
2416 break;
2417
2418 case ACTION:
2419 {
2420 nic->g_struct_frame_reg[1].frame_type = frame_type;
2421 nic->g_struct_frame_reg[1].reg = reg;
2422 }
2423 break;
2424
2425 default:
2426 {
2427 break;
2428 }
2429
2430 }
2431 /*If mac is closed, then return*/
Glen Lee1b869352015-10-20 17:14:01 +09002432 if (!wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002433 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2434 return;
2435 }
2436 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2437
2438
2439}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440
2441/**
Chaehyun Lima8047e22015-09-22 18:34:48 +09002442 * @brief set_cqm_rssi_config
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002443 * @details Configure connection quality monitor RSSI threshold.
2444 * @param[in] struct wiphy *wiphy:
2445 * @param[in] struct net_device *dev:
2446 * @param[in] s32 rssi_thold:
2447 * @param[in] u32 rssi_hyst:
2448 * @return int : Return 0 on Success
2449 * @author mdaftedar
2450 * @date 01 MAR 2012
2451 * @version 1.0
2452 */
Chaehyun Lima8047e22015-09-22 18:34:48 +09002453static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
2454 s32 rssi_thold, u32 rssi_hyst)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455{
2456 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2457 return 0;
2458
2459}
2460/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002461 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002462 * @details Configure connection quality monitor RSSI threshold.
2463 * @param[in] struct wiphy *wiphy:
2464 * @param[in] struct net_device *dev
2465 * @param[in] int idx
2466 * @param[in] u8 *mac
2467 * @param[in] struct station_info *sinfo
2468 * @return int : Return 0 on Success
2469 * @author mdaftedar
2470 * @date 01 MAR 2012
2471 * @version 1.0
2472 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002473static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2474 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475{
Chaehyun Lim27268872015-09-15 14:06:13 +09002476 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2479
2480 if (idx != 0)
2481 return -ENOENT;
2482
2483 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486
2487 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2488
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002489 return 0;
2490
2491}
2492
2493
2494/**
Chaehyun Lim46530672015-09-22 18:34:46 +09002495 * @brief set_power_mgmt
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496 * @details
2497 * @param[in]
2498 * @return int : Return 0 on Success.
2499 * @author mdaftedar
2500 * @date 01 JUL 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09002501 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002502 */
Chaehyun Lim46530672015-09-22 18:34:46 +09002503static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2504 bool enabled, int timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505{
Chaehyun Lim27268872015-09-15 14:06:13 +09002506 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002507
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2509
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002510 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002511 return -ENOENT;
2512
2513 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002514 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002515 PRINT_ER("Driver is NULL\n");
2516 return -EIO;
2517 }
2518
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002519 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002520 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2521
2522
Leo Kime6e12662015-09-16 18:36:03 +09002523 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002524
2525}
Glen Lee108b3432015-09-16 18:53:20 +09002526
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002527/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002528 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 * @details Change type/configuration of virtual interface,
2530 * keep the struct wireless_dev's iftype updated.
2531 * @param[in] NONE
2532 * @return int : Return 0 on Success.
2533 * @author mdaftedar
2534 * @date 01 MAR 2012
2535 * @version 1.0
2536 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2538
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002539static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2540 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541{
Chaehyun Lim27268872015-09-15 14:06:13 +09002542 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002543 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002544 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002545 u16 TID = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002546 u8 i;
Glen Lee299382c2015-10-20 17:13:56 +09002547 struct wilc *wl;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002548
2549 nic = netdev_priv(dev);
2550 priv = wiphy_priv(wiphy);
Glen Lee299382c2015-10-20 17:13:56 +09002551 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002552
2553 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2554 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2555 u8P2Plocalrandom = 0x01;
2556 u8P2Precvrandom = 0x00;
2557
Dean Lee72ed4dc2015-06-12 14:11:44 +09002558 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002559
Dean Lee72ed4dc2015-06-12 14:11:44 +09002560 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002561 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002562 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2564 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002565 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002566 }
2567
2568 switch (type) {
2569 case NL80211_IFTYPE_STATION:
2570 connecting = 0;
2571 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
2573 /* send delba over wlan interface */
2574
2575
2576 dev->ieee80211_ptr->iftype = type;
2577 priv->wdev->iftype = type;
2578 nic->monitor_flag = 0;
2579 nic->iftype = STATION_MODE;
2580
2581 /*Remove the enteries of the previously connected clients*/
2582 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583 interface_type = nic->iftype;
2584 nic->iftype = STATION_MODE;
2585
Glen Lee299382c2015-10-20 17:13:56 +09002586 if (wl->initialized) {
2587 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2588 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589 /* ensure that the message Q is empty */
2590 host_int_wait_msg_queue_idle();
2591
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592 /*Eliminate host interface blocking state*/
Glen Lee299382c2015-10-20 17:13:56 +09002593 up(&wl->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002594
Glen Lee53dc0cf2015-10-20 17:13:57 +09002595 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 wilc1000_wlan_init(dev, nic);
2597 g_wilc_initialized = 1;
2598 nic->iftype = interface_type;
2599
2600 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002601 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2602 host_int_set_MacAddress(wl->vif[0].hif_drv,
2603 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002604 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2605
2606 /*Add saved WEP keys, if any*/
2607 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002608 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002609 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002610 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002611 g_key_wep_params.key,
2612 g_key_wep_params.key_len,
2613 g_key_wep_params.key_idx);
2614 }
2615
2616 /*No matter the driver handler passed here, it will be overwriiten*/
2617 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2618 host_int_flush_join_req(priv->hWILCWFIDrv);
2619
2620 /*Add saved PTK and GTK keys, if any*/
2621 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2622 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2623 g_key_ptk_params.key[1],
2624 g_key_ptk_params.key[2]);
2625 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2626 g_key_gtk_params.key[1],
2627 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002628 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2629 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002630 g_add_ptk_key_params.key_idx,
2631 g_add_ptk_key_params.pairwise,
2632 g_add_ptk_key_params.mac_addr,
2633 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002634
Glen Lee299382c2015-10-20 17:13:56 +09002635 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2636 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002637 g_add_gtk_key_params.key_idx,
2638 g_add_gtk_key_params.pairwise,
2639 g_add_gtk_key_params.mac_addr,
2640 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002641 }
2642
Glen Lee299382c2015-10-20 17:13:56 +09002643 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002644 for (i = 0; i < num_reg_frame; i++) {
2645 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2646 nic->g_struct_frame_reg[i].reg);
2647 host_int_frame_register(priv->hWILCWFIDrv,
2648 nic->g_struct_frame_reg[i].frame_type,
2649 nic->g_struct_frame_reg[i].reg);
2650 }
2651 }
2652
Dean Lee72ed4dc2015-06-12 14:11:44 +09002653 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002654 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2655 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656 break;
2657
2658 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002659 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002660 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2661 connecting = 0;
2662 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663
Glen Lee299382c2015-10-20 17:13:56 +09002664 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2665 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002666
2667 dev->ieee80211_ptr->iftype = type;
2668 priv->wdev->iftype = type;
2669 nic->monitor_flag = 0;
2670
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002671 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2672 nic->iftype = CLIENT_MODE;
2673
2674
Glen Lee299382c2015-10-20 17:13:56 +09002675 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002676 /* ensure that the message Q is empty */
2677 host_int_wait_msg_queue_idle();
2678
Glen Lee53dc0cf2015-10-20 17:13:57 +09002679 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680 wilc1000_wlan_init(dev, nic);
2681 g_wilc_initialized = 1;
2682
Glen Lee299382c2015-10-20 17:13:56 +09002683 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2684 host_int_set_MacAddress(wl->vif[0].hif_drv,
2685 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002686 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2687
2688 /*Add saved WEP keys, if any*/
2689 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002690 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002691 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002692 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002693 g_key_wep_params.key,
2694 g_key_wep_params.key_len,
2695 g_key_wep_params.key_idx);
2696 }
2697
2698 /*No matter the driver handler passed here, it will be overwriiten*/
2699 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2700 host_int_flush_join_req(priv->hWILCWFIDrv);
2701
2702 /*Add saved PTK and GTK keys, if any*/
2703 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2704 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2705 g_key_ptk_params.key[1],
2706 g_key_ptk_params.key[2]);
2707 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2708 g_key_gtk_params.key[1],
2709 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002710 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2711 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002712 g_add_ptk_key_params.key_idx,
2713 g_add_ptk_key_params.pairwise,
2714 g_add_ptk_key_params.mac_addr,
2715 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002716
Glen Lee299382c2015-10-20 17:13:56 +09002717 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2718 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002719 g_add_gtk_key_params.key_idx,
2720 g_add_gtk_key_params.pairwise,
2721 g_add_gtk_key_params.mac_addr,
2722 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002723 }
2724
2725 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09002726 refresh_scan(priv, 1, true);
2727 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002728
Glen Lee299382c2015-10-20 17:13:56 +09002729 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002730 for (i = 0; i < num_reg_frame; i++) {
2731 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2732 nic->g_struct_frame_reg[i].reg);
2733 host_int_frame_register(priv->hWILCWFIDrv,
2734 nic->g_struct_frame_reg[i].frame_type,
2735 nic->g_struct_frame_reg[i].reg);
2736 }
2737 }
2738 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739 break;
2740
2741 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002742 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002743 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002744 dev->ieee80211_ptr->iftype = type;
2745 priv->wdev->iftype = type;
2746 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002747 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002749 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2750 linux_wlan_get_firmware(nic);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
Glen Lee299382c2015-10-20 17:13:56 +09002752 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 nic->iftype = AP_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002754 mac_close(dev);
2755 mac_open(dev);
2756
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002757 for (i = 0; i < num_reg_frame; i++) {
2758 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2759 nic->g_struct_frame_reg[i].reg);
2760 host_int_frame_register(priv->hWILCWFIDrv,
2761 nic->g_struct_frame_reg[i].frame_type,
2762 nic->g_struct_frame_reg[i].reg);
2763 }
2764 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002765 break;
2766
2767 case NL80211_IFTYPE_P2P_GO:
2768 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2769
Dean Lee72ed4dc2015-06-12 14:11:44 +09002770 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002771 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773 /*Delete block ack has to be the latest config packet*/
2774 /*sent before downloading new FW. This is because it blocks on*/
2775 /*hWaitResponse semaphore, which allows previous config*/
2776 /*packets to actually take action on old FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002777 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2778 wl->vif[0].bssid, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002779 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002781 dev->ieee80211_ptr->iftype = type;
2782 priv->wdev->iftype = type;
2783
Johnny Kim8a143302015-06-10 17:06:46 +09002784 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2787
2788
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789 nic->iftype = GO_MODE;
2790
2791 /* ensure that the message Q is empty */
2792 host_int_wait_msg_queue_idle();
Glen Lee53dc0cf2015-10-20 17:13:57 +09002793 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002794 wilc1000_wlan_init(dev, nic);
2795 g_wilc_initialized = 1;
2796
2797
2798 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002799 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2800 host_int_set_MacAddress(wl->vif[0].hif_drv,
2801 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
2803
2804 /*Add saved WEP keys, if any*/
2805 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002806 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002808 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 g_key_wep_params.key,
2810 g_key_wep_params.key_len,
2811 g_key_wep_params.key_idx);
2812 }
2813
2814 /*No matter the driver handler passed here, it will be overwriiten*/
2815 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2816 host_int_flush_join_req(priv->hWILCWFIDrv);
2817
2818 /*Add saved PTK and GTK keys, if any*/
2819 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2820 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
2821 g_key_ptk_params.key[1],
2822 g_key_ptk_params.key[2],
2823 g_key_ptk_params.cipher);
2824 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
2825 g_key_gtk_params.key[1],
2826 g_key_gtk_params.key[2],
2827 g_key_gtk_params.cipher);
Glen Lee299382c2015-10-20 17:13:56 +09002828 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2829 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002830 g_add_ptk_key_params.key_idx,
2831 g_add_ptk_key_params.pairwise,
2832 g_add_ptk_key_params.mac_addr,
2833 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834
Glen Lee299382c2015-10-20 17:13:56 +09002835 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2836 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002837 g_add_gtk_key_params.key_idx,
2838 g_add_gtk_key_params.pairwise,
2839 g_add_gtk_key_params.mac_addr,
2840 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842
Glen Lee299382c2015-10-20 17:13:56 +09002843 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844 for (i = 0; i < num_reg_frame; i++) {
2845 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2846 nic->g_struct_frame_reg[i].reg);
2847 host_int_frame_register(priv->hWILCWFIDrv,
2848 nic->g_struct_frame_reg[i].frame_type,
2849 nic->g_struct_frame_reg[i].reg);
2850 }
2851 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852 break;
2853
2854 default:
2855 PRINT_ER("Unknown interface type= %d\n", type);
Leo Kimaaed3292015-10-12 16:55:38 +09002856 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002857 }
2858
Leo Kimaaed3292015-10-12 16:55:38 +09002859 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860}
2861
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002862/* (austin.2013-07-23)
2863 *
2864 * To support revised cfg80211_ops
2865 *
2866 * add_beacon --> start_ap
2867 * set_beacon --> change_beacon
2868 * del_beacon --> stop_ap
2869 *
2870 * beacon_parameters --> cfg80211_ap_settings
2871 * cfg80211_beacon_data
2872 *
2873 * applicable for linux kernel 3.4+
2874 */
2875
2876/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09002877 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002878 * @details Add a beacon with given parameters, @head, @interval
2879 * and @dtim_period will be valid, @tail is optional.
2880 * @param[in] wiphy
2881 * @param[in] dev The net device structure
2882 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2883 * @return int : Return 0 on Success.
2884 * @author austin
2885 * @date 23 JUL 2013
2886 * @version 1.0
2887 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09002888static int start_ap(struct wiphy *wiphy, struct net_device *dev,
2889 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890{
2891 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09002892 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002893 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002894
2895 priv = wiphy_priv(wiphy);
2896 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
2897
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302898 PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
2900
Chaehyun Lim80785a92015-09-14 12:24:01 +09002901 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002902
Leo Kime6e12662015-09-16 18:36:03 +09002903 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002905
Tony Cho7e7fa472015-10-20 14:26:48 +09002906 linux_wlan_set_bssid(dev, g_linux_wlan->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002908 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2909 settings->beacon_interval,
2910 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002911 beacon->head_len, (u8 *)beacon->head,
2912 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002913
2914 return s32Error;
2915}
2916
2917/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002918 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919 * @details Add a beacon with given parameters, @head, @interval
2920 * and @dtim_period will be valid, @tail is optional.
2921 * @param[in] wiphy
2922 * @param[in] dev The net device structure
2923 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2924 * @return int : Return 0 on Success.
2925 * @author austin
2926 * @date 23 JUL 2013
2927 * @version 1.0
2928 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002929static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
2930 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931{
Chaehyun Lim27268872015-09-15 14:06:13 +09002932 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002933 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934
2935 priv = wiphy_priv(wiphy);
2936 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
2937
2938
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2940 0,
2941 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002942 beacon->head_len, (u8 *)beacon->head,
2943 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002944
2945 return s32Error;
2946}
2947
2948/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002949 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 * @details Remove beacon configuration and stop sending the beacon.
2951 * @param[in]
2952 * @return int : Return 0 on Success.
2953 * @author austin
2954 * @date 23 JUL 2013
2955 * @version 1.0
2956 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002957static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002958{
Leo Kime6e12662015-09-16 18:36:03 +09002959 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002960 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002961 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002962
Leo Kim7ae43362015-09-16 18:35:59 +09002963 if (!wiphy)
2964 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965
2966 priv = wiphy_priv(wiphy);
2967
2968 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
2969
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002970 linux_wlan_set_bssid(dev, NullBssid);
2971
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002972 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973
Leo Kim7dc1d0c2015-09-16 18:36:00 +09002974 if (s32Error)
2975 PRINT_ER("Host delete beacon fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002976
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 return s32Error;
2978}
2979
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002980/**
Chaehyun Limed269552015-09-14 12:24:15 +09002981 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002982 * @details Add a new station.
2983 * @param[in]
2984 * @return int : Return 0 on Success.
2985 * @author mdaftedar
2986 * @date 01 MAR 2012
2987 * @version 1.0
2988 */
Chaehyun Limed269552015-09-14 12:24:15 +09002989static int add_station(struct wiphy *wiphy, struct net_device *dev,
2990 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991{
Leo Kime6e12662015-09-16 18:36:03 +09002992 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002993 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09002994 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002995 perInterface_wlan_t *nic;
2996
Leo Kim7ae43362015-09-16 18:35:59 +09002997 if (!wiphy)
2998 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999
3000 priv = wiphy_priv(wiphy);
3001 nic = netdev_priv(dev);
3002
3003 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003004 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3005 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003006 strStaParams.u16AssocID = params->aid;
3007 strStaParams.u8NumRates = params->supported_rates_len;
3008 strStaParams.pu8Rates = params->supported_rates;
3009
3010 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3011
3012 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4],
3013 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3014 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3015 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3016
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003017 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003018 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003020 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003021 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3022 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003023 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3025 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3026 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3027 }
3028
3029 strStaParams.u16FlagsMask = params->sta_flags_mask;
3030 strStaParams.u16FlagsSet = params->sta_flags_set;
3031
3032 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3033 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3034 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3035 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3036 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3037 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3038 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3039 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3040
3041 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003042 if (s32Error)
3043 PRINT_ER("Host add station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003044 }
3045
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003046 return s32Error;
3047}
3048
3049/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003050 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003051 * @details Remove a station; @mac may be NULL to remove all stations.
3052 * @param[in]
3053 * @return int : Return 0 on Success.
3054 * @author mdaftedar
3055 * @date 01 MAR 2012
3056 * @version 1.0
3057 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003058static int del_station(struct wiphy *wiphy, struct net_device *dev,
3059 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003060{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003061 const u8 *mac = params->mac;
Leo Kime6e12662015-09-16 18:36:03 +09003062 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003063 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003064 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003065
Leo Kim7ae43362015-09-16 18:35:59 +09003066 if (!wiphy)
3067 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068
3069 priv = wiphy_priv(wiphy);
3070 nic = netdev_priv(dev);
3071
3072 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3073 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3074
3075
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003076 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303077 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003078 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3079 } else {
3080 PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
3081 }
3082
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003085 if (s32Error)
3086 PRINT_ER("Host delete station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003087 }
3088 return s32Error;
3089}
3090
3091/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003092 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003093 * @details Modify a given station.
3094 * @param[in]
3095 * @return int : Return 0 on Success.
3096 * @author mdaftedar
3097 * @date 01 MAR 2012
3098 * @version 1.0
3099 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003100static int change_station(struct wiphy *wiphy, struct net_device *dev,
3101 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102{
Leo Kime6e12662015-09-16 18:36:03 +09003103 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003104 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09003105 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106 perInterface_wlan_t *nic;
3107
3108
3109 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3110
Leo Kim7ae43362015-09-16 18:35:59 +09003111 if (!wiphy)
3112 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003113
3114 priv = wiphy_priv(wiphy);
3115 nic = netdev_priv(dev);
3116
3117 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003118 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003119 strStaParams.u16AssocID = params->aid;
3120 strStaParams.u8NumRates = params->supported_rates_len;
3121 strStaParams.pu8Rates = params->supported_rates;
3122
3123 PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4],
3124 strStaParams.au8BSSID[5]);
3125 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3126 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3127
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003128 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003129 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003130 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003131 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003132 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3133 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003134 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003135 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3136 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3137 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3138
3139 }
3140
3141 strStaParams.u16FlagsMask = params->sta_flags_mask;
3142 strStaParams.u16FlagsSet = params->sta_flags_set;
3143
3144 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3145 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3146 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3147 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3148 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3149 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3150 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3151 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3152
3153 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003154 if (s32Error)
3155 PRINT_ER("Host edit station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003156 }
3157 return s32Error;
3158}
3159
3160
3161/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003162 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163 * @details
3164 * @param[in]
3165 * @return int : Return 0 on Success.
3166 * @author mdaftedar
3167 * @date 01 JUL 2012
3168 * @version 1.0
3169 */
Chaehyun Lim37316e82015-09-22 18:34:52 +09003170static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
3171 const char *name,
3172 unsigned char name_assign_type,
3173 enum nl80211_iftype type,
3174 u32 *flags,
3175 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176{
3177 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003178 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003179 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003180
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003181 priv = wiphy_priv(wiphy);
3182
3183
3184
3185 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3186
3187 nic = netdev_priv(priv->wdev->netdev);
3188
3189
3190 if (type == NL80211_IFTYPE_MONITOR) {
3191 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3192 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3193 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3194 if (new_ifc != NULL) {
3195 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003196 nic = netdev_priv(priv->wdev->netdev);
3197 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003198 } else
3199 PRINT_ER("Error in initializing monitor interface\n ");
3200 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003202}
3203
3204/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003205 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003206 * @details
3207 * @param[in]
3208 * @return int : Return 0 on Success.
3209 * @author mdaftedar
3210 * @date 01 JUL 2012
3211 * @version 1.0
3212 */
Chaehyun Lim956d7212015-09-22 18:34:49 +09003213static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214{
3215 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
Leo Kime6e12662015-09-16 18:36:03 +09003216 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217}
3218
Chaehyun Lim08241922015-09-15 14:06:12 +09003219static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003220
Chaehyun Lim80785a92015-09-14 12:24:01 +09003221 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003222 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003223 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003224 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003225 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003226 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003227 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003228 .set_default_key = set_default_key,
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003229 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003230 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003231 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003232
Chaehyun Lima13168d2015-09-14 12:24:12 +09003233 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003234 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003235 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003236 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003237 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003238 .change_station = change_station,
Chaehyun Limf06f5622015-09-14 12:24:18 +09003239 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003240 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003241 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003242 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003243
Chaehyun Lim4d466572015-09-14 12:24:22 +09003244 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003245 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003246 .flush_pmksa = flush_pmksa,
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003247 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003248 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003249 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003250 .mgmt_tx = mgmt_tx,
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09003251 .mgmt_frame_register = wilc_mgmt_frame_register,
Chaehyun Lim46530672015-09-22 18:34:46 +09003252 .set_power_mgmt = set_power_mgmt,
Chaehyun Lima8047e22015-09-22 18:34:48 +09003253 .set_cqm_rssi_config = set_cqm_rssi_config,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003254
3255};
3256
3257
3258
3259
3260
3261/**
3262 * @brief WILC_WFI_update_stats
3263 * @details Modify parameters for a given BSS.
3264 * @param[in]
3265 * @return int : Return 0 on Success.
3266 * @author mdaftedar
3267 * @date 01 MAR 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003268 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269 */
3270int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3271{
3272
Chaehyun Lim27268872015-09-15 14:06:13 +09003273 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003274
3275 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276 switch (changed) {
3277
3278 case WILC_WFI_RX_PKT:
3279 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003280 priv->netstats.rx_packets++;
3281 priv->netstats.rx_bytes += pktlen;
3282 priv->netstats.rx_time = get_jiffies_64();
3283 }
3284 break;
3285
3286 case WILC_WFI_TX_PKT:
3287 {
3288 priv->netstats.tx_packets++;
3289 priv->netstats.tx_bytes += pktlen;
3290 priv->netstats.tx_time = get_jiffies_64();
3291
3292 }
3293 break;
3294
3295 default:
3296 break;
3297 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003298 return 0;
3299}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003300
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301/**
3302 * @brief WILC_WFI_CfgAlloc
3303 * @details Allocation of the wireless device structure and assigning it
3304 * to the cfg80211 operations structure.
3305 * @param[in] NONE
3306 * @return wireless_dev : Returns pointer to wireless_dev structure.
3307 * @author mdaftedar
3308 * @date 01 MAR 2012
3309 * @version 1.0
3310 */
3311struct wireless_dev *WILC_WFI_CfgAlloc(void)
3312{
3313
3314 struct wireless_dev *wdev;
3315
3316
3317 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3318 /*Allocating the wireless device structure*/
3319 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3320 if (!wdev) {
3321 PRINT_ER("Cannot allocate wireless device\n");
3322 goto _fail_;
3323 }
3324
3325 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003326 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003327 if (!wdev->wiphy) {
3328 PRINT_ER("Cannot allocate wiphy\n");
3329 goto _fail_mem_;
3330
3331 }
3332
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003333 /* enable 802.11n HT */
3334 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3335 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3336 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3337 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3338 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003339
3340 /*wiphy bands*/
3341 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3342
3343 return wdev;
3344
3345_fail_mem_:
3346 kfree(wdev);
3347_fail_:
3348 return NULL;
3349
3350}
3351/**
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003352 * @brief wilc_create_wiphy
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003353 * @details Registering of the wiphy structure and interface modes
3354 * @param[in] NONE
3355 * @return NONE
3356 * @author mdaftedar
3357 * @date 01 MAR 2012
3358 * @version 1.0
3359 */
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003360struct wireless_dev *wilc_create_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003361{
Chaehyun Lim27268872015-09-15 14:06:13 +09003362 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003363 struct wireless_dev *wdev;
Leo Kime6e12662015-09-16 18:36:03 +09003364 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003365
3366 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3367
3368 wdev = WILC_WFI_CfgAlloc();
3369 if (wdev == NULL) {
3370 PRINT_ER("CfgAlloc Failed\n");
3371 return NULL;
3372 }
3373
3374
3375 /*Return hardware description structure (wiphy)'s priv*/
3376 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003377 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003378
3379 /*Link the wiphy with wireless structure*/
3380 priv->wdev = wdev;
3381
3382 /*Maximum number of probed ssid to be added by user for the scan request*/
3383 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384 /*Maximum number of pmkids to be cashed*/
3385 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3386 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387
3388 wdev->wiphy->max_scan_ie_len = 1000;
3389
3390 /*signal strength in mBm (100*dBm) */
3391 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3392
3393 /*Set the availaible cipher suites*/
3394 wdev->wiphy->cipher_suites = cipher_suites;
3395 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396 /*Setting default managment types: for register action frame: */
3397 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003398
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 wdev->wiphy->max_remain_on_channel_duration = 500;
3400 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3401 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3402 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003404 wdev->iftype = NL80211_IFTYPE_STATION;
3405
3406
3407
3408 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3409 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3410 wdev->wiphy->interface_modes, wdev->iftype);
3411
3412 #ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003413 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 #endif
3415
3416 /*Register wiphy structure*/
3417 s32Error = wiphy_register(wdev->wiphy);
3418 if (s32Error) {
3419 PRINT_ER("Cannot register wiphy device\n");
3420 /*should define what action to be taken in such failure*/
3421 } else {
3422 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3423 }
3424
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003425 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003426 return wdev;
3427
3428
3429}
3430/**
3431 * @brief WILC_WFI_WiphyFree
3432 * @details Freeing allocation of the wireless device structure
3433 * @param[in] NONE
3434 * @return NONE
3435 * @author mdaftedar
3436 * @date 01 MAR 2012
3437 * @version 1.0
3438 */
Chaehyun Limdd4b6a82015-09-20 15:51:25 +09003439int wilc_init_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440{
3441
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003442 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443
Chaehyun Lim27268872015-09-15 14:06:13 +09003444 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003445
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003446 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3447 priv = wdev_priv(net->ieee80211_ptr);
3448 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003449 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003450 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451 }
3452 op_ifcs++;
3453 if (s32Error < 0) {
3454 PRINT_ER("Failed to creat refresh Timer\n");
3455 return s32Error;
3456 }
3457
Dean Lee72ed4dc2015-06-12 14:11:44 +09003458 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003459
Dean Lee72ed4dc2015-06-12 14:11:44 +09003460 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003462 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003463 s32Error = host_int_init(&priv->hWILCWFIDrv);
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003464 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465 PRINT_ER("Error while initializing hostinterface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003466
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003467 return s32Error;
3468}
3469
3470/**
3471 * @brief WILC_WFI_WiphyFree
3472 * @details Freeing allocation of the wireless device structure
3473 * @param[in] NONE
3474 * @return NONE
3475 * @author mdaftedar
3476 * @date 01 MAR 2012
3477 * @version 1.0
3478 */
Chaehyun Lima9a16822015-09-20 15:51:24 +09003479int wilc_deinit_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003480{
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003481 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482
Chaehyun Lim27268872015-09-15 14:06:13 +09003483 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003484
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485 priv = wdev_priv(net->ieee80211_ptr);
3486
Dean Lee72ed4dc2015-06-12 14:11:44 +09003487 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003488
Dean Lee72ed4dc2015-06-12 14:11:44 +09003489 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490
3491 op_ifcs--;
3492
3493 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494
3495 /* Clear the Shadow scan */
3496 clear_shadow_scan(priv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497 if (op_ifcs == 0) {
3498 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003499 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003500 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003501
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003502 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503 PRINT_ER("Error while deintializing host interface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003504
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003505 return s32Error;
3506}
3507
3508
3509/**
3510 * @brief WILC_WFI_WiphyFree
3511 * @details Freeing allocation of the wireless device structure
3512 * @param[in] NONE
3513 * @return NONE
3514 * @author mdaftedar
3515 * @date 01 MAR 2012
3516 * @version 1.0
3517 */
Chaehyun Lim96da20a2015-09-20 15:51:08 +09003518void wilc_free_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003519{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003520 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3521
Chaehyun Lim619837a2015-09-20 15:51:10 +09003522 if (!net) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 PRINT_D(INIT_DBG, "net_device is NULL\n");
3524 return;
3525 }
3526
Chaehyun Lim619837a2015-09-20 15:51:10 +09003527 if (!net->ieee80211_ptr) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003528 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3529 return;
3530 }
3531
Chaehyun Lim619837a2015-09-20 15:51:10 +09003532 if (!net->ieee80211_ptr->wiphy) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003533 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3534 return;
3535 }
3536
3537 wiphy_unregister(net->ieee80211_ptr->wiphy);
3538
3539 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3540 wiphy_free(net->ieee80211_ptr->wiphy);
3541 kfree(net->ieee80211_ptr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542}