blob: 4151aae0eb9798af856e80a880bebf57b9f2955d [file] [log] [blame]
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001/*!
2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
4 * @author aabouzaeid
5 * mabubakr
6 * mdaftedar
7 * zsalah
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
9 * @date 31 Aug 2010
10 * @version 1.0
11 */
12
13#include "wilc_wfi_cfgoperations.h"
14#include "wilc_wlan.c"
15#ifdef WILC_SDIO
16#include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
17#endif
18
19
20#define IS_MANAGMEMENT 0x100
21#define IS_MANAGMEMENT_CALLBACK 0x080
22#define IS_MGMT_STATUS_SUCCES 0x040
23#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
24
Johnny Kimc5c77ba2015-05-11 14:30:56 +090025extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
Dean Lee72ed4dc2015-06-12 14:11:44 +090026extern u16 Set_machw_change_vir_if(bool bValue);
Johnny Kimc5c77ba2015-05-11 14:30:56 +090027
28extern int mac_open(struct net_device *ndev);
29extern int mac_close(struct net_device *ndev);
30
31tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +090032u32 u32LastScannedNtwrksCountShadow;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090033#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070034struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090035#endif
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070036struct timer_list hAgingTimer;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090037static u8 op_ifcs;
38extern u8 u8ConnectedSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +090039
40/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090041u8 g_wilc_initialized = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090042extern linux_wlan_t *g_linux_wlan;
43#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +090044extern bool g_obtainingIP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090045#endif
46
47#define CHAN2G(_channel, _freq, _flags) { \
48 .band = IEEE80211_BAND_2GHZ, \
49 .center_freq = (_freq), \
50 .hw_value = (_channel), \
51 .flags = (_flags), \
52 .max_antenna_gain = 0, \
53 .max_power = 30, \
54}
55
56/*Frequency range for channels*/
57static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
58 CHAN2G(1, 2412, 0),
59 CHAN2G(2, 2417, 0),
60 CHAN2G(3, 2422, 0),
61 CHAN2G(4, 2427, 0),
62 CHAN2G(5, 2432, 0),
63 CHAN2G(6, 2437, 0),
64 CHAN2G(7, 2442, 0),
65 CHAN2G(8, 2447, 0),
66 CHAN2G(9, 2452, 0),
67 CHAN2G(10, 2457, 0),
68 CHAN2G(11, 2462, 0),
69 CHAN2G(12, 2467, 0),
70 CHAN2G(13, 2472, 0),
71 CHAN2G(14, 2484, 0),
72};
73
74#define RATETAB_ENT(_rate, _hw_value, _flags) { \
75 .bitrate = (_rate), \
76 .hw_value = (_hw_value), \
77 .flags = (_flags), \
78}
79
80
81/* Table 6 in section 3.2.1.1 */
82static struct ieee80211_rate WILC_WFI_rates[] = {
83 RATETAB_ENT(10, 0, 0),
84 RATETAB_ENT(20, 1, 0),
85 RATETAB_ENT(55, 2, 0),
86 RATETAB_ENT(110, 3, 0),
87 RATETAB_ENT(60, 9, 0),
88 RATETAB_ENT(90, 6, 0),
89 RATETAB_ENT(120, 7, 0),
90 RATETAB_ENT(180, 8, 0),
91 RATETAB_ENT(240, 9, 0),
92 RATETAB_ENT(360, 10, 0),
93 RATETAB_ENT(480, 11, 0),
94 RATETAB_ENT(540, 12, 0),
95};
96
97#ifdef WILC_P2P
98struct p2p_mgmt_data {
99 int size;
100 u8 *buff;
101};
102
103/*Global variable used to state the current connected STA channel*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900104u8 u8WLANChannel = INVALID_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900105
106/*BugID_5442*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900107u8 u8CurrChannel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900108
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900109u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
110u8 u8P2Plocalrandom = 0x01;
111u8 u8P2Precvrandom = 0x00;
112u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
Daniel Machon7fc80962015-08-05 00:09:35 +0200113bool bWilc_ie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900114#endif
115
116static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
117 .channels = WILC_WFI_2ghz_channels,
118 .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
119 .bitrates = WILC_WFI_rates,
120 .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
121};
122
123
124/*BugID_5137*/
125struct add_key_params {
126 u8 key_idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900127 bool pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128 u8 *mac_addr;
129};
130struct add_key_params g_add_gtk_key_params;
131struct wilc_wfi_key g_key_gtk_params;
132struct add_key_params g_add_ptk_key_params;
133struct wilc_wfi_key g_key_ptk_params;
134struct wilc_wfi_wep_key g_key_wep_params;
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;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900377 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378 struct cfg80211_bss *bss = NULL;
379
Chaehyun Lim27268872015-09-15 14:06:13 +0900380 priv = (struct wilc_priv *)pUserVoid;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900381 if (priv->bCfgScanning == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900382 if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
383 wiphy = priv->dev->ieee80211_ptr->wiphy;
384 WILC_NULLCHECK(s32Error, wiphy);
385 if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
386 &&
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900387 ((((s32)pstrNetworkInfo->s8rssi) * 100) < 0
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900388 ||
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900389 (((s32)pstrNetworkInfo->s8rssi) * 100) > 100)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390 ) {
391 WILC_ERRORREPORT(s32Error, WILC_FAIL);
392 }
393
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900394 if (pstrNetworkInfo != NULL) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900395 s32Freq = ieee80211_channel_to_frequency((s32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900396 channel = ieee80211_get_channel(wiphy, s32Freq);
397
398 WILC_NULLCHECK(s32Error, channel);
399
400 PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530401 "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900402 pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
403
Dean Lee72ed4dc2015-06-12 14:11:44 +0900404 if (pstrNetworkInfo->bNewNetwork == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900405 if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
406 /* max_scan_ssids */
407 PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
408
409
410 priv->u32RcvdChCount++;
411
412
413
414 if (pJoinParams == NULL) {
415 PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
416 }
417 add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
418
419 /*P2P peers are sent to WPA supplicant and added to shadow table*/
420
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900421 if (!(memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900422 bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
423 pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900424 (size_t)pstrNetworkInfo->u16IEsLen, (((s32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900425 cfg80211_put_bss(wiphy, bss);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426 }
427
428
429 } else {
430 PRINT_ER("Discovered networks exceeded the max limit\n");
431 }
432 } else {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900433 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434 /* So this network is discovered before, we'll just update its RSSI */
435 for (i = 0; i < priv->u32RcvdChCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900436 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530437 PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438
439 astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
440 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
441 break;
442 }
443 }
444 }
445 }
446 } else if (enuScanEvent == SCAN_EVENT_DONE) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530447 PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev);
448 PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +0900449 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900450
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530451 if (priv->u32RcvdChCount > 0)
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530452 PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +0530453 else
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530454 PRINT_D(CFG80211_DBG, "No networks found\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900455
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200456 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900457
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900458 if (priv->pstrScanReq != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900459 cfg80211_scan_done(priv->pstrScanReq, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900460 priv->u32RcvdChCount = 0;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900461 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900462 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900463 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200464 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900465
466 }
467 /*Aborting any scan operation during mac close*/
468 else if (enuScanEvent == SCAN_EVENT_ABORTED) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200469 down(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530471 PRINT_D(CFG80211_DBG, "Scan Aborted\n");
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900472 if (priv->pstrScanReq != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900473
474 update_scan_time(priv);
Dean Lee72ed4dc2015-06-12 14:11:44 +0900475 refresh_scan(priv, 1, false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900476
Dean Lee72ed4dc2015-06-12 14:11:44 +0900477 cfg80211_scan_done(priv->pstrScanReq, false);
478 priv->bCfgScanning = false;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +0900479 priv->pstrScanReq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900480 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200481 up(&(priv->hSemScanReq));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900482 }
483 }
484
485
486 WILC_CATCH(s32Error)
487 {
488 }
489}
490
491
492/**
493 * @brief WILC_WFI_Set_PMKSA
494 * @details Check if pmksa is cached and set it.
495 * @param[in]
496 * @return int : Return 0 on Success
497 * @author mdaftedar
498 * @date 01 MAR 2012
499 * @version 1.0
500 */
Chaehyun Lim27268872015-09-15 14:06:13 +0900501int WILC_WFI_Set_PMKSA(u8 *bssid, struct wilc_priv *priv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900503 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900504 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900505
506
507 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
508
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900509 if (!memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900510 ETH_ALEN)) {
511 PRINT_D(CFG80211_DBG, "PMKID successful comparison");
512
513 /*If bssid is found, set the values*/
514 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
515
516 if (s32Error != WILC_SUCCESS)
517 PRINT_ER("Error in pmkid\n");
518
519 break;
520 }
521 }
522
523 return s32Error;
524
525
526}
Chaehyun Lim51e825f2015-09-15 14:06:14 +0900527int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900528
529
530/**
531 * @brief CfgConnectResult
532 * @details
533 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
534 * connection response or disconnection notification.
535 * tstrConnectInfo* pstrConnectInfo: COnnection information.
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900536 * u8 u8MacStatus: Mac Status from firmware
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900537 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
538 * void* pUserVoid: Private data associated with wireless interface
539 * @return NONE
540 * @author mabubakr
541 * @date 01 MAR 2012
542 * @version 1.0
543 */
544int connecting;
545
546static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
547 tstrConnectInfo *pstrConnectInfo,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900548 u8 u8MacStatus,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900549 tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
550 void *pUserVoid)
551{
Chaehyun Lim27268872015-09-15 14:06:13 +0900552 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900553 struct net_device *dev;
554 #ifdef WILC_P2P
555 tstrWILC_WFIDrv *pstrWFIDrv;
556 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900557 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900558
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900559 connecting = 0;
560
Chaehyun Lim27268872015-09-15 14:06:13 +0900561 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900562 dev = priv->dev;
563 #ifdef WILC_P2P
564 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
565 #endif
566
567 if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
568 /*Initialization*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900569 u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570
571 u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
572
573 PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
574
575 if ((u8MacStatus == MAC_DISCONNECTED) &&
576 (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
577 /* The case here is that our station was waiting for association response frame and has just received it containing status code
578 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
579 u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
580 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900581 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900582
583 /*BugID_5457*/
584 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
585 #ifdef WILC_P2P
586 if (!pstrWFIDrv->u8P2PConnect)
587 u8WLANChannel = INVALID_CHANNEL;
588 #endif
589
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530590 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591 }
592
593 if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900594 bool bNeedScanRefresh = false;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900595 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900596
597 PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
598 pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900599 memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900601 /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
602 * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
603 * Linux kernel warning generated at the nl80211 layer */
604
605 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900606 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900607 pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
608 unsigned long now = jiffies;
609
610 if (time_after(now,
611 astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900612 bNeedScanRefresh = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900613 }
614
615 break;
616 }
617 }
618
Abdul Hussain5a66bf22015-06-16 09:44:06 +0000619 if (bNeedScanRefresh) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900620 /*BugID_5418*/
621 /*Also, refrsh DIRECT- results if */
Dean Lee72ed4dc2015-06-12 14:11:44 +0900622 refresh_scan(priv, 1, true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900623
624 }
625
626 }
627
628
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530629 PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900630
631 PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
632
633 cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
634 pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
635 pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
636 u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
637 /* be replaced by pstrConnectInfo->u16ConnectStatus */
638 } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
639 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900640 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900641 #endif
642 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
643 pstrDisconnectNotifInfo->u16reason, priv->dev);
644 u8P2Plocalrandom = 0x01;
645 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900646 bWilc_ie = false;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900647 memset(priv->au8AssociatedBss, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900648 linux_wlan_set_bssid(priv->dev, NullBssid);
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900649 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900650
651 /*BugID_5457*/
652 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
653 #ifdef WILC_P2P
654 if (!pstrWFIDrv->u8P2PConnect)
655 u8WLANChannel = INVALID_CHANNEL;
656 #endif
657 /*BugID_5315*/
658 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
659 * virtual interface to station*/
660 if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
661 pstrDisconnectNotifInfo->u16reason = 3;
662 }
663 /*BugID_5315*/
664 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
665 * to scan again and retry the connection*/
666 else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
667 pstrDisconnectNotifInfo->u16reason = 1;
668 }
669 cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
Sudip Mukherjeee26bb712015-06-30 13:51:51 +0530670 pstrDisconnectNotifInfo->ie_len, false,
671 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672
673 }
674
675}
676
677
678/**
Chaehyun Lim80785a92015-09-14 12:24:01 +0900679 * @brief set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900680 * @details Set channel for a given wireless interface. Some devices
681 * may support multi-channel operation (by channel hopping) so cfg80211
682 * doesn't verify much. Note, however, that the passed netdev may be
683 * %NULL as well if the user requested changing the channel for the
684 * device itself, or for a monitor interface.
685 * @param[in]
686 * @return int : Return 0 on Success
687 * @author mdaftedar
688 * @date 01 MAR 2012
689 * @version 1.0
690 */
Chaehyun Lim80785a92015-09-14 12:24:01 +0900691static int set_channel(struct wiphy *wiphy,
692 struct cfg80211_chan_def *chandef)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693{
694
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900695 u32 channelnum = 0;
Chaehyun Lim27268872015-09-15 14:06:13 +0900696 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900697 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +0900698
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900699 priv = wiphy_priv(wiphy);
700
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701 channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
702 PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900703
704 u8CurrChannel = channelnum;
705 s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
706
707 if (s32Error != WILC_SUCCESS)
708 PRINT_ER("Error in setting channel %d\n", channelnum);
709
710 return s32Error;
711}
712
713/**
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900714 * @brief scan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900715 * @details Request to do a scan. If returning zero, the scan request is given
716 * the driver, and will be valid until passed to cfg80211_scan_done().
717 * For scan results, call cfg80211_inform_bss(); you can call this outside
718 * the scan/scan_done bracket too.
719 * @param[in]
720 * @return int : Return 0 on Success
721 * @author mabubakr
722 * @date 01 MAR 2012
723 * @version 1.0
724 */
725
726/*
727 * kernel version 3.8.8 supported
728 * tony, sswd, WILC-KR, 2013-10-29
729 */
Chaehyun Lim0e30d062015-09-14 12:24:02 +0900730static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731{
Chaehyun Lim27268872015-09-15 14:06:13 +0900732 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900733 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900734 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900735 u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900736 tstrHiddenNetwork strHiddenNetwork;
737
738 priv = wiphy_priv(wiphy);
739
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 priv->pstrScanReq = request;
741
742 priv->u32RcvdChCount = 0;
743
Johnny Kim218dc402015-08-13 13:41:19 +0900744 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900745
746
747 reset_shadow_found(priv);
748
Dean Lee72ed4dc2015-06-12 14:11:44 +0900749 priv->bCfgScanning = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900750 if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
751 /* max_scan_ssids */
752 for (i = 0; i < request->n_channels; i++) {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900753 au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900754 PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
755 }
756
757 PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
Sudip Mukherjee52db75202015-06-02 14:28:17 +0530758 PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900759
760 PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
761
762 if (request->n_ssids >= 1) {
763
764
Glen Leef3052582015-09-10 12:03:04 +0900765 strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(tstrHiddenNetwork), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900766 strHiddenNetwork.u8ssidnum = request->n_ssids;
767
768
769 /*BugID_4156*/
770 for (i = 0; i < request->n_ssids; i++) {
771
772 if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
Glen Leef3052582015-09-10 12:03:04 +0900773 strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900774 memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900775 strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
776 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530777 PRINT_D(CFG80211_DBG, "Received one NULL SSID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900778 strHiddenNetwork.u8ssidnum -= 1;
779 }
780 }
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530781 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900782 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
783 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900784 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900785 CfgScanResult, (void *)priv, &strHiddenNetwork);
786 } else {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530787 PRINT_D(CFG80211_DBG, "Trigger Scan Request\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900788 s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
789 au8ScanChanList, request->n_channels,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900790 (const u8 *)request->ie, request->ie_len,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900791 CfgScanResult, (void *)priv, NULL);
792 }
793
794 } else {
795 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530796 " channels\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900797 }
798
799 if (s32Error != WILC_SUCCESS) {
800 s32Error = -EBUSY;
801 PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
802 }
803
804 return s32Error;
805}
806
807/**
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900808 * @brief connect
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900809 * @details Connect to the ESS with the specified parameters. When connected,
810 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
811 * If the connection fails for some reason, call cfg80211_connect_result()
812 * with the status from the AP.
813 * @param[in]
814 * @return int : Return 0 on Success
815 * @author mabubakr
816 * @date 01 MAR 2012
817 * @version 1.0
818 */
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +0900819static int connect(struct wiphy *wiphy, struct net_device *dev,
820 struct cfg80211_connect_params *sme)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900821{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900822 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900823 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900824 u8 u8security = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900825 AUTHTYPE_T tenuAuth_type = ANY;
Dean Lee576917a2015-06-15 11:58:57 +0900826 char *pcgroup_encrypt_val = NULL;
827 char *pccipher_group = NULL;
828 char *pcwpa_version = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900829
Chaehyun Lim27268872015-09-15 14:06:13 +0900830 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900831 tstrWILC_WFIDrv *pstrWFIDrv;
832 tstrNetworkInfo *pstrNetworkInfo = NULL;
833
834
835 connecting = 1;
836 priv = wiphy_priv(wiphy);
837 pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
838
Johnny Kim218dc402015-08-13 13:41:19 +0900839 host_int_set_wfi_drv_handler(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900840
Johnny Kim8a143302015-06-10 17:06:46 +0900841 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 +0900842 #ifdef WILC_P2P
Chaehyun Lim3f882892015-08-10 11:33:17 +0900843 if (!(strncmp(sme->ssid, "DIRECT-", 7))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900844 PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
845 pstrWFIDrv->u8P2PConnect = 1;
846 } else
847 pstrWFIDrv->u8P2PConnect = 0;
848 #endif
Chandra S Gorentla17aacd42015-08-08 17:41:35 +0530849 PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900850
851 for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
852 if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900853 memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900854 sme->ssid,
855 sme->ssid_len) == 0) {
856 PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
857 if (sme->bssid == NULL) {
858 /* BSSID is not passed from the user, so decision of matching
859 * is done by SSID only */
860 PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
861 break;
862 } else {
863 /* BSSID is also passed from the user, so decision of matching
864 * should consider also this passed BSSID */
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900865 if (memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866 sme->bssid,
867 ETH_ALEN) == 0) {
868 PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
869 break;
870 }
871 }
872 }
873 }
874
875 if (i < u32LastScannedNtwrksCountShadow) {
876 PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
877
878 pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
879
880 PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
881 pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
882 pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
883 pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
884 } else {
885 s32Error = -ENOENT;
886 if (u32LastScannedNtwrksCountShadow == 0)
887 PRINT_D(CFG80211_DBG, "No Scan results yet\n");
888 else
889 PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
890
891 goto done;
892 }
893
894 priv->WILC_WFI_wep_default = 0;
Chaehyun Lim2cc46832015-08-07 09:02:01 +0900895 memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
896 memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900897
898 PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
899 PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
900
901 PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
902
903 if (INFO) {
904 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
905 PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
906 }
907
908 if (sme->crypto.cipher_group != NO_ENCRYPT) {
909 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
910 * we will add to it the pairwise cipher suite(s) */
911 pcwpa_version = "Default";
912 PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900913 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900914 u8security = ENCRYPT_ENABLED | WEP;
915 pcgroup_encrypt_val = "WEP40";
916 pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
917 PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
918
919 if (INFO) {
920 for (i = 0; i < sme->key_len; i++)
921 PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
922 }
923 priv->WILC_WFI_wep_default = sme->key_idx;
924 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900925 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900926
927 /*BugID_5137*/
928 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900929 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
931 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900932 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900933
934 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
935 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
936 } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900937 u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
938 pcgroup_encrypt_val = "WEP104";
939 pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
940
941 priv->WILC_WFI_wep_default = sme->key_idx;
942 priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900943 memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900944
945 /*BugID_5137*/
946 g_key_wep_params.key_len = sme->key_len;
Glen Leef3052582015-09-10 12:03:04 +0900947 g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948 memcpy(g_key_wep_params.key, sme->key, sme->key_len);
949 g_key_wep_params.key_idx = sme->key_idx;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900950 g_wep_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900951
952 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
953 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
954 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900955 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900956 u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
957 pcgroup_encrypt_val = "WPA2_TKIP";
958 pccipher_group = "TKIP";
959 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
960 /* tenuSecurity_t = WPA2_AES; */
961 u8security = ENCRYPT_ENABLED | WPA2 | AES;
962 pcgroup_encrypt_val = "WPA2_AES";
963 pccipher_group = "AES";
964 }
965 pcwpa_version = "WPA_VERSION_2";
966 } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
967 if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900968 u8security = ENCRYPT_ENABLED | WPA | TKIP;
969 pcgroup_encrypt_val = "WPA_TKIP";
970 pccipher_group = "TKIP";
971 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
972 /* tenuSecurity_t = WPA_AES; */
973 u8security = ENCRYPT_ENABLED | WPA | AES;
974 pcgroup_encrypt_val = "WPA_AES";
975 pccipher_group = "AES";
976
977 }
978 pcwpa_version = "WPA_VERSION_1";
979
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980 } else {
981 s32Error = -ENOTSUPP;
982 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
983
984 goto done;
985 }
986
987 }
988
989 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
990 * add to it the pairwise cipher suite(s) */
991 if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
992 || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
993 for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
994 if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
995 u8security = u8security | TKIP;
996 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
997 u8security = u8security | AES;
998 }
999 }
1000 }
1001
1002 PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
1003
1004 PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
1005 switch (sme->auth_type) {
1006 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1007 PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
1008 tenuAuth_type = OPEN_SYSTEM;
1009 break;
1010
1011 case NL80211_AUTHTYPE_SHARED_KEY:
1012 tenuAuth_type = SHARED_KEY;
1013 PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
1014 break;
1015
1016 default:
1017 PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
1018 }
1019
1020
1021 /* ai: key_mgmt: enterprise case */
1022 if (sme->crypto.n_akm_suites) {
1023 switch (sme->crypto.akm_suites[0]) {
1024 case WLAN_AKM_SUITE_8021X:
1025 tenuAuth_type = IEEE8021;
1026 break;
1027
1028 default:
1029 break;
1030 }
1031 }
1032
1033
1034 PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
1035
1036 PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1037 pcgroup_encrypt_val, pccipher_group, pcwpa_version);
1038
1039 /*BugID_5442*/
1040 u8CurrChannel = pstrNetworkInfo->u8channel;
1041
1042 if (!pstrWFIDrv->u8P2PConnect) {
1043 u8WLANChannel = pstrNetworkInfo->u8channel;
1044 }
1045
1046 linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
1047
1048 s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
1049 sme->ssid_len, sme->ie, sme->ie_len,
1050 CfgConnectResult, (void *)priv, u8security,
1051 tenuAuth_type, pstrNetworkInfo->u8channel,
1052 pstrNetworkInfo->pJoinParams);
1053 if (s32Error != WILC_SUCCESS) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301054 PRINT_ER("host_int_set_join_req(): Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001055 s32Error = -ENOENT;
1056 goto done;
1057 }
1058
1059done:
1060
1061 return s32Error;
1062}
1063
1064
1065/**
Chaehyun Limb027cde2015-09-14 12:24:04 +09001066 * @brief disconnect
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 * @details Disconnect from the BSS/ESS.
1068 * @param[in]
1069 * @return int : Return 0 on Success
1070 * @author mdaftedar
1071 * @date 01 MAR 2012
1072 * @version 1.0
1073 */
Chaehyun Limb027cde2015-09-14 12:24:04 +09001074static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001076 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001077 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001078 #ifdef WILC_P2P
1079 tstrWILC_WFIDrv *pstrWFIDrv;
1080 #endif
Chaehyun Lim51e825f2015-09-15 14:06:14 +09001081 u8 NullBssid[ETH_ALEN] = {0};
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001082
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001083 connecting = 0;
1084 priv = wiphy_priv(wiphy);
1085
1086 /*BugID_5457*/
1087 /*Invalidate u8WLANChannel value on wlan0 disconnect*/
1088 #ifdef WILC_P2P
1089 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
1090 if (!pstrWFIDrv->u8P2PConnect)
1091 u8WLANChannel = INVALID_CHANNEL;
1092 #endif
1093 linux_wlan_set_bssid(priv->dev, NullBssid);
1094
1095 PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
1096
1097 u8P2Plocalrandom = 0x01;
1098 u8P2Precvrandom = 0x00;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001099 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001100 #ifdef WILC_P2P
1101 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
1102 #endif
1103
1104 s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
1105 if (s32Error != WILC_SUCCESS) {
1106 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
1107 s32Error = -EINVAL;
1108 }
1109
1110 return s32Error;
1111}
1112
1113/**
Chaehyun Lim953d4172015-09-14 12:24:05 +09001114 * @brief add_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001115 * @details Add a key with the given parameters. @mac_addr will be %NULL
1116 * when adding a group key.
1117 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1118 * @return int : Return 0 on Success
1119 * @author mdaftedar
1120 * @date 01 MAR 2012
1121 * @version 1.0
1122 */
Chaehyun Lim953d4172015-09-14 12:24:05 +09001123static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1124 bool pairwise,
1125 const u8 *mac_addr, struct key_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126
1127{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001128 s32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001129 u32 i;
Chaehyun Lim27268872015-09-15 14:06:13 +09001130 struct wilc_priv *priv;
Arnd Bergmann057d1e92015-06-01 21:06:44 +02001131 const u8 *pu8RxMic = NULL;
1132 const u8 *pu8TxMic = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001133 u8 u8mode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001134 #ifdef WILC_AP_EXTERNAL_MLME
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001135 u8 u8gmode = NO_ENCRYPT;
1136 u8 u8pmode = NO_ENCRYPT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001137 AUTHTYPE_T tenuAuth_type = ANY;
1138 #endif
1139
1140 priv = wiphy_priv(wiphy);
1141
1142 PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
1143
1144 /*BugID_5137*/
Johnny Kim8a143302015-06-10 17:06:46 +09001145 PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146
1147 PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
1148 params->key[1],
1149 params->key[2]);
1150
1151
1152 switch (params->cipher) {
1153 case WLAN_CIPHER_SUITE_WEP40:
1154 case WLAN_CIPHER_SUITE_WEP104:
1155 #ifdef WILC_AP_EXTERNAL_MLME
1156 if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
1157
1158 priv->WILC_WFI_wep_default = key_index;
1159 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001160 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161
1162 PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
1163 PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
1164
1165 for (i = 0; i < params->key_len; i++)
1166 PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
1167
1168 tenuAuth_type = OPEN_SYSTEM;
1169
1170 if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
1171 u8mode = ENCRYPT_ENABLED | WEP;
1172 else
1173 u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
1174
1175 host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
1176 break;
1177 }
1178 #endif
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001179 if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 priv->WILC_WFI_wep_default = key_index;
1181 priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001182 memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001183
1184 PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
1185 PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
1186 if (INFO) {
1187 for (i = 0; i < params->key_len; i++)
1188 PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
1189 }
1190 host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
1191 }
1192
1193 break;
1194
1195 case WLAN_CIPHER_SUITE_TKIP:
1196 case WLAN_CIPHER_SUITE_CCMP:
1197 #ifdef WILC_AP_EXTERNAL_MLME
1198 if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
1199
1200 if (priv->wilc_gtk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001201 priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001202 priv->wilc_gtk[key_index]->key = NULL;
1203 priv->wilc_gtk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001204
1205 }
1206 if (priv->wilc_ptk[key_index] == NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001207 priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001208 priv->wilc_ptk[key_index]->key = NULL;
1209 priv->wilc_ptk[key_index]->seq = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001210 }
1211
1212
1213
Daniel Machon19132212015-08-05 08:18:31 +02001214 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001215 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1216 u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
1217 else
1218 u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
1219
1220 priv->wilc_groupkey = u8gmode;
1221
1222 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1223
1224 pu8TxMic = params->key + 24;
1225 pu8RxMic = params->key + 16;
1226 KeyLen = params->key_len - 16;
1227 }
1228 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1229 if (priv->wilc_gtk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001230 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231
Glen Leef3052582015-09-10 12:03:04 +09001232 priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001233 memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001234
1235 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1236 if (priv->wilc_gtk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001237 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001238
1239 if ((params->seq_len) > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001240 priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001241 memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242 }
1243
1244 priv->wilc_gtk[key_index]->cipher = params->cipher;
1245 priv->wilc_gtk[key_index]->key_len = params->key_len;
1246 priv->wilc_gtk[key_index]->seq_len = params->seq_len;
1247
1248 if (INFO) {
1249 for (i = 0; i < params->key_len; i++)
1250 PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
1251 for (i = 0; i < params->seq_len; i++)
1252 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1253 }
1254
1255
1256 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1257 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
1258
1259 } else {
1260 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]);
1261
1262 if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
1263 u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
1264 else
1265 u8pmode = priv->wilc_groupkey | AES;
1266
1267
1268 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1269
1270 pu8TxMic = params->key + 24;
1271 pu8RxMic = params->key + 16;
1272 KeyLen = params->key_len - 16;
1273 }
1274
1275 if (priv->wilc_ptk[key_index]->key)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001276 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001277
Glen Leef3052582015-09-10 12:03:04 +09001278 priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001279
1280 if (priv->wilc_ptk[key_index]->seq)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001281 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001282
1283 if ((params->seq_len) > 0)
Glen Leef3052582015-09-10 12:03:04 +09001284 priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001285
1286 if (INFO) {
1287 for (i = 0; i < params->key_len; i++)
1288 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
1289
1290 for (i = 0; i < params->seq_len; i++)
1291 PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
1292 }
1293
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001294 memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001295
1296 if ((params->seq_len) > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001297 memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001298
1299 priv->wilc_ptk[key_index]->cipher = params->cipher;
1300 priv->wilc_ptk[key_index]->key_len = params->key_len;
1301 priv->wilc_ptk[key_index]->seq_len = params->seq_len;
1302
1303 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1304 pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
1305 }
1306 break;
1307 }
1308 #endif
1309
1310 {
1311 u8mode = 0;
Daniel Machon19132212015-08-05 08:18:31 +02001312 if (!pairwise) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1314 /* swap the tx mic by rx mic */
1315 pu8RxMic = params->key + 24;
1316 pu8TxMic = params->key + 16;
1317 KeyLen = params->key_len - 16;
1318 }
1319
1320 /*BugID_5137*/
1321 /*save keys only on interface 0 (wifi interface)*/
1322 if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1323 g_add_gtk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324 g_add_gtk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001325 if (!mac_addr) {
1326 g_add_gtk_key_params.mac_addr = NULL;
1327 } else {
Glen Leef3052582015-09-10 12:03:04 +09001328 g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001329 memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
1330 }
1331 g_key_gtk_params.key_len = params->key_len;
1332 g_key_gtk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001333 g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001334 memcpy(g_key_gtk_params.key, params->key, params->key_len);
1335 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001336 g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001337 memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
1338 }
1339 g_key_gtk_params.cipher = params->cipher;
1340
1341 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
1342 g_key_gtk_params.key[1],
1343 g_key_gtk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001344 g_gtk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001345 }
1346
1347 host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
1348 key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 } else {
1350 if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
1351 /* swap the tx mic by rx mic */
1352 pu8RxMic = params->key + 24;
1353 pu8TxMic = params->key + 16;
1354 KeyLen = params->key_len - 16;
1355 }
1356
1357 /*BugID_5137*/
1358 /*save keys only on interface 0 (wifi interface)*/
1359 if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
1360 g_add_ptk_key_params.key_idx = key_index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361 g_add_ptk_key_params.pairwise = pairwise;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001362 if (!mac_addr) {
1363 g_add_ptk_key_params.mac_addr = NULL;
1364 } else {
Glen Leef3052582015-09-10 12:03:04 +09001365 g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366 memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
1367 }
1368 g_key_ptk_params.key_len = params->key_len;
1369 g_key_ptk_params.seq_len = params->seq_len;
Glen Leef3052582015-09-10 12:03:04 +09001370 g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371 memcpy(g_key_ptk_params.key, params->key, params->key_len);
1372 if (params->seq_len > 0) {
Glen Leef3052582015-09-10 12:03:04 +09001373 g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001374 memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
1375 }
1376 g_key_ptk_params.cipher = params->cipher;
1377
1378 PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
1379 g_key_ptk_params.key[1],
1380 g_key_ptk_params.key[2]);
Dean Lee72ed4dc2015-06-12 14:11:44 +09001381 g_ptk_keys_saved = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382 }
1383
1384 host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
1385 pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
1386 PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
1387 if (INFO) {
1388 for (i = 0; i < params->key_len; i++)
1389 PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
1390 }
1391 }
1392 }
1393 break;
1394
1395 default:
1396 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
1397 s32Error = -ENOTSUPP;
1398
1399 }
1400
1401 return s32Error;
1402}
1403
1404/**
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001405 * @brief del_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001406 * @details Remove a key given the @mac_addr (%NULL for a group key)
1407 * and @key_index, return -ENOENT if the key doesn't exist.
1408 * @param[in]
1409 * @return int : Return 0 on Success
1410 * @author mdaftedar
1411 * @date 01 MAR 2012
1412 * @version 1.0
1413 */
Chaehyun Lim3044ba72015-09-14 12:24:06 +09001414static int del_key(struct wiphy *wiphy, struct net_device *netdev,
1415 u8 key_index,
1416 bool pairwise,
1417 const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001418{
Chaehyun Lim27268872015-09-15 14:06:13 +09001419 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001420 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421
1422 priv = wiphy_priv(wiphy);
1423
1424 /*BugID_5137*/
1425 /*delete saved keys, if any*/
1426 if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001427 g_ptk_keys_saved = false;
1428 g_gtk_keys_saved = false;
1429 g_wep_keys_saved = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001430
1431 /*Delete saved WEP keys params, if any*/
1432 if (g_key_wep_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001433 kfree(g_key_wep_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001434 g_key_wep_params.key = NULL;
1435 }
1436
1437 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1438
1439 #ifdef WILC_AP_EXTERNAL_MLME
1440 if ((priv->wilc_gtk[key_index]) != NULL) {
1441
1442 if (priv->wilc_gtk[key_index]->key != NULL) {
1443
Chaehyun Lim49188af2015-08-11 10:32:41 +09001444 kfree(priv->wilc_gtk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445 priv->wilc_gtk[key_index]->key = NULL;
1446 }
1447 if (priv->wilc_gtk[key_index]->seq) {
1448
Chaehyun Lim49188af2015-08-11 10:32:41 +09001449 kfree(priv->wilc_gtk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001450 priv->wilc_gtk[key_index]->seq = NULL;
1451 }
1452
Chaehyun Lim49188af2015-08-11 10:32:41 +09001453 kfree(priv->wilc_gtk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454 priv->wilc_gtk[key_index] = NULL;
1455
1456 }
1457
1458 if ((priv->wilc_ptk[key_index]) != NULL) {
1459
1460 if (priv->wilc_ptk[key_index]->key) {
1461
Chaehyun Lim49188af2015-08-11 10:32:41 +09001462 kfree(priv->wilc_ptk[key_index]->key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001463 priv->wilc_ptk[key_index]->key = NULL;
1464 }
1465 if (priv->wilc_ptk[key_index]->seq) {
1466
Chaehyun Lim49188af2015-08-11 10:32:41 +09001467 kfree(priv->wilc_ptk[key_index]->seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468 priv->wilc_ptk[key_index]->seq = NULL;
1469 }
Chaehyun Lim49188af2015-08-11 10:32:41 +09001470 kfree(priv->wilc_ptk[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471 priv->wilc_ptk[key_index] = NULL;
1472 }
1473 #endif
1474
1475 /*Delete saved PTK and GTK keys params, if any*/
1476 if (g_key_ptk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001477 kfree(g_key_ptk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001478 g_key_ptk_params.key = NULL;
1479 }
1480 if (g_key_ptk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001481 kfree(g_key_ptk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001482 g_key_ptk_params.seq = NULL;
1483 }
1484
1485 if (g_key_gtk_params.key != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001486 kfree(g_key_gtk_params.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001487 g_key_gtk_params.key = NULL;
1488 }
1489 if (g_key_gtk_params.seq != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001490 kfree(g_key_gtk_params.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491 g_key_gtk_params.seq = NULL;
1492 }
1493
1494 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
Dean Lee72ed4dc2015-06-12 14:11:44 +09001495 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001496 }
1497
1498 if (key_index >= 0 && key_index <= 3) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001499 memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001500 priv->WILC_WFI_wep_key_len[key_index] = 0;
1501
1502 PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
1503 host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
1504 } else {
1505 PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
1506 host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
1507 }
1508
1509 return s32Error;
1510}
1511
1512/**
Chaehyun Limf4893df2015-09-14 12:24:07 +09001513 * @brief get_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001514 * @details Get information about the key with the given parameters.
1515 * @mac_addr will be %NULL when requesting information for a group
1516 * key. All pointers given to the @callback function need not be valid
1517 * after it returns. This function should return an error if it is
1518 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1519 * @param[in]
1520 * @return int : Return 0 on Success
1521 * @author mdaftedar
1522 * @date 01 MAR 2012
1523 * @version 1.0
1524 */
Chaehyun Limf4893df2015-09-14 12:24:07 +09001525static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1526 bool pairwise,
1527 const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528{
1529
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001530 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001531
Chaehyun Lim27268872015-09-15 14:06:13 +09001532 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001533 struct key_params key_params;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001534 u32 i;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001535
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001536 priv = wiphy_priv(wiphy);
1537
1538
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 if (!pairwise)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540 {
1541 PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
1542
1543 key_params.key = priv->wilc_gtk[key_index]->key;
1544 key_params.cipher = priv->wilc_gtk[key_index]->cipher;
1545 key_params.key_len = priv->wilc_gtk[key_index]->key_len;
1546 key_params.seq = priv->wilc_gtk[key_index]->seq;
1547 key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
1548 if (INFO) {
1549 for (i = 0; i < key_params.key_len; i++)
1550 PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
1551 }
1552 } else {
1553 PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
1554
1555 key_params.key = priv->wilc_ptk[key_index]->key;
1556 key_params.cipher = priv->wilc_ptk[key_index]->cipher;
1557 key_params.key_len = priv->wilc_ptk[key_index]->key_len;
1558 key_params.seq = priv->wilc_ptk[key_index]->seq;
1559 key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
1560 }
1561
1562 callback(cookie, &key_params);
1563
1564 return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1565}
1566
1567/**
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001568 * @brief set_default_key
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001569 * @details Set the default management frame key on an interface
1570 * @param[in]
1571 * @return int : Return 0 on Success.
1572 * @author mdaftedar
1573 * @date 01 MAR 2012
1574 * @version 1.0
1575 */
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09001576static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
1577 bool unicast, bool multicast)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001578{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001579 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001580 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581
1582
1583 priv = wiphy_priv(wiphy);
1584
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301585 PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586
1587 if (key_index != priv->WILC_WFI_wep_default) {
1588
1589 host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
1590 }
1591
1592 return s32Error;
1593}
1594
1595/**
1596 * @brief WILC_WFI_dump_survey
1597 * @details Get site survey information
1598 * @param[in]
1599 * @return int : Return 0 on Success.
1600 * @author mdaftedar
1601 * @date 01 MAR 2012
1602 * @version 1.0
1603 */
1604static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
1605 int idx, struct survey_info *info)
1606{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001607 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001608
1609
1610 if (idx != 0) {
1611 s32Error = -ENOENT;
1612 PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
1613
1614 }
1615
1616 return s32Error;
1617}
1618
1619
1620/**
Chaehyun Limf06f5622015-09-14 12:24:18 +09001621 * @brief get_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001622 * @details Get station information for the station identified by @mac
1623 * @param[in] NONE
1624 * @return int : Return 0 on Success.
1625 * @author mdaftedar
1626 * @date 01 MAR 2012
1627 * @version 1.0
1628 */
1629
Chaehyun Limf06f5622015-09-14 12:24:18 +09001630static int get_station(struct wiphy *wiphy, struct net_device *dev,
1631 const u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001633 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09001634 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001635 perInterface_wlan_t *nic;
1636 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001637 u32 i = 0;
1638 u32 associatedsta = 0;
1639 u32 inactive_time = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001640 #endif
1641 priv = wiphy_priv(wiphy);
1642 nic = netdev_priv(dev);
1643
1644 #ifdef WILC_AP_EXTERNAL_MLME
1645 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
1646 PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
1647
1648 PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
1649
1650 for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
1651
1652 if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
1653 associatedsta = i;
1654 break;
1655 }
1656
1657 }
1658
1659 if (associatedsta == -1) {
1660 s32Error = -ENOENT;
1661 PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
1662
1663 return s32Error;
1664 }
1665
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667
1668 host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
1669 sinfo->inactive_time = 1000 * inactive_time;
1670 PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
1671
1672 }
1673 #endif
1674
1675 if (nic->iftype == STATION_MODE) {
1676 tstrStatistics strStatistics;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09001677
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001678 host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
1679
1680 /*
1681 * tony: 2013-11-13
1682 * tx_failed introduced more than
1683 * kernel version 3.0.0
1684 */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001685 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
Chandra S Gorentla62129902015-08-05 22:11:57 +05301686 BIT(NL80211_STA_INFO_RX_PACKETS) |
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687 BIT(NL80211_STA_INFO_TX_PACKETS) |
1688 BIT(NL80211_STA_INFO_TX_FAILED) |
1689 BIT(NL80211_STA_INFO_TX_BITRATE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690
1691 sinfo->signal = strStatistics.s8RSSI;
1692 sinfo->rx_packets = strStatistics.u32RxCount;
1693 sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694 sinfo->tx_failed = strStatistics.u32TxFailureCount;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001695 sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
1696
1697#ifdef TCP_ENHANCEMENTS
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301698 if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED))
Dean Lee72ed4dc2015-06-12 14:11:44 +09001699 Enable_TCP_ACK_Filter(true);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301700 else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001701 Enable_TCP_ACK_Filter(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001702#endif
1703
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001704 PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
1705 sinfo->tx_failed, sinfo->txrate.legacy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001706 }
1707 return s32Error;
1708}
1709
1710
1711/**
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001712 * @brief change_bss
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001713 * @details Modify parameters for a given BSS.
1714 * @param[in]
1715 * -use_cts_prot: Whether to use CTS protection
1716 * (0 = no, 1 = yes, -1 = do not change)
1717 * -use_short_preamble: Whether the use of short preambles is allowed
1718 * (0 = no, 1 = yes, -1 = do not change)
1719 * -use_short_slot_time: Whether the use of short slot time is allowed
1720 * (0 = no, 1 = yes, -1 = do not change)
1721 * -basic_rates: basic rates in IEEE 802.11 format
1722 * (or NULL for no change)
1723 * -basic_rates_len: number of basic rates
1724 * -ap_isolate: do not forward packets between connected stations
1725 * -ht_opmode: HT Operation mode
1726 * (u16 = opmode, -1 = do not change)
1727 * @return int : Return 0 on Success.
1728 * @author mdaftedar
1729 * @date 01 MAR 2012
1730 * @version 1.0
1731 */
Chaehyun Lima5f7db62015-09-14 12:24:20 +09001732static int change_bss(struct wiphy *wiphy, struct net_device *dev,
1733 struct bss_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001734{
1735 PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
1736 return 0;
1737}
1738
1739/**
1740 * @brief WILC_WFI_auth
1741 * @details Request to authenticate with the specified peer
1742 * @param[in]
1743 * @return int : Return 0 on Success.
1744 * @author mdaftedar
1745 * @date 01 MAR 2012
1746 * @version 1.0
1747 */
1748static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
1749 struct cfg80211_auth_request *req)
1750{
1751 PRINT_D(CFG80211_DBG, "In Authentication Function\n");
1752 return 0;
1753}
1754
1755/**
1756 * @brief WILC_WFI_assoc
1757 * @details Request to (re)associate with the specified peer
1758 * @param[in]
1759 * @return int : Return 0 on Success.
1760 * @author mdaftedar
1761 * @date 01 MAR 2012
1762 * @version 1.0
1763 */
1764static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
1765 struct cfg80211_assoc_request *req)
1766{
1767 PRINT_D(CFG80211_DBG, "In Association Function\n");
1768 return 0;
1769}
1770
1771/**
1772 * @brief WILC_WFI_deauth
1773 * @details Request to deauthenticate from the specified peer
1774 * @param[in]
1775 * @return int : Return 0 on Success.
1776 * @author mdaftedar
1777 * @date 01 MAR 2012
1778 * @version 1.0
1779 */
1780static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
1781 struct cfg80211_deauth_request *req, void *cookie)
1782{
1783 PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
1784 return 0;
1785}
1786
1787/**
1788 * @brief WILC_WFI_disassoc
1789 * @details Request to disassociate from the specified peer
1790 * @param[in]
1791 * @return int : Return 0 on Success
1792 * @author mdaftedar
1793 * @date 01 MAR 2012
1794 * @version 1.0
1795 */
1796static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
1797 struct cfg80211_disassoc_request *req, void *cookie)
1798{
1799 PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
1800 return 0;
1801}
1802
1803/**
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001804 * @brief set_wiphy_params
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805 * @details Notify that wiphy parameters have changed;
1806 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1807 * have changed.
1808 * @return int : Return 0 on Success
1809 * @author mdaftedar
1810 * @date 01 MAR 2012
1811 * @version 1.0
1812 */
Chaehyun Lima76b63e2015-09-14 12:24:21 +09001813static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001815 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816 tstrCfgParamVal pstrCfgParamVal;
Chaehyun Lim27268872015-09-15 14:06:13 +09001817 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001818
1819 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820
1821 pstrCfgParamVal.u32SetCfgFlag = 0;
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05301822 PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001823
1824 if (changed & WIPHY_PARAM_RETRY_SHORT) {
1825 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1826 priv->dev->ieee80211_ptr->wiphy->retry_short);
1827 pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
1828 pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
1829 }
1830 if (changed & WIPHY_PARAM_RETRY_LONG) {
1831
1832 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
1833 pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
1834 pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
1835
1836 }
1837 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1838 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
1839 pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
1840 pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
1841
1842 }
1843
1844 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1845 PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
1846
1847 pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
1848 pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
1849
1850 }
1851
1852 PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
1853 s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
1854 if (s32Error)
1855 PRINT_ER("Error in setting WIPHY PARAMS\n");
1856
1857
1858 return s32Error;
1859}
Arnd Bergmanne5af0562015-05-29 22:52:12 +02001860
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001861/**
1862 * @brief WILC_WFI_set_bitrate_mask
1863 * @details set the bitrate mask configuration
1864 * @param[in]
1865 * @return int : Return 0 on Success
1866 * @author mdaftedar
1867 * @date 01 MAR 2012
1868 * @version 1.0
1869 */
1870static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
1871 struct net_device *dev, const u8 *peer,
1872 const struct cfg80211_bitrate_mask *mask)
1873{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001874 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875
1876 PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001877 return s32Error;
1878
1879}
1880
1881/**
Chaehyun Lim4d466572015-09-14 12:24:22 +09001882 * @brief set_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001883 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1884 * devices running firmwares capable of generating the (re) association
1885 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1886 * @param[in]
1887 * @return int : Return 0 on Success
1888 * @author mdaftedar
1889 * @date 01 MAR 2012
1890 * @version 1.0
1891 */
Chaehyun Lim4d466572015-09-14 12:24:22 +09001892static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1893 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001894{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001895 u32 i;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001896 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001897 u8 flag = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001898
Chaehyun Lim27268872015-09-15 14:06:13 +09001899 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001900
1901 PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
1902
1903
1904 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001905 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001906 ETH_ALEN)) {
1907 /*If bssid already exists and pmkid value needs to reset*/
1908 flag = PMKID_FOUND;
1909 PRINT_D(CFG80211_DBG, "PMKID already exists\n");
1910 break;
1911 }
1912 }
1913 if (i < WILC_MAX_NUM_PMKIDS) {
1914 PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001915 memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001917 memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001918 PMKID_LEN);
1919 if (!(flag == PMKID_FOUND))
1920 priv->pmkid_list.numpmkid++;
1921 } else {
1922 PRINT_ER("Invalid PMKID index\n");
1923 s32Error = -EINVAL;
1924 }
1925
1926 if (!s32Error) {
1927 PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
1928 s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
1929 }
1930 return s32Error;
1931}
1932
1933/**
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001934 * @brief del_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001935 * @details Delete a cached PMKID.
1936 * @param[in]
1937 * @return int : Return 0 on Success
1938 * @author mdaftedar
1939 * @date 01 MAR 2012
1940 * @version 1.0
1941 */
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09001942static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
1943 struct cfg80211_pmksa *pmksa)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944{
1945
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001946 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001947 u8 flag = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001948 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001949
Chaehyun Lim27268872015-09-15 14:06:13 +09001950 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001951
1952 PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
1953
1954 for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001955 if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956 ETH_ALEN)) {
1957 /*If bssid is found, reset the values*/
1958 PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001959 memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001960 flag = PMKID_FOUND;
1961 break;
1962 }
1963 }
1964
1965 if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
1966 for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001967 memcpy(priv->pmkid_list.pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001968 priv->pmkid_list.pmkidlist[i + 1].bssid,
1969 ETH_ALEN);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001970 memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 priv->pmkid_list.pmkidlist[i].pmkid,
1972 PMKID_LEN);
1973 }
1974 priv->pmkid_list.numpmkid--;
1975 } else {
1976 s32Error = -EINVAL;
1977 }
1978
1979 return s32Error;
1980}
1981
1982/**
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001983 * @brief flush_pmksa
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984 * @details Flush all cached PMKIDs.
1985 * @param[in]
1986 * @return int : Return 0 on Success
1987 * @author mdaftedar
1988 * @date 01 MAR 2012
1989 * @version 1.0
1990 */
Chaehyun Limb33c39b2015-09-14 12:24:24 +09001991static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992{
Chaehyun Lim27268872015-09-15 14:06:13 +09001993 struct wilc_priv *priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001994
1995 PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
1996
1997 /*Get cashed Pmkids and set all with zeros*/
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001998 memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999
2000 return 0;
2001}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002
2003#ifdef WILC_P2P
2004
2005/**
2006 * @brief WILC_WFI_CfgParseRxAction
2007 * @details Function parses the received frames and modifies the following attributes:
2008 * -GO Intent
2009 * -Channel list
2010 * -Operating Channel
2011 *
2012 * @param[in] u8* Buffer, u32 length
2013 * @return NONE.
2014 * @author mdaftedar
2015 * @date 12 DEC 2012
2016 * @version
2017 */
2018
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002019void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002020{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002021 u32 index = 0;
2022 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002023
2024 /*BugID_5460*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002025 u8 op_channel_attr_index = 0;
2026 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002027
2028 while (index < len) {
2029 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030 buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002031 }
2032
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302033 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002034 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302035 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002037 index += buf[index + 1] + 3; /* ID,Length byte */
2038 }
2039
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002040 if (u8WLANChannel != INVALID_CHANNEL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041 {
2042 /*Modify channel list attribute*/
2043 if (channel_list_attr_index) {
2044 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2045 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2046 if (buf[i] == 0x51) {
2047 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2048 buf[j] = u8WLANChannel;
2049 }
2050 break;
2051 }
2052 }
2053 }
2054 /*Modify operating channel attribute*/
2055 if (op_channel_attr_index) {
2056 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2057 buf[op_channel_attr_index + 6] = 0x51;
2058 buf[op_channel_attr_index + 7] = u8WLANChannel;
2059 }
2060 }
2061}
2062
2063/**
2064 * @brief WILC_WFI_CfgParseTxAction
2065 * @details Function parses the transmitted action frames and modifies the
2066 * GO Intent attribute
2067 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
2068 * @return NONE.
2069 * @author mdaftedar
2070 * @date 12 DEC 2012
2071 * @version
2072 */
Dean Lee72ed4dc2015-06-12 14:11:44 +09002073void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002074{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002075 u32 index = 0;
2076 u32 i = 0, j = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002077
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002078 u8 op_channel_attr_index = 0;
2079 u8 channel_list_attr_index = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002080
2081 while (index < len) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 if (buf[index] == GO_INTENT_ATTR_ID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083 buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084
2085 break;
2086 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002087
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302088 if (buf[index] == CHANLIST_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002089 channel_list_attr_index = index;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302090 else if (buf[index] == OPERCHAN_ATTR_ID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091 op_channel_attr_index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002092 index += buf[index + 1] + 3; /* ID,Length byte */
2093 }
2094
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095 if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002096 {
2097 /*Modify channel list attribute*/
2098 if (channel_list_attr_index) {
2099 PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
2100 for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
2101 if (buf[i] == 0x51) {
2102 for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
2103 buf[j] = u8WLANChannel;
2104 }
2105 break;
2106 }
2107 }
2108 }
2109 /*Modify operating channel attribute*/
2110 if (op_channel_attr_index) {
2111 PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
2112 buf[op_channel_attr_index + 6] = 0x51;
2113 buf[op_channel_attr_index + 7] = u8WLANChannel;
2114 }
2115 }
2116}
2117
2118/* @brief WILC_WFI_p2p_rx
2119 * @details
2120 * @param[in]
2121 *
2122 * @return None
2123 * @author Mai Daftedar
2124 * @date 2 JUN 2013
2125 * @version 1.0
2126 */
2127
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09002128void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002129{
2130
Chaehyun Lim27268872015-09-15 14:06:13 +09002131 struct wilc_priv *priv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002132 u32 header, pkt_offset;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002134 u32 i = 0;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002135 s32 s32Freq;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002136
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002137 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
2138 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2139
2140 /* Get WILC header */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002141 memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002142
2143 /* The packet offset field conain info about what type of managment frame */
2144 /* we are dealing with and ack status */
2145 pkt_offset = GET_PKT_OFFSET(header);
2146
2147 if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
2148 if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
2149 PRINT_D(GENERIC_DBG, "Probe response ACK\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002150 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002151 return;
2152 } else {
2153 if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
2154 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],
2155 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002156 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002157 } else {
2158 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],
2159 buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160 cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002161 }
2162 return;
2163 }
2164 } else {
2165
2166 PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
2167
2168 /*BugID_5442*/
2169 /*Upper layer is informed that the frame is received on this freq*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170 s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171
2172 if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
2173 PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
2174
Dean Lee72ed4dc2015-06-12 14:11:44 +09002175 if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176 PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
2177 return;
2178 }
2179 if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2180
2181 switch (buff[ACTION_SUBTYPE_ID]) {
2182 case GAS_INTIAL_REQ:
2183 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
2184 break;
2185
2186 case GAS_INTIAL_RSP:
2187 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
2188 break;
2189
2190 case PUBLIC_ACT_VENDORSPEC:
2191 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2192 * 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 +09002193 if (!memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002194 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2195 if (!bWilc_ie) {
2196 for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002197 if (!memcmp(u8P2P_vendorspec, &buff[i], 6)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002198 u8P2Precvrandom = buff[i + 6];
Dean Lee72ed4dc2015-06-12 14:11:44 +09002199 bWilc_ie = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002200 PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
2201 break;
2202 }
2203 }
2204 }
2205 }
2206 if (u8P2Plocalrandom > u8P2Precvrandom) {
2207 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2208 || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2209 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002210 if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buff[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211 WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
2212 break;
2213 }
2214 }
2215 }
2216 } else
2217 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2218 }
2219
2220
2221 if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
2222 PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
2223 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225 return;
2226 }
2227 break;
2228
2229 default:
2230 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
2231 break;
2232 }
2233 }
2234 }
2235
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236 cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 }
2238}
2239
2240/**
2241 * @brief WILC_WFI_mgmt_tx_complete
2242 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2243 * @param[in] priv
2244 * transmitting status
2245 * @return None
2246 * @author Amr Abdelmoghny
2247 * @date 20 MAY 2013
2248 * @version 1.0
2249 */
2250static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
2251{
2252 struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
2253
2254
2255 kfree(pv_data->buff);
2256 kfree(pv_data);
2257}
2258
2259/**
2260 * @brief WILC_WFI_RemainOnChannelReady
2261 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2262 * @param
2263 * @return none
2264 * @author Amr abdelmoghny
2265 * @date 9 JUNE 2013
2266 * @version
2267 */
2268
2269static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
2270{
Chaehyun Lim27268872015-09-15 14:06:13 +09002271 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002272
Chaehyun Lim27268872015-09-15 14:06:13 +09002273 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002274
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302275 PRINT_D(HOSTINF_DBG, "Remain on channel ready\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276
Dean Lee72ed4dc2015-06-12 14:11:44 +09002277 priv->bInP2PlistenState = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002279 cfg80211_ready_on_channel(priv->wdev,
2280 priv->strRemainOnChanParams.u64ListenCookie,
2281 priv->strRemainOnChanParams.pstrListenChan,
2282 priv->strRemainOnChanParams.u32ListenDuration,
2283 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002284}
2285
2286/**
2287 * @brief WILC_WFI_RemainOnChannelExpired
2288 * @details Callback function, called on expiration of remain-on-channel duration
2289 * @param
2290 * @return none
2291 * @author Amr abdelmoghny
2292 * @date 15 MAY 2013
2293 * @version
2294 */
2295
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002296static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002297{
Chaehyun Lim27268872015-09-15 14:06:13 +09002298 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002299
Chaehyun Lim27268872015-09-15 14:06:13 +09002300 priv = (struct wilc_priv *)pUserVoid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301
2302 /*BugID_5477*/
2303 if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05302304 PRINT_D(GENERIC_DBG, "Remain on channel expired\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002305
Dean Lee72ed4dc2015-06-12 14:11:44 +09002306 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002307
2308 /*Inform wpas of remain-on-channel expiration*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309 cfg80211_remain_on_channel_expired(priv->wdev,
2310 priv->strRemainOnChanParams.u64ListenCookie,
2311 priv->strRemainOnChanParams.pstrListenChan,
2312 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002313 } else {
2314 PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2315 , priv->strRemainOnChanParams.u32ListenSessionID);
2316 }
2317}
2318
2319
2320/**
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002321 * @brief remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002322 * @details Request the driver to remain awake on the specified
2323 * channel for the specified duration to complete an off-channel
2324 * operation (e.g., public action frame exchange). When the driver is
2325 * ready on the requested channel, it must indicate this with an event
2326 * notification by calling cfg80211_ready_on_channel().
2327 * @param[in]
2328 * @return int : Return 0 on Success
2329 * @author mdaftedar
2330 * @date 01 MAR 2012
2331 * @version 1.0
2332 */
Chaehyun Lim6d19d692015-09-14 12:24:25 +09002333static int remain_on_channel(struct wiphy *wiphy,
2334 struct wireless_dev *wdev,
2335 struct ieee80211_channel *chan,
2336 unsigned int duration, u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002337{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002338 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002339 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002340
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002341 priv = wiphy_priv(wiphy);
2342
2343 PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
2344
2345 /*BugID_4800: if in AP mode, return.*/
2346 /*This check is to handle the situation when user*/
2347 /*requests "create group" during a running scan*/
2348
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349 if (wdev->iftype == NL80211_IFTYPE_AP) {
2350 PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
2351 return s32Error;
2352 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002353
2354 u8CurrChannel = chan->hw_value;
2355
2356 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2357 priv->strRemainOnChanParams.pstrListenChan = chan;
2358 priv->strRemainOnChanParams.u64ListenCookie = *cookie;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002359 priv->strRemainOnChanParams.u32ListenDuration = duration;
2360 priv->strRemainOnChanParams.u32ListenSessionID++;
2361
2362 s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
2363 , priv->strRemainOnChanParams.u32ListenSessionID
2364 , duration
2365 , chan->hw_value
2366 , WILC_WFI_RemainOnChannelExpired
2367 , WILC_WFI_RemainOnChannelReady
2368 , (void *)priv);
2369
2370 return s32Error;
2371}
2372
2373/**
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002374 * @brief cancel_remain_on_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002375 * @details Cancel an on-going remain-on-channel operation.
2376 * This allows the operation to be terminated prior to timeout based on
2377 * the duration value.
2378 * @param[in] struct wiphy *wiphy,
2379 * @param[in] struct net_device *dev
2380 * @param[in] u64 cookie,
2381 * @return int : Return 0 on Success
2382 * @author mdaftedar
2383 * @date 01 MAR 2012
2384 * @version 1.0
2385 */
Chaehyun Lim1dd54402015-09-14 12:24:26 +09002386static int cancel_remain_on_channel(struct wiphy *wiphy,
2387 struct wireless_dev *wdev,
2388 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002389{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002390 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002391 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002392
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393 priv = wiphy_priv(wiphy);
2394
2395 PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
2396
2397 s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
2398 return s32Error;
2399}
2400/**
2401 * @brief WILC_WFI_add_wilcvendorspec
2402 * @details Adding WILC information elemet to allow two WILC devices to
2403 * identify each other and connect
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002404 * @param[in] u8 * buf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405 * @return void
2406 * @author mdaftedar
2407 * @date 01 JAN 2014
2408 * @version 1.0
2409 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002410void WILC_WFI_add_wilcvendorspec(u8 *buff)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002411{
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002412 memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002413}
2414/**
2415 * @brief WILC_WFI_mgmt_tx_frame
2416 * @details
2417 *
2418 * @param[in]
2419 * @return NONE.
2420 * @author mdaftedar
2421 * @date 01 JUL 2012
2422 * @version
2423 */
2424extern linux_wlan_t *g_linux_wlan;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002425extern bool bEnablePS;
Chaehyun Lim12a26a32015-09-14 12:24:28 +09002426int mgmt_tx(struct wiphy *wiphy,
2427 struct wireless_dev *wdev,
2428 struct cfg80211_mgmt_tx_params *params,
2429 u64 *cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002430{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002431 struct ieee80211_channel *chan = params->chan;
2432 unsigned int wait = params->wait;
2433 const u8 *buf = params->buf;
2434 size_t len = params->len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002435 const struct ieee80211_mgmt *mgmt;
2436 struct p2p_mgmt_data *mgmt_tx;
Chaehyun Lim27268872015-09-15 14:06:13 +09002437 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002438 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002440 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002441 perInterface_wlan_t *nic;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002442 u32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002443
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002444 nic = netdev_priv(wdev->netdev);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002445 priv = wiphy_priv(wiphy);
2446 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2447
2448 *cookie = (unsigned long)buf;
2449 priv->u64tx_cookie = *cookie;
2450 mgmt = (const struct ieee80211_mgmt *) buf;
2451
2452 if (ieee80211_is_mgmt(mgmt->frame_control)) {
2453
2454 /*mgmt frame allocation*/
Glen Leef3052582015-09-10 12:03:04 +09002455 mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002456 if (mgmt_tx == NULL) {
2457 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2458 return WILC_FAIL;
2459 }
Glen Leef3052582015-09-10 12:03:04 +09002460 mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461 if (mgmt_tx->buff == NULL) {
2462 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
Tony Chof638dd32015-09-07 19:09:31 +09002463 kfree(mgmt_tx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464 return WILC_FAIL;
2465 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002466 memcpy(mgmt_tx->buff, buf, len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002467 mgmt_tx->size = len;
2468
2469
2470 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
2471 PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
2472 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2473 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2474 /*Save the current channel after we tune to it*/
2475 u8CurrChannel = chan->hw_value;
2476 } else if (ieee80211_is_action(mgmt->frame_control)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002477 PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478
2479
2480 /*BugID_4847*/
2481 if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
2482 /*BugID_4847*/
2483 /*Only set the channel, if not a negotiation confirmation frame
2484 * (If Negotiation confirmation frame, force it
2485 * to be transmitted on the same negotiation channel)*/
2486
2487 if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
2488 buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
2489 PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
2490 host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
2491 /*Save the current channel after we tune to it*/
2492 u8CurrChannel = chan->hw_value;
2493 }
2494 switch (buf[ACTION_SUBTYPE_ID]) {
2495 case GAS_INTIAL_REQ:
2496 {
2497 PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
2498 break;
2499 }
2500
2501 case GAS_INTIAL_RSP:
2502 {
2503 PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
2504 break;
2505 }
2506
2507 case PUBLIC_ACT_VENDORSPEC:
2508 {
2509 /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
2510 * 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 +09002511 if (!memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002512 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2513 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
2514 if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
2515 get_random_bytes(&u8P2Plocalrandom, 1);
2516 /*Increment the number to prevent if its 0*/
2517 u8P2Plocalrandom++;
2518 }
2519 }
2520
2521 if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
2522 || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
2523 if (u8P2Plocalrandom > u8P2Precvrandom) {
2524 PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2525
2526 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2527 for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002528 if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(u8P2P_oui, &buf[i + 2], 4))) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
Dean Lee72ed4dc2015-06-12 14:11:44 +09002530 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002531
2532 /*BugID_5460*/
2533 /*If using supplicant go intent, no need at all*/
2534 /*to parse transmitted negotiation frames*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535 else
Dean Lee72ed4dc2015-06-12 14:11:44 +09002536 WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537 break;
2538 }
2539 }
2540
2541 if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
2542 WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
2543 mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
2544 mgmt_tx->size = buf_len;
2545 }
2546 } else
2547 PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
2548 }
2549
2550 } else {
2551 PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
2552 }
2553
2554 break;
2555 }
2556
2557 default:
2558 {
2559 PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
2560 break;
2561 }
2562 }
2563
2564 }
2565
2566 PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
2567 pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
2568
2569 PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
2570
2571 }
2572
2573 g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
2574 } else {
2575 PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
2576 }
2577 return s32Error;
2578}
2579
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09002580int mgmt_tx_cancel_wait(struct wiphy *wiphy,
2581 struct wireless_dev *wdev,
2582 u64 cookie)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583{
Chaehyun Lim27268872015-09-15 14:06:13 +09002584 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585 tstrWILC_WFIDrv *pstrWFIDrv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002586
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002587 priv = wiphy_priv(wiphy);
2588 pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
2589
2590
2591 PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
2592 pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
2593
Dean Lee72ed4dc2015-06-12 14:11:44 +09002594 if (priv->bInP2PlistenState == false) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002595 /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
2596 * considers the driver falsely that it is in Listen state */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002597 cfg80211_remain_on_channel_expired(priv->wdev,
2598 priv->strRemainOnChanParams.u64ListenCookie,
2599 priv->strRemainOnChanParams.pstrListenChan,
2600 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601 }
2602
2603 return 0;
2604}
2605
2606/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607 * @brief WILC_WFI_frame_register
2608 * @details Notify driver that a management frame type was
2609 * registered. Note that this callback may not sleep, and cannot run
2610 * concurrently with itself.
2611 * @param[in]
2612 * @return NONE.
2613 * @author mdaftedar
2614 * @date 01 JUL 2012
2615 * @version
2616 */
2617void WILC_WFI_frame_register(struct wiphy *wiphy,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 struct wireless_dev *wdev,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619 u16 frame_type, bool reg)
2620{
2621
Chaehyun Lim27268872015-09-15 14:06:13 +09002622 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002623 perInterface_wlan_t *nic;
2624
2625
2626 priv = wiphy_priv(wiphy);
2627 nic = netdev_priv(priv->wdev->netdev);
2628
2629
2630
2631 /*BugID_5137*/
2632 if (!frame_type)
2633 return;
2634
2635 PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
2636 switch (frame_type) {
2637 case PROBE_REQ:
2638 {
2639 nic->g_struct_frame_reg[0].frame_type = frame_type;
2640 nic->g_struct_frame_reg[0].reg = reg;
2641 }
2642 break;
2643
2644 case ACTION:
2645 {
2646 nic->g_struct_frame_reg[1].frame_type = frame_type;
2647 nic->g_struct_frame_reg[1].reg = reg;
2648 }
2649 break;
2650
2651 default:
2652 {
2653 break;
2654 }
2655
2656 }
2657 /*If mac is closed, then return*/
2658 if (!g_linux_wlan->wilc1000_initialized) {
2659 PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
2660 return;
2661 }
2662 host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
2663
2664
2665}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002666#endif /*WILC_P2P*/
2667
2668/**
2669 * @brief WILC_WFI_set_cqm_rssi_config
2670 * @details Configure connection quality monitor RSSI threshold.
2671 * @param[in] struct wiphy *wiphy:
2672 * @param[in] struct net_device *dev:
2673 * @param[in] s32 rssi_thold:
2674 * @param[in] u32 rssi_hyst:
2675 * @return int : Return 0 on Success
2676 * @author mdaftedar
2677 * @date 01 MAR 2012
2678 * @version 1.0
2679 */
2680static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
2681 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
2682{
2683 PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
2684 return 0;
2685
2686}
2687/**
Chaehyun Limbdb63382015-09-14 12:24:19 +09002688 * @brief dump_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002689 * @details Configure connection quality monitor RSSI threshold.
2690 * @param[in] struct wiphy *wiphy:
2691 * @param[in] struct net_device *dev
2692 * @param[in] int idx
2693 * @param[in] u8 *mac
2694 * @param[in] struct station_info *sinfo
2695 * @return int : Return 0 on Success
2696 * @author mdaftedar
2697 * @date 01 MAR 2012
2698 * @version 1.0
2699 */
Chaehyun Limbdb63382015-09-14 12:24:19 +09002700static int dump_station(struct wiphy *wiphy, struct net_device *dev,
2701 int idx, u8 *mac, struct station_info *sinfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002702{
Chaehyun Lim27268872015-09-15 14:06:13 +09002703 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002704
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002705 PRINT_D(CFG80211_DBG, "Dumping station information\n");
2706
2707 if (idx != 0)
2708 return -ENOENT;
2709
2710 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002711
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713
2714 host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
2715
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002716 return 0;
2717
2718}
2719
2720
2721/**
2722 * @brief WILC_WFI_set_power_mgmt
2723 * @details
2724 * @param[in]
2725 * @return int : Return 0 on Success.
2726 * @author mdaftedar
2727 * @date 01 JUL 2012
2728 * @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
2729 */
2730int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2731 bool enabled, int timeout)
2732{
Chaehyun Lim27268872015-09-15 14:06:13 +09002733 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09002734
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002735 PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
2736
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002737 if (wiphy == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002738 return -ENOENT;
2739
2740 priv = wiphy_priv(wiphy);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002741 if (priv->hWILCWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 PRINT_ER("Driver is NULL\n");
2743 return -EIO;
2744 }
2745
Abdul Hussain5a66bf22015-06-16 09:44:06 +00002746 if (bEnablePS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747 host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
2748
2749
2750 return WILC_SUCCESS;
2751
2752}
2753#ifdef WILC_AP_EXTERNAL_MLME
2754/**
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002755 * @brief change_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002756 * @details Change type/configuration of virtual interface,
2757 * keep the struct wireless_dev's iftype updated.
2758 * @param[in] NONE
2759 * @return int : Return 0 on Success.
2760 * @author mdaftedar
2761 * @date 01 MAR 2012
2762 * @version 1.0
2763 */
2764void wilc1000_wlan_deinit(linux_wlan_t *nic);
2765int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
2766
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09002767static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
2768 enum nl80211_iftype type, u32 *flags, struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002769{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002770 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09002771 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 perInterface_wlan_t *nic;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002773 u8 interface_type;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002774 u16 TID = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002775 #ifdef WILC_P2P
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002776 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777 #endif
2778
2779 nic = netdev_priv(dev);
2780 priv = wiphy_priv(wiphy);
2781
2782 PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
2783 PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
2784 u8P2Plocalrandom = 0x01;
2785 u8P2Precvrandom = 0x00;
2786
Dean Lee72ed4dc2015-06-12 14:11:44 +09002787 bWilc_ie = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002788
2789 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09002790 g_obtainingIP = false;
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002791 del_timer(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002792 PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
2793 #endif
2794 /*BugID_5137*/
2795 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2796 if (g_ptk_keys_saved && g_gtk_keys_saved) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002797 Set_machw_change_vir_if(true);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002798 }
2799
2800 switch (type) {
2801 case NL80211_IFTYPE_STATION:
2802 connecting = 0;
2803 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002804
2805 /* send delba over wlan interface */
2806
2807
2808 dev->ieee80211_ptr->iftype = type;
2809 priv->wdev->iftype = type;
2810 nic->monitor_flag = 0;
2811 nic->iftype = STATION_MODE;
2812
2813 /*Remove the enteries of the previously connected clients*/
2814 memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002815 #ifdef WILC_P2P
2816 interface_type = nic->iftype;
2817 nic->iftype = STATION_MODE;
2818
2819 if (g_linux_wlan->wilc1000_initialized) {
2820 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2821 /* ensure that the message Q is empty */
2822 host_int_wait_msg_queue_idle();
2823
2824 /*BugID_5213*/
2825 /*Eliminate host interface blocking state*/
Greg Kroah-Hartman8990d852015-09-03 20:07:58 -07002826 up(&g_linux_wlan->cfg_event);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002827
2828 wilc1000_wlan_deinit(g_linux_wlan);
2829 wilc1000_wlan_init(dev, nic);
2830 g_wilc_initialized = 1;
2831 nic->iftype = interface_type;
2832
2833 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2834 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002835 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2837 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2838
2839 /*Add saved WEP keys, if any*/
2840 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002841 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002843 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844 g_key_wep_params.key,
2845 g_key_wep_params.key_len,
2846 g_key_wep_params.key_idx);
2847 }
2848
2849 /*No matter the driver handler passed here, it will be overwriiten*/
2850 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2851 host_int_flush_join_req(priv->hWILCWFIDrv);
2852
2853 /*Add saved PTK and GTK keys, if any*/
2854 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2855 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2856 g_key_ptk_params.key[1],
2857 g_key_ptk_params.key[2]);
2858 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2859 g_key_gtk_params.key[1],
2860 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002861 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2862 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2863 g_add_ptk_key_params.key_idx,
2864 g_add_ptk_key_params.pairwise,
2865 g_add_ptk_key_params.mac_addr,
2866 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002867
Chaehyun Lim953d4172015-09-14 12:24:05 +09002868 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2869 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2870 g_add_gtk_key_params.key_idx,
2871 g_add_gtk_key_params.pairwise,
2872 g_add_gtk_key_params.mac_addr,
2873 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874 }
2875
2876 /*BugID_4847: registered frames in firmware are now*/
2877 /*lost due to mac close. So re-register those frames*/
2878 if (g_linux_wlan->wilc1000_initialized) {
2879 for (i = 0; i < num_reg_frame; i++) {
2880 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2881 nic->g_struct_frame_reg[i].reg);
2882 host_int_frame_register(priv->hWILCWFIDrv,
2883 nic->g_struct_frame_reg[i].frame_type,
2884 nic->g_struct_frame_reg[i].reg);
2885 }
2886 }
2887
Dean Lee72ed4dc2015-06-12 14:11:44 +09002888 bEnablePS = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889 host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
2890 }
2891 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 break;
2893
2894 case NL80211_IFTYPE_P2P_CLIENT:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002895 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
2897 connecting = 0;
2898 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899
2900 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
2901
2902 dev->ieee80211_ptr->iftype = type;
2903 priv->wdev->iftype = type;
2904 nic->monitor_flag = 0;
2905
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002906 #ifdef WILC_P2P
2907
2908 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2909 nic->iftype = CLIENT_MODE;
2910
2911
2912 if (g_linux_wlan->wilc1000_initialized) {
2913 /* ensure that the message Q is empty */
2914 host_int_wait_msg_queue_idle();
2915
2916 wilc1000_wlan_deinit(g_linux_wlan);
2917 wilc1000_wlan_init(dev, nic);
2918 g_wilc_initialized = 1;
2919
2920 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09002921 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002922 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
2923 host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
2924
2925 /*Add saved WEP keys, if any*/
2926 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09002927 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09002929 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002930 g_key_wep_params.key,
2931 g_key_wep_params.key_len,
2932 g_key_wep_params.key_idx);
2933 }
2934
2935 /*No matter the driver handler passed here, it will be overwriiten*/
2936 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2937 host_int_flush_join_req(priv->hWILCWFIDrv);
2938
2939 /*Add saved PTK and GTK keys, if any*/
2940 if (g_ptk_keys_saved && g_gtk_keys_saved) {
2941 PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
2942 g_key_ptk_params.key[1],
2943 g_key_ptk_params.key[2]);
2944 PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
2945 g_key_gtk_params.key[1],
2946 g_key_gtk_params.key[2]);
Chaehyun Lim953d4172015-09-14 12:24:05 +09002947 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2948 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2949 g_add_ptk_key_params.key_idx,
2950 g_add_ptk_key_params.pairwise,
2951 g_add_ptk_key_params.mac_addr,
2952 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002953
Chaehyun Lim953d4172015-09-14 12:24:05 +09002954 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
2955 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
2956 g_add_gtk_key_params.key_idx,
2957 g_add_gtk_key_params.pairwise,
2958 g_add_gtk_key_params.mac_addr,
2959 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960 }
2961
2962 /*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 +09002963 refresh_scan(priv, 1, true);
2964 Set_machw_change_vir_if(false);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965
2966 /*BugID_4847: registered frames in firmware are now lost
2967 * due to mac close. So re-register those frames */
2968 if (g_linux_wlan->wilc1000_initialized) {
2969 for (i = 0; i < num_reg_frame; i++) {
2970 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
2971 nic->g_struct_frame_reg[i].reg);
2972 host_int_frame_register(priv->hWILCWFIDrv,
2973 nic->g_struct_frame_reg[i].frame_type,
2974 nic->g_struct_frame_reg[i].reg);
2975 }
2976 }
2977 }
2978 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979 break;
2980
2981 case NL80211_IFTYPE_AP:
Dean Lee72ed4dc2015-06-12 14:11:44 +09002982 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002984 dev->ieee80211_ptr->iftype = type;
2985 priv->wdev->iftype = type;
2986 nic->iftype = AP_MODE;
Johnny Kim8a143302015-06-10 17:06:46 +09002987 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002988
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989 PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
2990 linux_wlan_get_firmware(nic);
2991 #ifdef WILC_P2P
2992 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2993 if (g_linux_wlan->wilc1000_initialized) {
2994 nic->iftype = AP_MODE;
2995 g_linux_wlan->wilc1000_initialized = 1;
2996 mac_close(dev);
2997 mac_open(dev);
2998
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999 /*BugID_4847: registered frames in firmware are now lost
3000 * due to mac close. So re-register those frames */
3001 for (i = 0; i < num_reg_frame; i++) {
3002 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3003 nic->g_struct_frame_reg[i].reg);
3004 host_int_frame_register(priv->hWILCWFIDrv,
3005 nic->g_struct_frame_reg[i].frame_type,
3006 nic->g_struct_frame_reg[i].reg);
3007 }
3008 }
3009 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010 break;
3011
3012 case NL80211_IFTYPE_P2P_GO:
3013 PRINT_D(GENERIC_DBG, "start duringIP timer\n");
3014
3015 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +09003016 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003017 mod_timer(&hDuringIpTimer, jiffies + msecs_to_jiffies(duringIP_TIME));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018 #endif
3019 host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
3020 /*BugID_5222*/
3021 /*Delete block ack has to be the latest config packet*/
3022 /*sent before downloading new FW. This is because it blocks on*/
3023 /*hWaitResponse semaphore, which allows previous config*/
3024 /*packets to actually take action on old FW*/
3025 host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
Dean Lee72ed4dc2015-06-12 14:11:44 +09003026 bEnablePS = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027 PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003028 dev->ieee80211_ptr->iftype = type;
3029 priv->wdev->iftype = type;
3030
Johnny Kim8a143302015-06-10 17:06:46 +09003031 PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003032
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 #ifdef WILC_P2P
3034 PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
3035
3036
3037 #if 1
3038 nic->iftype = GO_MODE;
3039
3040 /* ensure that the message Q is empty */
3041 host_int_wait_msg_queue_idle();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003042 wilc1000_wlan_deinit(g_linux_wlan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 wilc1000_wlan_init(dev, nic);
3044 g_wilc_initialized = 1;
3045
3046
3047 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
3048 host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
Johnny Kim218dc402015-08-13 13:41:19 +09003049 host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003050 g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3051 host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
3052
3053 /*Add saved WEP keys, if any*/
3054 if (g_wep_keys_saved) {
Johnny Kim218dc402015-08-13 13:41:19 +09003055 host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003056 g_key_wep_params.key_idx);
Johnny Kim218dc402015-08-13 13:41:19 +09003057 host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058 g_key_wep_params.key,
3059 g_key_wep_params.key_len,
3060 g_key_wep_params.key_idx);
3061 }
3062
3063 /*No matter the driver handler passed here, it will be overwriiten*/
3064 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
3065 host_int_flush_join_req(priv->hWILCWFIDrv);
3066
3067 /*Add saved PTK and GTK keys, if any*/
3068 if (g_ptk_keys_saved && g_gtk_keys_saved) {
3069 PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
3070 g_key_ptk_params.key[1],
3071 g_key_ptk_params.key[2],
3072 g_key_ptk_params.cipher);
3073 PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
3074 g_key_gtk_params.key[1],
3075 g_key_gtk_params.key[2],
3076 g_key_gtk_params.cipher);
3077 #if 1
Chaehyun Lim953d4172015-09-14 12:24:05 +09003078 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3079 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3080 g_add_ptk_key_params.key_idx,
3081 g_add_ptk_key_params.pairwise,
3082 g_add_ptk_key_params.mac_addr,
3083 (struct key_params *)(&g_key_ptk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084
Chaehyun Lim953d4172015-09-14 12:24:05 +09003085 add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
3086 g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
3087 g_add_gtk_key_params.key_idx,
3088 g_add_gtk_key_params.pairwise,
3089 g_add_gtk_key_params.mac_addr,
3090 (struct key_params *)(&g_key_gtk_params));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003091 #endif
3092 }
3093 #endif
3094
3095 /*BugID_4847: registered frames in firmware are now*/
3096 /*lost due to mac close. So re-register those frames*/
3097 if (g_linux_wlan->wilc1000_initialized) {
3098 for (i = 0; i < num_reg_frame; i++) {
3099 PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
3100 nic->g_struct_frame_reg[i].reg);
3101 host_int_frame_register(priv->hWILCWFIDrv,
3102 nic->g_struct_frame_reg[i].frame_type,
3103 nic->g_struct_frame_reg[i].reg);
3104 }
3105 }
3106 #endif
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003107 break;
3108
3109 default:
3110 PRINT_ER("Unknown interface type= %d\n", type);
3111 s32Error = -EINVAL;
3112 return s32Error;
3113 break;
3114 }
3115
3116 return s32Error;
3117}
3118
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003119/* (austin.2013-07-23)
3120 *
3121 * To support revised cfg80211_ops
3122 *
3123 * add_beacon --> start_ap
3124 * set_beacon --> change_beacon
3125 * del_beacon --> stop_ap
3126 *
3127 * beacon_parameters --> cfg80211_ap_settings
3128 * cfg80211_beacon_data
3129 *
3130 * applicable for linux kernel 3.4+
3131 */
3132
3133/**
Chaehyun Lima13168d2015-09-14 12:24:12 +09003134 * @brief start_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003135 * @details Add a beacon with given parameters, @head, @interval
3136 * and @dtim_period will be valid, @tail is optional.
3137 * @param[in] wiphy
3138 * @param[in] dev The net device structure
3139 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
3140 * @return int : Return 0 on Success.
3141 * @author austin
3142 * @date 23 JUL 2013
3143 * @version 1.0
3144 */
Chaehyun Lima13168d2015-09-14 12:24:12 +09003145static int start_ap(struct wiphy *wiphy, struct net_device *dev,
3146 struct cfg80211_ap_settings *settings)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003147{
3148 struct cfg80211_beacon_data *beacon = &(settings->beacon);
Chaehyun Lim27268872015-09-15 14:06:13 +09003149 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003150 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003151
3152 priv = wiphy_priv(wiphy);
3153 PRINT_D(HOSTAPD_DBG, "Starting ap\n");
3154
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303155 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 +09003156 settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
3157
Chaehyun Lim80785a92015-09-14 12:24:01 +09003158 s32Error = set_channel(wiphy, &settings->chandef);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003159
3160 if (s32Error != WILC_SUCCESS)
3161 PRINT_ER("Error in setting channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162
3163 linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
3164
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003165 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3166 settings->beacon_interval,
3167 settings->dtim_period,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003168 beacon->head_len, (u8 *)beacon->head,
3169 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003170
3171 return s32Error;
3172}
3173
3174/**
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003175 * @brief change_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176 * @details Add a beacon with given parameters, @head, @interval
3177 * and @dtim_period will be valid, @tail is optional.
3178 * @param[in] wiphy
3179 * @param[in] dev The net device structure
3180 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
3181 * @return int : Return 0 on Success.
3182 * @author austin
3183 * @date 23 JUL 2013
3184 * @version 1.0
3185 */
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003186static int change_beacon(struct wiphy *wiphy, struct net_device *dev,
3187 struct cfg80211_beacon_data *beacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003188{
Chaehyun Lim27268872015-09-15 14:06:13 +09003189 struct wilc_priv *priv;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003190 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191
3192 priv = wiphy_priv(wiphy);
3193 PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
3194
3195
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003196 s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
3197 0,
3198 0,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003199 beacon->head_len, (u8 *)beacon->head,
3200 beacon->tail_len, (u8 *)beacon->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201
3202 return s32Error;
3203}
3204
3205/**
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003206 * @brief stop_ap
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003207 * @details Remove beacon configuration and stop sending the beacon.
3208 * @param[in]
3209 * @return int : Return 0 on Success.
3210 * @author austin
3211 * @date 23 JUL 2013
3212 * @version 1.0
3213 */
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003214static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003215{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003216 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003217 struct wilc_priv *priv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003218 u8 NullBssid[ETH_ALEN] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219
3220
3221 WILC_NULLCHECK(s32Error, wiphy);
3222
3223 priv = wiphy_priv(wiphy);
3224
3225 PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
3226
3227 /*BugID_5188*/
3228 linux_wlan_set_bssid(dev, NullBssid);
3229
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230 s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231
3232 WILC_ERRORCHECK(s32Error);
3233
3234 WILC_CATCH(s32Error)
3235 {
3236 }
3237 return s32Error;
3238}
3239
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240/**
Chaehyun Limed269552015-09-14 12:24:15 +09003241 * @brief add_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003242 * @details Add a new station.
3243 * @param[in]
3244 * @return int : Return 0 on Success.
3245 * @author mdaftedar
3246 * @date 01 MAR 2012
3247 * @version 1.0
3248 */
Chaehyun Limed269552015-09-14 12:24:15 +09003249static int add_station(struct wiphy *wiphy, struct net_device *dev,
3250 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003251{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003252 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003253 struct wilc_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303254 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003255 perInterface_wlan_t *nic;
3256
3257
3258 WILC_NULLCHECK(s32Error, wiphy);
3259
3260 priv = wiphy_priv(wiphy);
3261 nic = netdev_priv(dev);
3262
3263 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003264 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
3265 memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266 strStaParams.u16AssocID = params->aid;
3267 strStaParams.u8NumRates = params->supported_rates_len;
3268 strStaParams.pu8Rates = params->supported_rates;
3269
3270 PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
3271
3272 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],
3273 priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
3274 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3275 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3276
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003277 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003278 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003280 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3282 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003283 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003284 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3285 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3286 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3287 }
3288
3289 strStaParams.u16FlagsMask = params->sta_flags_mask;
3290 strStaParams.u16FlagsSet = params->sta_flags_set;
3291
3292 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3293 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3294 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3295 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3296 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3297 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3298 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3299 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3300
3301 s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
3302 WILC_ERRORCHECK(s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003303 }
3304
3305 WILC_CATCH(s32Error)
3306 {
3307 }
3308 return s32Error;
3309}
3310
3311/**
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003312 * @brief del_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313 * @details Remove a station; @mac may be NULL to remove all stations.
3314 * @param[in]
3315 * @return int : Return 0 on Success.
3316 * @author mdaftedar
3317 * @date 01 MAR 2012
3318 * @version 1.0
3319 */
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003320static int del_station(struct wiphy *wiphy, struct net_device *dev,
3321 struct station_del_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003322{
Arnd Bergmann057d1e92015-06-01 21:06:44 +02003323 const u8 *mac = params->mac;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003324 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003325 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326 perInterface_wlan_t *nic;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003327
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328 WILC_NULLCHECK(s32Error, wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329
3330 priv = wiphy_priv(wiphy);
3331 nic = netdev_priv(dev);
3332
3333 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
3334 PRINT_D(HOSTAPD_DBG, "Deleting station\n");
3335
3336
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003337 if (mac == NULL) {
Chandra S Gorentla17aacd42015-08-08 17:41:35 +05303338 PRINT_D(HOSTAPD_DBG, "All associated stations\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003339 s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
3340 } else {
3341 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]);
3342 }
3343
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344 s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003345
3346 WILC_ERRORCHECK(s32Error);
3347 }
3348 WILC_CATCH(s32Error)
3349 {
3350 }
3351 return s32Error;
3352}
3353
3354/**
Chaehyun Lim14b42082015-09-14 12:24:17 +09003355 * @brief change_station
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356 * @details Modify a given station.
3357 * @param[in]
3358 * @return int : Return 0 on Success.
3359 * @author mdaftedar
3360 * @date 01 MAR 2012
3361 * @version 1.0
3362 */
Chaehyun Lim14b42082015-09-14 12:24:17 +09003363static int change_station(struct wiphy *wiphy, struct net_device *dev,
3364 const u8 *mac, struct station_parameters *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003365{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003366 s32 s32Error = WILC_SUCCESS;
Chaehyun Lim27268872015-09-15 14:06:13 +09003367 struct wilc_priv *priv;
Chandra S Gorentlaa2b40412015-08-08 17:41:33 +05303368 tstrWILC_AddStaParam strStaParams = { {0} };
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003369 perInterface_wlan_t *nic;
3370
3371
3372 PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
3373
3374 WILC_NULLCHECK(s32Error, wiphy);
3375
3376 priv = wiphy_priv(wiphy);
3377 nic = netdev_priv(dev);
3378
3379 if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003380 memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 strStaParams.u16AssocID = params->aid;
3382 strStaParams.u8NumRates = params->supported_rates_len;
3383 strStaParams.pu8Rates = params->supported_rates;
3384
3385 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],
3386 strStaParams.au8BSSID[5]);
3387 PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
3388 PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
3389
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003390 if (params->ht_capa == NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003391 strStaParams.bIsHTSupported = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003392 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003393 strStaParams.bIsHTSupported = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003394 strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
3395 strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003396 memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003397 strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
3398 strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
3399 strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
3400
3401 }
3402
3403 strStaParams.u16FlagsMask = params->sta_flags_mask;
3404 strStaParams.u16FlagsSet = params->sta_flags_set;
3405
3406 PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
3407 PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
3408 PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
3409 PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
3410 PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
3411 PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
3412 PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
3413 PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
3414
3415 s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
3416 WILC_ERRORCHECK(s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003417 }
3418 WILC_CATCH(s32Error)
3419 {
3420 }
3421 return s32Error;
3422}
3423
3424
3425/**
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003426 * @brief add_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003427 * @details
3428 * @param[in]
3429 * @return int : Return 0 on Success.
3430 * @author mdaftedar
3431 * @date 01 JUL 2012
3432 * @version 1.0
3433 */
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003434struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, const char *name,
3435 unsigned char name_assign_type,
3436 enum nl80211_iftype type, u32 *flags,
3437 struct vif_params *params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003438{
3439 perInterface_wlan_t *nic;
Chaehyun Lim27268872015-09-15 14:06:13 +09003440 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441 struct net_device *new_ifc = NULL;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003442
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443 priv = wiphy_priv(wiphy);
3444
3445
3446
3447 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
3448
3449 nic = netdev_priv(priv->wdev->netdev);
3450
3451
3452 if (type == NL80211_IFTYPE_MONITOR) {
3453 PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3454 PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
3455 new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
3456 if (new_ifc != NULL) {
3457 PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003458 nic = netdev_priv(priv->wdev->netdev);
3459 nic->monitor_flag = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460 } else
3461 PRINT_ER("Error in initializing monitor interface\n ");
3462 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003463 return priv->wdev;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003464}
3465
3466/**
Chaehyun Limb4a73352015-09-14 12:24:10 +09003467 * @brief del_virtual_intf
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468 * @details
3469 * @param[in]
3470 * @return int : Return 0 on Success.
3471 * @author mdaftedar
3472 * @date 01 JUL 2012
3473 * @version 1.0
3474 */
Chaehyun Limb4a73352015-09-14 12:24:10 +09003475int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003476{
3477 PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
3478 return WILC_SUCCESS;
3479}
3480
3481
3482
3483#endif /*WILC_AP_EXTERNAL_MLME*/
Chaehyun Lim08241922015-09-15 14:06:12 +09003484static struct cfg80211_ops wilc_cfg80211_ops = {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485
Chaehyun Lim80785a92015-09-14 12:24:01 +09003486 .set_monitor_channel = set_channel,
Chaehyun Lim0e30d062015-09-14 12:24:02 +09003487 .scan = scan,
Chaehyun Lim4ffbcdb2015-09-14 12:24:03 +09003488 .connect = connect,
Chaehyun Limb027cde2015-09-14 12:24:04 +09003489 .disconnect = disconnect,
Chaehyun Lim953d4172015-09-14 12:24:05 +09003490 .add_key = add_key,
Chaehyun Lim3044ba72015-09-14 12:24:06 +09003491 .del_key = del_key,
Chaehyun Limf4893df2015-09-14 12:24:07 +09003492 .get_key = get_key,
Chaehyun Lim0f5b8ca2015-09-14 12:24:08 +09003493 .set_default_key = set_default_key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494 #ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim69deb4c2015-09-14 12:24:09 +09003495 .add_virtual_intf = add_virtual_intf,
Chaehyun Limb4a73352015-09-14 12:24:10 +09003496 .del_virtual_intf = del_virtual_intf,
Chaehyun Lim3615e9a2015-09-14 12:24:11 +09003497 .change_virtual_intf = change_virtual_intf,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498
Chaehyun Lima13168d2015-09-14 12:24:12 +09003499 .start_ap = start_ap,
Chaehyun Lim2a4c84d2015-09-14 12:24:13 +09003500 .change_beacon = change_beacon,
Chaehyun Limc8cddd72015-09-14 12:24:14 +09003501 .stop_ap = stop_ap,
Chaehyun Limed269552015-09-14 12:24:15 +09003502 .add_station = add_station,
Chaehyun Lima0a8be92015-09-14 12:24:16 +09003503 .del_station = del_station,
Chaehyun Lim14b42082015-09-14 12:24:17 +09003504 .change_station = change_station,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003505 #endif /* WILC_AP_EXTERNAL_MLME*/
Chaehyun Limf06f5622015-09-14 12:24:18 +09003506 .get_station = get_station,
Chaehyun Limbdb63382015-09-14 12:24:19 +09003507 .dump_station = dump_station,
Chaehyun Lima5f7db62015-09-14 12:24:20 +09003508 .change_bss = change_bss,
Chaehyun Lima76b63e2015-09-14 12:24:21 +09003509 .set_wiphy_params = set_wiphy_params,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510
Chaehyun Lim4d466572015-09-14 12:24:22 +09003511 .set_pmksa = set_pmksa,
Chaehyun Lim1ff86d92015-09-14 12:24:23 +09003512 .del_pmksa = del_pmksa,
Chaehyun Limb33c39b2015-09-14 12:24:24 +09003513 .flush_pmksa = flush_pmksa,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003514#ifdef WILC_P2P
Chaehyun Lim6d19d692015-09-14 12:24:25 +09003515 .remain_on_channel = remain_on_channel,
Chaehyun Lim1dd54402015-09-14 12:24:26 +09003516 .cancel_remain_on_channel = cancel_remain_on_channel,
Chaehyun Lim4a2f9b32015-09-14 12:24:27 +09003517 .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait,
Chaehyun Lim12a26a32015-09-14 12:24:28 +09003518 .mgmt_tx = mgmt_tx,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003519 .mgmt_frame_register = WILC_WFI_frame_register,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003520 .set_power_mgmt = WILC_WFI_set_power_mgmt,
3521 .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
3522#endif
3523
3524};
3525
3526
3527
3528
3529
3530/**
3531 * @brief WILC_WFI_update_stats
3532 * @details Modify parameters for a given BSS.
3533 * @param[in]
3534 * @return int : Return 0 on Success.
3535 * @author mdaftedar
3536 * @date 01 MAR 2012
3537 * @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
3538 */
3539int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
3540{
3541
Chaehyun Lim27268872015-09-15 14:06:13 +09003542 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543
3544 priv = wiphy_priv(wiphy);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545#if 1
3546 switch (changed) {
3547
3548 case WILC_WFI_RX_PKT:
3549 {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003550 priv->netstats.rx_packets++;
3551 priv->netstats.rx_bytes += pktlen;
3552 priv->netstats.rx_time = get_jiffies_64();
3553 }
3554 break;
3555
3556 case WILC_WFI_TX_PKT:
3557 {
3558 priv->netstats.tx_packets++;
3559 priv->netstats.tx_bytes += pktlen;
3560 priv->netstats.tx_time = get_jiffies_64();
3561
3562 }
3563 break;
3564
3565 default:
3566 break;
3567 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003568#endif
3569 return 0;
3570}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003571
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003572/**
3573 * @brief WILC_WFI_CfgAlloc
3574 * @details Allocation of the wireless device structure and assigning it
3575 * to the cfg80211 operations structure.
3576 * @param[in] NONE
3577 * @return wireless_dev : Returns pointer to wireless_dev structure.
3578 * @author mdaftedar
3579 * @date 01 MAR 2012
3580 * @version 1.0
3581 */
3582struct wireless_dev *WILC_WFI_CfgAlloc(void)
3583{
3584
3585 struct wireless_dev *wdev;
3586
3587
3588 PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
3589 /*Allocating the wireless device structure*/
3590 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
3591 if (!wdev) {
3592 PRINT_ER("Cannot allocate wireless device\n");
3593 goto _fail_;
3594 }
3595
3596 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
Chaehyun Lim27268872015-09-15 14:06:13 +09003597 wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003598 if (!wdev->wiphy) {
3599 PRINT_ER("Cannot allocate wiphy\n");
3600 goto _fail_mem_;
3601
3602 }
3603
3604 #ifdef WILC_AP_EXTERNAL_MLME
3605 /* enable 802.11n HT */
3606 WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
3607 WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
3608 WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
3609 WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
3610 WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
3611 #endif
3612
3613 /*wiphy bands*/
3614 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
3615
3616 return wdev;
3617
3618_fail_mem_:
3619 kfree(wdev);
3620_fail_:
3621 return NULL;
3622
3623}
3624/**
3625 * @brief WILC_WFI_WiphyRegister
3626 * @details Registering of the wiphy structure and interface modes
3627 * @param[in] NONE
3628 * @return NONE
3629 * @author mdaftedar
3630 * @date 01 MAR 2012
3631 * @version 1.0
3632 */
3633struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
3634{
Chaehyun Lim27268872015-09-15 14:06:13 +09003635 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636 struct wireless_dev *wdev;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003637 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003638
3639 PRINT_D(CFG80211_DBG, "Registering wifi device\n");
3640
3641 wdev = WILC_WFI_CfgAlloc();
3642 if (wdev == NULL) {
3643 PRINT_ER("CfgAlloc Failed\n");
3644 return NULL;
3645 }
3646
3647
3648 /*Return hardware description structure (wiphy)'s priv*/
3649 priv = wdev_priv(wdev);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003650 sema_init(&(priv->SemHandleUpdateStats), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003651
3652 /*Link the wiphy with wireless structure*/
3653 priv->wdev = wdev;
3654
3655 /*Maximum number of probed ssid to be added by user for the scan request*/
3656 wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657 /*Maximum number of pmkids to be cashed*/
3658 wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
3659 PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
3661 wdev->wiphy->max_scan_ie_len = 1000;
3662
3663 /*signal strength in mBm (100*dBm) */
3664 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
3665
3666 /*Set the availaible cipher suites*/
3667 wdev->wiphy->cipher_suites = cipher_suites;
3668 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003669 /*Setting default managment types: for register action frame: */
3670 wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003671
3672#ifdef WILC_P2P
3673 wdev->wiphy->max_remain_on_channel_duration = 500;
3674 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3675 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
3676 BIT(NL80211_IFTYPE_P2P_CLIENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003677 wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003678#else
3679 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
3680#endif
3681 wdev->iftype = NL80211_IFTYPE_STATION;
3682
3683
3684
3685 PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3686 wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
3687 wdev->wiphy->interface_modes, wdev->iftype);
3688
3689 #ifdef WILC_SDIO
3690 set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
3691 #endif
3692
3693 /*Register wiphy structure*/
3694 s32Error = wiphy_register(wdev->wiphy);
3695 if (s32Error) {
3696 PRINT_ER("Cannot register wiphy device\n");
3697 /*should define what action to be taken in such failure*/
3698 } else {
3699 PRINT_D(CFG80211_DBG, "Successful Registering\n");
3700 }
3701
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003702 priv->dev = net;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003703 return wdev;
3704
3705
3706}
3707/**
3708 * @brief WILC_WFI_WiphyFree
3709 * @details Freeing allocation of the wireless device structure
3710 * @param[in] NONE
3711 * @return NONE
3712 * @author mdaftedar
3713 * @date 01 MAR 2012
3714 * @version 1.0
3715 */
3716int WILC_WFI_InitHostInt(struct net_device *net)
3717{
3718
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003719 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720
Chaehyun Lim27268872015-09-15 14:06:13 +09003721 struct wilc_priv *priv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003722
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003723 PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
3724 priv = wdev_priv(net->ieee80211_ptr);
3725 if (op_ifcs == 0) {
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003726 setup_timer(&hAgingTimer, remove_network_from_shadow, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003727 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003728 setup_timer(&hDuringIpTimer, clear_duringIP, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003729 #endif
3730 }
3731 op_ifcs++;
3732 if (s32Error < 0) {
3733 PRINT_ER("Failed to creat refresh Timer\n");
3734 return s32Error;
3735 }
3736
Dean Lee72ed4dc2015-06-12 14:11:44 +09003737 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003738
Dean Lee72ed4dc2015-06-12 14:11:44 +09003739 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003740
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003741 sema_init(&(priv->hSemScanReq), 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003742 s32Error = host_int_init(&priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003743 if (s32Error) {
3744 PRINT_ER("Error while initializing hostinterface\n");
3745 }
3746 return s32Error;
3747}
3748
3749/**
3750 * @brief WILC_WFI_WiphyFree
3751 * @details Freeing allocation of the wireless device structure
3752 * @param[in] NONE
3753 * @return NONE
3754 * @author mdaftedar
3755 * @date 01 MAR 2012
3756 * @version 1.0
3757 */
3758int WILC_WFI_DeInitHostInt(struct net_device *net)
3759{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003760 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003761
Chaehyun Lim27268872015-09-15 14:06:13 +09003762 struct wilc_priv *priv;
Chaehyun Lim8dfaafd2015-08-18 23:18:11 +09003763
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764 priv = wdev_priv(net->ieee80211_ptr);
3765
Dean Lee72ed4dc2015-06-12 14:11:44 +09003766 priv->gbAutoRateAdjusted = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003767
Dean Lee72ed4dc2015-06-12 14:11:44 +09003768 priv->bInP2PlistenState = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003769
3770 op_ifcs--;
3771
3772 s32Error = host_int_deinit(priv->hWILCWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003773
3774 /* Clear the Shadow scan */
3775 clear_shadow_scan(priv);
3776 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3777 if (op_ifcs == 0) {
3778 PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07003779 del_timer_sync(&hDuringIpTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003780 }
3781 #endif
3782
3783 if (s32Error) {
3784 PRINT_ER("Error while deintializing host interface\n");
3785 }
3786 return s32Error;
3787}
3788
3789
3790/**
3791 * @brief WILC_WFI_WiphyFree
3792 * @details Freeing allocation of the wireless device structure
3793 * @param[in] NONE
3794 * @return NONE
3795 * @author mdaftedar
3796 * @date 01 MAR 2012
3797 * @version 1.0
3798 */
3799void WILC_WFI_WiphyFree(struct net_device *net)
3800{
3801
3802 PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
3803
3804 if (net == NULL) {
3805 PRINT_D(INIT_DBG, "net_device is NULL\n");
3806 return;
3807 }
3808
3809 if (net->ieee80211_ptr == NULL) {
3810 PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
3811 return;
3812 }
3813
3814 if (net->ieee80211_ptr->wiphy == NULL) {
3815 PRINT_D(INIT_DBG, "wiphy is NULL\n");
3816 return;
3817 }
3818
3819 wiphy_unregister(net->ieee80211_ptr->wiphy);
3820
3821 PRINT_D(INIT_DBG, "Freeing wiphy\n");
3822 wiphy_free(net->ieee80211_ptr->wiphy);
3823 kfree(net->ieee80211_ptr);
3824
3825}