blob: b5e6176c5174c466465de0ed2c61ea601b2e4fc1 [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"
14#include "wilc_wlan.c"
15#ifdef WILC_SDIO
16#include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
17#endif
18
19
20#define IS_MANAGMEMENT 0x100
21#define IS_MANAGMEMENT_CALLBACK 0x080
22#define IS_MGMT_STATUS_SUCCES 0x040
23#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
24
Johnny Kimc5c77ba2015-05-11 14:30:56 +090025extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
Dean Lee72ed4dc2015-06-12 14:11:44 +090026extern u16 Set_machw_change_vir_if(bool bValue);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090027
28extern int mac_open(struct net_device *ndev);
29extern int mac_close(struct net_device *ndev);
30
31tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090032u32 u32LastScannedNtwrksCountShadow;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090033#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070034struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090035#endif
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070036struct timer_list hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090037static u8 op_ifcs;
38extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090039
40/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090041u8 g_wilc_initialized = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090042extern linux_wlan_t *g_linux_wlan;
43#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +090044extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090045#endif
46
47#define CHAN2G(_channel, _freq, _flags) { \
48 .band = IEEE80211_BAND_2GHZ, \
49 .center_freq = (_freq), \
50 .hw_value = (_channel), \
51 .flags = (_flags), \
52 .max_antenna_gain = 0, \
53 .max_power = 30, \
54}
55
56/*Frequency range for channels*/
57static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
58 CHAN2G(1, 2412, 0),
59 CHAN2G(2, 2417, 0),
60 CHAN2G(3, 2422, 0),
61 CHAN2G(4, 2427, 0),
62 CHAN2G(5, 2432, 0),
63 CHAN2G(6, 2437, 0),
64 CHAN2G(7, 2442, 0),
65 CHAN2G(8, 2447, 0),
66 CHAN2G(9, 2452, 0),
67 CHAN2G(10, 2457, 0),
68 CHAN2G(11, 2462, 0),
69 CHAN2G(12, 2467, 0),
70 CHAN2G(13, 2472, 0),
71 CHAN2G(14, 2484, 0),
72};
73
74#define RATETAB_ENT(_rate, _hw_value, _flags) { \
75 .bitrate = (_rate), \
76 .hw_value = (_hw_value), \
77 .flags = (_flags), \
78}
79
80
81/* Table 6 in section 3.2.1.1 */
82static struct ieee80211_rate WILC_WFI_rates[] = {
83 RATETAB_ENT(10, 0, 0),
84 RATETAB_ENT(20, 1, 0),
85 RATETAB_ENT(55, 2, 0),
86 RATETAB_ENT(110, 3, 0),
87 RATETAB_ENT(60, 9, 0),
88 RATETAB_ENT(90, 6, 0),
89 RATETAB_ENT(120, 7, 0),
90 RATETAB_ENT(180, 8, 0),
91 RATETAB_ENT(240, 9, 0),
92 RATETAB_ENT(360, 10, 0),
93 RATETAB_ENT(480, 11, 0),
94 RATETAB_ENT(540, 12, 0),
95};
96
97#ifdef WILC_P2P
98struct p2p_mgmt_data {
99 int size;
100 u8 *buff;
101};
102
103/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900104u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900105
106/*BugID_5442*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900107u8 u8CurrChannel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900108
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900109u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
110u8 u8P2Plocalrandom = 0x01;
111u8 u8P2Precvrandom = 0x00;
112u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200113bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900114#endif
115
116static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
117 .channels = WILC_WFI_2ghz_channels,
118 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
119 .bitrates = WILC_WFI_rates,
120 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
121};
122
123
124/*BugID_5137*/
125struct add_key_params {
126 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900127 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128 u8 *mac_addr;
129};
130struct add_key_params g_add_gtk_key_params;
131struct wilc_wfi_key g_key_gtk_params;
132struct add_key_params g_add_ptk_key_params;
133struct wilc_wfi_key g_key_ptk_params;
134struct wilc_wfi_wep_key g_key_wep_params;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900135u8 g_flushing_in_progress;
Daniel Machon7fc80962015-08-05 00:09:35 +0200136bool g_ptk_keys_saved;
137bool g_gtk_keys_saved;
138bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900139
140#define AGING_TIME (9 * 1000)
141#define duringIP_TIME 15000
142
143void clear_shadow_scan(void *pUserVoid)
144{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900145 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900146
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900147 if (op_ifcs == 0) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -0700148 del_timer_sync(&hAgingTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900149 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
150
151 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
152 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900153 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900154 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
155 }
156
157 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
158 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
159 }
160 u32LastScannedNtwrksCountShadow = 0;
161 }
162
163}
164
165uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
166{
167 uint8_t i;
168 int rssi_v = 0;
169 uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
170
171 for (i = 0; i < num_rssi; i++)
172 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
173
174 rssi_v /= num_rssi;
175 return rssi_v;
176}
177
Dean Lee72ed4dc2015-06-12 14:11:44 +0900178void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900179{
180 struct WILC_WFI_priv *priv;
181 struct wiphy *wiphy;
182 struct cfg80211_bss *bss = NULL;
183 int i;
184 int rssi = 0;
185
186 priv = (struct WILC_WFI_priv *)pUserVoid;
187 wiphy = priv->dev->ieee80211_ptr->wiphy;
188
189 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
190 tstrNetworkInfo *pstrNetworkInfo;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900191
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900192 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
193
194
195 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900196 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900197 struct ieee80211_channel *channel;
198
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900199 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900200
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900201 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202 channel = ieee80211_get_channel(wiphy, s32Freq);
203
204 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900205 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900206 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
207 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900208 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900209 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900210 }
211 }
212
213 }
214 }
215
216}
217
218void reset_shadow_found(void *pUserVoid)
219{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900220 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900221
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900222 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
223 astrLastScannedNtwrksShadow[i].u8Found = 0;
224
225 }
226}
227
228void update_scan_time(void *pUserVoid)
229{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900230 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900231
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900232 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
233 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
234 }
235}
236
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700237static void remove_network_from_shadow(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900238{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900239 unsigned long now = jiffies;
240 int i, j;
241
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900242
243 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
244 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530245 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900246
247 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900248 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900249 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
250 }
251
252 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
253
254 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
255 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
256 }
257 u32LastScannedNtwrksCountShadow--;
258 }
259 }
260
261 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700262 if (u32LastScannedNtwrksCountShadow != 0) {
263 hAgingTimer.data = arg;
264 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
265 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700267 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268}
269
270#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700271static void clear_duringIP(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272{
273 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900274 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900275}
276#endif
277
278int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
279{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900280 int8_t state = -1;
281 int i;
282
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900283 if (u32LastScannedNtwrksCountShadow == 0) {
284 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700285 hAgingTimer.data = (unsigned long)pUserVoid;
286 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900287 state = -1;
288 } else {
289 /* Linear search for now */
290 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900291 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900292 pstrNetworkInfo->au8bssid, 6) == 0) {
293 state = i;
294 break;
295 }
296 }
297 }
298 return state;
299}
300
301void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
302{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900303 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
304 uint32_t ap_index = 0;
305 uint8_t rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900306
307 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
308 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
309 return;
310 }
311 if (ap_found == -1) {
312 ap_index = u32LastScannedNtwrksCountShadow;
313 u32LastScannedNtwrksCountShadow++;
314
315 } else {
316 ap_index = ap_found;
317 }
318 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
319 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
320 if (rssi_index == NUM_RSSI) {
321 rssi_index = 0;
322 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
323 }
324 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
325
326 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
327 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
328
329 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900330 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900331 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
332
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900333 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900334 pstrNetworkInfo->au8bssid, ETH_ALEN);
335
336 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
337 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
338 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
339
340 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
341 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
342 if (ap_found != -1)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900343 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900344 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Glen Leef3052582015-09-10 12:03:04 +0900345 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900346 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900347 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
348
349 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
350 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
351 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
352 if (ap_found != -1)
353 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
354 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
355
356}
357
358
359/**
360 * @brief CfgScanResult
361 * @details Callback function which returns the scan results found
362 *
363 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
364 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
365 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
366 * void* pUserVoid: Private structure associated with the wireless interface
367 * @return NONE
368 * @author mabubakr
369 * @date
370 * @version 1.0
371 */
372static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
373{
374 struct WILC_WFI_priv *priv;
375 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900376 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377 struct ieee80211_channel *channel;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900378 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900379 struct cfg80211_bss *bss = NULL;
380
381 priv = (struct WILC_WFI_priv *)pUserVoid;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900382 if (priv->bCfgScanning == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900383 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
384 wiphy = priv->dev->ieee80211_ptr->wiphy;
385 WILC_NULLCHECK(s32Error, wiphy);
386 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
387 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900388 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900389 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900390 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391 ) {
392 WILC_ERRORREPORT(s32Error, WILC_FAIL);
393 }
394
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900395 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900396 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397 channel = ieee80211_get_channel(wiphy, s32Freq);
398
399 WILC_NULLCHECK(s32Error, channel);
400
401 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530402 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900403 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
404
Dean Lee72ed4dc2015-06-12 14:11:44 +0900405 if (pstrNetworkInfo->bNewNetwork == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900406 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
407 /* max_scan_ssids */
408 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
409
410
411 priv->u32RcvdChCount++;
412
413
414
415 if (pJoinParams == NULL) {
416 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
417 }
418 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
419
420 /*P2P peers are sent to WPA supplicant and added to shadow table*/
421
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900422 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900423 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
424 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900425 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900427 }
428
429
430 } else {
431 PRINT_ER("Discovered networks exceeded the max limit\n");
432 }
433 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900434 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900435 /* So this network is discovered before, we'll just update its RSSI */
436 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900437 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530438 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900439
440 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
441 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
442 break;
443 }
444 }
445 }
446 }
447 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530448 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
449 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900450 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530452 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530453 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530454 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530455 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900456
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200457 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900458
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900459 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900460 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900461 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900462 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900463 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200465 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466
467 }
468 /*Aborting any scan operation during mac close*/
469 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200470 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900471
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530472 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900473 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900474
475 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900476 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477
Dean Lee72ed4dc2015-06-12 14:11:44 +0900478 cfg80211_scan_done(priv->pstrScanReq, false);
479 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900480 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900481 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200482 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900483 }
484 }
485
486
487 WILC_CATCH(s32Error)
488 {
489 }
490}
491
492
493/**
494 * @brief WILC_WFI_Set_PMKSA
495 * @details Check if pmksa is cached and set it.
496 * @param[in]
497 * @return int : Return 0 on Success
498 * @author mdaftedar
499 * @date 01 MAR 2012
500 * @version 1.0
501 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900502int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900503{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900504 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900505 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506
507
508 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
509
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900510 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900511 ETH_ALEN)) {
512 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
513
514 /*If bssid is found, set the values*/
515 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
516
517 if (s32Error != WILC_SUCCESS)
518 PRINT_ER("Error in pmkid\n");
519
520 break;
521 }
522 }
523
524 return s32Error;
525
526
527}
528int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
529
530
531/**
532 * @brief CfgConnectResult
533 * @details
534 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
535 * connection response or disconnection notification.
536 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900537 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
539 * void* pUserVoid: Private data associated with wireless interface
540 * @return NONE
541 * @author mabubakr
542 * @date 01 MAR 2012
543 * @version 1.0
544 */
545int connecting;
546
547static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
548 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900549 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900550 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
551 void *pUserVoid)
552{
553 struct WILC_WFI_priv *priv;
554 struct net_device *dev;
555 #ifdef WILC_P2P
556 tstrWILC_WFIDrv *pstrWFIDrv;
557 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900558 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900559
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900560 connecting = 0;
561
562 priv = (struct WILC_WFI_priv *)pUserVoid;
563 dev = priv->dev;
564 #ifdef WILC_P2P
565 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
566 #endif
567
568 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
569 /*Initialization*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900570 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571
572 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
573
574 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
575
576 if ((u8MacStatus == MAC_DISCONNECTED) &&
577 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
578 /* The case here is that our station was waiting for association response frame and has just received it containing status code
579 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
580 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
581 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900582 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900583
584 /*BugID_5457*/
585 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
586 #ifdef WILC_P2P
587 if (!pstrWFIDrv->u8P2PConnect)
588 u8WLANChannel = INVALID_CHANNEL;
589 #endif
590
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530591 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900592 }
593
594 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900595 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900596 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900597
598 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
599 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900600 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900601
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900602 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
603 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
604 * Linux kernel warning generated at the nl80211 layer */
605
606 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900607 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900608 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
609 unsigned long now = jiffies;
610
611 if (time_after(now,
612 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900613 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900614 }
615
616 break;
617 }
618 }
619
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000620 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900621 /*BugID_5418*/
622 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900623 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900624
625 }
626
627 }
628
629
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530630 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900631
632 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
633
634 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
635 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
636 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
637 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
638 /* be replaced by pstrConnectInfo->u16ConnectStatus */
639 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
640 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900641 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900642 #endif
643 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
644 pstrDisconnectNotifInfo->u16reason, priv->dev);
645 u8P2Plocalrandom = 0x01;
646 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900647 bWilc_ie = false;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900648 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900649 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900650 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900651
652 /*BugID_5457*/
653 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
654 #ifdef WILC_P2P
655 if (!pstrWFIDrv->u8P2PConnect)
656 u8WLANChannel = INVALID_CHANNEL;
657 #endif
658 /*BugID_5315*/
659 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
660 * virtual interface to station*/
661 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
662 pstrDisconnectNotifInfo->u16reason = 3;
663 }
664 /*BugID_5315*/
665 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
666 * to scan again and retry the connection*/
667 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
668 pstrDisconnectNotifInfo->u16reason = 1;
669 }
670 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530671 pstrDisconnectNotifInfo->ie_len, false,
672 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900673
674 }
675
676}
677
678
679/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900680 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681 * @details Set channel for a given wireless interface. Some devices
682 * may support multi-channel operation (by channel hopping) so cfg80211
683 * doesn't verify much. Note, however, that the passed netdev may be
684 * %NULL as well if the user requested changing the channel for the
685 * device itself, or for a monitor interface.
686 * @param[in]
687 * @return int : Return 0 on Success
688 * @author mdaftedar
689 * @date 01 MAR 2012
690 * @version 1.0
691 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900692static int set_channel(struct wiphy *wiphy,
693 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900694{
695
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900696 u32 channelnum = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900698 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900699
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900700 priv = wiphy_priv(wiphy);
701
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900702 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
703 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900704
705 u8CurrChannel = channelnum;
706 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
707
708 if (s32Error != WILC_SUCCESS)
709 PRINT_ER("Error in setting channel %d\n", channelnum);
710
711 return s32Error;
712}
713
714/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900715 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900716 * @details Request to do a scan. If returning zero, the scan request is given
717 * the driver, and will be valid until passed to cfg80211_scan_done().
718 * For scan results, call cfg80211_inform_bss(); you can call this outside
719 * the scan/scan_done bracket too.
720 * @param[in]
721 * @return int : Return 0 on Success
722 * @author mabubakr
723 * @date 01 MAR 2012
724 * @version 1.0
725 */
726
727/*
728 * kernel version 3.8.8 supported
729 * tony, sswd, WILC-KR, 2013-10-29
730 */
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900731static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900732{
733 struct WILC_WFI_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900734 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900735 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900736 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900737 tstrHiddenNetwork strHiddenNetwork;
738
739 priv = wiphy_priv(wiphy);
740
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900741 priv->pstrScanReq = request;
742
743 priv->u32RcvdChCount = 0;
744
Johnny Kim218dc402015-08-13 13:41:19 +0900745 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746
747
748 reset_shadow_found(priv);
749
Dean Lee72ed4dc2015-06-12 14:11:44 +0900750 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900751 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
752 /* max_scan_ssids */
753 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900754 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
756 }
757
758 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530759 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900760
761 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
762
763 if (request->n_ssids >= 1) {
764
765
Glen Leef3052582015-09-10 12:03:04 +0900766 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900767 strHiddenNetwork.u8ssidnum = request->n_ssids;
768
769
770 /*BugID_4156*/
771 for (i = 0; i < request->n_ssids; i++) {
772
773 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900774 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900775 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900776 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
777 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530778 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900779 strHiddenNetwork.u8ssidnum -= 1;
780 }
781 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530782 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900783 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
784 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900785 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900786 CfgScanResult, (void *)priv, &strHiddenNetwork);
787 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530788 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900789 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
790 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900791 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900792 CfgScanResult, (void *)priv, NULL);
793 }
794
795 } else {
796 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530797 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900798 }
799
800 if (s32Error != WILC_SUCCESS) {
801 s32Error = -EBUSY;
802 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
803 }
804
805 return s32Error;
806}
807
808/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900809 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900810 * @details Connect to the ESS with the specified parameters. When connected,
811 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
812 * If the connection fails for some reason, call cfg80211_connect_result()
813 * with the status from the AP.
814 * @param[in]
815 * @return int : Return 0 on Success
816 * @author mabubakr
817 * @date 01 MAR 2012
818 * @version 1.0
819 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900820static int connect(struct wiphy *wiphy, struct net_device *dev,
821 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900822{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900823 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900824 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900825 u8 u8security = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900826 AUTHTYPE_T tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900827 char *pcgroup_encrypt_val = NULL;
828 char *pccipher_group = NULL;
829 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900830
831 struct WILC_WFI_priv *priv;
832 tstrWILC_WFIDrv *pstrWFIDrv;
833 tstrNetworkInfo *pstrNetworkInfo = NULL;
834
835
836 connecting = 1;
837 priv = wiphy_priv(wiphy);
838 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
839
Johnny Kim218dc402015-08-13 13:41:19 +0900840 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900841
Johnny Kim8a143302015-06-10 17:06:46 +0900842 PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900843 #ifdef WILC_P2P
Chaehyun Lim3f882892015-08-10 11:33:17 +0900844 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900845 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
846 pstrWFIDrv->u8P2PConnect = 1;
847 } else
848 pstrWFIDrv->u8P2PConnect = 0;
849 #endif
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530850 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851
852 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
853 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900854 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900855 sme->ssid,
856 sme->ssid_len) == 0) {
857 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
858 if (sme->bssid == NULL) {
859 /* BSSID is not passed from the user, so decision of matching
860 * is done by SSID only */
861 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
862 break;
863 } else {
864 /* BSSID is also passed from the user, so decision of matching
865 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900866 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900867 sme->bssid,
868 ETH_ALEN) == 0) {
869 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
870 break;
871 }
872 }
873 }
874 }
875
876 if (i < u32LastScannedNtwrksCountShadow) {
877 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
878
879 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
880
881 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
882 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
883 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
884 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
885 } else {
886 s32Error = -ENOENT;
887 if (u32LastScannedNtwrksCountShadow == 0)
888 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
889 else
890 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
891
892 goto done;
893 }
894
895 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900896 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
897 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898
899 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
900 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
901
902 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
903
904 if (INFO) {
905 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
906 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
907 }
908
909 if (sme->crypto.cipher_group != NO_ENCRYPT) {
910 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
911 * we will add to it the pairwise cipher suite(s) */
912 pcwpa_version = "Default";
913 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900914 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900915 u8security = ENCRYPT_ENABLED | WEP;
916 pcgroup_encrypt_val = "WEP40";
917 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
918 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
919
920 if (INFO) {
921 for (i = 0; i < sme->key_len; i++)
922 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
923 }
924 priv->WILC_WFI_wep_default = sme->key_idx;
925 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900926 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927
928 /*BugID_5137*/
929 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900930 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900931 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
932 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900933 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934
935 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
936 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
937 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900938 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
939 pcgroup_encrypt_val = "WEP104";
940 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
941
942 priv->WILC_WFI_wep_default = sme->key_idx;
943 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900944 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900945
946 /*BugID_5137*/
947 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900948 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
950 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900951 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900952
953 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
954 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
955 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900956 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
958 pcgroup_encrypt_val = "WPA2_TKIP";
959 pccipher_group = "TKIP";
960 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
961 /* tenuSecurity_t = WPA2_AES; */
962 u8security = ENCRYPT_ENABLED | WPA2 | AES;
963 pcgroup_encrypt_val = "WPA2_AES";
964 pccipher_group = "AES";
965 }
966 pcwpa_version = "WPA_VERSION_2";
967 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
968 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900969 u8security = ENCRYPT_ENABLED | WPA | TKIP;
970 pcgroup_encrypt_val = "WPA_TKIP";
971 pccipher_group = "TKIP";
972 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
973 /* tenuSecurity_t = WPA_AES; */
974 u8security = ENCRYPT_ENABLED | WPA | AES;
975 pcgroup_encrypt_val = "WPA_AES";
976 pccipher_group = "AES";
977
978 }
979 pcwpa_version = "WPA_VERSION_1";
980
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900981 } else {
982 s32Error = -ENOTSUPP;
983 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
984
985 goto done;
986 }
987
988 }
989
990 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
991 * add to it the pairwise cipher suite(s) */
992 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
993 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
994 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
995 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
996 u8security = u8security | TKIP;
997 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
998 u8security = u8security | AES;
999 }
1000 }
1001 }
1002
1003 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1004
1005 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1006 switch (sme->auth_type) {
1007 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1008 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1009 tenuAuth_type = OPEN_SYSTEM;
1010 break;
1011
1012 case NL80211_AUTHTYPE_SHARED_KEY:
1013 tenuAuth_type = SHARED_KEY;
1014 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1015 break;
1016
1017 default:
1018 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1019 }
1020
1021
1022 /* ai: key_mgmt: enterprise case */
1023 if (sme->crypto.n_akm_suites) {
1024 switch (sme->crypto.akm_suites[0]) {
1025 case WLAN_AKM_SUITE_8021X:
1026 tenuAuth_type = IEEE8021;
1027 break;
1028
1029 default:
1030 break;
1031 }
1032 }
1033
1034
1035 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1036
1037 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1038 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1039
1040 /*BugID_5442*/
1041 u8CurrChannel = pstrNetworkInfo->u8channel;
1042
1043 if (!pstrWFIDrv->u8P2PConnect) {
1044 u8WLANChannel = pstrNetworkInfo->u8channel;
1045 }
1046
1047 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1048
1049 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1050 sme->ssid_len, sme->ie, sme->ie_len,
1051 CfgConnectResult, (void *)priv, u8security,
1052 tenuAuth_type, pstrNetworkInfo->u8channel,
1053 pstrNetworkInfo->pJoinParams);
1054 if (s32Error != WILC_SUCCESS) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301055 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001056 s32Error = -ENOENT;
1057 goto done;
1058 }
1059
1060done:
1061
1062 return s32Error;
1063}
1064
1065
1066/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001067 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001068 * @details Disconnect from the BSS/ESS.
1069 * @param[in]
1070 * @return int : Return 0 on Success
1071 * @author mdaftedar
1072 * @date 01 MAR 2012
1073 * @version 1.0
1074 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001075static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001076{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001077 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001078 struct WILC_WFI_priv *priv;
1079 #ifdef WILC_P2P
1080 tstrWILC_WFIDrv *pstrWFIDrv;
1081 #endif
1082 uint8_t NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001083
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 connecting = 0;
1085 priv = wiphy_priv(wiphy);
1086
1087 /*BugID_5457*/
1088 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1089 #ifdef WILC_P2P
1090 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1091 if (!pstrWFIDrv->u8P2PConnect)
1092 u8WLANChannel = INVALID_CHANNEL;
1093 #endif
1094 linux_wlan_set_bssid(priv->dev, NullBssid);
1095
1096 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1097
1098 u8P2Plocalrandom = 0x01;
1099 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001100 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 #ifdef WILC_P2P
1102 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1103 #endif
1104
1105 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1106 if (s32Error != WILC_SUCCESS) {
1107 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1108 s32Error = -EINVAL;
1109 }
1110
1111 return s32Error;
1112}
1113
1114/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001115 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 * @details Add a key with the given parameters. @mac_addr will be %NULL
1117 * when adding a group key.
1118 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1119 * @return int : Return 0 on Success
1120 * @author mdaftedar
1121 * @date 01 MAR 2012
1122 * @version 1.0
1123 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001124static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1125 bool pairwise,
1126 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001127
1128{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001129 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001130 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 struct WILC_WFI_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001132 const u8 *pu8RxMic = NULL;
1133 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001134 u8 u8mode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001135 #ifdef WILC_AP_EXTERNAL_MLME
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001136 u8 u8gmode = NO_ENCRYPT;
1137 u8 u8pmode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001138 AUTHTYPE_T tenuAuth_type = ANY;
1139 #endif
1140
1141 priv = wiphy_priv(wiphy);
1142
1143 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1144
1145 /*BugID_5137*/
Johnny Kim8a143302015-06-10 17:06:46 +09001146 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147
1148 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1149 params->key[1],
1150 params->key[2]);
1151
1152
1153 switch (params->cipher) {
1154 case WLAN_CIPHER_SUITE_WEP40:
1155 case WLAN_CIPHER_SUITE_WEP104:
1156 #ifdef WILC_AP_EXTERNAL_MLME
1157 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1158
1159 priv->WILC_WFI_wep_default = key_index;
1160 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001161 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001162
1163 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1164 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1165
1166 for (i = 0; i < params->key_len; i++)
1167 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1168
1169 tenuAuth_type = OPEN_SYSTEM;
1170
1171 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1172 u8mode = ENCRYPT_ENABLED | WEP;
1173 else
1174 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1175
1176 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1177 break;
1178 }
1179 #endif
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001180 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001181 priv->WILC_WFI_wep_default = key_index;
1182 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001183 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001184
1185 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1186 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1187 if (INFO) {
1188 for (i = 0; i < params->key_len; i++)
1189 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1190 }
1191 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1192 }
1193
1194 break;
1195
1196 case WLAN_CIPHER_SUITE_TKIP:
1197 case WLAN_CIPHER_SUITE_CCMP:
1198 #ifdef WILC_AP_EXTERNAL_MLME
1199 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1200
1201 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001202 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001203 priv->wilc_gtk[key_index]->key = NULL;
1204 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001205
1206 }
1207 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001208 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001209 priv->wilc_ptk[key_index]->key = NULL;
1210 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211 }
1212
1213
1214
Daniel Machon19132212015-08-05 08:18:31 +02001215 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001216 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1217 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1218 else
1219 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1220
1221 priv->wilc_groupkey = u8gmode;
1222
1223 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1224
1225 pu8TxMic = params->key + 24;
1226 pu8RxMic = params->key + 16;
1227 KeyLen = params->key_len - 16;
1228 }
1229 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1230 if (priv->wilc_gtk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001231 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001232
Glen Leef3052582015-09-10 12:03:04 +09001233 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001234 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001235
1236 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1237 if (priv->wilc_gtk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001238 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001239
1240 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001241 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001242 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001243 }
1244
1245 priv->wilc_gtk[key_index]->cipher = params->cipher;
1246 priv->wilc_gtk[key_index]->key_len = params->key_len;
1247 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1248
1249 if (INFO) {
1250 for (i = 0; i < params->key_len; i++)
1251 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1252 for (i = 0; i < params->seq_len; i++)
1253 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1254 }
1255
1256
1257 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1258 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1259
1260 } else {
1261 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]);
1262
1263 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1264 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1265 else
1266 u8pmode = priv->wilc_groupkey | AES;
1267
1268
1269 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1270
1271 pu8TxMic = params->key + 24;
1272 pu8RxMic = params->key + 16;
1273 KeyLen = params->key_len - 16;
1274 }
1275
1276 if (priv->wilc_ptk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001277 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278
Glen Leef3052582015-09-10 12:03:04 +09001279 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280
1281 if (priv->wilc_ptk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001282 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001283
1284 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001285 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286
1287 if (INFO) {
1288 for (i = 0; i < params->key_len; i++)
1289 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1290
1291 for (i = 0; i < params->seq_len; i++)
1292 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1293 }
1294
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001295 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001296
1297 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001298 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001299
1300 priv->wilc_ptk[key_index]->cipher = params->cipher;
1301 priv->wilc_ptk[key_index]->key_len = params->key_len;
1302 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1303
1304 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1305 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1306 }
1307 break;
1308 }
1309 #endif
1310
1311 {
1312 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001313 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001314 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1315 /* swap the tx mic by rx mic */
1316 pu8RxMic = params->key + 24;
1317 pu8TxMic = params->key + 16;
1318 KeyLen = params->key_len - 16;
1319 }
1320
1321 /*BugID_5137*/
1322 /*save keys only on interface 0 (wifi interface)*/
1323 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1324 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001325 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326 if (!mac_addr) {
1327 g_add_gtk_key_params.mac_addr = NULL;
1328 } else {
Glen Leef3052582015-09-10 12:03:04 +09001329 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001330 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1331 }
1332 g_key_gtk_params.key_len = params->key_len;
1333 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001334 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001335 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1336 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001337 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001338 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1339 }
1340 g_key_gtk_params.cipher = params->cipher;
1341
1342 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1343 g_key_gtk_params.key[1],
1344 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001345 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001346 }
1347
1348 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1349 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001350 } else {
1351 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1352 /* swap the tx mic by rx mic */
1353 pu8RxMic = params->key + 24;
1354 pu8TxMic = params->key + 16;
1355 KeyLen = params->key_len - 16;
1356 }
1357
1358 /*BugID_5137*/
1359 /*save keys only on interface 0 (wifi interface)*/
1360 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1361 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001362 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001363 if (!mac_addr) {
1364 g_add_ptk_key_params.mac_addr = NULL;
1365 } else {
Glen Leef3052582015-09-10 12:03:04 +09001366 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001367 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1368 }
1369 g_key_ptk_params.key_len = params->key_len;
1370 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001371 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001372 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1373 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001374 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1376 }
1377 g_key_ptk_params.cipher = params->cipher;
1378
1379 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1380 g_key_ptk_params.key[1],
1381 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001382 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001383 }
1384
1385 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1386 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1387 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1388 if (INFO) {
1389 for (i = 0; i < params->key_len; i++)
1390 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1391 }
1392 }
1393 }
1394 break;
1395
1396 default:
1397 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1398 s32Error = -ENOTSUPP;
1399
1400 }
1401
1402 return s32Error;
1403}
1404
1405/**
1406 * @brief WILC_WFI_del_key
1407 * @details Remove a key given the @mac_addr (%NULL for a group key)
1408 * and @key_index, return -ENOENT if the key doesn't exist.
1409 * @param[in]
1410 * @return int : Return 0 on Success
1411 * @author mdaftedar
1412 * @date 01 MAR 2012
1413 * @version 1.0
1414 */
1415static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
1416 u8 key_index,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417 bool pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001418 const u8 *mac_addr)
1419{
1420 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001421 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001422
1423 priv = wiphy_priv(wiphy);
1424
1425 /*BugID_5137*/
1426 /*delete saved keys, if any*/
1427 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001428 g_ptk_keys_saved = false;
1429 g_gtk_keys_saved = false;
1430 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431
1432 /*Delete saved WEP keys params, if any*/
1433 if (g_key_wep_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001434 kfree(g_key_wep_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001435 g_key_wep_params.key = NULL;
1436 }
1437
1438 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1439
1440 #ifdef WILC_AP_EXTERNAL_MLME
1441 if ((priv->wilc_gtk[key_index]) != NULL) {
1442
1443 if (priv->wilc_gtk[key_index]->key != NULL) {
1444
Chaehyun Lim49188af2015-08-11 10:32:41 +09001445 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446 priv->wilc_gtk[key_index]->key = NULL;
1447 }
1448 if (priv->wilc_gtk[key_index]->seq) {
1449
Chaehyun Lim49188af2015-08-11 10:32:41 +09001450 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001451 priv->wilc_gtk[key_index]->seq = NULL;
1452 }
1453
Chaehyun Lim49188af2015-08-11 10:32:41 +09001454 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001455 priv->wilc_gtk[key_index] = NULL;
1456
1457 }
1458
1459 if ((priv->wilc_ptk[key_index]) != NULL) {
1460
1461 if (priv->wilc_ptk[key_index]->key) {
1462
Chaehyun Lim49188af2015-08-11 10:32:41 +09001463 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464 priv->wilc_ptk[key_index]->key = NULL;
1465 }
1466 if (priv->wilc_ptk[key_index]->seq) {
1467
Chaehyun Lim49188af2015-08-11 10:32:41 +09001468 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001469 priv->wilc_ptk[key_index]->seq = NULL;
1470 }
Chaehyun Lim49188af2015-08-11 10:32:41 +09001471 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001472 priv->wilc_ptk[key_index] = NULL;
1473 }
1474 #endif
1475
1476 /*Delete saved PTK and GTK keys params, if any*/
1477 if (g_key_ptk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001478 kfree(g_key_ptk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001479 g_key_ptk_params.key = NULL;
1480 }
1481 if (g_key_ptk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001482 kfree(g_key_ptk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001483 g_key_ptk_params.seq = NULL;
1484 }
1485
1486 if (g_key_gtk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001487 kfree(g_key_gtk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001488 g_key_gtk_params.key = NULL;
1489 }
1490 if (g_key_gtk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001491 kfree(g_key_gtk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001492 g_key_gtk_params.seq = NULL;
1493 }
1494
1495 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001496 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001497 }
1498
1499 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001500 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001501 priv->WILC_WFI_wep_key_len[key_index] = 0;
1502
1503 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1504 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1505 } else {
1506 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1507 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1508 }
1509
1510 return s32Error;
1511}
1512
1513/**
1514 * @brief WILC_WFI_get_key
1515 * @details Get information about the key with the given parameters.
1516 * @mac_addr will be %NULL when requesting information for a group
1517 * key. All pointers given to the @callback function need not be valid
1518 * after it returns. This function should return an error if it is
1519 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1520 * @param[in]
1521 * @return int : Return 0 on Success
1522 * @author mdaftedar
1523 * @date 01 MAR 2012
1524 * @version 1.0
1525 */
1526static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527 bool pairwise,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
1529{
1530
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001531 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532
1533 struct WILC_WFI_priv *priv;
1534 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001535 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001536
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001537 priv = wiphy_priv(wiphy);
1538
1539
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540 if (!pairwise)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001541 {
1542 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1543
1544 key_params.key = priv->wilc_gtk[key_index]->key;
1545 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1546 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1547 key_params.seq = priv->wilc_gtk[key_index]->seq;
1548 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1549 if (INFO) {
1550 for (i = 0; i < key_params.key_len; i++)
1551 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1552 }
1553 } else {
1554 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1555
1556 key_params.key = priv->wilc_ptk[key_index]->key;
1557 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1558 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1559 key_params.seq = priv->wilc_ptk[key_index]->seq;
1560 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1561 }
1562
1563 callback(cookie, &key_params);
1564
1565 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1566}
1567
1568/**
1569 * @brief WILC_WFI_set_default_key
1570 * @details Set the default management frame key on an interface
1571 * @param[in]
1572 * @return int : Return 0 on Success.
1573 * @author mdaftedar
1574 * @date 01 MAR 2012
1575 * @version 1.0
1576 */
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001577static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1578 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001580 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581 struct WILC_WFI_priv *priv;
1582
1583
1584 priv = wiphy_priv(wiphy);
1585
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301586 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001587
1588 if (key_index != priv->WILC_WFI_wep_default) {
1589
1590 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1591 }
1592
1593 return s32Error;
1594}
1595
1596/**
1597 * @brief WILC_WFI_dump_survey
1598 * @details Get site survey information
1599 * @param[in]
1600 * @return int : Return 0 on Success.
1601 * @author mdaftedar
1602 * @date 01 MAR 2012
1603 * @version 1.0
1604 */
1605static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1606 int idx, struct survey_info *info)
1607{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001608 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001609
1610
1611 if (idx != 0) {
1612 s32Error = -ENOENT;
1613 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1614
1615 }
1616
1617 return s32Error;
1618}
1619
1620
1621/**
1622 * @brief WILC_WFI_get_station
1623 * @details Get station information for the station identified by @mac
1624 * @param[in] NONE
1625 * @return int : Return 0 on Success.
1626 * @author mdaftedar
1627 * @date 01 MAR 2012
1628 * @version 1.0
1629 */
1630
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001631static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001632 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001634 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001635 struct WILC_WFI_priv *priv;
1636 perInterface_wlan_t *nic;
1637 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001638 u32 i = 0;
1639 u32 associatedsta = 0;
1640 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641 #endif
1642 priv = wiphy_priv(wiphy);
1643 nic = netdev_priv(dev);
1644
1645 #ifdef WILC_AP_EXTERNAL_MLME
1646 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1647 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1648
1649 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1650
1651 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1652
1653 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1654 associatedsta = i;
1655 break;
1656 }
1657
1658 }
1659
1660 if (associatedsta == -1) {
1661 s32Error = -ENOENT;
1662 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1663
1664 return s32Error;
1665 }
1666
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001668
1669 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1670 sinfo->inactive_time = 1000 * inactive_time;
1671 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1672
1673 }
1674 #endif
1675
1676 if (nic->iftype == STATION_MODE) {
1677 tstrStatistics strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001678
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001679 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1680
1681 /*
1682 * tony: 2013-11-13
1683 * tx_failed introduced more than
1684 * kernel version 3.0.0
1685 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301687 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001688 BIT(NL80211_STA_INFO_TX_PACKETS) |
1689 BIT(NL80211_STA_INFO_TX_FAILED) |
1690 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691
1692 sinfo->signal = strStatistics.s8RSSI;
1693 sinfo->rx_packets = strStatistics.u32RxCount;
1694 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001695 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001696 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1697
1698#ifdef TCP_ENHANCEMENTS
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301699 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001700 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301701 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001702 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001703#endif
1704
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001705 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1706 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001707 }
1708 return s32Error;
1709}
1710
1711
1712/**
1713 * @brief WILC_WFI_change_bss
1714 * @details Modify parameters for a given BSS.
1715 * @param[in]
1716 * -use_cts_prot: Whether to use CTS protection
1717 * (0 = no, 1 = yes, -1 = do not change)
1718 * -use_short_preamble: Whether the use of short preambles is allowed
1719 * (0 = no, 1 = yes, -1 = do not change)
1720 * -use_short_slot_time: Whether the use of short slot time is allowed
1721 * (0 = no, 1 = yes, -1 = do not change)
1722 * -basic_rates: basic rates in IEEE 802.11 format
1723 * (or NULL for no change)
1724 * -basic_rates_len: number of basic rates
1725 * -ap_isolate: do not forward packets between connected stations
1726 * -ht_opmode: HT Operation mode
1727 * (u16 = opmode, -1 = do not change)
1728 * @return int : Return 0 on Success.
1729 * @author mdaftedar
1730 * @date 01 MAR 2012
1731 * @version 1.0
1732 */
1733static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
1734 struct bss_parameters *params)
1735{
1736 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1737 return 0;
1738}
1739
1740/**
1741 * @brief WILC_WFI_auth
1742 * @details Request to authenticate with the specified peer
1743 * @param[in]
1744 * @return int : Return 0 on Success.
1745 * @author mdaftedar
1746 * @date 01 MAR 2012
1747 * @version 1.0
1748 */
1749static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1750 struct cfg80211_auth_request *req)
1751{
1752 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1753 return 0;
1754}
1755
1756/**
1757 * @brief WILC_WFI_assoc
1758 * @details Request to (re)associate with the specified peer
1759 * @param[in]
1760 * @return int : Return 0 on Success.
1761 * @author mdaftedar
1762 * @date 01 MAR 2012
1763 * @version 1.0
1764 */
1765static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1766 struct cfg80211_assoc_request *req)
1767{
1768 PRINT_D(CFG80211_DBG, "In Association Function\n");
1769 return 0;
1770}
1771
1772/**
1773 * @brief WILC_WFI_deauth
1774 * @details Request to deauthenticate from the specified peer
1775 * @param[in]
1776 * @return int : Return 0 on Success.
1777 * @author mdaftedar
1778 * @date 01 MAR 2012
1779 * @version 1.0
1780 */
1781static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1782 struct cfg80211_deauth_request *req, void *cookie)
1783{
1784 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1785 return 0;
1786}
1787
1788/**
1789 * @brief WILC_WFI_disassoc
1790 * @details Request to disassociate from the specified peer
1791 * @param[in]
1792 * @return int : Return 0 on Success
1793 * @author mdaftedar
1794 * @date 01 MAR 2012
1795 * @version 1.0
1796 */
1797static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1798 struct cfg80211_disassoc_request *req, void *cookie)
1799{
1800 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1801 return 0;
1802}
1803
1804/**
1805 * @brief WILC_WFI_set_wiphy_params
1806 * @details Notify that wiphy parameters have changed;
1807 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1808 * have changed.
1809 * @return int : Return 0 on Success
1810 * @author mdaftedar
1811 * @date 01 MAR 2012
1812 * @version 1.0
1813 */
1814static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1815{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001816 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001817 tstrCfgParamVal pstrCfgParamVal;
1818 struct WILC_WFI_priv *priv;
1819
1820 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821
1822 pstrCfgParamVal.u32SetCfgFlag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301823 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824
1825 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1826 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1827 priv->dev->ieee80211_ptr->wiphy->retry_short);
1828 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1829 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1830 }
1831 if (changed & WIPHY_PARAM_RETRY_LONG) {
1832
1833 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1834 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1835 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1836
1837 }
1838 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1839 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1840 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1841 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1842
1843 }
1844
1845 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1846 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1847
1848 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1849 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1850
1851 }
1852
1853 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1854 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1855 if (s32Error)
1856 PRINT_ER("Error in setting WIPHY PARAMS\n");
1857
1858
1859 return s32Error;
1860}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001861
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862/**
1863 * @brief WILC_WFI_set_bitrate_mask
1864 * @details set the bitrate mask configuration
1865 * @param[in]
1866 * @return int : Return 0 on Success
1867 * @author mdaftedar
1868 * @date 01 MAR 2012
1869 * @version 1.0
1870 */
1871static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1872 struct net_device *dev, const u8 *peer,
1873 const struct cfg80211_bitrate_mask *mask)
1874{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001875 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001876
1877 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001878 return s32Error;
1879
1880}
1881
1882/**
1883 * @brief WILC_WFI_set_pmksa
1884 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1885 * devices running firmwares capable of generating the (re) association
1886 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1887 * @param[in]
1888 * @return int : Return 0 on Success
1889 * @author mdaftedar
1890 * @date 01 MAR 2012
1891 * @version 1.0
1892 */
1893static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1894 struct cfg80211_pmksa *pmksa)
1895{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001896 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001897 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001898 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001899
1900 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
1901
1902 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1903
1904
1905 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001906 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907 ETH_ALEN)) {
1908 /*If bssid already exists and pmkid value needs to reset*/
1909 flag = PMKID_FOUND;
1910 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1911 break;
1912 }
1913 }
1914 if (i < WILC_MAX_NUM_PMKIDS) {
1915 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001916 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001917 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001918 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919 PMKID_LEN);
1920 if (!(flag == PMKID_FOUND))
1921 priv->pmkid_list.numpmkid++;
1922 } else {
1923 PRINT_ER("Invalid PMKID index\n");
1924 s32Error = -EINVAL;
1925 }
1926
1927 if (!s32Error) {
1928 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1929 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1930 }
1931 return s32Error;
1932}
1933
1934/**
1935 * @brief WILC_WFI_del_pmksa
1936 * @details Delete a cached PMKID.
1937 * @param[in]
1938 * @return int : Return 0 on Success
1939 * @author mdaftedar
1940 * @date 01 MAR 2012
1941 * @version 1.0
1942 */
1943static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1944 struct cfg80211_pmksa *pmksa)
1945{
1946
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001947 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001948 u8 flag = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001949 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950
1951 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001952
1953 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1954
1955 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001956 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001957 ETH_ALEN)) {
1958 /*If bssid is found, reset the values*/
1959 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001960 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001961 flag = PMKID_FOUND;
1962 break;
1963 }
1964 }
1965
1966 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1967 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001968 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001969 priv->pmkid_list.pmkidlist[i + 1].bssid,
1970 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001971 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001972 priv->pmkid_list.pmkidlist[i].pmkid,
1973 PMKID_LEN);
1974 }
1975 priv->pmkid_list.numpmkid--;
1976 } else {
1977 s32Error = -EINVAL;
1978 }
1979
1980 return s32Error;
1981}
1982
1983/**
1984 * @brief WILC_WFI_flush_pmksa
1985 * @details Flush all cached PMKIDs.
1986 * @param[in]
1987 * @return int : Return 0 on Success
1988 * @author mdaftedar
1989 * @date 01 MAR 2012
1990 * @version 1.0
1991 */
1992static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
1993{
1994 struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001995
1996 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1997
1998 /*Get cashed Pmkids and set all with zeros*/
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001999 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000
2001 return 0;
2002}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002003
2004#ifdef WILC_P2P
2005
2006/**
2007 * @brief WILC_WFI_CfgParseRxAction
2008 * @details Function parses the received frames and modifies the following attributes:
2009 * -GO Intent
2010 * -Channel list
2011 * -Operating Channel
2012 *
2013 * @param[in] u8* Buffer, u32 length
2014 * @return NONE.
2015 * @author mdaftedar
2016 * @date 12 DEC 2012
2017 * @version
2018 */
2019
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002020void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002022 u32 index = 0;
2023 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002024
2025 /*BugID_5460*/
2026 #ifdef USE_SUPPLICANT_GO_INTENT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002027 u8 intent;
2028 u8 tie_breaker;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002029 bool is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002031 u8 op_channel_attr_index = 0;
2032 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002033
2034 while (index < len) {
2035 if (buf[index] == GO_INTENT_ATTR_ID) {
2036 #ifdef USE_SUPPLICANT_GO_INTENT
2037 /*BugID_5460*/
2038 /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
2039 /*In negotiation frames, go intent attr value determines who will be GO*/
2040 intent = GET_GO_INTENT(buf[index + 3]);
2041 tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
2042 if (intent > SUPPLICANT_GO_INTENT
2043 || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
2044 PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002045 is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002046 } else {
2047 PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002048 is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002049 }
2050
2051 #else /* USE_SUPPLICANT_GO_INTENT */
2052 #ifdef FORCE_P2P_CLIENT
2053 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2054 #else
2055 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2056 #endif
2057 #endif /* USE_SUPPLICANT_GO_INTENT */
2058 }
2059
2060 #ifdef USE_SUPPLICANT_GO_INTENT
2061 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2062 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2063 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2064 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2065 , buf[index + 4]
2066 , buf[index + 5]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002067 is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002068 }
2069 #endif /* USE_SUPPLICANT_GO_INTENT */
2070
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302071 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002072 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302073 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002074 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002075 index += buf[index + 1] + 3; /* ID,Length byte */
2076 }
2077
2078 #ifdef USE_SUPPLICANT_GO_INTENT
2079 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2080 #else
2081 if (u8WLANChannel != INVALID_CHANNEL)
2082 #endif
2083 {
2084 /*Modify channel list attribute*/
2085 if (channel_list_attr_index) {
2086 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2087 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2088 if (buf[i] == 0x51) {
2089 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2090 buf[j] = u8WLANChannel;
2091 }
2092 break;
2093 }
2094 }
2095 }
2096 /*Modify operating channel attribute*/
2097 if (op_channel_attr_index) {
2098 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2099 buf[op_channel_attr_index + 6] = 0x51;
2100 buf[op_channel_attr_index + 7] = u8WLANChannel;
2101 }
2102 }
2103}
2104
2105/**
2106 * @brief WILC_WFI_CfgParseTxAction
2107 * @details Function parses the transmitted action frames and modifies the
2108 * GO Intent attribute
2109 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2110 * @return NONE.
2111 * @author mdaftedar
2112 * @date 12 DEC 2012
2113 * @version
2114 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002115void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002116{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002117 u32 index = 0;
2118 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002119
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002120 u8 op_channel_attr_index = 0;
2121 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122 #ifdef USE_SUPPLICANT_GO_INTENT
Dean Lee72ed4dc2015-06-12 14:11:44 +09002123 bool is_wilc_go = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002124
2125 /*BugID_5460*/
2126 /*Case 1: If we are already p2p client, no need to modify channels attributes*/
2127 /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
2128 if (iftype == CLIENT_MODE)
2129 return;
2130 #endif
2131
2132 while (index < len) {
2133 #ifdef USE_SUPPLICANT_GO_INTENT
2134 /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
2135 /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
2136 /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
2137 if (buf[index] == GROUP_BSSID_ATTR_ID) {
2138 PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
2139 , buf[index + 4]
2140 , buf[index + 5]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09002141 is_wilc_go = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002142 }
2143
2144 #else /* USE_SUPPLICANT_GO_INTENT */
2145 if (buf[index] == GO_INTENT_ATTR_ID) {
2146 #ifdef FORCE_P2P_CLIENT
2147 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
2148 #else
2149 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
2150 #endif
2151
2152 break;
2153 }
2154 #endif
2155
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302156 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002157 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302158 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002159 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160 index += buf[index + 1] + 3; /* ID,Length byte */
2161 }
2162
2163 #ifdef USE_SUPPLICANT_GO_INTENT
2164 /*No need to check bOperChan since only transmitted invitation frames are parsed*/
2165 if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
2166 #else
2167 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
2168 #endif
2169 {
2170 /*Modify channel list attribute*/
2171 if (channel_list_attr_index) {
2172 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2173 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2174 if (buf[i] == 0x51) {
2175 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2176 buf[j] = u8WLANChannel;
2177 }
2178 break;
2179 }
2180 }
2181 }
2182 /*Modify operating channel attribute*/
2183 if (op_channel_attr_index) {
2184 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2185 buf[op_channel_attr_index + 6] = 0x51;
2186 buf[op_channel_attr_index + 7] = u8WLANChannel;
2187 }
2188 }
2189}
2190
2191/* @brief WILC_WFI_p2p_rx
2192 * @details
2193 * @param[in]
2194 *
2195 * @return None
2196 * @author Mai Daftedar
2197 * @date 2 JUN 2013
2198 * @version 1.0
2199 */
2200
2201void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
2202{
2203
2204 struct WILC_WFI_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002205 u32 header, pkt_offset;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002206 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002207 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002208 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002209
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2211 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2212
2213 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002214 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215
2216 /* The packet offset field conain info about what type of managment frame */
2217 /* we are dealing with and ack status */
2218 pkt_offset = GET_PKT_OFFSET(header);
2219
2220 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2221 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2222 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 return;
2225 } else {
2226 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2227 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],
2228 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002229 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002230 } else {
2231 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],
2232 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002233 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002234 }
2235 return;
2236 }
2237 } else {
2238
2239 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2240
2241 /*BugID_5442*/
2242 /*Upper layer is informed that the frame is received on this freq*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002243 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002244
2245 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2246 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2247
Dean Lee72ed4dc2015-06-12 14:11:44 +09002248 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002249 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2250 return;
2251 }
2252 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2253
2254 switch (buff[ACTION_SUBTYPE_ID]) {
2255 case GAS_INTIAL_REQ:
2256 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2257 break;
2258
2259 case GAS_INTIAL_RSP:
2260 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2261 break;
2262
2263 case PUBLIC_ACT_VENDORSPEC:
2264 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2265 * 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 +09002266 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2268 if (!bWilc_ie) {
2269 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002270 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002271 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09002272 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002273 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2274 break;
2275 }
2276 }
2277 }
2278 }
2279 if (u8P2Plocalrandom > u8P2Precvrandom) {
2280 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2281 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2282 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002283 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002284 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2285 break;
2286 }
2287 }
2288 }
2289 } else
2290 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2291 }
2292
2293
2294 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2295 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2296 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002297 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298 return;
2299 }
2300 break;
2301
2302 default:
2303 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2304 break;
2305 }
2306 }
2307 }
2308
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310 }
2311}
2312
2313/**
2314 * @brief WILC_WFI_mgmt_tx_complete
2315 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2316 * @param[in] priv
2317 * transmitting status
2318 * @return None
2319 * @author Amr Abdelmoghny
2320 * @date 20 MAY 2013
2321 * @version 1.0
2322 */
2323static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2324{
2325 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2326
2327
2328 kfree(pv_data->buff);
2329 kfree(pv_data);
2330}
2331
2332/**
2333 * @brief WILC_WFI_RemainOnChannelReady
2334 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2335 * @param
2336 * @return none
2337 * @author Amr abdelmoghny
2338 * @date 9 JUNE 2013
2339 * @version
2340 */
2341
2342static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2343{
2344 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002345
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002346 priv = (struct WILC_WFI_priv *)pUserVoid;
2347
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302348 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349
Dean Lee72ed4dc2015-06-12 14:11:44 +09002350 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002351
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002352 cfg80211_ready_on_channel(priv->wdev,
2353 priv->strRemainOnChanParams.u64ListenCookie,
2354 priv->strRemainOnChanParams.pstrListenChan,
2355 priv->strRemainOnChanParams.u32ListenDuration,
2356 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357}
2358
2359/**
2360 * @brief WILC_WFI_RemainOnChannelExpired
2361 * @details Callback function, called on expiration of remain-on-channel duration
2362 * @param
2363 * @return none
2364 * @author Amr abdelmoghny
2365 * @date 15 MAY 2013
2366 * @version
2367 */
2368
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002369static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370{
2371 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002372
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002373 priv = (struct WILC_WFI_priv *)pUserVoid;
2374
2375 /*BugID_5477*/
2376 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302377 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378
Dean Lee72ed4dc2015-06-12 14:11:44 +09002379 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002380
2381 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382 cfg80211_remain_on_channel_expired(priv->wdev,
2383 priv->strRemainOnChanParams.u64ListenCookie,
2384 priv->strRemainOnChanParams.pstrListenChan,
2385 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002386 } else {
2387 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2388 , priv->strRemainOnChanParams.u32ListenSessionID);
2389 }
2390}
2391
2392
2393/**
2394 * @brief WILC_WFI_remain_on_channel
2395 * @details Request the driver to remain awake on the specified
2396 * channel for the specified duration to complete an off-channel
2397 * operation (e.g., public action frame exchange). When the driver is
2398 * ready on the requested channel, it must indicate this with an event
2399 * notification by calling cfg80211_ready_on_channel().
2400 * @param[in]
2401 * @return int : Return 0 on Success
2402 * @author mdaftedar
2403 * @date 01 MAR 2012
2404 * @version 1.0
2405 */
2406static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002408 struct ieee80211_channel *chan,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002409 unsigned int duration, u64 *cookie)
2410{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002411 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002413
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002414 priv = wiphy_priv(wiphy);
2415
2416 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2417
2418 /*BugID_4800: if in AP mode, return.*/
2419 /*This check is to handle the situation when user*/
2420 /*requests "create group" during a running scan*/
2421
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002422 if (wdev->iftype == NL80211_IFTYPE_AP) {
2423 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2424 return s32Error;
2425 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002426
2427 u8CurrChannel = chan->hw_value;
2428
2429 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2430 priv->strRemainOnChanParams.pstrListenChan = chan;
2431 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432 priv->strRemainOnChanParams.u32ListenDuration = duration;
2433 priv->strRemainOnChanParams.u32ListenSessionID++;
2434
2435 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2436 , priv->strRemainOnChanParams.u32ListenSessionID
2437 , duration
2438 , chan->hw_value
2439 , WILC_WFI_RemainOnChannelExpired
2440 , WILC_WFI_RemainOnChannelReady
2441 , (void *)priv);
2442
2443 return s32Error;
2444}
2445
2446/**
2447 * @brief WILC_WFI_cancel_remain_on_channel
2448 * @details Cancel an on-going remain-on-channel operation.
2449 * This allows the operation to be terminated prior to timeout based on
2450 * the duration value.
2451 * @param[in] struct wiphy *wiphy,
2452 * @param[in] struct net_device *dev
2453 * @param[in] u64 cookie,
2454 * @return int : Return 0 on Success
2455 * @author mdaftedar
2456 * @date 01 MAR 2012
2457 * @version 1.0
2458 */
2459static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002460 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461 u64 cookie)
2462{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002463 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002465
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466 priv = wiphy_priv(wiphy);
2467
2468 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2469
2470 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2471 return s32Error;
2472}
2473/**
2474 * @brief WILC_WFI_add_wilcvendorspec
2475 * @details Adding WILC information elemet to allow two WILC devices to
2476 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002477 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478 * @return void
2479 * @author mdaftedar
2480 * @date 01 JAN 2014
2481 * @version 1.0
2482 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002483void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002485 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486}
2487/**
2488 * @brief WILC_WFI_mgmt_tx_frame
2489 * @details
2490 *
2491 * @param[in]
2492 * @return NONE.
2493 * @author mdaftedar
2494 * @date 01 JUL 2012
2495 * @version
2496 */
2497extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002498extern bool bEnablePS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002500 struct wireless_dev *wdev,
2501 struct cfg80211_mgmt_tx_params *params,
2502 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002503{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504 struct ieee80211_channel *chan = params->chan;
2505 unsigned int wait = params->wait;
2506 const u8 *buf = params->buf;
2507 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 const struct ieee80211_mgmt *mgmt;
2509 struct p2p_mgmt_data *mgmt_tx;
2510 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002511 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002512 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002513 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002514 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002515 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002516
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002518 priv = wiphy_priv(wiphy);
2519 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2520
2521 *cookie = (unsigned long)buf;
2522 priv->u64tx_cookie = *cookie;
2523 mgmt = (const struct ieee80211_mgmt *) buf;
2524
2525 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2526
2527 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002528 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 if (mgmt_tx == NULL) {
2530 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2531 return WILC_FAIL;
2532 }
Glen Leef3052582015-09-10 12:03:04 +09002533 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002534 if (mgmt_tx->buff == NULL) {
2535 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002536 kfree(mgmt_tx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537 return WILC_FAIL;
2538 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002539 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002540 mgmt_tx->size = len;
2541
2542
2543 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2544 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2545 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2546 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2547 /*Save the current channel after we tune to it*/
2548 u8CurrChannel = chan->hw_value;
2549 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002550 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002551
2552
2553 /*BugID_4847*/
2554 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2555 /*BugID_4847*/
2556 /*Only set the channel, if not a negotiation confirmation frame
2557 * (If Negotiation confirmation frame, force it
2558 * to be transmitted on the same negotiation channel)*/
2559
2560 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2561 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2562 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2563 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2564 /*Save the current channel after we tune to it*/
2565 u8CurrChannel = chan->hw_value;
2566 }
2567 switch (buf[ACTION_SUBTYPE_ID]) {
2568 case GAS_INTIAL_REQ:
2569 {
2570 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2571 break;
2572 }
2573
2574 case GAS_INTIAL_RSP:
2575 {
2576 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2577 break;
2578 }
2579
2580 case PUBLIC_ACT_VENDORSPEC:
2581 {
2582 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2583 * 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 +09002584 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2586 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2587 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2588 get_random_bytes(&u8P2Plocalrandom, 1);
2589 /*Increment the number to prevent if its 0*/
2590 u8P2Plocalrandom++;
2591 }
2592 }
2593
2594 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2595 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2596 if (u8P2Plocalrandom > u8P2Precvrandom) {
2597 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2598
2599 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2600 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002601 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002602 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002603 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002604
2605 /*BugID_5460*/
2606 /*If using supplicant go intent, no need at all*/
2607 /*to parse transmitted negotiation frames*/
2608 #ifndef USE_SUPPLICANT_GO_INTENT
2609 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002610 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002611 #endif
2612 break;
2613 }
2614 }
2615
2616 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2617 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2618 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2619 mgmt_tx->size = buf_len;
2620 }
2621 } else
2622 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2623 }
2624
2625 } else {
2626 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2627 }
2628
2629 break;
2630 }
2631
2632 default:
2633 {
2634 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2635 break;
2636 }
2637 }
2638
2639 }
2640
2641 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2642 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2643
2644 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2645
2646 }
2647
2648 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2649 } else {
2650 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2651 }
2652 return s32Error;
2653}
2654
2655int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002657 u64 cookie)
2658{
2659 struct WILC_WFI_priv *priv;
2660 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002661
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002662 priv = wiphy_priv(wiphy);
2663 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2664
2665
2666 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2667 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2668
Dean Lee72ed4dc2015-06-12 14:11:44 +09002669 if (priv->bInP2PlistenState == false) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2671 * considers the driver falsely that it is in Listen state */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002672 cfg80211_remain_on_channel_expired(priv->wdev,
2673 priv->strRemainOnChanParams.u64ListenCookie,
2674 priv->strRemainOnChanParams.pstrListenChan,
2675 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002676 }
2677
2678 return 0;
2679}
2680
2681/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682 * @brief WILC_WFI_frame_register
2683 * @details Notify driver that a management frame type was
2684 * registered. Note that this callback may not sleep, and cannot run
2685 * concurrently with itself.
2686 * @param[in]
2687 * @return NONE.
2688 * @author mdaftedar
2689 * @date 01 JUL 2012
2690 * @version
2691 */
2692void WILC_WFI_frame_register(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002693 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002694 u16 frame_type, bool reg)
2695{
2696
2697 struct WILC_WFI_priv *priv;
2698 perInterface_wlan_t *nic;
2699
2700
2701 priv = wiphy_priv(wiphy);
2702 nic = netdev_priv(priv->wdev->netdev);
2703
2704
2705
2706 /*BugID_5137*/
2707 if (!frame_type)
2708 return;
2709
2710 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2711 switch (frame_type) {
2712 case PROBE_REQ:
2713 {
2714 nic->g_struct_frame_reg[0].frame_type = frame_type;
2715 nic->g_struct_frame_reg[0].reg = reg;
2716 }
2717 break;
2718
2719 case ACTION:
2720 {
2721 nic->g_struct_frame_reg[1].frame_type = frame_type;
2722 nic->g_struct_frame_reg[1].reg = reg;
2723 }
2724 break;
2725
2726 default:
2727 {
2728 break;
2729 }
2730
2731 }
2732 /*If mac is closed, then return*/
2733 if (!g_linux_wlan->wilc1000_initialized) {
2734 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2735 return;
2736 }
2737 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2738
2739
2740}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741#endif /*WILC_P2P*/
2742
2743/**
2744 * @brief WILC_WFI_set_cqm_rssi_config
2745 * @details Configure connection quality monitor RSSI threshold.
2746 * @param[in] struct wiphy *wiphy:
2747 * @param[in] struct net_device *dev:
2748 * @param[in] s32 rssi_thold:
2749 * @param[in] u32 rssi_hyst:
2750 * @return int : Return 0 on Success
2751 * @author mdaftedar
2752 * @date 01 MAR 2012
2753 * @version 1.0
2754 */
2755static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2756 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2757{
2758 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2759 return 0;
2760
2761}
2762/**
2763 * @brief WILC_WFI_dump_station
2764 * @details Configure connection quality monitor RSSI threshold.
2765 * @param[in] struct wiphy *wiphy:
2766 * @param[in] struct net_device *dev
2767 * @param[in] int idx
2768 * @param[in] u8 *mac
2769 * @param[in] struct station_info *sinfo
2770 * @return int : Return 0 on Success
2771 * @author mdaftedar
2772 * @date 01 MAR 2012
2773 * @version 1.0
2774 */
2775static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
2776 int idx, u8 *mac, struct station_info *sinfo)
2777{
2778 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002779
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2781
2782 if (idx != 0)
2783 return -ENOENT;
2784
2785 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002788
2789 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2790
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 return 0;
2792
2793}
2794
2795
2796/**
2797 * @brief WILC_WFI_set_power_mgmt
2798 * @details
2799 * @param[in]
2800 * @return int : Return 0 on Success.
2801 * @author mdaftedar
2802 * @date 01 JUL 2012
2803 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
2804 */
2805int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2806 bool enabled, int timeout)
2807{
2808 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002809
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002810 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2811
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002812 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002813 return -ENOENT;
2814
2815 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002816 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002817 PRINT_ER("Driver is NULL\n");
2818 return -EIO;
2819 }
2820
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002821 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002822 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2823
2824
2825 return WILC_SUCCESS;
2826
2827}
2828#ifdef WILC_AP_EXTERNAL_MLME
2829/**
2830 * @brief WILC_WFI_change_virt_intf
2831 * @details Change type/configuration of virtual interface,
2832 * keep the struct wireless_dev's iftype updated.
2833 * @param[in] NONE
2834 * @return int : Return 0 on Success.
2835 * @author mdaftedar
2836 * @date 01 MAR 2012
2837 * @version 1.0
2838 */
2839void wilc1000_wlan_deinit(linux_wlan_t *nic);
2840int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2841
2842static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
2843 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
2844{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002845 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002846 struct WILC_WFI_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002848 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002849 u16 TID = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002850 #ifdef WILC_P2P
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002851 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852 #endif
2853
2854 nic = netdev_priv(dev);
2855 priv = wiphy_priv(wiphy);
2856
2857 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2858 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2859 u8P2Plocalrandom = 0x01;
2860 u8P2Precvrandom = 0x00;
2861
Dean Lee72ed4dc2015-06-12 14:11:44 +09002862 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002863
2864 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09002865 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002866 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002867 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2868 #endif
2869 /*BugID_5137*/
2870 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2871 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002872 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002873 }
2874
2875 switch (type) {
2876 case NL80211_IFTYPE_STATION:
2877 connecting = 0;
2878 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002879
2880 /* send delba over wlan interface */
2881
2882
2883 dev->ieee80211_ptr->iftype = type;
2884 priv->wdev->iftype = type;
2885 nic->monitor_flag = 0;
2886 nic->iftype = STATION_MODE;
2887
2888 /*Remove the enteries of the previously connected clients*/
2889 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890 #ifdef WILC_P2P
2891 interface_type = nic->iftype;
2892 nic->iftype = STATION_MODE;
2893
2894 if (g_linux_wlan->wilc1000_initialized) {
2895 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2896 /* ensure that the message Q is empty */
2897 host_int_wait_msg_queue_idle();
2898
2899 /*BugID_5213*/
2900 /*Eliminate host interface blocking state*/
Greg Kroah-Hartman8990d852015-09-03 20:07:58 -07002901 up(&g_linux_wlan->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002902
2903 wilc1000_wlan_deinit(g_linux_wlan);
2904 wilc1000_wlan_init(dev, nic);
2905 g_wilc_initialized = 1;
2906 nic->iftype = interface_type;
2907
2908 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2909 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002910 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002911 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2912 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2913
2914 /*Add saved WEP keys, if any*/
2915 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002916 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002917 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002918 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919 g_key_wep_params.key,
2920 g_key_wep_params.key_len,
2921 g_key_wep_params.key_idx);
2922 }
2923
2924 /*No matter the driver handler passed here, it will be overwriiten*/
2925 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2926 host_int_flush_join_req(priv->hWILCWFIDrv);
2927
2928 /*Add saved PTK and GTK keys, if any*/
2929 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2930 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2931 g_key_ptk_params.key[1],
2932 g_key_ptk_params.key[2]);
2933 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2934 g_key_gtk_params.key[1],
2935 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002936 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2937 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2938 g_add_ptk_key_params.key_idx,
2939 g_add_ptk_key_params.pairwise,
2940 g_add_ptk_key_params.mac_addr,
2941 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942
Chaehyun Lim953d4172015-09-14 12:24:05 +09002943 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2944 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2945 g_add_gtk_key_params.key_idx,
2946 g_add_gtk_key_params.pairwise,
2947 g_add_gtk_key_params.mac_addr,
2948 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949 }
2950
2951 /*BugID_4847: registered frames in firmware are now*/
2952 /*lost due to mac close. So re-register those frames*/
2953 if (g_linux_wlan->wilc1000_initialized) {
2954 for (i = 0; i < num_reg_frame; i++) {
2955 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2956 nic->g_struct_frame_reg[i].reg);
2957 host_int_frame_register(priv->hWILCWFIDrv,
2958 nic->g_struct_frame_reg[i].frame_type,
2959 nic->g_struct_frame_reg[i].reg);
2960 }
2961 }
2962
Dean Lee72ed4dc2015-06-12 14:11:44 +09002963 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2965 }
2966 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002967 break;
2968
2969 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002970 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002971 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2972 connecting = 0;
2973 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002974
2975 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2976
2977 dev->ieee80211_ptr->iftype = type;
2978 priv->wdev->iftype = type;
2979 nic->monitor_flag = 0;
2980
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981 #ifdef WILC_P2P
2982
2983 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2984 nic->iftype = CLIENT_MODE;
2985
2986
2987 if (g_linux_wlan->wilc1000_initialized) {
2988 /* ensure that the message Q is empty */
2989 host_int_wait_msg_queue_idle();
2990
2991 wilc1000_wlan_deinit(g_linux_wlan);
2992 wilc1000_wlan_init(dev, nic);
2993 g_wilc_initialized = 1;
2994
2995 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002996 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002997 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2998 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2999
3000 /*Add saved WEP keys, if any*/
3001 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09003002 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003003 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09003004 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003005 g_key_wep_params.key,
3006 g_key_wep_params.key_len,
3007 g_key_wep_params.key_idx);
3008 }
3009
3010 /*No matter the driver handler passed here, it will be overwriiten*/
3011 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3012 host_int_flush_join_req(priv->hWILCWFIDrv);
3013
3014 /*Add saved PTK and GTK keys, if any*/
3015 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3016 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
3017 g_key_ptk_params.key[1],
3018 g_key_ptk_params.key[2]);
3019 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
3020 g_key_gtk_params.key[1],
3021 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09003022 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3023 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3024 g_add_ptk_key_params.key_idx,
3025 g_add_ptk_key_params.pairwise,
3026 g_add_ptk_key_params.mac_addr,
3027 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003028
Chaehyun Lim953d4172015-09-14 12:24:05 +09003029 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3030 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3031 g_add_gtk_key_params.key_idx,
3032 g_add_gtk_key_params.pairwise,
3033 g_add_gtk_key_params.mac_addr,
3034 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003035 }
3036
3037 /*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 +09003038 refresh_scan(priv, 1, true);
3039 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003040
3041 /*BugID_4847: registered frames in firmware are now lost
3042 * due to mac close. So re-register those frames */
3043 if (g_linux_wlan->wilc1000_initialized) {
3044 for (i = 0; i < num_reg_frame; i++) {
3045 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3046 nic->g_struct_frame_reg[i].reg);
3047 host_int_frame_register(priv->hWILCWFIDrv,
3048 nic->g_struct_frame_reg[i].frame_type,
3049 nic->g_struct_frame_reg[i].reg);
3050 }
3051 }
3052 }
3053 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054 break;
3055
3056 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09003057 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059 dev->ieee80211_ptr->iftype = type;
3060 priv->wdev->iftype = type;
3061 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09003062 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003063
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003064 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
3065 linux_wlan_get_firmware(nic);
3066 #ifdef WILC_P2P
3067 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
3068 if (g_linux_wlan->wilc1000_initialized) {
3069 nic->iftype = AP_MODE;
3070 g_linux_wlan->wilc1000_initialized = 1;
3071 mac_close(dev);
3072 mac_open(dev);
3073
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074 /*BugID_4847: registered frames in firmware are now lost
3075 * due to mac close. So re-register those frames */
3076 for (i = 0; i < num_reg_frame; i++) {
3077 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3078 nic->g_struct_frame_reg[i].reg);
3079 host_int_frame_register(priv->hWILCWFIDrv,
3080 nic->g_struct_frame_reg[i].frame_type,
3081 nic->g_struct_frame_reg[i].reg);
3082 }
3083 }
3084 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003085 break;
3086
3087 case NL80211_IFTYPE_P2P_GO:
3088 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3089
3090 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09003091 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003092 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003093 #endif
3094 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3095 /*BugID_5222*/
3096 /*Delete block ack has to be the latest config packet*/
3097 /*sent before downloading new FW. This is because it blocks on*/
3098 /*hWaitResponse semaphore, which allows previous config*/
3099 /*packets to actually take action on old FW*/
3100 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09003101 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003103 dev->ieee80211_ptr->iftype = type;
3104 priv->wdev->iftype = type;
3105
Johnny Kim8a143302015-06-10 17:06:46 +09003106 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003107
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003108 #ifdef WILC_P2P
3109 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3110
3111
3112 #if 1
3113 nic->iftype = GO_MODE;
3114
3115 /* ensure that the message Q is empty */
3116 host_int_wait_msg_queue_idle();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117 wilc1000_wlan_deinit(g_linux_wlan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003118 wilc1000_wlan_init(dev, nic);
3119 g_wilc_initialized = 1;
3120
3121
3122 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3123 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09003124 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003125 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3126 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3127
3128 /*Add saved WEP keys, if any*/
3129 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09003130 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003131 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09003132 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133 g_key_wep_params.key,
3134 g_key_wep_params.key_len,
3135 g_key_wep_params.key_idx);
3136 }
3137
3138 /*No matter the driver handler passed here, it will be overwriiten*/
3139 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3140 host_int_flush_join_req(priv->hWILCWFIDrv);
3141
3142 /*Add saved PTK and GTK keys, if any*/
3143 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3144 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3145 g_key_ptk_params.key[1],
3146 g_key_ptk_params.key[2],
3147 g_key_ptk_params.cipher);
3148 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3149 g_key_gtk_params.key[1],
3150 g_key_gtk_params.key[2],
3151 g_key_gtk_params.cipher);
3152 #if 1
Chaehyun Lim953d4172015-09-14 12:24:05 +09003153 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3154 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3155 g_add_ptk_key_params.key_idx,
3156 g_add_ptk_key_params.pairwise,
3157 g_add_ptk_key_params.mac_addr,
3158 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003159
Chaehyun Lim953d4172015-09-14 12:24:05 +09003160 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3161 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3162 g_add_gtk_key_params.key_idx,
3163 g_add_gtk_key_params.pairwise,
3164 g_add_gtk_key_params.mac_addr,
3165 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166 #endif
3167 }
3168 #endif
3169
3170 /*BugID_4847: registered frames in firmware are now*/
3171 /*lost due to mac close. So re-register those frames*/
3172 if (g_linux_wlan->wilc1000_initialized) {
3173 for (i = 0; i < num_reg_frame; i++) {
3174 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3175 nic->g_struct_frame_reg[i].reg);
3176 host_int_frame_register(priv->hWILCWFIDrv,
3177 nic->g_struct_frame_reg[i].frame_type,
3178 nic->g_struct_frame_reg[i].reg);
3179 }
3180 }
3181 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003182 break;
3183
3184 default:
3185 PRINT_ER("Unknown interface type= %d\n", type);
3186 s32Error = -EINVAL;
3187 return s32Error;
3188 break;
3189 }
3190
3191 return s32Error;
3192}
3193
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003194/* (austin.2013-07-23)
3195 *
3196 * To support revised cfg80211_ops
3197 *
3198 * add_beacon --> start_ap
3199 * set_beacon --> change_beacon
3200 * del_beacon --> stop_ap
3201 *
3202 * beacon_parameters --> cfg80211_ap_settings
3203 * cfg80211_beacon_data
3204 *
3205 * applicable for linux kernel 3.4+
3206 */
3207
3208/**
3209 * @brief WILC_WFI_start_ap
3210 * @details Add a beacon with given parameters, @head, @interval
3211 * and @dtim_period will be valid, @tail is optional.
3212 * @param[in] wiphy
3213 * @param[in] dev The net device structure
3214 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3215 * @return int : Return 0 on Success.
3216 * @author austin
3217 * @date 23 JUL 2013
3218 * @version 1.0
3219 */
3220static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
3221 struct cfg80211_ap_settings *settings)
3222{
3223 struct cfg80211_beacon_data *beacon = &(settings->beacon);
3224 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003225 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226
3227 priv = wiphy_priv(wiphy);
3228 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3229
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303230 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 +09003231 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3232
Chaehyun Lim80785a92015-09-14 12:24:01 +09003233 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003234
3235 if (s32Error != WILC_SUCCESS)
3236 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237
3238 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3239
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3241 settings->beacon_interval,
3242 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003243 beacon->head_len, (u8 *)beacon->head,
3244 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003245
3246 return s32Error;
3247}
3248
3249/**
3250 * @brief WILC_WFI_change_beacon
3251 * @details Add a beacon with given parameters, @head, @interval
3252 * and @dtim_period will be valid, @tail is optional.
3253 * @param[in] wiphy
3254 * @param[in] dev The net device structure
3255 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3256 * @return int : Return 0 on Success.
3257 * @author austin
3258 * @date 23 JUL 2013
3259 * @version 1.0
3260 */
3261static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
3262 struct cfg80211_beacon_data *beacon)
3263{
3264 struct WILC_WFI_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003265 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266
3267 priv = wiphy_priv(wiphy);
3268 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3269
3270
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003271 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3272 0,
3273 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003274 beacon->head_len, (u8 *)beacon->head,
3275 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276
3277 return s32Error;
3278}
3279
3280/**
3281 * @brief WILC_WFI_stop_ap
3282 * @details Remove beacon configuration and stop sending the beacon.
3283 * @param[in]
3284 * @return int : Return 0 on Success.
3285 * @author austin
3286 * @date 23 JUL 2013
3287 * @version 1.0
3288 */
3289static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
3290{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003291 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292 struct WILC_WFI_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003293 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003294
3295
3296 WILC_NULLCHECK(s32Error, wiphy);
3297
3298 priv = wiphy_priv(wiphy);
3299
3300 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3301
3302 /*BugID_5188*/
3303 linux_wlan_set_bssid(dev, NullBssid);
3304
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003305 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306
3307 WILC_ERRORCHECK(s32Error);
3308
3309 WILC_CATCH(s32Error)
3310 {
3311 }
3312 return s32Error;
3313}
3314
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315/**
3316 * @brief WILC_WFI_add_station
3317 * @details Add a new station.
3318 * @param[in]
3319 * @return int : Return 0 on Success.
3320 * @author mdaftedar
3321 * @date 01 MAR 2012
3322 * @version 1.0
3323 */
3324static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003325 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003327 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328 struct WILC_WFI_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303329 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330 perInterface_wlan_t *nic;
3331
3332
3333 WILC_NULLCHECK(s32Error, wiphy);
3334
3335 priv = wiphy_priv(wiphy);
3336 nic = netdev_priv(dev);
3337
3338 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003339 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3340 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341 strStaParams.u16AssocID = params->aid;
3342 strStaParams.u8NumRates = params->supported_rates_len;
3343 strStaParams.pu8Rates = params->supported_rates;
3344
3345 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3346
3347 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],
3348 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3349 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3350 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3351
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003352 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003353 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003354 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003355 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3357 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003358 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3360 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3361 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3362 }
3363
3364 strStaParams.u16FlagsMask = params->sta_flags_mask;
3365 strStaParams.u16FlagsSet = params->sta_flags_set;
3366
3367 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3368 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3369 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3370 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3371 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3372 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3373 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3374 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3375
3376 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3377 WILC_ERRORCHECK(s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003378 }
3379
3380 WILC_CATCH(s32Error)
3381 {
3382 }
3383 return s32Error;
3384}
3385
3386/**
3387 * @brief WILC_WFI_del_station
3388 * @details Remove a station; @mac may be NULL to remove all stations.
3389 * @param[in]
3390 * @return int : Return 0 on Success.
3391 * @author mdaftedar
3392 * @date 01 MAR 2012
3393 * @version 1.0
3394 */
3395static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003397{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003398 const u8 *mac = params->mac;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003399 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400 struct WILC_WFI_priv *priv;
3401 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003402
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403 WILC_NULLCHECK(s32Error, wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003404
3405 priv = wiphy_priv(wiphy);
3406 nic = netdev_priv(dev);
3407
3408 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3409 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3410
3411
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003412 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303413 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3415 } else {
3416 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]);
3417 }
3418
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003419 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420
3421 WILC_ERRORCHECK(s32Error);
3422 }
3423 WILC_CATCH(s32Error)
3424 {
3425 }
3426 return s32Error;
3427}
3428
3429/**
3430 * @brief WILC_WFI_change_station
3431 * @details Modify a given station.
3432 * @param[in]
3433 * @return int : Return 0 on Success.
3434 * @author mdaftedar
3435 * @date 01 MAR 2012
3436 * @version 1.0
3437 */
3438static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003439 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003441 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442 struct WILC_WFI_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303443 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003444 perInterface_wlan_t *nic;
3445
3446
3447 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3448
3449 WILC_NULLCHECK(s32Error, wiphy);
3450
3451 priv = wiphy_priv(wiphy);
3452 nic = netdev_priv(dev);
3453
3454 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003455 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003456 strStaParams.u16AssocID = params->aid;
3457 strStaParams.u8NumRates = params->supported_rates_len;
3458 strStaParams.pu8Rates = params->supported_rates;
3459
3460 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],
3461 strStaParams.au8BSSID[5]);
3462 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3463 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3464
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003465 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003466 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003467 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003468 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003469 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3470 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003471 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3473 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3474 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3475
3476 }
3477
3478 strStaParams.u16FlagsMask = params->sta_flags_mask;
3479 strStaParams.u16FlagsSet = params->sta_flags_set;
3480
3481 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3482 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3483 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3484 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3485 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3486 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3487 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3488 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3489
3490 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3491 WILC_ERRORCHECK(s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003492 }
3493 WILC_CATCH(s32Error)
3494 {
3495 }
3496 return s32Error;
3497}
3498
3499
3500/**
3501 * @brief WILC_WFI_add_virt_intf
3502 * @details
3503 * @param[in]
3504 * @return int : Return 0 on Success.
3505 * @author mdaftedar
3506 * @date 01 JUL 2012
3507 * @version 1.0
3508 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003509struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
3510 unsigned char name_assign_type,
3511 enum nl80211_iftype type, u32 *flags,
3512 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003513{
3514 perInterface_wlan_t *nic;
3515 struct WILC_WFI_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003517
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 priv = wiphy_priv(wiphy);
3519
3520
3521
3522 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3523
3524 nic = netdev_priv(priv->wdev->netdev);
3525
3526
3527 if (type == NL80211_IFTYPE_MONITOR) {
3528 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3529 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3530 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3531 if (new_ifc != NULL) {
3532 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003533 nic = netdev_priv(priv->wdev->netdev);
3534 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003535 } else
3536 PRINT_ER("Error in initializing monitor interface\n ");
3537 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003539}
3540
3541/**
3542 * @brief WILC_WFI_del_virt_intf
3543 * @details
3544 * @param[in]
3545 * @return int : Return 0 on Success.
3546 * @author mdaftedar
3547 * @date 01 JUL 2012
3548 * @version 1.0
3549 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003550int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003551{
3552 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3553 return WILC_SUCCESS;
3554}
3555
3556
3557
3558#endif /*WILC_AP_EXTERNAL_MLME*/
3559static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
3560
Chaehyun Lim80785a92015-09-14 12:24:01 +09003561 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003562 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003563 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003564 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003565 .add_key = add_key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003566 .del_key = WILC_WFI_del_key,
3567 .get_key = WILC_WFI_get_key,
3568 .set_default_key = WILC_WFI_set_default_key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569 #ifdef WILC_AP_EXTERNAL_MLME
3570 .add_virtual_intf = WILC_WFI_add_virt_intf,
3571 .del_virtual_intf = WILC_WFI_del_virt_intf,
3572 .change_virtual_intf = WILC_WFI_change_virt_intf,
3573
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003574 .start_ap = WILC_WFI_start_ap,
3575 .change_beacon = WILC_WFI_change_beacon,
3576 .stop_ap = WILC_WFI_stop_ap,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577 .add_station = WILC_WFI_add_station,
3578 .del_station = WILC_WFI_del_station,
3579 .change_station = WILC_WFI_change_station,
3580 #endif /* WILC_AP_EXTERNAL_MLME*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003581 .get_station = WILC_WFI_get_station,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003582 .dump_station = WILC_WFI_dump_station,
3583 .change_bss = WILC_WFI_change_bss,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003584 .set_wiphy_params = WILC_WFI_set_wiphy_params,
3585
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003586 .set_pmksa = WILC_WFI_set_pmksa,
3587 .del_pmksa = WILC_WFI_del_pmksa,
3588 .flush_pmksa = WILC_WFI_flush_pmksa,
3589#ifdef WILC_P2P
3590 .remain_on_channel = WILC_WFI_remain_on_channel,
3591 .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
3592 .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003593 .mgmt_tx = WILC_WFI_mgmt_tx,
3594 .mgmt_frame_register = WILC_WFI_frame_register,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003595 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3596 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3597#endif
3598
3599};
3600
3601
3602
3603
3604
3605/**
3606 * @brief WILC_WFI_update_stats
3607 * @details Modify parameters for a given BSS.
3608 * @param[in]
3609 * @return int : Return 0 on Success.
3610 * @author mdaftedar
3611 * @date 01 MAR 2012
3612 * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
3613 */
3614int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3615{
3616
3617 struct WILC_WFI_priv *priv;
3618
3619 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003620#if 1
3621 switch (changed) {
3622
3623 case WILC_WFI_RX_PKT:
3624 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625 priv->netstats.rx_packets++;
3626 priv->netstats.rx_bytes += pktlen;
3627 priv->netstats.rx_time = get_jiffies_64();
3628 }
3629 break;
3630
3631 case WILC_WFI_TX_PKT:
3632 {
3633 priv->netstats.tx_packets++;
3634 priv->netstats.tx_bytes += pktlen;
3635 priv->netstats.tx_time = get_jiffies_64();
3636
3637 }
3638 break;
3639
3640 default:
3641 break;
3642 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003643#endif
3644 return 0;
3645}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647/**
3648 * @brief WILC_WFI_CfgAlloc
3649 * @details Allocation of the wireless device structure and assigning it
3650 * to the cfg80211 operations structure.
3651 * @param[in] NONE
3652 * @return wireless_dev : Returns pointer to wireless_dev structure.
3653 * @author mdaftedar
3654 * @date 01 MAR 2012
3655 * @version 1.0
3656 */
3657struct wireless_dev *WILC_WFI_CfgAlloc(void)
3658{
3659
3660 struct wireless_dev *wdev;
3661
3662
3663 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3664 /*Allocating the wireless device structure*/
3665 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3666 if (!wdev) {
3667 PRINT_ER("Cannot allocate wireless device\n");
3668 goto _fail_;
3669 }
3670
3671 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3672 wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
3673 if (!wdev->wiphy) {
3674 PRINT_ER("Cannot allocate wiphy\n");
3675 goto _fail_mem_;
3676
3677 }
3678
3679 #ifdef WILC_AP_EXTERNAL_MLME
3680 /* enable 802.11n HT */
3681 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3682 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3683 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3684 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3685 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3686 #endif
3687
3688 /*wiphy bands*/
3689 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3690
3691 return wdev;
3692
3693_fail_mem_:
3694 kfree(wdev);
3695_fail_:
3696 return NULL;
3697
3698}
3699/**
3700 * @brief WILC_WFI_WiphyRegister
3701 * @details Registering of the wiphy structure and interface modes
3702 * @param[in] NONE
3703 * @return NONE
3704 * @author mdaftedar
3705 * @date 01 MAR 2012
3706 * @version 1.0
3707 */
3708struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3709{
3710 struct WILC_WFI_priv *priv;
3711 struct wireless_dev *wdev;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003712 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003713
3714 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3715
3716 wdev = WILC_WFI_CfgAlloc();
3717 if (wdev == NULL) {
3718 PRINT_ER("CfgAlloc Failed\n");
3719 return NULL;
3720 }
3721
3722
3723 /*Return hardware description structure (wiphy)'s priv*/
3724 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003725 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726
3727 /*Link the wiphy with wireless structure*/
3728 priv->wdev = wdev;
3729
3730 /*Maximum number of probed ssid to be added by user for the scan request*/
3731 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732 /*Maximum number of pmkids to be cashed*/
3733 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3734 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003735
3736 wdev->wiphy->max_scan_ie_len = 1000;
3737
3738 /*signal strength in mBm (100*dBm) */
3739 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3740
3741 /*Set the availaible cipher suites*/
3742 wdev->wiphy->cipher_suites = cipher_suites;
3743 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744 /*Setting default managment types: for register action frame: */
3745 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003746
3747#ifdef WILC_P2P
3748 wdev->wiphy->max_remain_on_channel_duration = 500;
3749 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3750 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3751 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753#else
3754 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3755#endif
3756 wdev->iftype = NL80211_IFTYPE_STATION;
3757
3758
3759
3760 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3761 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3762 wdev->wiphy->interface_modes, wdev->iftype);
3763
3764 #ifdef WILC_SDIO
3765 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3766 #endif
3767
3768 /*Register wiphy structure*/
3769 s32Error = wiphy_register(wdev->wiphy);
3770 if (s32Error) {
3771 PRINT_ER("Cannot register wiphy device\n");
3772 /*should define what action to be taken in such failure*/
3773 } else {
3774 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3775 }
3776
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003778 return wdev;
3779
3780
3781}
3782/**
3783 * @brief WILC_WFI_WiphyFree
3784 * @details Freeing allocation of the wireless device structure
3785 * @param[in] NONE
3786 * @return NONE
3787 * @author mdaftedar
3788 * @date 01 MAR 2012
3789 * @version 1.0
3790 */
3791int WILC_WFI_InitHostInt(struct net_device *net)
3792{
3793
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003794 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003795
3796 struct WILC_WFI_priv *priv;
3797
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3799 priv = wdev_priv(net->ieee80211_ptr);
3800 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003801 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003802 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003803 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804 #endif
3805 }
3806 op_ifcs++;
3807 if (s32Error < 0) {
3808 PRINT_ER("Failed to creat refresh Timer\n");
3809 return s32Error;
3810 }
3811
Dean Lee72ed4dc2015-06-12 14:11:44 +09003812 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003813
Dean Lee72ed4dc2015-06-12 14:11:44 +09003814 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003815
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003816 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003817 s32Error = host_int_init(&priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818 if (s32Error) {
3819 PRINT_ER("Error while initializing hostinterface\n");
3820 }
3821 return s32Error;
3822}
3823
3824/**
3825 * @brief WILC_WFI_WiphyFree
3826 * @details Freeing allocation of the wireless device structure
3827 * @param[in] NONE
3828 * @return NONE
3829 * @author mdaftedar
3830 * @date 01 MAR 2012
3831 * @version 1.0
3832 */
3833int WILC_WFI_DeInitHostInt(struct net_device *net)
3834{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003835 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003836
3837 struct WILC_WFI_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003838
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839 priv = wdev_priv(net->ieee80211_ptr);
3840
Dean Lee72ed4dc2015-06-12 14:11:44 +09003841 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842
Dean Lee72ed4dc2015-06-12 14:11:44 +09003843 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003844
3845 op_ifcs--;
3846
3847 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003848
3849 /* Clear the Shadow scan */
3850 clear_shadow_scan(priv);
3851 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3852 if (op_ifcs == 0) {
3853 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003854 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003855 }
3856 #endif
3857
3858 if (s32Error) {
3859 PRINT_ER("Error while deintializing host interface\n");
3860 }
3861 return s32Error;
3862}
3863
3864
3865/**
3866 * @brief WILC_WFI_WiphyFree
3867 * @details Freeing allocation of the wireless device structure
3868 * @param[in] NONE
3869 * @return NONE
3870 * @author mdaftedar
3871 * @date 01 MAR 2012
3872 * @version 1.0
3873 */
3874void WILC_WFI_WiphyFree(struct net_device *net)
3875{
3876
3877 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3878
3879 if (net == NULL) {
3880 PRINT_D(INIT_DBG, "net_device is NULL\n");
3881 return;
3882 }
3883
3884 if (net->ieee80211_ptr == NULL) {
3885 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3886 return;
3887 }
3888
3889 if (net->ieee80211_ptr->wiphy == NULL) {
3890 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3891 return;
3892 }
3893
3894 wiphy_unregister(net->ieee80211_ptr->wiphy);
3895
3896 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3897 wiphy_free(net->ieee80211_ptr->wiphy);
3898 kfree(net->ieee80211_ptr);
3899
3900}