blob: bf7a2a22da6262e119997b40157ea5007649c6d5 [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);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090025
26extern int mac_open(struct net_device *ndev);
27extern int mac_close(struct net_device *ndev);
28
29tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090030u32 u32LastScannedNtwrksCountShadow;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070031struct timer_list hDuringIpTimer;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070032struct timer_list hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090033static u8 op_ifcs;
34extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090035
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090036u8 g_wilc_initialized = 1;
Dean Lee72ed4dc2015-06-12 14:11:44 +090037extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090038
39#define CHAN2G(_channel, _freq, _flags) { \
40 .band = IEEE80211_BAND_2GHZ, \
41 .center_freq = (_freq), \
42 .hw_value = (_channel), \
43 .flags = (_flags), \
44 .max_antenna_gain = 0, \
45 .max_power = 30, \
46}
47
48/*Frequency range for channels*/
49static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
50 CHAN2G(1, 2412, 0),
51 CHAN2G(2, 2417, 0),
52 CHAN2G(3, 2422, 0),
53 CHAN2G(4, 2427, 0),
54 CHAN2G(5, 2432, 0),
55 CHAN2G(6, 2437, 0),
56 CHAN2G(7, 2442, 0),
57 CHAN2G(8, 2447, 0),
58 CHAN2G(9, 2452, 0),
59 CHAN2G(10, 2457, 0),
60 CHAN2G(11, 2462, 0),
61 CHAN2G(12, 2467, 0),
62 CHAN2G(13, 2472, 0),
63 CHAN2G(14, 2484, 0),
64};
65
66#define RATETAB_ENT(_rate, _hw_value, _flags) { \
67 .bitrate = (_rate), \
68 .hw_value = (_hw_value), \
69 .flags = (_flags), \
70}
71
72
73/* Table 6 in section 3.2.1.1 */
74static struct ieee80211_rate WILC_WFI_rates[] = {
75 RATETAB_ENT(10, 0, 0),
76 RATETAB_ENT(20, 1, 0),
77 RATETAB_ENT(55, 2, 0),
78 RATETAB_ENT(110, 3, 0),
79 RATETAB_ENT(60, 9, 0),
80 RATETAB_ENT(90, 6, 0),
81 RATETAB_ENT(120, 7, 0),
82 RATETAB_ENT(180, 8, 0),
83 RATETAB_ENT(240, 9, 0),
84 RATETAB_ENT(360, 10, 0),
85 RATETAB_ENT(480, 11, 0),
86 RATETAB_ENT(540, 12, 0),
87};
88
Johnny Kimc5c77ba2015-05-11 14:30:56 +090089struct p2p_mgmt_data {
90 int size;
91 u8 *buff;
92};
93
94/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090095u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090096
Chaehyun Lim866a2c22015-10-02 16:41:21 +090097u8 curr_channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090098
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090099u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
100u8 u8P2Plocalrandom = 0x01;
101u8 u8P2Precvrandom = 0x00;
102u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200103bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900104
105static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
106 .channels = WILC_WFI_2ghz_channels,
107 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
108 .bitrates = WILC_WFI_rates,
109 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
110};
111
112
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900113struct add_key_params {
114 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900115 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900116 u8 *mac_addr;
117};
118struct add_key_params g_add_gtk_key_params;
119struct wilc_wfi_key g_key_gtk_params;
120struct add_key_params g_add_ptk_key_params;
121struct wilc_wfi_key g_key_ptk_params;
122struct wilc_wfi_wep_key g_key_wep_params;
Daniel Machon7fc80962015-08-05 00:09:35 +0200123bool g_ptk_keys_saved;
124bool g_gtk_keys_saved;
125bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900126
127#define AGING_TIME (9 * 1000)
128#define duringIP_TIME 15000
129
130void clear_shadow_scan(void *pUserVoid)
131{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900132 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900133
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900134 if (op_ifcs == 0) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -0700135 del_timer_sync(&hAgingTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900136 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
137
138 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
139 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900140 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900141 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
142 }
143
144 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
145 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
146 }
147 u32LastScannedNtwrksCountShadow = 0;
148 }
149
150}
151
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900152u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153{
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900154 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155 int rssi_v = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900156 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900157
158 for (i = 0; i < num_rssi; i++)
159 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
160
161 rssi_v /= num_rssi;
162 return rssi_v;
163}
164
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900165void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900166{
Chaehyun Lim27268872015-09-15 14:06:13 +0900167 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900168 struct wiphy *wiphy;
169 struct cfg80211_bss *bss = NULL;
170 int i;
171 int rssi = 0;
172
Chaehyun Lim27268872015-09-15 14:06:13 +0900173 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900174 wiphy = priv->dev->ieee80211_ptr->wiphy;
175
176 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
177 tstrNetworkInfo *pstrNetworkInfo;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900178
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900179 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
180
181
182 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900183 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900184 struct ieee80211_channel *channel;
185
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900186 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900187
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900188 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900189 channel = ieee80211_get_channel(wiphy, s32Freq);
190
191 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900192 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900193 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
194 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900195 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900197 }
198 }
199
200 }
201 }
202
203}
204
205void reset_shadow_found(void *pUserVoid)
206{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900207 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900208
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900209 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
210 astrLastScannedNtwrksShadow[i].u8Found = 0;
211
212 }
213}
214
215void update_scan_time(void *pUserVoid)
216{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900217 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900218
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
220 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
221 }
222}
223
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700224static void remove_network_from_shadow(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900225{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900226 unsigned long now = jiffies;
227 int i, j;
228
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900229
230 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
231 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530232 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233
Shraddha Barkecccfc392015-10-12 20:49:19 +0530234 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
235 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900236
237 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
238
239 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
240 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
241 }
242 u32LastScannedNtwrksCountShadow--;
243 }
244 }
245
246 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700247 if (u32LastScannedNtwrksCountShadow != 0) {
248 hAgingTimer.data = arg;
249 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
250 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900251 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700252 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900253}
254
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700255static void clear_duringIP(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900256{
257 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900258 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900259}
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900261int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900262{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900263 int state = -1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900264 int i;
265
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266 if (u32LastScannedNtwrksCountShadow == 0) {
267 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700268 hAgingTimer.data = (unsigned long)pUserVoid;
269 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900270 state = -1;
271 } else {
272 /* Linear search for now */
273 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900274 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900275 pstrNetworkInfo->au8bssid, 6) == 0) {
276 state = i;
277 break;
278 }
279 }
280 }
281 return state;
282}
283
284void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
285{
Chaehyun Lima74cc6b2015-10-02 16:41:17 +0900286 int ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900287 u32 ap_index = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900288 u8 rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900289
290 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
291 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
292 return;
293 }
294 if (ap_found == -1) {
295 ap_index = u32LastScannedNtwrksCountShadow;
296 u32LastScannedNtwrksCountShadow++;
297
298 } else {
299 ap_index = ap_found;
300 }
301 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
302 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
303 if (rssi_index == NUM_RSSI) {
304 rssi_index = 0;
305 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
306 }
307 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
308
309 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
310 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
311
312 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900313 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900314 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
315
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900316 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900317 pstrNetworkInfo->au8bssid, ETH_ALEN);
318
319 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
320 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
321 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
322
323 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
324 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
325 if (ap_found != -1)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900326 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900327 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Glen Leef3052582015-09-10 12:03:04 +0900328 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900329 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900330 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
331
332 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
333 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
334 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
335 if (ap_found != -1)
336 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
337 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
338
339}
340
341
342/**
343 * @brief CfgScanResult
344 * @details Callback function which returns the scan results found
345 *
346 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
347 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
348 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
349 * void* pUserVoid: Private structure associated with the wireless interface
350 * @return NONE
351 * @author mabubakr
352 * @date
353 * @version 1.0
354 */
Leo Kim1ec38152015-10-12 16:55:59 +0900355static void CfgScanResult(enum scan_event enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900356{
Chaehyun Lim27268872015-09-15 14:06:13 +0900357 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900358 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900359 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900360 struct ieee80211_channel *channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361 struct cfg80211_bss *bss = NULL;
362
Chaehyun Lim27268872015-09-15 14:06:13 +0900363 priv = (struct wilc_priv *)pUserVoid;
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +0100364 if (priv->bCfgScanning) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900365 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
366 wiphy = priv->dev->ieee80211_ptr->wiphy;
Leo Kim7ae43362015-09-16 18:35:59 +0900367
368 if (!wiphy)
369 return;
370
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900371 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
372 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900373 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900374 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900375 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376 ) {
Leo Kim24db7132015-09-16 18:36:01 +0900377 PRINT_ER("wiphy signal type fial\n");
378 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900379 }
380
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900381 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900382 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900383 channel = ieee80211_get_channel(wiphy, s32Freq);
384
Leo Kim7ae43362015-09-16 18:35:59 +0900385 if (!channel)
386 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900387
388 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530389 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
391
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +0100392 if (pstrNetworkInfo->bNewNetwork) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900393 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
394 /* max_scan_ssids */
395 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
396
397
398 priv->u32RcvdChCount++;
399
400
401
402 if (pJoinParams == NULL) {
403 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
404 }
405 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
406
407 /*P2P peers are sent to WPA supplicant and added to shadow table*/
408
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900409 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
411 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900412 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900413 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900414 }
415
416
417 } else {
418 PRINT_ER("Discovered networks exceeded the max limit\n");
419 }
420 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900421 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900422 /* So this network is discovered before, we'll just update its RSSI */
423 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900424 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530425 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426
427 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
428 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
429 break;
430 }
431 }
432 }
433 }
434 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530435 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
436 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900437 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530439 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530440 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530441 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530442 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900443
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200444 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900446 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900447 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900448 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900449 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900450 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200452 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900453
454 }
455 /*Aborting any scan operation during mac close*/
456 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200457 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900458
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530459 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900460 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900461
462 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900463 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464
Dean Lee72ed4dc2015-06-12 14:11:44 +0900465 cfg80211_scan_done(priv->pstrScanReq, false);
466 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900467 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900468 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200469 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470 }
471 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472}
473
474
475/**
476 * @brief WILC_WFI_Set_PMKSA
477 * @details Check if pmksa is cached and set it.
478 * @param[in]
479 * @return int : Return 0 on Success
480 * @author mdaftedar
481 * @date 01 MAR 2012
482 * @version 1.0
483 */
Chaehyun Lim27268872015-09-15 14:06:13 +0900484int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900485{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900486 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900487 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900488
489
490 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
491
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900492 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900493 ETH_ALEN)) {
494 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
495
496 /*If bssid is found, set the values*/
497 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
498
Leo Kime6e12662015-09-16 18:36:03 +0900499 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900500 PRINT_ER("Error in pmkid\n");
501
502 break;
503 }
504 }
505
506 return s32Error;
507
508
509}
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900510int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900511
512
513/**
514 * @brief CfgConnectResult
515 * @details
516 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
517 * connection response or disconnection notification.
518 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900519 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900520 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
521 * void* pUserVoid: Private data associated with wireless interface
522 * @return NONE
523 * @author mabubakr
524 * @date 01 MAR 2012
525 * @version 1.0
526 */
527int connecting;
528
Leo Kimed3f0372015-10-12 16:56:01 +0900529static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900530 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900531 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900532 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
533 void *pUserVoid)
534{
Chaehyun Lim27268872015-09-15 14:06:13 +0900535 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900536 struct net_device *dev;
Leo Kim441dc602015-10-12 16:55:35 +0900537 struct host_if_drv *pstrWFIDrv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900538 u8 NullBssid[ETH_ALEN] = {0};
Glen Leec1ec2c12015-10-20 17:13:58 +0900539 struct wilc *wl;
540 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900541
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900542 connecting = 0;
543
Chaehyun Lim27268872015-09-15 14:06:13 +0900544 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900545 dev = priv->dev;
Glen Leec1ec2c12015-10-20 17:13:58 +0900546 nic = netdev_priv(dev);
547 wl = nic->wilc;
Leo Kim441dc602015-10-12 16:55:35 +0900548 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900549
550 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
551 /*Initialization*/
Amitoj Kaur Chawlababa7c72015-10-15 13:48:29 +0530552 u16 u16ConnectStatus;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900553
554 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
555
556 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
557
558 if ((u8MacStatus == MAC_DISCONNECTED) &&
559 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
560 /* The case here is that our station was waiting for association response frame and has just received it containing status code
561 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
562 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
563 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530564 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900565
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900566 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900567 if (!pstrWFIDrv->u8P2PConnect)
568 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530570 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571 }
572
573 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900574 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900575 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900576
577 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
578 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900579 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900580
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900581
582 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900583 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900584 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
585 unsigned long now = jiffies;
586
587 if (time_after(now,
588 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900589 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900590 }
591
592 break;
593 }
594 }
595
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000596 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900597 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900598 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900599
600 }
601
602 }
603
604
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530605 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900606
607 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
608
609 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
610 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
611 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
612 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
613 /* be replaced by pstrConnectInfo->u16ConnectStatus */
614 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900615 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900616 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
617 pstrDisconnectNotifInfo->u16reason, priv->dev);
618 u8P2Plocalrandom = 0x01;
619 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900620 bWilc_ie = false;
Shraddha Barkebcf02652015-10-05 17:00:32 +0530621 eth_zero_addr(priv->au8AssociatedBss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900622 linux_wlan_set_bssid(priv->dev, NullBssid);
Shraddha Barkebcf02652015-10-05 17:00:32 +0530623 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900624
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900625 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900626 if (!pstrWFIDrv->u8P2PConnect)
627 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900628 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
629 * virtual interface to station*/
Glen Leec1ec2c12015-10-20 17:13:58 +0900630 if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900631 pstrDisconnectNotifInfo->u16reason = 3;
632 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900633 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
634 * to scan again and retry the connection*/
Glen Leec1ec2c12015-10-20 17:13:58 +0900635 else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900636 pstrDisconnectNotifInfo->u16reason = 1;
637 }
638 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530639 pstrDisconnectNotifInfo->ie_len, false,
640 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900641
642 }
643
644}
645
646
647/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900648 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900649 * @details Set channel for a given wireless interface. Some devices
650 * may support multi-channel operation (by channel hopping) so cfg80211
651 * doesn't verify much. Note, however, that the passed netdev may be
652 * %NULL as well if the user requested changing the channel for the
653 * device itself, or for a monitor interface.
654 * @param[in]
655 * @return int : Return 0 on Success
656 * @author mdaftedar
657 * @date 01 MAR 2012
658 * @version 1.0
659 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900660static int set_channel(struct wiphy *wiphy,
661 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900662{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900663 u32 channelnum = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +0900664 struct wilc_priv *priv;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900665 int result = 0;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900666
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900667 priv = wiphy_priv(wiphy);
668
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
670 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900671
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900672 curr_channel = channelnum;
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900673 result = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900674
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900675 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900676 PRINT_ER("Error in setting channel %d\n", channelnum);
677
Chaehyun Limdd739ea2015-10-02 16:41:20 +0900678 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900679}
680
681/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900682 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900683 * @details Request to do a scan. If returning zero, the scan request is given
684 * the driver, and will be valid until passed to cfg80211_scan_done().
685 * For scan results, call cfg80211_inform_bss(); you can call this outside
686 * the scan/scan_done bracket too.
687 * @param[in]
688 * @return int : Return 0 on Success
689 * @author mabubakr
690 * @date 01 MAR 2012
691 * @version 1.0
692 */
693
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900694static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900695{
Chaehyun Lim27268872015-09-15 14:06:13 +0900696 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900697 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +0900698 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900699 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Leo Kim607db442015-10-05 15:25:37 +0900700 struct hidden_network strHiddenNetwork;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701
702 priv = wiphy_priv(wiphy);
703
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900704 priv->pstrScanReq = request;
705
706 priv->u32RcvdChCount = 0;
707
Johnny Kim218dc402015-08-13 13:41:19 +0900708 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900709
710
711 reset_shadow_found(priv);
712
Dean Lee72ed4dc2015-06-12 14:11:44 +0900713 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900714 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
715 /* max_scan_ssids */
716 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900717 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900718 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
719 }
720
721 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530722 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900723
724 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
725
726 if (request->n_ssids >= 1) {
727
728
Leo Kim607db442015-10-05 15:25:37 +0900729 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900730 strHiddenNetwork.u8ssidnum = request->n_ssids;
731
732
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900733 for (i = 0; i < request->n_ssids; i++) {
734
735 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900736 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900737 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900738 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
739 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530740 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900741 strHiddenNetwork.u8ssidnum -= 1;
742 }
743 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530744 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900745 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
746 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900747 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900748 CfgScanResult, (void *)priv, &strHiddenNetwork);
749 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530750 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900751 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
752 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900753 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900754 CfgScanResult, (void *)priv, NULL);
755 }
756
757 } else {
758 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530759 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900760 }
761
Leo Kime6e12662015-09-16 18:36:03 +0900762 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763 s32Error = -EBUSY;
764 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
765 }
766
767 return s32Error;
768}
769
770/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900771 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900772 * @details Connect to the ESS with the specified parameters. When connected,
773 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
774 * If the connection fails for some reason, call cfg80211_connect_result()
775 * with the status from the AP.
776 * @param[in]
777 * @return int : Return 0 on Success
778 * @author mabubakr
779 * @date 01 MAR 2012
780 * @version 1.0
781 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900782static int connect(struct wiphy *wiphy, struct net_device *dev,
783 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784{
Leo Kime6e12662015-09-16 18:36:03 +0900785 s32 s32Error = 0;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900786 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900787 u8 u8security = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +0900788 enum AUTHTYPE tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900789 char *pcgroup_encrypt_val = NULL;
790 char *pccipher_group = NULL;
791 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900792
Chaehyun Lim27268872015-09-15 14:06:13 +0900793 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +0900794 struct host_if_drv *pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900795 tstrNetworkInfo *pstrNetworkInfo = NULL;
796
797
798 connecting = 1;
799 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +0900800 pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801
Johnny Kim218dc402015-08-13 13:41:19 +0900802 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900803
Johnny Kim8a143302015-06-10 17:06:46 +0900804 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 +0900805 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900806 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
807 pstrWFIDrv->u8P2PConnect = 1;
808 } else
809 pstrWFIDrv->u8P2PConnect = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530810 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900811
812 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
813 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900814 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900815 sme->ssid,
816 sme->ssid_len) == 0) {
817 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
818 if (sme->bssid == NULL) {
819 /* BSSID is not passed from the user, so decision of matching
820 * is done by SSID only */
821 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
822 break;
823 } else {
824 /* BSSID is also passed from the user, so decision of matching
825 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900826 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900827 sme->bssid,
828 ETH_ALEN) == 0) {
829 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
830 break;
831 }
832 }
833 }
834 }
835
836 if (i < u32LastScannedNtwrksCountShadow) {
837 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
838
839 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
840
841 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
842 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
843 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
844 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
845 } else {
846 s32Error = -ENOENT;
847 if (u32LastScannedNtwrksCountShadow == 0)
848 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
849 else
850 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
851
852 goto done;
853 }
854
855 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900856 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
857 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900858
859 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
860 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
861
862 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
863
864 if (INFO) {
865 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
866 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
867 }
868
869 if (sme->crypto.cipher_group != NO_ENCRYPT) {
870 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
871 * we will add to it the pairwise cipher suite(s) */
872 pcwpa_version = "Default";
873 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900874 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900875 u8security = ENCRYPT_ENABLED | WEP;
876 pcgroup_encrypt_val = "WEP40";
877 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
878 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
879
880 if (INFO) {
881 for (i = 0; i < sme->key_len; i++)
882 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
883 }
884 priv->WILC_WFI_wep_default = sme->key_idx;
885 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900886 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900888 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900889 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900890 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
891 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900892 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900893
Chaehyun Limdf8b4832015-10-26 09:44:45 +0900894 host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
896 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900897 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
898 pcgroup_encrypt_val = "WEP104";
899 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
900
901 priv->WILC_WFI_wep_default = sme->key_idx;
902 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900903 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900904
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900905 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900906 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900907 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
908 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900909 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900910
Chaehyun Limdf8b4832015-10-26 09:44:45 +0900911 host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
913 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900914 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900915 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
916 pcgroup_encrypt_val = "WPA2_TKIP";
917 pccipher_group = "TKIP";
918 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
919 /* tenuSecurity_t = WPA2_AES; */
920 u8security = ENCRYPT_ENABLED | WPA2 | AES;
921 pcgroup_encrypt_val = "WPA2_AES";
922 pccipher_group = "AES";
923 }
924 pcwpa_version = "WPA_VERSION_2";
925 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
926 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927 u8security = ENCRYPT_ENABLED | WPA | TKIP;
928 pcgroup_encrypt_val = "WPA_TKIP";
929 pccipher_group = "TKIP";
930 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
931 /* tenuSecurity_t = WPA_AES; */
932 u8security = ENCRYPT_ENABLED | WPA | AES;
933 pcgroup_encrypt_val = "WPA_AES";
934 pccipher_group = "AES";
935
936 }
937 pcwpa_version = "WPA_VERSION_1";
938
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900939 } else {
940 s32Error = -ENOTSUPP;
941 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
942
943 goto done;
944 }
945
946 }
947
948 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
949 * add to it the pairwise cipher suite(s) */
950 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
951 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
952 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
953 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
954 u8security = u8security | TKIP;
955 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
956 u8security = u8security | AES;
957 }
958 }
959 }
960
961 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
962
963 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
964 switch (sme->auth_type) {
965 case NL80211_AUTHTYPE_OPEN_SYSTEM:
966 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
967 tenuAuth_type = OPEN_SYSTEM;
968 break;
969
970 case NL80211_AUTHTYPE_SHARED_KEY:
971 tenuAuth_type = SHARED_KEY;
972 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
973 break;
974
975 default:
976 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
977 }
978
979
980 /* ai: key_mgmt: enterprise case */
981 if (sme->crypto.n_akm_suites) {
982 switch (sme->crypto.akm_suites[0]) {
983 case WLAN_AKM_SUITE_8021X:
984 tenuAuth_type = IEEE8021;
985 break;
986
987 default:
988 break;
989 }
990 }
991
992
993 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
994
995 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
996 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
997
Chaehyun Lim866a2c22015-10-02 16:41:21 +0900998 curr_channel = pstrNetworkInfo->u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900999
1000 if (!pstrWFIDrv->u8P2PConnect) {
1001 u8WLANChannel = pstrNetworkInfo->u8channel;
1002 }
1003
1004 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1005
1006 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1007 sme->ssid_len, sme->ie, sme->ie_len,
1008 CfgConnectResult, (void *)priv, u8security,
1009 tenuAuth_type, pstrNetworkInfo->u8channel,
1010 pstrNetworkInfo->pJoinParams);
Leo Kime6e12662015-09-16 18:36:03 +09001011 if (s32Error != 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301012 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001013 s32Error = -ENOENT;
1014 goto done;
1015 }
1016
1017done:
1018
1019 return s32Error;
1020}
1021
1022
1023/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001024 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001025 * @details Disconnect from the BSS/ESS.
1026 * @param[in]
1027 * @return int : Return 0 on Success
1028 * @author mdaftedar
1029 * @date 01 MAR 2012
1030 * @version 1.0
1031 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001032static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001033{
Leo Kime6e12662015-09-16 18:36:03 +09001034 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09001035 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09001036 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim51e825f2015-09-15 14:06:14 +09001037 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001038
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001039 connecting = 0;
1040 priv = wiphy_priv(wiphy);
1041
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001042 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
Leo Kim441dc602015-10-12 16:55:35 +09001043 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 if (!pstrWFIDrv->u8P2PConnect)
1045 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001046 linux_wlan_set_bssid(priv->dev, NullBssid);
1047
1048 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1049
1050 u8P2Plocalrandom = 0x01;
1051 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001052 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001053 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054
1055 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
Leo Kime6e12662015-09-16 18:36:03 +09001056 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1058 s32Error = -EINVAL;
1059 }
1060
1061 return s32Error;
1062}
1063
1064/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001065 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001066 * @details Add a key with the given parameters. @mac_addr will be %NULL
1067 * when adding a group key.
1068 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1069 * @return int : Return 0 on Success
1070 * @author mdaftedar
1071 * @date 01 MAR 2012
1072 * @version 1.0
1073 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001074static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1075 bool pairwise,
1076 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001077
1078{
Leo Kime6e12662015-09-16 18:36:03 +09001079 s32 s32Error = 0, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001080 u32 i;
Chaehyun Lim27268872015-09-15 14:06:13 +09001081 struct wilc_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001082 const u8 *pu8RxMic = NULL;
1083 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001084 u8 u8mode = NO_ENCRYPT;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001085 u8 u8gmode = NO_ENCRYPT;
1086 u8 u8pmode = NO_ENCRYPT;
Leo Kim841dfc42015-10-05 15:25:39 +09001087 enum AUTHTYPE tenuAuth_type = ANY;
Glen Lee76469202015-10-20 17:13:59 +09001088 struct wilc *wl;
1089 perInterface_wlan_t *nic;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001090
1091 priv = wiphy_priv(wiphy);
Glen Lee76469202015-10-20 17:13:59 +09001092 nic = netdev_priv(netdev);
1093 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001094
1095 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1096
Johnny Kim8a143302015-06-10 17:06:46 +09001097 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001098
1099 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1100 params->key[1],
1101 params->key[2]);
1102
1103
1104 switch (params->cipher) {
1105 case WLAN_CIPHER_SUITE_WEP40:
1106 case WLAN_CIPHER_SUITE_WEP104:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001107 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1108
1109 priv->WILC_WFI_wep_default = key_index;
1110 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001111 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001112
1113 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1114 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1115
1116 for (i = 0; i < params->key_len; i++)
1117 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1118
1119 tenuAuth_type = OPEN_SYSTEM;
1120
1121 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1122 u8mode = ENCRYPT_ENABLED | WEP;
1123 else
1124 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1125
1126 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1127 break;
1128 }
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001129 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001130 priv->WILC_WFI_wep_default = key_index;
1131 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001132 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133
1134 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1135 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1136 if (INFO) {
1137 for (i = 0; i < params->key_len; i++)
1138 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1139 }
1140 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1141 }
1142
1143 break;
1144
1145 case WLAN_CIPHER_SUITE_TKIP:
1146 case WLAN_CIPHER_SUITE_CCMP:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1148
1149 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001150 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001151 priv->wilc_gtk[key_index]->key = NULL;
1152 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153
1154 }
1155 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001156 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001157 priv->wilc_ptk[key_index]->key = NULL;
1158 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001159 }
1160
1161
1162
Daniel Machon19132212015-08-05 08:18:31 +02001163 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001164 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1165 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1166 else
1167 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1168
1169 priv->wilc_groupkey = u8gmode;
1170
1171 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1172
1173 pu8TxMic = params->key + 24;
1174 pu8RxMic = params->key + 16;
1175 KeyLen = params->key_len - 16;
1176 }
1177 /* 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 +05301178 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179
Glen Leef3052582015-09-10 12:03:04 +09001180 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001181 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182
1183 /* 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 +05301184 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185
1186 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001187 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001188 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001189 }
1190
1191 priv->wilc_gtk[key_index]->cipher = params->cipher;
1192 priv->wilc_gtk[key_index]->key_len = params->key_len;
1193 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1194
1195 if (INFO) {
1196 for (i = 0; i < params->key_len; i++)
1197 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1198 for (i = 0; i < params->seq_len; i++)
1199 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1200 }
1201
1202
1203 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1204 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1205
1206 } else {
1207 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]);
1208
1209 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1210 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1211 else
1212 u8pmode = priv->wilc_groupkey | AES;
1213
1214
1215 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1216
1217 pu8TxMic = params->key + 24;
1218 pu8RxMic = params->key + 16;
1219 KeyLen = params->key_len - 16;
1220 }
1221
Shraddha Barkecccfc392015-10-12 20:49:19 +05301222 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001223
Glen Leef3052582015-09-10 12:03:04 +09001224 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001225
Shraddha Barkecccfc392015-10-12 20:49:19 +05301226 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001227
1228 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001229 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001230
1231 if (INFO) {
1232 for (i = 0; i < params->key_len; i++)
1233 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1234
1235 for (i = 0; i < params->seq_len; i++)
1236 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1237 }
1238
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001239 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001240
1241 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001242 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001243
1244 priv->wilc_ptk[key_index]->cipher = params->cipher;
1245 priv->wilc_ptk[key_index]->key_len = params->key_len;
1246 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1247
1248 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1249 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1250 }
1251 break;
1252 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001253
1254 {
1255 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001256 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001257 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1258 /* swap the tx mic by rx mic */
1259 pu8RxMic = params->key + 24;
1260 pu8TxMic = params->key + 16;
1261 KeyLen = params->key_len - 16;
1262 }
1263
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001264 /*save keys only on interface 0 (wifi interface)*/
Glen Lee76469202015-10-20 17:13:59 +09001265 if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001266 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001268 if (!mac_addr) {
1269 g_add_gtk_key_params.mac_addr = NULL;
1270 } else {
Glen Leef3052582015-09-10 12:03:04 +09001271 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1273 }
1274 g_key_gtk_params.key_len = params->key_len;
1275 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001276 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001277 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1278 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001279 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1281 }
1282 g_key_gtk_params.cipher = params->cipher;
1283
1284 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1285 g_key_gtk_params.key[1],
1286 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001287 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001288 }
1289
1290 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1291 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001292 } else {
1293 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1294 /* swap the tx mic by rx mic */
1295 pu8RxMic = params->key + 24;
1296 pu8TxMic = params->key + 16;
1297 KeyLen = params->key_len - 16;
1298 }
1299
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001300 /*save keys only on interface 0 (wifi interface)*/
Glen Lee76469202015-10-20 17:13:59 +09001301 if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001302 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001303 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001304 if (!mac_addr) {
1305 g_add_ptk_key_params.mac_addr = NULL;
1306 } else {
Glen Leef3052582015-09-10 12:03:04 +09001307 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001308 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1309 }
1310 g_key_ptk_params.key_len = params->key_len;
1311 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001312 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1314 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001315 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001316 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1317 }
1318 g_key_ptk_params.cipher = params->cipher;
1319
1320 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1321 g_key_ptk_params.key[1],
1322 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001323 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324 }
1325
1326 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1327 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1328 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1329 if (INFO) {
1330 for (i = 0; i < params->key_len; i++)
1331 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1332 }
1333 }
1334 }
1335 break;
1336
1337 default:
1338 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1339 s32Error = -ENOTSUPP;
1340
1341 }
1342
1343 return s32Error;
1344}
1345
1346/**
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001347 * @brief del_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348 * @details Remove a key given the @mac_addr (%NULL for a group key)
1349 * and @key_index, return -ENOENT if the key doesn't exist.
1350 * @param[in]
1351 * @return int : Return 0 on Success
1352 * @author mdaftedar
1353 * @date 01 MAR 2012
1354 * @version 1.0
1355 */
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001356static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1357 u8 key_index,
1358 bool pairwise,
1359 const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360{
Chaehyun Lim27268872015-09-15 14:06:13 +09001361 struct wilc_priv *priv;
Glen Lee692e2ac2015-10-20 17:14:00 +09001362 struct wilc *wl;
1363 perInterface_wlan_t *nic;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001364
1365 priv = wiphy_priv(wiphy);
Glen Lee692e2ac2015-10-20 17:14:00 +09001366 nic = netdev_priv(netdev);
1367 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001368
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001369 /*delete saved keys, if any*/
Glen Lee692e2ac2015-10-20 17:14:00 +09001370 if (netdev == wl->vif[0].ndev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001371 g_ptk_keys_saved = false;
1372 g_gtk_keys_saved = false;
1373 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001374
1375 /*Delete saved WEP keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301376 kfree(g_key_wep_params.key);
1377 g_key_wep_params.key = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001378
1379 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1380
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001381 if ((priv->wilc_gtk[key_index]) != NULL) {
1382
Shraddha Barkecccfc392015-10-12 20:49:19 +05301383 kfree(priv->wilc_gtk[key_index]->key);
1384 priv->wilc_gtk[key_index]->key = NULL;
1385 kfree(priv->wilc_gtk[key_index]->seq);
1386 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001387
Chaehyun Lim49188af2015-08-11 10:32:41 +09001388 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001389 priv->wilc_gtk[key_index] = NULL;
1390
1391 }
1392
1393 if ((priv->wilc_ptk[key_index]) != NULL) {
1394
Shraddha Barkecccfc392015-10-12 20:49:19 +05301395 kfree(priv->wilc_ptk[key_index]->key);
1396 priv->wilc_ptk[key_index]->key = NULL;
1397 kfree(priv->wilc_ptk[key_index]->seq);
1398 priv->wilc_ptk[key_index]->seq = NULL;
Chaehyun Lim49188af2015-08-11 10:32:41 +09001399 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001400 priv->wilc_ptk[key_index] = NULL;
1401 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001402
1403 /*Delete saved PTK and GTK keys params, if any*/
Shraddha Barkecccfc392015-10-12 20:49:19 +05301404 kfree(g_key_ptk_params.key);
1405 g_key_ptk_params.key = NULL;
1406 kfree(g_key_ptk_params.seq);
1407 g_key_ptk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408
Shraddha Barkecccfc392015-10-12 20:49:19 +05301409 kfree(g_key_gtk_params.key);
1410 g_key_gtk_params.key = NULL;
1411 kfree(g_key_gtk_params.seq);
1412 g_key_gtk_params.seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001413
1414 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Glen Lee178c3832015-10-27 18:27:58 +09001415 Set_machw_change_vir_if(netdev, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001416 }
1417
1418 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001419 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001420 priv->WILC_WFI_wep_key_len[key_index] = 0;
1421
1422 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1423 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1424 } else {
1425 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1426 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1427 }
1428
Leo Kimaaed3292015-10-12 16:55:38 +09001429 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001430}
1431
1432/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001433 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001434 * @details Get information about the key with the given parameters.
1435 * @mac_addr will be %NULL when requesting information for a group
1436 * key. All pointers given to the @callback function need not be valid
1437 * after it returns. This function should return an error if it is
1438 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1439 * @param[in]
1440 * @return int : Return 0 on Success
1441 * @author mdaftedar
1442 * @date 01 MAR 2012
1443 * @version 1.0
1444 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001445static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1446 bool pairwise,
1447 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001448{
Chaehyun Lim27268872015-09-15 14:06:13 +09001449 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001450 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001451 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001452
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 priv = wiphy_priv(wiphy);
1454
1455
Alison Schofield3604af52015-10-12 13:22:44 -07001456 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001457 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1458
1459 key_params.key = priv->wilc_gtk[key_index]->key;
1460 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1461 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1462 key_params.seq = priv->wilc_gtk[key_index]->seq;
1463 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1464 if (INFO) {
1465 for (i = 0; i < key_params.key_len; i++)
1466 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1467 }
1468 } else {
1469 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1470
1471 key_params.key = priv->wilc_ptk[key_index]->key;
1472 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1473 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1474 key_params.seq = priv->wilc_ptk[key_index]->seq;
1475 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1476 }
1477
1478 callback(cookie, &key_params);
1479
Leo Kimaaed3292015-10-12 16:55:38 +09001480 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481}
1482
1483/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001484 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001485 * @details Set the default management frame key on an interface
1486 * @param[in]
1487 * @return int : Return 0 on Success.
1488 * @author mdaftedar
1489 * @date 01 MAR 2012
1490 * @version 1.0
1491 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001492static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1493 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001494{
Chaehyun Lim27268872015-09-15 14:06:13 +09001495 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001496
1497
1498 priv = wiphy_priv(wiphy);
1499
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301500 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001501
1502 if (key_index != priv->WILC_WFI_wep_default) {
1503
Chaehyun Limdf8b4832015-10-26 09:44:45 +09001504 host_int_set_wep_default_key(priv->hWILCWFIDrv, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001505 }
1506
Leo Kimaaed3292015-10-12 16:55:38 +09001507 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001508}
1509
1510/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001511 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512 * @details Get station information for the station identified by @mac
1513 * @param[in] NONE
1514 * @return int : Return 0 on Success.
1515 * @author mdaftedar
1516 * @date 01 MAR 2012
1517 * @version 1.0
1518 */
1519
Chaehyun Limf06f5622015-09-14 12:24:18 +09001520static int get_station(struct wiphy *wiphy, struct net_device *dev,
1521 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001522{
Chaehyun Lim27268872015-09-15 14:06:13 +09001523 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001524 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001525 u32 i = 0;
1526 u32 associatedsta = 0;
1527 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528 priv = wiphy_priv(wiphy);
1529 nic = netdev_priv(dev);
1530
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001531 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1532 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1533
1534 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1535
1536 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1537
1538 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1539 associatedsta = i;
1540 break;
1541 }
1542
1543 }
1544
1545 if (associatedsta == -1) {
Leo Kimaaed3292015-10-12 16:55:38 +09001546 PRINT_ER("Station required is not associated\n");
1547 return -ENOENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001548 }
1549
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001550 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551
1552 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1553 sinfo->inactive_time = 1000 * inactive_time;
1554 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1555
1556 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001557
1558 if (nic->iftype == STATION_MODE) {
Leo Kim03e7b9c2015-10-12 16:55:58 +09001559 struct rf_info strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001560
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001561 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1562
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001563 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301564 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001565 BIT(NL80211_STA_INFO_TX_PACKETS) |
1566 BIT(NL80211_STA_INFO_TX_FAILED) |
1567 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001568
1569 sinfo->signal = strStatistics.s8RSSI;
1570 sinfo->rx_packets = strStatistics.u32RxCount;
1571 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001573 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1574
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301575 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001576 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301577 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001578 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001580 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1581 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001582 }
Leo Kimaaed3292015-10-12 16:55:38 +09001583 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001584}
1585
1586
1587/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001588 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001589 * @details Modify parameters for a given BSS.
1590 * @param[in]
1591 * -use_cts_prot: Whether to use CTS protection
1592 * (0 = no, 1 = yes, -1 = do not change)
1593 * -use_short_preamble: Whether the use of short preambles is allowed
1594 * (0 = no, 1 = yes, -1 = do not change)
1595 * -use_short_slot_time: Whether the use of short slot time is allowed
1596 * (0 = no, 1 = yes, -1 = do not change)
1597 * -basic_rates: basic rates in IEEE 802.11 format
1598 * (or NULL for no change)
1599 * -basic_rates_len: number of basic rates
1600 * -ap_isolate: do not forward packets between connected stations
1601 * -ht_opmode: HT Operation mode
1602 * (u16 = opmode, -1 = do not change)
1603 * @return int : Return 0 on Success.
1604 * @author mdaftedar
1605 * @date 01 MAR 2012
1606 * @version 1.0
1607 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001608static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1609 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001610{
1611 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1612 return 0;
1613}
1614
1615/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001616 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001617 * @details Notify that wiphy parameters have changed;
1618 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1619 * have changed.
1620 * @return int : Return 0 on Success
1621 * @author mdaftedar
1622 * @date 01 MAR 2012
1623 * @version 1.0
1624 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001625static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001626{
Leo Kime6e12662015-09-16 18:36:03 +09001627 s32 s32Error = 0;
Leo Kim95296502015-10-05 15:25:46 +09001628 struct cfg_param_val pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001629 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001630
1631 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632
Tony Cho87c05b22015-10-12 16:56:07 +09001633 pstrCfgParamVal.flag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301634 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001635
1636 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1637 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1638 priv->dev->ieee80211_ptr->wiphy->retry_short);
Tony Cho87c05b22015-10-12 16:56:07 +09001639 pstrCfgParamVal.flag |= RETRY_SHORT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001640 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1641 }
1642 if (changed & WIPHY_PARAM_RETRY_LONG) {
1643
1644 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 +09001645 pstrCfgParamVal.flag |= RETRY_LONG;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001646 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1647
1648 }
1649 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1650 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 +09001651 pstrCfgParamVal.flag |= FRAG_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001652 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1653
1654 }
1655
1656 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1657 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1658
Tony Cho87c05b22015-10-12 16:56:07 +09001659 pstrCfgParamVal.flag |= RTS_THRESHOLD;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001660 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1661
1662 }
1663
1664 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1665 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1666 if (s32Error)
1667 PRINT_ER("Error in setting WIPHY PARAMS\n");
1668
1669
1670 return s32Error;
1671}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001672
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001673/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001674 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1676 * devices running firmwares capable of generating the (re) association
1677 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1678 * @param[in]
1679 * @return int : Return 0 on Success
1680 * @author mdaftedar
1681 * @date 01 MAR 2012
1682 * @version 1.0
1683 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001684static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1685 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001687 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001688 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001689 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690
Chaehyun Lim27268872015-09-15 14:06:13 +09001691 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001692
1693 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1694
1695
1696 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001697 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698 ETH_ALEN)) {
1699 /*If bssid already exists and pmkid value needs to reset*/
1700 flag = PMKID_FOUND;
1701 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1702 break;
1703 }
1704 }
1705 if (i < WILC_MAX_NUM_PMKIDS) {
1706 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001707 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001709 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710 PMKID_LEN);
1711 if (!(flag == PMKID_FOUND))
1712 priv->pmkid_list.numpmkid++;
1713 } else {
1714 PRINT_ER("Invalid PMKID index\n");
1715 s32Error = -EINVAL;
1716 }
1717
1718 if (!s32Error) {
1719 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1720 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1721 }
1722 return s32Error;
1723}
1724
1725/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001726 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001727 * @details Delete a cached PMKID.
1728 * @param[in]
1729 * @return int : Return 0 on Success
1730 * @author mdaftedar
1731 * @date 01 MAR 2012
1732 * @version 1.0
1733 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001734static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1735 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001736{
1737
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001738 u32 i;
Leo Kime6e12662015-09-16 18:36:03 +09001739 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001740
Chaehyun Lim27268872015-09-15 14:06:13 +09001741 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001742
1743 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1744
1745 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001746 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001747 ETH_ALEN)) {
1748 /*If bssid is found, reset the values*/
1749 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Leo Kimcd1e6cb2015-10-05 15:25:45 +09001750 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001751 break;
1752 }
1753 }
1754
1755 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1756 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001757 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001758 priv->pmkid_list.pmkidlist[i + 1].bssid,
1759 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001760 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001761 priv->pmkid_list.pmkidlist[i].pmkid,
1762 PMKID_LEN);
1763 }
1764 priv->pmkid_list.numpmkid--;
1765 } else {
1766 s32Error = -EINVAL;
1767 }
1768
1769 return s32Error;
1770}
1771
1772/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001773 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001774 * @details Flush all cached PMKIDs.
1775 * @param[in]
1776 * @return int : Return 0 on Success
1777 * @author mdaftedar
1778 * @date 01 MAR 2012
1779 * @version 1.0
1780 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001781static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001782{
Chaehyun Lim27268872015-09-15 14:06:13 +09001783 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784
1785 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1786
1787 /*Get cashed Pmkids and set all with zeros*/
Leo Kima949f902015-10-05 15:25:44 +09001788 memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789
1790 return 0;
1791}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001793
1794/**
1795 * @brief WILC_WFI_CfgParseRxAction
1796 * @details Function parses the received frames and modifies the following attributes:
1797 * -GO Intent
1798 * -Channel list
1799 * -Operating Channel
1800 *
1801 * @param[in] u8* Buffer, u32 length
1802 * @return NONE.
1803 * @author mdaftedar
1804 * @date 12 DEC 2012
1805 * @version
1806 */
1807
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001808void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001809{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001810 u32 index = 0;
1811 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001813 u8 op_channel_attr_index = 0;
1814 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815
1816 while (index < len) {
1817 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001818 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819 }
1820
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301821 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001822 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301823 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825 index += buf[index + 1] + 3; /* ID,Length byte */
1826 }
Alison Schofield3604af52015-10-12 13:22:44 -07001827 if (u8WLANChannel != INVALID_CHANNEL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001828
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001829 /*Modify channel list attribute*/
1830 if (channel_list_attr_index) {
1831 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1832 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1833 if (buf[i] == 0x51) {
1834 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1835 buf[j] = u8WLANChannel;
1836 }
1837 break;
1838 }
1839 }
1840 }
1841 /*Modify operating channel attribute*/
1842 if (op_channel_attr_index) {
1843 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1844 buf[op_channel_attr_index + 6] = 0x51;
1845 buf[op_channel_attr_index + 7] = u8WLANChannel;
1846 }
1847 }
1848}
1849
1850/**
1851 * @brief WILC_WFI_CfgParseTxAction
1852 * @details Function parses the transmitted action frames and modifies the
1853 * GO Intent attribute
1854 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1855 * @return NONE.
1856 * @author mdaftedar
1857 * @date 12 DEC 2012
1858 * @version
1859 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09001860void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001861{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001862 u32 index = 0;
1863 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001864
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001865 u8 op_channel_attr_index = 0;
1866 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867
1868 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001869 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871
1872 break;
1873 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301875 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001876 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301877 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001878 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 index += buf[index + 1] + 3; /* ID,Length byte */
1880 }
Alison Schofield3604af52015-10-12 13:22:44 -07001881 if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001882
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001883 /*Modify channel list attribute*/
1884 if (channel_list_attr_index) {
1885 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
1886 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
1887 if (buf[i] == 0x51) {
1888 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
1889 buf[j] = u8WLANChannel;
1890 }
1891 break;
1892 }
1893 }
1894 }
1895 /*Modify operating channel attribute*/
1896 if (op_channel_attr_index) {
1897 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
1898 buf[op_channel_attr_index + 6] = 0x51;
1899 buf[op_channel_attr_index + 7] = u8WLANChannel;
1900 }
1901 }
1902}
1903
1904/* @brief WILC_WFI_p2p_rx
1905 * @details
1906 * @param[in]
1907 *
1908 * @return None
1909 * @author Mai Daftedar
1910 * @date 2 JUN 2013
1911 * @version 1.0
1912 */
1913
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09001914void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915{
1916
Chaehyun Lim27268872015-09-15 14:06:13 +09001917 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001918 u32 header, pkt_offset;
Leo Kim441dc602015-10-12 16:55:35 +09001919 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001920 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001921 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001922
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001923 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09001924 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925
1926 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001927 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001928
1929 /* The packet offset field conain info about what type of managment frame */
1930 /* we are dealing with and ack status */
1931 pkt_offset = GET_PKT_OFFSET(header);
1932
1933 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
1934 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
1935 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001936 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001937 return;
1938 } else {
1939 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
1940 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],
1941 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001942 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001943 } else {
1944 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],
1945 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001946 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001947 }
1948 return;
1949 }
1950 } else {
1951
1952 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
1953
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954 /*Upper layer is informed that the frame is received on this freq*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09001955 s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956
1957 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
1958 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
1959
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01001960 if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001961 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
1962 return;
1963 }
1964 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
1965
1966 switch (buff[ACTION_SUBTYPE_ID]) {
1967 case GAS_INTIAL_REQ:
1968 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
1969 break;
1970
1971 case GAS_INTIAL_RSP:
1972 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
1973 break;
1974
1975 case PUBLIC_ACT_VENDORSPEC:
1976 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
1977 * 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 +09001978 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001979 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
1980 if (!bWilc_ie) {
1981 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001982 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001983 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09001984 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001985 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
1986 break;
1987 }
1988 }
1989 }
1990 }
1991 if (u8P2Plocalrandom > u8P2Precvrandom) {
1992 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
1993 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
1994 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001995 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
1997 break;
1998 }
1999 }
2000 }
2001 } else
2002 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2003 }
2004
2005
2006 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2007 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2008 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002009 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002010 return;
2011 }
2012 break;
2013
2014 default:
2015 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2016 break;
2017 }
2018 }
2019 }
2020
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022 }
2023}
2024
2025/**
2026 * @brief WILC_WFI_mgmt_tx_complete
2027 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2028 * @param[in] priv
2029 * transmitting status
2030 * @return None
2031 * @author Amr Abdelmoghny
2032 * @date 20 MAY 2013
2033 * @version 1.0
2034 */
2035static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2036{
2037 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2038
2039
2040 kfree(pv_data->buff);
2041 kfree(pv_data);
2042}
2043
2044/**
2045 * @brief WILC_WFI_RemainOnChannelReady
2046 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2047 * @param
2048 * @return none
2049 * @author Amr abdelmoghny
2050 * @date 9 JUNE 2013
2051 * @version
2052 */
2053
2054static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2055{
Chaehyun Lim27268872015-09-15 14:06:13 +09002056 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002057
Chaehyun Lim27268872015-09-15 14:06:13 +09002058 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002059
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302060 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061
Dean Lee72ed4dc2015-06-12 14:11:44 +09002062 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002063
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002064 cfg80211_ready_on_channel(priv->wdev,
2065 priv->strRemainOnChanParams.u64ListenCookie,
2066 priv->strRemainOnChanParams.pstrListenChan,
2067 priv->strRemainOnChanParams.u32ListenDuration,
2068 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002069}
2070
2071/**
2072 * @brief WILC_WFI_RemainOnChannelExpired
2073 * @details Callback function, called on expiration of remain-on-channel duration
2074 * @param
2075 * @return none
2076 * @author Amr abdelmoghny
2077 * @date 15 MAY 2013
2078 * @version
2079 */
2080
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002081static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082{
Chaehyun Lim27268872015-09-15 14:06:13 +09002083 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002084
Chaehyun Lim27268872015-09-15 14:06:13 +09002085 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002086
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002087 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302088 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002089
Dean Lee72ed4dc2015-06-12 14:11:44 +09002090 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091
2092 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002093 cfg80211_remain_on_channel_expired(priv->wdev,
2094 priv->strRemainOnChanParams.u64ListenCookie,
2095 priv->strRemainOnChanParams.pstrListenChan,
2096 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 } else {
2098 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2099 , priv->strRemainOnChanParams.u32ListenSessionID);
2100 }
2101}
2102
2103
2104/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002105 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002106 * @details Request the driver to remain awake on the specified
2107 * channel for the specified duration to complete an off-channel
2108 * operation (e.g., public action frame exchange). When the driver is
2109 * ready on the requested channel, it must indicate this with an event
2110 * notification by calling cfg80211_ready_on_channel().
2111 * @param[in]
2112 * @return int : Return 0 on Success
2113 * @author mdaftedar
2114 * @date 01 MAR 2012
2115 * @version 1.0
2116 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002117static int remain_on_channel(struct wiphy *wiphy,
2118 struct wireless_dev *wdev,
2119 struct ieee80211_channel *chan,
2120 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121{
Leo Kime6e12662015-09-16 18:36:03 +09002122 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002123 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002124
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125 priv = wiphy_priv(wiphy);
2126
2127 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2128
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002129
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002130 if (wdev->iftype == NL80211_IFTYPE_AP) {
2131 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2132 return s32Error;
2133 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002134
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002135 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002136
2137 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2138 priv->strRemainOnChanParams.pstrListenChan = chan;
2139 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002140 priv->strRemainOnChanParams.u32ListenDuration = duration;
2141 priv->strRemainOnChanParams.u32ListenSessionID++;
2142
2143 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2144 , priv->strRemainOnChanParams.u32ListenSessionID
2145 , duration
2146 , chan->hw_value
2147 , WILC_WFI_RemainOnChannelExpired
2148 , WILC_WFI_RemainOnChannelReady
2149 , (void *)priv);
2150
2151 return s32Error;
2152}
2153
2154/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002155 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002156 * @details Cancel an on-going remain-on-channel operation.
2157 * This allows the operation to be terminated prior to timeout based on
2158 * the duration value.
2159 * @param[in] struct wiphy *wiphy,
2160 * @param[in] struct net_device *dev
2161 * @param[in] u64 cookie,
2162 * @return int : Return 0 on Success
2163 * @author mdaftedar
2164 * @date 01 MAR 2012
2165 * @version 1.0
2166 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002167static int cancel_remain_on_channel(struct wiphy *wiphy,
2168 struct wireless_dev *wdev,
2169 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170{
Leo Kime6e12662015-09-16 18:36:03 +09002171 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002172 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002173
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002174 priv = wiphy_priv(wiphy);
2175
2176 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2177
2178 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2179 return s32Error;
2180}
2181/**
2182 * @brief WILC_WFI_add_wilcvendorspec
2183 * @details Adding WILC information elemet to allow two WILC devices to
2184 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002185 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186 * @return void
2187 * @author mdaftedar
2188 * @date 01 JAN 2014
2189 * @version 1.0
2190 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002191void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002192{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002193 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002194}
2195/**
2196 * @brief WILC_WFI_mgmt_tx_frame
2197 * @details
2198 *
2199 * @param[in]
2200 * @return NONE.
2201 * @author mdaftedar
2202 * @date 01 JUL 2012
2203 * @version
2204 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002205extern bool bEnablePS;
Chaehyun Limc1560322015-09-22 18:34:51 +09002206static int mgmt_tx(struct wiphy *wiphy,
2207 struct wireless_dev *wdev,
2208 struct cfg80211_mgmt_tx_params *params,
2209 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211 struct ieee80211_channel *chan = params->chan;
2212 unsigned int wait = params->wait;
2213 const u8 *buf = params->buf;
2214 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215 const struct ieee80211_mgmt *mgmt;
2216 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002217 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002218 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002219 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002220 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002221 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002222
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002225 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002226
2227 *cookie = (unsigned long)buf;
2228 priv->u64tx_cookie = *cookie;
2229 mgmt = (const struct ieee80211_mgmt *) buf;
2230
2231 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2232
2233 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002234 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 if (mgmt_tx == NULL) {
2236 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
Leo Kime6e12662015-09-16 18:36:03 +09002237 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002238 }
Glen Leef3052582015-09-10 12:03:04 +09002239 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002240 if (mgmt_tx->buff == NULL) {
2241 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002242 kfree(mgmt_tx);
Leo Kime6e12662015-09-16 18:36:03 +09002243 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002244 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002245 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002246 mgmt_tx->size = len;
2247
2248
2249 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2250 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2251 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2252 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2253 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002254 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002256 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002257
2258
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002260 /*Only set the channel, if not a negotiation confirmation frame
2261 * (If Negotiation confirmation frame, force it
2262 * to be transmitted on the same negotiation channel)*/
2263
2264 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2265 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2266 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2267 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2268 /*Save the current channel after we tune to it*/
Chaehyun Lim866a2c22015-10-02 16:41:21 +09002269 curr_channel = chan->hw_value;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270 }
2271 switch (buf[ACTION_SUBTYPE_ID]) {
2272 case GAS_INTIAL_REQ:
2273 {
2274 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2275 break;
2276 }
2277
2278 case GAS_INTIAL_RSP:
2279 {
2280 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2281 break;
2282 }
2283
2284 case PUBLIC_ACT_VENDORSPEC:
2285 {
2286 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2287 * 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 +09002288 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002289 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2290 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2291 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2292 get_random_bytes(&u8P2Plocalrandom, 1);
2293 /*Increment the number to prevent if its 0*/
2294 u8P2Plocalrandom++;
2295 }
2296 }
2297
2298 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2299 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2300 if (u8P2Plocalrandom > u8P2Precvrandom) {
2301 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2302
2303 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2304 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002305 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002307 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309 /*If using supplicant go intent, no need at all*/
2310 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002311 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002312 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002313 break;
2314 }
2315 }
2316
2317 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2318 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2319 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2320 mgmt_tx->size = buf_len;
2321 }
2322 } else
2323 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2324 }
2325
2326 } else {
2327 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2328 }
2329
2330 break;
2331 }
2332
2333 default:
2334 {
2335 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2336 break;
2337 }
2338 }
2339
2340 }
2341
2342 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2343 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2344
2345 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2346
2347 }
2348
Glen Leec9d48342015-10-01 16:03:43 +09002349 wilc_wlan_txq_add_mgmt_pkt(mgmt_tx, mgmt_tx->buff,
2350 mgmt_tx->size,
2351 WILC_WFI_mgmt_tx_complete);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002352 } else {
2353 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2354 }
Leo Kimaaed3292015-10-12 16:55:38 +09002355 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002356}
2357
Chaehyun Lim85c587a2015-09-22 18:34:50 +09002358static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2359 struct wireless_dev *wdev,
2360 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361{
Chaehyun Lim27268872015-09-15 14:06:13 +09002362 struct wilc_priv *priv;
Leo Kim441dc602015-10-12 16:55:35 +09002363 struct host_if_drv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002364
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002365 priv = wiphy_priv(wiphy);
Leo Kim441dc602015-10-12 16:55:35 +09002366 pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002367
2368
2369 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2370 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2371
Luis de Bethencourt7e4e87d2015-10-16 16:32:26 +01002372 if (!priv->bInP2PlistenState) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002373 cfg80211_remain_on_channel_expired(priv->wdev,
2374 priv->strRemainOnChanParams.u64ListenCookie,
2375 priv->strRemainOnChanParams.pstrListenChan,
2376 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377 }
2378
2379 return 0;
2380}
2381
2382/**
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002383 * @brief wilc_mgmt_frame_register
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002384 * @details Notify driver that a management frame type was
2385 * registered. Note that this callback may not sleep, and cannot run
2386 * concurrently with itself.
2387 * @param[in]
2388 * @return NONE.
2389 * @author mdaftedar
2390 * @date 01 JUL 2012
2391 * @version
2392 */
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09002393void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
2394 u16 frame_type, bool reg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002395{
2396
Chaehyun Lim27268872015-09-15 14:06:13 +09002397 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398 perInterface_wlan_t *nic;
Glen Lee1b869352015-10-20 17:14:01 +09002399 struct wilc *wl;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002400
2401 priv = wiphy_priv(wiphy);
2402 nic = netdev_priv(priv->wdev->netdev);
Glen Lee1b869352015-10-20 17:14:01 +09002403 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002404
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405 if (!frame_type)
2406 return;
2407
2408 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2409 switch (frame_type) {
2410 case PROBE_REQ:
2411 {
2412 nic->g_struct_frame_reg[0].frame_type = frame_type;
2413 nic->g_struct_frame_reg[0].reg = reg;
2414 }
2415 break;
2416
2417 case ACTION:
2418 {
2419 nic->g_struct_frame_reg[1].frame_type = frame_type;
2420 nic->g_struct_frame_reg[1].reg = reg;
2421 }
2422 break;
2423
2424 default:
2425 {
2426 break;
2427 }
2428
2429 }
2430 /*If mac is closed, then return*/
Glen Lee1b869352015-10-20 17:14:01 +09002431 if (!wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2433 return;
2434 }
2435 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2436
2437
2438}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439
2440/**
Chaehyun Lima8047e22015-09-22 18:34:48 +09002441 * @brief set_cqm_rssi_config
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002442 * @details Configure connection quality monitor RSSI threshold.
2443 * @param[in] struct wiphy *wiphy:
2444 * @param[in] struct net_device *dev:
2445 * @param[in] s32 rssi_thold:
2446 * @param[in] u32 rssi_hyst:
2447 * @return int : Return 0 on Success
2448 * @author mdaftedar
2449 * @date 01 MAR 2012
2450 * @version 1.0
2451 */
Chaehyun Lima8047e22015-09-22 18:34:48 +09002452static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev,
2453 s32 rssi_thold, u32 rssi_hyst)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002454{
2455 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2456 return 0;
2457
2458}
2459/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002460 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461 * @details Configure connection quality monitor RSSI threshold.
2462 * @param[in] struct wiphy *wiphy:
2463 * @param[in] struct net_device *dev
2464 * @param[in] int idx
2465 * @param[in] u8 *mac
2466 * @param[in] struct station_info *sinfo
2467 * @return int : Return 0 on Success
2468 * @author mdaftedar
2469 * @date 01 MAR 2012
2470 * @version 1.0
2471 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002472static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2473 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002474{
Chaehyun Lim27268872015-09-15 14:06:13 +09002475 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002476
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2478
2479 if (idx != 0)
2480 return -ENOENT;
2481
2482 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002483
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485
2486 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2487
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002488 return 0;
2489
2490}
2491
2492
2493/**
Chaehyun Lim46530672015-09-22 18:34:46 +09002494 * @brief set_power_mgmt
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002495 * @details
2496 * @param[in]
2497 * @return int : Return 0 on Success.
2498 * @author mdaftedar
2499 * @date 01 JUL 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09002500 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002501 */
Chaehyun Lim46530672015-09-22 18:34:46 +09002502static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2503 bool enabled, int timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504{
Chaehyun Lim27268872015-09-15 14:06:13 +09002505 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002506
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002507 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2508
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002509 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002510 return -ENOENT;
2511
2512 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002513 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002514 PRINT_ER("Driver is NULL\n");
2515 return -EIO;
2516 }
2517
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002518 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002519 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2520
2521
Leo Kime6e12662015-09-16 18:36:03 +09002522 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523
2524}
Glen Lee108b3432015-09-16 18:53:20 +09002525
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002527 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528 * @details Change type/configuration of virtual interface,
2529 * keep the struct wireless_dev's iftype updated.
2530 * @param[in] NONE
2531 * @return int : Return 0 on Success.
2532 * @author mdaftedar
2533 * @date 01 MAR 2012
2534 * @version 1.0
2535 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002536int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2537
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002538static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2539 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002540{
Chaehyun Lim27268872015-09-15 14:06:13 +09002541 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002542 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002543 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002544 u16 TID = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002545 u8 i;
Glen Lee299382c2015-10-20 17:13:56 +09002546 struct wilc *wl;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002547
2548 nic = netdev_priv(dev);
2549 priv = wiphy_priv(wiphy);
Glen Lee299382c2015-10-20 17:13:56 +09002550 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002551
2552 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2553 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2554 u8P2Plocalrandom = 0x01;
2555 u8P2Precvrandom = 0x00;
2556
Dean Lee72ed4dc2015-06-12 14:11:44 +09002557 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558
Dean Lee72ed4dc2015-06-12 14:11:44 +09002559 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002560 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002561 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002562 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2563 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Glen Lee178c3832015-10-27 18:27:58 +09002564 Set_machw_change_vir_if(dev, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002565 }
2566
2567 switch (type) {
2568 case NL80211_IFTYPE_STATION:
2569 connecting = 0;
2570 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002571
2572 /* send delba over wlan interface */
2573
2574
2575 dev->ieee80211_ptr->iftype = type;
2576 priv->wdev->iftype = type;
2577 nic->monitor_flag = 0;
2578 nic->iftype = STATION_MODE;
2579
2580 /*Remove the enteries of the previously connected clients*/
2581 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002582 interface_type = nic->iftype;
2583 nic->iftype = STATION_MODE;
2584
Glen Lee299382c2015-10-20 17:13:56 +09002585 if (wl->initialized) {
2586 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2587 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002588 /* ensure that the message Q is empty */
2589 host_int_wait_msg_queue_idle();
2590
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002591 /*Eliminate host interface blocking state*/
Glen Lee299382c2015-10-20 17:13:56 +09002592 up(&wl->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593
Glen Lee53dc0cf2015-10-20 17:13:57 +09002594 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002595 wilc1000_wlan_init(dev, nic);
2596 g_wilc_initialized = 1;
2597 nic->iftype = interface_type;
2598
2599 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002600 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2601 host_int_set_MacAddress(wl->vif[0].hif_drv,
2602 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002603 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2604
2605 /*Add saved WEP keys, if any*/
2606 if (g_wep_keys_saved) {
Chaehyun Limdf8b4832015-10-26 09:44:45 +09002607 host_int_set_wep_default_key(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002609 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610 g_key_wep_params.key,
2611 g_key_wep_params.key_len,
2612 g_key_wep_params.key_idx);
2613 }
2614
2615 /*No matter the driver handler passed here, it will be overwriiten*/
2616 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2617 host_int_flush_join_req(priv->hWILCWFIDrv);
2618
2619 /*Add saved PTK and GTK keys, if any*/
2620 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2621 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2622 g_key_ptk_params.key[1],
2623 g_key_ptk_params.key[2]);
2624 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2625 g_key_gtk_params.key[1],
2626 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002627 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2628 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002629 g_add_ptk_key_params.key_idx,
2630 g_add_ptk_key_params.pairwise,
2631 g_add_ptk_key_params.mac_addr,
2632 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633
Glen Lee299382c2015-10-20 17:13:56 +09002634 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2635 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002636 g_add_gtk_key_params.key_idx,
2637 g_add_gtk_key_params.pairwise,
2638 g_add_gtk_key_params.mac_addr,
2639 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002640 }
2641
Glen Lee299382c2015-10-20 17:13:56 +09002642 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 for (i = 0; i < num_reg_frame; i++) {
2644 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2645 nic->g_struct_frame_reg[i].reg);
2646 host_int_frame_register(priv->hWILCWFIDrv,
2647 nic->g_struct_frame_reg[i].frame_type,
2648 nic->g_struct_frame_reg[i].reg);
2649 }
2650 }
2651
Dean Lee72ed4dc2015-06-12 14:11:44 +09002652 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002653 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2654 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002655 break;
2656
2657 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002658 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2660 connecting = 0;
2661 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002662
Glen Lee299382c2015-10-20 17:13:56 +09002663 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2664 wl->vif[0].bssid, TID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665
2666 dev->ieee80211_ptr->iftype = type;
2667 priv->wdev->iftype = type;
2668 nic->monitor_flag = 0;
2669
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2671 nic->iftype = CLIENT_MODE;
2672
2673
Glen Lee299382c2015-10-20 17:13:56 +09002674 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675 /* ensure that the message Q is empty */
2676 host_int_wait_msg_queue_idle();
2677
Glen Lee53dc0cf2015-10-20 17:13:57 +09002678 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002679 wilc1000_wlan_init(dev, nic);
2680 g_wilc_initialized = 1;
2681
Glen Lee299382c2015-10-20 17:13:56 +09002682 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2683 host_int_set_MacAddress(wl->vif[0].hif_drv,
2684 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002685 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2686
2687 /*Add saved WEP keys, if any*/
2688 if (g_wep_keys_saved) {
Chaehyun Limdf8b4832015-10-26 09:44:45 +09002689 host_int_set_wep_default_key(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002690 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002691 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002692 g_key_wep_params.key,
2693 g_key_wep_params.key_len,
2694 g_key_wep_params.key_idx);
2695 }
2696
2697 /*No matter the driver handler passed here, it will be overwriiten*/
2698 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2699 host_int_flush_join_req(priv->hWILCWFIDrv);
2700
2701 /*Add saved PTK and GTK keys, if any*/
2702 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2703 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2704 g_key_ptk_params.key[1],
2705 g_key_ptk_params.key[2]);
2706 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2707 g_key_gtk_params.key[1],
2708 g_key_gtk_params.key[2]);
Glen Lee299382c2015-10-20 17:13:56 +09002709 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2710 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002711 g_add_ptk_key_params.key_idx,
2712 g_add_ptk_key_params.pairwise,
2713 g_add_ptk_key_params.mac_addr,
2714 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715
Glen Lee299382c2015-10-20 17:13:56 +09002716 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2717 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002718 g_add_gtk_key_params.key_idx,
2719 g_add_gtk_key_params.pairwise,
2720 g_add_gtk_key_params.mac_addr,
2721 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002722 }
2723
2724 /*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 +09002725 refresh_scan(priv, 1, true);
Glen Lee178c3832015-10-27 18:27:58 +09002726 Set_machw_change_vir_if(dev, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002727
Glen Lee299382c2015-10-20 17:13:56 +09002728 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002729 for (i = 0; i < num_reg_frame; i++) {
2730 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2731 nic->g_struct_frame_reg[i].reg);
2732 host_int_frame_register(priv->hWILCWFIDrv,
2733 nic->g_struct_frame_reg[i].frame_type,
2734 nic->g_struct_frame_reg[i].reg);
2735 }
2736 }
2737 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002738 break;
2739
2740 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002741 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002743 dev->ieee80211_ptr->iftype = type;
2744 priv->wdev->iftype = type;
2745 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002746 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2749 linux_wlan_get_firmware(nic);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002750 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
Glen Lee299382c2015-10-20 17:13:56 +09002751 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002752 nic->iftype = AP_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 mac_close(dev);
2754 mac_open(dev);
2755
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002756 for (i = 0; i < num_reg_frame; i++) {
2757 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2758 nic->g_struct_frame_reg[i].reg);
2759 host_int_frame_register(priv->hWILCWFIDrv,
2760 nic->g_struct_frame_reg[i].frame_type,
2761 nic->g_struct_frame_reg[i].reg);
2762 }
2763 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002764 break;
2765
2766 case NL80211_IFTYPE_P2P_GO:
2767 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
2768
Dean Lee72ed4dc2015-06-12 14:11:44 +09002769 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002770 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 /*Delete block ack has to be the latest config packet*/
2773 /*sent before downloading new FW. This is because it blocks on*/
2774 /*hWaitResponse semaphore, which allows previous config*/
2775 /*packets to actually take action on old FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002776 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
2777 wl->vif[0].bssid, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002778 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 dev->ieee80211_ptr->iftype = type;
2781 priv->wdev->iftype = type;
2782
Johnny Kim8a143302015-06-10 17:06:46 +09002783 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2786
2787
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002788 nic->iftype = GO_MODE;
2789
2790 /* ensure that the message Q is empty */
2791 host_int_wait_msg_queue_idle();
Glen Lee53dc0cf2015-10-20 17:13:57 +09002792 wilc1000_wlan_deinit(dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002793 wilc1000_wlan_init(dev, nic);
2794 g_wilc_initialized = 1;
2795
2796
2797 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
Glen Lee299382c2015-10-20 17:13:56 +09002798 host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
2799 host_int_set_MacAddress(wl->vif[0].hif_drv,
2800 wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
2802
2803 /*Add saved WEP keys, if any*/
2804 if (g_wep_keys_saved) {
Chaehyun Limdf8b4832015-10-26 09:44:45 +09002805 host_int_set_wep_default_key(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002806 g_key_wep_params.key_idx);
Glen Lee299382c2015-10-20 17:13:56 +09002807 host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002808 g_key_wep_params.key,
2809 g_key_wep_params.key_len,
2810 g_key_wep_params.key_idx);
2811 }
2812
2813 /*No matter the driver handler passed here, it will be overwriiten*/
2814 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2815 host_int_flush_join_req(priv->hWILCWFIDrv);
2816
2817 /*Add saved PTK and GTK keys, if any*/
2818 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2819 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
2820 g_key_ptk_params.key[1],
2821 g_key_ptk_params.key[2],
2822 g_key_ptk_params.cipher);
2823 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
2824 g_key_gtk_params.key[1],
2825 g_key_gtk_params.key[2],
2826 g_key_gtk_params.cipher);
Glen Lee299382c2015-10-20 17:13:56 +09002827 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2828 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002829 g_add_ptk_key_params.key_idx,
2830 g_add_ptk_key_params.pairwise,
2831 g_add_ptk_key_params.mac_addr,
2832 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002833
Glen Lee299382c2015-10-20 17:13:56 +09002834 add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
2835 wl->vif[0].ndev,
Chaehyun Lim953d4172015-09-14 12:24:05 +09002836 g_add_gtk_key_params.key_idx,
2837 g_add_gtk_key_params.pairwise,
2838 g_add_gtk_key_params.mac_addr,
2839 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002840 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841
Glen Lee299382c2015-10-20 17:13:56 +09002842 if (wl->initialized) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843 for (i = 0; i < num_reg_frame; i++) {
2844 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2845 nic->g_struct_frame_reg[i].reg);
2846 host_int_frame_register(priv->hWILCWFIDrv,
2847 nic->g_struct_frame_reg[i].frame_type,
2848 nic->g_struct_frame_reg[i].reg);
2849 }
2850 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 break;
2852
2853 default:
2854 PRINT_ER("Unknown interface type= %d\n", type);
Leo Kimaaed3292015-10-12 16:55:38 +09002855 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002856 }
2857
Leo Kimaaed3292015-10-12 16:55:38 +09002858 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002859}
2860
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002861/* (austin.2013-07-23)
2862 *
2863 * To support revised cfg80211_ops
2864 *
2865 * add_beacon --> start_ap
2866 * set_beacon --> change_beacon
2867 * del_beacon --> stop_ap
2868 *
2869 * beacon_parameters --> cfg80211_ap_settings
2870 * cfg80211_beacon_data
2871 *
2872 * applicable for linux kernel 3.4+
2873 */
2874
2875/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09002876 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002877 * @details Add a beacon with given parameters, @head, @interval
2878 * and @dtim_period will be valid, @tail is optional.
2879 * @param[in] wiphy
2880 * @param[in] dev The net device structure
2881 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2882 * @return int : Return 0 on Success.
2883 * @author austin
2884 * @date 23 JUL 2013
2885 * @version 1.0
2886 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09002887static int start_ap(struct wiphy *wiphy, struct net_device *dev,
2888 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889{
2890 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09002891 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002892 s32 s32Error = 0;
Glen Lee684dc182015-10-20 17:14:02 +09002893 struct wilc *wl;
2894 perInterface_wlan_t *nic;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895
2896 priv = wiphy_priv(wiphy);
Glen Lee684dc182015-10-20 17:14:02 +09002897 nic = netdev_priv(dev);
2898 wl = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
2900
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302901 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 +09002902 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
2903
Chaehyun Lim80785a92015-09-14 12:24:01 +09002904 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002905
Leo Kime6e12662015-09-16 18:36:03 +09002906 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002908
Glen Lee684dc182015-10-20 17:14:02 +09002909 linux_wlan_set_bssid(dev, wl->vif[0].src_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002911 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2912 settings->beacon_interval,
2913 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002914 beacon->head_len, (u8 *)beacon->head,
2915 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002916
2917 return s32Error;
2918}
2919
2920/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002921 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002922 * @details Add a beacon with given parameters, @head, @interval
2923 * and @dtim_period will be valid, @tail is optional.
2924 * @param[in] wiphy
2925 * @param[in] dev The net device structure
2926 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2927 * @return int : Return 0 on Success.
2928 * @author austin
2929 * @date 23 JUL 2013
2930 * @version 1.0
2931 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09002932static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
2933 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934{
Chaehyun Lim27268872015-09-15 14:06:13 +09002935 struct wilc_priv *priv;
Leo Kime6e12662015-09-16 18:36:03 +09002936 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937
2938 priv = wiphy_priv(wiphy);
2939 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
2940
2941
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
2943 0,
2944 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002945 beacon->head_len, (u8 *)beacon->head,
2946 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002947
2948 return s32Error;
2949}
2950
2951/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002952 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002953 * @details Remove beacon configuration and stop sending the beacon.
2954 * @param[in]
2955 * @return int : Return 0 on Success.
2956 * @author austin
2957 * @date 23 JUL 2013
2958 * @version 1.0
2959 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09002960static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002961{
Leo Kime6e12662015-09-16 18:36:03 +09002962 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002963 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002964 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965
Leo Kim7ae43362015-09-16 18:35:59 +09002966 if (!wiphy)
2967 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002968
2969 priv = wiphy_priv(wiphy);
2970
2971 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
2972
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973 linux_wlan_set_bssid(dev, NullBssid);
2974
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002976
Leo Kim7dc1d0c2015-09-16 18:36:00 +09002977 if (s32Error)
2978 PRINT_ER("Host delete beacon fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002980 return s32Error;
2981}
2982
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983/**
Chaehyun Limed269552015-09-14 12:24:15 +09002984 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985 * @details Add a new station.
2986 * @param[in]
2987 * @return int : Return 0 on Success.
2988 * @author mdaftedar
2989 * @date 01 MAR 2012
2990 * @version 1.0
2991 */
Chaehyun Limed269552015-09-14 12:24:15 +09002992static int add_station(struct wiphy *wiphy, struct net_device *dev,
2993 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002994{
Leo Kime6e12662015-09-16 18:36:03 +09002995 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09002996 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09002997 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998 perInterface_wlan_t *nic;
2999
Leo Kim7ae43362015-09-16 18:35:59 +09003000 if (!wiphy)
3001 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003002
3003 priv = wiphy_priv(wiphy);
3004 nic = netdev_priv(dev);
3005
3006 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003007 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3008 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003009 strStaParams.u16AssocID = params->aid;
3010 strStaParams.u8NumRates = params->supported_rates_len;
3011 strStaParams.pu8Rates = params->supported_rates;
3012
3013 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3014
3015 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],
3016 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3017 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3018 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3019
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003020 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003021 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003022 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003023 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3025 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003026 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3028 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3029 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3030 }
3031
3032 strStaParams.u16FlagsMask = params->sta_flags_mask;
3033 strStaParams.u16FlagsSet = params->sta_flags_set;
3034
3035 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3036 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3037 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3038 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3039 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3040 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3041 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3042 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3043
3044 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003045 if (s32Error)
3046 PRINT_ER("Host add station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003047 }
3048
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049 return s32Error;
3050}
3051
3052/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003053 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054 * @details Remove a station; @mac may be NULL to remove all stations.
3055 * @param[in]
3056 * @return int : Return 0 on Success.
3057 * @author mdaftedar
3058 * @date 01 MAR 2012
3059 * @version 1.0
3060 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003061static int del_station(struct wiphy *wiphy, struct net_device *dev,
3062 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003063{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003064 const u8 *mac = params->mac;
Leo Kime6e12662015-09-16 18:36:03 +09003065 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003066 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003068
Leo Kim7ae43362015-09-16 18:35:59 +09003069 if (!wiphy)
3070 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003071
3072 priv = wiphy_priv(wiphy);
3073 nic = netdev_priv(dev);
3074
3075 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3076 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3077
3078
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003079 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303080 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003081 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3082 } else {
3083 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]);
3084 }
3085
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003086 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003087
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003088 if (s32Error)
3089 PRINT_ER("Host delete station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 }
3091 return s32Error;
3092}
3093
3094/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003095 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096 * @details Modify a given station.
3097 * @param[in]
3098 * @return int : Return 0 on Success.
3099 * @author mdaftedar
3100 * @date 01 MAR 2012
3101 * @version 1.0
3102 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003103static int change_station(struct wiphy *wiphy, struct net_device *dev,
3104 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003105{
Leo Kime6e12662015-09-16 18:36:03 +09003106 s32 s32Error = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +09003107 struct wilc_priv *priv;
Tony Cho6a89ba92015-09-21 12:16:46 +09003108 struct add_sta_param strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109 perInterface_wlan_t *nic;
3110
3111
3112 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3113
Leo Kim7ae43362015-09-16 18:35:59 +09003114 if (!wiphy)
3115 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003116
3117 priv = wiphy_priv(wiphy);
3118 nic = netdev_priv(dev);
3119
3120 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003121 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003122 strStaParams.u16AssocID = params->aid;
3123 strStaParams.u8NumRates = params->supported_rates_len;
3124 strStaParams.pu8Rates = params->supported_rates;
3125
3126 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],
3127 strStaParams.au8BSSID[5]);
3128 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3129 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3130
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003131 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003132 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003134 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003135 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3136 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003137 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003138 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3139 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3140 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3141
3142 }
3143
3144 strStaParams.u16FlagsMask = params->sta_flags_mask;
3145 strStaParams.u16FlagsSet = params->sta_flags_set;
3146
3147 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3148 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3149 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3150 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3151 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3152 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3153 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3154 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3155
3156 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003157 if (s32Error)
3158 PRINT_ER("Host edit station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003159 }
3160 return s32Error;
3161}
3162
3163
3164/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003165 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166 * @details
3167 * @param[in]
3168 * @return int : Return 0 on Success.
3169 * @author mdaftedar
3170 * @date 01 JUL 2012
3171 * @version 1.0
3172 */
Chaehyun Lim37316e82015-09-22 18:34:52 +09003173static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
3174 const char *name,
3175 unsigned char name_assign_type,
3176 enum nl80211_iftype type,
3177 u32 *flags,
3178 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003179{
3180 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003181 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003182 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003183
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003184 priv = wiphy_priv(wiphy);
3185
3186
3187
3188 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3189
3190 nic = netdev_priv(priv->wdev->netdev);
3191
3192
3193 if (type == NL80211_IFTYPE_MONITOR) {
3194 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3195 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3196 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3197 if (new_ifc != NULL) {
3198 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003199 nic = netdev_priv(priv->wdev->netdev);
3200 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201 } else
3202 PRINT_ER("Error in initializing monitor interface\n ");
3203 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003205}
3206
3207/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003208 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003209 * @details
3210 * @param[in]
3211 * @return int : Return 0 on Success.
3212 * @author mdaftedar
3213 * @date 01 JUL 2012
3214 * @version 1.0
3215 */
Chaehyun Lim956d7212015-09-22 18:34:49 +09003216static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217{
3218 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
Leo Kime6e12662015-09-16 18:36:03 +09003219 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003220}
3221
Chaehyun Lim08241922015-09-15 14:06:12 +09003222static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003223
Chaehyun Lim80785a92015-09-14 12:24:01 +09003224 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003225 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003226 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003227 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003228 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003229 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003230 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003231 .set_default_key = set_default_key,
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003232 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003233 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003234 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235
Chaehyun Lima13168d2015-09-14 12:24:12 +09003236 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003237 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003238 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003239 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003240 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003241 .change_station = change_station,
Chaehyun Limf06f5622015-09-14 12:24:18 +09003242 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003243 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003244 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003245 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003246
Chaehyun Lim4d466572015-09-14 12:24:22 +09003247 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003248 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003249 .flush_pmksa = flush_pmksa,
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003250 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003251 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003252 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003253 .mgmt_tx = mgmt_tx,
Chaehyun Lim8e0735c2015-09-20 15:51:16 +09003254 .mgmt_frame_register = wilc_mgmt_frame_register,
Chaehyun Lim46530672015-09-22 18:34:46 +09003255 .set_power_mgmt = set_power_mgmt,
Chaehyun Lima8047e22015-09-22 18:34:48 +09003256 .set_cqm_rssi_config = set_cqm_rssi_config,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003257
3258};
3259
3260
3261
3262
3263
3264/**
3265 * @brief WILC_WFI_update_stats
3266 * @details Modify parameters for a given BSS.
3267 * @param[in]
3268 * @return int : Return 0 on Success.
3269 * @author mdaftedar
3270 * @date 01 MAR 2012
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003271 * @version 1.0
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003272 */
3273int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3274{
3275
Chaehyun Lim27268872015-09-15 14:06:13 +09003276 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003277
3278 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279 switch (changed) {
3280
3281 case WILC_WFI_RX_PKT:
3282 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003283 priv->netstats.rx_packets++;
3284 priv->netstats.rx_bytes += pktlen;
3285 priv->netstats.rx_time = get_jiffies_64();
3286 }
3287 break;
3288
3289 case WILC_WFI_TX_PKT:
3290 {
3291 priv->netstats.tx_packets++;
3292 priv->netstats.tx_bytes += pktlen;
3293 priv->netstats.tx_time = get_jiffies_64();
3294
3295 }
3296 break;
3297
3298 default:
3299 break;
3300 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301 return 0;
3302}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003303
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003304/**
3305 * @brief WILC_WFI_CfgAlloc
3306 * @details Allocation of the wireless device structure and assigning it
3307 * to the cfg80211 operations structure.
3308 * @param[in] NONE
3309 * @return wireless_dev : Returns pointer to wireless_dev structure.
3310 * @author mdaftedar
3311 * @date 01 MAR 2012
3312 * @version 1.0
3313 */
3314struct wireless_dev *WILC_WFI_CfgAlloc(void)
3315{
3316
3317 struct wireless_dev *wdev;
3318
3319
3320 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3321 /*Allocating the wireless device structure*/
3322 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3323 if (!wdev) {
3324 PRINT_ER("Cannot allocate wireless device\n");
3325 goto _fail_;
3326 }
3327
3328 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003329 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330 if (!wdev->wiphy) {
3331 PRINT_ER("Cannot allocate wiphy\n");
3332 goto _fail_mem_;
3333
3334 }
3335
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336 /* enable 802.11n HT */
3337 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3338 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3339 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3340 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3341 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342
3343 /*wiphy bands*/
3344 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3345
3346 return wdev;
3347
3348_fail_mem_:
3349 kfree(wdev);
3350_fail_:
3351 return NULL;
3352
3353}
3354/**
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003355 * @brief wilc_create_wiphy
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356 * @details Registering of the wiphy structure and interface modes
3357 * @param[in] NONE
3358 * @return NONE
3359 * @author mdaftedar
3360 * @date 01 MAR 2012
3361 * @version 1.0
3362 */
Chaehyun Lim8459fd52015-09-20 15:51:09 +09003363struct wireless_dev *wilc_create_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003364{
Chaehyun Lim27268872015-09-15 14:06:13 +09003365 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003366 struct wireless_dev *wdev;
Leo Kime6e12662015-09-16 18:36:03 +09003367 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003368
3369 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3370
3371 wdev = WILC_WFI_CfgAlloc();
3372 if (wdev == NULL) {
3373 PRINT_ER("CfgAlloc Failed\n");
3374 return NULL;
3375 }
3376
3377
3378 /*Return hardware description structure (wiphy)'s priv*/
3379 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003380 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381
3382 /*Link the wiphy with wireless structure*/
3383 priv->wdev = wdev;
3384
3385 /*Maximum number of probed ssid to be added by user for the scan request*/
3386 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387 /*Maximum number of pmkids to be cashed*/
3388 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3389 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003390
3391 wdev->wiphy->max_scan_ie_len = 1000;
3392
3393 /*signal strength in mBm (100*dBm) */
3394 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3395
3396 /*Set the availaible cipher suites*/
3397 wdev->wiphy->cipher_suites = cipher_suites;
3398 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 /*Setting default managment types: for register action frame: */
3400 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003401
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003402 wdev->wiphy->max_remain_on_channel_duration = 500;
3403 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3404 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3405 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003406 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 wdev->iftype = NL80211_IFTYPE_STATION;
3408
3409
3410
3411 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3412 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3413 wdev->wiphy->interface_modes, wdev->iftype);
3414
3415 #ifdef WILC_SDIO
Chaehyun Limcdc9cba2015-09-22 18:34:47 +09003416 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003417 #endif
3418
3419 /*Register wiphy structure*/
3420 s32Error = wiphy_register(wdev->wiphy);
3421 if (s32Error) {
3422 PRINT_ER("Cannot register wiphy device\n");
3423 /*should define what action to be taken in such failure*/
3424 } else {
3425 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3426 }
3427
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003428 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003429 return wdev;
3430
3431
3432}
3433/**
3434 * @brief WILC_WFI_WiphyFree
3435 * @details Freeing allocation of the wireless device structure
3436 * @param[in] NONE
3437 * @return NONE
3438 * @author mdaftedar
3439 * @date 01 MAR 2012
3440 * @version 1.0
3441 */
Chaehyun Limdd4b6a82015-09-20 15:51:25 +09003442int wilc_init_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443{
3444
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003445 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003446
Chaehyun Lim27268872015-09-15 14:06:13 +09003447 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3450 priv = wdev_priv(net->ieee80211_ptr);
3451 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003452 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003453 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454 }
3455 op_ifcs++;
3456 if (s32Error < 0) {
3457 PRINT_ER("Failed to creat refresh Timer\n");
3458 return s32Error;
3459 }
3460
Dean Lee72ed4dc2015-06-12 14:11:44 +09003461 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003462
Dean Lee72ed4dc2015-06-12 14:11:44 +09003463 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003464
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003465 sema_init(&(priv->hSemScanReq), 1);
Glen Leed53822192015-10-27 18:27:49 +09003466 s32Error = host_int_init(net, &priv->hWILCWFIDrv);
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003467 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468 PRINT_ER("Error while initializing hostinterface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003469
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003470 return s32Error;
3471}
3472
3473/**
3474 * @brief WILC_WFI_WiphyFree
3475 * @details Freeing allocation of the wireless device structure
3476 * @param[in] NONE
3477 * @return NONE
3478 * @author mdaftedar
3479 * @date 01 MAR 2012
3480 * @version 1.0
3481 */
Chaehyun Lima9a16822015-09-20 15:51:24 +09003482int wilc_deinit_host_int(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003483{
Chaehyun Lim1a8ccd82015-09-20 15:51:23 +09003484 int s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485
Chaehyun Lim27268872015-09-15 14:06:13 +09003486 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003487
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003488 priv = wdev_priv(net->ieee80211_ptr);
3489
Dean Lee72ed4dc2015-06-12 14:11:44 +09003490 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
Dean Lee72ed4dc2015-06-12 14:11:44 +09003492 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493
3494 op_ifcs--;
3495
3496 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497
3498 /* Clear the Shadow scan */
3499 clear_shadow_scan(priv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003500 if (op_ifcs == 0) {
3501 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003502 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003504
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003505 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003506 PRINT_ER("Error while deintializing host interface\n");
Chaehyun Limf1fe9c42015-09-20 15:51:22 +09003507
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508 return s32Error;
3509}
3510
3511
3512/**
3513 * @brief WILC_WFI_WiphyFree
3514 * @details Freeing allocation of the wireless device structure
3515 * @param[in] NONE
3516 * @return NONE
3517 * @author mdaftedar
3518 * @date 01 MAR 2012
3519 * @version 1.0
3520 */
Chaehyun Lim96da20a2015-09-20 15:51:08 +09003521void wilc_free_wiphy(struct net_device *net)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003522{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3524
Chaehyun Lim619837a2015-09-20 15:51:10 +09003525 if (!net) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003526 PRINT_D(INIT_DBG, "net_device is NULL\n");
3527 return;
3528 }
3529
Chaehyun Lim619837a2015-09-20 15:51:10 +09003530 if (!net->ieee80211_ptr) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003531 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3532 return;
3533 }
3534
Chaehyun Lim619837a2015-09-20 15:51:10 +09003535 if (!net->ieee80211_ptr->wiphy) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003536 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3537 return;
3538 }
3539
3540 wiphy_unregister(net->ieee80211_ptr->wiphy);
3541
3542 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3543 wiphy_free(net->ieee80211_ptr->wiphy);
3544 kfree(net->ieee80211_ptr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545}