1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
13 #define HOST_IF_MSG_SCAN 0
14 #define HOST_IF_MSG_CONNECT 1
15 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16 #define HOST_IF_MSG_KEY 3
17 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19 #define HOST_IF_MSG_CFG_PARAMS 6
20 #define HOST_IF_MSG_SET_CHANNEL 7
21 #define HOST_IF_MSG_DISCONNECT 8
22 #define HOST_IF_MSG_GET_RSSI 9
23 #define HOST_IF_MSG_GET_CHNL 10
24 #define HOST_IF_MSG_ADD_BEACON 11
25 #define HOST_IF_MSG_DEL_BEACON 12
26 #define HOST_IF_MSG_ADD_STATION 13
27 #define HOST_IF_MSG_DEL_STATION 14
28 #define HOST_IF_MSG_EDIT_STATION 15
29 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
30 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
31 #define HOST_IF_MSG_POWER_MGMT 18
32 #define HOST_IF_MSG_GET_INACTIVETIME 19
33 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
34 #define HOST_IF_MSG_REGISTER_FRAME 21
35 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
36 #define HOST_IF_MSG_GET_LINKSPEED 23
37 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
38 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
39 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
40 #define HOST_IF_MSG_SET_OPERATION_MODE 27
41 #define HOST_IF_MSG_SET_IPADDRESS 28
42 #define HOST_IF_MSG_GET_IPADDRESS 29
43 #define HOST_IF_MSG_FLUSH_CONNECT 30
44 #define HOST_IF_MSG_GET_STATISTICS 31
45 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
46 #define HOST_IF_MSG_DEL_BA_SESSION 34
47 #define HOST_IF_MSG_Q_IDLE 35
48 #define HOST_IF_MSG_DEL_ALL_STA 36
49 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 37
50 #define HOST_IF_MSG_SET_TX_POWER 38
51 #define HOST_IF_MSG_GET_TX_POWER 39
52 #define HOST_IF_MSG_EXIT 100
54 #define HOST_IF_SCAN_TIMEOUT 4000
55 #define HOST_IF_CONNECT_TIMEOUT 9500
57 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
58 #define BA_SESSION_DEFAULT_TIMEOUT 1000
59 #define BLOCK_ACK_REQ_SIZE 0x14
60 #define FALSE_FRMWR_CHANNEL 100
62 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
63 #define DEFAULT_LINK_SPEED 72
65 struct cfg_param_attr
{
66 struct cfg_param_val cfg_attr_info
;
69 struct host_if_wpa_attr
{
79 struct host_if_wep_attr
{
84 enum AUTHTYPE auth_type
;
87 union host_if_key_attr
{
88 struct host_if_wep_attr wep
;
89 struct host_if_wpa_attr wpa
;
90 struct host_if_pmkid_attr pmkid
;
96 union host_if_key_attr attr
;
106 wilc_scan_result result
;
108 struct hidden_network hidden_network
;
111 struct connect_attr
{
118 wilc_connect_result result
;
120 enum AUTHTYPE auth_type
;
125 struct rcvd_async_info
{
130 struct channel_attr
{
143 struct set_multicast
{
149 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
154 u8 mac_addr
[ETH_ALEN
];
157 struct power_mgmt_param
{
167 struct sta_inactive_t
{
176 struct scan_attr scan_info
;
177 struct connect_attr con_info
;
178 struct rcvd_net_info net_info
;
179 struct rcvd_async_info async_info
;
180 struct key_attr key_info
;
181 struct cfg_param_attr cfg_info
;
182 struct channel_attr channel_info
;
183 struct beacon_attr beacon_info
;
184 struct add_sta_param add_sta_info
;
185 struct del_sta del_sta_info
;
186 struct add_sta_param edit_sta_info
;
187 struct power_mgmt_param pwr_mgmt_info
;
188 struct sta_inactive_t mac_info
;
189 struct set_ip_addr ip_info
;
190 struct drv_handler drv
;
191 struct set_multicast multicast_info
;
193 struct set_mac_addr set_mac_info
;
194 struct get_mac_addr get_mac_info
;
195 struct ba_session_info session_info
;
196 struct remain_ch remain_on_ch
;
197 struct reg_frame reg_frame
;
199 struct del_all_sta del_all_sta_info
;
200 struct tx_power tx_power
;
205 union message_body body
;
206 struct wilc_vif
*vif
;
209 struct join_bss_param
{
215 char ssid
[MAX_SSID_LEN
];
217 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
224 u8 rsn_pcip_policy
[3];
225 u8 rsn_auth_policy
[3];
238 static struct host_if_drv
*terminated_handle
;
239 bool wilc_optaining_ip
;
240 static u8 P2P_LISTEN_STATE
;
241 static struct task_struct
*hif_thread_handler
;
242 static struct message_queue hif_msg_q
;
243 static struct semaphore hif_sema_thread
;
244 static struct semaphore hif_sema_driver
;
245 static struct semaphore hif_sema_wait_response
;
246 static struct semaphore hif_sema_deinit
;
247 static struct timer_list periodic_rssi
;
249 u8 wilc_multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
251 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
253 static bool scan_while_connected
;
256 static s8 link_speed
;
258 static u8 set_ip
[2][4];
259 static u8 get_ip
[2][4];
260 static u32 inactive_time
;
261 static u8 del_beacon
;
262 static u32 clients_count
;
265 static u8
*info_element
;
268 static u32 join_req_size
;
269 static u32 info_element_size
;
270 static struct wilc_vif
*join_req_vif
;
271 #define REAL_JOIN_REQ 0
272 #define FLUSHED_JOIN_REQ 1
273 #define FLUSHED_BYTE_POS 79
275 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
);
276 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
);
278 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
279 * special purpose in wilc device, so we add 1 to the index to starts from 1.
280 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
282 int wilc_get_vif_idx(struct wilc_vif
*vif
)
287 /* We need to minus 1 from idx which is from wilc device to get real index
288 * of wilc->vif[], because we add 1 when pass to wilc device in the function
290 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
292 static struct wilc_vif
*wilc_get_vif_from_idx(struct wilc
*wilc
, int idx
)
296 if (index
< 0 || index
>= NUM_CONCURRENT_IFC
)
299 return wilc
->vif
[index
];
302 static void handle_set_channel(struct wilc_vif
*vif
,
303 struct channel_attr
*hif_set_ch
)
308 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
310 wid
.val
= (char *)&hif_set_ch
->set_ch
;
311 wid
.size
= sizeof(char);
313 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
314 wilc_get_vif_idx(vif
));
317 netdev_err(vif
->ndev
, "Failed to set channel\n");
320 static s32
handle_set_wfi_drv_handler(struct wilc_vif
*vif
,
321 struct drv_handler
*hif_drv_handler
)
326 wid
.id
= (u16
)WID_SET_DRV_HANDLER
;
328 wid
.val
= (s8
*)hif_drv_handler
;
329 wid
.size
= sizeof(*hif_drv_handler
);
331 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
332 hif_drv_handler
->handler
);
334 if (!hif_drv_handler
->handler
)
335 up(&hif_sema_driver
);
338 PRINT_ER("Failed to set driver handler\n");
345 static s32
handle_set_operation_mode(struct wilc_vif
*vif
,
346 struct op_mode
*hif_op_mode
)
351 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
353 wid
.val
= (s8
*)&hif_op_mode
->mode
;
354 wid
.size
= sizeof(u32
);
356 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
357 wilc_get_vif_idx(vif
));
359 if ((hif_op_mode
->mode
) == IDLE_MODE
)
360 up(&hif_sema_driver
);
363 PRINT_ER("Failed to set driver handler\n");
370 static s32
handle_set_ip_address(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
374 char firmware_ip_addr
[4] = {0};
376 if (ip_addr
[0] < 192)
379 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
381 wid
.id
= (u16
)WID_IP_ADDRESS
;
383 wid
.val
= (u8
*)ip_addr
;
386 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
387 wilc_get_vif_idx(vif
));
389 host_int_get_ipaddress(vif
, firmware_ip_addr
, idx
);
392 PRINT_ER("Failed to set IP address\n");
399 static s32
handle_get_ip_address(struct wilc_vif
*vif
, u8 idx
)
404 wid
.id
= (u16
)WID_IP_ADDRESS
;
406 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
409 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
410 wilc_get_vif_idx(vif
));
412 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
416 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
417 wilc_setup_ipaddress(vif
, set_ip
[idx
], idx
);
420 PRINT_ER("Failed to get IP address\n");
427 static s32
handle_set_mac_address(struct wilc_vif
*vif
,
428 struct set_mac_addr
*set_mac_addr
)
432 u8
*mac_buf
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
435 PRINT_ER("No buffer to send mac address\n");
438 memcpy(mac_buf
, set_mac_addr
->mac_addr
, ETH_ALEN
);
440 wid
.id
= (u16
)WID_MAC_ADDR
;
445 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
446 wilc_get_vif_idx(vif
));
448 PRINT_ER("Failed to set mac address\n");
456 static s32
handle_get_mac_address(struct wilc_vif
*vif
,
457 struct get_mac_addr
*get_mac_addr
)
462 wid
.id
= (u16
)WID_MAC_ADDR
;
464 wid
.val
= get_mac_addr
->mac_addr
;
467 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
468 wilc_get_vif_idx(vif
));
471 PRINT_ER("Failed to get mac address\n");
474 up(&hif_sema_wait_response
);
479 static s32
handle_cfg_param(struct wilc_vif
*vif
,
480 struct cfg_param_attr
*cfg_param_attr
)
483 struct wid wid_list
[32];
484 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
487 down(&hif_drv
->sem_cfg_values
);
489 if (cfg_param_attr
->cfg_attr_info
.flag
& BSS_TYPE
) {
490 if (cfg_param_attr
->cfg_attr_info
.bss_type
< 6) {
491 wid_list
[wid_cnt
].id
= WID_BSS_TYPE
;
492 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.bss_type
;
493 wid_list
[wid_cnt
].type
= WID_CHAR
;
494 wid_list
[wid_cnt
].size
= sizeof(char);
495 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->cfg_attr_info
.bss_type
;
497 PRINT_ER("check value 6 over\n");
503 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTH_TYPE
) {
504 if (cfg_param_attr
->cfg_attr_info
.auth_type
== 1 ||
505 cfg_param_attr
->cfg_attr_info
.auth_type
== 2 ||
506 cfg_param_attr
->cfg_attr_info
.auth_type
== 5) {
507 wid_list
[wid_cnt
].id
= WID_AUTH_TYPE
;
508 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_type
;
509 wid_list
[wid_cnt
].type
= WID_CHAR
;
510 wid_list
[wid_cnt
].size
= sizeof(char);
511 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->cfg_attr_info
.auth_type
;
513 PRINT_ER("Impossible value \n");
519 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTHEN_TIMEOUT
) {
520 if (cfg_param_attr
->cfg_attr_info
.auth_timeout
> 0 &&
521 cfg_param_attr
->cfg_attr_info
.auth_timeout
< 65536) {
522 wid_list
[wid_cnt
].id
= WID_AUTH_TIMEOUT
;
523 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_timeout
;
524 wid_list
[wid_cnt
].type
= WID_SHORT
;
525 wid_list
[wid_cnt
].size
= sizeof(u16
);
526 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->cfg_attr_info
.auth_timeout
;
528 PRINT_ER("Range(1 ~ 65535) over\n");
534 if (cfg_param_attr
->cfg_attr_info
.flag
& POWER_MANAGEMENT
) {
535 if (cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
< 5) {
536 wid_list
[wid_cnt
].id
= WID_POWER_MANAGEMENT
;
537 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
538 wid_list
[wid_cnt
].type
= WID_CHAR
;
539 wid_list
[wid_cnt
].size
= sizeof(char);
540 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
542 PRINT_ER("Invalid power mode\n");
548 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_SHORT
) {
549 if (cfg_param_attr
->cfg_attr_info
.short_retry_limit
> 0 &&
550 cfg_param_attr
->cfg_attr_info
.short_retry_limit
< 256) {
551 wid_list
[wid_cnt
].id
= WID_SHORT_RETRY_LIMIT
;
552 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
553 wid_list
[wid_cnt
].type
= WID_SHORT
;
554 wid_list
[wid_cnt
].size
= sizeof(u16
);
555 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
557 PRINT_ER("Range(1~256) over\n");
563 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_LONG
) {
564 if (cfg_param_attr
->cfg_attr_info
.long_retry_limit
> 0 &&
565 cfg_param_attr
->cfg_attr_info
.long_retry_limit
< 256) {
566 wid_list
[wid_cnt
].id
= WID_LONG_RETRY_LIMIT
;
567 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
568 wid_list
[wid_cnt
].type
= WID_SHORT
;
569 wid_list
[wid_cnt
].size
= sizeof(u16
);
570 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
572 PRINT_ER("Range(1~256) over\n");
578 if (cfg_param_attr
->cfg_attr_info
.flag
& FRAG_THRESHOLD
) {
579 if (cfg_param_attr
->cfg_attr_info
.frag_threshold
> 255 &&
580 cfg_param_attr
->cfg_attr_info
.frag_threshold
< 7937) {
581 wid_list
[wid_cnt
].id
= WID_FRAG_THRESHOLD
;
582 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.frag_threshold
;
583 wid_list
[wid_cnt
].type
= WID_SHORT
;
584 wid_list
[wid_cnt
].size
= sizeof(u16
);
585 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->cfg_attr_info
.frag_threshold
;
587 PRINT_ER("Threshold Range fail\n");
593 if (cfg_param_attr
->cfg_attr_info
.flag
& RTS_THRESHOLD
) {
594 if (cfg_param_attr
->cfg_attr_info
.rts_threshold
> 255 &&
595 cfg_param_attr
->cfg_attr_info
.rts_threshold
< 65536) {
596 wid_list
[wid_cnt
].id
= WID_RTS_THRESHOLD
;
597 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.rts_threshold
;
598 wid_list
[wid_cnt
].type
= WID_SHORT
;
599 wid_list
[wid_cnt
].size
= sizeof(u16
);
600 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->cfg_attr_info
.rts_threshold
;
602 PRINT_ER("Threshold Range fail\n");
608 if (cfg_param_attr
->cfg_attr_info
.flag
& PREAMBLE
) {
609 if (cfg_param_attr
->cfg_attr_info
.preamble_type
< 3) {
610 wid_list
[wid_cnt
].id
= WID_PREAMBLE
;
611 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.preamble_type
;
612 wid_list
[wid_cnt
].type
= WID_CHAR
;
613 wid_list
[wid_cnt
].size
= sizeof(char);
614 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->cfg_attr_info
.preamble_type
;
616 PRINT_ER("Preamle Range(0~2) over\n");
622 if (cfg_param_attr
->cfg_attr_info
.flag
& SHORT_SLOT_ALLOWED
) {
623 if (cfg_param_attr
->cfg_attr_info
.short_slot_allowed
< 2) {
624 wid_list
[wid_cnt
].id
= WID_SHORT_SLOT_ALLOWED
;
625 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
626 wid_list
[wid_cnt
].type
= WID_CHAR
;
627 wid_list
[wid_cnt
].size
= sizeof(char);
628 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
630 PRINT_ER("Short slot(2) over\n");
636 if (cfg_param_attr
->cfg_attr_info
.flag
& TXOP_PROT_DISABLE
) {
637 if (cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
< 2) {
638 wid_list
[wid_cnt
].id
= WID_11N_TXOP_PROT_DISABLE
;
639 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
640 wid_list
[wid_cnt
].type
= WID_CHAR
;
641 wid_list
[wid_cnt
].size
= sizeof(char);
642 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
644 PRINT_ER("TXOP prot disable\n");
650 if (cfg_param_attr
->cfg_attr_info
.flag
& BEACON_INTERVAL
) {
651 if (cfg_param_attr
->cfg_attr_info
.beacon_interval
> 0 &&
652 cfg_param_attr
->cfg_attr_info
.beacon_interval
< 65536) {
653 wid_list
[wid_cnt
].id
= WID_BEACON_INTERVAL
;
654 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.beacon_interval
;
655 wid_list
[wid_cnt
].type
= WID_SHORT
;
656 wid_list
[wid_cnt
].size
= sizeof(u16
);
657 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->cfg_attr_info
.beacon_interval
;
659 PRINT_ER("Beacon interval(1~65535) fail\n");
665 if (cfg_param_attr
->cfg_attr_info
.flag
& DTIM_PERIOD
) {
666 if (cfg_param_attr
->cfg_attr_info
.dtim_period
> 0 &&
667 cfg_param_attr
->cfg_attr_info
.dtim_period
< 256) {
668 wid_list
[wid_cnt
].id
= WID_DTIM_PERIOD
;
669 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.dtim_period
;
670 wid_list
[wid_cnt
].type
= WID_CHAR
;
671 wid_list
[wid_cnt
].size
= sizeof(char);
672 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->cfg_attr_info
.dtim_period
;
674 PRINT_ER("DTIM range(1~255) fail\n");
680 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY
) {
681 if (cfg_param_attr
->cfg_attr_info
.site_survey_enabled
< 3) {
682 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY
;
683 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
684 wid_list
[wid_cnt
].type
= WID_CHAR
;
685 wid_list
[wid_cnt
].size
= sizeof(char);
686 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
688 PRINT_ER("Site survey disable\n");
694 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY_SCAN_TIME
) {
695 if (cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
> 0 &&
696 cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
< 65536) {
697 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY_SCAN_TIME
;
698 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
699 wid_list
[wid_cnt
].type
= WID_SHORT
;
700 wid_list
[wid_cnt
].size
= sizeof(u16
);
701 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
703 PRINT_ER("Site survey scan time(1~65535) over\n");
709 if (cfg_param_attr
->cfg_attr_info
.flag
& ACTIVE_SCANTIME
) {
710 if (cfg_param_attr
->cfg_attr_info
.active_scan_time
> 0 &&
711 cfg_param_attr
->cfg_attr_info
.active_scan_time
< 65536) {
712 wid_list
[wid_cnt
].id
= WID_ACTIVE_SCAN_TIME
;
713 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.active_scan_time
;
714 wid_list
[wid_cnt
].type
= WID_SHORT
;
715 wid_list
[wid_cnt
].size
= sizeof(u16
);
716 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->cfg_attr_info
.active_scan_time
;
718 PRINT_ER("Active scan time(1~65535) over\n");
724 if (cfg_param_attr
->cfg_attr_info
.flag
& PASSIVE_SCANTIME
) {
725 if (cfg_param_attr
->cfg_attr_info
.passive_scan_time
> 0 &&
726 cfg_param_attr
->cfg_attr_info
.passive_scan_time
< 65536) {
727 wid_list
[wid_cnt
].id
= WID_PASSIVE_SCAN_TIME
;
728 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
729 wid_list
[wid_cnt
].type
= WID_SHORT
;
730 wid_list
[wid_cnt
].size
= sizeof(u16
);
731 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
733 PRINT_ER("Passive scan time(1~65535) over\n");
739 if (cfg_param_attr
->cfg_attr_info
.flag
& CURRENT_TX_RATE
) {
740 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->cfg_attr_info
.curr_tx_rate
;
742 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
743 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
744 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
745 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
746 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
747 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
748 wid_list
[wid_cnt
].id
= WID_CURRENT_TX_RATE
;
749 wid_list
[wid_cnt
].val
= (s8
*)&curr_tx_rate
;
750 wid_list
[wid_cnt
].type
= WID_SHORT
;
751 wid_list
[wid_cnt
].size
= sizeof(u16
);
752 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
754 PRINT_ER("out of TX rate\n");
761 result
= wilc_send_config_pkt(vif
, SET_CFG
, wid_list
,
762 wid_cnt
, wilc_get_vif_idx(vif
));
765 PRINT_ER("Error in setting CFG params\n");
768 up(&hif_drv
->sem_cfg_values
);
772 static void Handle_wait_msg_q_empty(void)
774 wilc_initialized
= 0;
775 up(&hif_sema_wait_response
);
778 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
779 enum scan_event enuEvent
);
781 static s32
Handle_Scan(struct wilc_vif
*vif
,
782 struct scan_attr
*pstrHostIFscanAttr
)
785 struct wid strWIDList
[5];
786 u32 u32WidsCount
= 0;
790 u8
*pu8HdnNtwrksWidVal
= NULL
;
791 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
793 hif_drv
->usr_scan_req
.scan_result
= pstrHostIFscanAttr
->result
;
794 hif_drv
->usr_scan_req
.arg
= pstrHostIFscanAttr
->arg
;
796 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
797 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
798 PRINT_ER("Already scan\n");
803 if (wilc_optaining_ip
|| wilc_connecting
) {
804 PRINT_ER("Don't do obss scan\n");
809 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
811 strWIDList
[u32WidsCount
].id
= (u16
)WID_SSID_PROBE_REQ
;
812 strWIDList
[u32WidsCount
].type
= WID_STR
;
814 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++)
815 valuesize
+= ((pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
) + 1);
816 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
817 strWIDList
[u32WidsCount
].val
= pu8HdnNtwrksWidVal
;
818 if (strWIDList
[u32WidsCount
].val
) {
819 pu8Buffer
= strWIDList
[u32WidsCount
].val
;
821 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.n_ssids
;
823 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++) {
824 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
825 memcpy(pu8Buffer
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
);
826 pu8Buffer
+= pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
829 strWIDList
[u32WidsCount
].size
= (s32
)(valuesize
+ 1);
834 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_PROBE
;
835 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
836 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ies
;
837 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ies_len
;
841 strWIDList
[u32WidsCount
].id
= WID_SCAN_TYPE
;
842 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
843 strWIDList
[u32WidsCount
].size
= sizeof(char);
844 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->type
;
847 strWIDList
[u32WidsCount
].id
= WID_SCAN_CHANNEL_LIST
;
848 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
850 if (pstrHostIFscanAttr
->ch_freq_list
&&
851 pstrHostIFscanAttr
->ch_list_len
> 0) {
854 for (i
= 0; i
< pstrHostIFscanAttr
->ch_list_len
; i
++) {
855 if (pstrHostIFscanAttr
->ch_freq_list
[i
] > 0)
856 pstrHostIFscanAttr
->ch_freq_list
[i
] = pstrHostIFscanAttr
->ch_freq_list
[i
] - 1;
860 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ch_freq_list
;
861 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ch_list_len
;
864 strWIDList
[u32WidsCount
].id
= WID_START_SCAN_REQ
;
865 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
866 strWIDList
[u32WidsCount
].size
= sizeof(char);
867 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->src
;
870 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
871 scan_while_connected
= true;
872 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
873 scan_while_connected
= false;
875 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
877 wilc_get_vif_idx(vif
));
880 PRINT_ER("Failed to send scan parameters config packet\n");
884 del_timer(&hif_drv
->scan_timer
);
885 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
888 kfree(pstrHostIFscanAttr
->ch_freq_list
);
889 pstrHostIFscanAttr
->ch_freq_list
= NULL
;
891 kfree(pstrHostIFscanAttr
->ies
);
892 pstrHostIFscanAttr
->ies
= NULL
;
893 kfree(pstrHostIFscanAttr
->hidden_network
.net_info
);
894 pstrHostIFscanAttr
->hidden_network
.net_info
= NULL
;
896 kfree(pu8HdnNtwrksWidVal
);
901 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
902 enum scan_event enuEvent
)
905 u8 u8abort_running_scan
;
907 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
909 if (enuEvent
== SCAN_EVENT_ABORTED
) {
910 u8abort_running_scan
= 1;
911 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
913 wid
.val
= (s8
*)&u8abort_running_scan
;
914 wid
.size
= sizeof(char);
916 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
917 wilc_get_vif_idx(vif
));
920 PRINT_ER("Failed to set abort running scan\n");
926 PRINT_ER("Driver handler is NULL\n");
930 if (hif_drv
->usr_scan_req
.scan_result
) {
931 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
932 hif_drv
->usr_scan_req
.arg
, NULL
);
933 hif_drv
->usr_scan_req
.scan_result
= NULL
;
939 u8 wilc_connected_ssid
[6] = {0};
940 static s32
Handle_Connect(struct wilc_vif
*vif
,
941 struct connect_attr
*pstrHostIFconnectAttr
)
944 struct wid strWIDList
[8];
945 u32 u32WidsCount
= 0, dummyval
= 0;
946 u8
*pu8CurrByte
= NULL
;
947 struct join_bss_param
*ptstrJoinBssParam
;
948 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
950 if (memcmp(pstrHostIFconnectAttr
->bssid
, wilc_connected_ssid
, ETH_ALEN
) == 0) {
952 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
956 ptstrJoinBssParam
= pstrHostIFconnectAttr
->params
;
957 if (!ptstrJoinBssParam
) {
958 PRINT_ER("Required BSSID not found\n");
963 if (pstrHostIFconnectAttr
->bssid
) {
964 hif_drv
->usr_conn_req
.bssid
= kmalloc(6, GFP_KERNEL
);
965 memcpy(hif_drv
->usr_conn_req
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
968 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
969 if (pstrHostIFconnectAttr
->ssid
) {
970 hif_drv
->usr_conn_req
.ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
971 memcpy(hif_drv
->usr_conn_req
.ssid
,
972 pstrHostIFconnectAttr
->ssid
,
973 pstrHostIFconnectAttr
->ssid_len
);
974 hif_drv
->usr_conn_req
.ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
977 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
978 if (pstrHostIFconnectAttr
->ies
) {
979 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
980 memcpy(hif_drv
->usr_conn_req
.ies
,
981 pstrHostIFconnectAttr
->ies
,
982 pstrHostIFconnectAttr
->ies_len
);
985 hif_drv
->usr_conn_req
.security
= pstrHostIFconnectAttr
->security
;
986 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
987 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
988 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
990 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
991 strWIDList
[u32WidsCount
].type
= WID_INT
;
992 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
993 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
996 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
997 strWIDList
[u32WidsCount
].type
= WID_INT
;
998 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
999 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1002 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
1003 strWIDList
[u32WidsCount
].type
= WID_INT
;
1004 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1005 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1009 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1010 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1011 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
1012 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
1015 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1016 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
1017 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
1018 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
1022 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1023 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1024 strWIDList
[u32WidsCount
].size
= sizeof(char);
1025 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.security
;
1028 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1029 mode_11i
= hif_drv
->usr_conn_req
.security
;
1031 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1032 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1033 strWIDList
[u32WidsCount
].size
= sizeof(char);
1034 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
1037 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1038 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
1040 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1041 strWIDList
[u32WidsCount
].type
= WID_STR
;
1042 strWIDList
[u32WidsCount
].size
= 112;
1043 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
1045 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1046 join_req_size
= strWIDList
[u32WidsCount
].size
;
1047 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
1049 if (!strWIDList
[u32WidsCount
].val
) {
1054 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1056 if (pstrHostIFconnectAttr
->ssid
) {
1057 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
1058 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1060 pu8CurrByte
+= MAX_SSID_LEN
;
1061 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1063 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
1064 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1066 PRINT_ER("Channel out of range\n");
1067 *(pu8CurrByte
++) = 0xFF;
1069 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1070 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1072 if (pstrHostIFconnectAttr
->bssid
)
1073 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1076 if (pstrHostIFconnectAttr
->bssid
)
1077 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1080 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1081 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1082 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1084 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1085 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1087 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1088 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1090 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1091 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1093 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1094 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1095 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1097 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1098 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1100 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1101 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1103 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1104 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1106 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1107 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1109 if (ptstrJoinBssParam
->noa_enabled
) {
1110 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1111 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1112 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1113 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1115 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1116 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1118 if (ptstrJoinBssParam
->opp_enabled
)
1119 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1121 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1123 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1124 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1126 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1127 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1129 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1130 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1133 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1136 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1137 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1141 if (pstrHostIFconnectAttr
->bssid
)
1142 memcpy(wilc_connected_ssid
,
1143 pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1145 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1147 wilc_get_vif_idx(vif
));
1149 PRINT_ER("failed to send config packet\n");
1153 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1158 tstrConnectInfo strConnectInfo
;
1160 del_timer(&hif_drv
->connect_timer
);
1162 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1164 if (pstrHostIFconnectAttr
->result
) {
1165 if (pstrHostIFconnectAttr
->bssid
)
1166 memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1168 if (pstrHostIFconnectAttr
->ies
) {
1169 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->ies_len
;
1170 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1171 memcpy(strConnectInfo
.pu8ReqIEs
,
1172 pstrHostIFconnectAttr
->ies
,
1173 pstrHostIFconnectAttr
->ies_len
);
1176 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1180 pstrHostIFconnectAttr
->arg
);
1181 hif_drv
->hif_state
= HOST_IF_IDLE
;
1182 kfree(strConnectInfo
.pu8ReqIEs
);
1183 strConnectInfo
.pu8ReqIEs
= NULL
;
1186 PRINT_ER("Connect callback function pointer is NULL\n");
1190 kfree(pstrHostIFconnectAttr
->bssid
);
1191 pstrHostIFconnectAttr
->bssid
= NULL
;
1193 kfree(pstrHostIFconnectAttr
->ssid
);
1194 pstrHostIFconnectAttr
->ssid
= NULL
;
1196 kfree(pstrHostIFconnectAttr
->ies
);
1197 pstrHostIFconnectAttr
->ies
= NULL
;
1203 static s32
Handle_FlushConnect(struct wilc_vif
*vif
)
1206 struct wid strWIDList
[5];
1207 u32 u32WidsCount
= 0;
1208 u8
*pu8CurrByte
= NULL
;
1210 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1211 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1212 strWIDList
[u32WidsCount
].val
= info_element
;
1213 strWIDList
[u32WidsCount
].size
= info_element_size
;
1216 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1217 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1218 strWIDList
[u32WidsCount
].size
= sizeof(char);
1219 strWIDList
[u32WidsCount
].val
= (s8
*)(&(mode_11i
));
1222 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1223 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1224 strWIDList
[u32WidsCount
].size
= sizeof(char);
1225 strWIDList
[u32WidsCount
].val
= (s8
*)(&auth_type
);
1228 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1229 strWIDList
[u32WidsCount
].type
= WID_STR
;
1230 strWIDList
[u32WidsCount
].size
= join_req_size
;
1231 strWIDList
[u32WidsCount
].val
= (s8
*)join_req
;
1232 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1234 pu8CurrByte
+= FLUSHED_BYTE_POS
;
1235 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
1239 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1241 wilc_get_vif_idx(join_req_vif
));
1243 PRINT_ER("failed to send config packet\n");
1250 static s32
Handle_ConnectTimeout(struct wilc_vif
*vif
)
1253 tstrConnectInfo strConnectInfo
;
1255 u16 u16DummyReasonCode
= 0;
1256 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1259 PRINT_ER("Driver handler is NULL\n");
1263 hif_drv
->hif_state
= HOST_IF_IDLE
;
1265 scan_while_connected
= false;
1267 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1269 if (hif_drv
->usr_conn_req
.conn_result
) {
1270 if (hif_drv
->usr_conn_req
.bssid
) {
1271 memcpy(strConnectInfo
.au8bssid
,
1272 hif_drv
->usr_conn_req
.bssid
, 6);
1275 if (hif_drv
->usr_conn_req
.ies
) {
1276 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1277 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1278 memcpy(strConnectInfo
.pu8ReqIEs
,
1279 hif_drv
->usr_conn_req
.ies
,
1280 hif_drv
->usr_conn_req
.ies_len
);
1283 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1287 hif_drv
->usr_conn_req
.arg
);
1289 kfree(strConnectInfo
.pu8ReqIEs
);
1290 strConnectInfo
.pu8ReqIEs
= NULL
;
1292 PRINT_ER("Connect callback function pointer is NULL\n");
1295 wid
.id
= (u16
)WID_DISCONNECT
;
1296 wid
.type
= WID_CHAR
;
1297 wid
.val
= (s8
*)&u16DummyReasonCode
;
1298 wid
.size
= sizeof(char);
1300 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1301 wilc_get_vif_idx(vif
));
1303 PRINT_ER("Failed to send dissconect config packet\n");
1305 hif_drv
->usr_conn_req
.ssid_len
= 0;
1306 kfree(hif_drv
->usr_conn_req
.ssid
);
1307 hif_drv
->usr_conn_req
.ssid
= NULL
;
1308 kfree(hif_drv
->usr_conn_req
.bssid
);
1309 hif_drv
->usr_conn_req
.bssid
= NULL
;
1310 hif_drv
->usr_conn_req
.ies_len
= 0;
1311 kfree(hif_drv
->usr_conn_req
.ies
);
1312 hif_drv
->usr_conn_req
.ies
= NULL
;
1314 eth_zero_addr(wilc_connected_ssid
);
1316 if (join_req
&& join_req_vif
== vif
) {
1321 if (info_element
&& join_req_vif
== vif
) {
1322 kfree(info_element
);
1323 info_element
= NULL
;
1329 static s32
Handle_RcvdNtwrkInfo(struct wilc_vif
*vif
,
1330 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1333 bool bNewNtwrkFound
;
1335 struct network_info
*pstrNetworkInfo
= NULL
;
1336 void *pJoinParams
= NULL
;
1337 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1339 bNewNtwrkFound
= true;
1341 if (hif_drv
->usr_scan_req
.scan_result
) {
1342 wilc_parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1343 if ((!pstrNetworkInfo
) ||
1344 (!hif_drv
->usr_scan_req
.scan_result
)) {
1345 PRINT_ER("driver is null\n");
1350 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1351 if ((hif_drv
->usr_scan_req
.net_info
[i
].bssid
) &&
1352 (pstrNetworkInfo
->bssid
)) {
1353 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].bssid
,
1354 pstrNetworkInfo
->bssid
, 6) == 0) {
1355 if (pstrNetworkInfo
->rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].rssi
) {
1358 hif_drv
->usr_scan_req
.net_info
[i
].rssi
= pstrNetworkInfo
->rssi
;
1359 bNewNtwrkFound
= false;
1366 if (bNewNtwrkFound
) {
1367 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1368 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].rssi
= pstrNetworkInfo
->rssi
;
1370 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
&&
1371 pstrNetworkInfo
->bssid
) {
1372 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
,
1373 pstrNetworkInfo
->bssid
, 6);
1375 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1377 pstrNetworkInfo
->new_network
= true;
1378 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1380 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1381 hif_drv
->usr_scan_req
.arg
,
1386 pstrNetworkInfo
->new_network
= false;
1387 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1388 hif_drv
->usr_scan_req
.arg
, NULL
);
1393 kfree(pstrRcvdNetworkInfo
->buffer
);
1394 pstrRcvdNetworkInfo
->buffer
= NULL
;
1396 if (pstrNetworkInfo
) {
1397 kfree(pstrNetworkInfo
->ies
);
1398 kfree(pstrNetworkInfo
);
1404 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
1405 u8
*pu8AssocRespInfo
,
1406 u32 u32MaxAssocRespInfoLen
,
1407 u32
*pu32RcvdAssocRespInfoLen
);
1409 static s32
Handle_RcvdGnrlAsyncInfo(struct wilc_vif
*vif
,
1410 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1416 u16 u16WidID
= (u16
)WID_NIL
;
1419 u8 u8MacStatusReasonCode
;
1420 u8 u8MacStatusAdditionalInfo
;
1421 tstrConnectInfo strConnectInfo
;
1422 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1424 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1427 PRINT_ER("Driver handler is NULL\n");
1431 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1432 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1433 hif_drv
->usr_scan_req
.scan_result
) {
1434 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1435 !hif_drv
->usr_conn_req
.conn_result
) {
1436 PRINT_ER("driver is null\n");
1440 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1442 if ('I' != u8MsgType
) {
1443 PRINT_ER("Received Message format incorrect.\n");
1447 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1448 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1449 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1450 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1451 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1452 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1453 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1454 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1455 u32 u32RcvdAssocRespInfoLen
= 0;
1456 struct connect_resp_info
*pstrConnectRespInfo
= NULL
;
1458 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1460 if (u8MacStatus
== MAC_CONNECTED
) {
1461 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1463 host_int_get_assoc_res_info(vif
,
1465 MAX_ASSOC_RESP_FRAME_SIZE
,
1466 &u32RcvdAssocRespInfoLen
);
1468 if (u32RcvdAssocRespInfoLen
!= 0) {
1469 s32Err
= wilc_parse_assoc_resp_info(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1470 &pstrConnectRespInfo
);
1472 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err
);
1474 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->status
;
1476 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
1477 if (pstrConnectRespInfo
->ies
) {
1478 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->ies_len
;
1479 strConnectInfo
.pu8RespIEs
= kmalloc(pstrConnectRespInfo
->ies_len
, GFP_KERNEL
);
1480 memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->ies
,
1481 pstrConnectRespInfo
->ies_len
);
1485 if (pstrConnectRespInfo
) {
1486 kfree(pstrConnectRespInfo
->ies
);
1487 kfree(pstrConnectRespInfo
);
1493 if ((u8MacStatus
== MAC_CONNECTED
) &&
1494 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
1495 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1496 eth_zero_addr(wilc_connected_ssid
);
1497 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1498 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1499 eth_zero_addr(wilc_connected_ssid
);
1502 if (hif_drv
->usr_conn_req
.bssid
) {
1503 memcpy(strConnectInfo
.au8bssid
, hif_drv
->usr_conn_req
.bssid
, 6);
1505 if ((u8MacStatus
== MAC_CONNECTED
) &&
1506 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1507 memcpy(hif_drv
->assoc_bssid
,
1508 hif_drv
->usr_conn_req
.bssid
, ETH_ALEN
);
1512 if (hif_drv
->usr_conn_req
.ies
) {
1513 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1514 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1515 memcpy(strConnectInfo
.pu8ReqIEs
,
1516 hif_drv
->usr_conn_req
.ies
,
1517 hif_drv
->usr_conn_req
.ies_len
);
1520 del_timer(&hif_drv
->connect_timer
);
1521 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1525 hif_drv
->usr_conn_req
.arg
);
1527 if ((u8MacStatus
== MAC_CONNECTED
) &&
1528 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1529 wilc_set_power_mgmt(vif
, 0, 0);
1531 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1533 wilc_optaining_ip
= true;
1534 mod_timer(&wilc_during_ip_timer
,
1535 jiffies
+ msecs_to_jiffies(10000));
1537 hif_drv
->hif_state
= HOST_IF_IDLE
;
1538 scan_while_connected
= false;
1541 kfree(strConnectInfo
.pu8RespIEs
);
1542 strConnectInfo
.pu8RespIEs
= NULL
;
1544 kfree(strConnectInfo
.pu8ReqIEs
);
1545 strConnectInfo
.pu8ReqIEs
= NULL
;
1546 hif_drv
->usr_conn_req
.ssid_len
= 0;
1547 kfree(hif_drv
->usr_conn_req
.ssid
);
1548 hif_drv
->usr_conn_req
.ssid
= NULL
;
1549 kfree(hif_drv
->usr_conn_req
.bssid
);
1550 hif_drv
->usr_conn_req
.bssid
= NULL
;
1551 hif_drv
->usr_conn_req
.ies_len
= 0;
1552 kfree(hif_drv
->usr_conn_req
.ies
);
1553 hif_drv
->usr_conn_req
.ies
= NULL
;
1554 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1555 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1556 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1558 if (hif_drv
->usr_scan_req
.scan_result
) {
1559 del_timer(&hif_drv
->scan_timer
);
1560 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1563 strDisconnectNotifInfo
.u16reason
= 0;
1564 strDisconnectNotifInfo
.ie
= NULL
;
1565 strDisconnectNotifInfo
.ie_len
= 0;
1567 if (hif_drv
->usr_conn_req
.conn_result
) {
1568 wilc_optaining_ip
= false;
1569 wilc_set_power_mgmt(vif
, 0, 0);
1571 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1574 &strDisconnectNotifInfo
,
1575 hif_drv
->usr_conn_req
.arg
);
1577 PRINT_ER("Connect result callback function is NULL\n");
1580 eth_zero_addr(hif_drv
->assoc_bssid
);
1582 hif_drv
->usr_conn_req
.ssid_len
= 0;
1583 kfree(hif_drv
->usr_conn_req
.ssid
);
1584 hif_drv
->usr_conn_req
.ssid
= NULL
;
1585 kfree(hif_drv
->usr_conn_req
.bssid
);
1586 hif_drv
->usr_conn_req
.bssid
= NULL
;
1587 hif_drv
->usr_conn_req
.ies_len
= 0;
1588 kfree(hif_drv
->usr_conn_req
.ies
);
1589 hif_drv
->usr_conn_req
.ies
= NULL
;
1591 if (join_req
&& join_req_vif
== vif
) {
1596 if (info_element
&& join_req_vif
== vif
) {
1597 kfree(info_element
);
1598 info_element
= NULL
;
1601 hif_drv
->hif_state
= HOST_IF_IDLE
;
1602 scan_while_connected
= false;
1604 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1605 (hif_drv
->usr_scan_req
.scan_result
)) {
1606 del_timer(&hif_drv
->scan_timer
);
1607 if (hif_drv
->usr_scan_req
.scan_result
)
1608 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1612 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1613 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1618 static int Handle_Key(struct wilc_vif
*vif
,
1619 struct key_attr
*pstrHostIFkeyAttr
)
1623 struct wid strWIDList
[5];
1628 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1630 switch (pstrHostIFkeyAttr
->type
) {
1633 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1634 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1635 strWIDList
[0].type
= WID_CHAR
;
1636 strWIDList
[0].size
= sizeof(char);
1637 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1639 strWIDList
[1].id
= WID_AUTH_TYPE
;
1640 strWIDList
[1].type
= WID_CHAR
;
1641 strWIDList
[1].size
= sizeof(char);
1642 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1644 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2,
1647 if (pu8keybuf
== NULL
) {
1648 PRINT_ER("No buffer to send Key\n");
1652 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1653 pu8keybuf
[1] = pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1655 memcpy(&pu8keybuf
[2], pstrHostIFkeyAttr
->attr
.wep
.key
,
1656 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1658 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1660 strWIDList
[2].id
= (u16
)WID_WEP_KEY_VALUE
;
1661 strWIDList
[2].type
= WID_STR
;
1662 strWIDList
[2].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1663 strWIDList
[2].val
= (s8
*)pu8keybuf
;
1665 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1667 wilc_get_vif_idx(vif
));
1669 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1670 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1672 PRINT_ER("No buffer to send Key\n");
1675 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1676 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1677 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1678 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1679 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1681 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1683 wid
.val
= (s8
*)pu8keybuf
;
1684 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1686 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1688 wilc_get_vif_idx(vif
));
1690 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1691 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1694 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1695 wid
.val
= s8idxarray
;
1698 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1700 wilc_get_vif_idx(vif
));
1701 } else if (pstrHostIFkeyAttr
->action
& DEFAULTKEY
) {
1702 wid
.id
= (u16
)WID_KEY_ID
;
1703 wid
.type
= WID_CHAR
;
1704 wid
.val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1705 wid
.size
= sizeof(char);
1707 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1709 wilc_get_vif_idx(vif
));
1711 up(&hif_drv
->sem_test_key_block
);
1715 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1716 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1718 PRINT_ER("No buffer to send RxGTK Key\n");
1720 goto _WPARxGtk_end_case_
;
1723 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1724 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1726 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1727 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1728 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1729 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1731 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1732 strWIDList
[0].type
= WID_CHAR
;
1733 strWIDList
[0].size
= sizeof(char);
1734 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1736 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1737 strWIDList
[1].type
= WID_STR
;
1738 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1739 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1741 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1743 wilc_get_vif_idx(vif
));
1746 up(&hif_drv
->sem_test_key_block
);
1747 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1748 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1749 if (pu8keybuf
== NULL
) {
1750 PRINT_ER("No buffer to send RxGTK Key\n");
1752 goto _WPARxGtk_end_case_
;
1755 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
1756 memcpy(pu8keybuf
, hif_drv
->assoc_bssid
, ETH_ALEN
);
1758 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
1760 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1761 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1762 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1763 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1764 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1766 wid
.id
= (u16
)WID_ADD_RX_GTK
;
1768 wid
.val
= (s8
*)pu8keybuf
;
1769 wid
.size
= RX_MIC_KEY_MSG_LEN
;
1771 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1773 wilc_get_vif_idx(vif
));
1776 up(&hif_drv
->sem_test_key_block
);
1778 _WPARxGtk_end_case_
:
1779 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1780 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1787 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1788 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1790 PRINT_ER("No buffer to send PTK Key\n");
1792 goto _WPAPtk_end_case_
;
1795 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1796 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1797 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1798 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1799 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1801 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1802 strWIDList
[0].type
= WID_CHAR
;
1803 strWIDList
[0].size
= sizeof(char);
1804 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1806 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1807 strWIDList
[1].type
= WID_STR
;
1808 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1809 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1811 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1813 wilc_get_vif_idx(vif
));
1815 up(&hif_drv
->sem_test_key_block
);
1816 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1817 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1819 PRINT_ER("No buffer to send PTK Key\n");
1821 goto _WPAPtk_end_case_
;
1824 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1825 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1826 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1827 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1829 wid
.id
= (u16
)WID_ADD_PTK
;
1831 wid
.val
= (s8
*)pu8keybuf
;
1832 wid
.size
= PTK_KEY_MSG_LEN
;
1834 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1836 wilc_get_vif_idx(vif
));
1838 up(&hif_drv
->sem_test_key_block
);
1842 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1849 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1851 PRINT_ER("No buffer to send PMKSA Key\n");
1855 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1857 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1858 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1859 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1862 wid
.id
= (u16
)WID_PMKID_INFO
;
1864 wid
.val
= (s8
*)pu8keybuf
;
1865 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1867 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1868 wilc_get_vif_idx(vif
));
1875 PRINT_ER("Failed to send key config packet\n");
1880 static void Handle_Disconnect(struct wilc_vif
*vif
)
1883 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1886 u16 u16DummyReasonCode
= 0;
1888 wid
.id
= (u16
)WID_DISCONNECT
;
1889 wid
.type
= WID_CHAR
;
1890 wid
.val
= (s8
*)&u16DummyReasonCode
;
1891 wid
.size
= sizeof(char);
1893 wilc_optaining_ip
= false;
1894 wilc_set_power_mgmt(vif
, 0, 0);
1896 eth_zero_addr(wilc_connected_ssid
);
1898 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1899 wilc_get_vif_idx(vif
));
1902 PRINT_ER("Failed to send dissconect config packet\n");
1904 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1906 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1908 strDisconnectNotifInfo
.u16reason
= 0;
1909 strDisconnectNotifInfo
.ie
= NULL
;
1910 strDisconnectNotifInfo
.ie_len
= 0;
1912 if (hif_drv
->usr_scan_req
.scan_result
) {
1913 del_timer(&hif_drv
->scan_timer
);
1914 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
1916 hif_drv
->usr_scan_req
.arg
,
1918 hif_drv
->usr_scan_req
.scan_result
= NULL
;
1921 if (hif_drv
->usr_conn_req
.conn_result
) {
1922 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
)
1923 del_timer(&hif_drv
->connect_timer
);
1925 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1928 &strDisconnectNotifInfo
,
1929 hif_drv
->usr_conn_req
.arg
);
1931 PRINT_ER("usr_conn_req.conn_result = NULL\n");
1934 scan_while_connected
= false;
1936 hif_drv
->hif_state
= HOST_IF_IDLE
;
1938 eth_zero_addr(hif_drv
->assoc_bssid
);
1940 hif_drv
->usr_conn_req
.ssid_len
= 0;
1941 kfree(hif_drv
->usr_conn_req
.ssid
);
1942 hif_drv
->usr_conn_req
.ssid
= NULL
;
1943 kfree(hif_drv
->usr_conn_req
.bssid
);
1944 hif_drv
->usr_conn_req
.bssid
= NULL
;
1945 hif_drv
->usr_conn_req
.ies_len
= 0;
1946 kfree(hif_drv
->usr_conn_req
.ies
);
1947 hif_drv
->usr_conn_req
.ies
= NULL
;
1949 if (join_req
&& join_req_vif
== vif
) {
1954 if (info_element
&& join_req_vif
== vif
) {
1955 kfree(info_element
);
1956 info_element
= NULL
;
1960 up(&hif_drv
->sem_test_disconn_block
);
1963 void wilc_resolve_disconnect_aberration(struct wilc_vif
*vif
)
1967 if ((vif
->hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1968 (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTING
))
1969 wilc_disconnect(vif
, 1);
1972 static s32
Handle_GetChnl(struct wilc_vif
*vif
)
1977 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
1978 wid
.type
= WID_CHAR
;
1979 wid
.val
= (s8
*)&ch_no
;
1980 wid
.size
= sizeof(char);
1982 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1983 wilc_get_vif_idx(vif
));
1986 PRINT_ER("Failed to get channel number\n");
1993 static void Handle_GetRssi(struct wilc_vif
*vif
)
1998 wid
.id
= (u16
)WID_RSSI
;
1999 wid
.type
= WID_CHAR
;
2001 wid
.size
= sizeof(char);
2003 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2004 wilc_get_vif_idx(vif
));
2006 PRINT_ER("Failed to get RSSI value\n");
2010 up(&vif
->hif_drv
->sem_get_rssi
);
2013 static void Handle_GetLinkspeed(struct wilc_vif
*vif
)
2020 wid
.id
= (u16
)WID_LINKSPEED
;
2021 wid
.type
= WID_CHAR
;
2022 wid
.val
= &link_speed
;
2023 wid
.size
= sizeof(char);
2025 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2026 wilc_get_vif_idx(vif
));
2028 PRINT_ER("Failed to get LINKSPEED value\n");
2034 static s32
Handle_GetStatistics(struct wilc_vif
*vif
,
2035 struct rf_info
*pstrStatistics
)
2037 struct wid strWIDList
[5];
2038 u32 u32WidsCount
= 0, result
= 0;
2040 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
2041 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2042 strWIDList
[u32WidsCount
].size
= sizeof(char);
2043 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
2046 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
2047 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2048 strWIDList
[u32WidsCount
].size
= sizeof(char);
2049 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
2052 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
2053 strWIDList
[u32WidsCount
].type
= WID_INT
;
2054 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2055 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
2058 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
2059 strWIDList
[u32WidsCount
].type
= WID_INT
;
2060 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2061 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
2064 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
2065 strWIDList
[u32WidsCount
].type
= WID_INT
;
2066 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2067 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
2070 result
= wilc_send_config_pkt(vif
, GET_CFG
, strWIDList
,
2072 wilc_get_vif_idx(vif
));
2075 PRINT_ER("Failed to send scan parameters config packet\n");
2077 if (pstrStatistics
->link_speed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
&&
2078 pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
2079 wilc_enable_tcp_ack_filter(true);
2080 else if (pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
2081 wilc_enable_tcp_ack_filter(false);
2083 if (pstrStatistics
!= &vif
->wilc
->dummy_statistics
)
2084 up(&hif_sema_wait_response
);
2088 static s32
Handle_Get_InActiveTime(struct wilc_vif
*vif
,
2089 struct sta_inactive_t
*strHostIfStaInactiveT
)
2094 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2096 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
2098 wid
.size
= ETH_ALEN
;
2099 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2102 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
2104 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
2106 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2107 wilc_get_vif_idx(vif
));
2110 PRINT_ER("Failed to SET incative time\n");
2114 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
2116 wid
.val
= (s8
*)&inactive_time
;
2117 wid
.size
= sizeof(u32
);
2119 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2120 wilc_get_vif_idx(vif
));
2123 PRINT_ER("Failed to get incative time\n");
2127 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", inactive_time
);
2129 up(&hif_drv
->sem_inactive_time
);
2134 static void Handle_AddBeacon(struct wilc_vif
*vif
,
2135 struct beacon_attr
*pstrSetBeaconParam
)
2141 wid
.id
= (u16
)WID_ADD_BEACON
;
2143 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
2144 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2148 pu8CurrByte
= wid
.val
;
2149 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
2150 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
2151 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
2152 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
2154 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
2155 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
2156 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
2157 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
2159 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
2160 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
2161 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
2162 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
2164 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
2165 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2167 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2168 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2169 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2170 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2172 if (pstrSetBeaconParam
->tail
)
2173 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2174 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2176 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2177 wilc_get_vif_idx(vif
));
2179 PRINT_ER("Failed to send add beacon config packet\n");
2183 kfree(pstrSetBeaconParam
->head
);
2184 kfree(pstrSetBeaconParam
->tail
);
2187 static void Handle_DelBeacon(struct wilc_vif
*vif
)
2193 wid
.id
= (u16
)WID_DEL_BEACON
;
2194 wid
.type
= WID_CHAR
;
2195 wid
.size
= sizeof(char);
2196 wid
.val
= &del_beacon
;
2201 pu8CurrByte
= wid
.val
;
2203 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2204 wilc_get_vif_idx(vif
));
2206 PRINT_ER("Failed to send delete beacon config packet\n");
2209 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2210 struct add_sta_param
*pstrStationParam
)
2214 pu8CurrByte
= pu8Buffer
;
2216 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2217 pu8CurrByte
+= ETH_ALEN
;
2219 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2220 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2222 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2223 if (pstrStationParam
->rates_len
> 0)
2224 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2225 pstrStationParam
->rates_len
);
2226 pu8CurrByte
+= pstrStationParam
->rates_len
;
2228 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2229 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2230 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2232 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2233 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2234 WILC_SUPP_MCS_SET_SIZE
);
2235 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2237 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2238 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2240 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2241 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2242 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2243 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2245 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2247 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2248 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2250 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2251 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2253 return pu8CurrByte
- pu8Buffer
;
2256 static void Handle_AddStation(struct wilc_vif
*vif
,
2257 struct add_sta_param
*pstrStationParam
)
2263 wid
.id
= (u16
)WID_ADD_STA
;
2265 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2267 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2271 pu8CurrByte
= wid
.val
;
2272 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2274 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2275 wilc_get_vif_idx(vif
));
2277 PRINT_ER("Failed to send add station config packet\n");
2280 kfree(pstrStationParam
->rates
);
2284 static void Handle_DelAllSta(struct wilc_vif
*vif
,
2285 struct del_all_sta
*pstrDelAllStaParam
)
2291 u8 au8Zero_Buff
[6] = {0};
2293 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2295 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2297 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2301 pu8CurrByte
= wid
.val
;
2303 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2305 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2306 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2307 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2311 pu8CurrByte
+= ETH_ALEN
;
2314 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2315 wilc_get_vif_idx(vif
));
2317 PRINT_ER("Failed to send add station config packet\n");
2322 up(&hif_sema_wait_response
);
2325 static void Handle_DelStation(struct wilc_vif
*vif
,
2326 struct del_sta
*pstrDelStaParam
)
2332 wid
.id
= (u16
)WID_REMOVE_STA
;
2334 wid
.size
= ETH_ALEN
;
2336 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2340 pu8CurrByte
= wid
.val
;
2342 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2344 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2345 wilc_get_vif_idx(vif
));
2347 PRINT_ER("Failed to send add station config packet\n");
2353 static void Handle_EditStation(struct wilc_vif
*vif
,
2354 struct add_sta_param
*pstrStationParam
)
2360 wid
.id
= (u16
)WID_EDIT_STA
;
2362 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2364 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2368 pu8CurrByte
= wid
.val
;
2369 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2371 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2372 wilc_get_vif_idx(vif
));
2374 PRINT_ER("Failed to send edit station config packet\n");
2377 kfree(pstrStationParam
->rates
);
2381 static int Handle_RemainOnChan(struct wilc_vif
*vif
,
2382 struct remain_ch
*pstrHostIfRemainOnChan
)
2385 u8 u8remain_on_chan_flag
;
2387 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2389 if (!hif_drv
->remain_on_ch_pending
) {
2390 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2391 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2392 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2393 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2394 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2396 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2399 if (hif_drv
->usr_scan_req
.scan_result
) {
2400 hif_drv
->remain_on_ch_pending
= 1;
2404 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2409 if (wilc_optaining_ip
|| wilc_connecting
) {
2414 u8remain_on_chan_flag
= true;
2415 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2418 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2424 wid
.val
[0] = u8remain_on_chan_flag
;
2425 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2427 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2428 wilc_get_vif_idx(vif
));
2430 PRINT_ER("Failed to set remain on channel\n");
2434 P2P_LISTEN_STATE
= 1;
2435 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)vif
;
2436 mod_timer(&hif_drv
->remain_on_ch_timer
,
2438 msecs_to_jiffies(pstrHostIfRemainOnChan
->duration
));
2440 if (hif_drv
->remain_on_ch
.ready
)
2441 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2443 if (hif_drv
->remain_on_ch_pending
)
2444 hif_drv
->remain_on_ch_pending
= 0;
2450 static int Handle_RegisterFrame(struct wilc_vif
*vif
,
2451 struct reg_frame
*pstrHostIfRegisterFrame
)
2457 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2459 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2463 pu8CurrByte
= wid
.val
;
2465 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2466 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2467 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2469 wid
.size
= sizeof(u16
) + 2;
2471 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2472 wilc_get_vif_idx(vif
));
2474 PRINT_ER("Failed to frame register config packet\n");
2481 static u32
Handle_ListenStateExpired(struct wilc_vif
*vif
,
2482 struct remain_ch
*pstrHostIfRemainOnChan
)
2484 u8 u8remain_on_chan_flag
;
2487 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2489 if (P2P_LISTEN_STATE
) {
2490 u8remain_on_chan_flag
= false;
2491 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2494 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2497 PRINT_ER("Failed to allocate memory\n");
2501 wid
.val
[0] = u8remain_on_chan_flag
;
2502 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2504 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2505 wilc_get_vif_idx(vif
));
2507 PRINT_ER("Failed to set remain on channel\n");
2511 if (hif_drv
->remain_on_ch
.expired
) {
2512 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2513 pstrHostIfRemainOnChan
->id
);
2515 P2P_LISTEN_STATE
= 0;
2517 netdev_dbg(vif
->ndev
, "Not in listen state\n");
2525 static void ListenTimerCB(unsigned long arg
)
2528 struct host_if_msg msg
;
2529 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2531 del_timer(&vif
->hif_drv
->remain_on_ch_timer
);
2533 memset(&msg
, 0, sizeof(struct host_if_msg
));
2534 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2536 msg
.body
.remain_on_ch
.id
= vif
->hif_drv
->remain_on_ch
.id
;
2538 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2540 PRINT_ER("wilc_mq_send fail\n");
2543 static void Handle_PowerManagement(struct wilc_vif
*vif
,
2544 struct power_mgmt_param
*strPowerMgmtParam
)
2550 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2552 if (strPowerMgmtParam
->enabled
)
2553 s8PowerMode
= MIN_FAST_PS
;
2555 s8PowerMode
= NO_POWERSAVE
;
2557 wid
.val
= &s8PowerMode
;
2558 wid
.size
= sizeof(char);
2560 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2561 wilc_get_vif_idx(vif
));
2563 PRINT_ER("Failed to send power management config packet\n");
2566 static void Handle_SetMulticastFilter(struct wilc_vif
*vif
,
2567 struct set_multicast
*strHostIfSetMulti
)
2573 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2575 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2576 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2580 pu8CurrByte
= wid
.val
;
2581 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2586 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2587 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2588 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2589 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2591 if ((strHostIfSetMulti
->cnt
) > 0)
2592 memcpy(pu8CurrByte
, wilc_multicast_mac_addr_list
,
2593 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2595 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2596 wilc_get_vif_idx(vif
));
2598 PRINT_ER("Failed to send setup multicast config packet\n");
2604 static s32
Handle_DelAllRxBASessions(struct wilc_vif
*vif
,
2605 struct ba_session_info
*strHostIfBASessionInfo
)
2611 wid
.id
= (u16
)WID_DEL_ALL_RX_BA
;
2613 wid
.val
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
2614 wid
.size
= BLOCK_ACK_REQ_SIZE
;
2619 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2621 *ptr
++ = strHostIfBASessionInfo
->tid
;
2625 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2626 wilc_get_vif_idx(vif
));
2630 up(&hif_sema_wait_response
);
2635 static void handle_set_tx_pwr(struct wilc_vif
*vif
, u8 tx_pwr
)
2640 wid
.id
= (u16
)WID_TX_POWER
;
2641 wid
.type
= WID_CHAR
;
2643 wid
.size
= sizeof(char);
2645 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2646 wilc_get_vif_idx(vif
));
2648 netdev_err(vif
->ndev
, "Failed to set TX PWR\n");
2651 static void handle_get_tx_pwr(struct wilc_vif
*vif
, u8
*tx_pwr
)
2656 wid
.id
= (u16
)WID_TX_POWER
;
2657 wid
.type
= WID_CHAR
;
2658 wid
.val
= (s8
*)tx_pwr
;
2659 wid
.size
= sizeof(char);
2661 ret
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2662 wilc_get_vif_idx(vif
));
2664 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
2666 up(&hif_sema_wait_response
);
2669 static int hostIFthread(void *pvArg
)
2672 struct host_if_msg msg
;
2673 struct wilc
*wilc
= pvArg
;
2674 struct wilc_vif
*vif
;
2676 memset(&msg
, 0, sizeof(struct host_if_msg
));
2679 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2681 if (msg
.id
== HOST_IF_MSG_EXIT
)
2684 if ((!wilc_initialized
)) {
2685 usleep_range(200 * 1000, 200 * 1000);
2686 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2690 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2691 vif
->hif_drv
->usr_scan_req
.scan_result
) {
2692 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2693 usleep_range(2 * 1000, 2 * 1000);
2698 case HOST_IF_MSG_Q_IDLE
:
2699 Handle_wait_msg_q_empty();
2702 case HOST_IF_MSG_SCAN
:
2703 Handle_Scan(msg
.vif
, &msg
.body
.scan_info
);
2706 case HOST_IF_MSG_CONNECT
:
2707 Handle_Connect(msg
.vif
, &msg
.body
.con_info
);
2710 case HOST_IF_MSG_FLUSH_CONNECT
:
2711 Handle_FlushConnect(msg
.vif
);
2714 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2715 Handle_RcvdNtwrkInfo(msg
.vif
, &msg
.body
.net_info
);
2718 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2719 Handle_RcvdGnrlAsyncInfo(vif
,
2720 &msg
.body
.async_info
);
2723 case HOST_IF_MSG_KEY
:
2724 Handle_Key(msg
.vif
, &msg
.body
.key_info
);
2727 case HOST_IF_MSG_CFG_PARAMS
:
2728 handle_cfg_param(msg
.vif
, &msg
.body
.cfg_info
);
2731 case HOST_IF_MSG_SET_CHANNEL
:
2732 handle_set_channel(msg
.vif
, &msg
.body
.channel_info
);
2735 case HOST_IF_MSG_DISCONNECT
:
2736 Handle_Disconnect(msg
.vif
);
2739 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2740 del_timer(&vif
->hif_drv
->scan_timer
);
2742 if (!wilc_wlan_get_num_conn_ifcs(wilc
))
2743 wilc_chip_sleep_manually(wilc
);
2745 Handle_ScanDone(msg
.vif
, SCAN_EVENT_DONE
);
2747 if (vif
->hif_drv
->remain_on_ch_pending
)
2748 Handle_RemainOnChan(msg
.vif
,
2749 &msg
.body
.remain_on_ch
);
2753 case HOST_IF_MSG_GET_RSSI
:
2754 Handle_GetRssi(msg
.vif
);
2757 case HOST_IF_MSG_GET_LINKSPEED
:
2758 Handle_GetLinkspeed(msg
.vif
);
2761 case HOST_IF_MSG_GET_STATISTICS
:
2762 Handle_GetStatistics(msg
.vif
,
2763 (struct rf_info
*)msg
.body
.data
);
2766 case HOST_IF_MSG_GET_CHNL
:
2767 Handle_GetChnl(msg
.vif
);
2770 case HOST_IF_MSG_ADD_BEACON
:
2771 Handle_AddBeacon(msg
.vif
, &msg
.body
.beacon_info
);
2774 case HOST_IF_MSG_DEL_BEACON
:
2775 Handle_DelBeacon(msg
.vif
);
2778 case HOST_IF_MSG_ADD_STATION
:
2779 Handle_AddStation(msg
.vif
, &msg
.body
.add_sta_info
);
2782 case HOST_IF_MSG_DEL_STATION
:
2783 Handle_DelStation(msg
.vif
, &msg
.body
.del_sta_info
);
2786 case HOST_IF_MSG_EDIT_STATION
:
2787 Handle_EditStation(msg
.vif
, &msg
.body
.edit_sta_info
);
2790 case HOST_IF_MSG_GET_INACTIVETIME
:
2791 Handle_Get_InActiveTime(msg
.vif
, &msg
.body
.mac_info
);
2794 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2796 Handle_ScanDone(msg
.vif
, SCAN_EVENT_ABORTED
);
2799 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2800 Handle_ConnectTimeout(msg
.vif
);
2803 case HOST_IF_MSG_POWER_MGMT
:
2804 Handle_PowerManagement(msg
.vif
,
2805 &msg
.body
.pwr_mgmt_info
);
2808 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2809 handle_set_wfi_drv_handler(msg
.vif
, &msg
.body
.drv
);
2812 case HOST_IF_MSG_SET_OPERATION_MODE
:
2813 handle_set_operation_mode(msg
.vif
, &msg
.body
.mode
);
2816 case HOST_IF_MSG_SET_IPADDRESS
:
2817 handle_set_ip_address(vif
,
2818 msg
.body
.ip_info
.ip_addr
,
2819 msg
.body
.ip_info
.idx
);
2822 case HOST_IF_MSG_GET_IPADDRESS
:
2823 handle_get_ip_address(vif
, msg
.body
.ip_info
.idx
);
2826 case HOST_IF_MSG_SET_MAC_ADDRESS
:
2827 handle_set_mac_address(msg
.vif
,
2828 &msg
.body
.set_mac_info
);
2831 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2832 handle_get_mac_address(msg
.vif
,
2833 &msg
.body
.get_mac_info
);
2836 case HOST_IF_MSG_REMAIN_ON_CHAN
:
2837 Handle_RemainOnChan(msg
.vif
, &msg
.body
.remain_on_ch
);
2840 case HOST_IF_MSG_REGISTER_FRAME
:
2841 Handle_RegisterFrame(msg
.vif
, &msg
.body
.reg_frame
);
2844 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
2845 Handle_ListenStateExpired(msg
.vif
, &msg
.body
.remain_on_ch
);
2848 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
2849 Handle_SetMulticastFilter(msg
.vif
, &msg
.body
.multicast_info
);
2852 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
2853 Handle_DelAllRxBASessions(msg
.vif
, &msg
.body
.session_info
);
2856 case HOST_IF_MSG_DEL_ALL_STA
:
2857 Handle_DelAllSta(msg
.vif
, &msg
.body
.del_all_sta_info
);
2860 case HOST_IF_MSG_SET_TX_POWER
:
2861 handle_set_tx_pwr(msg
.vif
, msg
.body
.tx_power
.tx_pwr
);
2864 case HOST_IF_MSG_GET_TX_POWER
:
2865 handle_get_tx_pwr(msg
.vif
, &msg
.body
.tx_power
.tx_pwr
);
2868 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
2873 up(&hif_sema_thread
);
2877 static void TimerCB_Scan(unsigned long arg
)
2879 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2880 struct host_if_msg msg
;
2882 memset(&msg
, 0, sizeof(struct host_if_msg
));
2884 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
2886 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2889 static void TimerCB_Connect(unsigned long arg
)
2891 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2892 struct host_if_msg msg
;
2894 memset(&msg
, 0, sizeof(struct host_if_msg
));
2896 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
2898 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2901 s32
wilc_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
2905 wid
.id
= (u16
)WID_REMOVE_KEY
;
2907 wid
.val
= (s8
*)pu8StaAddress
;
2913 int wilc_remove_wep_key(struct wilc_vif
*vif
, u8 index
)
2916 struct host_if_msg msg
;
2917 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2921 PRINT_ER("Failed to send setup multicast config packet\n");
2925 memset(&msg
, 0, sizeof(struct host_if_msg
));
2927 msg
.id
= HOST_IF_MSG_KEY
;
2928 msg
.body
.key_info
.type
= WEP
;
2929 msg
.body
.key_info
.action
= REMOVEKEY
;
2931 msg
.body
.key_info
.attr
.wep
.index
= index
;
2933 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2935 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
2936 down(&hif_drv
->sem_test_key_block
);
2941 int wilc_set_wep_default_keyid(struct wilc_vif
*vif
, u8 index
)
2944 struct host_if_msg msg
;
2945 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2949 PRINT_ER("driver is null\n");
2953 memset(&msg
, 0, sizeof(struct host_if_msg
));
2955 msg
.id
= HOST_IF_MSG_KEY
;
2956 msg
.body
.key_info
.type
= WEP
;
2957 msg
.body
.key_info
.action
= DEFAULTKEY
;
2959 msg
.body
.key_info
.attr
.wep
.index
= index
;
2961 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2963 PRINT_ER("Error in sending message queue : Default key index\n");
2964 down(&hif_drv
->sem_test_key_block
);
2969 int wilc_add_wep_key_bss_sta(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2973 struct host_if_msg msg
;
2974 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2977 PRINT_ER("driver is null\n");
2981 memset(&msg
, 0, sizeof(struct host_if_msg
));
2983 msg
.id
= HOST_IF_MSG_KEY
;
2984 msg
.body
.key_info
.type
= WEP
;
2985 msg
.body
.key_info
.action
= ADDKEY
;
2987 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2988 if (!msg
.body
.key_info
.attr
.wep
.key
)
2991 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2992 msg
.body
.key_info
.attr
.wep
.index
= index
;
2994 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2996 PRINT_ER("Error in sending message queue :WEP Key\n");
2997 down(&hif_drv
->sem_test_key_block
);
3002 int wilc_add_wep_key_bss_ap(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
3003 u8 index
, u8 mode
, enum AUTHTYPE auth_type
)
3006 struct host_if_msg msg
;
3007 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3011 PRINT_ER("driver is null\n");
3015 memset(&msg
, 0, sizeof(struct host_if_msg
));
3018 for (i
= 0; i
< len
; i
++)
3019 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", key
[i
]);
3021 msg
.id
= HOST_IF_MSG_KEY
;
3022 msg
.body
.key_info
.type
= WEP
;
3023 msg
.body
.key_info
.action
= ADDKEY_AP
;
3025 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3026 if (!msg
.body
.key_info
.attr
.wep
.key
)
3029 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3030 msg
.body
.key_info
.attr
.wep
.index
= index
;
3031 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
3032 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
3034 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3037 PRINT_ER("Error in sending message queue :WEP Key\n");
3038 down(&hif_drv
->sem_test_key_block
);
3043 int wilc_add_ptk(struct wilc_vif
*vif
, const u8
*ptk
, u8 ptk_key_len
,
3044 const u8
*mac_addr
, const u8
*rx_mic
, const u8
*tx_mic
,
3045 u8 mode
, u8 cipher_mode
, u8 index
)
3048 struct host_if_msg msg
;
3049 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3050 u8 key_len
= ptk_key_len
;
3054 PRINT_ER("driver is null\n");
3059 key_len
+= RX_MIC_KEY_LEN
;
3062 key_len
+= TX_MIC_KEY_LEN
;
3064 memset(&msg
, 0, sizeof(struct host_if_msg
));
3066 msg
.id
= HOST_IF_MSG_KEY
;
3067 msg
.body
.key_info
.type
= WPA_PTK
;
3068 if (mode
== AP_MODE
) {
3069 msg
.body
.key_info
.action
= ADDKEY_AP
;
3070 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3072 if (mode
== STATION_MODE
)
3073 msg
.body
.key_info
.action
= ADDKEY
;
3075 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
3076 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3080 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
3082 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
3083 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, rx_mic
[i
]);
3087 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
3089 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
3090 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, tx_mic
[i
]);
3094 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3095 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
3096 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3099 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3102 PRINT_ER("Error in sending message queue: PTK Key\n");
3104 down(&hif_drv
->sem_test_key_block
);
3109 int wilc_add_rx_gtk(struct wilc_vif
*vif
, const u8
*rx_gtk
, u8 gtk_key_len
,
3110 u8 index
, u32 key_rsc_len
, const u8
*key_rsc
,
3111 const u8
*rx_mic
, const u8
*tx_mic
, u8 mode
,
3115 struct host_if_msg msg
;
3116 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3117 u8 key_len
= gtk_key_len
;
3120 PRINT_ER("driver is null\n");
3123 memset(&msg
, 0, sizeof(struct host_if_msg
));
3126 key_len
+= RX_MIC_KEY_LEN
;
3129 key_len
+= TX_MIC_KEY_LEN
;
3132 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
3135 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
3139 msg
.id
= HOST_IF_MSG_KEY
;
3140 msg
.body
.key_info
.type
= WPA_RX_GTK
;
3143 if (mode
== AP_MODE
) {
3144 msg
.body
.key_info
.action
= ADDKEY_AP
;
3145 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3147 if (mode
== STATION_MODE
)
3148 msg
.body
.key_info
.action
= ADDKEY
;
3150 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
3153 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3157 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
3161 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
3164 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3165 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3166 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
3168 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3170 PRINT_ER("Error in sending message queue: RX GTK\n");
3172 down(&hif_drv
->sem_test_key_block
);
3177 int wilc_set_pmkid_info(struct wilc_vif
*vif
,
3178 struct host_if_pmkid_attr
*pmkid
)
3181 struct host_if_msg msg
;
3182 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3186 PRINT_ER("driver is null\n");
3190 memset(&msg
, 0, sizeof(struct host_if_msg
));
3192 msg
.id
= HOST_IF_MSG_KEY
;
3193 msg
.body
.key_info
.type
= PMKSA
;
3194 msg
.body
.key_info
.action
= ADDKEY
;
3197 for (i
= 0; i
< pmkid
->numpmkid
; i
++) {
3198 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
3199 &pmkid
->pmkidlist
[i
].bssid
, ETH_ALEN
);
3200 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
3201 &pmkid
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
3204 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3206 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3211 int wilc_get_mac_address(struct wilc_vif
*vif
, u8
*mac_addr
)
3214 struct host_if_msg msg
;
3216 memset(&msg
, 0, sizeof(struct host_if_msg
));
3218 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
3219 msg
.body
.get_mac_info
.mac_addr
= mac_addr
;
3222 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3224 PRINT_ER("Failed to send get mac address\n");
3228 down(&hif_sema_wait_response
);
3232 int wilc_set_join_req(struct wilc_vif
*vif
, u8
*bssid
, const u8
*ssid
,
3233 size_t ssid_len
, const u8
*ies
, size_t ies_len
,
3234 wilc_connect_result connect_result
, void *user_arg
,
3235 u8 security
, enum AUTHTYPE auth_type
,
3236 u8 channel
, void *join_params
)
3239 struct host_if_msg msg
;
3240 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3242 if (!hif_drv
|| !connect_result
) {
3243 PRINT_ER("Driver is null\n");
3248 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3252 memset(&msg
, 0, sizeof(struct host_if_msg
));
3254 msg
.id
= HOST_IF_MSG_CONNECT
;
3256 msg
.body
.con_info
.security
= security
;
3257 msg
.body
.con_info
.auth_type
= auth_type
;
3258 msg
.body
.con_info
.ch
= channel
;
3259 msg
.body
.con_info
.result
= connect_result
;
3260 msg
.body
.con_info
.arg
= user_arg
;
3261 msg
.body
.con_info
.params
= join_params
;
3265 msg
.body
.con_info
.bssid
= kmemdup(bssid
, 6, GFP_KERNEL
);
3266 if (!msg
.body
.con_info
.bssid
)
3271 msg
.body
.con_info
.ssid_len
= ssid_len
;
3272 msg
.body
.con_info
.ssid
= kmemdup(ssid
, ssid_len
, GFP_KERNEL
);
3273 if (!msg
.body
.con_info
.ssid
)
3278 msg
.body
.con_info
.ies_len
= ies_len
;
3279 msg
.body
.con_info
.ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3280 if (!msg
.body
.con_info
.ies
)
3283 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3284 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3286 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3288 PRINT_ER("Failed to send message queue: Set join request\n");
3292 hif_drv
->connect_timer
.data
= (unsigned long)vif
;
3293 mod_timer(&hif_drv
->connect_timer
,
3294 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3299 int wilc_disconnect(struct wilc_vif
*vif
, u16 reason_code
)
3302 struct host_if_msg msg
;
3303 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3306 PRINT_ER("Driver is null\n");
3310 memset(&msg
, 0, sizeof(struct host_if_msg
));
3312 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3315 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3317 PRINT_ER("Failed to send message queue: disconnect\n");
3319 down(&hif_drv
->sem_test_disconn_block
);
3324 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
3325 u8
*pu8AssocRespInfo
,
3326 u32 u32MaxAssocRespInfoLen
,
3327 u32
*pu32RcvdAssocRespInfoLen
)
3331 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3334 PRINT_ER("Driver is null\n");
3338 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3340 wid
.val
= pu8AssocRespInfo
;
3341 wid
.size
= u32MaxAssocRespInfoLen
;
3343 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
3344 wilc_get_vif_idx(vif
));
3346 *pu32RcvdAssocRespInfoLen
= 0;
3347 PRINT_ER("Failed to send association response config packet\n");
3351 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3355 int wilc_set_mac_chnl_num(struct wilc_vif
*vif
, u8 channel
)
3358 struct host_if_msg msg
;
3359 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3362 PRINT_ER("driver is null\n");
3366 memset(&msg
, 0, sizeof(struct host_if_msg
));
3367 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3368 msg
.body
.channel_info
.set_ch
= channel
;
3371 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3373 PRINT_ER("wilc mq send fail\n");
3380 int wilc_set_wfi_drv_handler(struct wilc_vif
*vif
, int index
, u8 mac_idx
)
3383 struct host_if_msg msg
;
3385 memset(&msg
, 0, sizeof(struct host_if_msg
));
3386 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3387 msg
.body
.drv
.handler
= index
;
3388 msg
.body
.drv
.mac_idx
= mac_idx
;
3391 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3393 PRINT_ER("wilc mq send fail\n");
3400 int wilc_set_operation_mode(struct wilc_vif
*vif
, u32 mode
)
3403 struct host_if_msg msg
;
3405 memset(&msg
, 0, sizeof(struct host_if_msg
));
3406 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3407 msg
.body
.mode
.mode
= mode
;
3410 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3412 PRINT_ER("wilc mq send fail\n");
3419 s32
wilc_get_inactive_time(struct wilc_vif
*vif
, const u8
*mac
,
3420 u32
*pu32InactiveTime
)
3423 struct host_if_msg msg
;
3424 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3427 PRINT_ER("driver is null\n");
3431 memset(&msg
, 0, sizeof(struct host_if_msg
));
3432 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3434 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3437 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3439 PRINT_ER("Failed to send get host channel param's message queue ");
3441 down(&hif_drv
->sem_inactive_time
);
3443 *pu32InactiveTime
= inactive_time
;
3448 int wilc_get_rssi(struct wilc_vif
*vif
, s8
*rssi_level
)
3451 struct host_if_msg msg
;
3452 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3454 memset(&msg
, 0, sizeof(struct host_if_msg
));
3455 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3458 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3460 PRINT_ER("Failed to send get host channel param's message queue ");
3464 down(&hif_drv
->sem_get_rssi
);
3467 PRINT_ER("RSS pointer value is null");
3476 int wilc_get_statistics(struct wilc_vif
*vif
, struct rf_info
*stats
)
3479 struct host_if_msg msg
;
3481 memset(&msg
, 0, sizeof(struct host_if_msg
));
3482 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3483 msg
.body
.data
= (char *)stats
;
3486 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3488 PRINT_ER("Failed to send get host channel param's message queue ");
3492 if (stats
!= &vif
->wilc
->dummy_statistics
)
3493 down(&hif_sema_wait_response
);
3497 int wilc_scan(struct wilc_vif
*vif
, u8 scan_source
, u8 scan_type
,
3498 u8
*ch_freq_list
, u8 ch_list_len
, const u8
*ies
,
3499 size_t ies_len
, wilc_scan_result scan_result
, void *user_arg
,
3500 struct hidden_network
*hidden_network
)
3503 struct host_if_msg msg
;
3504 struct scan_attr
*scan_info
= &msg
.body
.scan_info
;
3505 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3507 if (!hif_drv
|| !scan_result
) {
3508 PRINT_ER("hif_drv or scan_result = NULL\n");
3512 memset(&msg
, 0, sizeof(struct host_if_msg
));
3514 msg
.id
= HOST_IF_MSG_SCAN
;
3516 if (hidden_network
) {
3517 scan_info
->hidden_network
.net_info
= hidden_network
->net_info
;
3518 scan_info
->hidden_network
.n_ssids
= hidden_network
->n_ssids
;
3522 scan_info
->src
= scan_source
;
3523 scan_info
->type
= scan_type
;
3524 scan_info
->result
= scan_result
;
3525 scan_info
->arg
= user_arg
;
3527 scan_info
->ch_list_len
= ch_list_len
;
3528 scan_info
->ch_freq_list
= kmemdup(ch_freq_list
,
3531 if (!scan_info
->ch_freq_list
)
3534 scan_info
->ies_len
= ies_len
;
3535 scan_info
->ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3536 if (!scan_info
->ies
)
3539 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3541 PRINT_ER("Error in sending message queue\n");
3545 hif_drv
->scan_timer
.data
= (unsigned long)vif
;
3546 mod_timer(&hif_drv
->scan_timer
,
3547 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3552 int wilc_hif_set_cfg(struct wilc_vif
*vif
,
3553 struct cfg_param_val
*cfg_param
)
3556 struct host_if_msg msg
;
3557 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3560 PRINT_ER("hif_drv NULL\n");
3564 memset(&msg
, 0, sizeof(struct host_if_msg
));
3565 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3566 msg
.body
.cfg_info
.cfg_attr_info
= *cfg_param
;
3569 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3574 static void GetPeriodicRSSI(unsigned long arg
)
3576 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3578 if (!vif
->hif_drv
) {
3579 PRINT_ER("Driver handler is NULL\n");
3583 if (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTED
)
3584 wilc_get_statistics(vif
, &vif
->wilc
->dummy_statistics
);
3586 periodic_rssi
.data
= (unsigned long)vif
;
3587 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3590 int wilc_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
3593 struct host_if_drv
*hif_drv
;
3594 struct wilc_vif
*vif
;
3598 vif
= netdev_priv(dev
);
3601 scan_while_connected
= false;
3603 sema_init(&hif_sema_wait_response
, 0);
3605 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
3610 *hif_drv_handler
= hif_drv
;
3611 for (i
= 0; i
< wilc
->vif_num
; i
++)
3612 if (dev
== wilc
->vif
[i
]->ndev
) {
3613 wilc
->vif
[i
]->hif_drv
= hif_drv
;
3617 wilc_optaining_ip
= false;
3619 if (clients_count
== 0) {
3620 sema_init(&hif_sema_thread
, 0);
3621 sema_init(&hif_sema_driver
, 0);
3622 sema_init(&hif_sema_deinit
, 1);
3625 sema_init(&hif_drv
->sem_test_key_block
, 0);
3626 sema_init(&hif_drv
->sem_test_disconn_block
, 0);
3627 sema_init(&hif_drv
->sem_get_rssi
, 0);
3628 sema_init(&hif_drv
->sem_inactive_time
, 0);
3630 if (clients_count
== 0) {
3631 result
= wilc_mq_create(&hif_msg_q
);
3634 PRINT_ER("Failed to creat MQ\n");
3638 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
3641 if (IS_ERR(hif_thread_handler
)) {
3642 PRINT_ER("Failed to creat Thread\n");
3646 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
3647 (unsigned long)vif
);
3648 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3651 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
3652 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
3653 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
3655 sema_init(&hif_drv
->sem_cfg_values
, 1);
3656 down(&hif_drv
->sem_cfg_values
);
3658 hif_drv
->hif_state
= HOST_IF_IDLE
;
3659 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
3660 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
3661 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
3662 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
3663 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
3665 hif_drv
->p2p_timeout
= 0;
3667 up(&hif_drv
->sem_cfg_values
);
3674 wilc_mq_destroy(&hif_msg_q
);
3679 int wilc_deinit(struct wilc_vif
*vif
)
3682 struct host_if_msg msg
;
3683 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3686 PRINT_ER("hif_drv = NULL\n");
3690 down(&hif_sema_deinit
);
3692 terminated_handle
= hif_drv
;
3694 del_timer_sync(&hif_drv
->scan_timer
);
3695 del_timer_sync(&hif_drv
->connect_timer
);
3696 del_timer_sync(&periodic_rssi
);
3697 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
3699 wilc_set_wfi_drv_handler(vif
, 0, 0);
3700 down(&hif_sema_driver
);
3702 if (hif_drv
->usr_scan_req
.scan_result
) {
3703 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
3704 hif_drv
->usr_scan_req
.arg
, NULL
);
3705 hif_drv
->usr_scan_req
.scan_result
= NULL
;
3708 hif_drv
->hif_state
= HOST_IF_IDLE
;
3710 scan_while_connected
= false;
3712 memset(&msg
, 0, sizeof(struct host_if_msg
));
3714 if (clients_count
== 1) {
3715 del_timer_sync(&periodic_rssi
);
3716 msg
.id
= HOST_IF_MSG_EXIT
;
3719 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3721 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result
);
3723 down(&hif_sema_thread
);
3725 wilc_mq_destroy(&hif_msg_q
);
3731 terminated_handle
= NULL
;
3732 up(&hif_sema_deinit
);
3736 void wilc_network_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3740 struct host_if_msg msg
;
3742 struct host_if_drv
*hif_drv
= NULL
;
3743 struct wilc_vif
*vif
;
3745 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3746 vif
= wilc_get_vif_from_idx(wilc
, id
);
3749 hif_drv
= vif
->hif_drv
;
3751 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3752 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv
);
3756 memset(&msg
, 0, sizeof(struct host_if_msg
));
3758 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
3761 msg
.body
.net_info
.len
= u32Length
;
3762 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3763 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
3765 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3767 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result
);
3770 void wilc_gnrl_async_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3774 struct host_if_msg msg
;
3776 struct host_if_drv
*hif_drv
= NULL
;
3777 struct wilc_vif
*vif
;
3779 down(&hif_sema_deinit
);
3781 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3782 vif
= wilc_get_vif_from_idx(wilc
, id
);
3784 up(&hif_sema_deinit
);
3788 hif_drv
= vif
->hif_drv
;
3790 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3791 up(&hif_sema_deinit
);
3795 if (!hif_drv
->usr_conn_req
.conn_result
) {
3796 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
3797 up(&hif_sema_deinit
);
3801 memset(&msg
, 0, sizeof(struct host_if_msg
));
3803 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
3806 msg
.body
.async_info
.len
= u32Length
;
3807 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3808 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
3810 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3812 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result
);
3814 up(&hif_sema_deinit
);
3817 void wilc_scan_complete_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3821 struct host_if_msg msg
;
3823 struct host_if_drv
*hif_drv
= NULL
;
3824 struct wilc_vif
*vif
;
3826 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3827 vif
= wilc_get_vif_from_idx(wilc
, id
);
3830 hif_drv
= vif
->hif_drv
;
3832 if (!hif_drv
|| hif_drv
== terminated_handle
)
3835 if (hif_drv
->usr_scan_req
.scan_result
) {
3836 memset(&msg
, 0, sizeof(struct host_if_msg
));
3838 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
3841 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3843 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result
);
3847 int wilc_remain_on_channel(struct wilc_vif
*vif
, u32 session_id
,
3848 u32 duration
, u16 chan
,
3849 wilc_remain_on_chan_expired expired
,
3850 wilc_remain_on_chan_ready ready
,
3854 struct host_if_msg msg
;
3855 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3858 PRINT_ER("driver is null\n");
3862 memset(&msg
, 0, sizeof(struct host_if_msg
));
3864 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
3865 msg
.body
.remain_on_ch
.ch
= chan
;
3866 msg
.body
.remain_on_ch
.expired
= expired
;
3867 msg
.body
.remain_on_ch
.ready
= ready
;
3868 msg
.body
.remain_on_ch
.arg
= user_arg
;
3869 msg
.body
.remain_on_ch
.duration
= duration
;
3870 msg
.body
.remain_on_ch
.id
= session_id
;
3873 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3875 PRINT_ER("wilc mq send fail\n");
3880 int wilc_listen_state_expired(struct wilc_vif
*vif
, u32 session_id
)
3883 struct host_if_msg msg
;
3884 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3887 PRINT_ER("driver is null\n");
3891 del_timer(&hif_drv
->remain_on_ch_timer
);
3893 memset(&msg
, 0, sizeof(struct host_if_msg
));
3894 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3896 msg
.body
.remain_on_ch
.id
= session_id
;
3898 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3900 PRINT_ER("wilc mq send fail\n");
3905 int wilc_frame_register(struct wilc_vif
*vif
, u16 frame_type
, bool reg
)
3908 struct host_if_msg msg
;
3909 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3912 PRINT_ER("driver is null\n");
3916 memset(&msg
, 0, sizeof(struct host_if_msg
));
3918 msg
.id
= HOST_IF_MSG_REGISTER_FRAME
;
3919 switch (frame_type
) {
3921 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
3925 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
3931 msg
.body
.reg_frame
.frame_type
= frame_type
;
3932 msg
.body
.reg_frame
.reg
= reg
;
3935 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3937 PRINT_ER("wilc mq send fail\n");
3942 int wilc_add_beacon(struct wilc_vif
*vif
, u32 interval
, u32 dtim_period
,
3943 u32 head_len
, u8
*head
, u32 tail_len
, u8
*tail
)
3946 struct host_if_msg msg
;
3947 struct beacon_attr
*beacon_info
= &msg
.body
.beacon_info
;
3948 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3951 PRINT_ER("driver is null\n");
3955 memset(&msg
, 0, sizeof(struct host_if_msg
));
3957 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
3959 beacon_info
->interval
= interval
;
3960 beacon_info
->dtim_period
= dtim_period
;
3961 beacon_info
->head_len
= head_len
;
3962 beacon_info
->head
= kmemdup(head
, head_len
, GFP_KERNEL
);
3963 if (!beacon_info
->head
) {
3967 beacon_info
->tail_len
= tail_len
;
3970 beacon_info
->tail
= kmemdup(tail
, tail_len
, GFP_KERNEL
);
3971 if (!beacon_info
->tail
) {
3976 beacon_info
->tail
= NULL
;
3979 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3981 PRINT_ER("wilc mq send fail\n");
3985 kfree(beacon_info
->head
);
3987 kfree(beacon_info
->tail
);
3993 int wilc_del_beacon(struct wilc_vif
*vif
)
3996 struct host_if_msg msg
;
3997 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4000 PRINT_ER("driver is null\n");
4004 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
4007 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4009 PRINT_ER("wilc_mq_send fail\n");
4014 int wilc_add_station(struct wilc_vif
*vif
, struct add_sta_param
*sta_param
)
4017 struct host_if_msg msg
;
4018 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
4019 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4022 PRINT_ER("driver is null\n");
4026 memset(&msg
, 0, sizeof(struct host_if_msg
));
4028 msg
.id
= HOST_IF_MSG_ADD_STATION
;
4031 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
4032 if (add_sta_info
->rates_len
> 0) {
4033 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
4034 add_sta_info
->rates_len
,
4036 if (!add_sta_info
->rates
)
4040 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4042 PRINT_ER("wilc_mq_send fail\n");
4046 int wilc_del_station(struct wilc_vif
*vif
, const u8
*mac_addr
)
4049 struct host_if_msg msg
;
4050 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
4051 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4054 PRINT_ER("driver is null\n");
4058 memset(&msg
, 0, sizeof(struct host_if_msg
));
4060 msg
.id
= HOST_IF_MSG_DEL_STATION
;
4064 eth_broadcast_addr(del_sta_info
->mac_addr
);
4066 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
4068 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4070 PRINT_ER("wilc_mq_send fail\n");
4074 int wilc_del_allstation(struct wilc_vif
*vif
, u8 mac_addr
[][ETH_ALEN
])
4077 struct host_if_msg msg
;
4078 struct del_all_sta
*del_all_sta_info
= &msg
.body
.del_all_sta_info
;
4079 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4080 u8 zero_addr
[ETH_ALEN
] = {0};
4085 PRINT_ER("driver is null\n");
4089 memset(&msg
, 0, sizeof(struct host_if_msg
));
4091 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
4094 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
4095 if (memcmp(mac_addr
[i
], zero_addr
, ETH_ALEN
)) {
4096 memcpy(del_all_sta_info
->del_all_sta
[i
], mac_addr
[i
], ETH_ALEN
);
4097 PRINT_D(CFG80211_DBG
, "BSSID = %x%x%x%x%x%x\n",
4098 del_all_sta_info
->del_all_sta
[i
][0],
4099 del_all_sta_info
->del_all_sta
[i
][1],
4100 del_all_sta_info
->del_all_sta
[i
][2],
4101 del_all_sta_info
->del_all_sta
[i
][3],
4102 del_all_sta_info
->del_all_sta
[i
][4],
4103 del_all_sta_info
->del_all_sta
[i
][5]);
4108 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
4112 del_all_sta_info
->assoc_sta
= assoc_sta
;
4113 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4116 PRINT_ER("wilc_mq_send fail\n");
4118 down(&hif_sema_wait_response
);
4123 int wilc_edit_station(struct wilc_vif
*vif
,
4124 struct add_sta_param
*sta_param
)
4127 struct host_if_msg msg
;
4128 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
4129 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4132 PRINT_ER("driver is null\n");
4136 memset(&msg
, 0, sizeof(struct host_if_msg
));
4138 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
4141 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
4142 if (add_sta_info
->rates_len
> 0) {
4143 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
4144 add_sta_info
->rates_len
,
4146 if (!add_sta_info
->rates
)
4150 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4152 PRINT_ER("wilc_mq_send fail\n");
4157 int wilc_set_power_mgmt(struct wilc_vif
*vif
, bool enabled
, u32 timeout
)
4160 struct host_if_msg msg
;
4161 struct power_mgmt_param
*pwr_mgmt_info
= &msg
.body
.pwr_mgmt_info
;
4162 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4165 PRINT_ER("driver is null\n");
4169 if (wilc_wlan_get_num_conn_ifcs(vif
->wilc
) == 2 && enabled
)
4172 memset(&msg
, 0, sizeof(struct host_if_msg
));
4174 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
4177 pwr_mgmt_info
->enabled
= enabled
;
4178 pwr_mgmt_info
->timeout
= timeout
;
4180 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4182 PRINT_ER("wilc_mq_send fail\n");
4186 int wilc_setup_multicast_filter(struct wilc_vif
*vif
, bool enabled
,
4190 struct host_if_msg msg
;
4191 struct set_multicast
*multicast_filter_param
= &msg
.body
.multicast_info
;
4192 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4195 PRINT_ER("driver is null\n");
4199 memset(&msg
, 0, sizeof(struct host_if_msg
));
4201 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
4204 multicast_filter_param
->enabled
= enabled
;
4205 multicast_filter_param
->cnt
= count
;
4207 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4209 PRINT_ER("wilc_mq_send fail\n");
4213 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
)
4215 struct join_bss_param
*pNewJoinBssParam
= NULL
;
4224 u8 pcipherTotalCount
= 0;
4225 u8 authTotalCount
= 0;
4228 pu8IEs
= ptstrNetworkInfo
->ies
;
4229 u16IEsLen
= ptstrNetworkInfo
->ies_len
;
4231 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
4232 if (pNewJoinBssParam
) {
4233 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->dtim_period
;
4234 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->beacon_period
;
4235 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->cap_info
;
4236 memcpy(pNewJoinBssParam
->bssid
, ptstrNetworkInfo
->bssid
, 6);
4237 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->ssid
,
4238 ptstrNetworkInfo
->ssid_len
+ 1);
4239 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->ssid_len
;
4240 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
4241 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
4243 while (index
< u16IEsLen
) {
4244 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
4245 suppRatesNo
= pu8IEs
[index
+ 1];
4246 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
4249 for (i
= 0; i
< suppRatesNo
; i
++)
4250 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
4252 index
+= suppRatesNo
;
4254 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
4255 extSuppRatesNo
= pu8IEs
[index
+ 1];
4256 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
4257 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
4259 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
4261 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
4262 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
4264 index
+= extSuppRatesNo
;
4266 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
4267 pNewJoinBssParam
->ht_capable
= true;
4268 index
+= pu8IEs
[index
+ 1] + 2;
4270 } else if ((pu8IEs
[index
] == WMM_IE
) &&
4271 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
4272 (pu8IEs
[index
+ 4] == 0xF2) &&
4273 (pu8IEs
[index
+ 5] == 0x02) &&
4274 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
4275 (pu8IEs
[index
+ 7] == 0x01)) {
4276 pNewJoinBssParam
->wmm_cap
= true;
4278 if (pu8IEs
[index
+ 8] & BIT(7))
4279 pNewJoinBssParam
->uapsd_cap
= true;
4280 index
+= pu8IEs
[index
+ 1] + 2;
4282 } else if ((pu8IEs
[index
] == P2P_IE
) &&
4283 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
4284 (pu8IEs
[index
+ 4] == 0x9a) &&
4285 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
4288 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->tsf_lo
;
4289 pNewJoinBssParam
->noa_enabled
= 1;
4290 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
4292 if (pu8IEs
[index
+ 10] & BIT(7)) {
4293 pNewJoinBssParam
->opp_enabled
= 1;
4294 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
4296 pNewJoinBssParam
->opp_enabled
= 0;
4299 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
4300 u16P2P_count
= index
+ 12;
4302 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
4305 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
4308 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
4310 index
+= pu8IEs
[index
+ 1] + 2;
4313 } else if ((pu8IEs
[index
] == RSN_IE
) ||
4314 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
4315 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
4316 (pu8IEs
[index
+ 5] == 0x01))) {
4317 u16 rsnIndex
= index
;
4319 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
4320 pNewJoinBssParam
->mode_802_11i
= 2;
4322 if (pNewJoinBssParam
->mode_802_11i
== 0)
4323 pNewJoinBssParam
->mode_802_11i
= 1;
4328 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4330 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4331 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4334 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4335 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4337 pcipherTotalCount
+= pcipherCount
;
4338 rsnIndex
+= jumpOffset
;
4340 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4342 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4345 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4346 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4348 authTotalCount
+= authCount
;
4349 rsnIndex
+= jumpOffset
;
4351 if (pu8IEs
[index
] == RSN_IE
) {
4352 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4353 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4356 pNewJoinBssParam
->rsn_found
= true;
4357 index
+= pu8IEs
[index
+ 1] + 2;
4360 index
+= pu8IEs
[index
+ 1] + 2;
4364 return (void *)pNewJoinBssParam
;
4367 int wilc_setup_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4370 struct host_if_msg msg
;
4371 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4374 PRINT_ER("driver is null\n");
4378 memset(&msg
, 0, sizeof(struct host_if_msg
));
4380 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
4382 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4384 msg
.body
.ip_info
.idx
= idx
;
4386 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4388 PRINT_ER("wilc_mq_send fail\n");
4393 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4396 struct host_if_msg msg
;
4397 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4400 PRINT_ER("driver is null\n");
4404 memset(&msg
, 0, sizeof(struct host_if_msg
));
4406 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
4408 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4410 msg
.body
.ip_info
.idx
= idx
;
4412 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4414 PRINT_ER("wilc_mq_send fail\n");
4419 int wilc_set_tx_power(struct wilc_vif
*vif
, u8 tx_power
)
4422 struct host_if_msg msg
;
4424 memset(&msg
, 0, sizeof(struct host_if_msg
));
4426 msg
.id
= HOST_IF_MSG_SET_TX_POWER
;
4427 msg
.body
.tx_power
.tx_pwr
= tx_power
;
4430 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4432 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4437 int wilc_get_tx_power(struct wilc_vif
*vif
, u8
*tx_power
)
4440 struct host_if_msg msg
;
4442 memset(&msg
, 0, sizeof(struct host_if_msg
));
4444 msg
.id
= HOST_IF_MSG_GET_TX_POWER
;
4447 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4449 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
4451 down(&hif_sema_wait_response
);
4452 *tx_power
= msg
.body
.tx_power
.tx_pwr
;