2 * @file wilc_wfi_cfgopertaions.c
3 * @brief CFG80211 Function Implementation functionality
8 * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
13 #include "wilc_wfi_cfgoperations.h"
14 #include "host_interface.h"
15 #include <linux/errno.h>
17 /* The following macros describe the bitfield map used by the firmware to determine its 11i mode */
19 #define ENCRYPT_ENABLED BIT(0)
21 #define WEP_EXTENDED BIT(2)
27 /*Public action frame index IDs*/
28 #define FRAME_TYPE_ID 0
29 #define ACTION_CAT_ID 24
30 #define ACTION_SUBTYPE_ID 25
31 #define P2P_PUB_ACTION_SUBTYPE 30
33 /*Public action frame Attribute IDs*/
34 #define ACTION_FRAME 0xd0
35 #define GO_INTENT_ATTR_ID 0x04
36 #define CHANLIST_ATTR_ID 0x0b
37 #define OPERCHAN_ATTR_ID 0x11
38 #define PUB_ACTION_ATTR_ID 0x04
39 #define P2PELEM_ATTR_ID 0xdd
41 /*Public action subtype values*/
42 #define GO_NEG_REQ 0x00
43 #define GO_NEG_RSP 0x01
44 #define GO_NEG_CONF 0x02
45 #define P2P_INV_REQ 0x03
46 #define P2P_INV_RSP 0x04
47 #define PUBLIC_ACT_VENDORSPEC 0x09
48 #define GAS_INTIAL_REQ 0x0a
49 #define GAS_INTIAL_RSP 0x0b
51 #define INVALID_CHANNEL 0
53 #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
54 #define SCAN_RESULT_EXPIRE (40 * HZ)
56 static const u32 cipher_suites
[] = {
57 WLAN_CIPHER_SUITE_WEP40
,
58 WLAN_CIPHER_SUITE_WEP104
,
59 WLAN_CIPHER_SUITE_TKIP
,
60 WLAN_CIPHER_SUITE_CCMP
,
61 WLAN_CIPHER_SUITE_AES_CMAC
,
64 static const struct ieee80211_txrx_stypes
65 wilc_wfi_cfg80211_mgmt_types
[NUM_NL80211_IFTYPES
] = {
66 [NL80211_IFTYPE_STATION
] = {
68 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
69 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4)
71 [NL80211_IFTYPE_AP
] = {
73 .rx
= BIT(IEEE80211_STYPE_ASSOC_REQ
>> 4) |
74 BIT(IEEE80211_STYPE_REASSOC_REQ
>> 4) |
75 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4) |
76 BIT(IEEE80211_STYPE_DISASSOC
>> 4) |
77 BIT(IEEE80211_STYPE_AUTH
>> 4) |
78 BIT(IEEE80211_STYPE_DEAUTH
>> 4) |
79 BIT(IEEE80211_STYPE_ACTION
>> 4)
81 [NL80211_IFTYPE_P2P_CLIENT
] = {
83 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
84 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4) |
85 BIT(IEEE80211_STYPE_ASSOC_REQ
>> 4) |
86 BIT(IEEE80211_STYPE_REASSOC_REQ
>> 4) |
87 BIT(IEEE80211_STYPE_DISASSOC
>> 4) |
88 BIT(IEEE80211_STYPE_AUTH
>> 4) |
89 BIT(IEEE80211_STYPE_DEAUTH
>> 4)
93 /* Time to stay on the channel */
94 #define WILC_WFI_DWELL_PASSIVE 100
95 #define WILC_WFI_DWELL_ACTIVE 40
97 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
98 #define DEFAULT_LINK_SPEED 72
101 #define IS_MANAGMEMENT 0x100
102 #define IS_MANAGMEMENT_CALLBACK 0x080
103 #define IS_MGMT_STATUS_SUCCES 0x040
104 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
106 extern int wilc_mac_open(struct net_device
*ndev
);
107 extern int wilc_mac_close(struct net_device
*ndev
);
109 static tstrNetworkInfo last_scanned_shadow
[MAX_NUM_SCANNED_NETWORKS_SHADOW
];
110 static u32 last_scanned_cnt
;
111 struct timer_list wilc_during_ip_timer
;
112 static struct timer_list hAgingTimer
;
115 u8 wilc_initialized
= 1;
117 #define CHAN2G(_channel, _freq, _flags) { \
118 .band = IEEE80211_BAND_2GHZ, \
119 .center_freq = (_freq), \
120 .hw_value = (_channel), \
122 .max_antenna_gain = 0, \
126 /*Frequency range for channels*/
127 static struct ieee80211_channel ieee80211_2ghz_channels
[] = {
144 #define RATETAB_ENT(_rate, _hw_value, _flags) { \
145 .bitrate = (_rate), \
146 .hw_value = (_hw_value), \
151 /* Table 6 in section 3.2.1.1 */
152 static struct ieee80211_rate ieee80211_bitrates
[] = {
153 RATETAB_ENT(10, 0, 0),
154 RATETAB_ENT(20, 1, 0),
155 RATETAB_ENT(55, 2, 0),
156 RATETAB_ENT(110, 3, 0),
157 RATETAB_ENT(60, 9, 0),
158 RATETAB_ENT(90, 6, 0),
159 RATETAB_ENT(120, 7, 0),
160 RATETAB_ENT(180, 8, 0),
161 RATETAB_ENT(240, 9, 0),
162 RATETAB_ENT(360, 10, 0),
163 RATETAB_ENT(480, 11, 0),
164 RATETAB_ENT(540, 12, 0),
167 struct p2p_mgmt_data
{
172 static u8 wlan_channel
= INVALID_CHANNEL
;
173 static u8 curr_channel
;
174 static u8 p2p_oui
[] = {0x50, 0x6f, 0x9A, 0x09};
175 static u8 p2p_local_random
= 0x01;
176 static u8 p2p_recv_random
= 0x00;
177 static u8 p2p_vendor_spec
[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
180 static struct ieee80211_supported_band WILC_WFI_band_2ghz
= {
181 .channels
= ieee80211_2ghz_channels
,
182 .n_channels
= ARRAY_SIZE(ieee80211_2ghz_channels
),
183 .bitrates
= ieee80211_bitrates
,
184 .n_bitrates
= ARRAY_SIZE(ieee80211_bitrates
),
188 struct add_key_params
{
193 static struct add_key_params g_add_gtk_key_params
;
194 static struct wilc_wfi_key g_key_gtk_params
;
195 static struct add_key_params g_add_ptk_key_params
;
196 static struct wilc_wfi_key g_key_ptk_params
;
197 static struct wilc_wfi_wep_key g_key_wep_params
;
198 static bool g_ptk_keys_saved
;
199 static bool g_gtk_keys_saved
;
200 static bool g_wep_keys_saved
;
202 #define AGING_TIME (9 * 1000)
203 #define during_ip_time 15000
205 static void clear_shadow_scan(void)
210 del_timer_sync(&hAgingTimer
);
211 PRINT_INFO(CORECONFIG_DBG
, "destroy aging timer\n");
213 for (i
= 0; i
< last_scanned_cnt
; i
++) {
214 if (last_scanned_shadow
[last_scanned_cnt
].pu8IEs
) {
215 kfree(last_scanned_shadow
[i
].pu8IEs
);
216 last_scanned_shadow
[last_scanned_cnt
].pu8IEs
= NULL
;
219 wilc_free_join_params(last_scanned_shadow
[i
].pJoinParams
);
220 last_scanned_shadow
[i
].pJoinParams
= NULL
;
222 last_scanned_cnt
= 0;
227 static u32
get_rssi_avg(tstrNetworkInfo
*pstrNetworkInfo
)
231 u8 num_rssi
= (pstrNetworkInfo
->strRssi
.u8Full
) ? NUM_RSSI
: (pstrNetworkInfo
->strRssi
.u8Index
);
233 for (i
= 0; i
< num_rssi
; i
++)
234 rssi_v
+= pstrNetworkInfo
->strRssi
.as8RSSI
[i
];
240 static void refresh_scan(void *pUserVoid
, u8 all
, bool bDirectScan
)
242 struct wilc_priv
*priv
;
244 struct cfg80211_bss
*bss
= NULL
;
248 priv
= (struct wilc_priv
*)pUserVoid
;
249 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
251 for (i
= 0; i
< last_scanned_cnt
; i
++) {
252 tstrNetworkInfo
*pstrNetworkInfo
;
254 pstrNetworkInfo
= &last_scanned_shadow
[i
];
256 if ((!pstrNetworkInfo
->u8Found
) || all
) {
258 struct ieee80211_channel
*channel
;
260 if (pstrNetworkInfo
!= NULL
) {
262 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
263 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
265 rssi
= get_rssi_avg(pstrNetworkInfo
);
266 if (memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7) || bDirectScan
) {
267 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
268 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
269 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)rssi
) * 100), GFP_KERNEL
);
270 cfg80211_put_bss(wiphy
, bss
);
279 static void reset_shadow_found(void *pUserVoid
)
283 for (i
= 0; i
< last_scanned_cnt
; i
++)
284 last_scanned_shadow
[i
].u8Found
= 0;
287 static void update_scan_time(void *pUserVoid
)
291 for (i
= 0; i
< last_scanned_cnt
; i
++)
292 last_scanned_shadow
[i
].u32TimeRcvdInScan
= jiffies
;
295 static void remove_network_from_shadow(unsigned long arg
)
297 unsigned long now
= jiffies
;
301 for (i
= 0; i
< last_scanned_cnt
; i
++) {
302 if (time_after(now
, last_scanned_shadow
[i
].u32TimeRcvdInScan
+ (unsigned long)(SCAN_RESULT_EXPIRE
))) {
303 PRINT_D(CFG80211_DBG
, "Network expired in ScanShadow: %s\n", last_scanned_shadow
[i
].au8ssid
);
305 kfree(last_scanned_shadow
[i
].pu8IEs
);
306 last_scanned_shadow
[i
].pu8IEs
= NULL
;
308 wilc_free_join_params(last_scanned_shadow
[i
].pJoinParams
);
310 for (j
= i
; (j
< last_scanned_cnt
- 1); j
++)
311 last_scanned_shadow
[j
] = last_scanned_shadow
[j
+ 1];
317 PRINT_D(CFG80211_DBG
, "Number of cached networks: %d\n",
319 if (last_scanned_cnt
!= 0) {
320 hAgingTimer
.data
= arg
;
321 mod_timer(&hAgingTimer
, jiffies
+ msecs_to_jiffies(AGING_TIME
));
323 PRINT_D(CFG80211_DBG
, "No need to restart Aging timer\n");
327 static void clear_duringIP(unsigned long arg
)
329 PRINT_D(GENERIC_DBG
, "GO:IP Obtained , enable scan\n");
330 wilc_optaining_ip
= false;
333 static int is_network_in_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
)
338 if (last_scanned_cnt
== 0) {
339 PRINT_D(CFG80211_DBG
, "Starting Aging timer\n");
340 hAgingTimer
.data
= (unsigned long)pUserVoid
;
341 mod_timer(&hAgingTimer
, jiffies
+ msecs_to_jiffies(AGING_TIME
));
344 /* Linear search for now */
345 for (i
= 0; i
< last_scanned_cnt
; i
++) {
346 if (memcmp(last_scanned_shadow
[i
].au8bssid
,
347 pstrNetworkInfo
->au8bssid
, 6) == 0) {
356 static void add_network_to_shadow(tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
358 int ap_found
= is_network_in_shadow(pstrNetworkInfo
, pUserVoid
);
362 if (last_scanned_cnt
>= MAX_NUM_SCANNED_NETWORKS_SHADOW
) {
363 PRINT_D(CFG80211_DBG
, "Shadow network reached its maximum limit\n");
366 if (ap_found
== -1) {
367 ap_index
= last_scanned_cnt
;
373 rssi_index
= last_scanned_shadow
[ap_index
].strRssi
.u8Index
;
374 last_scanned_shadow
[ap_index
].strRssi
.as8RSSI
[rssi_index
++] = pstrNetworkInfo
->s8rssi
;
375 if (rssi_index
== NUM_RSSI
) {
377 last_scanned_shadow
[ap_index
].strRssi
.u8Full
= 1;
379 last_scanned_shadow
[ap_index
].strRssi
.u8Index
= rssi_index
;
380 last_scanned_shadow
[ap_index
].s8rssi
= pstrNetworkInfo
->s8rssi
;
381 last_scanned_shadow
[ap_index
].u16CapInfo
= pstrNetworkInfo
->u16CapInfo
;
382 last_scanned_shadow
[ap_index
].u8SsidLen
= pstrNetworkInfo
->u8SsidLen
;
383 memcpy(last_scanned_shadow
[ap_index
].au8ssid
,
384 pstrNetworkInfo
->au8ssid
, pstrNetworkInfo
->u8SsidLen
);
385 memcpy(last_scanned_shadow
[ap_index
].au8bssid
,
386 pstrNetworkInfo
->au8bssid
, ETH_ALEN
);
387 last_scanned_shadow
[ap_index
].u16BeaconPeriod
= pstrNetworkInfo
->u16BeaconPeriod
;
388 last_scanned_shadow
[ap_index
].u8DtimPeriod
= pstrNetworkInfo
->u8DtimPeriod
;
389 last_scanned_shadow
[ap_index
].u8channel
= pstrNetworkInfo
->u8channel
;
390 last_scanned_shadow
[ap_index
].u16IEsLen
= pstrNetworkInfo
->u16IEsLen
;
391 last_scanned_shadow
[ap_index
].u64Tsf
= pstrNetworkInfo
->u64Tsf
;
393 kfree(last_scanned_shadow
[ap_index
].pu8IEs
);
394 last_scanned_shadow
[ap_index
].pu8IEs
=
395 kmalloc(pstrNetworkInfo
->u16IEsLen
, GFP_KERNEL
); /* will be deallocated by the WILC_WFI_CfgScan() function */
396 memcpy(last_scanned_shadow
[ap_index
].pu8IEs
,
397 pstrNetworkInfo
->pu8IEs
, pstrNetworkInfo
->u16IEsLen
);
398 last_scanned_shadow
[ap_index
].u32TimeRcvdInScan
= jiffies
;
399 last_scanned_shadow
[ap_index
].u32TimeRcvdInScanCached
= jiffies
;
400 last_scanned_shadow
[ap_index
].u8Found
= 1;
402 wilc_free_join_params(last_scanned_shadow
[ap_index
].pJoinParams
);
403 last_scanned_shadow
[ap_index
].pJoinParams
= pJoinParams
;
408 * @brief CfgScanResult
409 * @details Callback function which returns the scan results found
411 * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
412 * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
413 * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
414 * void* pUserVoid: Private structure associated with the wireless interface
420 static void CfgScanResult(enum scan_event enuScanEvent
, tstrNetworkInfo
*pstrNetworkInfo
, void *pUserVoid
, void *pJoinParams
)
422 struct wilc_priv
*priv
;
425 struct ieee80211_channel
*channel
;
426 struct cfg80211_bss
*bss
= NULL
;
428 priv
= (struct wilc_priv
*)pUserVoid
;
429 if (priv
->bCfgScanning
) {
430 if (enuScanEvent
== SCAN_EVENT_NETWORK_FOUND
) {
431 wiphy
= priv
->dev
->ieee80211_ptr
->wiphy
;
436 if (wiphy
->signal_type
== CFG80211_SIGNAL_TYPE_UNSPEC
438 ((((s32
)pstrNetworkInfo
->s8rssi
) * 100) < 0
440 (((s32
)pstrNetworkInfo
->s8rssi
) * 100) > 100)
442 PRINT_ER("wiphy signal type fial\n");
446 if (pstrNetworkInfo
!= NULL
) {
447 s32Freq
= ieee80211_channel_to_frequency((s32
)pstrNetworkInfo
->u8channel
, IEEE80211_BAND_2GHZ
);
448 channel
= ieee80211_get_channel(wiphy
, s32Freq
);
453 PRINT_INFO(CFG80211_DBG
, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
454 "BeaconPeriod: %d\n", channel
->center_freq
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100),
455 pstrNetworkInfo
->u16CapInfo
, pstrNetworkInfo
->u16BeaconPeriod
);
457 if (pstrNetworkInfo
->bNewNetwork
) {
458 if (priv
->u32RcvdChCount
< MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
460 PRINT_D(CFG80211_DBG
, "Network %s found\n", pstrNetworkInfo
->au8ssid
);
463 priv
->u32RcvdChCount
++;
467 if (pJoinParams
== NULL
) {
468 PRINT_INFO(CORECONFIG_DBG
, ">> Something really bad happened\n");
470 add_network_to_shadow(pstrNetworkInfo
, priv
, pJoinParams
);
472 /*P2P peers are sent to WPA supplicant and added to shadow table*/
474 if (!(memcmp("DIRECT-", pstrNetworkInfo
->au8ssid
, 7))) {
475 bss
= cfg80211_inform_bss(wiphy
, channel
, CFG80211_BSS_FTYPE_UNKNOWN
, pstrNetworkInfo
->au8bssid
, pstrNetworkInfo
->u64Tsf
, pstrNetworkInfo
->u16CapInfo
,
476 pstrNetworkInfo
->u16BeaconPeriod
, (const u8
*)pstrNetworkInfo
->pu8IEs
,
477 (size_t)pstrNetworkInfo
->u16IEsLen
, (((s32
)pstrNetworkInfo
->s8rssi
) * 100), GFP_KERNEL
);
478 cfg80211_put_bss(wiphy
, bss
);
483 PRINT_ER("Discovered networks exceeded the max limit\n");
487 /* So this network is discovered before, we'll just update its RSSI */
488 for (i
= 0; i
< priv
->u32RcvdChCount
; i
++) {
489 if (memcmp(last_scanned_shadow
[i
].au8bssid
, pstrNetworkInfo
->au8bssid
, 6) == 0) {
490 PRINT_D(CFG80211_DBG
, "Update RSSI of %s\n", last_scanned_shadow
[i
].au8ssid
);
492 last_scanned_shadow
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
493 last_scanned_shadow
[i
].u32TimeRcvdInScan
= jiffies
;
499 } else if (enuScanEvent
== SCAN_EVENT_DONE
) {
500 PRINT_D(CFG80211_DBG
, "Scan Done[%p]\n", priv
->dev
);
501 PRINT_D(CFG80211_DBG
, "Refreshing Scan ...\n");
502 refresh_scan(priv
, 1, false);
504 if (priv
->u32RcvdChCount
> 0)
505 PRINT_D(CFG80211_DBG
, "%d Network(s) found\n", priv
->u32RcvdChCount
);
507 PRINT_D(CFG80211_DBG
, "No networks found\n");
509 down(&(priv
->hSemScanReq
));
511 if (priv
->pstrScanReq
!= NULL
) {
512 cfg80211_scan_done(priv
->pstrScanReq
, false);
513 priv
->u32RcvdChCount
= 0;
514 priv
->bCfgScanning
= false;
515 priv
->pstrScanReq
= NULL
;
517 up(&(priv
->hSemScanReq
));
520 /*Aborting any scan operation during mac close*/
521 else if (enuScanEvent
== SCAN_EVENT_ABORTED
) {
522 down(&(priv
->hSemScanReq
));
524 PRINT_D(CFG80211_DBG
, "Scan Aborted\n");
525 if (priv
->pstrScanReq
!= NULL
) {
527 update_scan_time(priv
);
528 refresh_scan(priv
, 1, false);
530 cfg80211_scan_done(priv
->pstrScanReq
, false);
531 priv
->bCfgScanning
= false;
532 priv
->pstrScanReq
= NULL
;
534 up(&(priv
->hSemScanReq
));
541 * @brief CfgConnectResult
543 * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
544 * connection response or disconnection notification.
545 * tstrConnectInfo* pstrConnectInfo: COnnection information.
546 * u8 u8MacStatus: Mac Status from firmware
547 * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
548 * void* pUserVoid: Private data associated with wireless interface
556 static void CfgConnectResult(enum conn_event enuConnDisconnEvent
,
557 tstrConnectInfo
*pstrConnectInfo
,
559 tstrDisconnectNotifInfo
*pstrDisconnectNotifInfo
,
562 struct wilc_priv
*priv
;
563 struct net_device
*dev
;
564 struct host_if_drv
*pstrWFIDrv
;
565 u8 NullBssid
[ETH_ALEN
] = {0};
567 perInterface_wlan_t
*nic
;
571 priv
= (struct wilc_priv
*)pUserVoid
;
573 nic
= netdev_priv(dev
);
575 pstrWFIDrv
= (struct host_if_drv
*)priv
->hWILCWFIDrv
;
577 if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_CONN_RESP
) {
579 u16 u16ConnectStatus
;
581 u16ConnectStatus
= pstrConnectInfo
->u16ConnectStatus
;
583 PRINT_D(CFG80211_DBG
, " Connection response received = %d\n", u8MacStatus
);
585 if ((u8MacStatus
== MAC_DISCONNECTED
) &&
586 (pstrConnectInfo
->u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
587 /* The case here is that our station was waiting for association response frame and has just received it containing status code
588 * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
589 u16ConnectStatus
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
590 wilc_wlan_set_bssid(priv
->dev
, NullBssid
);
591 eth_zero_addr(wilc_connected_ssid
);
593 if (!pstrWFIDrv
->p2p_connect
)
594 wlan_channel
= INVALID_CHANNEL
;
596 PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus
, u8MacStatus
);
599 if (u16ConnectStatus
== WLAN_STATUS_SUCCESS
) {
600 bool bNeedScanRefresh
= false;
603 PRINT_INFO(CFG80211_DBG
, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo
->au8bssid
[0],
604 pstrConnectInfo
->au8bssid
[1], pstrConnectInfo
->au8bssid
[2], pstrConnectInfo
->au8bssid
[3], pstrConnectInfo
->au8bssid
[4], pstrConnectInfo
->au8bssid
[5]);
605 memcpy(priv
->au8AssociatedBss
, pstrConnectInfo
->au8bssid
, ETH_ALEN
);
608 for (i
= 0; i
< last_scanned_cnt
; i
++) {
609 if (memcmp(last_scanned_shadow
[i
].au8bssid
,
610 pstrConnectInfo
->au8bssid
, ETH_ALEN
) == 0) {
611 unsigned long now
= jiffies
;
614 last_scanned_shadow
[i
].u32TimeRcvdInScanCached
+ (unsigned long)(nl80211_SCAN_RESULT_EXPIRE
- (1 * HZ
)))) {
615 bNeedScanRefresh
= true;
622 if (bNeedScanRefresh
) {
623 /*Also, refrsh DIRECT- results if */
624 refresh_scan(priv
, 1, true);
631 PRINT_D(CFG80211_DBG
, "Association request info elements length = %zu\n", pstrConnectInfo
->ReqIEsLen
);
633 PRINT_D(CFG80211_DBG
, "Association response info elements length = %d\n", pstrConnectInfo
->u16RespIEsLen
);
635 cfg80211_connect_result(dev
, pstrConnectInfo
->au8bssid
,
636 pstrConnectInfo
->pu8ReqIEs
, pstrConnectInfo
->ReqIEsLen
,
637 pstrConnectInfo
->pu8RespIEs
, pstrConnectInfo
->u16RespIEsLen
,
638 u16ConnectStatus
, GFP_KERNEL
); /* TODO: mostafa: u16ConnectStatus to */
639 /* be replaced by pstrConnectInfo->u16ConnectStatus */
640 } else if (enuConnDisconnEvent
== CONN_DISCONN_EVENT_DISCONN_NOTIF
) {
641 wilc_optaining_ip
= false;
642 PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
643 pstrDisconnectNotifInfo
->u16reason
, priv
->dev
);
644 p2p_local_random
= 0x01;
645 p2p_recv_random
= 0x00;
647 eth_zero_addr(priv
->au8AssociatedBss
);
648 wilc_wlan_set_bssid(priv
->dev
, NullBssid
);
649 eth_zero_addr(wilc_connected_ssid
);
651 if (!pstrWFIDrv
->p2p_connect
)
652 wlan_channel
= INVALID_CHANNEL
;
653 /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
654 * virtual interface to station*/
655 if ((pstrWFIDrv
->IFC_UP
) && (dev
== wl
->vif
[1].ndev
)) {
656 pstrDisconnectNotifInfo
->u16reason
= 3;
658 /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
659 * to scan again and retry the connection*/
660 else if ((!pstrWFIDrv
->IFC_UP
) && (dev
== wl
->vif
[1].ndev
)) {
661 pstrDisconnectNotifInfo
->u16reason
= 1;
663 cfg80211_disconnected(dev
, pstrDisconnectNotifInfo
->u16reason
, pstrDisconnectNotifInfo
->ie
,
664 pstrDisconnectNotifInfo
->ie_len
, false,
674 * @details Set channel for a given wireless interface. Some devices
675 * may support multi-channel operation (by channel hopping) so cfg80211
676 * doesn't verify much. Note, however, that the passed netdev may be
677 * %NULL as well if the user requested changing the channel for the
678 * device itself, or for a monitor interface.
680 * @return int : Return 0 on Success
685 static int set_channel(struct wiphy
*wiphy
,
686 struct cfg80211_chan_def
*chandef
)
689 struct wilc_priv
*priv
;
692 priv
= wiphy_priv(wiphy
);
694 channelnum
= ieee80211_frequency_to_channel(chandef
->chan
->center_freq
);
695 PRINT_D(CFG80211_DBG
, "Setting channel %d with frequency %d\n", channelnum
, chandef
->chan
->center_freq
);
697 curr_channel
= channelnum
;
698 result
= wilc_set_mac_chnl_num(priv
->hWILCWFIDrv
, channelnum
);
701 PRINT_ER("Error in setting channel %d\n", channelnum
);
708 * @details Request to do a scan. If returning zero, the scan request is given
709 * the driver, and will be valid until passed to cfg80211_scan_done().
710 * For scan results, call cfg80211_inform_bss(); you can call this outside
711 * the scan/scan_done bracket too.
713 * @return int : Return 0 on Success
719 static int scan(struct wiphy
*wiphy
, struct cfg80211_scan_request
*request
)
721 struct wilc_priv
*priv
;
724 u8 au8ScanChanList
[MAX_NUM_SCANNED_NETWORKS
];
725 struct hidden_network strHiddenNetwork
;
727 priv
= wiphy_priv(wiphy
);
729 priv
->pstrScanReq
= request
;
731 priv
->u32RcvdChCount
= 0;
733 wilc_set_wfi_drv_handler(priv
->hWILCWFIDrv
);
736 reset_shadow_found(priv
);
738 priv
->bCfgScanning
= true;
739 if (request
->n_channels
<= MAX_NUM_SCANNED_NETWORKS
) { /* TODO: mostafa: to be replaced by */
741 for (i
= 0; i
< request
->n_channels
; i
++) {
742 au8ScanChanList
[i
] = (u8
)ieee80211_frequency_to_channel(request
->channels
[i
]->center_freq
);
743 PRINT_INFO(CFG80211_DBG
, "ScanChannel List[%d] = %d,", i
, au8ScanChanList
[i
]);
746 PRINT_D(CFG80211_DBG
, "Requested num of scan channel %d\n", request
->n_channels
);
747 PRINT_D(CFG80211_DBG
, "Scan Request IE len = %zu\n", request
->ie_len
);
749 PRINT_D(CFG80211_DBG
, "Number of SSIDs %d\n", request
->n_ssids
);
751 if (request
->n_ssids
>= 1) {
754 strHiddenNetwork
.pstrHiddenNetworkInfo
= kmalloc(request
->n_ssids
* sizeof(struct hidden_network
), GFP_KERNEL
);
755 strHiddenNetwork
.u8ssidnum
= request
->n_ssids
;
758 for (i
= 0; i
< request
->n_ssids
; i
++) {
760 if (request
->ssids
[i
].ssid
!= NULL
&& request
->ssids
[i
].ssid_len
!= 0) {
761 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
= kmalloc(request
->ssids
[i
].ssid_len
, GFP_KERNEL
);
762 memcpy(strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].pu8ssid
, request
->ssids
[i
].ssid
, request
->ssids
[i
].ssid_len
);
763 strHiddenNetwork
.pstrHiddenNetworkInfo
[i
].u8ssidlen
= request
->ssids
[i
].ssid_len
;
765 PRINT_D(CFG80211_DBG
, "Received one NULL SSID\n");
766 strHiddenNetwork
.u8ssidnum
-= 1;
769 PRINT_D(CFG80211_DBG
, "Trigger Scan Request\n");
770 s32Error
= wilc_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
771 au8ScanChanList
, request
->n_channels
,
772 (const u8
*)request
->ie
, request
->ie_len
,
773 CfgScanResult
, (void *)priv
, &strHiddenNetwork
);
775 PRINT_D(CFG80211_DBG
, "Trigger Scan Request\n");
776 s32Error
= wilc_scan(priv
->hWILCWFIDrv
, USER_SCAN
, ACTIVE_SCAN
,
777 au8ScanChanList
, request
->n_channels
,
778 (const u8
*)request
->ie
, request
->ie_len
,
779 CfgScanResult
, (void *)priv
, NULL
);
783 PRINT_ER("Requested num of scanned channels is greater than the max, supported"
789 PRINT_WRN(CFG80211_DBG
, "Device is busy: Error(%d)\n", s32Error
);
797 * @details Connect to the ESS with the specified parameters. When connected,
798 * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
799 * If the connection fails for some reason, call cfg80211_connect_result()
800 * with the status from the AP.
802 * @return int : Return 0 on Success
807 static int connect(struct wiphy
*wiphy
, struct net_device
*dev
,
808 struct cfg80211_connect_params
*sme
)
812 u8 u8security
= NO_ENCRYPT
;
813 enum AUTHTYPE tenuAuth_type
= ANY
;
814 char *pcgroup_encrypt_val
= NULL
;
815 char *pccipher_group
= NULL
;
816 char *pcwpa_version
= NULL
;
818 struct wilc_priv
*priv
;
819 struct host_if_drv
*pstrWFIDrv
;
820 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
824 priv
= wiphy_priv(wiphy
);
825 pstrWFIDrv
= (struct host_if_drv
*)(priv
->hWILCWFIDrv
);
827 wilc_set_wfi_drv_handler(priv
->hWILCWFIDrv
);
829 PRINT_D(CFG80211_DBG
, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme
->ssid
, dev
, priv
->hWILCWFIDrv
);
830 if (!(strncmp(sme
->ssid
, "DIRECT-", 7))) {
831 PRINT_D(CFG80211_DBG
, "Connected to Direct network,OBSS disabled\n");
832 pstrWFIDrv
->p2p_connect
= 1;
834 pstrWFIDrv
->p2p_connect
= 0;
836 PRINT_INFO(CFG80211_DBG
, "Required SSID = %s\n , AuthType = %d\n", sme
->ssid
, sme
->auth_type
);
838 for (i
= 0; i
< last_scanned_cnt
; i
++) {
839 if ((sme
->ssid_len
== last_scanned_shadow
[i
].u8SsidLen
) &&
840 memcmp(last_scanned_shadow
[i
].au8ssid
,
842 sme
->ssid_len
) == 0) {
843 PRINT_INFO(CFG80211_DBG
, "Network with required SSID is found %s\n", sme
->ssid
);
844 if (sme
->bssid
== NULL
) {
845 /* BSSID is not passed from the user, so decision of matching
846 * is done by SSID only */
847 PRINT_INFO(CFG80211_DBG
, "BSSID is not passed from the user\n");
850 /* BSSID is also passed from the user, so decision of matching
851 * should consider also this passed BSSID */
852 if (memcmp(last_scanned_shadow
[i
].au8bssid
,
855 PRINT_INFO(CFG80211_DBG
, "BSSID is passed from the user and matched\n");
862 if (i
< last_scanned_cnt
) {
863 PRINT_D(CFG80211_DBG
, "Required bss is in scan results\n");
865 pstrNetworkInfo
= &last_scanned_shadow
[i
];
867 PRINT_INFO(CFG80211_DBG
, "network BSSID to be associated: %x%x%x%x%x%x\n",
868 pstrNetworkInfo
->au8bssid
[0], pstrNetworkInfo
->au8bssid
[1],
869 pstrNetworkInfo
->au8bssid
[2], pstrNetworkInfo
->au8bssid
[3],
870 pstrNetworkInfo
->au8bssid
[4], pstrNetworkInfo
->au8bssid
[5]);
873 if (last_scanned_cnt
== 0)
874 PRINT_D(CFG80211_DBG
, "No Scan results yet\n");
876 PRINT_D(CFG80211_DBG
, "Required bss not in scan results: Error(%d)\n", s32Error
);
881 priv
->WILC_WFI_wep_default
= 0;
882 memset(priv
->WILC_WFI_wep_key
, 0, sizeof(priv
->WILC_WFI_wep_key
));
883 memset(priv
->WILC_WFI_wep_key_len
, 0, sizeof(priv
->WILC_WFI_wep_key_len
));
885 PRINT_INFO(CFG80211_DBG
, "sme->crypto.wpa_versions=%x\n", sme
->crypto
.wpa_versions
);
886 PRINT_INFO(CFG80211_DBG
, "sme->crypto.cipher_group=%x\n", sme
->crypto
.cipher_group
);
888 PRINT_INFO(CFG80211_DBG
, "sme->crypto.n_ciphers_pairwise=%d\n", sme
->crypto
.n_ciphers_pairwise
);
891 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++)
892 PRINT_D(CORECONFIG_DBG
, "sme->crypto.ciphers_pairwise[%d]=%x\n", i
, sme
->crypto
.ciphers_pairwise
[i
]);
895 if (sme
->crypto
.cipher_group
!= NO_ENCRYPT
) {
896 /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
897 * we will add to it the pairwise cipher suite(s) */
898 pcwpa_version
= "Default";
899 PRINT_D(CORECONFIG_DBG
, ">> sme->crypto.wpa_versions: %x\n", sme
->crypto
.wpa_versions
);
900 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP40
) {
901 u8security
= ENCRYPT_ENABLED
| WEP
;
902 pcgroup_encrypt_val
= "WEP40";
903 pccipher_group
= "WLAN_CIPHER_SUITE_WEP40";
904 PRINT_INFO(CFG80211_DBG
, "WEP Default Key Idx = %d\n", sme
->key_idx
);
907 for (i
= 0; i
< sme
->key_len
; i
++)
908 PRINT_D(CORECONFIG_DBG
, "WEP Key Value[%d] = %d\n", i
, sme
->key
[i
]);
910 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
911 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
912 memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
914 g_key_wep_params
.key_len
= sme
->key_len
;
915 g_key_wep_params
.key
= kmalloc(sme
->key_len
, GFP_KERNEL
);
916 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
917 g_key_wep_params
.key_idx
= sme
->key_idx
;
918 g_wep_keys_saved
= true;
920 wilc_set_wep_default_keyid(priv
->hWILCWFIDrv
, sme
->key_idx
);
921 wilc_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
922 } else if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_WEP104
) {
923 u8security
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
924 pcgroup_encrypt_val
= "WEP104";
925 pccipher_group
= "WLAN_CIPHER_SUITE_WEP104";
927 priv
->WILC_WFI_wep_default
= sme
->key_idx
;
928 priv
->WILC_WFI_wep_key_len
[sme
->key_idx
] = sme
->key_len
;
929 memcpy(priv
->WILC_WFI_wep_key
[sme
->key_idx
], sme
->key
, sme
->key_len
);
931 g_key_wep_params
.key_len
= sme
->key_len
;
932 g_key_wep_params
.key
= kmalloc(sme
->key_len
, GFP_KERNEL
);
933 memcpy(g_key_wep_params
.key
, sme
->key
, sme
->key_len
);
934 g_key_wep_params
.key_idx
= sme
->key_idx
;
935 g_wep_keys_saved
= true;
937 wilc_set_wep_default_keyid(priv
->hWILCWFIDrv
, sme
->key_idx
);
938 wilc_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, sme
->key
, sme
->key_len
, sme
->key_idx
);
939 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
) {
940 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
941 u8security
= ENCRYPT_ENABLED
| WPA2
| TKIP
;
942 pcgroup_encrypt_val
= "WPA2_TKIP";
943 pccipher_group
= "TKIP";
944 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
945 /* tenuSecurity_t = WPA2_AES; */
946 u8security
= ENCRYPT_ENABLED
| WPA2
| AES
;
947 pcgroup_encrypt_val
= "WPA2_AES";
948 pccipher_group
= "AES";
950 pcwpa_version
= "WPA_VERSION_2";
951 } else if (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
) {
952 if (sme
->crypto
.cipher_group
== WLAN_CIPHER_SUITE_TKIP
) {
953 u8security
= ENCRYPT_ENABLED
| WPA
| TKIP
;
954 pcgroup_encrypt_val
= "WPA_TKIP";
955 pccipher_group
= "TKIP";
956 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
957 /* tenuSecurity_t = WPA_AES; */
958 u8security
= ENCRYPT_ENABLED
| WPA
| AES
;
959 pcgroup_encrypt_val
= "WPA_AES";
960 pccipher_group
= "AES";
963 pcwpa_version
= "WPA_VERSION_1";
966 s32Error
= -ENOTSUPP
;
967 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
974 /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
975 * add to it the pairwise cipher suite(s) */
976 if ((sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_1
)
977 || (sme
->crypto
.wpa_versions
& NL80211_WPA_VERSION_2
)) {
978 for (i
= 0; i
< sme
->crypto
.n_ciphers_pairwise
; i
++) {
979 if (sme
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_TKIP
) {
980 u8security
= u8security
| TKIP
;
981 } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
982 u8security
= u8security
| AES
;
987 PRINT_D(CFG80211_DBG
, "Adding key with cipher group = %x\n", sme
->crypto
.cipher_group
);
989 PRINT_D(CFG80211_DBG
, "Authentication Type = %d\n", sme
->auth_type
);
990 switch (sme
->auth_type
) {
991 case NL80211_AUTHTYPE_OPEN_SYSTEM
:
992 PRINT_D(CFG80211_DBG
, "In OPEN SYSTEM\n");
993 tenuAuth_type
= OPEN_SYSTEM
;
996 case NL80211_AUTHTYPE_SHARED_KEY
:
997 tenuAuth_type
= SHARED_KEY
;
998 PRINT_D(CFG80211_DBG
, "In SHARED KEY\n");
1002 PRINT_D(CFG80211_DBG
, "Automatic Authentation type = %d\n", sme
->auth_type
);
1006 /* ai: key_mgmt: enterprise case */
1007 if (sme
->crypto
.n_akm_suites
) {
1008 switch (sme
->crypto
.akm_suites
[0]) {
1009 case WLAN_AKM_SUITE_8021X
:
1010 tenuAuth_type
= IEEE8021
;
1019 PRINT_INFO(CFG80211_DBG
, "Required Channel = %d\n", pstrNetworkInfo
->u8channel
);
1021 PRINT_INFO(CFG80211_DBG
, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
1022 pcgroup_encrypt_val
, pccipher_group
, pcwpa_version
);
1024 curr_channel
= pstrNetworkInfo
->u8channel
;
1026 if (!pstrWFIDrv
->p2p_connect
)
1027 wlan_channel
= pstrNetworkInfo
->u8channel
;
1029 wilc_wlan_set_bssid(dev
, pstrNetworkInfo
->au8bssid
);
1031 s32Error
= wilc_set_join_req(priv
->hWILCWFIDrv
, pstrNetworkInfo
->au8bssid
, sme
->ssid
,
1032 sme
->ssid_len
, sme
->ie
, sme
->ie_len
,
1033 CfgConnectResult
, (void *)priv
, u8security
,
1034 tenuAuth_type
, pstrNetworkInfo
->u8channel
,
1035 pstrNetworkInfo
->pJoinParams
);
1036 if (s32Error
!= 0) {
1037 PRINT_ER("wilc_set_join_req(): Error(%d)\n", s32Error
);
1050 * @details Disconnect from the BSS/ESS.
1052 * @return int : Return 0 on Success
1057 static int disconnect(struct wiphy
*wiphy
, struct net_device
*dev
, u16 reason_code
)
1060 struct wilc_priv
*priv
;
1061 struct host_if_drv
*pstrWFIDrv
;
1062 u8 NullBssid
[ETH_ALEN
] = {0};
1064 wilc_connecting
= 0;
1065 priv
= wiphy_priv(wiphy
);
1067 pstrWFIDrv
= (struct host_if_drv
*)priv
->hWILCWFIDrv
;
1068 if (!pstrWFIDrv
->p2p_connect
)
1069 wlan_channel
= INVALID_CHANNEL
;
1070 wilc_wlan_set_bssid(priv
->dev
, NullBssid
);
1072 PRINT_D(CFG80211_DBG
, "Disconnecting with reason code(%d)\n", reason_code
);
1074 p2p_local_random
= 0x01;
1075 p2p_recv_random
= 0x00;
1077 pstrWFIDrv
->p2p_timeout
= 0;
1079 s32Error
= wilc_disconnect(priv
->hWILCWFIDrv
, reason_code
);
1080 if (s32Error
!= 0) {
1081 PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error
);
1090 * @details Add a key with the given parameters. @mac_addr will be %NULL
1091 * when adding a group key.
1092 * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
1093 * @return int : Return 0 on Success
1098 static int add_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1100 const u8
*mac_addr
, struct key_params
*params
)
1103 s32 s32Error
= 0, KeyLen
= params
->key_len
;
1105 struct wilc_priv
*priv
;
1106 const u8
*pu8RxMic
= NULL
;
1107 const u8
*pu8TxMic
= NULL
;
1108 u8 u8mode
= NO_ENCRYPT
;
1109 u8 u8gmode
= NO_ENCRYPT
;
1110 u8 u8pmode
= NO_ENCRYPT
;
1111 enum AUTHTYPE tenuAuth_type
= ANY
;
1113 perInterface_wlan_t
*nic
;
1115 priv
= wiphy_priv(wiphy
);
1116 nic
= netdev_priv(netdev
);
1119 PRINT_D(CFG80211_DBG
, "Adding key with cipher suite = %x\n", params
->cipher
);
1121 PRINT_D(CFG80211_DBG
, "%p %p %d\n", wiphy
, netdev
, key_index
);
1123 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", params
->key
[0],
1128 switch (params
->cipher
) {
1129 case WLAN_CIPHER_SUITE_WEP40
:
1130 case WLAN_CIPHER_SUITE_WEP104
:
1131 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
) {
1133 priv
->WILC_WFI_wep_default
= key_index
;
1134 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1135 memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1137 PRINT_D(CFG80211_DBG
, "Adding AP WEP Default key Idx = %d\n", key_index
);
1138 PRINT_D(CFG80211_DBG
, "Adding AP WEP Key len= %d\n", params
->key_len
);
1140 for (i
= 0; i
< params
->key_len
; i
++)
1141 PRINT_D(CFG80211_DBG
, "WEP AP key val[%d] = %x\n", i
, params
->key
[i
]);
1143 tenuAuth_type
= OPEN_SYSTEM
;
1145 if (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
)
1146 u8mode
= ENCRYPT_ENABLED
| WEP
;
1148 u8mode
= ENCRYPT_ENABLED
| WEP
| WEP_EXTENDED
;
1150 wilc_add_wep_key_bss_ap(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
, u8mode
, tenuAuth_type
);
1153 if (memcmp(params
->key
, priv
->WILC_WFI_wep_key
[key_index
], params
->key_len
)) {
1154 priv
->WILC_WFI_wep_default
= key_index
;
1155 priv
->WILC_WFI_wep_key_len
[key_index
] = params
->key_len
;
1156 memcpy(priv
->WILC_WFI_wep_key
[key_index
], params
->key
, params
->key_len
);
1158 PRINT_D(CFG80211_DBG
, "Adding WEP Default key Idx = %d\n", key_index
);
1159 PRINT_D(CFG80211_DBG
, "Adding WEP Key length = %d\n", params
->key_len
);
1161 for (i
= 0; i
< params
->key_len
; i
++)
1162 PRINT_INFO(CFG80211_DBG
, "WEP key value[%d] = %d\n", i
, params
->key
[i
]);
1164 wilc_add_wep_key_bss_sta(priv
->hWILCWFIDrv
, params
->key
, params
->key_len
, key_index
);
1169 case WLAN_CIPHER_SUITE_TKIP
:
1170 case WLAN_CIPHER_SUITE_CCMP
:
1171 if (priv
->wdev
->iftype
== NL80211_IFTYPE_AP
|| priv
->wdev
->iftype
== NL80211_IFTYPE_P2P_GO
) {
1173 if (priv
->wilc_gtk
[key_index
] == NULL
) {
1174 priv
->wilc_gtk
[key_index
] = kmalloc(sizeof(struct wilc_wfi_key
), GFP_KERNEL
);
1175 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1176 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1179 if (priv
->wilc_ptk
[key_index
] == NULL
) {
1180 priv
->wilc_ptk
[key_index
] = kmalloc(sizeof(struct wilc_wfi_key
), GFP_KERNEL
);
1181 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1182 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1188 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1189 u8gmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1191 u8gmode
= ENCRYPT_ENABLED
| WPA2
| AES
;
1193 priv
->wilc_groupkey
= u8gmode
;
1195 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1197 pu8TxMic
= params
->key
+ 24;
1198 pu8RxMic
= params
->key
+ 16;
1199 KeyLen
= params
->key_len
- 16;
1201 /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
1202 kfree(priv
->wilc_gtk
[key_index
]->key
);
1204 priv
->wilc_gtk
[key_index
]->key
= kmalloc(params
->key_len
, GFP_KERNEL
);
1205 memcpy(priv
->wilc_gtk
[key_index
]->key
, params
->key
, params
->key_len
);
1207 /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
1208 kfree(priv
->wilc_gtk
[key_index
]->seq
);
1210 if ((params
->seq_len
) > 0) {
1211 priv
->wilc_gtk
[key_index
]->seq
= kmalloc(params
->seq_len
, GFP_KERNEL
);
1212 memcpy(priv
->wilc_gtk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1215 priv
->wilc_gtk
[key_index
]->cipher
= params
->cipher
;
1216 priv
->wilc_gtk
[key_index
]->key_len
= params
->key_len
;
1217 priv
->wilc_gtk
[key_index
]->seq_len
= params
->seq_len
;
1220 for (i
= 0; i
< params
->key_len
; i
++)
1221 PRINT_INFO(CFG80211_DBG
, "Adding group key value[%d] = %x\n", i
, params
->key
[i
]);
1222 for (i
= 0; i
< params
->seq_len
; i
++)
1223 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1227 wilc_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1228 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, AP_MODE
, u8gmode
);
1231 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]);
1233 if (params
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
1234 u8pmode
= ENCRYPT_ENABLED
| WPA
| TKIP
;
1236 u8pmode
= priv
->wilc_groupkey
| AES
;
1239 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1241 pu8TxMic
= params
->key
+ 24;
1242 pu8RxMic
= params
->key
+ 16;
1243 KeyLen
= params
->key_len
- 16;
1246 kfree(priv
->wilc_ptk
[key_index
]->key
);
1248 priv
->wilc_ptk
[key_index
]->key
= kmalloc(params
->key_len
, GFP_KERNEL
);
1250 kfree(priv
->wilc_ptk
[key_index
]->seq
);
1252 if ((params
->seq_len
) > 0)
1253 priv
->wilc_ptk
[key_index
]->seq
= kmalloc(params
->seq_len
, GFP_KERNEL
);
1256 for (i
= 0; i
< params
->key_len
; i
++)
1257 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %x\n", i
, params
->key
[i
]);
1259 for (i
= 0; i
< params
->seq_len
; i
++)
1260 PRINT_INFO(CFG80211_DBG
, "Adding group seq value[%d] = %x\n", i
, params
->seq
[i
]);
1263 memcpy(priv
->wilc_ptk
[key_index
]->key
, params
->key
, params
->key_len
);
1265 if ((params
->seq_len
) > 0)
1266 memcpy(priv
->wilc_ptk
[key_index
]->seq
, params
->seq
, params
->seq_len
);
1268 priv
->wilc_ptk
[key_index
]->cipher
= params
->cipher
;
1269 priv
->wilc_ptk
[key_index
]->key_len
= params
->key_len
;
1270 priv
->wilc_ptk
[key_index
]->seq_len
= params
->seq_len
;
1272 wilc_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1273 pu8RxMic
, pu8TxMic
, AP_MODE
, u8pmode
, key_index
);
1281 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1282 /* swap the tx mic by rx mic */
1283 pu8RxMic
= params
->key
+ 24;
1284 pu8TxMic
= params
->key
+ 16;
1285 KeyLen
= params
->key_len
- 16;
1288 /*save keys only on interface 0 (wifi interface)*/
1289 if (!g_gtk_keys_saved
&& netdev
== wl
->vif
[0].ndev
) {
1290 g_add_gtk_key_params
.key_idx
= key_index
;
1291 g_add_gtk_key_params
.pairwise
= pairwise
;
1293 g_add_gtk_key_params
.mac_addr
= NULL
;
1295 g_add_gtk_key_params
.mac_addr
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
1296 memcpy(g_add_gtk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1298 g_key_gtk_params
.key_len
= params
->key_len
;
1299 g_key_gtk_params
.seq_len
= params
->seq_len
;
1300 g_key_gtk_params
.key
= kmalloc(params
->key_len
, GFP_KERNEL
);
1301 memcpy(g_key_gtk_params
.key
, params
->key
, params
->key_len
);
1302 if (params
->seq_len
> 0) {
1303 g_key_gtk_params
.seq
= kmalloc(params
->seq_len
, GFP_KERNEL
);
1304 memcpy(g_key_gtk_params
.seq
, params
->seq
, params
->seq_len
);
1306 g_key_gtk_params
.cipher
= params
->cipher
;
1308 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_gtk_params
.key
[0],
1309 g_key_gtk_params
.key
[1],
1310 g_key_gtk_params
.key
[2]);
1311 g_gtk_keys_saved
= true;
1314 wilc_add_rx_gtk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
,
1315 key_index
, params
->seq_len
, params
->seq
, pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
);
1317 if (params
->key_len
> 16 && params
->cipher
== WLAN_CIPHER_SUITE_TKIP
) {
1318 /* swap the tx mic by rx mic */
1319 pu8RxMic
= params
->key
+ 24;
1320 pu8TxMic
= params
->key
+ 16;
1321 KeyLen
= params
->key_len
- 16;
1324 /*save keys only on interface 0 (wifi interface)*/
1325 if (!g_ptk_keys_saved
&& netdev
== wl
->vif
[0].ndev
) {
1326 g_add_ptk_key_params
.key_idx
= key_index
;
1327 g_add_ptk_key_params
.pairwise
= pairwise
;
1329 g_add_ptk_key_params
.mac_addr
= NULL
;
1331 g_add_ptk_key_params
.mac_addr
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
1332 memcpy(g_add_ptk_key_params
.mac_addr
, mac_addr
, ETH_ALEN
);
1334 g_key_ptk_params
.key_len
= params
->key_len
;
1335 g_key_ptk_params
.seq_len
= params
->seq_len
;
1336 g_key_ptk_params
.key
= kmalloc(params
->key_len
, GFP_KERNEL
);
1337 memcpy(g_key_ptk_params
.key
, params
->key
, params
->key_len
);
1338 if (params
->seq_len
> 0) {
1339 g_key_ptk_params
.seq
= kmalloc(params
->seq_len
, GFP_KERNEL
);
1340 memcpy(g_key_ptk_params
.seq
, params
->seq
, params
->seq_len
);
1342 g_key_ptk_params
.cipher
= params
->cipher
;
1344 PRINT_D(CFG80211_DBG
, "key %x %x %x\n", g_key_ptk_params
.key
[0],
1345 g_key_ptk_params
.key
[1],
1346 g_key_ptk_params
.key
[2]);
1347 g_ptk_keys_saved
= true;
1350 wilc_add_ptk(priv
->hWILCWFIDrv
, params
->key
, KeyLen
, mac_addr
,
1351 pu8RxMic
, pu8TxMic
, STATION_MODE
, u8mode
, key_index
);
1352 PRINT_D(CFG80211_DBG
, "Adding pairwise key\n");
1354 for (i
= 0; i
< params
->key_len
; i
++)
1355 PRINT_INFO(CFG80211_DBG
, "Adding pairwise key value[%d] = %d\n", i
, params
->key
[i
]);
1362 PRINT_ER("Not supported cipher: Error(%d)\n", s32Error
);
1363 s32Error
= -ENOTSUPP
;
1372 * @details Remove a key given the @mac_addr (%NULL for a group key)
1373 * and @key_index, return -ENOENT if the key doesn't exist.
1375 * @return int : Return 0 on Success
1380 static int del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
1385 struct wilc_priv
*priv
;
1387 perInterface_wlan_t
*nic
;
1389 priv
= wiphy_priv(wiphy
);
1390 nic
= netdev_priv(netdev
);
1393 /*delete saved keys, if any*/
1394 if (netdev
== wl
->vif
[0].ndev
) {
1395 g_ptk_keys_saved
= false;
1396 g_gtk_keys_saved
= false;
1397 g_wep_keys_saved
= false;
1399 /*Delete saved WEP keys params, if any*/
1400 kfree(g_key_wep_params
.key
);
1401 g_key_wep_params
.key
= NULL
;
1403 /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
1405 if ((priv
->wilc_gtk
[key_index
]) != NULL
) {
1407 kfree(priv
->wilc_gtk
[key_index
]->key
);
1408 priv
->wilc_gtk
[key_index
]->key
= NULL
;
1409 kfree(priv
->wilc_gtk
[key_index
]->seq
);
1410 priv
->wilc_gtk
[key_index
]->seq
= NULL
;
1412 kfree(priv
->wilc_gtk
[key_index
]);
1413 priv
->wilc_gtk
[key_index
] = NULL
;
1417 if ((priv
->wilc_ptk
[key_index
]) != NULL
) {
1419 kfree(priv
->wilc_ptk
[key_index
]->key
);
1420 priv
->wilc_ptk
[key_index
]->key
= NULL
;
1421 kfree(priv
->wilc_ptk
[key_index
]->seq
);
1422 priv
->wilc_ptk
[key_index
]->seq
= NULL
;
1423 kfree(priv
->wilc_ptk
[key_index
]);
1424 priv
->wilc_ptk
[key_index
] = NULL
;
1427 /*Delete saved PTK and GTK keys params, if any*/
1428 kfree(g_key_ptk_params
.key
);
1429 g_key_ptk_params
.key
= NULL
;
1430 kfree(g_key_ptk_params
.seq
);
1431 g_key_ptk_params
.seq
= NULL
;
1433 kfree(g_key_gtk_params
.key
);
1434 g_key_gtk_params
.key
= NULL
;
1435 kfree(g_key_gtk_params
.seq
);
1436 g_key_gtk_params
.seq
= NULL
;
1438 /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
1439 wilc_set_machw_change_vir_if(netdev
, false);
1442 if (key_index
>= 0 && key_index
<= 3) {
1443 memset(priv
->WILC_WFI_wep_key
[key_index
], 0, priv
->WILC_WFI_wep_key_len
[key_index
]);
1444 priv
->WILC_WFI_wep_key_len
[key_index
] = 0;
1446 PRINT_D(CFG80211_DBG
, "Removing WEP key with index = %d\n", key_index
);
1447 wilc_remove_wep_key(priv
->hWILCWFIDrv
, key_index
);
1449 PRINT_D(CFG80211_DBG
, "Removing all installed keys\n");
1450 wilc_remove_key(priv
->hWILCWFIDrv
, mac_addr
);
1458 * @details Get information about the key with the given parameters.
1459 * @mac_addr will be %NULL when requesting information for a group
1460 * key. All pointers given to the @callback function need not be valid
1461 * after it returns. This function should return an error if it is
1462 * not possible to retrieve the key, -ENOENT if it doesn't exist.
1464 * @return int : Return 0 on Success
1469 static int get_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1471 const u8
*mac_addr
, void *cookie
, void (*callback
)(void *cookie
, struct key_params
*))
1473 struct wilc_priv
*priv
;
1474 struct key_params key_params
;
1477 priv
= wiphy_priv(wiphy
);
1481 PRINT_D(CFG80211_DBG
, "Getting group key idx: %x\n", key_index
);
1483 key_params
.key
= priv
->wilc_gtk
[key_index
]->key
;
1484 key_params
.cipher
= priv
->wilc_gtk
[key_index
]->cipher
;
1485 key_params
.key_len
= priv
->wilc_gtk
[key_index
]->key_len
;
1486 key_params
.seq
= priv
->wilc_gtk
[key_index
]->seq
;
1487 key_params
.seq_len
= priv
->wilc_gtk
[key_index
]->seq_len
;
1489 for (i
= 0; i
< key_params
.key_len
; i
++)
1490 PRINT_INFO(CFG80211_DBG
, "Retrieved key value %x\n", key_params
.key
[i
]);
1493 PRINT_D(CFG80211_DBG
, "Getting pairwise key\n");
1495 key_params
.key
= priv
->wilc_ptk
[key_index
]->key
;
1496 key_params
.cipher
= priv
->wilc_ptk
[key_index
]->cipher
;
1497 key_params
.key_len
= priv
->wilc_ptk
[key_index
]->key_len
;
1498 key_params
.seq
= priv
->wilc_ptk
[key_index
]->seq
;
1499 key_params
.seq_len
= priv
->wilc_ptk
[key_index
]->seq_len
;
1502 callback(cookie
, &key_params
);
1504 return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
1508 * @brief set_default_key
1509 * @details Set the default management frame key on an interface
1511 * @return int : Return 0 on Success.
1516 static int set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
, u8 key_index
,
1517 bool unicast
, bool multicast
)
1519 struct wilc_priv
*priv
;
1522 priv
= wiphy_priv(wiphy
);
1524 PRINT_D(CFG80211_DBG
, "Setting default key with idx = %d\n", key_index
);
1526 if (key_index
!= priv
->WILC_WFI_wep_default
) {
1528 wilc_set_wep_default_keyid(priv
->hWILCWFIDrv
, key_index
);
1535 * @brief get_station
1536 * @details Get station information for the station identified by @mac
1538 * @return int : Return 0 on Success.
1544 static int get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1545 const u8
*mac
, struct station_info
*sinfo
)
1547 struct wilc_priv
*priv
;
1548 perInterface_wlan_t
*nic
;
1550 u32 associatedsta
= 0;
1551 u32 inactive_time
= 0;
1552 priv
= wiphy_priv(wiphy
);
1553 nic
= netdev_priv(dev
);
1555 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
1556 PRINT_D(HOSTAPD_DBG
, "Getting station parameters\n");
1558 PRINT_INFO(HOSTAPD_DBG
, ": %x%x%x%x%x\n", mac
[0], mac
[1], mac
[2], mac
[3], mac
[4]);
1560 for (i
= 0; i
< NUM_STA_ASSOCIATED
; i
++) {
1562 if (!(memcmp(mac
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
[i
], ETH_ALEN
))) {
1569 if (associatedsta
== -1) {
1570 PRINT_ER("Station required is not associated\n");
1574 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
);
1576 wilc_get_inactive_time(priv
->hWILCWFIDrv
, mac
, &(inactive_time
));
1577 sinfo
->inactive_time
= 1000 * inactive_time
;
1578 PRINT_D(CFG80211_DBG
, "Inactive time %d\n", sinfo
->inactive_time
);
1582 if (nic
->iftype
== STATION_MODE
) {
1583 struct rf_info strStatistics
;
1585 wilc_get_statistics(priv
->hWILCWFIDrv
, &strStatistics
);
1587 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
) |
1588 BIT(NL80211_STA_INFO_RX_PACKETS
) |
1589 BIT(NL80211_STA_INFO_TX_PACKETS
) |
1590 BIT(NL80211_STA_INFO_TX_FAILED
) |
1591 BIT(NL80211_STA_INFO_TX_BITRATE
);
1593 sinfo
->signal
= strStatistics
.rssi
;
1594 sinfo
->rx_packets
= strStatistics
.rx_cnt
;
1595 sinfo
->tx_packets
= strStatistics
.tx_cnt
+ strStatistics
.tx_fail_cnt
;
1596 sinfo
->tx_failed
= strStatistics
.tx_fail_cnt
;
1597 sinfo
->txrate
.legacy
= strStatistics
.link_speed
* 10;
1599 if ((strStatistics
.link_speed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
) &&
1600 (strStatistics
.link_speed
!= DEFAULT_LINK_SPEED
))
1601 wilc_enable_tcp_ack_filter(true);
1602 else if (strStatistics
.link_speed
!= DEFAULT_LINK_SPEED
)
1603 wilc_enable_tcp_ack_filter(false);
1605 PRINT_D(CORECONFIG_DBG
, "*** stats[%d][%d][%d][%d][%d]\n", sinfo
->signal
, sinfo
->rx_packets
, sinfo
->tx_packets
,
1606 sinfo
->tx_failed
, sinfo
->txrate
.legacy
);
1614 * @details Modify parameters for a given BSS.
1616 * -use_cts_prot: Whether to use CTS protection
1617 * (0 = no, 1 = yes, -1 = do not change)
1618 * -use_short_preamble: Whether the use of short preambles is allowed
1619 * (0 = no, 1 = yes, -1 = do not change)
1620 * -use_short_slot_time: Whether the use of short slot time is allowed
1621 * (0 = no, 1 = yes, -1 = do not change)
1622 * -basic_rates: basic rates in IEEE 802.11 format
1623 * (or NULL for no change)
1624 * -basic_rates_len: number of basic rates
1625 * -ap_isolate: do not forward packets between connected stations
1626 * -ht_opmode: HT Operation mode
1627 * (u16 = opmode, -1 = do not change)
1628 * @return int : Return 0 on Success.
1633 static int change_bss(struct wiphy
*wiphy
, struct net_device
*dev
,
1634 struct bss_parameters
*params
)
1636 PRINT_D(CFG80211_DBG
, "Changing Bss parametrs\n");
1641 * @brief set_wiphy_params
1642 * @details Notify that wiphy parameters have changed;
1643 * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
1645 * @return int : Return 0 on Success
1650 static int set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1653 struct cfg_param_val pstrCfgParamVal
;
1654 struct wilc_priv
*priv
;
1656 priv
= wiphy_priv(wiphy
);
1658 pstrCfgParamVal
.flag
= 0;
1659 PRINT_D(CFG80211_DBG
, "Setting Wiphy params\n");
1661 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
1662 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
1663 priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
);
1664 pstrCfgParamVal
.flag
|= RETRY_SHORT
;
1665 pstrCfgParamVal
.short_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_short
;
1667 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
1669 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
);
1670 pstrCfgParamVal
.flag
|= RETRY_LONG
;
1671 pstrCfgParamVal
.long_retry_limit
= priv
->dev
->ieee80211_ptr
->wiphy
->retry_long
;
1674 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
1675 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
);
1676 pstrCfgParamVal
.flag
|= FRAG_THRESHOLD
;
1677 pstrCfgParamVal
.frag_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->frag_threshold
;
1681 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
1682 PRINT_D(CFG80211_DBG
, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
);
1684 pstrCfgParamVal
.flag
|= RTS_THRESHOLD
;
1685 pstrCfgParamVal
.rts_threshold
= priv
->dev
->ieee80211_ptr
->wiphy
->rts_threshold
;
1689 PRINT_D(CFG80211_DBG
, "Setting CFG params in the host interface\n");
1690 s32Error
= wilc_hif_set_cfg(priv
->hWILCWFIDrv
, &pstrCfgParamVal
);
1692 PRINT_ER("Error in setting WIPHY PARAMS\n");
1700 * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
1701 * devices running firmwares capable of generating the (re) association
1702 * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
1704 * @return int : Return 0 on Success
1709 static int set_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1710 struct cfg80211_pmksa
*pmksa
)
1716 struct wilc_priv
*priv
= wiphy_priv(wiphy
);
1718 PRINT_D(CFG80211_DBG
, "Setting PMKSA\n");
1721 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1722 if (!memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1724 /*If bssid already exists and pmkid value needs to reset*/
1726 PRINT_D(CFG80211_DBG
, "PMKID already exists\n");
1730 if (i
< WILC_MAX_NUM_PMKIDS
) {
1731 PRINT_D(CFG80211_DBG
, "Setting PMKID in private structure\n");
1732 memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
, pmksa
->bssid
,
1734 memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
, pmksa
->pmkid
,
1736 if (!(flag
== PMKID_FOUND
))
1737 priv
->pmkid_list
.numpmkid
++;
1739 PRINT_ER("Invalid PMKID index\n");
1744 PRINT_D(CFG80211_DBG
, "Setting pmkid in the host interface\n");
1745 s32Error
= wilc_set_pmkid_info(priv
->hWILCWFIDrv
, &priv
->pmkid_list
);
1752 * @details Delete a cached PMKID.
1754 * @return int : Return 0 on Success
1759 static int del_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
,
1760 struct cfg80211_pmksa
*pmksa
)
1766 struct wilc_priv
*priv
= wiphy_priv(wiphy
);
1768 PRINT_D(CFG80211_DBG
, "Deleting PMKSA keys\n");
1770 for (i
= 0; i
< priv
->pmkid_list
.numpmkid
; i
++) {
1771 if (!memcmp(pmksa
->bssid
, priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1773 /*If bssid is found, reset the values*/
1774 PRINT_D(CFG80211_DBG
, "Reseting PMKID values\n");
1775 memset(&priv
->pmkid_list
.pmkidlist
[i
], 0, sizeof(struct host_if_pmkid
));
1780 if (i
< priv
->pmkid_list
.numpmkid
&& priv
->pmkid_list
.numpmkid
> 0) {
1781 for (; i
< (priv
->pmkid_list
.numpmkid
- 1); i
++) {
1782 memcpy(priv
->pmkid_list
.pmkidlist
[i
].bssid
,
1783 priv
->pmkid_list
.pmkidlist
[i
+ 1].bssid
,
1785 memcpy(priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1786 priv
->pmkid_list
.pmkidlist
[i
].pmkid
,
1789 priv
->pmkid_list
.numpmkid
--;
1798 * @brief flush_pmksa
1799 * @details Flush all cached PMKIDs.
1801 * @return int : Return 0 on Success
1806 static int flush_pmksa(struct wiphy
*wiphy
, struct net_device
*netdev
)
1808 struct wilc_priv
*priv
= wiphy_priv(wiphy
);
1810 PRINT_D(CFG80211_DBG
, "Flushing PMKID key values\n");
1812 /*Get cashed Pmkids and set all with zeros*/
1813 memset(&priv
->pmkid_list
, 0, sizeof(struct host_if_pmkid_attr
));
1820 * @brief WILC_WFI_CfgParseRxAction
1821 * @details Function parses the received frames and modifies the following attributes:
1824 * -Operating Channel
1826 * @param[in] u8* Buffer, u32 length
1833 static void WILC_WFI_CfgParseRxAction(u8
*buf
, u32 len
)
1838 u8 op_channel_attr_index
= 0;
1839 u8 channel_list_attr_index
= 0;
1841 while (index
< len
) {
1842 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
1843 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x00 << 1);
1846 if (buf
[index
] == CHANLIST_ATTR_ID
)
1847 channel_list_attr_index
= index
;
1848 else if (buf
[index
] == OPERCHAN_ATTR_ID
)
1849 op_channel_attr_index
= index
;
1850 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
1852 if (wlan_channel
!= INVALID_CHANNEL
) {
1853 /*Modify channel list attribute*/
1854 if (channel_list_attr_index
) {
1855 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
1856 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
1857 if (buf
[i
] == 0x51) {
1858 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
1859 buf
[j
] = wlan_channel
;
1865 /*Modify operating channel attribute*/
1866 if (op_channel_attr_index
) {
1867 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
1868 buf
[op_channel_attr_index
+ 6] = 0x51;
1869 buf
[op_channel_attr_index
+ 7] = wlan_channel
;
1875 * @brief WILC_WFI_CfgParseTxAction
1876 * @details Function parses the transmitted action frames and modifies the
1877 * GO Intent attribute
1878 * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
1884 static void WILC_WFI_CfgParseTxAction(u8
*buf
, u32 len
, bool bOperChan
, u8 iftype
)
1889 u8 op_channel_attr_index
= 0;
1890 u8 channel_list_attr_index
= 0;
1892 while (index
< len
) {
1893 if (buf
[index
] == GO_INTENT_ATTR_ID
) {
1894 buf
[index
+ 3] = (buf
[index
+ 3] & 0x01) | (0x0f << 1);
1899 if (buf
[index
] == CHANLIST_ATTR_ID
)
1900 channel_list_attr_index
= index
;
1901 else if (buf
[index
] == OPERCHAN_ATTR_ID
)
1902 op_channel_attr_index
= index
;
1903 index
+= buf
[index
+ 1] + 3; /* ID,Length byte */
1905 if (wlan_channel
!= INVALID_CHANNEL
&& bOperChan
) {
1906 /*Modify channel list attribute*/
1907 if (channel_list_attr_index
) {
1908 PRINT_D(GENERIC_DBG
, "Modify channel list attribute\n");
1909 for (i
= channel_list_attr_index
+ 3; i
< ((channel_list_attr_index
+ 3) + buf
[channel_list_attr_index
+ 1]); i
++) {
1910 if (buf
[i
] == 0x51) {
1911 for (j
= i
+ 2; j
< ((i
+ 2) + buf
[i
+ 1]); j
++) {
1912 buf
[j
] = wlan_channel
;
1918 /*Modify operating channel attribute*/
1919 if (op_channel_attr_index
) {
1920 PRINT_D(GENERIC_DBG
, "Modify operating channel attribute\n");
1921 buf
[op_channel_attr_index
+ 6] = 0x51;
1922 buf
[op_channel_attr_index
+ 7] = wlan_channel
;
1927 /* @brief WILC_WFI_p2p_rx
1932 * @author Mai Daftedar
1937 void WILC_WFI_p2p_rx (struct net_device
*dev
, u8
*buff
, u32 size
)
1940 struct wilc_priv
*priv
;
1941 u32 header
, pkt_offset
;
1942 struct host_if_drv
*pstrWFIDrv
;
1946 priv
= wiphy_priv(dev
->ieee80211_ptr
->wiphy
);
1947 pstrWFIDrv
= (struct host_if_drv
*)priv
->hWILCWFIDrv
;
1949 /* Get WILC header */
1950 memcpy(&header
, (buff
- HOST_HDR_OFFSET
), HOST_HDR_OFFSET
);
1952 /* The packet offset field conain info about what type of managment frame */
1953 /* we are dealing with and ack status */
1954 pkt_offset
= GET_PKT_OFFSET(header
);
1956 if (pkt_offset
& IS_MANAGMEMENT_CALLBACK
) {
1957 if (buff
[FRAME_TYPE_ID
] == IEEE80211_STYPE_PROBE_RESP
) {
1958 PRINT_D(GENERIC_DBG
, "Probe response ACK\n");
1959 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
1962 if (pkt_offset
& IS_MGMT_STATUS_SUCCES
) {
1963 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
],
1964 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
1965 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, true, GFP_KERNEL
);
1967 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
],
1968 buff
[ACTION_SUBTYPE_ID
+ 1], buff
[P2P_PUB_ACTION_SUBTYPE
+ 1]);
1969 cfg80211_mgmt_tx_status(priv
->wdev
, priv
->u64tx_cookie
, buff
, size
, false, GFP_KERNEL
);
1975 PRINT_D(GENERIC_DBG
, "Rx Frame Type:%x\n", buff
[FRAME_TYPE_ID
]);
1977 /*Upper layer is informed that the frame is received on this freq*/
1978 s32Freq
= ieee80211_channel_to_frequency(curr_channel
, IEEE80211_BAND_2GHZ
);
1980 if (ieee80211_is_action(buff
[FRAME_TYPE_ID
])) {
1981 PRINT_D(GENERIC_DBG
, "Rx Action Frame Type: %x %x\n", buff
[ACTION_SUBTYPE_ID
], buff
[P2P_PUB_ACTION_SUBTYPE
]);
1983 if (priv
->bCfgScanning
&& time_after_eq(jiffies
, (unsigned long)pstrWFIDrv
->p2p_timeout
)) {
1984 PRINT_D(GENERIC_DBG
, "Receiving action frames from wrong channels\n");
1987 if (buff
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
1989 switch (buff
[ACTION_SUBTYPE_ID
]) {
1990 case GAS_INTIAL_REQ
:
1991 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buff
[ACTION_SUBTYPE_ID
]);
1994 case GAS_INTIAL_RSP
:
1995 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buff
[ACTION_SUBTYPE_ID
]);
1998 case PUBLIC_ACT_VENDORSPEC
:
1999 if (!memcmp(p2p_oui
, &buff
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2000 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2002 for (i
= P2P_PUB_ACTION_SUBTYPE
; i
< size
; i
++) {
2003 if (!memcmp(p2p_vendor_spec
, &buff
[i
], 6)) {
2004 p2p_recv_random
= buff
[i
+ 6];
2006 PRINT_D(GENERIC_DBG
, "WILC Vendor specific IE:%02x\n", p2p_recv_random
);
2012 if (p2p_local_random
> p2p_recv_random
) {
2013 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2014 || buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2015 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< size
; i
++) {
2016 if (buff
[i
] == P2PELEM_ATTR_ID
&& !(memcmp(p2p_oui
, &buff
[i
+ 2], 4))) {
2017 WILC_WFI_CfgParseRxAction(&buff
[i
+ 6], size
- (i
+ 6));
2023 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random
, p2p_recv_random
);
2028 if ((buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buff
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
) && (wilc_ie
)) {
2029 PRINT_D(GENERIC_DBG
, "Sending P2P to host without extra elemnt\n");
2030 /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
2031 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2037 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff
[ACTION_SUBTYPE_ID
]);
2043 cfg80211_rx_mgmt(priv
->wdev
, s32Freq
, 0, buff
, size
- 7, 0);
2048 * @brief WILC_WFI_mgmt_tx_complete
2049 * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
2051 * transmitting status
2053 * @author Amr Abdelmoghny
2057 static void WILC_WFI_mgmt_tx_complete(void *priv
, int status
)
2059 struct p2p_mgmt_data
*pv_data
= (struct p2p_mgmt_data
*)priv
;
2062 kfree(pv_data
->buff
);
2067 * @brief WILC_WFI_RemainOnChannelReady
2068 * @details Callback function, called from handle_remain_on_channel on being ready on channel
2071 * @author Amr abdelmoghny
2076 static void WILC_WFI_RemainOnChannelReady(void *pUserVoid
)
2078 struct wilc_priv
*priv
;
2080 priv
= (struct wilc_priv
*)pUserVoid
;
2082 PRINT_D(HOSTINF_DBG
, "Remain on channel ready\n");
2084 priv
->bInP2PlistenState
= true;
2086 cfg80211_ready_on_channel(priv
->wdev
,
2087 priv
->strRemainOnChanParams
.u64ListenCookie
,
2088 priv
->strRemainOnChanParams
.pstrListenChan
,
2089 priv
->strRemainOnChanParams
.u32ListenDuration
,
2094 * @brief WILC_WFI_RemainOnChannelExpired
2095 * @details Callback function, called on expiration of remain-on-channel duration
2098 * @author Amr abdelmoghny
2103 static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid
, u32 u32SessionID
)
2105 struct wilc_priv
*priv
;
2107 priv
= (struct wilc_priv
*)pUserVoid
;
2109 if (u32SessionID
== priv
->strRemainOnChanParams
.u32ListenSessionID
) {
2110 PRINT_D(GENERIC_DBG
, "Remain on channel expired\n");
2112 priv
->bInP2PlistenState
= false;
2114 /*Inform wpas of remain-on-channel expiration*/
2115 cfg80211_remain_on_channel_expired(priv
->wdev
,
2116 priv
->strRemainOnChanParams
.u64ListenCookie
,
2117 priv
->strRemainOnChanParams
.pstrListenChan
,
2120 PRINT_D(GENERIC_DBG
, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
2121 , priv
->strRemainOnChanParams
.u32ListenSessionID
);
2127 * @brief remain_on_channel
2128 * @details Request the driver to remain awake on the specified
2129 * channel for the specified duration to complete an off-channel
2130 * operation (e.g., public action frame exchange). When the driver is
2131 * ready on the requested channel, it must indicate this with an event
2132 * notification by calling cfg80211_ready_on_channel().
2134 * @return int : Return 0 on Success
2139 static int remain_on_channel(struct wiphy
*wiphy
,
2140 struct wireless_dev
*wdev
,
2141 struct ieee80211_channel
*chan
,
2142 unsigned int duration
, u64
*cookie
)
2145 struct wilc_priv
*priv
;
2147 priv
= wiphy_priv(wiphy
);
2149 PRINT_D(GENERIC_DBG
, "Remaining on channel %d\n", chan
->hw_value
);
2152 if (wdev
->iftype
== NL80211_IFTYPE_AP
) {
2153 PRINT_D(GENERIC_DBG
, "Required remain-on-channel while in AP mode");
2157 curr_channel
= chan
->hw_value
;
2159 /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
2160 priv
->strRemainOnChanParams
.pstrListenChan
= chan
;
2161 priv
->strRemainOnChanParams
.u64ListenCookie
= *cookie
;
2162 priv
->strRemainOnChanParams
.u32ListenDuration
= duration
;
2163 priv
->strRemainOnChanParams
.u32ListenSessionID
++;
2165 s32Error
= wilc_remain_on_channel(priv
->hWILCWFIDrv
2166 , priv
->strRemainOnChanParams
.u32ListenSessionID
2169 , WILC_WFI_RemainOnChannelExpired
2170 , WILC_WFI_RemainOnChannelReady
2177 * @brief cancel_remain_on_channel
2178 * @details Cancel an on-going remain-on-channel operation.
2179 * This allows the operation to be terminated prior to timeout based on
2180 * the duration value.
2181 * @param[in] struct wiphy *wiphy,
2182 * @param[in] struct net_device *dev
2183 * @param[in] u64 cookie,
2184 * @return int : Return 0 on Success
2189 static int cancel_remain_on_channel(struct wiphy
*wiphy
,
2190 struct wireless_dev
*wdev
,
2194 struct wilc_priv
*priv
;
2196 priv
= wiphy_priv(wiphy
);
2198 PRINT_D(CFG80211_DBG
, "Cancel remain on channel\n");
2200 s32Error
= wilc_listen_state_expired(priv
->hWILCWFIDrv
, priv
->strRemainOnChanParams
.u32ListenSessionID
);
2204 * @brief WILC_WFI_mgmt_tx_frame
2213 static int mgmt_tx(struct wiphy
*wiphy
,
2214 struct wireless_dev
*wdev
,
2215 struct cfg80211_mgmt_tx_params
*params
,
2218 struct ieee80211_channel
*chan
= params
->chan
;
2219 unsigned int wait
= params
->wait
;
2220 const u8
*buf
= params
->buf
;
2221 size_t len
= params
->len
;
2222 const struct ieee80211_mgmt
*mgmt
;
2223 struct p2p_mgmt_data
*mgmt_tx
;
2224 struct wilc_priv
*priv
;
2225 struct host_if_drv
*pstrWFIDrv
;
2227 perInterface_wlan_t
*nic
;
2228 u32 buf_len
= len
+ sizeof(p2p_vendor_spec
) + sizeof(p2p_local_random
);
2230 nic
= netdev_priv(wdev
->netdev
);
2231 priv
= wiphy_priv(wiphy
);
2232 pstrWFIDrv
= (struct host_if_drv
*)priv
->hWILCWFIDrv
;
2234 *cookie
= (unsigned long)buf
;
2235 priv
->u64tx_cookie
= *cookie
;
2236 mgmt
= (const struct ieee80211_mgmt
*) buf
;
2238 if (ieee80211_is_mgmt(mgmt
->frame_control
)) {
2240 /*mgmt frame allocation*/
2241 mgmt_tx
= kmalloc(sizeof(struct p2p_mgmt_data
), GFP_KERNEL
);
2242 if (mgmt_tx
== NULL
) {
2243 PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
2246 mgmt_tx
->buff
= kmalloc(buf_len
, GFP_KERNEL
);
2247 if (mgmt_tx
->buff
== NULL
) {
2248 PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
2252 memcpy(mgmt_tx
->buff
, buf
, len
);
2253 mgmt_tx
->size
= len
;
2256 if (ieee80211_is_probe_resp(mgmt
->frame_control
)) {
2257 PRINT_D(GENERIC_DBG
, "TX: Probe Response\n");
2258 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2259 wilc_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2260 /*Save the current channel after we tune to it*/
2261 curr_channel
= chan
->hw_value
;
2262 } else if (ieee80211_is_action(mgmt
->frame_control
)) {
2263 PRINT_D(GENERIC_DBG
, "ACTION FRAME:%x\n", (u16
)mgmt
->frame_control
);
2266 if (buf
[ACTION_CAT_ID
] == PUB_ACTION_ATTR_ID
) {
2267 /*Only set the channel, if not a negotiation confirmation frame
2268 * (If Negotiation confirmation frame, force it
2269 * to be transmitted on the same negotiation channel)*/
2271 if (buf
[ACTION_SUBTYPE_ID
] != PUBLIC_ACT_VENDORSPEC
||
2272 buf
[P2P_PUB_ACTION_SUBTYPE
] != GO_NEG_CONF
) {
2273 PRINT_D(GENERIC_DBG
, "Setting channel: %d\n", chan
->hw_value
);
2274 wilc_set_mac_chnl_num(priv
->hWILCWFIDrv
, chan
->hw_value
);
2275 /*Save the current channel after we tune to it*/
2276 curr_channel
= chan
->hw_value
;
2278 switch (buf
[ACTION_SUBTYPE_ID
]) {
2279 case GAS_INTIAL_REQ
:
2281 PRINT_D(GENERIC_DBG
, "GAS INITIAL REQ %x\n", buf
[ACTION_SUBTYPE_ID
]);
2285 case GAS_INTIAL_RSP
:
2287 PRINT_D(GENERIC_DBG
, "GAS INITIAL RSP %x\n", buf
[ACTION_SUBTYPE_ID
]);
2291 case PUBLIC_ACT_VENDORSPEC
:
2293 if (!memcmp(p2p_oui
, &buf
[ACTION_SUBTYPE_ID
+ 1], 4)) {
2294 /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
2295 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
)) {
2296 if (p2p_local_random
== 1 && p2p_recv_random
< p2p_local_random
) {
2297 get_random_bytes(&p2p_local_random
, 1);
2302 if ((buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == GO_NEG_RSP
2303 || buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)) {
2304 if (p2p_local_random
> p2p_recv_random
) {
2305 PRINT_D(GENERIC_DBG
, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random
, p2p_recv_random
);
2307 /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
2308 for (i
= P2P_PUB_ACTION_SUBTYPE
+ 2; i
< len
; i
++) {
2309 if (buf
[i
] == P2PELEM_ATTR_ID
&& !(memcmp(p2p_oui
, &buf
[i
+ 2], 4))) {
2310 if (buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_REQ
|| buf
[P2P_PUB_ACTION_SUBTYPE
] == P2P_INV_RSP
)
2311 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), true, nic
->iftype
);
2313 /*If using supplicant go intent, no need at all*/
2314 /*to parse transmitted negotiation frames*/
2316 WILC_WFI_CfgParseTxAction(&mgmt_tx
->buff
[i
+ 6], len
- (i
+ 6), false, nic
->iftype
);
2321 if (buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_REQ
&& buf
[P2P_PUB_ACTION_SUBTYPE
] != P2P_INV_RSP
) {
2323 * Adding WILC information element to allow two WILC devices to
2324 * identify each other and connect
2326 memcpy(&mgmt_tx
->buff
[len
], p2p_vendor_spec
, sizeof(p2p_vendor_spec
));
2327 mgmt_tx
->buff
[len
+ sizeof(p2p_vendor_spec
)] = p2p_local_random
;
2328 mgmt_tx
->size
= buf_len
;
2331 PRINT_D(GENERIC_DBG
, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random
, p2p_recv_random
);
2336 PRINT_D(GENERIC_DBG
, "Not a P2P public action frame\n");
2344 PRINT_D(GENERIC_DBG
, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf
[ACTION_SUBTYPE_ID
]);
2351 PRINT_D(GENERIC_DBG
, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf
[ACTION_SUBTYPE_ID
], chan
->hw_value
);
2352 pstrWFIDrv
->p2p_timeout
= (jiffies
+ msecs_to_jiffies(wait
));
2354 PRINT_D(GENERIC_DBG
, "Current Jiffies: %lu Timeout:%llu\n",
2355 jiffies
, pstrWFIDrv
->p2p_timeout
);
2358 wilc_wlan_txq_add_mgmt_pkt(wdev
->netdev
, mgmt_tx
,
2359 mgmt_tx
->buff
, mgmt_tx
->size
,
2360 WILC_WFI_mgmt_tx_complete
);
2362 PRINT_D(GENERIC_DBG
, "This function transmits only management frames\n");
2367 static int mgmt_tx_cancel_wait(struct wiphy
*wiphy
,
2368 struct wireless_dev
*wdev
,
2371 struct wilc_priv
*priv
;
2372 struct host_if_drv
*pstrWFIDrv
;
2374 priv
= wiphy_priv(wiphy
);
2375 pstrWFIDrv
= (struct host_if_drv
*)priv
->hWILCWFIDrv
;
2378 PRINT_D(GENERIC_DBG
, "Tx Cancel wait :%lu\n", jiffies
);
2379 pstrWFIDrv
->p2p_timeout
= jiffies
;
2381 if (!priv
->bInP2PlistenState
) {
2382 cfg80211_remain_on_channel_expired(priv
->wdev
,
2383 priv
->strRemainOnChanParams
.u64ListenCookie
,
2384 priv
->strRemainOnChanParams
.pstrListenChan
,
2392 * @brief wilc_mgmt_frame_register
2393 * @details Notify driver that a management frame type was
2394 * registered. Note that this callback may not sleep, and cannot run
2395 * concurrently with itself.
2402 void wilc_mgmt_frame_register(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
2403 u16 frame_type
, bool reg
)
2406 struct wilc_priv
*priv
;
2407 perInterface_wlan_t
*nic
;
2410 priv
= wiphy_priv(wiphy
);
2411 nic
= netdev_priv(priv
->wdev
->netdev
);
2417 PRINT_D(GENERIC_DBG
, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type
, reg
);
2418 switch (frame_type
) {
2421 nic
->g_struct_frame_reg
[0].frame_type
= frame_type
;
2422 nic
->g_struct_frame_reg
[0].reg
= reg
;
2428 nic
->g_struct_frame_reg
[1].frame_type
= frame_type
;
2429 nic
->g_struct_frame_reg
[1].reg
= reg
;
2439 /*If mac is closed, then return*/
2440 if (!wl
->initialized
) {
2441 PRINT_D(GENERIC_DBG
, "Return since mac is closed\n");
2444 wilc_frame_register(priv
->hWILCWFIDrv
, frame_type
, reg
);
2450 * @brief set_cqm_rssi_config
2451 * @details Configure connection quality monitor RSSI threshold.
2452 * @param[in] struct wiphy *wiphy:
2453 * @param[in] struct net_device *dev:
2454 * @param[in] s32 rssi_thold:
2455 * @param[in] u32 rssi_hyst:
2456 * @return int : Return 0 on Success
2461 static int set_cqm_rssi_config(struct wiphy
*wiphy
, struct net_device
*dev
,
2462 s32 rssi_thold
, u32 rssi_hyst
)
2464 PRINT_D(CFG80211_DBG
, "Setting CQM RSSi Function\n");
2469 * @brief dump_station
2470 * @details Configure connection quality monitor RSSI threshold.
2471 * @param[in] struct wiphy *wiphy:
2472 * @param[in] struct net_device *dev
2473 * @param[in] int idx
2474 * @param[in] u8 *mac
2475 * @param[in] struct station_info *sinfo
2476 * @return int : Return 0 on Success
2481 static int dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
2482 int idx
, u8
*mac
, struct station_info
*sinfo
)
2484 struct wilc_priv
*priv
;
2486 PRINT_D(CFG80211_DBG
, "Dumping station information\n");
2491 priv
= wiphy_priv(wiphy
);
2493 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL
);
2495 wilc_get_rssi(priv
->hWILCWFIDrv
, &(sinfo
->signal
));
2503 * @brief set_power_mgmt
2506 * @return int : Return 0 on Success.
2511 static int set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
2512 bool enabled
, int timeout
)
2514 struct wilc_priv
*priv
;
2516 PRINT_D(CFG80211_DBG
, " Power save Enabled= %d , TimeOut = %d\n", enabled
, timeout
);
2521 priv
= wiphy_priv(wiphy
);
2522 if (priv
->hWILCWFIDrv
== NULL
) {
2523 PRINT_ER("Driver is NULL\n");
2528 wilc_set_power_mgmt(priv
->hWILCWFIDrv
, enabled
, timeout
);
2536 * @brief change_virtual_intf
2537 * @details Change type/configuration of virtual interface,
2538 * keep the struct wireless_dev's iftype updated.
2540 * @return int : Return 0 on Success.
2545 static int change_virtual_intf(struct wiphy
*wiphy
, struct net_device
*dev
,
2546 enum nl80211_iftype type
, u32
*flags
, struct vif_params
*params
)
2548 struct wilc_priv
*priv
;
2549 perInterface_wlan_t
*nic
;
2555 nic
= netdev_priv(dev
);
2556 priv
= wiphy_priv(wiphy
);
2559 PRINT_D(HOSTAPD_DBG
, "In Change virtual interface function\n");
2560 PRINT_D(HOSTAPD_DBG
, "Wireless interface name =%s\n", dev
->name
);
2561 p2p_local_random
= 0x01;
2562 p2p_recv_random
= 0x00;
2564 wilc_optaining_ip
= false;
2565 del_timer(&wilc_during_ip_timer
);
2566 PRINT_D(GENERIC_DBG
, "Changing virtual interface, enable scan\n");
2567 /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
2568 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2569 wilc_set_machw_change_vir_if(dev
, true);
2573 case NL80211_IFTYPE_STATION
:
2574 wilc_connecting
= 0;
2575 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_STATION\n");
2577 /* send delba over wlan interface */
2580 dev
->ieee80211_ptr
->iftype
= type
;
2581 priv
->wdev
->iftype
= type
;
2582 nic
->monitor_flag
= 0;
2583 nic
->iftype
= STATION_MODE
;
2585 /*Remove the enteries of the previously connected clients*/
2586 memset(priv
->assoc_stainfo
.au8Sta_AssociatedBss
, 0, MAX_NUM_STA
* ETH_ALEN
);
2587 interface_type
= nic
->iftype
;
2588 nic
->iftype
= STATION_MODE
;
2590 if (wl
->initialized
) {
2591 wilc_del_all_rx_ba_session(priv
->hWILCWFIDrv
,
2592 wl
->vif
[0].bssid
, TID
);
2593 /* ensure that the message Q is empty */
2594 wilc_wait_msg_queue_idle();
2596 /*Eliminate host interface blocking state*/
2599 wilc1000_wlan_deinit(dev
);
2600 wilc1000_wlan_init(dev
, nic
);
2601 wilc_initialized
= 1;
2602 nic
->iftype
= interface_type
;
2604 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2605 wilc_set_wfi_drv_handler(wl
->vif
[0].hif_drv
);
2606 wilc_set_mac_address(wl
->vif
[0].hif_drv
,
2607 wl
->vif
[0].src_addr
);
2608 wilc_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
2610 /*Add saved WEP keys, if any*/
2611 if (g_wep_keys_saved
) {
2612 wilc_set_wep_default_keyid(wl
->vif
[0].hif_drv
,
2613 g_key_wep_params
.key_idx
);
2614 wilc_add_wep_key_bss_sta(wl
->vif
[0].hif_drv
,
2615 g_key_wep_params
.key
,
2616 g_key_wep_params
.key_len
,
2617 g_key_wep_params
.key_idx
);
2620 /*No matter the driver handler passed here, it will be overwriiten*/
2621 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2622 wilc_flush_join_req(priv
->hWILCWFIDrv
);
2624 /*Add saved PTK and GTK keys, if any*/
2625 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2626 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
2627 g_key_ptk_params
.key
[1],
2628 g_key_ptk_params
.key
[2]);
2629 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
2630 g_key_gtk_params
.key
[1],
2631 g_key_gtk_params
.key
[2]);
2632 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2634 g_add_ptk_key_params
.key_idx
,
2635 g_add_ptk_key_params
.pairwise
,
2636 g_add_ptk_key_params
.mac_addr
,
2637 (struct key_params
*)(&g_key_ptk_params
));
2639 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2641 g_add_gtk_key_params
.key_idx
,
2642 g_add_gtk_key_params
.pairwise
,
2643 g_add_gtk_key_params
.mac_addr
,
2644 (struct key_params
*)(&g_key_gtk_params
));
2647 if (wl
->initialized
) {
2648 for (i
= 0; i
< num_reg_frame
; i
++) {
2649 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2650 nic
->g_struct_frame_reg
[i
].reg
);
2651 wilc_frame_register(priv
->hWILCWFIDrv
,
2652 nic
->g_struct_frame_reg
[i
].frame_type
,
2653 nic
->g_struct_frame_reg
[i
].reg
);
2657 wilc_enable_ps
= true;
2658 wilc_set_power_mgmt(priv
->hWILCWFIDrv
, 1, 0);
2662 case NL80211_IFTYPE_P2P_CLIENT
:
2663 wilc_enable_ps
= false;
2664 wilc_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
2665 wilc_connecting
= 0;
2666 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
2668 wilc_del_all_rx_ba_session(priv
->hWILCWFIDrv
,
2669 wl
->vif
[0].bssid
, TID
);
2671 dev
->ieee80211_ptr
->iftype
= type
;
2672 priv
->wdev
->iftype
= type
;
2673 nic
->monitor_flag
= 0;
2675 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2676 nic
->iftype
= CLIENT_MODE
;
2679 if (wl
->initialized
) {
2680 /* ensure that the message Q is empty */
2681 wilc_wait_msg_queue_idle();
2683 wilc1000_wlan_deinit(dev
);
2684 wilc1000_wlan_init(dev
, nic
);
2685 wilc_initialized
= 1;
2687 wilc_set_wfi_drv_handler(wl
->vif
[0].hif_drv
);
2688 wilc_set_mac_address(wl
->vif
[0].hif_drv
,
2689 wl
->vif
[0].src_addr
);
2690 wilc_set_operation_mode(priv
->hWILCWFIDrv
, STATION_MODE
);
2692 /*Add saved WEP keys, if any*/
2693 if (g_wep_keys_saved
) {
2694 wilc_set_wep_default_keyid(wl
->vif
[0].hif_drv
,
2695 g_key_wep_params
.key_idx
);
2696 wilc_add_wep_key_bss_sta(wl
->vif
[0].hif_drv
,
2697 g_key_wep_params
.key
,
2698 g_key_wep_params
.key_len
,
2699 g_key_wep_params
.key_idx
);
2702 /*No matter the driver handler passed here, it will be overwriiten*/
2703 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2704 wilc_flush_join_req(priv
->hWILCWFIDrv
);
2706 /*Add saved PTK and GTK keys, if any*/
2707 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2708 PRINT_D(CFG80211_DBG
, "ptk %x %x %x\n", g_key_ptk_params
.key
[0],
2709 g_key_ptk_params
.key
[1],
2710 g_key_ptk_params
.key
[2]);
2711 PRINT_D(CFG80211_DBG
, "gtk %x %x %x\n", g_key_gtk_params
.key
[0],
2712 g_key_gtk_params
.key
[1],
2713 g_key_gtk_params
.key
[2]);
2714 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2716 g_add_ptk_key_params
.key_idx
,
2717 g_add_ptk_key_params
.pairwise
,
2718 g_add_ptk_key_params
.mac_addr
,
2719 (struct key_params
*)(&g_key_ptk_params
));
2721 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2723 g_add_gtk_key_params
.key_idx
,
2724 g_add_gtk_key_params
.pairwise
,
2725 g_add_gtk_key_params
.mac_addr
,
2726 (struct key_params
*)(&g_key_gtk_params
));
2729 /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
2730 refresh_scan(priv
, 1, true);
2731 wilc_set_machw_change_vir_if(dev
, false);
2733 if (wl
->initialized
) {
2734 for (i
= 0; i
< num_reg_frame
; i
++) {
2735 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2736 nic
->g_struct_frame_reg
[i
].reg
);
2737 wilc_frame_register(priv
->hWILCWFIDrv
,
2738 nic
->g_struct_frame_reg
[i
].frame_type
,
2739 nic
->g_struct_frame_reg
[i
].reg
);
2745 case NL80211_IFTYPE_AP
:
2746 wilc_enable_ps
= false;
2747 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_AP %d\n", type
);
2748 dev
->ieee80211_ptr
->iftype
= type
;
2749 priv
->wdev
->iftype
= type
;
2750 nic
->iftype
= AP_MODE
;
2751 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
2753 PRINT_D(HOSTAPD_DBG
, "Downloading AP firmware\n");
2754 wilc_wlan_get_firmware(dev
);
2755 /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
2756 if (wl
->initialized
) {
2757 nic
->iftype
= AP_MODE
;
2758 wilc_mac_close(dev
);
2761 for (i
= 0; i
< num_reg_frame
; i
++) {
2762 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2763 nic
->g_struct_frame_reg
[i
].reg
);
2764 wilc_frame_register(priv
->hWILCWFIDrv
,
2765 nic
->g_struct_frame_reg
[i
].frame_type
,
2766 nic
->g_struct_frame_reg
[i
].reg
);
2771 case NL80211_IFTYPE_P2P_GO
:
2772 PRINT_D(GENERIC_DBG
, "start duringIP timer\n");
2774 wilc_optaining_ip
= true;
2775 mod_timer(&wilc_during_ip_timer
,
2776 jiffies
+ msecs_to_jiffies(during_ip_time
));
2777 wilc_set_power_mgmt(priv
->hWILCWFIDrv
, 0, 0);
2778 /*Delete block ack has to be the latest config packet*/
2779 /*sent before downloading new FW. This is because it blocks on*/
2780 /*hWaitResponse semaphore, which allows previous config*/
2781 /*packets to actually take action on old FW*/
2782 wilc_del_all_rx_ba_session(priv
->hWILCWFIDrv
,
2783 wl
->vif
[0].bssid
, TID
);
2784 wilc_enable_ps
= false;
2785 PRINT_D(HOSTAPD_DBG
, "Interface type = NL80211_IFTYPE_GO\n");
2786 dev
->ieee80211_ptr
->iftype
= type
;
2787 priv
->wdev
->iftype
= type
;
2789 PRINT_D(CORECONFIG_DBG
, "priv->hWILCWFIDrv[%p]\n", priv
->hWILCWFIDrv
);
2791 PRINT_D(HOSTAPD_DBG
, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
2794 nic
->iftype
= GO_MODE
;
2796 /* ensure that the message Q is empty */
2797 wilc_wait_msg_queue_idle();
2798 wilc1000_wlan_deinit(dev
);
2799 wilc1000_wlan_init(dev
, nic
);
2800 wilc_initialized
= 1;
2803 /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
2804 wilc_set_wfi_drv_handler(wl
->vif
[0].hif_drv
);
2805 wilc_set_mac_address(wl
->vif
[0].hif_drv
,
2806 wl
->vif
[0].src_addr
);
2807 wilc_set_operation_mode(priv
->hWILCWFIDrv
, AP_MODE
);
2809 /*Add saved WEP keys, if any*/
2810 if (g_wep_keys_saved
) {
2811 wilc_set_wep_default_keyid(wl
->vif
[0].hif_drv
,
2812 g_key_wep_params
.key_idx
);
2813 wilc_add_wep_key_bss_sta(wl
->vif
[0].hif_drv
,
2814 g_key_wep_params
.key
,
2815 g_key_wep_params
.key_len
,
2816 g_key_wep_params
.key_idx
);
2819 /*No matter the driver handler passed here, it will be overwriiten*/
2820 /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
2821 wilc_flush_join_req(priv
->hWILCWFIDrv
);
2823 /*Add saved PTK and GTK keys, if any*/
2824 if (g_ptk_keys_saved
&& g_gtk_keys_saved
) {
2825 PRINT_D(CFG80211_DBG
, "ptk %x %x %x cipher %x\n", g_key_ptk_params
.key
[0],
2826 g_key_ptk_params
.key
[1],
2827 g_key_ptk_params
.key
[2],
2828 g_key_ptk_params
.cipher
);
2829 PRINT_D(CFG80211_DBG
, "gtk %x %x %x cipher %x\n", g_key_gtk_params
.key
[0],
2830 g_key_gtk_params
.key
[1],
2831 g_key_gtk_params
.key
[2],
2832 g_key_gtk_params
.cipher
);
2833 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2835 g_add_ptk_key_params
.key_idx
,
2836 g_add_ptk_key_params
.pairwise
,
2837 g_add_ptk_key_params
.mac_addr
,
2838 (struct key_params
*)(&g_key_ptk_params
));
2840 add_key(wl
->vif
[0].ndev
->ieee80211_ptr
->wiphy
,
2842 g_add_gtk_key_params
.key_idx
,
2843 g_add_gtk_key_params
.pairwise
,
2844 g_add_gtk_key_params
.mac_addr
,
2845 (struct key_params
*)(&g_key_gtk_params
));
2848 if (wl
->initialized
) {
2849 for (i
= 0; i
< num_reg_frame
; i
++) {
2850 PRINT_D(INIT_DBG
, "Frame registering Type: %x - Reg: %d\n", nic
->g_struct_frame_reg
[i
].frame_type
,
2851 nic
->g_struct_frame_reg
[i
].reg
);
2852 wilc_frame_register(priv
->hWILCWFIDrv
,
2853 nic
->g_struct_frame_reg
[i
].frame_type
,
2854 nic
->g_struct_frame_reg
[i
].reg
);
2860 PRINT_ER("Unknown interface type= %d\n", type
);
2867 /* (austin.2013-07-23)
2869 * To support revised cfg80211_ops
2871 * add_beacon --> start_ap
2872 * set_beacon --> change_beacon
2873 * del_beacon --> stop_ap
2875 * beacon_parameters --> cfg80211_ap_settings
2876 * cfg80211_beacon_data
2878 * applicable for linux kernel 3.4+
2883 * @details Add a beacon with given parameters, @head, @interval
2884 * and @dtim_period will be valid, @tail is optional.
2886 * @param[in] dev The net device structure
2887 * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
2888 * @return int : Return 0 on Success.
2893 static int start_ap(struct wiphy
*wiphy
, struct net_device
*dev
,
2894 struct cfg80211_ap_settings
*settings
)
2896 struct cfg80211_beacon_data
*beacon
= &(settings
->beacon
);
2897 struct wilc_priv
*priv
;
2900 perInterface_wlan_t
*nic
;
2902 priv
= wiphy_priv(wiphy
);
2903 nic
= netdev_priv(dev
);
2905 PRINT_D(HOSTAPD_DBG
, "Starting ap\n");
2907 PRINT_D(HOSTAPD_DBG
, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
2908 settings
->beacon_interval
, settings
->dtim_period
, beacon
->head_len
, beacon
->tail_len
);
2910 s32Error
= set_channel(wiphy
, &settings
->chandef
);
2913 PRINT_ER("Error in setting channel\n");
2915 wilc_wlan_set_bssid(dev
, wl
->vif
[0].src_addr
);
2917 s32Error
= wilc_add_beacon(priv
->hWILCWFIDrv
,
2918 settings
->beacon_interval
,
2919 settings
->dtim_period
,
2920 beacon
->head_len
, (u8
*)beacon
->head
,
2921 beacon
->tail_len
, (u8
*)beacon
->tail
);
2927 * @brief change_beacon
2928 * @details Add a beacon with given parameters, @head, @interval
2929 * and @dtim_period will be valid, @tail is optional.
2931 * @param[in] dev The net device structure
2932 * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
2933 * @return int : Return 0 on Success.
2938 static int change_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
2939 struct cfg80211_beacon_data
*beacon
)
2941 struct wilc_priv
*priv
;
2944 priv
= wiphy_priv(wiphy
);
2945 PRINT_D(HOSTAPD_DBG
, "Setting beacon\n");
2948 s32Error
= wilc_add_beacon(priv
->hWILCWFIDrv
,
2951 beacon
->head_len
, (u8
*)beacon
->head
,
2952 beacon
->tail_len
, (u8
*)beacon
->tail
);
2959 * @details Remove beacon configuration and stop sending the beacon.
2961 * @return int : Return 0 on Success.
2966 static int stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
2969 struct wilc_priv
*priv
;
2970 u8 NullBssid
[ETH_ALEN
] = {0};
2975 priv
= wiphy_priv(wiphy
);
2977 PRINT_D(HOSTAPD_DBG
, "Deleting beacon\n");
2979 wilc_wlan_set_bssid(dev
, NullBssid
);
2981 s32Error
= wilc_del_beacon(priv
->hWILCWFIDrv
);
2984 PRINT_ER("Host delete beacon fail\n");
2990 * @brief add_station
2991 * @details Add a new station.
2993 * @return int : Return 0 on Success.
2998 static int add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
2999 const u8
*mac
, struct station_parameters
*params
)
3002 struct wilc_priv
*priv
;
3003 struct add_sta_param strStaParams
= { {0} };
3004 perInterface_wlan_t
*nic
;
3009 priv
= wiphy_priv(wiphy
);
3010 nic
= netdev_priv(dev
);
3012 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3013 memcpy(strStaParams
.bssid
, mac
, ETH_ALEN
);
3014 memcpy(priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
], mac
, ETH_ALEN
);
3015 strStaParams
.aid
= params
->aid
;
3016 strStaParams
.rates_len
= params
->supported_rates_len
;
3017 strStaParams
.rates
= params
->supported_rates
;
3019 PRINT_D(CFG80211_DBG
, "Adding station parameters %d\n", params
->aid
);
3021 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],
3022 priv
->assoc_stainfo
.au8Sta_AssociatedBss
[params
->aid
][5]);
3023 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.aid
);
3024 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n",
3025 strStaParams
.rates_len
);
3027 if (params
->ht_capa
== NULL
) {
3028 strStaParams
.ht_supported
= false;
3030 strStaParams
.ht_supported
= true;
3031 strStaParams
.ht_capa_info
= params
->ht_capa
->cap_info
;
3032 strStaParams
.ht_ampdu_params
= params
->ht_capa
->ampdu_params_info
;
3033 memcpy(strStaParams
.ht_supp_mcs_set
,
3034 ¶ms
->ht_capa
->mcs
,
3035 WILC_SUPP_MCS_SET_SIZE
);
3036 strStaParams
.ht_ext_params
= params
->ht_capa
->extended_ht_cap_info
;
3037 strStaParams
.ht_tx_bf_cap
= params
->ht_capa
->tx_BF_cap_info
;
3038 strStaParams
.ht_ante_sel
= params
->ht_capa
->antenna_selection_info
;
3041 strStaParams
.flags_mask
= params
->sta_flags_mask
;
3042 strStaParams
.flags_set
= params
->sta_flags_set
;
3044 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n",
3045 strStaParams
.ht_supported
);
3046 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n",
3047 strStaParams
.ht_capa_info
);
3048 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n",
3049 strStaParams
.ht_ampdu_params
);
3050 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n",
3051 strStaParams
.ht_ext_params
);
3052 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n",
3053 strStaParams
.ht_tx_bf_cap
);
3054 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n",
3055 strStaParams
.ht_ante_sel
);
3056 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n",
3057 strStaParams
.flags_mask
);
3058 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n",
3059 strStaParams
.flags_set
);
3061 s32Error
= wilc_add_station(priv
->hWILCWFIDrv
, &strStaParams
);
3063 PRINT_ER("Host add station fail\n");
3070 * @brief del_station
3071 * @details Remove a station; @mac may be NULL to remove all stations.
3073 * @return int : Return 0 on Success.
3078 static int del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3079 struct station_del_parameters
*params
)
3081 const u8
*mac
= params
->mac
;
3083 struct wilc_priv
*priv
;
3084 perInterface_wlan_t
*nic
;
3089 priv
= wiphy_priv(wiphy
);
3090 nic
= netdev_priv(dev
);
3092 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3093 PRINT_D(HOSTAPD_DBG
, "Deleting station\n");
3097 PRINT_D(HOSTAPD_DBG
, "All associated stations\n");
3098 s32Error
= wilc_del_allstation(priv
->hWILCWFIDrv
, priv
->assoc_stainfo
.au8Sta_AssociatedBss
);
3100 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]);
3103 s32Error
= wilc_del_station(priv
->hWILCWFIDrv
, mac
);
3106 PRINT_ER("Host delete station fail\n");
3112 * @brief change_station
3113 * @details Modify a given station.
3115 * @return int : Return 0 on Success.
3120 static int change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3121 const u8
*mac
, struct station_parameters
*params
)
3124 struct wilc_priv
*priv
;
3125 struct add_sta_param strStaParams
= { {0} };
3126 perInterface_wlan_t
*nic
;
3129 PRINT_D(HOSTAPD_DBG
, "Change station paramters\n");
3134 priv
= wiphy_priv(wiphy
);
3135 nic
= netdev_priv(dev
);
3137 if (nic
->iftype
== AP_MODE
|| nic
->iftype
== GO_MODE
) {
3138 memcpy(strStaParams
.bssid
, mac
, ETH_ALEN
);
3139 strStaParams
.aid
= params
->aid
;
3140 strStaParams
.rates_len
= params
->supported_rates_len
;
3141 strStaParams
.rates
= params
->supported_rates
;
3143 PRINT_D(HOSTAPD_DBG
, "BSSID = %x%x%x%x%x%x\n",
3144 strStaParams
.bssid
[0], strStaParams
.bssid
[1],
3145 strStaParams
.bssid
[2], strStaParams
.bssid
[3],
3146 strStaParams
.bssid
[4], strStaParams
.bssid
[5]);
3147 PRINT_D(HOSTAPD_DBG
, "ASSOC ID = %d\n", strStaParams
.aid
);
3148 PRINT_D(HOSTAPD_DBG
, "Number of supported rates = %d\n",
3149 strStaParams
.rates_len
);
3151 if (params
->ht_capa
== NULL
) {
3152 strStaParams
.ht_supported
= false;
3154 strStaParams
.ht_supported
= true;
3155 strStaParams
.ht_capa_info
= params
->ht_capa
->cap_info
;
3156 strStaParams
.ht_ampdu_params
= params
->ht_capa
->ampdu_params_info
;
3157 memcpy(strStaParams
.ht_supp_mcs_set
,
3158 ¶ms
->ht_capa
->mcs
,
3159 WILC_SUPP_MCS_SET_SIZE
);
3160 strStaParams
.ht_ext_params
= params
->ht_capa
->extended_ht_cap_info
;
3161 strStaParams
.ht_tx_bf_cap
= params
->ht_capa
->tx_BF_cap_info
;
3162 strStaParams
.ht_ante_sel
= params
->ht_capa
->antenna_selection_info
;
3165 strStaParams
.flags_mask
= params
->sta_flags_mask
;
3166 strStaParams
.flags_set
= params
->sta_flags_set
;
3168 PRINT_D(HOSTAPD_DBG
, "IS HT supported = %d\n",
3169 strStaParams
.ht_supported
);
3170 PRINT_D(HOSTAPD_DBG
, "Capability Info = %d\n",
3171 strStaParams
.ht_capa_info
);
3172 PRINT_D(HOSTAPD_DBG
, "AMPDU Params = %d\n",
3173 strStaParams
.ht_ampdu_params
);
3174 PRINT_D(HOSTAPD_DBG
, "HT Extended params = %d\n",
3175 strStaParams
.ht_ext_params
);
3176 PRINT_D(HOSTAPD_DBG
, "Tx Beamforming Cap = %d\n",
3177 strStaParams
.ht_tx_bf_cap
);
3178 PRINT_D(HOSTAPD_DBG
, "Antenna selection info = %d\n",
3179 strStaParams
.ht_ante_sel
);
3180 PRINT_D(HOSTAPD_DBG
, "Flag Mask = %d\n",
3181 strStaParams
.flags_mask
);
3182 PRINT_D(HOSTAPD_DBG
, "Flag Set = %d\n",
3183 strStaParams
.flags_set
);
3185 s32Error
= wilc_edit_station(priv
->hWILCWFIDrv
, &strStaParams
);
3187 PRINT_ER("Host edit station fail\n");
3194 * @brief add_virtual_intf
3197 * @return int : Return 0 on Success.
3202 static struct wireless_dev
*add_virtual_intf(struct wiphy
*wiphy
,
3204 unsigned char name_assign_type
,
3205 enum nl80211_iftype type
,
3207 struct vif_params
*params
)
3209 perInterface_wlan_t
*nic
;
3210 struct wilc_priv
*priv
;
3211 struct net_device
*new_ifc
= NULL
;
3213 priv
= wiphy_priv(wiphy
);
3217 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", priv
->wdev
->netdev
);
3219 nic
= netdev_priv(priv
->wdev
->netdev
);
3222 if (type
== NL80211_IFTYPE_MONITOR
) {
3223 PRINT_D(HOSTAPD_DBG
, "Monitor interface mode: Initializing mon interface virtual device driver\n");
3224 PRINT_D(HOSTAPD_DBG
, "Adding monitor interface[%p]\n", nic
->wilc_netdev
);
3225 new_ifc
= WILC_WFI_init_mon_interface(name
, nic
->wilc_netdev
);
3226 if (new_ifc
!= NULL
) {
3227 PRINT_D(HOSTAPD_DBG
, "Setting monitor flag in private structure\n");
3228 nic
= netdev_priv(priv
->wdev
->netdev
);
3229 nic
->monitor_flag
= 1;
3231 PRINT_ER("Error in initializing monitor interface\n ");
3237 * @brief del_virtual_intf
3240 * @return int : Return 0 on Success.
3245 static int del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
3247 PRINT_D(HOSTAPD_DBG
, "Deleting virtual interface\n");
3251 static struct cfg80211_ops wilc_cfg80211_ops
= {
3253 .set_monitor_channel
= set_channel
,
3256 .disconnect
= disconnect
,
3260 .set_default_key
= set_default_key
,
3261 .add_virtual_intf
= add_virtual_intf
,
3262 .del_virtual_intf
= del_virtual_intf
,
3263 .change_virtual_intf
= change_virtual_intf
,
3265 .start_ap
= start_ap
,
3266 .change_beacon
= change_beacon
,
3268 .add_station
= add_station
,
3269 .del_station
= del_station
,
3270 .change_station
= change_station
,
3271 .get_station
= get_station
,
3272 .dump_station
= dump_station
,
3273 .change_bss
= change_bss
,
3274 .set_wiphy_params
= set_wiphy_params
,
3276 .set_pmksa
= set_pmksa
,
3277 .del_pmksa
= del_pmksa
,
3278 .flush_pmksa
= flush_pmksa
,
3279 .remain_on_channel
= remain_on_channel
,
3280 .cancel_remain_on_channel
= cancel_remain_on_channel
,
3281 .mgmt_tx_cancel_wait
= mgmt_tx_cancel_wait
,
3283 .mgmt_frame_register
= wilc_mgmt_frame_register
,
3284 .set_power_mgmt
= set_power_mgmt
,
3285 .set_cqm_rssi_config
= set_cqm_rssi_config
,
3294 * @brief WILC_WFI_update_stats
3295 * @details Modify parameters for a given BSS.
3297 * @return int : Return 0 on Success.
3302 int WILC_WFI_update_stats(struct wiphy
*wiphy
, u32 pktlen
, u8 changed
)
3305 struct wilc_priv
*priv
;
3307 priv
= wiphy_priv(wiphy
);
3310 case WILC_WFI_RX_PKT
:
3312 priv
->netstats
.rx_packets
++;
3313 priv
->netstats
.rx_bytes
+= pktlen
;
3314 priv
->netstats
.rx_time
= get_jiffies_64();
3318 case WILC_WFI_TX_PKT
:
3320 priv
->netstats
.tx_packets
++;
3321 priv
->netstats
.tx_bytes
+= pktlen
;
3322 priv
->netstats
.tx_time
= get_jiffies_64();
3334 * @brief WILC_WFI_CfgAlloc
3335 * @details Allocation of the wireless device structure and assigning it
3336 * to the cfg80211 operations structure.
3338 * @return wireless_dev : Returns pointer to wireless_dev structure.
3343 static struct wireless_dev
*WILC_WFI_CfgAlloc(void)
3346 struct wireless_dev
*wdev
;
3349 PRINT_D(CFG80211_DBG
, "Allocating wireless device\n");
3350 /*Allocating the wireless device structure*/
3351 wdev
= kzalloc(sizeof(struct wireless_dev
), GFP_KERNEL
);
3353 PRINT_ER("Cannot allocate wireless device\n");
3357 /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
3358 wdev
->wiphy
= wiphy_new(&wilc_cfg80211_ops
, sizeof(struct wilc_priv
));
3360 PRINT_ER("Cannot allocate wiphy\n");
3365 /* enable 802.11n HT */
3366 WILC_WFI_band_2ghz
.ht_cap
.ht_supported
= 1;
3367 WILC_WFI_band_2ghz
.ht_cap
.cap
|= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
);
3368 WILC_WFI_band_2ghz
.ht_cap
.mcs
.rx_mask
[0] = 0xff;
3369 WILC_WFI_band_2ghz
.ht_cap
.ampdu_factor
= IEEE80211_HT_MAX_AMPDU_8K
;
3370 WILC_WFI_band_2ghz
.ht_cap
.ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
3373 wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &WILC_WFI_band_2ghz
;
3384 * @brief wilc_create_wiphy
3385 * @details Registering of the wiphy structure and interface modes
3392 struct wireless_dev
*wilc_create_wiphy(struct net_device
*net
, struct device
*dev
)
3394 struct wilc_priv
*priv
;
3395 struct wireless_dev
*wdev
;
3398 PRINT_D(CFG80211_DBG
, "Registering wifi device\n");
3400 wdev
= WILC_WFI_CfgAlloc();
3402 PRINT_ER("CfgAlloc Failed\n");
3407 /*Return hardware description structure (wiphy)'s priv*/
3408 priv
= wdev_priv(wdev
);
3409 sema_init(&(priv
->SemHandleUpdateStats
), 1);
3411 /*Link the wiphy with wireless structure*/
3414 /*Maximum number of probed ssid to be added by user for the scan request*/
3415 wdev
->wiphy
->max_scan_ssids
= MAX_NUM_PROBED_SSID
;
3416 /*Maximum number of pmkids to be cashed*/
3417 wdev
->wiphy
->max_num_pmkids
= WILC_MAX_NUM_PMKIDS
;
3418 PRINT_INFO(CFG80211_DBG
, "Max number of PMKIDs = %d\n", wdev
->wiphy
->max_num_pmkids
);
3420 wdev
->wiphy
->max_scan_ie_len
= 1000;
3422 /*signal strength in mBm (100*dBm) */
3423 wdev
->wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3425 /*Set the availaible cipher suites*/
3426 wdev
->wiphy
->cipher_suites
= cipher_suites
;
3427 wdev
->wiphy
->n_cipher_suites
= ARRAY_SIZE(cipher_suites
);
3428 /*Setting default managment types: for register action frame: */
3429 wdev
->wiphy
->mgmt_stypes
= wilc_wfi_cfg80211_mgmt_types
;
3431 wdev
->wiphy
->max_remain_on_channel_duration
= 500;
3432 /*Setting the wiphy interfcae mode and type before registering the wiphy*/
3433 wdev
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_AP
) | BIT(NL80211_IFTYPE_MONITOR
) | BIT(NL80211_IFTYPE_P2P_GO
) |
3434 BIT(NL80211_IFTYPE_P2P_CLIENT
);
3435 wdev
->wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
;
3436 wdev
->iftype
= NL80211_IFTYPE_STATION
;
3440 PRINT_INFO(CFG80211_DBG
, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
3441 wdev
->wiphy
->max_scan_ssids
, wdev
->wiphy
->max_scan_ie_len
, wdev
->wiphy
->signal_type
,
3442 wdev
->wiphy
->interface_modes
, wdev
->iftype
);
3444 set_wiphy_dev(wdev
->wiphy
, dev
);
3446 /*Register wiphy structure*/
3447 s32Error
= wiphy_register(wdev
->wiphy
);
3449 PRINT_ER("Cannot register wiphy device\n");
3450 /*should define what action to be taken in such failure*/
3452 PRINT_D(CFG80211_DBG
, "Successful Registering\n");
3461 * @brief WILC_WFI_WiphyFree
3462 * @details Freeing allocation of the wireless device structure
3469 int wilc_init_host_int(struct net_device
*net
)
3474 struct wilc_priv
*priv
;
3476 PRINT_D(INIT_DBG
, "Host[%p][%p]\n", net
, net
->ieee80211_ptr
);
3477 priv
= wdev_priv(net
->ieee80211_ptr
);
3479 setup_timer(&hAgingTimer
, remove_network_from_shadow
, 0);
3480 setup_timer(&wilc_during_ip_timer
, clear_duringIP
, 0);
3484 PRINT_ER("Failed to creat refresh Timer\n");
3488 priv
->gbAutoRateAdjusted
= false;
3490 priv
->bInP2PlistenState
= false;
3492 sema_init(&(priv
->hSemScanReq
), 1);
3493 s32Error
= wilc_init(net
, &priv
->hWILCWFIDrv
);
3495 PRINT_ER("Error while initializing hostinterface\n");
3501 * @brief WILC_WFI_WiphyFree
3502 * @details Freeing allocation of the wireless device structure
3509 int wilc_deinit_host_int(struct net_device
*net
)
3513 struct wilc_priv
*priv
;
3515 priv
= wdev_priv(net
->ieee80211_ptr
);
3517 priv
->gbAutoRateAdjusted
= false;
3519 priv
->bInP2PlistenState
= false;
3523 s32Error
= wilc_deinit(priv
->hWILCWFIDrv
);
3525 /* Clear the Shadow scan */
3526 clear_shadow_scan();
3528 PRINT_D(CORECONFIG_DBG
, "destroy during ip\n");
3529 del_timer_sync(&wilc_during_ip_timer
);
3533 PRINT_ER("Error while deintializing host interface\n");
3540 * @brief WILC_WFI_WiphyFree
3541 * @details Freeing allocation of the wireless device structure
3548 void wilc_free_wiphy(struct net_device
*net
)
3550 PRINT_D(CFG80211_DBG
, "Unregistering wiphy\n");
3553 PRINT_D(INIT_DBG
, "net_device is NULL\n");
3557 if (!net
->ieee80211_ptr
) {
3558 PRINT_D(INIT_DBG
, "ieee80211_ptr is NULL\n");
3562 if (!net
->ieee80211_ptr
->wiphy
) {
3563 PRINT_D(INIT_DBG
, "wiphy is NULL\n");
3567 wiphy_unregister(net
->ieee80211_ptr
->wiphy
);
3569 PRINT_D(INIT_DBG
, "Freeing wiphy\n");
3570 wiphy_free(net
->ieee80211_ptr
->wiphy
);
3571 kfree(net
->ieee80211_ptr
);