blob: 8aea4b560b2e0dd6c1449061ee24a87931a0c5fd [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;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001363
1364 priv = wiphy_priv(wiphy);
1365
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366 /*delete saved keys, if any*/
Tony Cho817f3fb2015-10-20 14:26:51 +09001367 if (netdev == g_linux_wlan->vif[0].ndev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001368 g_ptk_keys_saved = false;
1369 g_gtk_keys_saved = false;
1370 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371
1372 /*Delete saved WEP keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301373 kfree(g_key_wep_params.key);
1374 g_key_wep_params.key = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375
1376 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1377
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001378 if ((priv->wilc_gtk[key_index]) != NULL) {
1379
Shraddha Barkecccfc392015-10-12 20:49:19 +05301380 kfree(priv->wilc_gtk[key_index]->key);
1381 priv->wilc_gtk[key_index]->key = NULL;
1382 kfree(priv->wilc_gtk[key_index]->seq);
1383 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001384
Chaehyun Lim49188af2015-08-11 10:32:41 +09001385 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001386 priv->wilc_gtk[key_index] = NULL;
1387
1388 }
1389
1390 if ((priv->wilc_ptk[key_index]) != NULL) {
1391
Shraddha Barkecccfc392015-10-12 20:49:19 +05301392 kfree(priv->wilc_ptk[key_index]->key);
1393 priv->wilc_ptk[key_index]->key = NULL;
1394 kfree(priv->wilc_ptk[key_index]->seq);
1395 priv->wilc_ptk[key_index]->seq = NULL;
Chaehyun Lim49188af2015-08-11 10:32:41 +09001396 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397 priv->wilc_ptk[key_index] = NULL;
1398 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001399
1400 /*Delete saved PTK and GTK keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301401 kfree(g_key_ptk_params.key);
1402 g_key_ptk_params.key = NULL;
1403 kfree(g_key_ptk_params.seq);
1404 g_key_ptk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405
Shraddha Barkecccfc392015-10-12 20:49:19 +05301406 kfree(g_key_gtk_params.key);
1407 g_key_gtk_params.key = NULL;
1408 kfree(g_key_gtk_params.seq);
1409 g_key_gtk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001410
1411 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001412 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001413 }
1414
1415 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001416 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417 priv->WILC_WFI_wep_key_len[key_index] = 0;
1418
1419 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1420 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1421 } else {
1422 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1423 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1424 }
1425
Leo Kimaaed3292015-10-12 16:55:38 +09001426 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001427}
1428
1429/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001430 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431 * @details Get information about the key with the given parameters.
1432 * @mac_addr will be %NULL when requesting information for a group
1433 * key. All pointers given to the @callback function need not be valid
1434 * after it returns. This function should return an error if it is
1435 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1436 * @param[in]
1437 * @return int : Return 0 on Success
1438 * @author mdaftedar
1439 * @date 01 MAR 2012
1440 * @version 1.0
1441 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001442static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1443 bool pairwise,
1444 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445{
Chaehyun Lim27268872015-09-15 14:06:13 +09001446 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001447 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001448 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001449
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001450 priv = wiphy_priv(wiphy);
1451
1452
Alison Schofield3604af52015-10-12 13:22:44 -07001453 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1455
1456 key_params.key = priv->wilc_gtk[key_index]->key;
1457 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1458 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1459 key_params.seq = priv->wilc_gtk[key_index]->seq;
1460 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1461 if (INFO) {
1462 for (i = 0; i < key_params.key_len; i++)
1463 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1464 }
1465 } else {
1466 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1467
1468 key_params.key = priv->wilc_ptk[key_index]->key;
1469 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1470 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1471 key_params.seq = priv->wilc_ptk[key_index]->seq;
1472 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1473 }
1474
1475 callback(cookie, &key_params);
1476
Leo Kimaaed3292015-10-12 16:55:38 +09001477 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001478}
1479
1480/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001481 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001482 * @details Set the default management frame key on an interface
1483 * @param[in]
1484 * @return int : Return 0 on Success.
1485 * @author mdaftedar
1486 * @date 01 MAR 2012
1487 * @version 1.0
1488 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001489static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1490 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491{
Chaehyun Lim27268872015-09-15 14:06:13 +09001492 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001493
1494
1495 priv = wiphy_priv(wiphy);
1496
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301497 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498
1499 if (key_index != priv->WILC_WFI_wep_default) {
1500
1501 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1502 }
1503
Leo Kimaaed3292015-10-12 16:55:38 +09001504 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001505}
1506
1507/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001508 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509 * @details Get station information for the station identified by @mac
1510 * @param[in] NONE
1511 * @return int : Return 0 on Success.
1512 * @author mdaftedar
1513 * @date 01 MAR 2012
1514 * @version 1.0
1515 */
1516
Chaehyun Limf06f5622015-09-14 12:24:18 +09001517static int get_station(struct wiphy *wiphy, struct net_device *dev,
1518 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001519{
Chaehyun Lim27268872015-09-15 14:06:13 +09001520 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001521 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001522 u32 i = 0;
1523 u32 associatedsta = 0;
1524 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 priv = wiphy_priv(wiphy);
1526 nic = netdev_priv(dev);
1527
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1529 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1530
1531 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1532
1533 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1534
1535 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1536 associatedsta = i;
1537 break;
1538 }
1539
1540 }
1541
1542 if (associatedsta == -1) {
Leo Kimaaed3292015-10-12 16:55:38 +09001543 PRINT_ER("Station required is not associated\n");
1544 return -ENOENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001545 }
1546
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001548
1549 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1550 sinfo->inactive_time = 1000 * inactive_time;
1551 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1552
1553 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001554
1555 if (nic->iftype == STATION_MODE) {
Leo Kim03e7b9c2015-10-12 16:55:58 +09001556 struct rf_info strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001557
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1559
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001560 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301561 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001562 BIT(NL80211_STA_INFO_TX_PACKETS) |
1563 BIT(NL80211_STA_INFO_TX_FAILED) |
1564 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001565
1566 sinfo->signal = strStatistics.s8RSSI;
1567 sinfo->rx_packets = strStatistics.u32RxCount;
1568 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001569 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001570 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1571
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301572 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001573 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301574 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001575 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001576
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001577 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1578 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579 }
Leo Kimaaed3292015-10-12 16:55:38 +09001580 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581}
1582
1583
1584/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001585 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586 * @details Modify parameters for a given BSS.
1587 * @param[in]
1588 * -use_cts_prot: Whether to use CTS protection
1589 * (0 = no, 1 = yes, -1 = do not change)
1590 * -use_short_preamble: Whether the use of short preambles is allowed
1591 * (0 = no, 1 = yes, -1 = do not change)
1592 * -use_short_slot_time: Whether the use of short slot time is allowed
1593 * (0 = no, 1 = yes, -1 = do not change)
1594 * -basic_rates: basic rates in IEEE 802.11 format
1595 * (or NULL for no change)
1596 * -basic_rates_len: number of basic rates
1597 * -ap_isolate: do not forward packets between connected stations
1598 * -ht_opmode: HT Operation mode
1599 * (u16 = opmode, -1 = do not change)
1600 * @return int : Return 0 on Success.
1601 * @author mdaftedar
1602 * @date 01 MAR 2012
1603 * @version 1.0
1604 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001605static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1606 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001607{
1608 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1609 return 0;
1610}
1611
1612/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001613 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001614 * @details Notify that wiphy parameters have changed;
1615 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1616 * have changed.
1617 * @return int : Return 0 on Success
1618 * @author mdaftedar
1619 * @date 01 MAR 2012
1620 * @version 1.0
1621 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001622static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001623{
Leo Kime6e12662015-09-16 18:36:03 +09001624 s32 s32Error = 0;
Leo Kim95296502015-10-05 15:25:46 +09001625 struct cfg_param_val pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001626 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001627
1628 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001629
Tony Cho87c05b22015-10-12 16:56:07 +09001630 pstrCfgParamVal.flag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301631 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632
1633 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1634 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1635 priv->dev->ieee80211_ptr->wiphy->retry_short);
Tony Cho87c05b22015-10-12 16:56:07 +09001636 pstrCfgParamVal.flag |= RETRY_SHORT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001637 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1638 }
1639 if (changed & WIPHY_PARAM_RETRY_LONG) {
1640
1641 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 +09001642 pstrCfgParamVal.flag |= RETRY_LONG;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001643 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1644
1645 }
1646 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1647 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 +09001648 pstrCfgParamVal.flag |= FRAG_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001649 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1650
1651 }
1652
1653 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1654 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1655
Tony Cho87c05b22015-10-12 16:56:07 +09001656 pstrCfgParamVal.flag |= RTS_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001657 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1658
1659 }
1660
1661 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1662 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1663 if (s32Error)
1664 PRINT_ER("Error in setting WIPHY PARAMS\n");
1665
1666
1667 return s32Error;
1668}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001669
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001670/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001671 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001672 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1673 * devices running firmwares capable of generating the (re) association
1674 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1675 * @param[in]
1676 * @return int : Return 0 on Success
1677 * @author mdaftedar
1678 * @date 01 MAR 2012
1679 * @version 1.0
1680 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001681static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1682 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001683{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001684 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001685 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001686 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687
Chaehyun Lim27268872015-09-15 14:06:13 +09001688 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001689
1690 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1691
1692
1693 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001694 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001695 ETH_ALEN)) {
1696 /*If bssid already exists and pmkid value needs to reset*/
1697 flag = PMKID_FOUND;
1698 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1699 break;
1700 }
1701 }
1702 if (i < WILC_MAX_NUM_PMKIDS) {
1703 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001704 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001705 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001706 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001707 PMKID_LEN);
1708 if (!(flag == PMKID_FOUND))
1709 priv->pmkid_list.numpmkid++;
1710 } else {
1711 PRINT_ER("Invalid PMKID index\n");
1712 s32Error = -EINVAL;
1713 }
1714
1715 if (!s32Error) {
1716 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1717 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1718 }
1719 return s32Error;
1720}
1721
1722/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001723 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724 * @details Delete a cached PMKID.
1725 * @param[in]
1726 * @return int : Return 0 on Success
1727 * @author mdaftedar
1728 * @date 01 MAR 2012
1729 * @version 1.0
1730 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001731static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1732 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733{
1734
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001735 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001736 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001737
Chaehyun Lim27268872015-09-15 14:06:13 +09001738 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
1740 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1741
1742 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001743 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001744 ETH_ALEN)) {
1745 /*If bssid is found, reset the values*/
1746 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Leo Kimcd1e6cb2015-10-05 15:25:45 +09001747 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001748 break;
1749 }
1750 }
1751
1752 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1753 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001754 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001755 priv->pmkid_list.pmkidlist[i + 1].bssid,
1756 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001757 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001758 priv->pmkid_list.pmkidlist[i].pmkid,
1759 PMKID_LEN);
1760 }
1761 priv->pmkid_list.numpmkid--;
1762 } else {
1763 s32Error = -EINVAL;
1764 }
1765
1766 return s32Error;
1767}
1768
1769/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001770 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001771 * @details Flush all cached PMKIDs.
1772 * @param[in]
1773 * @return int : Return 0 on Success
1774 * @author mdaftedar
1775 * @date 01 MAR 2012
1776 * @version 1.0
1777 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001778static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001779{
Chaehyun Lim27268872015-09-15 14:06:13 +09001780 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001781
1782 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1783
1784 /*Get cashed Pmkids and set all with zeros*/
Leo Kima949f902015-10-05 15:25:44 +09001785 memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001786
1787 return 0;
1788}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790
1791/**
1792 * @brief WILC_WFI_CfgParseRxAction
1793 * @details Function parses the received frames and modifies the following attributes:
1794 * -GO Intent
1795 * -Channel list
1796 * -Operating Channel
1797 *
1798 * @param[in] u8* Buffer, u32 length
1799 * @return NONE.
1800 * @author mdaftedar
1801 * @date 12 DEC 2012
1802 * @version
1803 */
1804
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001805void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001806{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001807 u32 index = 0;
1808 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001809
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001810 u8 op_channel_attr_index = 0;
1811 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812
1813 while (index < len) {
1814 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816 }
1817
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301818 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301820 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001822 index += buf[index + 1] + 3; /* ID,Length byte */
1823 }
Alison Schofield3604af52015-10-12 13:22:44 -07001824 if (u8WLANChannel != INVALID_CHANNEL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001826 /*Modify channel list attribute*/
1827 if (channel_list_attr_index) {
1828 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1829 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1830 if (buf[i] == 0x51) {
1831 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1832 buf[j] = u8WLANChannel;
1833 }
1834 break;
1835 }
1836 }
1837 }
1838 /*Modify operating channel attribute*/
1839 if (op_channel_attr_index) {
1840 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1841 buf[op_channel_attr_index + 6] = 0x51;
1842 buf[op_channel_attr_index + 7] = u8WLANChannel;
1843 }
1844 }
1845}
1846
1847/**
1848 * @brief WILC_WFI_CfgParseTxAction
1849 * @details Function parses the transmitted action frames and modifies the
1850 * GO Intent attribute
1851 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1852 * @return NONE.
1853 * @author mdaftedar
1854 * @date 12 DEC 2012
1855 * @version
1856 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09001857void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001858{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001859 u32 index = 0;
1860 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001861
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001862 u8 op_channel_attr_index = 0;
1863 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001864
1865 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001866 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868
1869 break;
1870 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301872 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001873 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301874 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001876 index += buf[index + 1] + 3; /* ID,Length byte */
1877 }
Alison Schofield3604af52015-10-12 13:22:44 -07001878 if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001880 /*Modify channel list attribute*/
1881 if (channel_list_attr_index) {
1882 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1883 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1884 if (buf[i] == 0x51) {
1885 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1886 buf[j] = u8WLANChannel;
1887 }
1888 break;
1889 }
1890 }
1891 }
1892 /*Modify operating channel attribute*/
1893 if (op_channel_attr_index) {
1894 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1895 buf[op_channel_attr_index + 6] = 0x51;
1896 buf[op_channel_attr_index + 7] = u8WLANChannel;
1897 }
1898 }
1899}
1900
1901/* @brief WILC_WFI_p2p_rx
1902 * @details
1903 * @param[in]
1904 *
1905 * @return None
1906 * @author Mai Daftedar
1907 * @date 2 JUN 2013
1908 * @version 1.0
1909 */
1910
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09001911void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001912{
1913
Chaehyun Lim27268872015-09-15 14:06:13 +09001914 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001915 u32 header, pkt_offset;
Leo Kim441dc602015-10-12 16:55:35 +09001916 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001917 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001918 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001919
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001920 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09001921 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001922
1923 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001924 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925
1926 /* The packet offset field conain info about what type of managment frame */
1927 /* we are dealing with and ack status */
1928 pkt_offset = GET_PKT_OFFSET(header);
1929
1930 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
1931 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
1932 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934 return;
1935 } else {
1936 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
1937 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],
1938 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940 } else {
1941 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],
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, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 }
1945 return;
1946 }
1947 } else {
1948
1949 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
1950
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001951 /*Upper layer is informed that the frame is received on this freq*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09001952 s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001953
1954 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
1955 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
1956
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01001957 if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001958 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
1959 return;
1960 }
1961 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
1962
1963 switch (buff[ACTION_SUBTYPE_ID]) {
1964 case GAS_INTIAL_REQ:
1965 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
1966 break;
1967
1968 case GAS_INTIAL_RSP:
1969 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
1970 break;
1971
1972 case PUBLIC_ACT_VENDORSPEC:
1973 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
1974 * 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 +09001975 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001976 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
1977 if (!bWilc_ie) {
1978 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001979 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001980 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09001981 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001982 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
1983 break;
1984 }
1985 }
1986 }
1987 }
1988 if (u8P2Plocalrandom > u8P2Precvrandom) {
1989 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
1990 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
1991 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001992 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
1994 break;
1995 }
1996 }
1997 }
1998 } else
1999 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2000 }
2001
2002
2003 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2004 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2005 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002006 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002007 return;
2008 }
2009 break;
2010
2011 default:
2012 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2013 break;
2014 }
2015 }
2016 }
2017
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002018 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002019 }
2020}
2021
2022/**
2023 * @brief WILC_WFI_mgmt_tx_complete
2024 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2025 * @param[in] priv
2026 * transmitting status
2027 * @return None
2028 * @author Amr Abdelmoghny
2029 * @date 20 MAY 2013
2030 * @version 1.0
2031 */
2032static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2033{
2034 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2035
2036
2037 kfree(pv_data->buff);
2038 kfree(pv_data);
2039}
2040
2041/**
2042 * @brief WILC_WFI_RemainOnChannelReady
2043 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2044 * @param
2045 * @return none
2046 * @author Amr abdelmoghny
2047 * @date 9 JUNE 2013
2048 * @version
2049 */
2050
2051static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2052{
Chaehyun Lim27268872015-09-15 14:06:13 +09002053 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002054
Chaehyun Lim27268872015-09-15 14:06:13 +09002055 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302057 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002058
Dean Lee72ed4dc2015-06-12 14:11:44 +09002059 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002060
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061 cfg80211_ready_on_channel(priv->wdev,
2062 priv->strRemainOnChanParams.u64ListenCookie,
2063 priv->strRemainOnChanParams.pstrListenChan,
2064 priv->strRemainOnChanParams.u32ListenDuration,
2065 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002066}
2067
2068/**
2069 * @brief WILC_WFI_RemainOnChannelExpired
2070 * @details Callback function, called on expiration of remain-on-channel duration
2071 * @param
2072 * @return none
2073 * @author Amr abdelmoghny
2074 * @date 15 MAY 2013
2075 * @version
2076 */
2077
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002078static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079{
Chaehyun Lim27268872015-09-15 14:06:13 +09002080 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002081
Chaehyun Lim27268872015-09-15 14:06:13 +09002082 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302085 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002086
Dean Lee72ed4dc2015-06-12 14:11:44 +09002087 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088
2089 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002090 cfg80211_remain_on_channel_expired(priv->wdev,
2091 priv->strRemainOnChanParams.u64ListenCookie,
2092 priv->strRemainOnChanParams.pstrListenChan,
2093 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002094 } else {
2095 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2096 , priv->strRemainOnChanParams.u32ListenSessionID);
2097 }
2098}
2099
2100
2101/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002102 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002103 * @details Request the driver to remain awake on the specified
2104 * channel for the specified duration to complete an off-channel
2105 * operation (e.g., public action frame exchange). When the driver is
2106 * ready on the requested channel, it must indicate this with an event
2107 * notification by calling cfg80211_ready_on_channel().
2108 * @param[in]
2109 * @return int : Return 0 on Success
2110 * @author mdaftedar
2111 * @date 01 MAR 2012
2112 * @version 1.0
2113 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002114static int remain_on_channel(struct wiphy *wiphy,
2115 struct wireless_dev *wdev,
2116 struct ieee80211_channel *chan,
2117 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002118{
Leo Kime6e12662015-09-16 18:36:03 +09002119 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002120 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002121
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122 priv = wiphy_priv(wiphy);
2123
2124 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2125
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002126
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127 if (wdev->iftype == NL80211_IFTYPE_AP) {
2128 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2129 return s32Error;
2130 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002132 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133
2134 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2135 priv->strRemainOnChanParams.pstrListenChan = chan;
2136 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002137 priv->strRemainOnChanParams.u32ListenDuration = duration;
2138 priv->strRemainOnChanParams.u32ListenSessionID++;
2139
2140 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2141 , priv->strRemainOnChanParams.u32ListenSessionID
2142 , duration
2143 , chan->hw_value
2144 , WILC_WFI_RemainOnChannelExpired
2145 , WILC_WFI_RemainOnChannelReady
2146 , (void *)priv);
2147
2148 return s32Error;
2149}
2150
2151/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002152 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002153 * @details Cancel an on-going remain-on-channel operation.
2154 * This allows the operation to be terminated prior to timeout based on
2155 * the duration value.
2156 * @param[in] struct wiphy *wiphy,
2157 * @param[in] struct net_device *dev
2158 * @param[in] u64 cookie,
2159 * @return int : Return 0 on Success
2160 * @author mdaftedar
2161 * @date 01 MAR 2012
2162 * @version 1.0
2163 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002164static int cancel_remain_on_channel(struct wiphy *wiphy,
2165 struct wireless_dev *wdev,
2166 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002167{
Leo Kime6e12662015-09-16 18:36:03 +09002168 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002169 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002170
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171 priv = wiphy_priv(wiphy);
2172
2173 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2174
2175 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2176 return s32Error;
2177}
2178/**
2179 * @brief WILC_WFI_add_wilcvendorspec
2180 * @details Adding WILC information elemet to allow two WILC devices to
2181 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002182 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002183 * @return void
2184 * @author mdaftedar
2185 * @date 01 JAN 2014
2186 * @version 1.0
2187 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002188void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002189{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002190 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191}
2192/**
2193 * @brief WILC_WFI_mgmt_tx_frame
2194 * @details
2195 *
2196 * @param[in]
2197 * @return NONE.
2198 * @author mdaftedar
2199 * @date 01 JUL 2012
2200 * @version
2201 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002202extern bool bEnablePS;
Chaehyun Limc1560322015-09-22 18:34:51 +09002203static int mgmt_tx(struct wiphy *wiphy,
2204 struct wireless_dev *wdev,
2205 struct cfg80211_mgmt_tx_params *params,
2206 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002207{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002208 struct ieee80211_channel *chan = params->chan;
2209 unsigned int wait = params->wait;
2210 const u8 *buf = params->buf;
2211 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002212 const struct ieee80211_mgmt *mgmt;
2213 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002214 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002215 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002216 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002217 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002218 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002219
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002220 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002222 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223
2224 *cookie = (unsigned long)buf;
2225 priv->u64tx_cookie = *cookie;
2226 mgmt = (const struct ieee80211_mgmt *) buf;
2227
2228 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2229
2230 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002231 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002232 if (mgmt_tx == NULL) {
2233 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
Leo Kime6e12662015-09-16 18:36:03 +09002234 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 }
Glen Leef3052582015-09-10 12:03:04 +09002236 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 if (mgmt_tx->buff == NULL) {
2238 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002239 kfree(mgmt_tx);
Leo Kime6e12662015-09-16 18:36:03 +09002240 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002241 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002242 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002243 mgmt_tx->size = len;
2244
2245
2246 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2247 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2248 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2249 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2250 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002251 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002252 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002253 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002254
2255
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002256 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002257 /*Only set the channel, if not a negotiation confirmation frame
2258 * (If Negotiation confirmation frame, force it
2259 * to be transmitted on the same negotiation channel)*/
2260
2261 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2262 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2263 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2264 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2265 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002266 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267 }
2268 switch (buf[ACTION_SUBTYPE_ID]) {
2269 case GAS_INTIAL_REQ:
2270 {
2271 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2272 break;
2273 }
2274
2275 case GAS_INTIAL_RSP:
2276 {
2277 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2278 break;
2279 }
2280
2281 case PUBLIC_ACT_VENDORSPEC:
2282 {
2283 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2284 * 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 +09002285 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002286 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2287 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2288 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2289 get_random_bytes(&u8P2Plocalrandom, 1);
2290 /*Increment the number to prevent if its 0*/
2291 u8P2Plocalrandom++;
2292 }
2293 }
2294
2295 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2296 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2297 if (u8P2Plocalrandom > u8P2Precvrandom) {
2298 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2299
2300 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2301 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002302 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002303 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002304 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002305
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306 /*If using supplicant go intent, no need at all*/
2307 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002309 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310 break;
2311 }
2312 }
2313
2314 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2315 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2316 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2317 mgmt_tx->size = buf_len;
2318 }
2319 } else
2320 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2321 }
2322
2323 } else {
2324 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2325 }
2326
2327 break;
2328 }
2329
2330 default:
2331 {
2332 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2333 break;
2334 }
2335 }
2336
2337 }
2338
2339 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2340 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2341
2342 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2343
2344 }
2345
Glen Leec9d48342015-10-01 16:03:43 +09002346 wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff,
2347 mgmt_tx->size,
2348 WILC_WFI_mgmt_tx_complete);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349 } else {
2350 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2351 }
Leo Kimaaed3292015-10-12 16:55:38 +09002352 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002353}
2354
Chaehyun Lim85c587a2015-09-22 18:34:50 +09002355static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2356 struct wireless_dev *wdev,
2357 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002358{
Chaehyun Lim27268872015-09-15 14:06:13 +09002359 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002360 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002361
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002362 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002363 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002364
2365
2366 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2367 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2368
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01002369 if (!priv->bInP2PlistenState) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370 cfg80211_remain_on_channel_expired(priv->wdev,
2371 priv->strRemainOnChanParams.u64ListenCookie,
2372 priv->strRemainOnChanParams.pstrListenChan,
2373 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002374 }
2375
2376 return 0;
2377}
2378
2379/**
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002380 * @brief wilc_mgmt_frame_register
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002381 * @details Notify driver that a management frame type was
2382 * registered. Note that this callback may not sleep, and cannot run
2383 * concurrently with itself.
2384 * @param[in]
2385 * @return NONE.
2386 * @author mdaftedar
2387 * @date 01 JUL 2012
2388 * @version
2389 */
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002390void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
2391 u16 frame_type, bool reg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002392{
2393
Chaehyun Lim27268872015-09-15 14:06:13 +09002394 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002395 perInterface_wlan_t *nic;
2396
2397
2398 priv = wiphy_priv(wiphy);
2399 nic = netdev_priv(priv->wdev->netdev);
2400
2401
2402
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002403 if (!frame_type)
2404 return;
2405
2406 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2407 switch (frame_type) {
2408 case PROBE_REQ:
2409 {
2410 nic->g_struct_frame_reg[0].frame_type = frame_type;
2411 nic->g_struct_frame_reg[0].reg = reg;
2412 }
2413 break;
2414
2415 case ACTION:
2416 {
2417 nic->g_struct_frame_reg[1].frame_type = frame_type;
2418 nic->g_struct_frame_reg[1].reg = reg;
2419 }
2420 break;
2421
2422 default:
2423 {
2424 break;
2425 }
2426
2427 }
2428 /*If mac is closed, then return*/
Tony Cho080f11b2015-10-20 14:26:45 +09002429 if (!g_linux_wlan->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002430 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2431 return;
2432 }
2433 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2434
2435
2436}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002437
2438/**
Chaehyun Lima8047e22015-09-22 18:34:48 +09002439 * @brief set_cqm_rssi_config
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440 * @details Configure connection quality monitor RSSI threshold.
2441 * @param[in] struct wiphy *wiphy:
2442 * @param[in] struct net_device *dev:
2443 * @param[in] s32 rssi_thold:
2444 * @param[in] u32 rssi_hyst:
2445 * @return int : Return 0 on Success
2446 * @author mdaftedar
2447 * @date 01 MAR 2012
2448 * @version 1.0
2449 */
Chaehyun Lima8047e22015-09-22 18:34:48 +09002450static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
2451 s32 rssi_thold, u32 rssi_hyst)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002452{
2453 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2454 return 0;
2455
2456}
2457/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002458 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002459 * @details Configure connection quality monitor RSSI threshold.
2460 * @param[in] struct wiphy *wiphy:
2461 * @param[in] struct net_device *dev
2462 * @param[in] int idx
2463 * @param[in] u8 *mac
2464 * @param[in] struct station_info *sinfo
2465 * @return int : Return 0 on Success
2466 * @author mdaftedar
2467 * @date 01 MAR 2012
2468 * @version 1.0
2469 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002470static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2471 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002472{
Chaehyun Lim27268872015-09-15 14:06:13 +09002473 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002474
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2476
2477 if (idx != 0)
2478 return -ENOENT;
2479
2480 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002481
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002482 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002483
2484 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2485
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486 return 0;
2487
2488}
2489
2490
2491/**
Chaehyun Lim46530672015-09-22 18:34:46 +09002492 * @brief set_power_mgmt
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002493 * @details
2494 * @param[in]
2495 * @return int : Return 0 on Success.
2496 * @author mdaftedar
2497 * @date 01 JUL 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09002498 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499 */
Chaehyun Lim46530672015-09-22 18:34:46 +09002500static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2501 bool enabled, int timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002502{
Chaehyun Lim27268872015-09-15 14:06:13 +09002503 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002504
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2506
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002507 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 return -ENOENT;
2509
2510 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002511 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002512 PRINT_ER("Driver is NULL\n");
2513 return -EIO;
2514 }
2515
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002516 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2518
2519
Leo Kime6e12662015-09-16 18:36:03 +09002520 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521
2522}
Glen Lee108b3432015-09-16 18:53:20 +09002523
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002524/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002525 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526 * @details Change type/configuration of virtual interface,
2527 * keep the struct wireless_dev's iftype updated.
2528 * @param[in] NONE
2529 * @return int : Return 0 on Success.
2530 * @author mdaftedar
2531 * @date 01 MAR 2012
2532 * @version 1.0
2533 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002534int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2535
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002536static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2537 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002538{
Chaehyun Lim27268872015-09-15 14:06:13 +09002539 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002540 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002541 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002542 u16 TID = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002543 u8 i;
Glen Lee299382c2015-10-20 17:13:56 +09002544 struct wilc *wl;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002545
2546 nic = netdev_priv(dev);
2547 priv = wiphy_priv(wiphy);
Glen Lee299382c2015-10-20 17:13:56 +09002548 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002549
2550 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2551 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2552 u8P2Plocalrandom = 0x01;
2553 u8P2Precvrandom = 0x00;
2554
Dean Lee72ed4dc2015-06-12 14:11:44 +09002555 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002556
Dean Lee72ed4dc2015-06-12 14:11:44 +09002557 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002558 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002559 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002560 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2561 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002562 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563 }
2564
2565 switch (type) {
2566 case NL80211_IFTYPE_STATION:
2567 connecting = 0;
2568 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002569
2570 /* send delba over wlan interface */
2571
2572
2573 dev->ieee80211_ptr->iftype = type;
2574 priv->wdev->iftype = type;
2575 nic->monitor_flag = 0;
2576 nic->iftype = STATION_MODE;
2577
2578 /*Remove the enteries of the previously connected clients*/
2579 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002580 interface_type = nic->iftype;
2581 nic->iftype = STATION_MODE;
2582
Glen Lee299382c2015-10-20 17:13:56 +09002583 if (wl->initialized) {
2584 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2585 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002586 /* ensure that the message Q is empty */
2587 host_int_wait_msg_queue_idle();
2588
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589 /*Eliminate host interface blocking state*/
Glen Lee299382c2015-10-20 17:13:56 +09002590 up(&wl->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002591
Glen Lee53dc0cf2015-10-20 17:13:57 +09002592 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593 wilc1000_wlan_init(dev, nic);
2594 g_wilc_initialized = 1;
2595 nic->iftype = interface_type;
2596
2597 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002598 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2599 host_int_set_MacAddress(wl->vif[0].hif_drv,
2600 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2602
2603 /*Add saved WEP keys, if any*/
2604 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002605 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002606 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002607 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608 g_key_wep_params.key,
2609 g_key_wep_params.key_len,
2610 g_key_wep_params.key_idx);
2611 }
2612
2613 /*No matter the driver handler passed here, it will be overwriiten*/
2614 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2615 host_int_flush_join_req(priv->hWILCWFIDrv);
2616
2617 /*Add saved PTK and GTK keys, if any*/
2618 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2619 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2620 g_key_ptk_params.key[1],
2621 g_key_ptk_params.key[2]);
2622 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2623 g_key_gtk_params.key[1],
2624 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002625 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2626 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002627 g_add_ptk_key_params.key_idx,
2628 g_add_ptk_key_params.pairwise,
2629 g_add_ptk_key_params.mac_addr,
2630 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002631
Glen Lee299382c2015-10-20 17:13:56 +09002632 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2633 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002634 g_add_gtk_key_params.key_idx,
2635 g_add_gtk_key_params.pairwise,
2636 g_add_gtk_key_params.mac_addr,
2637 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002638 }
2639
Glen Lee299382c2015-10-20 17:13:56 +09002640 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002641 for (i = 0; i < num_reg_frame; i++) {
2642 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2643 nic->g_struct_frame_reg[i].reg);
2644 host_int_frame_register(priv->hWILCWFIDrv,
2645 nic->g_struct_frame_reg[i].frame_type,
2646 nic->g_struct_frame_reg[i].reg);
2647 }
2648 }
2649
Dean Lee72ed4dc2015-06-12 14:11:44 +09002650 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002651 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2652 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002653 break;
2654
2655 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002656 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002657 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2658 connecting = 0;
2659 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002660
Glen Lee299382c2015-10-20 17:13:56 +09002661 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2662 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663
2664 dev->ieee80211_ptr->iftype = type;
2665 priv->wdev->iftype = type;
2666 nic->monitor_flag = 0;
2667
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002668 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2669 nic->iftype = CLIENT_MODE;
2670
2671
Glen Lee299382c2015-10-20 17:13:56 +09002672 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673 /* ensure that the message Q is empty */
2674 host_int_wait_msg_queue_idle();
2675
Glen Lee53dc0cf2015-10-20 17:13:57 +09002676 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002677 wilc1000_wlan_init(dev, nic);
2678 g_wilc_initialized = 1;
2679
Glen Lee299382c2015-10-20 17:13:56 +09002680 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2681 host_int_set_MacAddress(wl->vif[0].hif_drv,
2682 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002683 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2684
2685 /*Add saved WEP keys, if any*/
2686 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002687 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002689 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002690 g_key_wep_params.key,
2691 g_key_wep_params.key_len,
2692 g_key_wep_params.key_idx);
2693 }
2694
2695 /*No matter the driver handler passed here, it will be overwriiten*/
2696 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2697 host_int_flush_join_req(priv->hWILCWFIDrv);
2698
2699 /*Add saved PTK and GTK keys, if any*/
2700 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2701 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2702 g_key_ptk_params.key[1],
2703 g_key_ptk_params.key[2]);
2704 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2705 g_key_gtk_params.key[1],
2706 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002707 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2708 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002709 g_add_ptk_key_params.key_idx,
2710 g_add_ptk_key_params.pairwise,
2711 g_add_ptk_key_params.mac_addr,
2712 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713
Glen Lee299382c2015-10-20 17:13:56 +09002714 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2715 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002716 g_add_gtk_key_params.key_idx,
2717 g_add_gtk_key_params.pairwise,
2718 g_add_gtk_key_params.mac_addr,
2719 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 }
2721
2722 /*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 +09002723 refresh_scan(priv, 1, true);
2724 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002725
Glen Lee299382c2015-10-20 17:13:56 +09002726 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002727 for (i = 0; i < num_reg_frame; i++) {
2728 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2729 nic->g_struct_frame_reg[i].reg);
2730 host_int_frame_register(priv->hWILCWFIDrv,
2731 nic->g_struct_frame_reg[i].frame_type,
2732 nic->g_struct_frame_reg[i].reg);
2733 }
2734 }
2735 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002736 break;
2737
2738 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002739 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002740 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741 dev->ieee80211_ptr->iftype = type;
2742 priv->wdev->iftype = type;
2743 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002744 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002745
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002746 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2747 linux_wlan_get_firmware(nic);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
Glen Lee299382c2015-10-20 17:13:56 +09002749 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002750 nic->iftype = AP_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751 mac_close(dev);
2752 mac_open(dev);
2753
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002754 for (i = 0; i < num_reg_frame; i++) {
2755 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2756 nic->g_struct_frame_reg[i].reg);
2757 host_int_frame_register(priv->hWILCWFIDrv,
2758 nic->g_struct_frame_reg[i].frame_type,
2759 nic->g_struct_frame_reg[i].reg);
2760 }
2761 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002762 break;
2763
2764 case NL80211_IFTYPE_P2P_GO:
2765 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2766
Dean Lee72ed4dc2015-06-12 14:11:44 +09002767 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002768 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002769 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002770 /*Delete block ack has to be the latest config packet*/
2771 /*sent before downloading new FW. This is because it blocks on*/
2772 /*hWaitResponse semaphore, which allows previous config*/
2773 /*packets to actually take action on old FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002774 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2775 wl->vif[0].bssid, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002776 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778 dev->ieee80211_ptr->iftype = type;
2779 priv->wdev->iftype = type;
2780
Johnny Kim8a143302015-06-10 17:06:46 +09002781 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002782
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002783 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2784
2785
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786 nic->iftype = GO_MODE;
2787
2788 /* ensure that the message Q is empty */
2789 host_int_wait_msg_queue_idle();
Glen Lee53dc0cf2015-10-20 17:13:57 +09002790 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 wilc1000_wlan_init(dev, nic);
2792 g_wilc_initialized = 1;
2793
2794
2795 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002796 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2797 host_int_set_MacAddress(wl->vif[0].hif_drv,
2798 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002799 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
2800
2801 /*Add saved WEP keys, if any*/
2802 if (g_wep_keys_saved) {
Glen Lee299382c2015-10-20 17:13:56 +09002803 host_int_set_WEPDefaultKeyID(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002804 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002805 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002806 g_key_wep_params.key,
2807 g_key_wep_params.key_len,
2808 g_key_wep_params.key_idx);
2809 }
2810
2811 /*No matter the driver handler passed here, it will be overwriiten*/
2812 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2813 host_int_flush_join_req(priv->hWILCWFIDrv);
2814
2815 /*Add saved PTK and GTK keys, if any*/
2816 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2817 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
2818 g_key_ptk_params.key[1],
2819 g_key_ptk_params.key[2],
2820 g_key_ptk_params.cipher);
2821 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
2822 g_key_gtk_params.key[1],
2823 g_key_gtk_params.key[2],
2824 g_key_gtk_params.cipher);
Glen Lee299382c2015-10-20 17:13:56 +09002825 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2826 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002827 g_add_ptk_key_params.key_idx,
2828 g_add_ptk_key_params.pairwise,
2829 g_add_ptk_key_params.mac_addr,
2830 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002831
Glen Lee299382c2015-10-20 17:13:56 +09002832 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2833 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002834 g_add_gtk_key_params.key_idx,
2835 g_add_gtk_key_params.pairwise,
2836 g_add_gtk_key_params.mac_addr,
2837 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002838 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002839
Glen Lee299382c2015-10-20 17:13:56 +09002840 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 for (i = 0; i < num_reg_frame; i++) {
2842 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2843 nic->g_struct_frame_reg[i].reg);
2844 host_int_frame_register(priv->hWILCWFIDrv,
2845 nic->g_struct_frame_reg[i].frame_type,
2846 nic->g_struct_frame_reg[i].reg);
2847 }
2848 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 break;
2850
2851 default:
2852 PRINT_ER("Unknown interface type= %d\n", type);
Leo Kimaaed3292015-10-12 16:55:38 +09002853 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002854 }
2855
Leo Kimaaed3292015-10-12 16:55:38 +09002856 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002857}
2858
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002859/* (austin.2013-07-23)
2860 *
2861 * To support revised cfg80211_ops
2862 *
2863 * add_beacon --> start_ap
2864 * set_beacon --> change_beacon
2865 * del_beacon --> stop_ap
2866 *
2867 * beacon_parameters --> cfg80211_ap_settings
2868 * cfg80211_beacon_data
2869 *
2870 * applicable for linux kernel 3.4+
2871 */
2872
2873/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09002874 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 * @details Add a beacon with given parameters, @head, @interval
2876 * and @dtim_period will be valid, @tail is optional.
2877 * @param[in] wiphy
2878 * @param[in] dev The net device structure
2879 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2880 * @return int : Return 0 on Success.
2881 * @author austin
2882 * @date 23 JUL 2013
2883 * @version 1.0
2884 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09002885static int start_ap(struct wiphy *wiphy, struct net_device *dev,
2886 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002887{
2888 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09002889 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002890 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002891
2892 priv = wiphy_priv(wiphy);
2893 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
2894
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302895 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 +09002896 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
2897
Chaehyun Lim80785a92015-09-14 12:24:01 +09002898 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899
Leo Kime6e12662015-09-16 18:36:03 +09002900 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002901 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002902
Tony Cho7e7fa472015-10-20 14:26:48 +09002903 linux_wlan_set_bssid(dev, g_linux_wlan->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002905 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2906 settings->beacon_interval,
2907 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002908 beacon->head_len, (u8 *)beacon->head,
2909 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910
2911 return s32Error;
2912}
2913
2914/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002915 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002916 * @details Add a beacon with given parameters, @head, @interval
2917 * and @dtim_period will be valid, @tail is optional.
2918 * @param[in] wiphy
2919 * @param[in] dev The net device structure
2920 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2921 * @return int : Return 0 on Success.
2922 * @author austin
2923 * @date 23 JUL 2013
2924 * @version 1.0
2925 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002926static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
2927 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928{
Chaehyun Lim27268872015-09-15 14:06:13 +09002929 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002930 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931
2932 priv = wiphy_priv(wiphy);
2933 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
2934
2935
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002936 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2937 0,
2938 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002939 beacon->head_len, (u8 *)beacon->head,
2940 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941
2942 return s32Error;
2943}
2944
2945/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002946 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002947 * @details Remove beacon configuration and stop sending the beacon.
2948 * @param[in]
2949 * @return int : Return 0 on Success.
2950 * @author austin
2951 * @date 23 JUL 2013
2952 * @version 1.0
2953 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002954static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002955{
Leo Kime6e12662015-09-16 18:36:03 +09002956 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002957 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002958 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959
Leo Kim7ae43362015-09-16 18:35:59 +09002960 if (!wiphy)
2961 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002962
2963 priv = wiphy_priv(wiphy);
2964
2965 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
2966
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002967 linux_wlan_set_bssid(dev, NullBssid);
2968
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002969 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002970
Leo Kim7dc1d0c2015-09-16 18:36:00 +09002971 if (s32Error)
2972 PRINT_ER("Host delete beacon fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002974 return s32Error;
2975}
2976
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977/**
Chaehyun Limed269552015-09-14 12:24:15 +09002978 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979 * @details Add a new station.
2980 * @param[in]
2981 * @return int : Return 0 on Success.
2982 * @author mdaftedar
2983 * @date 01 MAR 2012
2984 * @version 1.0
2985 */
Chaehyun Limed269552015-09-14 12:24:15 +09002986static int add_station(struct wiphy *wiphy, struct net_device *dev,
2987 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002988{
Leo Kime6e12662015-09-16 18:36:03 +09002989 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002990 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09002991 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002992 perInterface_wlan_t *nic;
2993
Leo Kim7ae43362015-09-16 18:35:59 +09002994 if (!wiphy)
2995 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996
2997 priv = wiphy_priv(wiphy);
2998 nic = netdev_priv(dev);
2999
3000 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003001 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3002 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003003 strStaParams.u16AssocID = params->aid;
3004 strStaParams.u8NumRates = params->supported_rates_len;
3005 strStaParams.pu8Rates = params->supported_rates;
3006
3007 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3008
3009 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],
3010 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3011 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3012 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3013
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003014 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003015 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003016 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003017 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3019 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003020 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003021 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3022 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3023 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3024 }
3025
3026 strStaParams.u16FlagsMask = params->sta_flags_mask;
3027 strStaParams.u16FlagsSet = params->sta_flags_set;
3028
3029 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3030 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3031 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3032 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3033 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3034 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3035 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3036 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3037
3038 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003039 if (s32Error)
3040 PRINT_ER("Host add station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041 }
3042
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 return s32Error;
3044}
3045
3046/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003047 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003048 * @details Remove a station; @mac may be NULL to remove all stations.
3049 * @param[in]
3050 * @return int : Return 0 on Success.
3051 * @author mdaftedar
3052 * @date 01 MAR 2012
3053 * @version 1.0
3054 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003055static int del_station(struct wiphy *wiphy, struct net_device *dev,
3056 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003057{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003058 const u8 *mac = params->mac;
Leo Kime6e12662015-09-16 18:36:03 +09003059 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003060 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003061 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003062
Leo Kim7ae43362015-09-16 18:35:59 +09003063 if (!wiphy)
3064 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065
3066 priv = wiphy_priv(wiphy);
3067 nic = netdev_priv(dev);
3068
3069 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3070 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3071
3072
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003073 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303074 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003075 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3076 } else {
3077 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]);
3078 }
3079
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003081
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003082 if (s32Error)
3083 PRINT_ER("Host delete station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084 }
3085 return s32Error;
3086}
3087
3088/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003089 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 * @details Modify a given station.
3091 * @param[in]
3092 * @return int : Return 0 on Success.
3093 * @author mdaftedar
3094 * @date 01 MAR 2012
3095 * @version 1.0
3096 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003097static int change_station(struct wiphy *wiphy, struct net_device *dev,
3098 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003099{
Leo Kime6e12662015-09-16 18:36:03 +09003100 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003101 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09003102 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003103 perInterface_wlan_t *nic;
3104
3105
3106 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3107
Leo Kim7ae43362015-09-16 18:35:59 +09003108 if (!wiphy)
3109 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110
3111 priv = wiphy_priv(wiphy);
3112 nic = netdev_priv(dev);
3113
3114 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003115 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003116 strStaParams.u16AssocID = params->aid;
3117 strStaParams.u8NumRates = params->supported_rates_len;
3118 strStaParams.pu8Rates = params->supported_rates;
3119
3120 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],
3121 strStaParams.au8BSSID[5]);
3122 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3123 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3124
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003125 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003126 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003127 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003128 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3130 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003131 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003132 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3133 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3134 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3135
3136 }
3137
3138 strStaParams.u16FlagsMask = params->sta_flags_mask;
3139 strStaParams.u16FlagsSet = params->sta_flags_set;
3140
3141 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3142 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3143 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3144 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3145 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3146 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3147 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3148 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3149
3150 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003151 if (s32Error)
3152 PRINT_ER("Host edit station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003153 }
3154 return s32Error;
3155}
3156
3157
3158/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003159 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160 * @details
3161 * @param[in]
3162 * @return int : Return 0 on Success.
3163 * @author mdaftedar
3164 * @date 01 JUL 2012
3165 * @version 1.0
3166 */
Chaehyun Lim37316e82015-09-22 18:34:52 +09003167static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
3168 const char *name,
3169 unsigned char name_assign_type,
3170 enum nl80211_iftype type,
3171 u32 *flags,
3172 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003173{
3174 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003175 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003177
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178 priv = wiphy_priv(wiphy);
3179
3180
3181
3182 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3183
3184 nic = netdev_priv(priv->wdev->netdev);
3185
3186
3187 if (type == NL80211_IFTYPE_MONITOR) {
3188 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3189 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3190 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3191 if (new_ifc != NULL) {
3192 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003193 nic = netdev_priv(priv->wdev->netdev);
3194 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003195 } else
3196 PRINT_ER("Error in initializing monitor interface\n ");
3197 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003198 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003199}
3200
3201/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003202 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003203 * @details
3204 * @param[in]
3205 * @return int : Return 0 on Success.
3206 * @author mdaftedar
3207 * @date 01 JUL 2012
3208 * @version 1.0
3209 */
Chaehyun Lim956d7212015-09-22 18:34:49 +09003210static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003211{
3212 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
Leo Kime6e12662015-09-16 18:36:03 +09003213 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214}
3215
Chaehyun Lim08241922015-09-15 14:06:12 +09003216static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217
Chaehyun Lim80785a92015-09-14 12:24:01 +09003218 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003219 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003220 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003221 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003222 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003223 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003224 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003225 .set_default_key = set_default_key,
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003226 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003227 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003228 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229
Chaehyun Lima13168d2015-09-14 12:24:12 +09003230 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003231 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003232 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003233 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003234 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003235 .change_station = change_station,
Chaehyun Limf06f5622015-09-14 12:24:18 +09003236 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003237 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003238 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003239 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240
Chaehyun Lim4d466572015-09-14 12:24:22 +09003241 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003242 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003243 .flush_pmksa = flush_pmksa,
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003244 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003245 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003246 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003247 .mgmt_tx = mgmt_tx,
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09003248 .mgmt_frame_register = wilc_mgmt_frame_register,
Chaehyun Lim46530672015-09-22 18:34:46 +09003249 .set_power_mgmt = set_power_mgmt,
Chaehyun Lima8047e22015-09-22 18:34:48 +09003250 .set_cqm_rssi_config = set_cqm_rssi_config,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003251
3252};
3253
3254
3255
3256
3257
3258/**
3259 * @brief WILC_WFI_update_stats
3260 * @details Modify parameters for a given BSS.
3261 * @param[in]
3262 * @return int : Return 0 on Success.
3263 * @author mdaftedar
3264 * @date 01 MAR 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003265 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266 */
3267int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3268{
3269
Chaehyun Lim27268872015-09-15 14:06:13 +09003270 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003271
3272 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003273 switch (changed) {
3274
3275 case WILC_WFI_RX_PKT:
3276 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003277 priv->netstats.rx_packets++;
3278 priv->netstats.rx_bytes += pktlen;
3279 priv->netstats.rx_time = get_jiffies_64();
3280 }
3281 break;
3282
3283 case WILC_WFI_TX_PKT:
3284 {
3285 priv->netstats.tx_packets++;
3286 priv->netstats.tx_bytes += pktlen;
3287 priv->netstats.tx_time = get_jiffies_64();
3288
3289 }
3290 break;
3291
3292 default:
3293 break;
3294 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003295 return 0;
3296}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003297
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003298/**
3299 * @brief WILC_WFI_CfgAlloc
3300 * @details Allocation of the wireless device structure and assigning it
3301 * to the cfg80211 operations structure.
3302 * @param[in] NONE
3303 * @return wireless_dev : Returns pointer to wireless_dev structure.
3304 * @author mdaftedar
3305 * @date 01 MAR 2012
3306 * @version 1.0
3307 */
3308struct wireless_dev *WILC_WFI_CfgAlloc(void)
3309{
3310
3311 struct wireless_dev *wdev;
3312
3313
3314 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3315 /*Allocating the wireless device structure*/
3316 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3317 if (!wdev) {
3318 PRINT_ER("Cannot allocate wireless device\n");
3319 goto _fail_;
3320 }
3321
3322 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003323 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003324 if (!wdev->wiphy) {
3325 PRINT_ER("Cannot allocate wiphy\n");
3326 goto _fail_mem_;
3327
3328 }
3329
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330 /* enable 802.11n HT */
3331 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3332 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3333 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3334 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3335 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336
3337 /*wiphy bands*/
3338 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3339
3340 return wdev;
3341
3342_fail_mem_:
3343 kfree(wdev);
3344_fail_:
3345 return NULL;
3346
3347}
3348/**
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003349 * @brief wilc_create_wiphy
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350 * @details Registering of the wiphy structure and interface modes
3351 * @param[in] NONE
3352 * @return NONE
3353 * @author mdaftedar
3354 * @date 01 MAR 2012
3355 * @version 1.0
3356 */
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003357struct wireless_dev *wilc_create_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003358{
Chaehyun Lim27268872015-09-15 14:06:13 +09003359 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360 struct wireless_dev *wdev;
Leo Kime6e12662015-09-16 18:36:03 +09003361 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003362
3363 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3364
3365 wdev = WILC_WFI_CfgAlloc();
3366 if (wdev == NULL) {
3367 PRINT_ER("CfgAlloc Failed\n");
3368 return NULL;
3369 }
3370
3371
3372 /*Return hardware description structure (wiphy)'s priv*/
3373 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003374 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003375
3376 /*Link the wiphy with wireless structure*/
3377 priv->wdev = wdev;
3378
3379 /*Maximum number of probed ssid to be added by user for the scan request*/
3380 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 /*Maximum number of pmkids to be cashed*/
3382 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3383 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384
3385 wdev->wiphy->max_scan_ie_len = 1000;
3386
3387 /*signal strength in mBm (100*dBm) */
3388 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3389
3390 /*Set the availaible cipher suites*/
3391 wdev->wiphy->cipher_suites = cipher_suites;
3392 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003393 /*Setting default managment types: for register action frame: */
3394 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396 wdev->wiphy->max_remain_on_channel_duration = 500;
3397 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3398 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3399 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003401 wdev->iftype = NL80211_IFTYPE_STATION;
3402
3403
3404
3405 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3406 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3407 wdev->wiphy->interface_modes, wdev->iftype);
3408
3409 #ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003410 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411 #endif
3412
3413 /*Register wiphy structure*/
3414 s32Error = wiphy_register(wdev->wiphy);
3415 if (s32Error) {
3416 PRINT_ER("Cannot register wiphy device\n");
3417 /*should define what action to be taken in such failure*/
3418 } else {
3419 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3420 }
3421
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003422 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003423 return wdev;
3424
3425
3426}
3427/**
3428 * @brief WILC_WFI_WiphyFree
3429 * @details Freeing allocation of the wireless device structure
3430 * @param[in] NONE
3431 * @return NONE
3432 * @author mdaftedar
3433 * @date 01 MAR 2012
3434 * @version 1.0
3435 */
Chaehyun Limdd4b6a82015-09-20 15:51:25 +09003436int wilc_init_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437{
3438
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003439 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440
Chaehyun Lim27268872015-09-15 14:06:13 +09003441 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3444 priv = wdev_priv(net->ieee80211_ptr);
3445 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003446 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003447 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448 }
3449 op_ifcs++;
3450 if (s32Error < 0) {
3451 PRINT_ER("Failed to creat refresh Timer\n");
3452 return s32Error;
3453 }
3454
Dean Lee72ed4dc2015-06-12 14:11:44 +09003455 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003456
Dean Lee72ed4dc2015-06-12 14:11:44 +09003457 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003458
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003459 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460 s32Error = host_int_init(&priv->hWILCWFIDrv);
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003461 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003462 PRINT_ER("Error while initializing hostinterface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003463
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003464 return s32Error;
3465}
3466
3467/**
3468 * @brief WILC_WFI_WiphyFree
3469 * @details Freeing allocation of the wireless device structure
3470 * @param[in] NONE
3471 * @return NONE
3472 * @author mdaftedar
3473 * @date 01 MAR 2012
3474 * @version 1.0
3475 */
Chaehyun Lima9a16822015-09-20 15:51:24 +09003476int wilc_deinit_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003477{
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003478 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003479
Chaehyun Lim27268872015-09-15 14:06:13 +09003480 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003481
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482 priv = wdev_priv(net->ieee80211_ptr);
3483
Dean Lee72ed4dc2015-06-12 14:11:44 +09003484 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485
Dean Lee72ed4dc2015-06-12 14:11:44 +09003486 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003487
3488 op_ifcs--;
3489
3490 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
3492 /* Clear the Shadow scan */
3493 clear_shadow_scan(priv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494 if (op_ifcs == 0) {
3495 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003496 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003499 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003500 PRINT_ER("Error while deintializing host interface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003501
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003502 return s32Error;
3503}
3504
3505
3506/**
3507 * @brief WILC_WFI_WiphyFree
3508 * @details Freeing allocation of the wireless device structure
3509 * @param[in] NONE
3510 * @return NONE
3511 * @author mdaftedar
3512 * @date 01 MAR 2012
3513 * @version 1.0
3514 */
Chaehyun Lim96da20a2015-09-20 15:51:08 +09003515void wilc_free_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003517 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3518
Chaehyun Lim619837a2015-09-20 15:51:10 +09003519 if (!net) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003520 PRINT_D(INIT_DBG, "net_device is NULL\n");
3521 return;
3522 }
3523
Chaehyun Lim619837a2015-09-20 15:51:10 +09003524 if (!net->ieee80211_ptr) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003525 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3526 return;
3527 }
3528
Chaehyun Lim619837a2015-09-20 15:51:10 +09003529 if (!net->ieee80211_ptr->wiphy) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003530 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3531 return;
3532 }
3533
3534 wiphy_unregister(net->ieee80211_ptr->wiphy);
3535
3536 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3537 wiphy_free(net->ieee80211_ptr->wiphy);
3538 kfree(net->ieee80211_ptr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003539}