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"
7 #include "wilc_wlan_if.h"
8 #include "wilc_msgqueue.h"
9 #include <linux/etherdevice.h>
10 #include "wilc_wfi_netdevice.h"
14 extern struct timer_list hDuringIpTimer
;
16 extern u8 g_wilc_initialized
;
18 #define HOST_IF_MSG_SCAN 0
19 #define HOST_IF_MSG_CONNECT 1
20 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21 #define HOST_IF_MSG_KEY 3
22 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24 #define HOST_IF_MSG_CFG_PARAMS 6
25 #define HOST_IF_MSG_SET_CHANNEL 7
26 #define HOST_IF_MSG_DISCONNECT 8
27 #define HOST_IF_MSG_GET_RSSI 9
28 #define HOST_IF_MSG_GET_CHNL 10
29 #define HOST_IF_MSG_ADD_BEACON 11
30 #define HOST_IF_MSG_DEL_BEACON 12
31 #define HOST_IF_MSG_ADD_STATION 13
32 #define HOST_IF_MSG_DEL_STATION 14
33 #define HOST_IF_MSG_EDIT_STATION 15
34 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36 #define HOST_IF_MSG_POWER_MGMT 18
37 #define HOST_IF_MSG_GET_INACTIVETIME 19
38 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
39 #define HOST_IF_MSG_REGISTER_FRAME 21
40 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41 #define HOST_IF_MSG_GET_LINKSPEED 23
42 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
44 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
45 #define HOST_IF_MSG_SET_OPERATION_MODE 27
46 #define HOST_IF_MSG_SET_IPADDRESS 28
47 #define HOST_IF_MSG_GET_IPADDRESS 29
48 #define HOST_IF_MSG_FLUSH_CONNECT 30
49 #define HOST_IF_MSG_GET_STATISTICS 31
50 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51 #define HOST_IF_MSG_ADD_BA_SESSION 33
52 #define HOST_IF_MSG_DEL_BA_SESSION 34
53 #define HOST_IF_MSG_Q_IDLE 35
54 #define HOST_IF_MSG_DEL_ALL_STA 36
55 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56 #define HOST_IF_MSG_EXIT 100
58 #define HOST_IF_SCAN_TIMEOUT 4000
59 #define HOST_IF_CONNECT_TIMEOUT 9500
61 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62 #define BA_SESSION_DEFAULT_TIMEOUT 1000
63 #define BLOCK_ACK_REQ_SIZE 0x14
64 #define FALSE_FRMWR_CHANNEL 100
66 struct cfg_param_attr
{
67 struct cfg_param_val cfg_attr_info
;
70 struct host_if_wpa_attr
{
80 struct host_if_wep_attr
{
85 enum AUTHTYPE auth_type
;
88 union host_if_key_attr
{
89 struct host_if_wep_attr wep
;
90 struct host_if_wpa_attr wpa
;
91 struct host_if_pmkid_attr pmkid
;
97 union host_if_key_attr attr
;
107 wilc_scan_result result
;
109 struct hidden_network hidden_network
;
112 struct connect_attr
{
119 wilc_connect_result result
;
121 enum AUTHTYPE auth_type
;
126 struct rcvd_async_info
{
131 struct channel_attr
{
144 struct set_multicast
{
150 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
155 u8 mac_addr
[ETH_ALEN
];
158 struct power_mgmt_param
{
168 struct sta_inactive_t
{
173 struct scan_attr scan_info
;
174 struct connect_attr con_info
;
175 struct rcvd_net_info net_info
;
176 struct rcvd_async_info async_info
;
177 struct key_attr key_info
;
178 struct cfg_param_attr cfg_info
;
179 struct channel_attr channel_info
;
180 struct beacon_attr beacon_info
;
181 struct add_sta_param add_sta_info
;
182 struct del_sta del_sta_info
;
183 struct add_sta_param edit_sta_info
;
184 struct power_mgmt_param pwr_mgmt_info
;
185 struct sta_inactive_t mac_info
;
186 struct set_ip_addr ip_info
;
187 struct drv_handler drv
;
188 struct set_multicast multicast_info
;
190 struct set_mac_addr set_mac_info
;
191 struct get_mac_addr get_mac_info
;
192 struct ba_session_info session_info
;
193 struct remain_ch remain_on_ch
;
194 struct reg_frame reg_frame
;
196 struct del_all_sta del_all_sta_info
;
201 union message_body body
;
202 struct host_if_drv
*drv
;
205 struct join_bss_param
{
211 char ssid
[MAX_SSID_LEN
];
213 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
220 u8 rsn_pcip_policy
[3];
221 u8 rsn_auth_policy
[3];
234 static struct host_if_drv
*wfidrv_list
[NUM_CONCURRENT_IFC
+ 1];
235 struct host_if_drv
*terminated_handle
;
238 static struct task_struct
*hif_thread_handler
;
239 static WILC_MsgQueueHandle hif_msg_q
;
240 static struct semaphore hif_sema_thread
;
241 static struct semaphore hif_sema_driver
;
242 static struct semaphore hif_sema_wait_response
;
243 static struct semaphore hif_sema_deinit
;
244 static struct timer_list periodic_rssi
;
246 u8 multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
248 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
250 static bool scan_while_connected
;
253 static s8 link_speed
;
255 static u8 set_ip
[2][4];
256 static u8 get_ip
[2][4];
257 static u32 inactive_time
;
258 static u8 del_beacon
;
259 static u32 clients_count
;
266 static u32 info_element_size
;
267 static struct host_if_drv
*join_req_drv
;
268 #define REAL_JOIN_REQ 0
269 #define FLUSHED_JOIN_REQ 1
270 #define FLUSHED_BYTE_POS 79
272 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
274 extern int linux_wlan_get_num_conn_ifcs(void);
276 static int add_handler_in_list(struct host_if_drv
*handler
)
280 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
281 if (!wfidrv_list
[i
]) {
282 wfidrv_list
[i
] = handler
;
290 static int remove_handler_in_list(struct host_if_drv
*handler
)
294 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
295 if (wfidrv_list
[i
] == handler
) {
296 wfidrv_list
[i
] = NULL
;
304 static int get_id_from_handler(struct host_if_drv
*handler
)
311 for (i
= 1; i
< ARRAY_SIZE(wfidrv_list
); i
++) {
312 if (wfidrv_list
[i
] == handler
)
319 static struct host_if_drv
*get_handler_from_id(int id
)
321 if (id
<= 0 || id
>= ARRAY_SIZE(wfidrv_list
))
323 return wfidrv_list
[id
];
326 static s32
handle_set_channel(struct host_if_drv
*hif_drv
,
327 struct channel_attr
*hif_set_ch
)
332 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
334 wid
.val
= (char *)&hif_set_ch
->set_ch
;
335 wid
.size
= sizeof(char);
337 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
339 result
= send_config_pkt(SET_CFG
, &wid
, 1,
340 get_id_from_handler(hif_drv
));
343 PRINT_ER("Failed to set channel\n");
350 static s32
handle_set_wfi_drv_handler(struct host_if_drv
*hif_drv
,
351 struct drv_handler
*hif_drv_handler
)
356 wid
.id
= (u16
)WID_SET_DRV_HANDLER
;
358 wid
.val
= (s8
*)&hif_drv_handler
->handler
;
359 wid
.size
= sizeof(u32
);
361 result
= send_config_pkt(SET_CFG
, &wid
, 1, hif_drv_handler
->handler
);
364 up(&hif_sema_driver
);
367 PRINT_ER("Failed to set driver handler\n");
374 static s32
handle_set_operation_mode(struct host_if_drv
*hif_drv
,
375 struct op_mode
*hif_op_mode
)
380 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
382 wid
.val
= (s8
*)&hif_op_mode
->mode
;
383 wid
.size
= sizeof(u32
);
385 result
= send_config_pkt(SET_CFG
, &wid
, 1,
386 get_id_from_handler(hif_drv
));
388 if ((hif_op_mode
->mode
) == IDLE_MODE
)
389 up(&hif_sema_driver
);
392 PRINT_ER("Failed to set driver handler\n");
399 s32
handle_set_ip_address(struct host_if_drv
*hif_drv
, u8
*ip_addr
, u8 idx
)
403 char firmware_ip_addr
[4] = {0};
405 if (ip_addr
[0] < 192)
408 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %pI4\n",
411 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
413 wid
.id
= (u16
)WID_IP_ADDRESS
;
415 wid
.val
= (u8
*)ip_addr
;
418 result
= send_config_pkt(SET_CFG
, &wid
, 1,
419 get_id_from_handler(hif_drv
));
421 host_int_get_ipaddress(hif_drv
, firmware_ip_addr
, idx
);
424 PRINT_ER("Failed to set IP address\n");
428 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
433 s32
handle_get_ip_address(struct host_if_drv
*hif_drv
, u8 idx
)
438 wid
.id
= (u16
)WID_IP_ADDRESS
;
440 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
443 result
= send_config_pkt(GET_CFG
, &wid
, 1,
444 get_id_from_handler(hif_drv
));
446 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", wid
.val
);
448 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
452 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
453 host_int_setup_ipaddress(hif_drv
, set_ip
[idx
], idx
);
456 PRINT_ER("Failed to get IP address\n");
460 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d\n", idx
);
461 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", get_ip
[idx
]);
462 PRINT_INFO(HOSTINF_DBG
, "\n");
467 static s32
handle_set_mac_address(struct host_if_drv
*hif_drv
,
468 struct set_mac_addr
*set_mac_addr
)
472 u8
*mac_buf
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
475 PRINT_ER("No buffer to send mac address\n");
478 memcpy(mac_buf
, set_mac_addr
->mac_addr
, ETH_ALEN
);
480 wid
.id
= (u16
)WID_MAC_ADDR
;
484 PRINT_D(GENERIC_DBG
, "mac addr = :%pM\n", wid
.val
);
486 result
= send_config_pkt(SET_CFG
, &wid
, 1,
487 get_id_from_handler(hif_drv
));
489 PRINT_ER("Failed to set mac address\n");
497 static s32
handle_get_mac_address(struct host_if_drv
*hif_drv
,
498 struct get_mac_addr
*get_mac_addr
)
503 wid
.id
= (u16
)WID_MAC_ADDR
;
505 wid
.val
= get_mac_addr
->mac_addr
;
508 result
= send_config_pkt(GET_CFG
, &wid
, 1,
509 get_id_from_handler(hif_drv
));
512 PRINT_ER("Failed to get mac address\n");
515 up(&hif_sema_wait_response
);
520 static s32
handle_cfg_param(struct host_if_drv
*hif_drv
,
521 struct cfg_param_attr
*cfg_param_attr
)
524 struct wid wid_list
[32];
527 down(&hif_drv
->sem_cfg_values
);
529 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
531 if (cfg_param_attr
->cfg_attr_info
.flag
& BSS_TYPE
) {
532 if (cfg_param_attr
->cfg_attr_info
.bss_type
< 6) {
533 wid_list
[wid_cnt
].id
= WID_BSS_TYPE
;
534 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.bss_type
;
535 wid_list
[wid_cnt
].type
= WID_CHAR
;
536 wid_list
[wid_cnt
].size
= sizeof(char);
537 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->cfg_attr_info
.bss_type
;
539 PRINT_ER("check value 6 over\n");
545 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTH_TYPE
) {
546 if (cfg_param_attr
->cfg_attr_info
.auth_type
== 1 ||
547 cfg_param_attr
->cfg_attr_info
.auth_type
== 2 ||
548 cfg_param_attr
->cfg_attr_info
.auth_type
== 5) {
549 wid_list
[wid_cnt
].id
= WID_AUTH_TYPE
;
550 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_type
;
551 wid_list
[wid_cnt
].type
= WID_CHAR
;
552 wid_list
[wid_cnt
].size
= sizeof(char);
553 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->cfg_attr_info
.auth_type
;
555 PRINT_ER("Impossible value \n");
561 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTHEN_TIMEOUT
) {
562 if (cfg_param_attr
->cfg_attr_info
.auth_timeout
> 0 &&
563 cfg_param_attr
->cfg_attr_info
.auth_timeout
< 65536) {
564 wid_list
[wid_cnt
].id
= WID_AUTH_TIMEOUT
;
565 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_timeout
;
566 wid_list
[wid_cnt
].type
= WID_SHORT
;
567 wid_list
[wid_cnt
].size
= sizeof(u16
);
568 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->cfg_attr_info
.auth_timeout
;
570 PRINT_ER("Range(1 ~ 65535) over\n");
576 if (cfg_param_attr
->cfg_attr_info
.flag
& POWER_MANAGEMENT
) {
577 if (cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
< 5) {
578 wid_list
[wid_cnt
].id
= WID_POWER_MANAGEMENT
;
579 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
580 wid_list
[wid_cnt
].type
= WID_CHAR
;
581 wid_list
[wid_cnt
].size
= sizeof(char);
582 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
584 PRINT_ER("Invalide power mode\n");
590 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_SHORT
) {
591 if (cfg_param_attr
->cfg_attr_info
.short_retry_limit
> 0 &&
592 cfg_param_attr
->cfg_attr_info
.short_retry_limit
< 256) {
593 wid_list
[wid_cnt
].id
= WID_SHORT_RETRY_LIMIT
;
594 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
595 wid_list
[wid_cnt
].type
= WID_SHORT
;
596 wid_list
[wid_cnt
].size
= sizeof(u16
);
597 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
599 PRINT_ER("Range(1~256) over\n");
605 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_LONG
) {
606 if (cfg_param_attr
->cfg_attr_info
.long_retry_limit
> 0 &&
607 cfg_param_attr
->cfg_attr_info
.long_retry_limit
< 256) {
608 wid_list
[wid_cnt
].id
= WID_LONG_RETRY_LIMIT
;
609 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
610 wid_list
[wid_cnt
].type
= WID_SHORT
;
611 wid_list
[wid_cnt
].size
= sizeof(u16
);
612 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
614 PRINT_ER("Range(1~256) over\n");
620 if (cfg_param_attr
->cfg_attr_info
.flag
& FRAG_THRESHOLD
) {
621 if (cfg_param_attr
->cfg_attr_info
.frag_threshold
> 255 &&
622 cfg_param_attr
->cfg_attr_info
.frag_threshold
< 7937) {
623 wid_list
[wid_cnt
].id
= WID_FRAG_THRESHOLD
;
624 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.frag_threshold
;
625 wid_list
[wid_cnt
].type
= WID_SHORT
;
626 wid_list
[wid_cnt
].size
= sizeof(u16
);
627 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->cfg_attr_info
.frag_threshold
;
629 PRINT_ER("Threshold Range fail\n");
635 if (cfg_param_attr
->cfg_attr_info
.flag
& RTS_THRESHOLD
) {
636 if (cfg_param_attr
->cfg_attr_info
.rts_threshold
> 255 &&
637 cfg_param_attr
->cfg_attr_info
.rts_threshold
< 65536) {
638 wid_list
[wid_cnt
].id
= WID_RTS_THRESHOLD
;
639 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.rts_threshold
;
640 wid_list
[wid_cnt
].type
= WID_SHORT
;
641 wid_list
[wid_cnt
].size
= sizeof(u16
);
642 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->cfg_attr_info
.rts_threshold
;
644 PRINT_ER("Threshold Range fail\n");
650 if (cfg_param_attr
->cfg_attr_info
.flag
& PREAMBLE
) {
651 if (cfg_param_attr
->cfg_attr_info
.preamble_type
< 3) {
652 wid_list
[wid_cnt
].id
= WID_PREAMBLE
;
653 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.preamble_type
;
654 wid_list
[wid_cnt
].type
= WID_CHAR
;
655 wid_list
[wid_cnt
].size
= sizeof(char);
656 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->cfg_attr_info
.preamble_type
;
658 PRINT_ER("Preamle Range(0~2) over\n");
664 if (cfg_param_attr
->cfg_attr_info
.flag
& SHORT_SLOT_ALLOWED
) {
665 if (cfg_param_attr
->cfg_attr_info
.short_slot_allowed
< 2) {
666 wid_list
[wid_cnt
].id
= WID_SHORT_SLOT_ALLOWED
;
667 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
668 wid_list
[wid_cnt
].type
= WID_CHAR
;
669 wid_list
[wid_cnt
].size
= sizeof(char);
670 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
672 PRINT_ER("Short slot(2) over\n");
678 if (cfg_param_attr
->cfg_attr_info
.flag
& TXOP_PROT_DISABLE
) {
679 if (cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
< 2) {
680 wid_list
[wid_cnt
].id
= WID_11N_TXOP_PROT_DISABLE
;
681 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
682 wid_list
[wid_cnt
].type
= WID_CHAR
;
683 wid_list
[wid_cnt
].size
= sizeof(char);
684 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
686 PRINT_ER("TXOP prot disable\n");
692 if (cfg_param_attr
->cfg_attr_info
.flag
& BEACON_INTERVAL
) {
693 if (cfg_param_attr
->cfg_attr_info
.beacon_interval
> 0 &&
694 cfg_param_attr
->cfg_attr_info
.beacon_interval
< 65536) {
695 wid_list
[wid_cnt
].id
= WID_BEACON_INTERVAL
;
696 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.beacon_interval
;
697 wid_list
[wid_cnt
].type
= WID_SHORT
;
698 wid_list
[wid_cnt
].size
= sizeof(u16
);
699 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->cfg_attr_info
.beacon_interval
;
701 PRINT_ER("Beacon interval(1~65535) fail\n");
707 if (cfg_param_attr
->cfg_attr_info
.flag
& DTIM_PERIOD
) {
708 if (cfg_param_attr
->cfg_attr_info
.dtim_period
> 0 &&
709 cfg_param_attr
->cfg_attr_info
.dtim_period
< 256) {
710 wid_list
[wid_cnt
].id
= WID_DTIM_PERIOD
;
711 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.dtim_period
;
712 wid_list
[wid_cnt
].type
= WID_CHAR
;
713 wid_list
[wid_cnt
].size
= sizeof(char);
714 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->cfg_attr_info
.dtim_period
;
716 PRINT_ER("DTIM range(1~255) fail\n");
722 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY
) {
723 if (cfg_param_attr
->cfg_attr_info
.site_survey_enabled
< 3) {
724 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY
;
725 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
726 wid_list
[wid_cnt
].type
= WID_CHAR
;
727 wid_list
[wid_cnt
].size
= sizeof(char);
728 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
730 PRINT_ER("Site survey disable\n");
736 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY_SCAN_TIME
) {
737 if (cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
> 0 &&
738 cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
< 65536) {
739 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY_SCAN_TIME
;
740 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
741 wid_list
[wid_cnt
].type
= WID_SHORT
;
742 wid_list
[wid_cnt
].size
= sizeof(u16
);
743 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
745 PRINT_ER("Site survey scan time(1~65535) over\n");
751 if (cfg_param_attr
->cfg_attr_info
.flag
& ACTIVE_SCANTIME
) {
752 if (cfg_param_attr
->cfg_attr_info
.active_scan_time
> 0 &&
753 cfg_param_attr
->cfg_attr_info
.active_scan_time
< 65536) {
754 wid_list
[wid_cnt
].id
= WID_ACTIVE_SCAN_TIME
;
755 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.active_scan_time
;
756 wid_list
[wid_cnt
].type
= WID_SHORT
;
757 wid_list
[wid_cnt
].size
= sizeof(u16
);
758 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->cfg_attr_info
.active_scan_time
;
760 PRINT_ER("Active scan time(1~65535) over\n");
766 if (cfg_param_attr
->cfg_attr_info
.flag
& PASSIVE_SCANTIME
) {
767 if (cfg_param_attr
->cfg_attr_info
.passive_scan_time
> 0 &&
768 cfg_param_attr
->cfg_attr_info
.passive_scan_time
< 65536) {
769 wid_list
[wid_cnt
].id
= WID_PASSIVE_SCAN_TIME
;
770 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
771 wid_list
[wid_cnt
].type
= WID_SHORT
;
772 wid_list
[wid_cnt
].size
= sizeof(u16
);
773 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
775 PRINT_ER("Passive scan time(1~65535) over\n");
781 if (cfg_param_attr
->cfg_attr_info
.flag
& CURRENT_TX_RATE
) {
782 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->cfg_attr_info
.curr_tx_rate
;
784 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
785 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
786 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
787 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
788 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
789 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
790 wid_list
[wid_cnt
].id
= WID_CURRENT_TX_RATE
;
791 wid_list
[wid_cnt
].val
= (s8
*)&curr_tx_rate
;
792 wid_list
[wid_cnt
].type
= WID_SHORT
;
793 wid_list
[wid_cnt
].size
= sizeof(u16
);
794 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
796 PRINT_ER("out of TX rate\n");
803 result
= send_config_pkt(SET_CFG
, wid_list
, wid_cnt
,
804 get_id_from_handler(hif_drv
));
807 PRINT_ER("Error in setting CFG params\n");
810 up(&hif_drv
->sem_cfg_values
);
814 static void Handle_wait_msg_q_empty(void)
816 g_wilc_initialized
= 0;
817 up(&hif_sema_wait_response
);
820 static s32
Handle_Scan(struct host_if_drv
*hif_drv
,
821 struct scan_attr
*pstrHostIFscanAttr
)
824 struct wid strWIDList
[5];
825 u32 u32WidsCount
= 0;
829 u8
*pu8HdnNtwrksWidVal
= NULL
;
831 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
832 PRINT_D(HOSTINF_DBG
, "Scanning: In [%d] state\n", hif_drv
->hif_state
);
834 hif_drv
->usr_scan_req
.scan_result
= pstrHostIFscanAttr
->result
;
835 hif_drv
->usr_scan_req
.arg
= pstrHostIFscanAttr
->arg
;
837 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
838 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
839 PRINT_D(GENERIC_DBG
, "Don't scan already in [%d] state\n",
841 PRINT_ER("Already scan\n");
846 if (g_obtainingIP
|| connecting
) {
847 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
848 PRINT_ER("Don't do obss scan\n");
853 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
855 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
857 strWIDList
[u32WidsCount
].id
= (u16
)WID_SSID_PROBE_REQ
;
858 strWIDList
[u32WidsCount
].type
= WID_STR
;
860 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.u8ssidnum
; i
++)
861 valuesize
+= ((pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
) + 1);
862 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
863 strWIDList
[u32WidsCount
].val
= pu8HdnNtwrksWidVal
;
864 if (strWIDList
[u32WidsCount
].val
) {
865 pu8Buffer
= strWIDList
[u32WidsCount
].val
;
867 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.u8ssidnum
;
869 PRINT_D(HOSTINF_DBG
, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr
->hidden_network
.u8ssidnum
);
871 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.u8ssidnum
; i
++) {
872 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
873 memcpy(pu8Buffer
, pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].pu8ssid
, pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
);
874 pu8Buffer
+= pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
877 strWIDList
[u32WidsCount
].size
= (s32
)(valuesize
+ 1);
882 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_PROBE
;
883 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
884 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ies
;
885 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ies_len
;
889 strWIDList
[u32WidsCount
].id
= WID_SCAN_TYPE
;
890 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
891 strWIDList
[u32WidsCount
].size
= sizeof(char);
892 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->type
;
895 strWIDList
[u32WidsCount
].id
= WID_SCAN_CHANNEL_LIST
;
896 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
898 if (pstrHostIFscanAttr
->ch_freq_list
&&
899 pstrHostIFscanAttr
->ch_list_len
> 0) {
902 for (i
= 0; i
< pstrHostIFscanAttr
->ch_list_len
; i
++) {
903 if (pstrHostIFscanAttr
->ch_freq_list
[i
] > 0)
904 pstrHostIFscanAttr
->ch_freq_list
[i
] = pstrHostIFscanAttr
->ch_freq_list
[i
] - 1;
908 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ch_freq_list
;
909 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ch_list_len
;
912 strWIDList
[u32WidsCount
].id
= WID_START_SCAN_REQ
;
913 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
914 strWIDList
[u32WidsCount
].size
= sizeof(char);
915 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->src
;
918 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
919 scan_while_connected
= true;
920 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
921 scan_while_connected
= false;
923 result
= send_config_pkt(SET_CFG
, strWIDList
, u32WidsCount
,
924 get_id_from_handler(hif_drv
));
927 PRINT_ER("Failed to send scan paramters config packet\n");
929 PRINT_D(HOSTINF_DBG
, "Successfully sent SCAN params config packet\n");
933 del_timer(&hif_drv
->scan_timer
);
934 Handle_ScanDone(hif_drv
, SCAN_EVENT_ABORTED
);
937 kfree(pstrHostIFscanAttr
->ch_freq_list
);
938 pstrHostIFscanAttr
->ch_freq_list
= NULL
;
940 kfree(pstrHostIFscanAttr
->ies
);
941 pstrHostIFscanAttr
->ies
= NULL
;
942 kfree(pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
);
943 pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
= NULL
;
945 kfree(pu8HdnNtwrksWidVal
);
950 static s32
Handle_ScanDone(struct host_if_drv
*hif_drv
,
951 enum scan_event enuEvent
)
954 u8 u8abort_running_scan
;
957 PRINT_D(HOSTINF_DBG
, "in Handle_ScanDone()\n");
959 if (enuEvent
== SCAN_EVENT_ABORTED
) {
960 PRINT_D(GENERIC_DBG
, "Abort running scan\n");
961 u8abort_running_scan
= 1;
962 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
964 wid
.val
= (s8
*)&u8abort_running_scan
;
965 wid
.size
= sizeof(char);
967 result
= send_config_pkt(SET_CFG
, &wid
, 1,
968 get_id_from_handler(hif_drv
));
971 PRINT_ER("Failed to set abort running scan\n");
977 PRINT_ER("Driver handler is NULL\n");
981 if (hif_drv
->usr_scan_req
.scan_result
) {
982 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
983 hif_drv
->usr_scan_req
.arg
, NULL
);
984 hif_drv
->usr_scan_req
.scan_result
= NULL
;
990 u8 u8ConnectedSSID
[6] = {0};
991 static s32
Handle_Connect(struct host_if_drv
*hif_drv
,
992 struct connect_attr
*pstrHostIFconnectAttr
)
995 struct wid strWIDList
[8];
996 u32 u32WidsCount
= 0, dummyval
= 0;
997 u8
*pu8CurrByte
= NULL
;
998 struct join_bss_param
*ptstrJoinBssParam
;
1000 PRINT_D(GENERIC_DBG
, "Handling connect request\n");
1002 if (memcmp(pstrHostIFconnectAttr
->bssid
, u8ConnectedSSID
, ETH_ALEN
) == 0) {
1004 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1008 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
1010 ptstrJoinBssParam
= (struct join_bss_param
*)pstrHostIFconnectAttr
->params
;
1011 if (!ptstrJoinBssParam
) {
1012 PRINT_ER("Required BSSID not found\n");
1017 if (pstrHostIFconnectAttr
->bssid
) {
1018 hif_drv
->usr_conn_req
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
1019 memcpy(hif_drv
->usr_conn_req
.pu8bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1022 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
1023 if (pstrHostIFconnectAttr
->ssid
) {
1024 hif_drv
->usr_conn_req
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
1025 memcpy(hif_drv
->usr_conn_req
.pu8ssid
,
1026 pstrHostIFconnectAttr
->ssid
,
1027 pstrHostIFconnectAttr
->ssid_len
);
1028 hif_drv
->usr_conn_req
.pu8ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1031 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
1032 if (pstrHostIFconnectAttr
->ies
) {
1033 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1034 memcpy(hif_drv
->usr_conn_req
.ies
,
1035 pstrHostIFconnectAttr
->ies
,
1036 pstrHostIFconnectAttr
->ies_len
);
1039 hif_drv
->usr_conn_req
.u8security
= pstrHostIFconnectAttr
->security
;
1040 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
1041 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
1042 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
1044 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
1045 strWIDList
[u32WidsCount
].type
= WID_INT
;
1046 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1047 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1050 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
1051 strWIDList
[u32WidsCount
].type
= WID_INT
;
1052 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1053 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1056 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
1057 strWIDList
[u32WidsCount
].type
= WID_INT
;
1058 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1059 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1063 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1064 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1065 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
1066 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
1069 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1070 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
1071 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
1072 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
1076 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1077 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1078 strWIDList
[u32WidsCount
].size
= sizeof(char);
1079 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.u8security
;
1082 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1083 mode_11i
= hif_drv
->usr_conn_req
.u8security
;
1085 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", hif_drv
->usr_conn_req
.u8security
);
1087 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1088 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1089 strWIDList
[u32WidsCount
].size
= sizeof(char);
1090 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
1093 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1094 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
1096 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n",
1097 hif_drv
->usr_conn_req
.auth_type
);
1098 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1099 hif_drv
->usr_conn_req
.pu8ssid
, pstrHostIFconnectAttr
->ch
);
1101 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1102 strWIDList
[u32WidsCount
].type
= WID_STR
;
1103 strWIDList
[u32WidsCount
].size
= 112;
1104 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
1106 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1107 join_req_size
= strWIDList
[u32WidsCount
].size
;
1108 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
1110 if (!strWIDList
[u32WidsCount
].val
) {
1115 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1117 if (pstrHostIFconnectAttr
->ssid
) {
1118 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
1119 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1121 pu8CurrByte
+= MAX_SSID_LEN
;
1122 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1124 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
1125 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1127 PRINT_ER("Channel out of range\n");
1128 *(pu8CurrByte
++) = 0xFF;
1130 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1131 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1132 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1134 if (pstrHostIFconnectAttr
->bssid
)
1135 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1138 if (pstrHostIFconnectAttr
->bssid
)
1139 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1142 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1143 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1144 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1145 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1146 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1148 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1149 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1151 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1152 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1153 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1155 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1156 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1158 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1159 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1160 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1161 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1162 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1163 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1165 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1166 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1168 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1169 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1171 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1172 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1174 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1175 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1177 if (ptstrJoinBssParam
->noa_enabled
) {
1178 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1180 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1181 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1182 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1183 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1185 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1186 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1188 if (ptstrJoinBssParam
->opp_enabled
)
1189 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1191 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1193 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1194 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1196 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1197 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1199 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1200 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1202 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1204 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1207 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1208 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1209 join_req_drv
= hif_drv
;
1212 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
1214 if (pstrHostIFconnectAttr
->bssid
) {
1215 memcpy(u8ConnectedSSID
, pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1217 PRINT_D(GENERIC_DBG
, "save Bssid = %pM\n", pstrHostIFconnectAttr
->bssid
);
1218 PRINT_D(GENERIC_DBG
, "save bssid = %pM\n", u8ConnectedSSID
);
1221 result
= send_config_pkt(SET_CFG
, strWIDList
, u32WidsCount
,
1222 get_id_from_handler(hif_drv
));
1224 PRINT_ER("failed to send config packet\n");
1228 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
1229 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1234 tstrConnectInfo strConnectInfo
;
1236 del_timer(&hif_drv
->connect_timer
);
1238 PRINT_D(HOSTINF_DBG
, "could not start connecting to the required network\n");
1240 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1242 if (pstrHostIFconnectAttr
->result
) {
1243 if (pstrHostIFconnectAttr
->bssid
)
1244 memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1246 if (pstrHostIFconnectAttr
->ies
) {
1247 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->ies_len
;
1248 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1249 memcpy(strConnectInfo
.pu8ReqIEs
,
1250 pstrHostIFconnectAttr
->ies
,
1251 pstrHostIFconnectAttr
->ies_len
);
1254 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1258 pstrHostIFconnectAttr
->arg
);
1259 hif_drv
->hif_state
= HOST_IF_IDLE
;
1260 kfree(strConnectInfo
.pu8ReqIEs
);
1261 strConnectInfo
.pu8ReqIEs
= NULL
;
1264 PRINT_ER("Connect callback function pointer is NULL\n");
1268 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
1269 kfree(pstrHostIFconnectAttr
->bssid
);
1270 pstrHostIFconnectAttr
->bssid
= NULL
;
1272 kfree(pstrHostIFconnectAttr
->ssid
);
1273 pstrHostIFconnectAttr
->ssid
= NULL
;
1275 kfree(pstrHostIFconnectAttr
->ies
);
1276 pstrHostIFconnectAttr
->ies
= NULL
;
1282 static s32
Handle_FlushConnect(struct host_if_drv
*hif_drv
)
1285 struct wid strWIDList
[5];
1286 u32 u32WidsCount
= 0;
1287 u8
*pu8CurrByte
= NULL
;
1289 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1290 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1291 strWIDList
[u32WidsCount
].val
= info_element
;
1292 strWIDList
[u32WidsCount
].size
= info_element_size
;
1295 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1296 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1297 strWIDList
[u32WidsCount
].size
= sizeof(char);
1298 strWIDList
[u32WidsCount
].val
= (s8
*)(&(mode_11i
));
1301 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1302 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1303 strWIDList
[u32WidsCount
].size
= sizeof(char);
1304 strWIDList
[u32WidsCount
].val
= (s8
*)(&auth_type
);
1307 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1308 strWIDList
[u32WidsCount
].type
= WID_STR
;
1309 strWIDList
[u32WidsCount
].size
= join_req_size
;
1310 strWIDList
[u32WidsCount
].val
= (s8
*)join_req
;
1311 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1313 pu8CurrByte
+= FLUSHED_BYTE_POS
;
1314 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
1318 result
= send_config_pkt(SET_CFG
, strWIDList
, u32WidsCount
,
1319 get_id_from_handler(join_req_drv
));
1321 PRINT_ER("failed to send config packet\n");
1328 static s32
Handle_ConnectTimeout(struct host_if_drv
*hif_drv
)
1331 tstrConnectInfo strConnectInfo
;
1333 u16 u16DummyReasonCode
= 0;
1336 PRINT_ER("Driver handler is NULL\n");
1340 hif_drv
->hif_state
= HOST_IF_IDLE
;
1342 scan_while_connected
= false;
1344 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1346 if (hif_drv
->usr_conn_req
.conn_result
) {
1347 if (hif_drv
->usr_conn_req
.pu8bssid
) {
1348 memcpy(strConnectInfo
.au8bssid
,
1349 hif_drv
->usr_conn_req
.pu8bssid
, 6);
1352 if (hif_drv
->usr_conn_req
.ies
) {
1353 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1354 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1355 memcpy(strConnectInfo
.pu8ReqIEs
,
1356 hif_drv
->usr_conn_req
.ies
,
1357 hif_drv
->usr_conn_req
.ies_len
);
1360 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1364 hif_drv
->usr_conn_req
.arg
);
1366 kfree(strConnectInfo
.pu8ReqIEs
);
1367 strConnectInfo
.pu8ReqIEs
= NULL
;
1369 PRINT_ER("Connect callback function pointer is NULL\n");
1372 wid
.id
= (u16
)WID_DISCONNECT
;
1373 wid
.type
= WID_CHAR
;
1374 wid
.val
= (s8
*)&u16DummyReasonCode
;
1375 wid
.size
= sizeof(char);
1377 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
1379 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1380 get_id_from_handler(hif_drv
));
1382 PRINT_ER("Failed to send dissconect config packet\n");
1384 hif_drv
->usr_conn_req
.ssid_len
= 0;
1385 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1386 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1387 hif_drv
->usr_conn_req
.ies_len
= 0;
1388 kfree(hif_drv
->usr_conn_req
.ies
);
1390 eth_zero_addr(u8ConnectedSSID
);
1392 if (join_req
&& join_req_drv
== hif_drv
) {
1397 if (info_element
&& join_req_drv
== hif_drv
) {
1398 kfree(info_element
);
1399 info_element
= NULL
;
1405 static s32
Handle_RcvdNtwrkInfo(struct host_if_drv
*hif_drv
,
1406 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1409 bool bNewNtwrkFound
;
1411 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
1412 void *pJoinParams
= NULL
;
1414 bNewNtwrkFound
= true;
1415 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
1417 if (hif_drv
->usr_scan_req
.scan_result
) {
1418 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
1419 parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1420 if ((!pstrNetworkInfo
) ||
1421 (!hif_drv
->usr_scan_req
.scan_result
)) {
1422 PRINT_ER("driver is null\n");
1427 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1428 if ((hif_drv
->usr_scan_req
.net_info
[i
].au8bssid
) &&
1429 (pstrNetworkInfo
->au8bssid
)) {
1430 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].au8bssid
,
1431 pstrNetworkInfo
->au8bssid
, 6) == 0) {
1432 if (pstrNetworkInfo
->s8rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].s8rssi
) {
1433 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
1436 hif_drv
->usr_scan_req
.net_info
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
1437 bNewNtwrkFound
= false;
1444 if (bNewNtwrkFound
) {
1445 PRINT_D(HOSTINF_DBG
, "New network found\n");
1447 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1448 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].s8rssi
= pstrNetworkInfo
->s8rssi
;
1450 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].au8bssid
&&
1451 pstrNetworkInfo
->au8bssid
) {
1452 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].au8bssid
,
1453 pstrNetworkInfo
->au8bssid
, 6);
1455 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1457 pstrNetworkInfo
->bNewNetwork
= true;
1458 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1460 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1461 hif_drv
->usr_scan_req
.arg
,
1465 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit\n");
1468 pstrNetworkInfo
->bNewNetwork
= false;
1469 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1470 hif_drv
->usr_scan_req
.arg
, NULL
);
1475 kfree(pstrRcvdNetworkInfo
->buffer
);
1476 pstrRcvdNetworkInfo
->buffer
= NULL
;
1478 if (pstrNetworkInfo
) {
1479 DeallocateNetworkInfo(pstrNetworkInfo
);
1480 pstrNetworkInfo
= NULL
;
1486 static s32
Handle_RcvdGnrlAsyncInfo(struct host_if_drv
*hif_drv
,
1487 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1493 u16 u16WidID
= (u16
)WID_NIL
;
1496 u8 u8MacStatusReasonCode
;
1497 u8 u8MacStatusAdditionalInfo
;
1498 tstrConnectInfo strConnectInfo
;
1499 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1503 PRINT_ER("Driver handler is NULL\n");
1506 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n",
1507 hif_drv
->hif_state
, pstrRcvdGnrlAsyncInfo
->buffer
[7]);
1509 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1510 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1511 hif_drv
->usr_scan_req
.scan_result
) {
1512 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1513 !hif_drv
->usr_conn_req
.conn_result
) {
1514 PRINT_ER("driver is null\n");
1518 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1520 if ('I' != u8MsgType
) {
1521 PRINT_ER("Received Message format incorrect.\n");
1525 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1526 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1527 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1528 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1529 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1530 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1531 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1532 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
1533 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1534 u32 u32RcvdAssocRespInfoLen
;
1535 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
1537 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
1539 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1541 if (u8MacStatus
== MAC_CONNECTED
) {
1542 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1544 host_int_get_assoc_res_info(hif_drv
,
1546 MAX_ASSOC_RESP_FRAME_SIZE
,
1547 &u32RcvdAssocRespInfoLen
);
1549 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
1551 if (u32RcvdAssocRespInfoLen
!= 0) {
1552 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
1553 s32Err
= ParseAssocRespInfo(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1554 &pstrConnectRespInfo
);
1556 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err
);
1558 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
1560 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
1561 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
1562 if (pstrConnectRespInfo
->pu8RespIEs
) {
1563 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
1564 strConnectInfo
.pu8RespIEs
= kmalloc(pstrConnectRespInfo
->u16RespIEsLen
, GFP_KERNEL
);
1565 memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
1566 pstrConnectRespInfo
->u16RespIEsLen
);
1570 if (pstrConnectRespInfo
) {
1571 DeallocateAssocRespInfo(pstrConnectRespInfo
);
1572 pstrConnectRespInfo
= NULL
;
1578 if ((u8MacStatus
== MAC_CONNECTED
) &&
1579 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
1580 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1581 eth_zero_addr(u8ConnectedSSID
);
1583 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1584 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1585 eth_zero_addr(u8ConnectedSSID
);
1588 if (hif_drv
->usr_conn_req
.pu8bssid
) {
1589 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
1590 memcpy(strConnectInfo
.au8bssid
, hif_drv
->usr_conn_req
.pu8bssid
, 6);
1592 if ((u8MacStatus
== MAC_CONNECTED
) &&
1593 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1594 memcpy(hif_drv
->assoc_bssid
,
1595 hif_drv
->usr_conn_req
.pu8bssid
, ETH_ALEN
);
1599 if (hif_drv
->usr_conn_req
.ies
) {
1600 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1601 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1602 memcpy(strConnectInfo
.pu8ReqIEs
,
1603 hif_drv
->usr_conn_req
.ies
,
1604 hif_drv
->usr_conn_req
.ies_len
);
1607 del_timer(&hif_drv
->connect_timer
);
1608 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1612 hif_drv
->usr_conn_req
.arg
);
1614 if ((u8MacStatus
== MAC_CONNECTED
) &&
1615 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1616 host_int_set_power_mgmt(hif_drv
, 0, 0);
1618 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
1619 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1621 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
1622 g_obtainingIP
= true;
1623 mod_timer(&hDuringIpTimer
,
1624 jiffies
+ msecs_to_jiffies(10000));
1626 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
1627 hif_drv
->hif_state
= HOST_IF_IDLE
;
1628 scan_while_connected
= false;
1631 kfree(strConnectInfo
.pu8RespIEs
);
1632 strConnectInfo
.pu8RespIEs
= NULL
;
1634 kfree(strConnectInfo
.pu8ReqIEs
);
1635 strConnectInfo
.pu8ReqIEs
= NULL
;
1636 hif_drv
->usr_conn_req
.ssid_len
= 0;
1637 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1638 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1639 hif_drv
->usr_conn_req
.ies_len
= 0;
1640 kfree(hif_drv
->usr_conn_req
.ies
);
1641 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1642 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1643 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
1645 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1647 if (hif_drv
->usr_scan_req
.scan_result
) {
1648 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >>\n\n");
1649 del_timer(&hif_drv
->scan_timer
);
1650 Handle_ScanDone((void *)hif_drv
, SCAN_EVENT_ABORTED
);
1653 strDisconnectNotifInfo
.u16reason
= 0;
1654 strDisconnectNotifInfo
.ie
= NULL
;
1655 strDisconnectNotifInfo
.ie_len
= 0;
1657 if (hif_drv
->usr_conn_req
.conn_result
) {
1658 g_obtainingIP
= false;
1659 host_int_set_power_mgmt(hif_drv
, 0, 0);
1661 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1664 &strDisconnectNotifInfo
,
1665 hif_drv
->usr_conn_req
.arg
);
1667 PRINT_ER("Connect result callback function is NULL\n");
1670 eth_zero_addr(hif_drv
->assoc_bssid
);
1672 hif_drv
->usr_conn_req
.ssid_len
= 0;
1673 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1674 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1675 hif_drv
->usr_conn_req
.ies_len
= 0;
1676 kfree(hif_drv
->usr_conn_req
.ies
);
1678 if (join_req
&& join_req_drv
== hif_drv
) {
1683 if (info_element
&& join_req_drv
== hif_drv
) {
1684 kfree(info_element
);
1685 info_element
= NULL
;
1688 hif_drv
->hif_state
= HOST_IF_IDLE
;
1689 scan_while_connected
= false;
1691 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1692 (hif_drv
->usr_scan_req
.scan_result
)) {
1693 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
1694 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >>\n\n");
1696 del_timer(&hif_drv
->scan_timer
);
1697 if (hif_drv
->usr_scan_req
.scan_result
)
1698 Handle_ScanDone(hif_drv
, SCAN_EVENT_ABORTED
);
1702 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1703 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1708 static int Handle_Key(struct host_if_drv
*hif_drv
,
1709 struct key_attr
*pstrHostIFkeyAttr
)
1713 struct wid strWIDList
[5];
1719 switch (pstrHostIFkeyAttr
->type
) {
1722 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1723 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
1724 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", pstrHostIFkeyAttr
->attr
.wep
.index
);
1725 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1726 strWIDList
[0].type
= WID_CHAR
;
1727 strWIDList
[0].size
= sizeof(char);
1728 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1730 strWIDList
[1].id
= WID_AUTH_TYPE
;
1731 strWIDList
[1].type
= WID_CHAR
;
1732 strWIDList
[1].size
= sizeof(char);
1733 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1735 strWIDList
[2].id
= (u16
)WID_KEY_ID
;
1736 strWIDList
[2].type
= WID_CHAR
;
1738 strWIDList
[2].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1739 strWIDList
[2].size
= sizeof(char);
1741 pu8keybuf
= kmemdup(pstrHostIFkeyAttr
->attr
.wep
.key
,
1742 pstrHostIFkeyAttr
->attr
.wep
.key_len
,
1745 if (pu8keybuf
== NULL
) {
1746 PRINT_ER("No buffer to send Key\n");
1750 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1752 strWIDList
[3].id
= (u16
)WID_WEP_KEY_VALUE
;
1753 strWIDList
[3].type
= WID_STR
;
1754 strWIDList
[3].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1755 strWIDList
[3].val
= (s8
*)pu8keybuf
;
1757 result
= send_config_pkt(SET_CFG
, strWIDList
, 4,
1758 get_id_from_handler(hif_drv
));
1762 if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1763 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
1764 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1766 PRINT_ER("No buffer to send Key\n");
1769 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1770 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1771 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1772 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1773 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1775 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1777 wid
.val
= (s8
*)pu8keybuf
;
1778 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1780 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1781 get_id_from_handler(hif_drv
));
1783 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1784 PRINT_D(HOSTINF_DBG
, "Removing key\n");
1785 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1788 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1789 wid
.val
= s8idxarray
;
1792 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1793 get_id_from_handler(hif_drv
));
1795 wid
.id
= (u16
)WID_KEY_ID
;
1796 wid
.type
= WID_CHAR
;
1797 wid
.val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1798 wid
.size
= sizeof(char);
1800 PRINT_D(HOSTINF_DBG
, "Setting default key index\n");
1802 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1803 get_id_from_handler(hif_drv
));
1805 up(&hif_drv
->sem_test_key_block
);
1809 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1810 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1812 PRINT_ER("No buffer to send RxGTK Key\n");
1814 goto _WPARxGtk_end_case_
;
1817 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1818 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1820 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1821 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1822 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1823 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1825 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1826 strWIDList
[0].type
= WID_CHAR
;
1827 strWIDList
[0].size
= sizeof(char);
1828 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1830 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1831 strWIDList
[1].type
= WID_STR
;
1832 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1833 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1835 result
= send_config_pkt(SET_CFG
, strWIDList
, 2,
1836 get_id_from_handler(hif_drv
));
1839 up(&hif_drv
->sem_test_key_block
);
1842 if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1843 PRINT_D(HOSTINF_DBG
, "Handling group key(Rx) function\n");
1845 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1846 if (pu8keybuf
== NULL
) {
1847 PRINT_ER("No buffer to send RxGTK Key\n");
1849 goto _WPARxGtk_end_case_
;
1852 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
1853 memcpy(pu8keybuf
, hif_drv
->assoc_bssid
, ETH_ALEN
);
1855 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
1857 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1858 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1859 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1860 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1861 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1863 wid
.id
= (u16
)WID_ADD_RX_GTK
;
1865 wid
.val
= (s8
*)pu8keybuf
;
1866 wid
.size
= RX_MIC_KEY_MSG_LEN
;
1868 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1869 get_id_from_handler(hif_drv
));
1872 up(&hif_drv
->sem_test_key_block
);
1874 _WPARxGtk_end_case_
:
1875 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1876 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1883 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1884 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1886 PRINT_ER("No buffer to send PTK Key\n");
1888 goto _WPAPtk_end_case_
;
1891 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1892 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1893 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1894 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1895 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1897 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1898 strWIDList
[0].type
= WID_CHAR
;
1899 strWIDList
[0].size
= sizeof(char);
1900 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1902 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1903 strWIDList
[1].type
= WID_STR
;
1904 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1905 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1907 result
= send_config_pkt(SET_CFG
, strWIDList
, 2,
1908 get_id_from_handler(hif_drv
));
1910 up(&hif_drv
->sem_test_key_block
);
1912 if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1913 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1915 PRINT_ER("No buffer to send PTK Key\n");
1917 goto _WPAPtk_end_case_
;
1920 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1921 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1922 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1923 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1925 wid
.id
= (u16
)WID_ADD_PTK
;
1927 wid
.val
= (s8
*)pu8keybuf
;
1928 wid
.size
= PTK_KEY_MSG_LEN
;
1930 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1931 get_id_from_handler(hif_drv
));
1933 up(&hif_drv
->sem_test_key_block
);
1937 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1945 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
1947 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1949 PRINT_ER("No buffer to send PMKSA Key\n");
1953 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1955 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1956 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1957 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1960 wid
.id
= (u16
)WID_PMKID_INFO
;
1962 wid
.val
= (s8
*)pu8keybuf
;
1963 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1965 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1966 get_id_from_handler(hif_drv
));
1973 PRINT_ER("Failed to send key config packet\n");
1978 static void Handle_Disconnect(struct host_if_drv
*hif_drv
)
1983 u16 u16DummyReasonCode
= 0;
1985 wid
.id
= (u16
)WID_DISCONNECT
;
1986 wid
.type
= WID_CHAR
;
1987 wid
.val
= (s8
*)&u16DummyReasonCode
;
1988 wid
.size
= sizeof(char);
1990 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
1992 g_obtainingIP
= false;
1993 host_int_set_power_mgmt(hif_drv
, 0, 0);
1995 eth_zero_addr(u8ConnectedSSID
);
1997 result
= send_config_pkt(SET_CFG
, &wid
, 1,
1998 get_id_from_handler(hif_drv
));
2001 PRINT_ER("Failed to send dissconect config packet\n");
2003 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2005 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2007 strDisconnectNotifInfo
.u16reason
= 0;
2008 strDisconnectNotifInfo
.ie
= NULL
;
2009 strDisconnectNotifInfo
.ie_len
= 0;
2011 if (hif_drv
->usr_scan_req
.scan_result
) {
2012 del_timer(&hif_drv
->scan_timer
);
2013 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
2015 hif_drv
->usr_scan_req
.arg
,
2017 hif_drv
->usr_scan_req
.scan_result
= NULL
;
2020 if (hif_drv
->usr_conn_req
.conn_result
) {
2021 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2022 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
2023 del_timer(&hif_drv
->connect_timer
);
2026 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2029 &strDisconnectNotifInfo
,
2030 hif_drv
->usr_conn_req
.arg
);
2032 PRINT_ER("usr_conn_req.conn_result = NULL\n");
2035 scan_while_connected
= false;
2037 hif_drv
->hif_state
= HOST_IF_IDLE
;
2039 eth_zero_addr(hif_drv
->assoc_bssid
);
2041 hif_drv
->usr_conn_req
.ssid_len
= 0;
2042 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
2043 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
2044 hif_drv
->usr_conn_req
.ies_len
= 0;
2045 kfree(hif_drv
->usr_conn_req
.ies
);
2047 if (join_req
&& join_req_drv
== hif_drv
) {
2052 if (info_element
&& join_req_drv
== hif_drv
) {
2053 kfree(info_element
);
2054 info_element
= NULL
;
2058 up(&hif_drv
->sem_test_disconn_block
);
2061 void resolve_disconnect_aberration(struct host_if_drv
*hif_drv
)
2065 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
2066 (hif_drv
->hif_state
== HOST_IF_CONNECTING
)) {
2067 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
2068 host_int_disconnect(hif_drv
, 1);
2072 static s32
Handle_GetChnl(struct host_if_drv
*hif_drv
)
2077 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
2078 wid
.type
= WID_CHAR
;
2079 wid
.val
= (s8
*)&ch_no
;
2080 wid
.size
= sizeof(char);
2082 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
2084 result
= send_config_pkt(GET_CFG
, &wid
, 1,
2085 get_id_from_handler(hif_drv
));
2088 PRINT_ER("Failed to get channel number\n");
2092 up(&hif_drv
->sem_get_chnl
);
2097 static void Handle_GetRssi(struct host_if_drv
*hif_drv
)
2102 wid
.id
= (u16
)WID_RSSI
;
2103 wid
.type
= WID_CHAR
;
2105 wid
.size
= sizeof(char);
2107 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
2109 result
= send_config_pkt(GET_CFG
, &wid
, 1,
2110 get_id_from_handler(hif_drv
));
2112 PRINT_ER("Failed to get RSSI value\n");
2116 up(&hif_drv
->sem_get_rssi
);
2119 static void Handle_GetLinkspeed(struct host_if_drv
*hif_drv
)
2126 wid
.id
= (u16
)WID_LINKSPEED
;
2127 wid
.type
= WID_CHAR
;
2128 wid
.val
= &link_speed
;
2129 wid
.size
= sizeof(char);
2131 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
2133 result
= send_config_pkt(GET_CFG
, &wid
, 1,
2134 get_id_from_handler(hif_drv
));
2136 PRINT_ER("Failed to get LINKSPEED value\n");
2140 up(&hif_drv
->sem_get_link_speed
);
2143 s32
Handle_GetStatistics(struct host_if_drv
*hif_drv
, struct rf_info
*pstrStatistics
)
2145 struct wid strWIDList
[5];
2146 u32 u32WidsCount
= 0, result
= 0;
2148 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
2149 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2150 strWIDList
[u32WidsCount
].size
= sizeof(char);
2151 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
2154 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
2155 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2156 strWIDList
[u32WidsCount
].size
= sizeof(char);
2157 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
2160 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
2161 strWIDList
[u32WidsCount
].type
= WID_INT
;
2162 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2163 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
2166 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
2167 strWIDList
[u32WidsCount
].type
= WID_INT
;
2168 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2169 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
2172 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
2173 strWIDList
[u32WidsCount
].type
= WID_INT
;
2174 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2175 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
2178 result
= send_config_pkt(GET_CFG
, strWIDList
, u32WidsCount
,
2179 get_id_from_handler(hif_drv
));
2182 PRINT_ER("Failed to send scan paramters config packet\n");
2184 up(&hif_sema_wait_response
);
2188 static s32
Handle_Get_InActiveTime(struct host_if_drv
*hif_drv
,
2189 struct sta_inactive_t
*strHostIfStaInactiveT
)
2195 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
2197 wid
.size
= ETH_ALEN
;
2198 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2201 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
2203 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
2205 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2206 get_id_from_handler(hif_drv
));
2209 PRINT_ER("Failed to SET incative time\n");
2213 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
2215 wid
.val
= (s8
*)&inactive_time
;
2216 wid
.size
= sizeof(u32
);
2218 result
= send_config_pkt(GET_CFG
, &wid
, 1,
2219 get_id_from_handler(hif_drv
));
2222 PRINT_ER("Failed to get incative time\n");
2226 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", inactive_time
);
2228 up(&hif_drv
->sem_inactive_time
);
2233 static void Handle_AddBeacon(struct host_if_drv
*hif_drv
,
2234 struct beacon_attr
*pstrSetBeaconParam
)
2240 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
2242 wid
.id
= (u16
)WID_ADD_BEACON
;
2244 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
2245 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2249 pu8CurrByte
= wid
.val
;
2250 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
2251 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
2252 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
2253 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
2255 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
2256 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
2257 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
2258 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
2260 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
2261 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
2262 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
2263 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
2265 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
2266 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2268 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2269 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2270 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2271 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2273 if (pstrSetBeaconParam
->tail
> 0)
2274 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2275 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2277 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2278 get_id_from_handler(hif_drv
));
2280 PRINT_ER("Failed to send add beacon config packet\n");
2284 kfree(pstrSetBeaconParam
->head
);
2285 kfree(pstrSetBeaconParam
->tail
);
2288 static void Handle_DelBeacon(struct host_if_drv
*hif_drv
)
2294 wid
.id
= (u16
)WID_DEL_BEACON
;
2295 wid
.type
= WID_CHAR
;
2296 wid
.size
= sizeof(char);
2297 wid
.val
= &del_beacon
;
2302 pu8CurrByte
= wid
.val
;
2304 PRINT_D(HOSTINF_DBG
, "Deleting BEACON\n");
2306 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2307 get_id_from_handler(hif_drv
));
2309 PRINT_ER("Failed to send delete beacon config packet\n");
2312 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2313 struct add_sta_param
*pstrStationParam
)
2317 pu8CurrByte
= pu8Buffer
;
2319 PRINT_D(HOSTINF_DBG
, "Packing STA params\n");
2320 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2321 pu8CurrByte
+= ETH_ALEN
;
2323 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2324 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2326 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2327 if (pstrStationParam
->rates_len
> 0)
2328 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2329 pstrStationParam
->rates_len
);
2330 pu8CurrByte
+= pstrStationParam
->rates_len
;
2332 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2333 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2334 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2336 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2337 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2338 WILC_SUPP_MCS_SET_SIZE
);
2339 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2341 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2342 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2344 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2345 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2346 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2347 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2349 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2351 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2352 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2354 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2355 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2357 return pu8CurrByte
- pu8Buffer
;
2360 static void Handle_AddStation(struct host_if_drv
*hif_drv
,
2361 struct add_sta_param
*pstrStationParam
)
2367 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
2368 wid
.id
= (u16
)WID_ADD_STA
;
2370 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2372 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2376 pu8CurrByte
= wid
.val
;
2377 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2379 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2380 get_id_from_handler(hif_drv
));
2382 PRINT_ER("Failed to send add station config packet\n");
2385 kfree(pstrStationParam
->rates
);
2389 static void Handle_DelAllSta(struct host_if_drv
*hif_drv
,
2390 struct del_all_sta
*pstrDelAllStaParam
)
2396 u8 au8Zero_Buff
[6] = {0};
2398 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2400 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2402 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
2404 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2408 pu8CurrByte
= wid
.val
;
2410 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2412 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2413 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2414 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2418 pu8CurrByte
+= ETH_ALEN
;
2421 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2422 get_id_from_handler(hif_drv
));
2424 PRINT_ER("Failed to send add station config packet\n");
2429 up(&hif_sema_wait_response
);
2432 static void Handle_DelStation(struct host_if_drv
*hif_drv
,
2433 struct del_sta
*pstrDelStaParam
)
2439 wid
.id
= (u16
)WID_REMOVE_STA
;
2441 wid
.size
= ETH_ALEN
;
2443 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
2445 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2449 pu8CurrByte
= wid
.val
;
2451 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2453 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2454 get_id_from_handler(hif_drv
));
2456 PRINT_ER("Failed to send add station config packet\n");
2462 static void Handle_EditStation(struct host_if_drv
*hif_drv
,
2463 struct add_sta_param
*pstrStationParam
)
2469 wid
.id
= (u16
)WID_EDIT_STA
;
2471 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2473 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
2474 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2478 pu8CurrByte
= wid
.val
;
2479 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2481 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2482 get_id_from_handler(hif_drv
));
2484 PRINT_ER("Failed to send edit station config packet\n");
2487 kfree(pstrStationParam
->rates
);
2491 static int Handle_RemainOnChan(struct host_if_drv
*hif_drv
,
2492 struct remain_ch
*pstrHostIfRemainOnChan
)
2495 u8 u8remain_on_chan_flag
;
2498 if (!hif_drv
->remain_on_ch_pending
) {
2499 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2500 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2501 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2502 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2503 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2505 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2508 if (hif_drv
->usr_scan_req
.scan_result
) {
2509 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
2510 hif_drv
->remain_on_ch_pending
= 1;
2514 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2515 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
2520 if (g_obtainingIP
|| connecting
) {
2521 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2526 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n",
2527 pstrHostIfRemainOnChan
->ch
);
2529 u8remain_on_chan_flag
= true;
2530 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2533 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2539 wid
.val
[0] = u8remain_on_chan_flag
;
2540 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2542 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2543 get_id_from_handler(hif_drv
));
2545 PRINT_ER("Failed to set remain on channel\n");
2549 P2P_LISTEN_STATE
= 1;
2550 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)hif_drv
;
2551 mod_timer(&hif_drv
->remain_on_ch_timer
,
2553 msecs_to_jiffies(pstrHostIfRemainOnChan
->u32duration
));
2555 if (hif_drv
->remain_on_ch
.ready
)
2556 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2558 if (hif_drv
->remain_on_ch_pending
)
2559 hif_drv
->remain_on_ch_pending
= 0;
2565 static int Handle_RegisterFrame(struct host_if_drv
*hif_drv
,
2566 struct reg_frame
*pstrHostIfRegisterFrame
)
2572 PRINT_D(HOSTINF_DBG
, "Handling frame register : %d FrameType: %d\n",
2573 pstrHostIfRegisterFrame
->reg
,
2574 pstrHostIfRegisterFrame
->frame_type
);
2576 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2578 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2582 pu8CurrByte
= wid
.val
;
2584 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2585 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2586 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2588 wid
.size
= sizeof(u16
) + 2;
2590 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2591 get_id_from_handler(hif_drv
));
2593 PRINT_ER("Failed to frame register config packet\n");
2600 static u32
Handle_ListenStateExpired(struct host_if_drv
*hif_drv
,
2601 struct remain_ch
*pstrHostIfRemainOnChan
)
2603 u8 u8remain_on_chan_flag
;
2607 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
2609 if (P2P_LISTEN_STATE
) {
2610 u8remain_on_chan_flag
= false;
2611 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2614 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2617 PRINT_ER("Failed to allocate memory\n");
2619 wid
.val
[0] = u8remain_on_chan_flag
;
2620 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2622 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2623 get_id_from_handler(hif_drv
));
2625 PRINT_ER("Failed to set remain on channel\n");
2629 if (hif_drv
->remain_on_ch
.expired
) {
2630 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2631 pstrHostIfRemainOnChan
->id
);
2633 P2P_LISTEN_STATE
= 0;
2635 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
2643 static void ListenTimerCB(unsigned long arg
)
2646 struct host_if_msg msg
;
2647 struct host_if_drv
*hif_drv
= (struct host_if_drv
*)arg
;
2649 del_timer(&hif_drv
->remain_on_ch_timer
);
2651 memset(&msg
, 0, sizeof(struct host_if_msg
));
2652 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2654 msg
.body
.remain_on_ch
.id
= hif_drv
->remain_on_ch
.id
;
2656 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2658 PRINT_ER("wilc_mq_send fail\n");
2661 static void Handle_PowerManagement(struct host_if_drv
*hif_drv
,
2662 struct power_mgmt_param
*strPowerMgmtParam
)
2668 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2670 if (strPowerMgmtParam
->enabled
)
2671 s8PowerMode
= MIN_FAST_PS
;
2673 s8PowerMode
= NO_POWERSAVE
;
2674 PRINT_D(HOSTINF_DBG
, "Handling power mgmt to %d\n", s8PowerMode
);
2675 wid
.val
= &s8PowerMode
;
2676 wid
.size
= sizeof(char);
2678 PRINT_D(HOSTINF_DBG
, "Handling Power Management\n");
2680 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2681 get_id_from_handler(hif_drv
));
2683 PRINT_ER("Failed to send power management config packet\n");
2686 static void Handle_SetMulticastFilter(struct host_if_drv
*hif_drv
,
2687 struct set_multicast
*strHostIfSetMulti
)
2693 PRINT_D(HOSTINF_DBG
, "Setup Multicast Filter\n");
2695 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2697 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2698 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2702 pu8CurrByte
= wid
.val
;
2703 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2704 *pu8CurrByte
++ = ((strHostIfSetMulti
->enabled
>> 8) & 0xFF);
2705 *pu8CurrByte
++ = ((strHostIfSetMulti
->enabled
>> 16) & 0xFF);
2706 *pu8CurrByte
++ = ((strHostIfSetMulti
->enabled
>> 24) & 0xFF);
2708 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2709 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2710 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2711 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2713 if ((strHostIfSetMulti
->cnt
) > 0)
2714 memcpy(pu8CurrByte
, multicast_mac_addr_list
,
2715 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2717 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2718 get_id_from_handler(hif_drv
));
2720 PRINT_ER("Failed to send setup multicast config packet\n");
2726 static s32
Handle_AddBASession(struct host_if_drv
*hif_drv
,
2727 struct ba_session_info
*strHostIfBASessionInfo
)
2731 int AddbaTimeout
= 100;
2734 PRINT_D(HOSTINF_DBG
, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
2735 strHostIfBASessionInfo
->bssid
[0],
2736 strHostIfBASessionInfo
->bssid
[1],
2737 strHostIfBASessionInfo
->bssid
[2],
2738 strHostIfBASessionInfo
->buf_size
,
2739 strHostIfBASessionInfo
->time_out
,
2740 strHostIfBASessionInfo
->tid
);
2742 wid
.id
= (u16
)WID_11E_P_ACTION_REQ
;
2744 wid
.val
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
2745 wid
.size
= BLOCK_ACK_REQ_SIZE
;
2750 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2752 *ptr
++ = strHostIfBASessionInfo
->tid
;
2754 *ptr
++ = (strHostIfBASessionInfo
->buf_size
& 0xFF);
2755 *ptr
++ = ((strHostIfBASessionInfo
->buf_size
>> 16) & 0xFF);
2756 *ptr
++ = (strHostIfBASessionInfo
->time_out
& 0xFF);
2757 *ptr
++ = ((strHostIfBASessionInfo
->time_out
>> 16) & 0xFF);
2758 *ptr
++ = (AddbaTimeout
& 0xFF);
2759 *ptr
++ = ((AddbaTimeout
>> 16) & 0xFF);
2763 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2764 get_id_from_handler(hif_drv
));
2766 PRINT_D(HOSTINF_DBG
, "Couldn't open BA Session\n");
2768 wid
.id
= (u16
)WID_11E_P_ACTION_REQ
;
2775 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2777 *ptr
++ = strHostIfBASessionInfo
->tid
;
2779 *ptr
++ = (strHostIfBASessionInfo
->buf_size
& 0xFF);
2780 *ptr
++ = ((strHostIfBASessionInfo
->time_out
>> 16) & 0xFF);
2782 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2783 get_id_from_handler(hif_drv
));
2790 static s32
Handle_DelAllRxBASessions(struct host_if_drv
*hif_drv
,
2791 struct ba_session_info
*strHostIfBASessionInfo
)
2797 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2798 strHostIfBASessionInfo
->bssid
[0],
2799 strHostIfBASessionInfo
->bssid
[1],
2800 strHostIfBASessionInfo
->bssid
[2],
2801 strHostIfBASessionInfo
->tid
);
2803 wid
.id
= (u16
)WID_DEL_ALL_RX_BA
;
2805 wid
.val
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
2806 wid
.size
= BLOCK_ACK_REQ_SIZE
;
2811 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2813 *ptr
++ = strHostIfBASessionInfo
->tid
;
2817 result
= send_config_pkt(SET_CFG
, &wid
, 1,
2818 get_id_from_handler(hif_drv
));
2820 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
2824 up(&hif_sema_wait_response
);
2829 static int hostIFthread(void *pvArg
)
2832 struct host_if_msg msg
;
2833 struct host_if_drv
*hif_drv
;
2835 memset(&msg
, 0, sizeof(struct host_if_msg
));
2838 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2839 hif_drv
= (struct host_if_drv
*)msg
.drv
;
2840 if (msg
.id
== HOST_IF_MSG_EXIT
) {
2841 PRINT_D(GENERIC_DBG
, "THREAD: Exiting HostIfThread\n");
2845 if ((!g_wilc_initialized
)) {
2846 PRINT_D(GENERIC_DBG
, "--WAIT--");
2847 usleep_range(200 * 1000, 200 * 1000);
2848 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2852 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2853 hif_drv
->usr_scan_req
.scan_result
) {
2854 PRINT_D(HOSTINF_DBG
, "Requeue connect request till scan done received\n");
2855 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2856 usleep_range(2 * 1000, 2 * 1000);
2861 case HOST_IF_MSG_Q_IDLE
:
2862 Handle_wait_msg_q_empty();
2865 case HOST_IF_MSG_SCAN
:
2866 Handle_Scan(msg
.drv
, &msg
.body
.scan_info
);
2869 case HOST_IF_MSG_CONNECT
:
2870 Handle_Connect(msg
.drv
, &msg
.body
.con_info
);
2873 case HOST_IF_MSG_FLUSH_CONNECT
:
2874 Handle_FlushConnect(msg
.drv
);
2877 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2878 Handle_RcvdNtwrkInfo(msg
.drv
, &msg
.body
.net_info
);
2881 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2882 Handle_RcvdGnrlAsyncInfo(msg
.drv
, &msg
.body
.async_info
);
2885 case HOST_IF_MSG_KEY
:
2886 Handle_Key(msg
.drv
, &msg
.body
.key_info
);
2889 case HOST_IF_MSG_CFG_PARAMS
:
2890 handle_cfg_param(msg
.drv
, &msg
.body
.cfg_info
);
2893 case HOST_IF_MSG_SET_CHANNEL
:
2894 handle_set_channel(msg
.drv
, &msg
.body
.channel_info
);
2897 case HOST_IF_MSG_DISCONNECT
:
2898 Handle_Disconnect(msg
.drv
);
2901 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2902 del_timer(&hif_drv
->scan_timer
);
2903 PRINT_D(HOSTINF_DBG
, "scan completed successfully\n");
2905 if (!linux_wlan_get_num_conn_ifcs())
2906 chip_sleep_manually();
2908 Handle_ScanDone(msg
.drv
, SCAN_EVENT_DONE
);
2910 if (hif_drv
->remain_on_ch_pending
)
2911 Handle_RemainOnChan(msg
.drv
, &msg
.body
.remain_on_ch
);
2915 case HOST_IF_MSG_GET_RSSI
:
2916 Handle_GetRssi(msg
.drv
);
2919 case HOST_IF_MSG_GET_LINKSPEED
:
2920 Handle_GetLinkspeed(msg
.drv
);
2923 case HOST_IF_MSG_GET_STATISTICS
:
2924 Handle_GetStatistics(msg
.drv
, (struct rf_info
*)msg
.body
.data
);
2927 case HOST_IF_MSG_GET_CHNL
:
2928 Handle_GetChnl(msg
.drv
);
2931 case HOST_IF_MSG_ADD_BEACON
:
2932 Handle_AddBeacon(msg
.drv
, &msg
.body
.beacon_info
);
2935 case HOST_IF_MSG_DEL_BEACON
:
2936 Handle_DelBeacon(msg
.drv
);
2939 case HOST_IF_MSG_ADD_STATION
:
2940 Handle_AddStation(msg
.drv
, &msg
.body
.add_sta_info
);
2943 case HOST_IF_MSG_DEL_STATION
:
2944 Handle_DelStation(msg
.drv
, &msg
.body
.del_sta_info
);
2947 case HOST_IF_MSG_EDIT_STATION
:
2948 Handle_EditStation(msg
.drv
, &msg
.body
.edit_sta_info
);
2951 case HOST_IF_MSG_GET_INACTIVETIME
:
2952 Handle_Get_InActiveTime(msg
.drv
, &msg
.body
.mac_info
);
2955 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2956 PRINT_D(HOSTINF_DBG
, "Scan Timeout\n");
2958 Handle_ScanDone(msg
.drv
, SCAN_EVENT_ABORTED
);
2961 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2962 PRINT_D(HOSTINF_DBG
, "Connect Timeout\n");
2963 Handle_ConnectTimeout(msg
.drv
);
2966 case HOST_IF_MSG_POWER_MGMT
:
2967 Handle_PowerManagement(msg
.drv
, &msg
.body
.pwr_mgmt_info
);
2970 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2971 handle_set_wfi_drv_handler(msg
.drv
, &msg
.body
.drv
);
2974 case HOST_IF_MSG_SET_OPERATION_MODE
:
2975 handle_set_operation_mode(msg
.drv
, &msg
.body
.mode
);
2978 case HOST_IF_MSG_SET_IPADDRESS
:
2979 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
2980 handle_set_ip_address(msg
.drv
,
2981 msg
.body
.ip_info
.ip_addr
,
2982 msg
.body
.ip_info
.idx
);
2985 case HOST_IF_MSG_GET_IPADDRESS
:
2986 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
2987 handle_get_ip_address(msg
.drv
, msg
.body
.ip_info
.idx
);
2990 case HOST_IF_MSG_SET_MAC_ADDRESS
:
2991 handle_set_mac_address(msg
.drv
,
2992 &msg
.body
.set_mac_info
);
2995 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2996 handle_get_mac_address(msg
.drv
,
2997 &msg
.body
.get_mac_info
);
3000 case HOST_IF_MSG_REMAIN_ON_CHAN
:
3001 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
3002 Handle_RemainOnChan(msg
.drv
, &msg
.body
.remain_on_ch
);
3005 case HOST_IF_MSG_REGISTER_FRAME
:
3006 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REGISTER_FRAME\n");
3007 Handle_RegisterFrame(msg
.drv
, &msg
.body
.reg_frame
);
3010 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
3011 Handle_ListenStateExpired(msg
.drv
, &msg
.body
.remain_on_ch
);
3014 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
3015 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
3016 Handle_SetMulticastFilter(msg
.drv
, &msg
.body
.multicast_info
);
3019 case HOST_IF_MSG_ADD_BA_SESSION
:
3020 Handle_AddBASession(msg
.drv
, &msg
.body
.session_info
);
3023 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
3024 Handle_DelAllRxBASessions(msg
.drv
, &msg
.body
.session_info
);
3027 case HOST_IF_MSG_DEL_ALL_STA
:
3028 Handle_DelAllSta(msg
.drv
, &msg
.body
.del_all_sta_info
);
3032 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
3037 PRINT_D(HOSTINF_DBG
, "Releasing thread exit semaphore\n");
3038 up(&hif_sema_thread
);
3042 static void TimerCB_Scan(unsigned long arg
)
3044 void *pvArg
= (void *)arg
;
3045 struct host_if_msg msg
;
3047 memset(&msg
, 0, sizeof(struct host_if_msg
));
3049 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
3051 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3054 static void TimerCB_Connect(unsigned long arg
)
3056 void *pvArg
= (void *)arg
;
3057 struct host_if_msg msg
;
3059 memset(&msg
, 0, sizeof(struct host_if_msg
));
3061 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
3063 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3066 s32
host_int_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
3070 wid
.id
= (u16
)WID_REMOVE_KEY
;
3072 wid
.val
= (s8
*)pu8StaAddress
;
3078 int host_int_remove_wep_key(struct host_if_drv
*hif_drv
, u8 index
)
3081 struct host_if_msg msg
;
3085 PRINT_ER("Failed to send setup multicast config packet\n");
3089 memset(&msg
, 0, sizeof(struct host_if_msg
));
3091 msg
.id
= HOST_IF_MSG_KEY
;
3092 msg
.body
.key_info
.type
= WEP
;
3093 msg
.body
.key_info
.action
= REMOVEKEY
;
3095 msg
.body
.key_info
.attr
.wep
.index
= index
;
3097 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3099 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3100 down(&hif_drv
->sem_test_key_block
);
3105 int host_int_set_wep_default_key(struct host_if_drv
*hif_drv
, u8 index
)
3108 struct host_if_msg msg
;
3112 PRINT_ER("driver is null\n");
3116 memset(&msg
, 0, sizeof(struct host_if_msg
));
3118 msg
.id
= HOST_IF_MSG_KEY
;
3119 msg
.body
.key_info
.type
= WEP
;
3120 msg
.body
.key_info
.action
= DEFAULTKEY
;
3122 msg
.body
.key_info
.attr
.wep
.index
= index
;
3124 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3126 PRINT_ER("Error in sending message queue : Default key index\n");
3127 down(&hif_drv
->sem_test_key_block
);
3132 int host_int_add_wep_key_bss_sta(struct host_if_drv
*hif_drv
,
3138 struct host_if_msg msg
;
3141 PRINT_ER("driver is null\n");
3145 memset(&msg
, 0, sizeof(struct host_if_msg
));
3147 msg
.id
= HOST_IF_MSG_KEY
;
3148 msg
.body
.key_info
.type
= WEP
;
3149 msg
.body
.key_info
.action
= ADDKEY
;
3151 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3152 if (!msg
.body
.key_info
.attr
.wep
.key
)
3155 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3156 msg
.body
.key_info
.attr
.wep
.index
= index
;
3158 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3160 PRINT_ER("Error in sending message queue :WEP Key\n");
3161 down(&hif_drv
->sem_test_key_block
);
3166 int host_int_add_wep_key_bss_ap(struct host_if_drv
*hif_drv
,
3171 enum AUTHTYPE auth_type
)
3174 struct host_if_msg msg
;
3178 PRINT_ER("driver is null\n");
3182 memset(&msg
, 0, sizeof(struct host_if_msg
));
3185 for (i
= 0; i
< len
; i
++)
3186 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", key
[i
]);
3188 msg
.id
= HOST_IF_MSG_KEY
;
3189 msg
.body
.key_info
.type
= WEP
;
3190 msg
.body
.key_info
.action
= ADDKEY_AP
;
3192 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3193 if (!msg
.body
.key_info
.attr
.wep
.key
)
3196 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3197 msg
.body
.key_info
.attr
.wep
.index
= index
;
3198 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
3199 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
3201 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3204 PRINT_ER("Error in sending message queue :WEP Key\n");
3205 down(&hif_drv
->sem_test_key_block
);
3210 int host_int_add_ptk(struct host_if_drv
*hif_drv
, const u8
*ptk
,
3211 u8 ptk_key_len
, const u8
*mac_addr
,
3212 const u8
*rx_mic
, const u8
*tx_mic
,
3213 u8 mode
, u8 cipher_mode
, u8 index
)
3216 struct host_if_msg msg
;
3217 u8 key_len
= ptk_key_len
;
3221 PRINT_ER("driver is null\n");
3226 key_len
+= RX_MIC_KEY_LEN
;
3229 key_len
+= TX_MIC_KEY_LEN
;
3231 memset(&msg
, 0, sizeof(struct host_if_msg
));
3233 msg
.id
= HOST_IF_MSG_KEY
;
3234 msg
.body
.key_info
.type
= WPA_PTK
;
3235 if (mode
== AP_MODE
) {
3236 msg
.body
.key_info
.action
= ADDKEY_AP
;
3237 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3239 if (mode
== STATION_MODE
)
3240 msg
.body
.key_info
.action
= ADDKEY
;
3242 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
3243 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3247 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
3249 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
3250 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, rx_mic
[i
]);
3254 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
3256 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
3257 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, tx_mic
[i
]);
3261 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3262 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
3263 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3266 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3269 PRINT_ER("Error in sending message queue: PTK Key\n");
3271 down(&hif_drv
->sem_test_key_block
);
3276 int host_int_add_rx_gtk(struct host_if_drv
*hif_drv
, const u8
*rx_gtk
,
3277 u8 gtk_key_len
, u8 index
,
3278 u32 key_rsc_len
, const u8
*key_rsc
,
3279 const u8
*rx_mic
, const u8
*tx_mic
,
3280 u8 mode
, u8 cipher_mode
)
3283 struct host_if_msg msg
;
3284 u8 key_len
= gtk_key_len
;
3287 PRINT_ER("driver is null\n");
3290 memset(&msg
, 0, sizeof(struct host_if_msg
));
3293 key_len
+= RX_MIC_KEY_LEN
;
3296 key_len
+= TX_MIC_KEY_LEN
;
3299 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
3302 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
3306 msg
.id
= HOST_IF_MSG_KEY
;
3307 msg
.body
.key_info
.type
= WPA_RX_GTK
;
3310 if (mode
== AP_MODE
) {
3311 msg
.body
.key_info
.action
= ADDKEY_AP
;
3312 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3314 if (mode
== STATION_MODE
)
3315 msg
.body
.key_info
.action
= ADDKEY
;
3317 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
3320 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3324 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
3328 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
3331 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3332 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3333 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
3335 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3337 PRINT_ER("Error in sending message queue: RX GTK\n");
3339 down(&hif_drv
->sem_test_key_block
);
3344 s32
host_int_set_pmkid_info(struct host_if_drv
*hif_drv
, struct host_if_pmkid_attr
*pu8PmkidInfoArray
)
3347 struct host_if_msg msg
;
3351 PRINT_ER("driver is null\n");
3355 memset(&msg
, 0, sizeof(struct host_if_msg
));
3357 msg
.id
= HOST_IF_MSG_KEY
;
3358 msg
.body
.key_info
.type
= PMKSA
;
3359 msg
.body
.key_info
.action
= ADDKEY
;
3362 for (i
= 0; i
< pu8PmkidInfoArray
->numpmkid
; i
++) {
3363 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
3364 &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
, ETH_ALEN
);
3365 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
3366 &pu8PmkidInfoArray
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
3369 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3371 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3376 s32
host_int_get_pmkid_info(struct host_if_drv
*hif_drv
,
3377 u8
*pu8PmkidInfoArray
,
3378 u32 u32PmkidInfoLen
)
3382 wid
.id
= (u16
)WID_PMKID_INFO
;
3384 wid
.size
= u32PmkidInfoLen
;
3385 wid
.val
= pu8PmkidInfoArray
;
3390 s32
host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv
*hif_drv
,
3396 if ((u8Psklength
> 7) && (u8Psklength
< 65)) {
3397 wid
.id
= (u16
)WID_11I_PSK
;
3399 wid
.val
= pu8PassPhrase
;
3400 wid
.size
= u8Psklength
;
3406 s32
hif_get_mac_address(struct host_if_drv
*hif_drv
, u8
*pu8MacAddress
)
3409 struct host_if_msg msg
;
3411 memset(&msg
, 0, sizeof(struct host_if_msg
));
3413 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
3414 msg
.body
.get_mac_info
.mac_addr
= pu8MacAddress
;
3417 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3419 PRINT_ER("Failed to send get mac address\n");
3423 down(&hif_sema_wait_response
);
3427 s32
host_int_set_MacAddress(struct host_if_drv
*hif_drv
, u8
*pu8MacAddress
)
3430 struct host_if_msg msg
;
3432 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
3434 memset(&msg
, 0, sizeof(struct host_if_msg
));
3435 msg
.id
= HOST_IF_MSG_SET_MAC_ADDRESS
;
3436 memcpy(msg
.body
.set_mac_info
.mac_addr
, pu8MacAddress
, ETH_ALEN
);
3439 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3441 PRINT_ER("Failed to send message queue: Set mac address\n");
3446 s32
host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv
*hif_drv
,
3447 u8
*pu8PassPhrase
, u8 u8Psklength
)
3451 wid
.id
= (u16
)WID_11I_PSK
;
3453 wid
.size
= u8Psklength
;
3454 wid
.val
= pu8PassPhrase
;
3459 s32
host_int_set_start_scan_req(struct host_if_drv
*hif_drv
, u8 scanSource
)
3463 wid
.id
= (u16
)WID_START_SCAN_REQ
;
3464 wid
.type
= WID_CHAR
;
3465 wid
.val
= (s8
*)&scanSource
;
3466 wid
.size
= sizeof(char);
3471 s32
host_int_get_start_scan_req(struct host_if_drv
*hif_drv
, u8
*pu8ScanSource
)
3475 wid
.id
= (u16
)WID_START_SCAN_REQ
;
3476 wid
.type
= WID_CHAR
;
3477 wid
.val
= (s8
*)pu8ScanSource
;
3478 wid
.size
= sizeof(char);
3483 s32
host_int_set_join_req(struct host_if_drv
*hif_drv
, u8
*pu8bssid
,
3484 const u8
*pu8ssid
, size_t ssidLen
,
3485 const u8
*pu8IEs
, size_t IEsLen
,
3486 wilc_connect_result pfConnectResult
, void *pvUserArg
,
3487 u8 u8security
, enum AUTHTYPE tenuAuth_type
,
3488 u8 u8channel
, void *pJoinParams
)
3491 struct host_if_msg msg
;
3493 if (!hif_drv
|| !pfConnectResult
) {
3494 PRINT_ER("Driver is null\n");
3499 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3503 memset(&msg
, 0, sizeof(struct host_if_msg
));
3505 msg
.id
= HOST_IF_MSG_CONNECT
;
3507 msg
.body
.con_info
.security
= u8security
;
3508 msg
.body
.con_info
.auth_type
= tenuAuth_type
;
3509 msg
.body
.con_info
.ch
= u8channel
;
3510 msg
.body
.con_info
.result
= pfConnectResult
;
3511 msg
.body
.con_info
.arg
= pvUserArg
;
3512 msg
.body
.con_info
.params
= pJoinParams
;
3516 msg
.body
.con_info
.bssid
= kmalloc(6, GFP_KERNEL
);
3517 memcpy(msg
.body
.con_info
.bssid
, pu8bssid
, 6);
3521 msg
.body
.con_info
.ssid_len
= ssidLen
;
3522 msg
.body
.con_info
.ssid
= kmalloc(ssidLen
, GFP_KERNEL
);
3523 memcpy(msg
.body
.con_info
.ssid
, pu8ssid
, ssidLen
);
3527 msg
.body
.con_info
.ies_len
= IEsLen
;
3528 msg
.body
.con_info
.ies
= kmalloc(IEsLen
, GFP_KERNEL
);
3529 memcpy(msg
.body
.con_info
.ies
, pu8IEs
, IEsLen
);
3531 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3532 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3534 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' : %d\n",
3535 hif_drv
->hif_state
);
3537 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3539 PRINT_ER("Failed to send message queue: Set join request\n");
3543 hif_drv
->connect_timer
.data
= (unsigned long)hif_drv
;
3544 mod_timer(&hif_drv
->connect_timer
,
3545 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3550 s32
host_int_flush_join_req(struct host_if_drv
*hif_drv
)
3553 struct host_if_msg msg
;
3559 PRINT_ER("Driver is null\n");
3563 msg
.id
= HOST_IF_MSG_FLUSH_CONNECT
;
3566 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3568 PRINT_ER("Failed to send message queue: Flush join request\n");
3575 s32
host_int_disconnect(struct host_if_drv
*hif_drv
, u16 u16ReasonCode
)
3578 struct host_if_msg msg
;
3581 PRINT_ER("Driver is null\n");
3585 memset(&msg
, 0, sizeof(struct host_if_msg
));
3587 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3590 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3592 PRINT_ER("Failed to send message queue: disconnect\n");
3594 down(&hif_drv
->sem_test_disconn_block
);
3599 s32
host_int_disconnect_station(struct host_if_drv
*hif_drv
, u8 assoc_id
)
3603 wid
.id
= (u16
)WID_DISCONNECT
;
3604 wid
.type
= WID_CHAR
;
3605 wid
.val
= (s8
*)&assoc_id
;
3606 wid
.size
= sizeof(char);
3611 s32
host_int_get_assoc_req_info(struct host_if_drv
*hif_drv
,
3612 u8
*pu8AssocReqInfo
,
3613 u32 u32AssocReqInfoLen
)
3617 wid
.id
= (u16
)WID_ASSOC_REQ_INFO
;
3619 wid
.val
= pu8AssocReqInfo
;
3620 wid
.size
= u32AssocReqInfoLen
;
3625 s32
host_int_get_assoc_res_info(struct host_if_drv
*hif_drv
,
3626 u8
*pu8AssocRespInfo
,
3627 u32 u32MaxAssocRespInfoLen
,
3628 u32
*pu32RcvdAssocRespInfoLen
)
3634 PRINT_ER("Driver is null\n");
3638 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3640 wid
.val
= pu8AssocRespInfo
;
3641 wid
.size
= u32MaxAssocRespInfoLen
;
3643 result
= send_config_pkt(GET_CFG
, &wid
, 1,
3644 get_id_from_handler(hif_drv
));
3646 *pu32RcvdAssocRespInfoLen
= 0;
3647 PRINT_ER("Failed to send association response config packet\n");
3650 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3656 s32
host_int_get_rx_power_level(struct host_if_drv
*hif_drv
,
3657 u8
*pu8RxPowerLevel
,
3658 u32 u32RxPowerLevelLen
)
3662 wid
.id
= (u16
)WID_RX_POWER_LEVEL
;
3664 wid
.val
= pu8RxPowerLevel
;
3665 wid
.size
= u32RxPowerLevelLen
;
3670 int host_int_set_mac_chnl_num(struct host_if_drv
*hif_drv
, u8 channel
)
3673 struct host_if_msg msg
;
3676 PRINT_ER("driver is null\n");
3680 memset(&msg
, 0, sizeof(struct host_if_msg
));
3681 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3682 msg
.body
.channel_info
.set_ch
= channel
;
3685 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3687 PRINT_ER("wilc mq send fail\n");
3694 int host_int_wait_msg_queue_idle(void)
3697 struct host_if_msg msg
;
3699 memset(&msg
, 0, sizeof(struct host_if_msg
));
3700 msg
.id
= HOST_IF_MSG_Q_IDLE
;
3701 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3703 PRINT_ER("wilc mq send fail\n");
3707 down(&hif_sema_wait_response
);
3712 int host_int_set_wfi_drv_handler(struct host_if_drv
*hif_drv
)
3715 struct host_if_msg msg
;
3717 memset(&msg
, 0, sizeof(struct host_if_msg
));
3718 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3719 msg
.body
.drv
.handler
= get_id_from_handler(hif_drv
);
3722 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3724 PRINT_ER("wilc mq send fail\n");
3731 int host_int_set_operation_mode(struct host_if_drv
*hif_drv
, u32 mode
)
3734 struct host_if_msg msg
;
3736 memset(&msg
, 0, sizeof(struct host_if_msg
));
3737 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3738 msg
.body
.mode
.mode
= mode
;
3741 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3743 PRINT_ER("wilc mq send fail\n");
3750 s32
host_int_get_host_chnl_num(struct host_if_drv
*hif_drv
, u8
*pu8ChNo
)
3753 struct host_if_msg msg
;
3756 PRINT_ER("driver is null\n");
3760 memset(&msg
, 0, sizeof(struct host_if_msg
));
3762 msg
.id
= HOST_IF_MSG_GET_CHNL
;
3765 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3767 PRINT_ER("wilc mq send fail\n");
3768 down(&hif_drv
->sem_get_chnl
);
3775 s32
host_int_get_inactive_time(struct host_if_drv
*hif_drv
,
3776 const u8
*mac
, u32
*pu32InactiveTime
)
3779 struct host_if_msg msg
;
3782 PRINT_ER("driver is null\n");
3786 memset(&msg
, 0, sizeof(struct host_if_msg
));
3787 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3789 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3792 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3794 PRINT_ER("Failed to send get host channel param's message queue ");
3796 down(&hif_drv
->sem_inactive_time
);
3798 *pu32InactiveTime
= inactive_time
;
3803 s32
host_int_test_get_int_wid(struct host_if_drv
*hif_drv
, u32
*pu32TestMemAddr
)
3809 PRINT_ER("driver is null\n");
3813 wid
.id
= (u16
)WID_MEMORY_ADDRESS
;
3815 wid
.val
= (s8
*)pu32TestMemAddr
;
3816 wid
.size
= sizeof(u32
);
3818 result
= send_config_pkt(GET_CFG
, &wid
, 1,
3819 get_id_from_handler(hif_drv
));
3822 PRINT_ER("Failed to get wid value\n");
3825 PRINT_D(HOSTINF_DBG
, "Successfully got wid value\n");
3831 s32
host_int_get_rssi(struct host_if_drv
*hif_drv
, s8
*ps8Rssi
)
3834 struct host_if_msg msg
;
3836 memset(&msg
, 0, sizeof(struct host_if_msg
));
3837 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3840 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3842 PRINT_ER("Failed to send get host channel param's message queue ");
3846 down(&hif_drv
->sem_get_rssi
);
3849 PRINT_ER("RSS pointer value is null");
3858 s32
host_int_get_link_speed(struct host_if_drv
*hif_drv
, s8
*ps8lnkspd
)
3860 struct host_if_msg msg
;
3863 memset(&msg
, 0, sizeof(struct host_if_msg
));
3864 msg
.id
= HOST_IF_MSG_GET_LINKSPEED
;
3867 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3869 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
3873 down(&hif_drv
->sem_get_link_speed
);
3876 PRINT_ER("LINKSPEED pointer value is null");
3880 *ps8lnkspd
= link_speed
;
3885 s32
host_int_get_statistics(struct host_if_drv
*hif_drv
, struct rf_info
*pstrStatistics
)
3888 struct host_if_msg msg
;
3890 memset(&msg
, 0, sizeof(struct host_if_msg
));
3891 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3892 msg
.body
.data
= (char *)pstrStatistics
;
3895 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3897 PRINT_ER("Failed to send get host channel param's message queue ");
3901 down(&hif_sema_wait_response
);
3905 s32
host_int_scan(struct host_if_drv
*hif_drv
, u8 u8ScanSource
,
3906 u8 u8ScanType
, u8
*pu8ChnlFreqList
,
3907 u8 u8ChnlListLen
, const u8
*pu8IEs
,
3908 size_t IEsLen
, wilc_scan_result ScanResult
,
3909 void *pvUserArg
, struct hidden_network
*pstrHiddenNetwork
)
3912 struct host_if_msg msg
;
3914 if (!hif_drv
|| !ScanResult
) {
3915 PRINT_ER("hif_drv or ScanResult = NULL\n");
3919 memset(&msg
, 0, sizeof(struct host_if_msg
));
3921 msg
.id
= HOST_IF_MSG_SCAN
;
3923 if (pstrHiddenNetwork
) {
3924 msg
.body
.scan_info
.hidden_network
.pstrHiddenNetworkInfo
= pstrHiddenNetwork
->pstrHiddenNetworkInfo
;
3925 msg
.body
.scan_info
.hidden_network
.u8ssidnum
= pstrHiddenNetwork
->u8ssidnum
;
3928 PRINT_D(HOSTINF_DBG
, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3931 msg
.body
.scan_info
.src
= u8ScanSource
;
3932 msg
.body
.scan_info
.type
= u8ScanType
;
3933 msg
.body
.scan_info
.result
= ScanResult
;
3934 msg
.body
.scan_info
.arg
= pvUserArg
;
3936 msg
.body
.scan_info
.ch_list_len
= u8ChnlListLen
;
3937 msg
.body
.scan_info
.ch_freq_list
= kmalloc(u8ChnlListLen
, GFP_KERNEL
);
3938 memcpy(msg
.body
.scan_info
.ch_freq_list
, pu8ChnlFreqList
, u8ChnlListLen
);
3940 msg
.body
.scan_info
.ies_len
= IEsLen
;
3941 msg
.body
.scan_info
.ies
= kmalloc(IEsLen
, GFP_KERNEL
);
3942 memcpy(msg
.body
.scan_info
.ies
, pu8IEs
, IEsLen
);
3944 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3946 PRINT_ER("Error in sending message queue\n");
3950 PRINT_D(HOSTINF_DBG
, ">> Starting the SCAN timer\n");
3951 hif_drv
->scan_timer
.data
= (unsigned long)hif_drv
;
3952 mod_timer(&hif_drv
->scan_timer
,
3953 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3958 s32
hif_set_cfg(struct host_if_drv
*hif_drv
,
3959 struct cfg_param_val
*pstrCfgParamVal
)
3962 struct host_if_msg msg
;
3965 PRINT_ER("hif_drv NULL\n");
3969 memset(&msg
, 0, sizeof(struct host_if_msg
));
3970 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3971 msg
.body
.cfg_info
.cfg_attr_info
= *pstrCfgParamVal
;
3974 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3979 s32
hif_get_cfg(struct host_if_drv
*hif_drv
, u16 u16WID
, u16
*pu16WID_Value
)
3983 down(&hif_drv
->sem_cfg_values
);
3986 PRINT_ER("hif_drv NULL\n");
3989 PRINT_D(HOSTINF_DBG
, "Getting configuration parameters\n");
3992 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.bss_type
;
3996 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.auth_type
;
3999 case WID_AUTH_TIMEOUT
:
4000 *pu16WID_Value
= hif_drv
->cfg_values
.auth_timeout
;
4003 case WID_POWER_MANAGEMENT
:
4004 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.power_mgmt_mode
;
4007 case WID_SHORT_RETRY_LIMIT
:
4008 *pu16WID_Value
= hif_drv
->cfg_values
.short_retry_limit
;
4011 case WID_LONG_RETRY_LIMIT
:
4012 *pu16WID_Value
= hif_drv
->cfg_values
.long_retry_limit
;
4015 case WID_FRAG_THRESHOLD
:
4016 *pu16WID_Value
= hif_drv
->cfg_values
.frag_threshold
;
4019 case WID_RTS_THRESHOLD
:
4020 *pu16WID_Value
= hif_drv
->cfg_values
.rts_threshold
;
4024 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.preamble_type
;
4027 case WID_SHORT_SLOT_ALLOWED
:
4028 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.short_slot_allowed
;
4031 case WID_11N_TXOP_PROT_DISABLE
:
4032 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.txop_prot_disabled
;
4035 case WID_BEACON_INTERVAL
:
4036 *pu16WID_Value
= hif_drv
->cfg_values
.beacon_interval
;
4039 case WID_DTIM_PERIOD
:
4040 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.dtim_period
;
4043 case WID_SITE_SURVEY
:
4044 *pu16WID_Value
= (u16
)hif_drv
->cfg_values
.site_survey_enabled
;
4047 case WID_SITE_SURVEY_SCAN_TIME
:
4048 *pu16WID_Value
= hif_drv
->cfg_values
.site_survey_scan_time
;
4051 case WID_ACTIVE_SCAN_TIME
:
4052 *pu16WID_Value
= hif_drv
->cfg_values
.active_scan_time
;
4055 case WID_PASSIVE_SCAN_TIME
:
4056 *pu16WID_Value
= hif_drv
->cfg_values
.passive_scan_time
;
4059 case WID_CURRENT_TX_RATE
:
4060 *pu16WID_Value
= hif_drv
->cfg_values
.curr_tx_rate
;
4067 up(&hif_drv
->sem_cfg_values
);
4072 static void GetPeriodicRSSI(unsigned long arg
)
4074 struct host_if_drv
*hif_drv
= (struct host_if_drv
*)arg
;
4077 PRINT_ER("Driver handler is NULL\n");
4081 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
) {
4083 struct host_if_msg msg
;
4085 memset(&msg
, 0, sizeof(struct host_if_msg
));
4087 msg
.id
= HOST_IF_MSG_GET_RSSI
;
4090 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4092 PRINT_ER("Failed to send get host channel param's message queue ");
4096 periodic_rssi
.data
= (unsigned long)hif_drv
;
4097 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
4100 s32
host_int_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
4103 struct host_if_drv
*hif_drv
;
4105 perInterface_wlan_t
*nic
;
4108 nic
= netdev_priv(dev
);
4111 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
4113 scan_while_connected
= false;
4115 sema_init(&hif_sema_wait_response
, 0);
4117 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
4122 *hif_drv_handler
= hif_drv
;
4123 err
= add_handler_in_list(hif_drv
);
4129 g_obtainingIP
= false;
4131 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", hif_drv
);
4132 if (clients_count
== 0) {
4133 sema_init(&hif_sema_thread
, 0);
4134 sema_init(&hif_sema_driver
, 0);
4135 sema_init(&hif_sema_deinit
, 1);
4138 sema_init(&hif_drv
->sem_test_key_block
, 0);
4139 sema_init(&hif_drv
->sem_test_disconn_block
, 0);
4140 sema_init(&hif_drv
->sem_get_rssi
, 0);
4141 sema_init(&hif_drv
->sem_get_link_speed
, 0);
4142 sema_init(&hif_drv
->sem_get_chnl
, 0);
4143 sema_init(&hif_drv
->sem_inactive_time
, 0);
4145 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
4147 if (clients_count
== 0) {
4148 result
= wilc_mq_create(&hif_msg_q
);
4151 PRINT_ER("Failed to creat MQ\n");
4155 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
4158 if (IS_ERR(hif_thread_handler
)) {
4159 PRINT_ER("Failed to creat Thread\n");
4163 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
4164 (unsigned long)hif_drv
);
4165 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
4168 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
4169 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
4170 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
4172 sema_init(&hif_drv
->sem_cfg_values
, 1);
4173 down(&hif_drv
->sem_cfg_values
);
4175 hif_drv
->hif_state
= HOST_IF_IDLE
;
4176 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
4177 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
4178 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
4179 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
4180 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
4182 hif_drv
->p2p_timeout
= 0;
4184 PRINT_INFO(HOSTINF_DBG
, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
4185 hif_drv
->cfg_values
.site_survey_enabled
,
4186 hif_drv
->cfg_values
.scan_source
,
4187 hif_drv
->cfg_values
.active_scan_time
,
4188 hif_drv
->cfg_values
.passive_scan_time
,
4189 hif_drv
->cfg_values
.curr_tx_rate
);
4191 up(&hif_drv
->sem_cfg_values
);
4198 up(&hif_drv
->sem_cfg_values
);
4199 del_timer_sync(&hif_drv
->connect_timer
);
4200 del_timer_sync(&hif_drv
->scan_timer
);
4201 kthread_stop(hif_thread_handler
);
4203 wilc_mq_destroy(&hif_msg_q
);
4208 s32
host_int_deinit(struct host_if_drv
*hif_drv
)
4211 struct host_if_msg msg
;
4215 PRINT_ER("hif_drv = NULL\n");
4219 down(&hif_sema_deinit
);
4221 terminated_handle
= hif_drv
;
4222 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
4224 if (del_timer_sync(&hif_drv
->scan_timer
))
4225 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active\n");
4227 if (del_timer_sync(&hif_drv
->connect_timer
))
4228 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
4230 if (del_timer_sync(&periodic_rssi
))
4231 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
4233 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
4235 host_int_set_wfi_drv_handler(NULL
);
4236 down(&hif_sema_driver
);
4238 if (hif_drv
->usr_scan_req
.scan_result
) {
4239 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
4240 hif_drv
->usr_scan_req
.arg
, NULL
);
4241 hif_drv
->usr_scan_req
.scan_result
= NULL
;
4244 hif_drv
->hif_state
= HOST_IF_IDLE
;
4246 scan_while_connected
= false;
4248 memset(&msg
, 0, sizeof(struct host_if_msg
));
4250 if (clients_count
== 1) {
4251 if (del_timer_sync(&periodic_rssi
))
4252 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
4254 msg
.id
= HOST_IF_MSG_EXIT
;
4257 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4259 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result
);
4261 down(&hif_sema_thread
);
4263 wilc_mq_destroy(&hif_msg_q
);
4266 down(&hif_drv
->sem_cfg_values
);
4268 ret
= remove_handler_in_list(hif_drv
);
4275 terminated_handle
= NULL
;
4276 up(&hif_sema_deinit
);
4280 void NetworkInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
4283 struct host_if_msg msg
;
4285 struct host_if_drv
*hif_drv
= NULL
;
4287 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
4288 hif_drv
= get_handler_from_id(id
);
4290 if (!hif_drv
|| hif_drv
== terminated_handle
) {
4291 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv
);
4295 memset(&msg
, 0, sizeof(struct host_if_msg
));
4297 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
4300 msg
.body
.net_info
.len
= u32Length
;
4301 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
4302 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
4304 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4306 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result
);
4309 void GnrlAsyncInfoReceived(u8
*pu8Buffer
, u32 u32Length
)
4312 struct host_if_msg msg
;
4314 struct host_if_drv
*hif_drv
= NULL
;
4316 down(&hif_sema_deinit
);
4318 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
4319 hif_drv
= get_handler_from_id(id
);
4320 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received\n");
4322 if (!hif_drv
|| hif_drv
== terminated_handle
) {
4323 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
4324 up(&hif_sema_deinit
);
4328 if (!hif_drv
->usr_conn_req
.conn_result
) {
4329 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4330 up(&hif_sema_deinit
);
4334 memset(&msg
, 0, sizeof(struct host_if_msg
));
4336 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
4339 msg
.body
.async_info
.len
= u32Length
;
4340 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
4341 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
4343 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4345 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result
);
4347 up(&hif_sema_deinit
);
4350 void host_int_ScanCompleteReceived(u8
*pu8Buffer
, u32 u32Length
)
4353 struct host_if_msg msg
;
4355 struct host_if_drv
*hif_drv
= NULL
;
4357 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
4358 hif_drv
= get_handler_from_id(id
);
4360 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", hif_drv
);
4362 if (!hif_drv
|| hif_drv
== terminated_handle
)
4365 if (hif_drv
->usr_scan_req
.scan_result
) {
4366 memset(&msg
, 0, sizeof(struct host_if_msg
));
4368 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
4371 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4373 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result
);
4379 s32
host_int_remain_on_channel(struct host_if_drv
*hif_drv
, u32 u32SessionID
,
4380 u32 u32duration
, u16 chan
,
4381 wilc_remain_on_chan_expired RemainOnChanExpired
,
4382 wilc_remain_on_chan_ready RemainOnChanReady
,
4386 struct host_if_msg msg
;
4389 PRINT_ER("driver is null\n");
4393 memset(&msg
, 0, sizeof(struct host_if_msg
));
4395 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
4396 msg
.body
.remain_on_ch
.ch
= chan
;
4397 msg
.body
.remain_on_ch
.expired
= RemainOnChanExpired
;
4398 msg
.body
.remain_on_ch
.ready
= RemainOnChanReady
;
4399 msg
.body
.remain_on_ch
.arg
= pvUserArg
;
4400 msg
.body
.remain_on_ch
.u32duration
= u32duration
;
4401 msg
.body
.remain_on_ch
.id
= u32SessionID
;
4404 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4406 PRINT_ER("wilc mq send fail\n");
4411 s32
host_int_ListenStateExpired(struct host_if_drv
*hif_drv
, u32 u32SessionID
)
4414 struct host_if_msg msg
;
4417 PRINT_ER("driver is null\n");
4421 del_timer(&hif_drv
->remain_on_ch_timer
);
4423 memset(&msg
, 0, sizeof(struct host_if_msg
));
4424 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
4426 msg
.body
.remain_on_ch
.id
= u32SessionID
;
4428 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4430 PRINT_ER("wilc mq send fail\n");
4435 s32
host_int_frame_register(struct host_if_drv
*hif_drv
, u16 u16FrameType
, bool bReg
)
4438 struct host_if_msg msg
;
4441 PRINT_ER("driver is null\n");
4445 memset(&msg
, 0, sizeof(struct host_if_msg
));
4447 msg
.id
= HOST_IF_MSG_REGISTER_FRAME
;
4448 switch (u16FrameType
) {
4450 PRINT_D(HOSTINF_DBG
, "ACTION\n");
4451 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
4455 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
4456 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
4460 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
4463 msg
.body
.reg_frame
.frame_type
= u16FrameType
;
4464 msg
.body
.reg_frame
.reg
= bReg
;
4467 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4469 PRINT_ER("wilc mq send fail\n");
4474 s32
host_int_add_beacon(struct host_if_drv
*hif_drv
, u32 u32Interval
,
4475 u32 u32DTIMPeriod
, u32 u32HeadLen
, u8
*pu8Head
,
4476 u32 u32TailLen
, u8
*pu8Tail
)
4479 struct host_if_msg msg
;
4480 struct beacon_attr
*pstrSetBeaconParam
= &msg
.body
.beacon_info
;
4483 PRINT_ER("driver is null\n");
4487 memset(&msg
, 0, sizeof(struct host_if_msg
));
4489 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
4491 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
4493 pstrSetBeaconParam
->interval
= u32Interval
;
4494 pstrSetBeaconParam
->dtim_period
= u32DTIMPeriod
;
4495 pstrSetBeaconParam
->head_len
= u32HeadLen
;
4496 pstrSetBeaconParam
->head
= kmemdup(pu8Head
, u32HeadLen
, GFP_KERNEL
);
4497 if (!pstrSetBeaconParam
->head
) {
4501 pstrSetBeaconParam
->tail_len
= u32TailLen
;
4503 if (u32TailLen
> 0) {
4504 pstrSetBeaconParam
->tail
= kmemdup(pu8Tail
, u32TailLen
,
4506 if (!pstrSetBeaconParam
->tail
) {
4511 pstrSetBeaconParam
->tail
= NULL
;
4514 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4516 PRINT_ER("wilc mq send fail\n");
4520 kfree(pstrSetBeaconParam
->head
);
4522 kfree(pstrSetBeaconParam
->tail
);
4528 int host_int_del_beacon(struct host_if_drv
*hif_drv
)
4531 struct host_if_msg msg
;
4534 PRINT_ER("driver is null\n");
4538 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
4540 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
4542 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4544 PRINT_ER("wilc_mq_send fail\n");
4549 int host_int_add_station(struct host_if_drv
*hif_drv
,
4550 struct add_sta_param
*sta_param
)
4553 struct host_if_msg msg
;
4554 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
4557 PRINT_ER("driver is null\n");
4561 memset(&msg
, 0, sizeof(struct host_if_msg
));
4563 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
4565 msg
.id
= HOST_IF_MSG_ADD_STATION
;
4568 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
4569 if (add_sta_info
->rates_len
> 0) {
4570 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
4571 add_sta_info
->rates_len
,
4573 if (!add_sta_info
->rates
)
4577 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4579 PRINT_ER("wilc_mq_send fail\n");
4583 int host_int_del_station(struct host_if_drv
*hif_drv
, const u8
*mac_addr
)
4586 struct host_if_msg msg
;
4587 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
4590 PRINT_ER("driver is null\n");
4594 memset(&msg
, 0, sizeof(struct host_if_msg
));
4596 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
4598 msg
.id
= HOST_IF_MSG_DEL_STATION
;
4602 eth_broadcast_addr(del_sta_info
->mac_addr
);
4604 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
4606 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4608 PRINT_ER("wilc_mq_send fail\n");
4612 s32
host_int_del_allstation(struct host_if_drv
*hif_drv
,
4613 u8 pu8MacAddr
[][ETH_ALEN
])
4616 struct host_if_msg msg
;
4617 struct del_all_sta
*pstrDelAllStationMsg
= &msg
.body
.del_all_sta_info
;
4618 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
4623 PRINT_ER("driver is null\n");
4627 memset(&msg
, 0, sizeof(struct host_if_msg
));
4629 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
4631 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
4634 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
4635 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
4636 memcpy(pstrDelAllStationMsg
->del_all_sta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
4637 PRINT_D(CFG80211_DBG
, "BSSID = %x%x%x%x%x%x\n",
4638 pstrDelAllStationMsg
->del_all_sta
[i
][0],
4639 pstrDelAllStationMsg
->del_all_sta
[i
][1],
4640 pstrDelAllStationMsg
->del_all_sta
[i
][2],
4641 pstrDelAllStationMsg
->del_all_sta
[i
][3],
4642 pstrDelAllStationMsg
->del_all_sta
[i
][4],
4643 pstrDelAllStationMsg
->del_all_sta
[i
][5]);
4648 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
4652 pstrDelAllStationMsg
->assoc_sta
= u8AssocNumb
;
4653 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4656 PRINT_ER("wilc_mq_send fail\n");
4658 down(&hif_sema_wait_response
);
4663 s32
host_int_edit_station(struct host_if_drv
*hif_drv
,
4664 struct add_sta_param
*pstrStaParams
)
4667 struct host_if_msg msg
;
4668 struct add_sta_param
*pstrAddStationMsg
= &msg
.body
.add_sta_info
;
4671 PRINT_ER("driver is null\n");
4675 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
4677 memset(&msg
, 0, sizeof(struct host_if_msg
));
4679 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
4682 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(struct add_sta_param
));
4683 if (pstrAddStationMsg
->rates_len
> 0) {
4684 u8
*rates
= kmalloc(pstrAddStationMsg
->rates_len
, GFP_KERNEL
);
4689 memcpy(rates
, pstrStaParams
->rates
,
4690 pstrAddStationMsg
->rates_len
);
4691 pstrAddStationMsg
->rates
= rates
;
4694 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4696 PRINT_ER("wilc_mq_send fail\n");
4701 s32
host_int_set_power_mgmt(struct host_if_drv
*hif_drv
,
4706 struct host_if_msg msg
;
4707 struct power_mgmt_param
*pstrPowerMgmtParam
= &msg
.body
.pwr_mgmt_info
;
4709 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled
);
4712 PRINT_ER("driver is null\n");
4716 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
4718 memset(&msg
, 0, sizeof(struct host_if_msg
));
4720 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
4723 pstrPowerMgmtParam
->enabled
= bIsEnabled
;
4724 pstrPowerMgmtParam
->timeout
= u32Timeout
;
4726 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4728 PRINT_ER("wilc_mq_send fail\n");
4732 s32
host_int_setup_multicast_filter(struct host_if_drv
*hif_drv
,
4737 struct host_if_msg msg
;
4738 struct set_multicast
*pstrMulticastFilterParam
= &msg
.body
.multicast_info
;
4741 PRINT_ER("driver is null\n");
4745 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
4747 memset(&msg
, 0, sizeof(struct host_if_msg
));
4749 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
4752 pstrMulticastFilterParam
->enabled
= bIsEnabled
;
4753 pstrMulticastFilterParam
->cnt
= u32count
;
4755 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4757 PRINT_ER("wilc_mq_send fail\n");
4761 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
4763 struct join_bss_param
*pNewJoinBssParam
= NULL
;
4772 u8 pcipherTotalCount
= 0;
4773 u8 authTotalCount
= 0;
4776 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
4777 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
4779 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
4780 if (pNewJoinBssParam
) {
4781 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
4782 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
4783 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
4784 memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
4785 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
4786 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->u8SsidLen
;
4787 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
4788 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
4790 while (index
< u16IEsLen
) {
4791 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
4792 suppRatesNo
= pu8IEs
[index
+ 1];
4793 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
4796 for (i
= 0; i
< suppRatesNo
; i
++)
4797 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
4799 index
+= suppRatesNo
;
4801 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
4802 extSuppRatesNo
= pu8IEs
[index
+ 1];
4803 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
4804 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
4806 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
4808 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
4809 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
4811 index
+= extSuppRatesNo
;
4813 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
4814 pNewJoinBssParam
->ht_capable
= true;
4815 index
+= pu8IEs
[index
+ 1] + 2;
4817 } else if ((pu8IEs
[index
] == WMM_IE
) &&
4818 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
4819 (pu8IEs
[index
+ 4] == 0xF2) &&
4820 (pu8IEs
[index
+ 5] == 0x02) &&
4821 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
4822 (pu8IEs
[index
+ 7] == 0x01)) {
4823 pNewJoinBssParam
->wmm_cap
= true;
4825 if (pu8IEs
[index
+ 8] & BIT(7))
4826 pNewJoinBssParam
->uapsd_cap
= true;
4827 index
+= pu8IEs
[index
+ 1] + 2;
4829 } else if ((pu8IEs
[index
] == P2P_IE
) &&
4830 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
4831 (pu8IEs
[index
+ 4] == 0x9a) &&
4832 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
4835 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
4836 pNewJoinBssParam
->noa_enabled
= 1;
4837 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
4839 if (pu8IEs
[index
+ 10] & BIT(7)) {
4840 pNewJoinBssParam
->opp_enabled
= 1;
4841 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
4843 pNewJoinBssParam
->opp_enabled
= 0;
4846 PRINT_D(GENERIC_DBG
, "P2P Dump\n");
4847 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
4848 PRINT_D(GENERIC_DBG
, " %x\n", pu8IEs
[index
+ 9 + i
]);
4850 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
4851 u16P2P_count
= index
+ 12;
4853 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
4856 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
4859 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
4861 index
+= pu8IEs
[index
+ 1] + 2;
4864 } else if ((pu8IEs
[index
] == RSN_IE
) ||
4865 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
4866 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
4867 (pu8IEs
[index
+ 5] == 0x01))) {
4868 u16 rsnIndex
= index
;
4870 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
4871 pNewJoinBssParam
->mode_802_11i
= 2;
4873 if (pNewJoinBssParam
->mode_802_11i
== 0)
4874 pNewJoinBssParam
->mode_802_11i
= 1;
4879 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4881 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4882 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4885 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4886 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4888 pcipherTotalCount
+= pcipherCount
;
4889 rsnIndex
+= jumpOffset
;
4891 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4893 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4896 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4897 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4899 authTotalCount
+= authCount
;
4900 rsnIndex
+= jumpOffset
;
4902 if (pu8IEs
[index
] == RSN_IE
) {
4903 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4904 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4907 pNewJoinBssParam
->rsn_found
= true;
4908 index
+= pu8IEs
[index
+ 1] + 2;
4911 index
+= pu8IEs
[index
+ 1] + 2;
4915 return (void *)pNewJoinBssParam
;
4918 void host_int_freeJoinParams(void *pJoinParams
)
4920 if ((struct bss_param
*)pJoinParams
)
4921 kfree((struct bss_param
*)pJoinParams
);
4923 PRINT_ER("Unable to FREE null pointer\n");
4926 s32
host_int_delBASession(struct host_if_drv
*hif_drv
, char *pBSSID
, char TID
)
4929 struct host_if_msg msg
;
4930 struct ba_session_info
*pBASessionInfo
= &msg
.body
.session_info
;
4933 PRINT_ER("driver is null\n");
4937 memset(&msg
, 0, sizeof(struct host_if_msg
));
4939 msg
.id
= HOST_IF_MSG_DEL_BA_SESSION
;
4941 memcpy(pBASessionInfo
->bssid
, pBSSID
, ETH_ALEN
);
4942 pBASessionInfo
->tid
= TID
;
4945 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4947 PRINT_ER("wilc_mq_send fail\n");
4949 down(&hif_sema_wait_response
);
4954 s32
host_int_del_All_Rx_BASession(struct host_if_drv
*hif_drv
,
4959 struct host_if_msg msg
;
4960 struct ba_session_info
*pBASessionInfo
= &msg
.body
.session_info
;
4963 PRINT_ER("driver is null\n");
4967 memset(&msg
, 0, sizeof(struct host_if_msg
));
4969 msg
.id
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
4971 memcpy(pBASessionInfo
->bssid
, pBSSID
, ETH_ALEN
);
4972 pBASessionInfo
->tid
= TID
;
4975 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4977 PRINT_ER("wilc_mq_send fail\n");
4979 down(&hif_sema_wait_response
);
4984 s32
host_int_setup_ipaddress(struct host_if_drv
*hif_drv
, u8
*u16ipadd
, u8 idx
)
4987 struct host_if_msg msg
;
4992 PRINT_ER("driver is null\n");
4996 memset(&msg
, 0, sizeof(struct host_if_msg
));
4998 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
5000 msg
.body
.ip_info
.ip_addr
= u16ipadd
;
5002 msg
.body
.ip_info
.idx
= idx
;
5004 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
5006 PRINT_ER("wilc_mq_send fail\n");
5011 s32
host_int_get_ipaddress(struct host_if_drv
*hif_drv
, u8
*u16ipadd
, u8 idx
)
5014 struct host_if_msg msg
;
5017 PRINT_ER("driver is null\n");
5021 memset(&msg
, 0, sizeof(struct host_if_msg
));
5023 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
5025 msg
.body
.ip_info
.ip_addr
= u16ipadd
;
5027 msg
.body
.ip_info
.idx
= idx
;
5029 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
5031 PRINT_ER("wilc_mq_send fail\n");