blob: 48def8cb431864fedeaabc2d44afd0a0fab33e22 [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
Leo Kim7ae43362015-09-16 18:35:59 +090018#include <linux/errno.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +090019
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;
Daniel Machon7fc80962015-08-05 00:09:35 +0200135bool g_ptk_keys_saved;
136bool g_gtk_keys_saved;
137bool g_wep_keys_saved;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900138
139#define AGING_TIME (9 * 1000)
140#define duringIP_TIME 15000
141
142void clear_shadow_scan(void *pUserVoid)
143{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900144 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900145
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900146 if (op_ifcs == 0) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -0700147 del_timer_sync(&hAgingTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900148 PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
149
150 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
151 if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900152 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153 astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
154 }
155
156 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
157 astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
158 }
159 u32LastScannedNtwrksCountShadow = 0;
160 }
161
162}
163
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900164u32 get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900165{
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900166 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900167 int rssi_v = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900168 u8 num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900169
170 for (i = 0; i < num_rssi; i++)
171 rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
172
173 rssi_v /= num_rssi;
174 return rssi_v;
175}
176
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900177void refresh_scan(void *pUserVoid, u8 all, bool bDirectScan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900178{
Chaehyun Lim27268872015-09-15 14:06:13 +0900179 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900180 struct wiphy *wiphy;
181 struct cfg80211_bss *bss = NULL;
182 int i;
183 int rssi = 0;
184
Chaehyun Lim27268872015-09-15 14:06:13 +0900185 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900186 wiphy = priv->dev->ieee80211_ptr->wiphy;
187
188 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
189 tstrNetworkInfo *pstrNetworkInfo;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900190
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900191 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
192
193
194 if ((!pstrNetworkInfo->u8Found) || all) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900195 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 struct ieee80211_channel *channel;
197
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900198 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900199
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900200 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900201 channel = ieee80211_get_channel(wiphy, s32Freq);
202
203 rssi = get_rssi_avg(pstrNetworkInfo);
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900204 if (memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900205 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
206 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900207 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900208 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900209 }
210 }
211
212 }
213 }
214
215}
216
217void reset_shadow_found(void *pUserVoid)
218{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900220
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900221 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
222 astrLastScannedNtwrksShadow[i].u8Found = 0;
223
224 }
225}
226
227void update_scan_time(void *pUserVoid)
228{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900229 int i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900230
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900231 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
232 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
233 }
234}
235
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700236static void remove_network_from_shadow(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900237{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900238 unsigned long now = jiffies;
239 int i, j;
240
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900241
242 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
243 if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530244 PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900245
246 if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +0900247 kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900248 astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
249 }
250
251 host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
252
253 for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
254 astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
255 }
256 u32LastScannedNtwrksCountShadow--;
257 }
258 }
259
260 PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700261 if (u32LastScannedNtwrksCountShadow != 0) {
262 hAgingTimer.data = arg;
263 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
264 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900265 PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700266 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900267}
268
269#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -0700270static void clear_duringIP(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271{
272 PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900273 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274}
275#endif
276
277int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
278{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900279 int8_t state = -1;
280 int i;
281
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900282 if (u32LastScannedNtwrksCountShadow == 0) {
283 PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -0700284 hAgingTimer.data = (unsigned long)pUserVoid;
285 mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900286 state = -1;
287 } else {
288 /* Linear search for now */
289 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900290 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900291 pstrNetworkInfo->au8bssid, 6) == 0) {
292 state = i;
293 break;
294 }
295 }
296 }
297 return state;
298}
299
300void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
301{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900302 int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
Chaehyun Limfbc2fe12015-09-15 14:06:16 +0900303 u32 ap_index = 0;
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900304 u8 rssi_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900305
306 if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
307 PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
308 return;
309 }
310 if (ap_found == -1) {
311 ap_index = u32LastScannedNtwrksCountShadow;
312 u32LastScannedNtwrksCountShadow++;
313
314 } else {
315 ap_index = ap_found;
316 }
317 rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
318 astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
319 if (rssi_index == NUM_RSSI) {
320 rssi_index = 0;
321 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
322 }
323 astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
324
325 astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
326 astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
327
328 astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900329 memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900330 pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
331
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900332 memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900333 pstrNetworkInfo->au8bssid, ETH_ALEN);
334
335 astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
336 astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
337 astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
338
339 astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
340 astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
341 if (ap_found != -1)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900342 kfree(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900343 astrLastScannedNtwrksShadow[ap_index].pu8IEs =
Glen Leef3052582015-09-10 12:03:04 +0900344 kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900345 memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900346 pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
347
348 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
349 astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
350 astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
351 if (ap_found != -1)
352 host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
353 astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
354
355}
356
357
358/**
359 * @brief CfgScanResult
360 * @details Callback function which returns the scan results found
361 *
362 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
363 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
364 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
365 * void* pUserVoid: Private structure associated with the wireless interface
366 * @return NONE
367 * @author mabubakr
368 * @date
369 * @version 1.0
370 */
371static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
372{
Chaehyun Lim27268872015-09-15 14:06:13 +0900373 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900374 struct wiphy *wiphy;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900375 s32 s32Freq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376 struct ieee80211_channel *channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377 struct cfg80211_bss *bss = NULL;
378
Chaehyun Lim27268872015-09-15 14:06:13 +0900379 priv = (struct wilc_priv *)pUserVoid;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900380 if (priv->bCfgScanning == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900381 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
382 wiphy = priv->dev->ieee80211_ptr->wiphy;
Leo Kim7ae43362015-09-16 18:35:59 +0900383
384 if (!wiphy)
385 return;
386
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900387 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
388 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900389 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900391 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392 ) {
Leo Kim24db7132015-09-16 18:36:01 +0900393 PRINT_ER("wiphy signal type fial\n");
394 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900395 }
396
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900397 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900398 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900399 channel = ieee80211_get_channel(wiphy, s32Freq);
400
Leo Kim7ae43362015-09-16 18:35:59 +0900401 if (!channel)
402 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900403
404 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530405 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900406 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
407
Dean Lee72ed4dc2015-06-12 14:11:44 +0900408 if (pstrNetworkInfo->bNewNetwork == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900409 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
410 /* max_scan_ssids */
411 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
412
413
414 priv->u32RcvdChCount++;
415
416
417
418 if (pJoinParams == NULL) {
419 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
420 }
421 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
422
423 /*P2P peers are sent to WPA supplicant and added to shadow table*/
424
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900425 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
427 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900428 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900430 }
431
432
433 } else {
434 PRINT_ER("Discovered networks exceeded the max limit\n");
435 }
436 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900437 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438 /* So this network is discovered before, we'll just update its RSSI */
439 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900440 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530441 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900442
443 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
444 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
445 break;
446 }
447 }
448 }
449 }
450 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530451 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
452 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900453 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530455 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530456 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530457 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530458 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900459
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200460 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900461
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900462 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900463 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900465 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900466 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900467 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200468 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469
470 }
471 /*Aborting any scan operation during mac close*/
472 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200473 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900474
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530475 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900476 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477
478 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900479 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900480
Dean Lee72ed4dc2015-06-12 14:11:44 +0900481 cfg80211_scan_done(priv->pstrScanReq, false);
482 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900483 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900484 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200485 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900486 }
487 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900488}
489
490
491/**
492 * @brief WILC_WFI_Set_PMKSA
493 * @details Check if pmksa is cached and set it.
494 * @param[in]
495 * @return int : Return 0 on Success
496 * @author mdaftedar
497 * @date 01 MAR 2012
498 * @version 1.0
499 */
Chaehyun Lim27268872015-09-15 14:06:13 +0900500int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900502 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900503 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900504
505
506 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
507
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900508 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900509 ETH_ALEN)) {
510 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
511
512 /*If bssid is found, set the values*/
513 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
514
515 if (s32Error != WILC_SUCCESS)
516 PRINT_ER("Error in pmkid\n");
517
518 break;
519 }
520 }
521
522 return s32Error;
523
524
525}
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900526int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900527
528
529/**
530 * @brief CfgConnectResult
531 * @details
532 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
533 * connection response or disconnection notification.
534 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900535 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900536 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
537 * void* pUserVoid: Private data associated with wireless interface
538 * @return NONE
539 * @author mabubakr
540 * @date 01 MAR 2012
541 * @version 1.0
542 */
543int connecting;
544
545static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
546 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900547 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900548 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
549 void *pUserVoid)
550{
Chaehyun Lim27268872015-09-15 14:06:13 +0900551 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900552 struct net_device *dev;
553 #ifdef WILC_P2P
554 tstrWILC_WFIDrv *pstrWFIDrv;
555 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900556 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900557
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900558 connecting = 0;
559
Chaehyun Lim27268872015-09-15 14:06:13 +0900560 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900561 dev = priv->dev;
562 #ifdef WILC_P2P
563 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
564 #endif
565
566 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
567 /*Initialization*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900568 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569
570 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
571
572 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
573
574 if ((u8MacStatus == MAC_DISCONNECTED) &&
575 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
576 /* The case here is that our station was waiting for association response frame and has just received it containing status code
577 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
578 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
579 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900580 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900581
582 /*BugID_5457*/
583 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
584 #ifdef WILC_P2P
585 if (!pstrWFIDrv->u8P2PConnect)
586 u8WLANChannel = INVALID_CHANNEL;
587 #endif
588
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530589 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900590 }
591
592 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900593 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900594 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900595
596 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
597 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900598 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900599
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
601 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
602 * Linux kernel warning generated at the nl80211 layer */
603
604 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900605 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900606 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
607 unsigned long now = jiffies;
608
609 if (time_after(now,
610 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900611 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900612 }
613
614 break;
615 }
616 }
617
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000618 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900619 /*BugID_5418*/
620 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900621 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900622
623 }
624
625 }
626
627
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530628 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629
630 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
631
632 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
633 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
634 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
635 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
636 /* be replaced by pstrConnectInfo->u16ConnectStatus */
637 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
638 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900639 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900640 #endif
641 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
642 pstrDisconnectNotifInfo->u16reason, priv->dev);
643 u8P2Plocalrandom = 0x01;
644 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900645 bWilc_ie = false;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900646 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900647 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900648 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900649
650 /*BugID_5457*/
651 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
652 #ifdef WILC_P2P
653 if (!pstrWFIDrv->u8P2PConnect)
654 u8WLANChannel = INVALID_CHANNEL;
655 #endif
656 /*BugID_5315*/
657 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
658 * virtual interface to station*/
659 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
660 pstrDisconnectNotifInfo->u16reason = 3;
661 }
662 /*BugID_5315*/
663 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
664 * to scan again and retry the connection*/
665 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
666 pstrDisconnectNotifInfo->u16reason = 1;
667 }
668 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530669 pstrDisconnectNotifInfo->ie_len, false,
670 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900671
672 }
673
674}
675
676
677/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900678 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900679 * @details Set channel for a given wireless interface. Some devices
680 * may support multi-channel operation (by channel hopping) so cfg80211
681 * doesn't verify much. Note, however, that the passed netdev may be
682 * %NULL as well if the user requested changing the channel for the
683 * device itself, or for a monitor interface.
684 * @param[in]
685 * @return int : Return 0 on Success
686 * @author mdaftedar
687 * @date 01 MAR 2012
688 * @version 1.0
689 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900690static int set_channel(struct wiphy *wiphy,
691 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900692{
693
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900694 u32 channelnum = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +0900695 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900696 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900697
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900698 priv = wiphy_priv(wiphy);
699
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900700 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
701 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900702
703 u8CurrChannel = channelnum;
704 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
705
706 if (s32Error != WILC_SUCCESS)
707 PRINT_ER("Error in setting channel %d\n", channelnum);
708
709 return s32Error;
710}
711
712/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900713 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900714 * @details Request to do a scan. If returning zero, the scan request is given
715 * the driver, and will be valid until passed to cfg80211_scan_done().
716 * For scan results, call cfg80211_inform_bss(); you can call this outside
717 * the scan/scan_done bracket too.
718 * @param[in]
719 * @return int : Return 0 on Success
720 * @author mabubakr
721 * @date 01 MAR 2012
722 * @version 1.0
723 */
724
725/*
726 * kernel version 3.8.8 supported
727 * tony, sswd, WILC-KR, 2013-10-29
728 */
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900729static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900730{
Chaehyun Lim27268872015-09-15 14:06:13 +0900731 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900732 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900733 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900734 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735 tstrHiddenNetwork strHiddenNetwork;
736
737 priv = wiphy_priv(wiphy);
738
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900739 priv->pstrScanReq = request;
740
741 priv->u32RcvdChCount = 0;
742
Johnny Kim218dc402015-08-13 13:41:19 +0900743 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900744
745
746 reset_shadow_found(priv);
747
Dean Lee72ed4dc2015-06-12 14:11:44 +0900748 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
750 /* max_scan_ssids */
751 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900752 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
754 }
755
756 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530757 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900758
759 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
760
761 if (request->n_ssids >= 1) {
762
763
Glen Leef3052582015-09-10 12:03:04 +0900764 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900765 strHiddenNetwork.u8ssidnum = request->n_ssids;
766
767
768 /*BugID_4156*/
769 for (i = 0; i < request->n_ssids; i++) {
770
771 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900772 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900773 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900774 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
775 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530776 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900777 strHiddenNetwork.u8ssidnum -= 1;
778 }
779 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530780 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900781 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
782 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900783 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 CfgScanResult, (void *)priv, &strHiddenNetwork);
785 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530786 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900787 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
788 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900789 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900790 CfgScanResult, (void *)priv, NULL);
791 }
792
793 } else {
794 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530795 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 }
797
798 if (s32Error != WILC_SUCCESS) {
799 s32Error = -EBUSY;
800 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
801 }
802
803 return s32Error;
804}
805
806/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900807 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808 * @details Connect to the ESS with the specified parameters. When connected,
809 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
810 * If the connection fails for some reason, call cfg80211_connect_result()
811 * with the status from the AP.
812 * @param[in]
813 * @return int : Return 0 on Success
814 * @author mabubakr
815 * @date 01 MAR 2012
816 * @version 1.0
817 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900818static int connect(struct wiphy *wiphy, struct net_device *dev,
819 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900820{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900821 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900822 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900823 u8 u8security = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900824 AUTHTYPE_T tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900825 char *pcgroup_encrypt_val = NULL;
826 char *pccipher_group = NULL;
827 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900828
Chaehyun Lim27268872015-09-15 14:06:13 +0900829 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900830 tstrWILC_WFIDrv *pstrWFIDrv;
831 tstrNetworkInfo *pstrNetworkInfo = NULL;
832
833
834 connecting = 1;
835 priv = wiphy_priv(wiphy);
836 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
837
Johnny Kim218dc402015-08-13 13:41:19 +0900838 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900839
Johnny Kim8a143302015-06-10 17:06:46 +0900840 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 +0900841 #ifdef WILC_P2P
Chaehyun Lim3f882892015-08-10 11:33:17 +0900842 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900843 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
844 pstrWFIDrv->u8P2PConnect = 1;
845 } else
846 pstrWFIDrv->u8P2PConnect = 0;
847 #endif
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530848 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900849
850 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
851 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900852 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853 sme->ssid,
854 sme->ssid_len) == 0) {
855 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
856 if (sme->bssid == NULL) {
857 /* BSSID is not passed from the user, so decision of matching
858 * is done by SSID only */
859 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
860 break;
861 } else {
862 /* BSSID is also passed from the user, so decision of matching
863 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900864 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900865 sme->bssid,
866 ETH_ALEN) == 0) {
867 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
868 break;
869 }
870 }
871 }
872 }
873
874 if (i < u32LastScannedNtwrksCountShadow) {
875 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
876
877 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
878
879 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
880 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
881 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
882 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
883 } else {
884 s32Error = -ENOENT;
885 if (u32LastScannedNtwrksCountShadow == 0)
886 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
887 else
888 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
889
890 goto done;
891 }
892
893 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900894 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
895 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900896
897 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
898 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
899
900 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
901
902 if (INFO) {
903 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
904 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
905 }
906
907 if (sme->crypto.cipher_group != NO_ENCRYPT) {
908 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
909 * we will add to it the pairwise cipher suite(s) */
910 pcwpa_version = "Default";
911 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900913 u8security = ENCRYPT_ENABLED | WEP;
914 pcgroup_encrypt_val = "WEP40";
915 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
916 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
917
918 if (INFO) {
919 for (i = 0; i < sme->key_len; i++)
920 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
921 }
922 priv->WILC_WFI_wep_default = sme->key_idx;
923 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900924 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925
926 /*BugID_5137*/
927 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900928 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900929 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
930 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900931 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900932
933 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
934 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
935 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900936 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
937 pcgroup_encrypt_val = "WEP104";
938 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
939
940 priv->WILC_WFI_wep_default = sme->key_idx;
941 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900942 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900943
944 /*BugID_5137*/
945 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900946 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900947 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
948 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900949 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900950
951 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
952 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
953 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900954 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900955 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
956 pcgroup_encrypt_val = "WPA2_TKIP";
957 pccipher_group = "TKIP";
958 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
959 /* tenuSecurity_t = WPA2_AES; */
960 u8security = ENCRYPT_ENABLED | WPA2 | AES;
961 pcgroup_encrypt_val = "WPA2_AES";
962 pccipher_group = "AES";
963 }
964 pcwpa_version = "WPA_VERSION_2";
965 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
966 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900967 u8security = ENCRYPT_ENABLED | WPA | TKIP;
968 pcgroup_encrypt_val = "WPA_TKIP";
969 pccipher_group = "TKIP";
970 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
971 /* tenuSecurity_t = WPA_AES; */
972 u8security = ENCRYPT_ENABLED | WPA | AES;
973 pcgroup_encrypt_val = "WPA_AES";
974 pccipher_group = "AES";
975
976 }
977 pcwpa_version = "WPA_VERSION_1";
978
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900979 } else {
980 s32Error = -ENOTSUPP;
981 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
982
983 goto done;
984 }
985
986 }
987
988 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
989 * add to it the pairwise cipher suite(s) */
990 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
991 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
992 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
993 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
994 u8security = u8security | TKIP;
995 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
996 u8security = u8security | AES;
997 }
998 }
999 }
1000
1001 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1002
1003 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1004 switch (sme->auth_type) {
1005 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1006 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1007 tenuAuth_type = OPEN_SYSTEM;
1008 break;
1009
1010 case NL80211_AUTHTYPE_SHARED_KEY:
1011 tenuAuth_type = SHARED_KEY;
1012 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1013 break;
1014
1015 default:
1016 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1017 }
1018
1019
1020 /* ai: key_mgmt: enterprise case */
1021 if (sme->crypto.n_akm_suites) {
1022 switch (sme->crypto.akm_suites[0]) {
1023 case WLAN_AKM_SUITE_8021X:
1024 tenuAuth_type = IEEE8021;
1025 break;
1026
1027 default:
1028 break;
1029 }
1030 }
1031
1032
1033 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1034
1035 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1036 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1037
1038 /*BugID_5442*/
1039 u8CurrChannel = pstrNetworkInfo->u8channel;
1040
1041 if (!pstrWFIDrv->u8P2PConnect) {
1042 u8WLANChannel = pstrNetworkInfo->u8channel;
1043 }
1044
1045 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1046
1047 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1048 sme->ssid_len, sme->ie, sme->ie_len,
1049 CfgConnectResult, (void *)priv, u8security,
1050 tenuAuth_type, pstrNetworkInfo->u8channel,
1051 pstrNetworkInfo->pJoinParams);
1052 if (s32Error != WILC_SUCCESS) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301053 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 s32Error = -ENOENT;
1055 goto done;
1056 }
1057
1058done:
1059
1060 return s32Error;
1061}
1062
1063
1064/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001065 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001066 * @details Disconnect from the BSS/ESS.
1067 * @param[in]
1068 * @return int : Return 0 on Success
1069 * @author mdaftedar
1070 * @date 01 MAR 2012
1071 * @version 1.0
1072 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001073static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001075 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001076 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001077 #ifdef WILC_P2P
1078 tstrWILC_WFIDrv *pstrWFIDrv;
1079 #endif
Chaehyun Lim51e825f2015-09-15 14:06:14 +09001080 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001081
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001082 connecting = 0;
1083 priv = wiphy_priv(wiphy);
1084
1085 /*BugID_5457*/
1086 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1087 #ifdef WILC_P2P
1088 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1089 if (!pstrWFIDrv->u8P2PConnect)
1090 u8WLANChannel = INVALID_CHANNEL;
1091 #endif
1092 linux_wlan_set_bssid(priv->dev, NullBssid);
1093
1094 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1095
1096 u8P2Plocalrandom = 0x01;
1097 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001098 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 #ifdef WILC_P2P
1100 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1101 #endif
1102
1103 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1104 if (s32Error != WILC_SUCCESS) {
1105 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1106 s32Error = -EINVAL;
1107 }
1108
1109 return s32Error;
1110}
1111
1112/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001113 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001114 * @details Add a key with the given parameters. @mac_addr will be %NULL
1115 * when adding a group key.
1116 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1117 * @return int : Return 0 on Success
1118 * @author mdaftedar
1119 * @date 01 MAR 2012
1120 * @version 1.0
1121 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001122static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1123 bool pairwise,
1124 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001125
1126{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001127 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001128 u32 i;
Chaehyun Lim27268872015-09-15 14:06:13 +09001129 struct wilc_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001130 const u8 *pu8RxMic = NULL;
1131 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001132 u8 u8mode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133 #ifdef WILC_AP_EXTERNAL_MLME
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001134 u8 u8gmode = NO_ENCRYPT;
1135 u8 u8pmode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001136 AUTHTYPE_T tenuAuth_type = ANY;
1137 #endif
1138
1139 priv = wiphy_priv(wiphy);
1140
1141 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1142
1143 /*BugID_5137*/
Johnny Kim8a143302015-06-10 17:06:46 +09001144 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001145
1146 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1147 params->key[1],
1148 params->key[2]);
1149
1150
1151 switch (params->cipher) {
1152 case WLAN_CIPHER_SUITE_WEP40:
1153 case WLAN_CIPHER_SUITE_WEP104:
1154 #ifdef WILC_AP_EXTERNAL_MLME
1155 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1156
1157 priv->WILC_WFI_wep_default = key_index;
1158 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001159 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001160
1161 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1162 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1163
1164 for (i = 0; i < params->key_len; i++)
1165 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1166
1167 tenuAuth_type = OPEN_SYSTEM;
1168
1169 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1170 u8mode = ENCRYPT_ENABLED | WEP;
1171 else
1172 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1173
1174 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1175 break;
1176 }
1177 #endif
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001178 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179 priv->WILC_WFI_wep_default = key_index;
1180 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001181 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182
1183 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1184 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1185 if (INFO) {
1186 for (i = 0; i < params->key_len; i++)
1187 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1188 }
1189 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1190 }
1191
1192 break;
1193
1194 case WLAN_CIPHER_SUITE_TKIP:
1195 case WLAN_CIPHER_SUITE_CCMP:
1196 #ifdef WILC_AP_EXTERNAL_MLME
1197 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1198
1199 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001200 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001201 priv->wilc_gtk[key_index]->key = NULL;
1202 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001203
1204 }
1205 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001206 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001207 priv->wilc_ptk[key_index]->key = NULL;
1208 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001209 }
1210
1211
1212
Daniel Machon19132212015-08-05 08:18:31 +02001213 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001214 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1215 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1216 else
1217 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1218
1219 priv->wilc_groupkey = u8gmode;
1220
1221 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1222
1223 pu8TxMic = params->key + 24;
1224 pu8RxMic = params->key + 16;
1225 KeyLen = params->key_len - 16;
1226 }
1227 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1228 if (priv->wilc_gtk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001229 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001230
Glen Leef3052582015-09-10 12:03:04 +09001231 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001232 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001233
1234 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1235 if (priv->wilc_gtk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001236 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001237
1238 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001239 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001240 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001241 }
1242
1243 priv->wilc_gtk[key_index]->cipher = params->cipher;
1244 priv->wilc_gtk[key_index]->key_len = params->key_len;
1245 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1246
1247 if (INFO) {
1248 for (i = 0; i < params->key_len; i++)
1249 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1250 for (i = 0; i < params->seq_len; i++)
1251 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1252 }
1253
1254
1255 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1256 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1257
1258 } else {
1259 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]);
1260
1261 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1262 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1263 else
1264 u8pmode = priv->wilc_groupkey | AES;
1265
1266
1267 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1268
1269 pu8TxMic = params->key + 24;
1270 pu8RxMic = params->key + 16;
1271 KeyLen = params->key_len - 16;
1272 }
1273
1274 if (priv->wilc_ptk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001275 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001276
Glen Leef3052582015-09-10 12:03:04 +09001277 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278
1279 if (priv->wilc_ptk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001280 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001281
1282 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001283 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001284
1285 if (INFO) {
1286 for (i = 0; i < params->key_len; i++)
1287 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1288
1289 for (i = 0; i < params->seq_len; i++)
1290 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1291 }
1292
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001293 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001294
1295 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001296 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001297
1298 priv->wilc_ptk[key_index]->cipher = params->cipher;
1299 priv->wilc_ptk[key_index]->key_len = params->key_len;
1300 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1301
1302 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1303 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1304 }
1305 break;
1306 }
1307 #endif
1308
1309 {
1310 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001311 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001312 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1313 /* swap the tx mic by rx mic */
1314 pu8RxMic = params->key + 24;
1315 pu8TxMic = params->key + 16;
1316 KeyLen = params->key_len - 16;
1317 }
1318
1319 /*BugID_5137*/
1320 /*save keys only on interface 0 (wifi interface)*/
1321 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1322 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001323 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324 if (!mac_addr) {
1325 g_add_gtk_key_params.mac_addr = NULL;
1326 } else {
Glen Leef3052582015-09-10 12:03:04 +09001327 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001328 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1329 }
1330 g_key_gtk_params.key_len = params->key_len;
1331 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001332 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001333 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1334 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001335 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1337 }
1338 g_key_gtk_params.cipher = params->cipher;
1339
1340 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1341 g_key_gtk_params.key[1],
1342 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001343 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001344 }
1345
1346 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1347 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348 } else {
1349 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1350 /* swap the tx mic by rx mic */
1351 pu8RxMic = params->key + 24;
1352 pu8TxMic = params->key + 16;
1353 KeyLen = params->key_len - 16;
1354 }
1355
1356 /*BugID_5137*/
1357 /*save keys only on interface 0 (wifi interface)*/
1358 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1359 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361 if (!mac_addr) {
1362 g_add_ptk_key_params.mac_addr = NULL;
1363 } else {
Glen Leef3052582015-09-10 12:03:04 +09001364 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1366 }
1367 g_key_ptk_params.key_len = params->key_len;
1368 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001369 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001370 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1371 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001372 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001373 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1374 }
1375 g_key_ptk_params.cipher = params->cipher;
1376
1377 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1378 g_key_ptk_params.key[1],
1379 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001380 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001381 }
1382
1383 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1384 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1385 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1386 if (INFO) {
1387 for (i = 0; i < params->key_len; i++)
1388 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1389 }
1390 }
1391 }
1392 break;
1393
1394 default:
1395 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1396 s32Error = -ENOTSUPP;
1397
1398 }
1399
1400 return s32Error;
1401}
1402
1403/**
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001404 * @brief del_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405 * @details Remove a key given the @mac_addr (%NULL for a group key)
1406 * and @key_index, return -ENOENT if the key doesn't exist.
1407 * @param[in]
1408 * @return int : Return 0 on Success
1409 * @author mdaftedar
1410 * @date 01 MAR 2012
1411 * @version 1.0
1412 */
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001413static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1414 u8 key_index,
1415 bool pairwise,
1416 const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417{
Chaehyun Lim27268872015-09-15 14:06:13 +09001418 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001419 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001420
1421 priv = wiphy_priv(wiphy);
1422
1423 /*BugID_5137*/
1424 /*delete saved keys, if any*/
1425 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001426 g_ptk_keys_saved = false;
1427 g_gtk_keys_saved = false;
1428 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001429
1430 /*Delete saved WEP keys params, if any*/
1431 if (g_key_wep_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001432 kfree(g_key_wep_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001433 g_key_wep_params.key = NULL;
1434 }
1435
1436 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1437
1438 #ifdef WILC_AP_EXTERNAL_MLME
1439 if ((priv->wilc_gtk[key_index]) != NULL) {
1440
1441 if (priv->wilc_gtk[key_index]->key != NULL) {
1442
Chaehyun Lim49188af2015-08-11 10:32:41 +09001443 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001444 priv->wilc_gtk[key_index]->key = NULL;
1445 }
1446 if (priv->wilc_gtk[key_index]->seq) {
1447
Chaehyun Lim49188af2015-08-11 10:32:41 +09001448 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449 priv->wilc_gtk[key_index]->seq = NULL;
1450 }
1451
Chaehyun Lim49188af2015-08-11 10:32:41 +09001452 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 priv->wilc_gtk[key_index] = NULL;
1454
1455 }
1456
1457 if ((priv->wilc_ptk[key_index]) != NULL) {
1458
1459 if (priv->wilc_ptk[key_index]->key) {
1460
Chaehyun Lim49188af2015-08-11 10:32:41 +09001461 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001462 priv->wilc_ptk[key_index]->key = NULL;
1463 }
1464 if (priv->wilc_ptk[key_index]->seq) {
1465
Chaehyun Lim49188af2015-08-11 10:32:41 +09001466 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001467 priv->wilc_ptk[key_index]->seq = NULL;
1468 }
Chaehyun Lim49188af2015-08-11 10:32:41 +09001469 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001470 priv->wilc_ptk[key_index] = NULL;
1471 }
1472 #endif
1473
1474 /*Delete saved PTK and GTK keys params, if any*/
1475 if (g_key_ptk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001476 kfree(g_key_ptk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001477 g_key_ptk_params.key = NULL;
1478 }
1479 if (g_key_ptk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001480 kfree(g_key_ptk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481 g_key_ptk_params.seq = NULL;
1482 }
1483
1484 if (g_key_gtk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001485 kfree(g_key_gtk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 g_key_gtk_params.key = NULL;
1487 }
1488 if (g_key_gtk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001489 kfree(g_key_gtk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001490 g_key_gtk_params.seq = NULL;
1491 }
1492
1493 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001494 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001495 }
1496
1497 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001498 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001499 priv->WILC_WFI_wep_key_len[key_index] = 0;
1500
1501 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1502 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1503 } else {
1504 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1505 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1506 }
1507
1508 return s32Error;
1509}
1510
1511/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001512 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001513 * @details Get information about the key with the given parameters.
1514 * @mac_addr will be %NULL when requesting information for a group
1515 * key. All pointers given to the @callback function need not be valid
1516 * after it returns. This function should return an error if it is
1517 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1518 * @param[in]
1519 * @return int : Return 0 on Success
1520 * @author mdaftedar
1521 * @date 01 MAR 2012
1522 * @version 1.0
1523 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001524static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1525 bool pairwise,
1526 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527{
1528
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001529 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001530
Chaehyun Lim27268872015-09-15 14:06:13 +09001531 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001533 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001534
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001535 priv = wiphy_priv(wiphy);
1536
1537
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001538 if (!pairwise)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 {
1540 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1541
1542 key_params.key = priv->wilc_gtk[key_index]->key;
1543 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1544 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1545 key_params.seq = priv->wilc_gtk[key_index]->seq;
1546 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1547 if (INFO) {
1548 for (i = 0; i < key_params.key_len; i++)
1549 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1550 }
1551 } else {
1552 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1553
1554 key_params.key = priv->wilc_ptk[key_index]->key;
1555 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1556 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1557 key_params.seq = priv->wilc_ptk[key_index]->seq;
1558 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1559 }
1560
1561 callback(cookie, &key_params);
1562
1563 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1564}
1565
1566/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001567 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001568 * @details Set the default management frame key on an interface
1569 * @param[in]
1570 * @return int : Return 0 on Success.
1571 * @author mdaftedar
1572 * @date 01 MAR 2012
1573 * @version 1.0
1574 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001575static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1576 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001577{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001578 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001579 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001580
1581
1582 priv = wiphy_priv(wiphy);
1583
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301584 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001585
1586 if (key_index != priv->WILC_WFI_wep_default) {
1587
1588 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1589 }
1590
1591 return s32Error;
1592}
1593
1594/**
1595 * @brief WILC_WFI_dump_survey
1596 * @details Get site survey information
1597 * @param[in]
1598 * @return int : Return 0 on Success.
1599 * @author mdaftedar
1600 * @date 01 MAR 2012
1601 * @version 1.0
1602 */
1603static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1604 int idx, struct survey_info *info)
1605{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001606 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001607
1608
1609 if (idx != 0) {
1610 s32Error = -ENOENT;
1611 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1612
1613 }
1614
1615 return s32Error;
1616}
1617
1618
1619/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001620 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621 * @details Get station information for the station identified by @mac
1622 * @param[in] NONE
1623 * @return int : Return 0 on Success.
1624 * @author mdaftedar
1625 * @date 01 MAR 2012
1626 * @version 1.0
1627 */
1628
Chaehyun Limf06f5622015-09-14 12:24:18 +09001629static int get_station(struct wiphy *wiphy, struct net_device *dev,
1630 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001631{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001632 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001633 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001634 perInterface_wlan_t *nic;
1635 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001636 u32 i = 0;
1637 u32 associatedsta = 0;
1638 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001639 #endif
1640 priv = wiphy_priv(wiphy);
1641 nic = netdev_priv(dev);
1642
1643 #ifdef WILC_AP_EXTERNAL_MLME
1644 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1645 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1646
1647 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1648
1649 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1650
1651 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1652 associatedsta = i;
1653 break;
1654 }
1655
1656 }
1657
1658 if (associatedsta == -1) {
1659 s32Error = -ENOENT;
1660 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1661
1662 return s32Error;
1663 }
1664
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001665 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666
1667 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1668 sinfo->inactive_time = 1000 * inactive_time;
1669 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1670
1671 }
1672 #endif
1673
1674 if (nic->iftype == STATION_MODE) {
1675 tstrStatistics strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001676
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001677 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1678
1679 /*
1680 * tony: 2013-11-13
1681 * tx_failed introduced more than
1682 * kernel version 3.0.0
1683 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001684 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301685 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686 BIT(NL80211_STA_INFO_TX_PACKETS) |
1687 BIT(NL80211_STA_INFO_TX_FAILED) |
1688 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001689
1690 sinfo->signal = strStatistics.s8RSSI;
1691 sinfo->rx_packets = strStatistics.u32RxCount;
1692 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001693 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1695
1696#ifdef TCP_ENHANCEMENTS
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301697 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001698 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301699 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001700 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001701#endif
1702
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001703 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1704 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001705 }
1706 return s32Error;
1707}
1708
1709
1710/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001711 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001712 * @details Modify parameters for a given BSS.
1713 * @param[in]
1714 * -use_cts_prot: Whether to use CTS protection
1715 * (0 = no, 1 = yes, -1 = do not change)
1716 * -use_short_preamble: Whether the use of short preambles is allowed
1717 * (0 = no, 1 = yes, -1 = do not change)
1718 * -use_short_slot_time: Whether the use of short slot time is allowed
1719 * (0 = no, 1 = yes, -1 = do not change)
1720 * -basic_rates: basic rates in IEEE 802.11 format
1721 * (or NULL for no change)
1722 * -basic_rates_len: number of basic rates
1723 * -ap_isolate: do not forward packets between connected stations
1724 * -ht_opmode: HT Operation mode
1725 * (u16 = opmode, -1 = do not change)
1726 * @return int : Return 0 on Success.
1727 * @author mdaftedar
1728 * @date 01 MAR 2012
1729 * @version 1.0
1730 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001731static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1732 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733{
1734 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1735 return 0;
1736}
1737
1738/**
1739 * @brief WILC_WFI_auth
1740 * @details Request to authenticate with the specified peer
1741 * @param[in]
1742 * @return int : Return 0 on Success.
1743 * @author mdaftedar
1744 * @date 01 MAR 2012
1745 * @version 1.0
1746 */
1747static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1748 struct cfg80211_auth_request *req)
1749{
1750 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1751 return 0;
1752}
1753
1754/**
1755 * @brief WILC_WFI_assoc
1756 * @details Request to (re)associate with the specified peer
1757 * @param[in]
1758 * @return int : Return 0 on Success.
1759 * @author mdaftedar
1760 * @date 01 MAR 2012
1761 * @version 1.0
1762 */
1763static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1764 struct cfg80211_assoc_request *req)
1765{
1766 PRINT_D(CFG80211_DBG, "In Association Function\n");
1767 return 0;
1768}
1769
1770/**
1771 * @brief WILC_WFI_deauth
1772 * @details Request to deauthenticate from the specified peer
1773 * @param[in]
1774 * @return int : Return 0 on Success.
1775 * @author mdaftedar
1776 * @date 01 MAR 2012
1777 * @version 1.0
1778 */
1779static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1780 struct cfg80211_deauth_request *req, void *cookie)
1781{
1782 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1783 return 0;
1784}
1785
1786/**
1787 * @brief WILC_WFI_disassoc
1788 * @details Request to disassociate from the specified peer
1789 * @param[in]
1790 * @return int : Return 0 on Success
1791 * @author mdaftedar
1792 * @date 01 MAR 2012
1793 * @version 1.0
1794 */
1795static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1796 struct cfg80211_disassoc_request *req, void *cookie)
1797{
1798 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1799 return 0;
1800}
1801
1802/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001803 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001804 * @details Notify that wiphy parameters have changed;
1805 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1806 * have changed.
1807 * @return int : Return 0 on Success
1808 * @author mdaftedar
1809 * @date 01 MAR 2012
1810 * @version 1.0
1811 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001812static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001813{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001814 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815 tstrCfgParamVal pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001816 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001817
1818 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819
1820 pstrCfgParamVal.u32SetCfgFlag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301821 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001822
1823 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1824 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1825 priv->dev->ieee80211_ptr->wiphy->retry_short);
1826 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1827 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1828 }
1829 if (changed & WIPHY_PARAM_RETRY_LONG) {
1830
1831 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1832 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1833 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1834
1835 }
1836 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1837 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1838 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1839 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1840
1841 }
1842
1843 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1844 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1845
1846 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1847 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1848
1849 }
1850
1851 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1852 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1853 if (s32Error)
1854 PRINT_ER("Error in setting WIPHY PARAMS\n");
1855
1856
1857 return s32Error;
1858}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001859
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001860/**
1861 * @brief WILC_WFI_set_bitrate_mask
1862 * @details set the bitrate mask configuration
1863 * @param[in]
1864 * @return int : Return 0 on Success
1865 * @author mdaftedar
1866 * @date 01 MAR 2012
1867 * @version 1.0
1868 */
1869static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1870 struct net_device *dev, const u8 *peer,
1871 const struct cfg80211_bitrate_mask *mask)
1872{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001873 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874
1875 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001876 return s32Error;
1877
1878}
1879
1880/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001881 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001882 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1883 * devices running firmwares capable of generating the (re) association
1884 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1885 * @param[in]
1886 * @return int : Return 0 on Success
1887 * @author mdaftedar
1888 * @date 01 MAR 2012
1889 * @version 1.0
1890 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001891static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1892 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001893{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001894 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001895 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001896 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001897
Chaehyun Lim27268872015-09-15 14:06:13 +09001898 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001899
1900 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1901
1902
1903 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001904 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001905 ETH_ALEN)) {
1906 /*If bssid already exists and pmkid value needs to reset*/
1907 flag = PMKID_FOUND;
1908 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1909 break;
1910 }
1911 }
1912 if (i < WILC_MAX_NUM_PMKIDS) {
1913 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001914 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001916 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001917 PMKID_LEN);
1918 if (!(flag == PMKID_FOUND))
1919 priv->pmkid_list.numpmkid++;
1920 } else {
1921 PRINT_ER("Invalid PMKID index\n");
1922 s32Error = -EINVAL;
1923 }
1924
1925 if (!s32Error) {
1926 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1927 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1928 }
1929 return s32Error;
1930}
1931
1932/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001933 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934 * @details Delete a cached PMKID.
1935 * @param[in]
1936 * @return int : Return 0 on Success
1937 * @author mdaftedar
1938 * @date 01 MAR 2012
1939 * @version 1.0
1940 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001941static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1942 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001943{
1944
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001945 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001946 u8 flag = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001947 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948
Chaehyun Lim27268872015-09-15 14:06:13 +09001949 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950
1951 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1952
1953 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001954 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001955 ETH_ALEN)) {
1956 /*If bssid is found, reset the values*/
1957 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001958 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001959 flag = PMKID_FOUND;
1960 break;
1961 }
1962 }
1963
1964 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1965 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001966 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001967 priv->pmkid_list.pmkidlist[i + 1].bssid,
1968 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001969 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001970 priv->pmkid_list.pmkidlist[i].pmkid,
1971 PMKID_LEN);
1972 }
1973 priv->pmkid_list.numpmkid--;
1974 } else {
1975 s32Error = -EINVAL;
1976 }
1977
1978 return s32Error;
1979}
1980
1981/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001982 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001983 * @details Flush all cached PMKIDs.
1984 * @param[in]
1985 * @return int : Return 0 on Success
1986 * @author mdaftedar
1987 * @date 01 MAR 2012
1988 * @version 1.0
1989 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001990static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991{
Chaehyun Lim27268872015-09-15 14:06:13 +09001992 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993
1994 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1995
1996 /*Get cashed Pmkids and set all with zeros*/
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001997 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001998
1999 return 0;
2000}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001
2002#ifdef WILC_P2P
2003
2004/**
2005 * @brief WILC_WFI_CfgParseRxAction
2006 * @details Function parses the received frames and modifies the following attributes:
2007 * -GO Intent
2008 * -Channel list
2009 * -Operating Channel
2010 *
2011 * @param[in] u8* Buffer, u32 length
2012 * @return NONE.
2013 * @author mdaftedar
2014 * @date 12 DEC 2012
2015 * @version
2016 */
2017
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002018void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002019{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002020 u32 index = 0;
2021 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022
2023 /*BugID_5460*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002024 u8 op_channel_attr_index = 0;
2025 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002026
2027 while (index < len) {
2028 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002029 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030 }
2031
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302032 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002033 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302034 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002035 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036 index += buf[index + 1] + 3; /* ID,Length byte */
2037 }
2038
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002039 if (u8WLANChannel != INVALID_CHANNEL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002040 {
2041 /*Modify channel list attribute*/
2042 if (channel_list_attr_index) {
2043 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2044 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2045 if (buf[i] == 0x51) {
2046 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2047 buf[j] = u8WLANChannel;
2048 }
2049 break;
2050 }
2051 }
2052 }
2053 /*Modify operating channel attribute*/
2054 if (op_channel_attr_index) {
2055 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2056 buf[op_channel_attr_index + 6] = 0x51;
2057 buf[op_channel_attr_index + 7] = u8WLANChannel;
2058 }
2059 }
2060}
2061
2062/**
2063 * @brief WILC_WFI_CfgParseTxAction
2064 * @details Function parses the transmitted action frames and modifies the
2065 * GO Intent attribute
2066 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2067 * @return NONE.
2068 * @author mdaftedar
2069 * @date 12 DEC 2012
2070 * @version
2071 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002072void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002074 u32 index = 0;
2075 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002076
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002077 u8 op_channel_attr_index = 0;
2078 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079
2080 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002081 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083
2084 break;
2085 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002086
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302087 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302089 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002090 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091 index += buf[index + 1] + 3; /* ID,Length byte */
2092 }
2093
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002094 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095 {
2096 /*Modify channel list attribute*/
2097 if (channel_list_attr_index) {
2098 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2099 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2100 if (buf[i] == 0x51) {
2101 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2102 buf[j] = u8WLANChannel;
2103 }
2104 break;
2105 }
2106 }
2107 }
2108 /*Modify operating channel attribute*/
2109 if (op_channel_attr_index) {
2110 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2111 buf[op_channel_attr_index + 6] = 0x51;
2112 buf[op_channel_attr_index + 7] = u8WLANChannel;
2113 }
2114 }
2115}
2116
2117/* @brief WILC_WFI_p2p_rx
2118 * @details
2119 * @param[in]
2120 *
2121 * @return None
2122 * @author Mai Daftedar
2123 * @date 2 JUN 2013
2124 * @version 1.0
2125 */
2126
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09002127void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002128{
2129
Chaehyun Lim27268872015-09-15 14:06:13 +09002130 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002131 u32 header, pkt_offset;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002132 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002133 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002134 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002135
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002136 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2137 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2138
2139 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002140 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002141
2142 /* The packet offset field conain info about what type of managment frame */
2143 /* we are dealing with and ack status */
2144 pkt_offset = GET_PKT_OFFSET(header);
2145
2146 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2147 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2148 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002149 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002150 return;
2151 } else {
2152 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2153 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],
2154 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002155 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002156 } else {
2157 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],
2158 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002159 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160 }
2161 return;
2162 }
2163 } else {
2164
2165 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2166
2167 /*BugID_5442*/
2168 /*Upper layer is informed that the frame is received on this freq*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170
2171 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2172 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2173
Dean Lee72ed4dc2015-06-12 14:11:44 +09002174 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002175 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2176 return;
2177 }
2178 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2179
2180 switch (buff[ACTION_SUBTYPE_ID]) {
2181 case GAS_INTIAL_REQ:
2182 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2183 break;
2184
2185 case GAS_INTIAL_RSP:
2186 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2187 break;
2188
2189 case PUBLIC_ACT_VENDORSPEC:
2190 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2191 * 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 +09002192 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002193 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2194 if (!bWilc_ie) {
2195 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002196 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002197 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09002198 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002199 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2200 break;
2201 }
2202 }
2203 }
2204 }
2205 if (u8P2Plocalrandom > u8P2Precvrandom) {
2206 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2207 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2208 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002209 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2211 break;
2212 }
2213 }
2214 }
2215 } else
2216 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2217 }
2218
2219
2220 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2221 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2222 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 return;
2225 }
2226 break;
2227
2228 default:
2229 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2230 break;
2231 }
2232 }
2233 }
2234
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236 }
2237}
2238
2239/**
2240 * @brief WILC_WFI_mgmt_tx_complete
2241 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2242 * @param[in] priv
2243 * transmitting status
2244 * @return None
2245 * @author Amr Abdelmoghny
2246 * @date 20 MAY 2013
2247 * @version 1.0
2248 */
2249static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2250{
2251 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2252
2253
2254 kfree(pv_data->buff);
2255 kfree(pv_data);
2256}
2257
2258/**
2259 * @brief WILC_WFI_RemainOnChannelReady
2260 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2261 * @param
2262 * @return none
2263 * @author Amr abdelmoghny
2264 * @date 9 JUNE 2013
2265 * @version
2266 */
2267
2268static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2269{
Chaehyun Lim27268872015-09-15 14:06:13 +09002270 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002271
Chaehyun Lim27268872015-09-15 14:06:13 +09002272 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002273
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302274 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002275
Dean Lee72ed4dc2015-06-12 14:11:44 +09002276 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002277
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278 cfg80211_ready_on_channel(priv->wdev,
2279 priv->strRemainOnChanParams.u64ListenCookie,
2280 priv->strRemainOnChanParams.pstrListenChan,
2281 priv->strRemainOnChanParams.u32ListenDuration,
2282 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002283}
2284
2285/**
2286 * @brief WILC_WFI_RemainOnChannelExpired
2287 * @details Callback function, called on expiration of remain-on-channel duration
2288 * @param
2289 * @return none
2290 * @author Amr abdelmoghny
2291 * @date 15 MAY 2013
2292 * @version
2293 */
2294
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002295static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002296{
Chaehyun Lim27268872015-09-15 14:06:13 +09002297 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002298
Chaehyun Lim27268872015-09-15 14:06:13 +09002299 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002300
2301 /*BugID_5477*/
2302 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302303 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304
Dean Lee72ed4dc2015-06-12 14:11:44 +09002305 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306
2307 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308 cfg80211_remain_on_channel_expired(priv->wdev,
2309 priv->strRemainOnChanParams.u64ListenCookie,
2310 priv->strRemainOnChanParams.pstrListenChan,
2311 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002312 } else {
2313 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2314 , priv->strRemainOnChanParams.u32ListenSessionID);
2315 }
2316}
2317
2318
2319/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002320 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321 * @details Request the driver to remain awake on the specified
2322 * channel for the specified duration to complete an off-channel
2323 * operation (e.g., public action frame exchange). When the driver is
2324 * ready on the requested channel, it must indicate this with an event
2325 * notification by calling cfg80211_ready_on_channel().
2326 * @param[in]
2327 * @return int : Return 0 on Success
2328 * @author mdaftedar
2329 * @date 01 MAR 2012
2330 * @version 1.0
2331 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002332static int remain_on_channel(struct wiphy *wiphy,
2333 struct wireless_dev *wdev,
2334 struct ieee80211_channel *chan,
2335 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002337 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002338 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002339
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002340 priv = wiphy_priv(wiphy);
2341
2342 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2343
2344 /*BugID_4800: if in AP mode, return.*/
2345 /*This check is to handle the situation when user*/
2346 /*requests "create group" during a running scan*/
2347
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002348 if (wdev->iftype == NL80211_IFTYPE_AP) {
2349 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2350 return s32Error;
2351 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002352
2353 u8CurrChannel = chan->hw_value;
2354
2355 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2356 priv->strRemainOnChanParams.pstrListenChan = chan;
2357 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002358 priv->strRemainOnChanParams.u32ListenDuration = duration;
2359 priv->strRemainOnChanParams.u32ListenSessionID++;
2360
2361 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2362 , priv->strRemainOnChanParams.u32ListenSessionID
2363 , duration
2364 , chan->hw_value
2365 , WILC_WFI_RemainOnChannelExpired
2366 , WILC_WFI_RemainOnChannelReady
2367 , (void *)priv);
2368
2369 return s32Error;
2370}
2371
2372/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002373 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002374 * @details Cancel an on-going remain-on-channel operation.
2375 * This allows the operation to be terminated prior to timeout based on
2376 * the duration value.
2377 * @param[in] struct wiphy *wiphy,
2378 * @param[in] struct net_device *dev
2379 * @param[in] u64 cookie,
2380 * @return int : Return 0 on Success
2381 * @author mdaftedar
2382 * @date 01 MAR 2012
2383 * @version 1.0
2384 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002385static int cancel_remain_on_channel(struct wiphy *wiphy,
2386 struct wireless_dev *wdev,
2387 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002389 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002390 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002391
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002392 priv = wiphy_priv(wiphy);
2393
2394 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2395
2396 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2397 return s32Error;
2398}
2399/**
2400 * @brief WILC_WFI_add_wilcvendorspec
2401 * @details Adding WILC information elemet to allow two WILC devices to
2402 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002403 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002404 * @return void
2405 * @author mdaftedar
2406 * @date 01 JAN 2014
2407 * @version 1.0
2408 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002409void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002411 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412}
2413/**
2414 * @brief WILC_WFI_mgmt_tx_frame
2415 * @details
2416 *
2417 * @param[in]
2418 * @return NONE.
2419 * @author mdaftedar
2420 * @date 01 JUL 2012
2421 * @version
2422 */
2423extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002424extern bool bEnablePS;
Chaehyun Lim12a26a32015-09-14 12:24:28 +09002425int mgmt_tx(struct wiphy *wiphy,
2426 struct wireless_dev *wdev,
2427 struct cfg80211_mgmt_tx_params *params,
2428 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002429{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002430 struct ieee80211_channel *chan = params->chan;
2431 unsigned int wait = params->wait;
2432 const u8 *buf = params->buf;
2433 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002434 const struct ieee80211_mgmt *mgmt;
2435 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002436 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002437 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002438 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002439 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002441 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002442
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002443 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002444 priv = wiphy_priv(wiphy);
2445 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2446
2447 *cookie = (unsigned long)buf;
2448 priv->u64tx_cookie = *cookie;
2449 mgmt = (const struct ieee80211_mgmt *) buf;
2450
2451 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2452
2453 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002454 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455 if (mgmt_tx == NULL) {
2456 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2457 return WILC_FAIL;
2458 }
Glen Leef3052582015-09-10 12:03:04 +09002459 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002460 if (mgmt_tx->buff == NULL) {
2461 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002462 kfree(mgmt_tx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463 return WILC_FAIL;
2464 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002465 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466 mgmt_tx->size = len;
2467
2468
2469 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2470 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2471 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2472 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2473 /*Save the current channel after we tune to it*/
2474 u8CurrChannel = chan->hw_value;
2475 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002476 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477
2478
2479 /*BugID_4847*/
2480 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2481 /*BugID_4847*/
2482 /*Only set the channel, if not a negotiation confirmation frame
2483 * (If Negotiation confirmation frame, force it
2484 * to be transmitted on the same negotiation channel)*/
2485
2486 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2487 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2488 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2489 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2490 /*Save the current channel after we tune to it*/
2491 u8CurrChannel = chan->hw_value;
2492 }
2493 switch (buf[ACTION_SUBTYPE_ID]) {
2494 case GAS_INTIAL_REQ:
2495 {
2496 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2497 break;
2498 }
2499
2500 case GAS_INTIAL_RSP:
2501 {
2502 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2503 break;
2504 }
2505
2506 case PUBLIC_ACT_VENDORSPEC:
2507 {
2508 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2509 * 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 +09002510 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002511 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2512 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2513 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2514 get_random_bytes(&u8P2Plocalrandom, 1);
2515 /*Increment the number to prevent if its 0*/
2516 u8P2Plocalrandom++;
2517 }
2518 }
2519
2520 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2521 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2522 if (u8P2Plocalrandom > u8P2Precvrandom) {
2523 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2524
2525 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2526 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002527 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002529 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002530
2531 /*BugID_5460*/
2532 /*If using supplicant go intent, no need at all*/
2533 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002534 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002535 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002536 break;
2537 }
2538 }
2539
2540 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2541 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2542 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2543 mgmt_tx->size = buf_len;
2544 }
2545 } else
2546 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2547 }
2548
2549 } else {
2550 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2551 }
2552
2553 break;
2554 }
2555
2556 default:
2557 {
2558 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2559 break;
2560 }
2561 }
2562
2563 }
2564
2565 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2566 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2567
2568 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2569
2570 }
2571
2572 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2573 } else {
2574 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2575 }
2576 return s32Error;
2577}
2578
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09002579int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2580 struct wireless_dev *wdev,
2581 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002582{
Chaehyun Lim27268872015-09-15 14:06:13 +09002583 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002584 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002585
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002586 priv = wiphy_priv(wiphy);
2587 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2588
2589
2590 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2591 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2592
Dean Lee72ed4dc2015-06-12 14:11:44 +09002593 if (priv->bInP2PlistenState == false) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002594 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2595 * considers the driver falsely that it is in Listen state */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 cfg80211_remain_on_channel_expired(priv->wdev,
2597 priv->strRemainOnChanParams.u64ListenCookie,
2598 priv->strRemainOnChanParams.pstrListenChan,
2599 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002600 }
2601
2602 return 0;
2603}
2604
2605/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002606 * @brief WILC_WFI_frame_register
2607 * @details Notify driver that a management frame type was
2608 * registered. Note that this callback may not sleep, and cannot run
2609 * concurrently with itself.
2610 * @param[in]
2611 * @return NONE.
2612 * @author mdaftedar
2613 * @date 01 JUL 2012
2614 * @version
2615 */
2616void WILC_WFI_frame_register(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002617 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 u16 frame_type, bool reg)
2619{
2620
Chaehyun Lim27268872015-09-15 14:06:13 +09002621 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002622 perInterface_wlan_t *nic;
2623
2624
2625 priv = wiphy_priv(wiphy);
2626 nic = netdev_priv(priv->wdev->netdev);
2627
2628
2629
2630 /*BugID_5137*/
2631 if (!frame_type)
2632 return;
2633
2634 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2635 switch (frame_type) {
2636 case PROBE_REQ:
2637 {
2638 nic->g_struct_frame_reg[0].frame_type = frame_type;
2639 nic->g_struct_frame_reg[0].reg = reg;
2640 }
2641 break;
2642
2643 case ACTION:
2644 {
2645 nic->g_struct_frame_reg[1].frame_type = frame_type;
2646 nic->g_struct_frame_reg[1].reg = reg;
2647 }
2648 break;
2649
2650 default:
2651 {
2652 break;
2653 }
2654
2655 }
2656 /*If mac is closed, then return*/
2657 if (!g_linux_wlan->wilc1000_initialized) {
2658 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2659 return;
2660 }
2661 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2662
2663
2664}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665#endif /*WILC_P2P*/
2666
2667/**
2668 * @brief WILC_WFI_set_cqm_rssi_config
2669 * @details Configure connection quality monitor RSSI threshold.
2670 * @param[in] struct wiphy *wiphy:
2671 * @param[in] struct net_device *dev:
2672 * @param[in] s32 rssi_thold:
2673 * @param[in] u32 rssi_hyst:
2674 * @return int : Return 0 on Success
2675 * @author mdaftedar
2676 * @date 01 MAR 2012
2677 * @version 1.0
2678 */
2679static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2680 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2681{
2682 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2683 return 0;
2684
2685}
2686/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002687 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688 * @details Configure connection quality monitor RSSI threshold.
2689 * @param[in] struct wiphy *wiphy:
2690 * @param[in] struct net_device *dev
2691 * @param[in] int idx
2692 * @param[in] u8 *mac
2693 * @param[in] struct station_info *sinfo
2694 * @return int : Return 0 on Success
2695 * @author mdaftedar
2696 * @date 01 MAR 2012
2697 * @version 1.0
2698 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002699static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2700 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701{
Chaehyun Lim27268872015-09-15 14:06:13 +09002702 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002703
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002704 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2705
2706 if (idx != 0)
2707 return -ENOENT;
2708
2709 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002710
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002711 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712
2713 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2714
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715 return 0;
2716
2717}
2718
2719
2720/**
2721 * @brief WILC_WFI_set_power_mgmt
2722 * @details
2723 * @param[in]
2724 * @return int : Return 0 on Success.
2725 * @author mdaftedar
2726 * @date 01 JUL 2012
2727 * @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
2728 */
2729int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2730 bool enabled, int timeout)
2731{
Chaehyun Lim27268872015-09-15 14:06:13 +09002732 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002733
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002734 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2735
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002736 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002737 return -ENOENT;
2738
2739 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002740 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741 PRINT_ER("Driver is NULL\n");
2742 return -EIO;
2743 }
2744
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002745 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002746 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2747
2748
2749 return WILC_SUCCESS;
2750
2751}
2752#ifdef WILC_AP_EXTERNAL_MLME
2753/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002754 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755 * @details Change type/configuration of virtual interface,
2756 * keep the struct wireless_dev's iftype updated.
2757 * @param[in] NONE
2758 * @return int : Return 0 on Success.
2759 * @author mdaftedar
2760 * @date 01 MAR 2012
2761 * @version 1.0
2762 */
2763void wilc1000_wlan_deinit(linux_wlan_t *nic);
2764int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2765
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002766static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2767 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002768{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002769 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002770 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002772 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002773 u16 TID = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002774 #ifdef WILC_P2P
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002775 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776 #endif
2777
2778 nic = netdev_priv(dev);
2779 priv = wiphy_priv(wiphy);
2780
2781 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2782 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2783 u8P2Plocalrandom = 0x01;
2784 u8P2Precvrandom = 0x00;
2785
Dean Lee72ed4dc2015-06-12 14:11:44 +09002786 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787
2788 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09002789 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002790 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2792 #endif
2793 /*BugID_5137*/
2794 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2795 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002796 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 }
2798
2799 switch (type) {
2800 case NL80211_IFTYPE_STATION:
2801 connecting = 0;
2802 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002803
2804 /* send delba over wlan interface */
2805
2806
2807 dev->ieee80211_ptr->iftype = type;
2808 priv->wdev->iftype = type;
2809 nic->monitor_flag = 0;
2810 nic->iftype = STATION_MODE;
2811
2812 /*Remove the enteries of the previously connected clients*/
2813 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 #ifdef WILC_P2P
2815 interface_type = nic->iftype;
2816 nic->iftype = STATION_MODE;
2817
2818 if (g_linux_wlan->wilc1000_initialized) {
2819 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2820 /* ensure that the message Q is empty */
2821 host_int_wait_msg_queue_idle();
2822
2823 /*BugID_5213*/
2824 /*Eliminate host interface blocking state*/
Greg Kroah-Hartman8990d852015-09-03 20:07:58 -07002825 up(&g_linux_wlan->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826
2827 wilc1000_wlan_deinit(g_linux_wlan);
2828 wilc1000_wlan_init(dev, nic);
2829 g_wilc_initialized = 1;
2830 nic->iftype = interface_type;
2831
2832 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2833 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002834 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002835 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2836 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2837
2838 /*Add saved WEP keys, if any*/
2839 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002840 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002842 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843 g_key_wep_params.key,
2844 g_key_wep_params.key_len,
2845 g_key_wep_params.key_idx);
2846 }
2847
2848 /*No matter the driver handler passed here, it will be overwriiten*/
2849 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2850 host_int_flush_join_req(priv->hWILCWFIDrv);
2851
2852 /*Add saved PTK and GTK keys, if any*/
2853 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2854 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2855 g_key_ptk_params.key[1],
2856 g_key_ptk_params.key[2]);
2857 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2858 g_key_gtk_params.key[1],
2859 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002860 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2861 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2862 g_add_ptk_key_params.key_idx,
2863 g_add_ptk_key_params.pairwise,
2864 g_add_ptk_key_params.mac_addr,
2865 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002866
Chaehyun Lim953d4172015-09-14 12:24:05 +09002867 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2868 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2869 g_add_gtk_key_params.key_idx,
2870 g_add_gtk_key_params.pairwise,
2871 g_add_gtk_key_params.mac_addr,
2872 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002873 }
2874
2875 /*BugID_4847: registered frames in firmware are now*/
2876 /*lost due to mac close. So re-register those frames*/
2877 if (g_linux_wlan->wilc1000_initialized) {
2878 for (i = 0; i < num_reg_frame; i++) {
2879 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2880 nic->g_struct_frame_reg[i].reg);
2881 host_int_frame_register(priv->hWILCWFIDrv,
2882 nic->g_struct_frame_reg[i].frame_type,
2883 nic->g_struct_frame_reg[i].reg);
2884 }
2885 }
2886
Dean Lee72ed4dc2015-06-12 14:11:44 +09002887 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2889 }
2890 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002891 break;
2892
2893 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002894 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2896 connecting = 0;
2897 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002898
2899 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2900
2901 dev->ieee80211_ptr->iftype = type;
2902 priv->wdev->iftype = type;
2903 nic->monitor_flag = 0;
2904
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002905 #ifdef WILC_P2P
2906
2907 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2908 nic->iftype = CLIENT_MODE;
2909
2910
2911 if (g_linux_wlan->wilc1000_initialized) {
2912 /* ensure that the message Q is empty */
2913 host_int_wait_msg_queue_idle();
2914
2915 wilc1000_wlan_deinit(g_linux_wlan);
2916 wilc1000_wlan_init(dev, nic);
2917 g_wilc_initialized = 1;
2918
2919 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002920 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2922 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2923
2924 /*Add saved WEP keys, if any*/
2925 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002926 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002927 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002928 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002929 g_key_wep_params.key,
2930 g_key_wep_params.key_len,
2931 g_key_wep_params.key_idx);
2932 }
2933
2934 /*No matter the driver handler passed here, it will be overwriiten*/
2935 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2936 host_int_flush_join_req(priv->hWILCWFIDrv);
2937
2938 /*Add saved PTK and GTK keys, if any*/
2939 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2940 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2941 g_key_ptk_params.key[1],
2942 g_key_ptk_params.key[2]);
2943 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2944 g_key_gtk_params.key[1],
2945 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002946 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2947 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2948 g_add_ptk_key_params.key_idx,
2949 g_add_ptk_key_params.pairwise,
2950 g_add_ptk_key_params.mac_addr,
2951 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952
Chaehyun Lim953d4172015-09-14 12:24:05 +09002953 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2954 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2955 g_add_gtk_key_params.key_idx,
2956 g_add_gtk_key_params.pairwise,
2957 g_add_gtk_key_params.mac_addr,
2958 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959 }
2960
2961 /*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 +09002962 refresh_scan(priv, 1, true);
2963 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964
2965 /*BugID_4847: registered frames in firmware are now lost
2966 * due to mac close. So re-register those frames */
2967 if (g_linux_wlan->wilc1000_initialized) {
2968 for (i = 0; i < num_reg_frame; i++) {
2969 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2970 nic->g_struct_frame_reg[i].reg);
2971 host_int_frame_register(priv->hWILCWFIDrv,
2972 nic->g_struct_frame_reg[i].frame_type,
2973 nic->g_struct_frame_reg[i].reg);
2974 }
2975 }
2976 }
2977 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002978 break;
2979
2980 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002981 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002982 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983 dev->ieee80211_ptr->iftype = type;
2984 priv->wdev->iftype = type;
2985 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002986 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002988 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2989 linux_wlan_get_firmware(nic);
2990 #ifdef WILC_P2P
2991 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2992 if (g_linux_wlan->wilc1000_initialized) {
2993 nic->iftype = AP_MODE;
2994 g_linux_wlan->wilc1000_initialized = 1;
2995 mac_close(dev);
2996 mac_open(dev);
2997
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998 /*BugID_4847: registered frames in firmware are now lost
2999 * due to mac close. So re-register those frames */
3000 for (i = 0; i < num_reg_frame; i++) {
3001 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3002 nic->g_struct_frame_reg[i].reg);
3003 host_int_frame_register(priv->hWILCWFIDrv,
3004 nic->g_struct_frame_reg[i].frame_type,
3005 nic->g_struct_frame_reg[i].reg);
3006 }
3007 }
3008 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003009 break;
3010
3011 case NL80211_IFTYPE_P2P_GO:
3012 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3013
3014 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09003015 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003016 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017 #endif
3018 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3019 /*BugID_5222*/
3020 /*Delete block ack has to be the latest config packet*/
3021 /*sent before downloading new FW. This is because it blocks on*/
3022 /*hWaitResponse semaphore, which allows previous config*/
3023 /*packets to actually take action on old FW*/
3024 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09003025 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003026 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027 dev->ieee80211_ptr->iftype = type;
3028 priv->wdev->iftype = type;
3029
Johnny Kim8a143302015-06-10 17:06:46 +09003030 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003031
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003032 #ifdef WILC_P2P
3033 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3034
3035
3036 #if 1
3037 nic->iftype = GO_MODE;
3038
3039 /* ensure that the message Q is empty */
3040 host_int_wait_msg_queue_idle();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041 wilc1000_wlan_deinit(g_linux_wlan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003042 wilc1000_wlan_init(dev, nic);
3043 g_wilc_initialized = 1;
3044
3045
3046 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3047 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09003048 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3050 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3051
3052 /*Add saved WEP keys, if any*/
3053 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09003054 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003055 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09003056 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003057 g_key_wep_params.key,
3058 g_key_wep_params.key_len,
3059 g_key_wep_params.key_idx);
3060 }
3061
3062 /*No matter the driver handler passed here, it will be overwriiten*/
3063 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3064 host_int_flush_join_req(priv->hWILCWFIDrv);
3065
3066 /*Add saved PTK and GTK keys, if any*/
3067 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3068 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3069 g_key_ptk_params.key[1],
3070 g_key_ptk_params.key[2],
3071 g_key_ptk_params.cipher);
3072 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3073 g_key_gtk_params.key[1],
3074 g_key_gtk_params.key[2],
3075 g_key_gtk_params.cipher);
3076 #if 1
Chaehyun Lim953d4172015-09-14 12:24:05 +09003077 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3078 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3079 g_add_ptk_key_params.key_idx,
3080 g_add_ptk_key_params.pairwise,
3081 g_add_ptk_key_params.mac_addr,
3082 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083
Chaehyun Lim953d4172015-09-14 12:24:05 +09003084 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3085 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3086 g_add_gtk_key_params.key_idx,
3087 g_add_gtk_key_params.pairwise,
3088 g_add_gtk_key_params.mac_addr,
3089 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 #endif
3091 }
3092 #endif
3093
3094 /*BugID_4847: registered frames in firmware are now*/
3095 /*lost due to mac close. So re-register those frames*/
3096 if (g_linux_wlan->wilc1000_initialized) {
3097 for (i = 0; i < num_reg_frame; i++) {
3098 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3099 nic->g_struct_frame_reg[i].reg);
3100 host_int_frame_register(priv->hWILCWFIDrv,
3101 nic->g_struct_frame_reg[i].frame_type,
3102 nic->g_struct_frame_reg[i].reg);
3103 }
3104 }
3105 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106 break;
3107
3108 default:
3109 PRINT_ER("Unknown interface type= %d\n", type);
3110 s32Error = -EINVAL;
3111 return s32Error;
3112 break;
3113 }
3114
3115 return s32Error;
3116}
3117
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003118/* (austin.2013-07-23)
3119 *
3120 * To support revised cfg80211_ops
3121 *
3122 * add_beacon --> start_ap
3123 * set_beacon --> change_beacon
3124 * del_beacon --> stop_ap
3125 *
3126 * beacon_parameters --> cfg80211_ap_settings
3127 * cfg80211_beacon_data
3128 *
3129 * applicable for linux kernel 3.4+
3130 */
3131
3132/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09003133 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003134 * @details Add a beacon with given parameters, @head, @interval
3135 * and @dtim_period will be valid, @tail is optional.
3136 * @param[in] wiphy
3137 * @param[in] dev The net device structure
3138 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3139 * @return int : Return 0 on Success.
3140 * @author austin
3141 * @date 23 JUL 2013
3142 * @version 1.0
3143 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09003144static int start_ap(struct wiphy *wiphy, struct net_device *dev,
3145 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003146{
3147 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09003148 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003149 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003150
3151 priv = wiphy_priv(wiphy);
3152 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3153
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303154 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 +09003155 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3156
Chaehyun Lim80785a92015-09-14 12:24:01 +09003157 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003158
3159 if (s32Error != WILC_SUCCESS)
3160 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003161
3162 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3163
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003164 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3165 settings->beacon_interval,
3166 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003167 beacon->head_len, (u8 *)beacon->head,
3168 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003169
3170 return s32Error;
3171}
3172
3173/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003174 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003175 * @details Add a beacon with given parameters, @head, @interval
3176 * and @dtim_period will be valid, @tail is optional.
3177 * @param[in] wiphy
3178 * @param[in] dev The net device structure
3179 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3180 * @return int : Return 0 on Success.
3181 * @author austin
3182 * @date 23 JUL 2013
3183 * @version 1.0
3184 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003185static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
3186 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187{
Chaehyun Lim27268872015-09-15 14:06:13 +09003188 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003189 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003190
3191 priv = wiphy_priv(wiphy);
3192 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3193
3194
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003195 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3196 0,
3197 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003198 beacon->head_len, (u8 *)beacon->head,
3199 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003200
3201 return s32Error;
3202}
3203
3204/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003205 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003206 * @details Remove beacon configuration and stop sending the beacon.
3207 * @param[in]
3208 * @return int : Return 0 on Success.
3209 * @author austin
3210 * @date 23 JUL 2013
3211 * @version 1.0
3212 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003213static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003215 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003216 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003217 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003218
Leo Kim7ae43362015-09-16 18:35:59 +09003219 if (!wiphy)
3220 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003221
3222 priv = wiphy_priv(wiphy);
3223
3224 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3225
3226 /*BugID_5188*/
3227 linux_wlan_set_bssid(dev, NullBssid);
3228
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003231 if (s32Error)
3232 PRINT_ER("Host delete beacon fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003233
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003234 return s32Error;
3235}
3236
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237/**
Chaehyun Limed269552015-09-14 12:24:15 +09003238 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 * @details Add a new station.
3240 * @param[in]
3241 * @return int : Return 0 on Success.
3242 * @author mdaftedar
3243 * @date 01 MAR 2012
3244 * @version 1.0
3245 */
Chaehyun Limed269552015-09-14 12:24:15 +09003246static int add_station(struct wiphy *wiphy, struct net_device *dev,
3247 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003248{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003249 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003250 struct wilc_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303251 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003252 perInterface_wlan_t *nic;
3253
Leo Kim7ae43362015-09-16 18:35:59 +09003254 if (!wiphy)
3255 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003256
3257 priv = wiphy_priv(wiphy);
3258 nic = netdev_priv(dev);
3259
3260 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003261 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3262 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003263 strStaParams.u16AssocID = params->aid;
3264 strStaParams.u8NumRates = params->supported_rates_len;
3265 strStaParams.pu8Rates = params->supported_rates;
3266
3267 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3268
3269 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],
3270 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3271 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3272 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3273
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003274 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003275 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003277 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003278 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3279 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003280 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3282 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3283 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3284 }
3285
3286 strStaParams.u16FlagsMask = params->sta_flags_mask;
3287 strStaParams.u16FlagsSet = params->sta_flags_set;
3288
3289 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3290 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3291 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3292 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3293 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3294 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3295 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3296 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3297
3298 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003299 if (s32Error)
3300 PRINT_ER("Host add station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301 }
3302
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003303 return s32Error;
3304}
3305
3306/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003307 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003308 * @details Remove a station; @mac may be NULL to remove all stations.
3309 * @param[in]
3310 * @return int : Return 0 on Success.
3311 * @author mdaftedar
3312 * @date 01 MAR 2012
3313 * @version 1.0
3314 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003315static int del_station(struct wiphy *wiphy, struct net_device *dev,
3316 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003318 const u8 *mac = params->mac;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003319 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003320 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003321 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003322
Leo Kim7ae43362015-09-16 18:35:59 +09003323 if (!wiphy)
3324 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003325
3326 priv = wiphy_priv(wiphy);
3327 nic = netdev_priv(dev);
3328
3329 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3330 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3331
3332
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003333 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303334 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003335 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3336 } else {
3337 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]);
3338 }
3339
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003340 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003342 if (s32Error)
3343 PRINT_ER("Host delete station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344 }
3345 return s32Error;
3346}
3347
3348/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003349 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350 * @details Modify a given station.
3351 * @param[in]
3352 * @return int : Return 0 on Success.
3353 * @author mdaftedar
3354 * @date 01 MAR 2012
3355 * @version 1.0
3356 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003357static int change_station(struct wiphy *wiphy, struct net_device *dev,
3358 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003360 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003361 struct wilc_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303362 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003363 perInterface_wlan_t *nic;
3364
3365
3366 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3367
Leo Kim7ae43362015-09-16 18:35:59 +09003368 if (!wiphy)
3369 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003370
3371 priv = wiphy_priv(wiphy);
3372 nic = netdev_priv(dev);
3373
3374 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003375 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003376 strStaParams.u16AssocID = params->aid;
3377 strStaParams.u8NumRates = params->supported_rates_len;
3378 strStaParams.pu8Rates = params->supported_rates;
3379
3380 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],
3381 strStaParams.au8BSSID[5]);
3382 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3383 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3384
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003385 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003386 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003388 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3390 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003391 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003392 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3393 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3394 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3395
3396 }
3397
3398 strStaParams.u16FlagsMask = params->sta_flags_mask;
3399 strStaParams.u16FlagsSet = params->sta_flags_set;
3400
3401 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3402 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3403 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3404 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3405 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3406 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3407 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3408 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3409
3410 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
Leo Kim7dc1d0c2015-09-16 18:36:00 +09003411 if (s32Error)
3412 PRINT_ER("Host edit station fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003413 }
3414 return s32Error;
3415}
3416
3417
3418/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003419 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420 * @details
3421 * @param[in]
3422 * @return int : Return 0 on Success.
3423 * @author mdaftedar
3424 * @date 01 JUL 2012
3425 * @version 1.0
3426 */
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003427struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, const char *name,
3428 unsigned char name_assign_type,
3429 enum nl80211_iftype type, u32 *flags,
3430 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003431{
3432 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003433 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003434 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003435
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436 priv = wiphy_priv(wiphy);
3437
3438
3439
3440 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3441
3442 nic = netdev_priv(priv->wdev->netdev);
3443
3444
3445 if (type == NL80211_IFTYPE_MONITOR) {
3446 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3447 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3448 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3449 if (new_ifc != NULL) {
3450 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451 nic = netdev_priv(priv->wdev->netdev);
3452 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453 } else
3454 PRINT_ER("Error in initializing monitor interface\n ");
3455 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003456 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003457}
3458
3459/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003460 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461 * @details
3462 * @param[in]
3463 * @return int : Return 0 on Success.
3464 * @author mdaftedar
3465 * @date 01 JUL 2012
3466 * @version 1.0
3467 */
Chaehyun Limb4a73352015-09-14 12:24:10 +09003468int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003469{
3470 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3471 return WILC_SUCCESS;
3472}
3473
3474
3475
3476#endif /*WILC_AP_EXTERNAL_MLME*/
Chaehyun Lim08241922015-09-15 14:06:12 +09003477static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003478
Chaehyun Lim80785a92015-09-14 12:24:01 +09003479 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003480 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003481 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003482 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003483 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003484 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003485 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003486 .set_default_key = set_default_key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003487 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003488 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003489 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003490 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
Chaehyun Lima13168d2015-09-14 12:24:12 +09003492 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003493 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003494 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003495 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003496 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003497 .change_station = change_station,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498 #endif /* WILC_AP_EXTERNAL_MLME*/
Chaehyun Limf06f5622015-09-14 12:24:18 +09003499 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003500 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003501 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003502 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503
Chaehyun Lim4d466572015-09-14 12:24:22 +09003504 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003505 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003506 .flush_pmksa = flush_pmksa,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003507#ifdef WILC_P2P
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003508 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003509 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003510 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003511 .mgmt_tx = mgmt_tx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 .mgmt_frame_register = WILC_WFI_frame_register,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003513 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3514 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3515#endif
3516
3517};
3518
3519
3520
3521
3522
3523/**
3524 * @brief WILC_WFI_update_stats
3525 * @details Modify parameters for a given BSS.
3526 * @param[in]
3527 * @return int : Return 0 on Success.
3528 * @author mdaftedar
3529 * @date 01 MAR 2012
3530 * @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
3531 */
3532int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3533{
3534
Chaehyun Lim27268872015-09-15 14:06:13 +09003535 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003536
3537 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538#if 1
3539 switch (changed) {
3540
3541 case WILC_WFI_RX_PKT:
3542 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543 priv->netstats.rx_packets++;
3544 priv->netstats.rx_bytes += pktlen;
3545 priv->netstats.rx_time = get_jiffies_64();
3546 }
3547 break;
3548
3549 case WILC_WFI_TX_PKT:
3550 {
3551 priv->netstats.tx_packets++;
3552 priv->netstats.tx_bytes += pktlen;
3553 priv->netstats.tx_time = get_jiffies_64();
3554
3555 }
3556 break;
3557
3558 default:
3559 break;
3560 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561#endif
3562 return 0;
3563}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003564
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003565/**
3566 * @brief WILC_WFI_CfgAlloc
3567 * @details Allocation of the wireless device structure and assigning it
3568 * to the cfg80211 operations structure.
3569 * @param[in] NONE
3570 * @return wireless_dev : Returns pointer to wireless_dev structure.
3571 * @author mdaftedar
3572 * @date 01 MAR 2012
3573 * @version 1.0
3574 */
3575struct wireless_dev *WILC_WFI_CfgAlloc(void)
3576{
3577
3578 struct wireless_dev *wdev;
3579
3580
3581 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3582 /*Allocating the wireless device structure*/
3583 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3584 if (!wdev) {
3585 PRINT_ER("Cannot allocate wireless device\n");
3586 goto _fail_;
3587 }
3588
3589 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003590 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003591 if (!wdev->wiphy) {
3592 PRINT_ER("Cannot allocate wiphy\n");
3593 goto _fail_mem_;
3594
3595 }
3596
3597 #ifdef WILC_AP_EXTERNAL_MLME
3598 /* enable 802.11n HT */
3599 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3600 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3601 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3602 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3603 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3604 #endif
3605
3606 /*wiphy bands*/
3607 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3608
3609 return wdev;
3610
3611_fail_mem_:
3612 kfree(wdev);
3613_fail_:
3614 return NULL;
3615
3616}
3617/**
3618 * @brief WILC_WFI_WiphyRegister
3619 * @details Registering of the wiphy structure and interface modes
3620 * @param[in] NONE
3621 * @return NONE
3622 * @author mdaftedar
3623 * @date 01 MAR 2012
3624 * @version 1.0
3625 */
3626struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3627{
Chaehyun Lim27268872015-09-15 14:06:13 +09003628 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629 struct wireless_dev *wdev;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003630 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631
3632 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3633
3634 wdev = WILC_WFI_CfgAlloc();
3635 if (wdev == NULL) {
3636 PRINT_ER("CfgAlloc Failed\n");
3637 return NULL;
3638 }
3639
3640
3641 /*Return hardware description structure (wiphy)'s priv*/
3642 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003643 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003644
3645 /*Link the wiphy with wireless structure*/
3646 priv->wdev = wdev;
3647
3648 /*Maximum number of probed ssid to be added by user for the scan request*/
3649 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003650 /*Maximum number of pmkids to be cashed*/
3651 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3652 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003653
3654 wdev->wiphy->max_scan_ie_len = 1000;
3655
3656 /*signal strength in mBm (100*dBm) */
3657 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3658
3659 /*Set the availaible cipher suites*/
3660 wdev->wiphy->cipher_suites = cipher_suites;
3661 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003662 /*Setting default managment types: for register action frame: */
3663 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003664
3665#ifdef WILC_P2P
3666 wdev->wiphy->max_remain_on_channel_duration = 500;
3667 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3668 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3669 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003670 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003671#else
3672 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3673#endif
3674 wdev->iftype = NL80211_IFTYPE_STATION;
3675
3676
3677
3678 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3679 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3680 wdev->wiphy->interface_modes, wdev->iftype);
3681
3682 #ifdef WILC_SDIO
3683 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3684 #endif
3685
3686 /*Register wiphy structure*/
3687 s32Error = wiphy_register(wdev->wiphy);
3688 if (s32Error) {
3689 PRINT_ER("Cannot register wiphy device\n");
3690 /*should define what action to be taken in such failure*/
3691 } else {
3692 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3693 }
3694
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003695 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696 return wdev;
3697
3698
3699}
3700/**
3701 * @brief WILC_WFI_WiphyFree
3702 * @details Freeing allocation of the wireless device structure
3703 * @param[in] NONE
3704 * @return NONE
3705 * @author mdaftedar
3706 * @date 01 MAR 2012
3707 * @version 1.0
3708 */
3709int WILC_WFI_InitHostInt(struct net_device *net)
3710{
3711
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003712 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003713
Chaehyun Lim27268872015-09-15 14:06:13 +09003714 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003715
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003716 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3717 priv = wdev_priv(net->ieee80211_ptr);
3718 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003719 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003721 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003722 #endif
3723 }
3724 op_ifcs++;
3725 if (s32Error < 0) {
3726 PRINT_ER("Failed to creat refresh Timer\n");
3727 return s32Error;
3728 }
3729
Dean Lee72ed4dc2015-06-12 14:11:44 +09003730 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731
Dean Lee72ed4dc2015-06-12 14:11:44 +09003732 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003733
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003734 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003735 s32Error = host_int_init(&priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003736 if (s32Error) {
3737 PRINT_ER("Error while initializing hostinterface\n");
3738 }
3739 return s32Error;
3740}
3741
3742/**
3743 * @brief WILC_WFI_WiphyFree
3744 * @details Freeing allocation of the wireless device structure
3745 * @param[in] NONE
3746 * @return NONE
3747 * @author mdaftedar
3748 * @date 01 MAR 2012
3749 * @version 1.0
3750 */
3751int WILC_WFI_DeInitHostInt(struct net_device *net)
3752{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003753 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003754
Chaehyun Lim27268872015-09-15 14:06:13 +09003755 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003756
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003757 priv = wdev_priv(net->ieee80211_ptr);
3758
Dean Lee72ed4dc2015-06-12 14:11:44 +09003759 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003760
Dean Lee72ed4dc2015-06-12 14:11:44 +09003761 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003762
3763 op_ifcs--;
3764
3765 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003766
3767 /* Clear the Shadow scan */
3768 clear_shadow_scan(priv);
3769 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3770 if (op_ifcs == 0) {
3771 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003772 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003773 }
3774 #endif
3775
3776 if (s32Error) {
3777 PRINT_ER("Error while deintializing host interface\n");
3778 }
3779 return s32Error;
3780}
3781
3782
3783/**
3784 * @brief WILC_WFI_WiphyFree
3785 * @details Freeing allocation of the wireless device structure
3786 * @param[in] NONE
3787 * @return NONE
3788 * @author mdaftedar
3789 * @date 01 MAR 2012
3790 * @version 1.0
3791 */
3792void WILC_WFI_WiphyFree(struct net_device *net)
3793{
3794
3795 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3796
3797 if (net == NULL) {
3798 PRINT_D(INIT_DBG, "net_device is NULL\n");
3799 return;
3800 }
3801
3802 if (net->ieee80211_ptr == NULL) {
3803 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3804 return;
3805 }
3806
3807 if (net->ieee80211_ptr->wiphy == NULL) {
3808 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3809 return;
3810 }
3811
3812 wiphy_unregister(net->ieee80211_ptr->wiphy);
3813
3814 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3815 wiphy_free(net->ieee80211_ptr->wiphy);
3816 kfree(net->ieee80211_ptr);
3817
3818}