1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
13 #define HOST_IF_MSG_SCAN 0
14 #define HOST_IF_MSG_CONNECT 1
15 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16 #define HOST_IF_MSG_KEY 3
17 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19 #define HOST_IF_MSG_CFG_PARAMS 6
20 #define HOST_IF_MSG_SET_CHANNEL 7
21 #define HOST_IF_MSG_DISCONNECT 8
22 #define HOST_IF_MSG_GET_RSSI 9
23 #define HOST_IF_MSG_GET_CHNL 10
24 #define HOST_IF_MSG_ADD_BEACON 11
25 #define HOST_IF_MSG_DEL_BEACON 12
26 #define HOST_IF_MSG_ADD_STATION 13
27 #define HOST_IF_MSG_DEL_STATION 14
28 #define HOST_IF_MSG_EDIT_STATION 15
29 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
30 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
31 #define HOST_IF_MSG_POWER_MGMT 18
32 #define HOST_IF_MSG_GET_INACTIVETIME 19
33 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
34 #define HOST_IF_MSG_REGISTER_FRAME 21
35 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
36 #define HOST_IF_MSG_GET_LINKSPEED 23
37 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
38 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
39 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
40 #define HOST_IF_MSG_SET_OPERATION_MODE 27
41 #define HOST_IF_MSG_SET_IPADDRESS 28
42 #define HOST_IF_MSG_GET_IPADDRESS 29
43 #define HOST_IF_MSG_FLUSH_CONNECT 30
44 #define HOST_IF_MSG_GET_STATISTICS 31
45 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
46 #define HOST_IF_MSG_DEL_BA_SESSION 34
47 #define HOST_IF_MSG_Q_IDLE 35
48 #define HOST_IF_MSG_DEL_ALL_STA 36
49 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
50 #define HOST_IF_MSG_EXIT 100
52 #define HOST_IF_SCAN_TIMEOUT 4000
53 #define HOST_IF_CONNECT_TIMEOUT 9500
55 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
56 #define BA_SESSION_DEFAULT_TIMEOUT 1000
57 #define BLOCK_ACK_REQ_SIZE 0x14
58 #define FALSE_FRMWR_CHANNEL 100
60 struct cfg_param_attr
{
61 struct cfg_param_val cfg_attr_info
;
64 struct host_if_wpa_attr
{
74 struct host_if_wep_attr
{
79 enum AUTHTYPE auth_type
;
82 union host_if_key_attr
{
83 struct host_if_wep_attr wep
;
84 struct host_if_wpa_attr wpa
;
85 struct host_if_pmkid_attr pmkid
;
91 union host_if_key_attr attr
;
101 wilc_scan_result result
;
103 struct hidden_network hidden_network
;
106 struct connect_attr
{
113 wilc_connect_result result
;
115 enum AUTHTYPE auth_type
;
120 struct rcvd_async_info
{
125 struct channel_attr
{
138 struct set_multicast
{
144 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
149 u8 mac_addr
[ETH_ALEN
];
152 struct power_mgmt_param
{
162 struct sta_inactive_t
{
167 struct scan_attr scan_info
;
168 struct connect_attr con_info
;
169 struct rcvd_net_info net_info
;
170 struct rcvd_async_info async_info
;
171 struct key_attr key_info
;
172 struct cfg_param_attr cfg_info
;
173 struct channel_attr channel_info
;
174 struct beacon_attr beacon_info
;
175 struct add_sta_param add_sta_info
;
176 struct del_sta del_sta_info
;
177 struct add_sta_param edit_sta_info
;
178 struct power_mgmt_param pwr_mgmt_info
;
179 struct sta_inactive_t mac_info
;
180 struct set_ip_addr ip_info
;
181 struct drv_handler drv
;
182 struct set_multicast multicast_info
;
184 struct set_mac_addr set_mac_info
;
185 struct get_mac_addr get_mac_info
;
186 struct ba_session_info session_info
;
187 struct remain_ch remain_on_ch
;
188 struct reg_frame reg_frame
;
190 struct del_all_sta del_all_sta_info
;
195 union message_body body
;
196 struct wilc_vif
*vif
;
199 struct join_bss_param
{
205 char ssid
[MAX_SSID_LEN
];
207 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
214 u8 rsn_pcip_policy
[3];
215 u8 rsn_auth_policy
[3];
228 struct host_if_drv
*terminated_handle
;
229 bool wilc_optaining_ip
;
230 static u8 P2P_LISTEN_STATE
;
231 static struct task_struct
*hif_thread_handler
;
232 static WILC_MsgQueueHandle hif_msg_q
;
233 static struct semaphore hif_sema_thread
;
234 static struct semaphore hif_sema_driver
;
235 static struct semaphore hif_sema_wait_response
;
236 static struct semaphore hif_sema_deinit
;
237 static struct timer_list periodic_rssi
;
239 u8 wilc_multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
241 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
243 static bool scan_while_connected
;
246 static s8 link_speed
;
248 static u8 set_ip
[2][4];
249 static u8 get_ip
[2][4];
250 static u32 inactive_time
;
251 static u8 del_beacon
;
252 static u32 clients_count
;
255 static u8
*info_element
;
258 static u32 join_req_size
;
259 static u32 info_element_size
;
260 static struct wilc_vif
*join_req_vif
;
261 #define REAL_JOIN_REQ 0
262 #define FLUSHED_JOIN_REQ 1
263 #define FLUSHED_BYTE_POS 79
265 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
);
267 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
268 * special purpose in wilc device, so we add 1 to the index to starts from 1.
269 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
271 int wilc_get_vif_idx(struct wilc_vif
*vif
)
273 return vif
->u8IfIdx
+ 1;
276 /* We need to minus 1 from idx which is from wilc device to get real index
277 * of wilc->vif[], because we add 1 when pass to wilc device in the function
279 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
281 static struct wilc_vif
*wilc_get_vif_from_idx(struct wilc
*wilc
, int idx
)
285 if (index
< 0 || index
>= NUM_CONCURRENT_IFC
)
288 return wilc
->vif
[index
];
291 static s32
handle_set_channel(struct wilc_vif
*vif
,
292 struct channel_attr
*hif_set_ch
)
297 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
299 wid
.val
= (char *)&hif_set_ch
->set_ch
;
300 wid
.size
= sizeof(char);
302 PRINT_D(HOSTINF_DBG
, "Setting channel\n");
304 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
305 wilc_get_vif_idx(vif
));
308 PRINT_ER("Failed to set channel\n");
315 static s32
handle_set_wfi_drv_handler(struct wilc_vif
*vif
,
316 struct drv_handler
*hif_drv_handler
)
321 wid
.id
= (u16
)WID_SET_DRV_HANDLER
;
323 wid
.val
= (s8
*)&hif_drv_handler
->handler
;
324 wid
.size
= sizeof(u32
);
326 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
327 hif_drv_handler
->handler
);
329 if (!hif_drv_handler
->handler
)
330 up(&hif_sema_driver
);
333 PRINT_ER("Failed to set driver handler\n");
340 static s32
handle_set_operation_mode(struct wilc_vif
*vif
,
341 struct op_mode
*hif_op_mode
)
346 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
348 wid
.val
= (s8
*)&hif_op_mode
->mode
;
349 wid
.size
= sizeof(u32
);
351 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
352 wilc_get_vif_idx(vif
));
354 if ((hif_op_mode
->mode
) == IDLE_MODE
)
355 up(&hif_sema_driver
);
358 PRINT_ER("Failed to set driver handler\n");
365 static s32
host_int_get_ipaddress(struct wilc_vif
*vif
,
366 struct host_if_drv
*hif_drv
,
367 u8
*u16ipadd
, u8 idx
);
369 static s32
handle_set_ip_address(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
373 char firmware_ip_addr
[4] = {0};
374 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
376 if (ip_addr
[0] < 192)
379 PRINT_INFO(HOSTINF_DBG
, "Indx = %d, Handling set IP = %pI4\n",
382 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
384 wid
.id
= (u16
)WID_IP_ADDRESS
;
386 wid
.val
= (u8
*)ip_addr
;
389 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
390 wilc_get_vif_idx(vif
));
392 host_int_get_ipaddress(vif
, hif_drv
, firmware_ip_addr
, idx
);
395 PRINT_ER("Failed to set IP address\n");
399 PRINT_INFO(HOSTINF_DBG
, "IP address set\n");
404 static s32
handle_get_ip_address(struct wilc_vif
*vif
, u8 idx
)
409 wid
.id
= (u16
)WID_IP_ADDRESS
;
411 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
414 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
415 wilc_get_vif_idx(vif
));
417 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", wid
.val
);
419 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
423 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
424 wilc_setup_ipaddress(vif
, set_ip
[idx
], idx
);
427 PRINT_ER("Failed to get IP address\n");
431 PRINT_INFO(HOSTINF_DBG
, "IP address retrieved:: u8IfIdx = %d\n", idx
);
432 PRINT_INFO(HOSTINF_DBG
, "%pI4\n", get_ip
[idx
]);
433 PRINT_INFO(HOSTINF_DBG
, "\n");
438 static s32
handle_set_mac_address(struct wilc_vif
*vif
,
439 struct set_mac_addr
*set_mac_addr
)
443 u8
*mac_buf
= kmalloc(ETH_ALEN
, GFP_KERNEL
);
446 PRINT_ER("No buffer to send mac address\n");
449 memcpy(mac_buf
, set_mac_addr
->mac_addr
, ETH_ALEN
);
451 wid
.id
= (u16
)WID_MAC_ADDR
;
455 PRINT_D(GENERIC_DBG
, "mac addr = :%pM\n", wid
.val
);
457 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
458 wilc_get_vif_idx(vif
));
460 PRINT_ER("Failed to set mac address\n");
468 static s32
handle_get_mac_address(struct wilc_vif
*vif
,
469 struct get_mac_addr
*get_mac_addr
)
474 wid
.id
= (u16
)WID_MAC_ADDR
;
476 wid
.val
= get_mac_addr
->mac_addr
;
479 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
480 wilc_get_vif_idx(vif
));
483 PRINT_ER("Failed to get mac address\n");
486 up(&hif_sema_wait_response
);
491 static s32
handle_cfg_param(struct wilc_vif
*vif
,
492 struct cfg_param_attr
*cfg_param_attr
)
495 struct wid wid_list
[32];
496 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
499 down(&hif_drv
->sem_cfg_values
);
501 PRINT_D(HOSTINF_DBG
, "Setting CFG params\n");
503 if (cfg_param_attr
->cfg_attr_info
.flag
& BSS_TYPE
) {
504 if (cfg_param_attr
->cfg_attr_info
.bss_type
< 6) {
505 wid_list
[wid_cnt
].id
= WID_BSS_TYPE
;
506 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.bss_type
;
507 wid_list
[wid_cnt
].type
= WID_CHAR
;
508 wid_list
[wid_cnt
].size
= sizeof(char);
509 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->cfg_attr_info
.bss_type
;
511 PRINT_ER("check value 6 over\n");
517 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTH_TYPE
) {
518 if (cfg_param_attr
->cfg_attr_info
.auth_type
== 1 ||
519 cfg_param_attr
->cfg_attr_info
.auth_type
== 2 ||
520 cfg_param_attr
->cfg_attr_info
.auth_type
== 5) {
521 wid_list
[wid_cnt
].id
= WID_AUTH_TYPE
;
522 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_type
;
523 wid_list
[wid_cnt
].type
= WID_CHAR
;
524 wid_list
[wid_cnt
].size
= sizeof(char);
525 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->cfg_attr_info
.auth_type
;
527 PRINT_ER("Impossible value \n");
533 if (cfg_param_attr
->cfg_attr_info
.flag
& AUTHEN_TIMEOUT
) {
534 if (cfg_param_attr
->cfg_attr_info
.auth_timeout
> 0 &&
535 cfg_param_attr
->cfg_attr_info
.auth_timeout
< 65536) {
536 wid_list
[wid_cnt
].id
= WID_AUTH_TIMEOUT
;
537 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.auth_timeout
;
538 wid_list
[wid_cnt
].type
= WID_SHORT
;
539 wid_list
[wid_cnt
].size
= sizeof(u16
);
540 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->cfg_attr_info
.auth_timeout
;
542 PRINT_ER("Range(1 ~ 65535) over\n");
548 if (cfg_param_attr
->cfg_attr_info
.flag
& POWER_MANAGEMENT
) {
549 if (cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
< 5) {
550 wid_list
[wid_cnt
].id
= WID_POWER_MANAGEMENT
;
551 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
552 wid_list
[wid_cnt
].type
= WID_CHAR
;
553 wid_list
[wid_cnt
].size
= sizeof(char);
554 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->cfg_attr_info
.power_mgmt_mode
;
556 PRINT_ER("Invalide power mode\n");
562 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_SHORT
) {
563 if (cfg_param_attr
->cfg_attr_info
.short_retry_limit
> 0 &&
564 cfg_param_attr
->cfg_attr_info
.short_retry_limit
< 256) {
565 wid_list
[wid_cnt
].id
= WID_SHORT_RETRY_LIMIT
;
566 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
567 wid_list
[wid_cnt
].type
= WID_SHORT
;
568 wid_list
[wid_cnt
].size
= sizeof(u16
);
569 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->cfg_attr_info
.short_retry_limit
;
571 PRINT_ER("Range(1~256) over\n");
577 if (cfg_param_attr
->cfg_attr_info
.flag
& RETRY_LONG
) {
578 if (cfg_param_attr
->cfg_attr_info
.long_retry_limit
> 0 &&
579 cfg_param_attr
->cfg_attr_info
.long_retry_limit
< 256) {
580 wid_list
[wid_cnt
].id
= WID_LONG_RETRY_LIMIT
;
581 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
582 wid_list
[wid_cnt
].type
= WID_SHORT
;
583 wid_list
[wid_cnt
].size
= sizeof(u16
);
584 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->cfg_attr_info
.long_retry_limit
;
586 PRINT_ER("Range(1~256) over\n");
592 if (cfg_param_attr
->cfg_attr_info
.flag
& FRAG_THRESHOLD
) {
593 if (cfg_param_attr
->cfg_attr_info
.frag_threshold
> 255 &&
594 cfg_param_attr
->cfg_attr_info
.frag_threshold
< 7937) {
595 wid_list
[wid_cnt
].id
= WID_FRAG_THRESHOLD
;
596 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.frag_threshold
;
597 wid_list
[wid_cnt
].type
= WID_SHORT
;
598 wid_list
[wid_cnt
].size
= sizeof(u16
);
599 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->cfg_attr_info
.frag_threshold
;
601 PRINT_ER("Threshold Range fail\n");
607 if (cfg_param_attr
->cfg_attr_info
.flag
& RTS_THRESHOLD
) {
608 if (cfg_param_attr
->cfg_attr_info
.rts_threshold
> 255 &&
609 cfg_param_attr
->cfg_attr_info
.rts_threshold
< 65536) {
610 wid_list
[wid_cnt
].id
= WID_RTS_THRESHOLD
;
611 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.rts_threshold
;
612 wid_list
[wid_cnt
].type
= WID_SHORT
;
613 wid_list
[wid_cnt
].size
= sizeof(u16
);
614 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->cfg_attr_info
.rts_threshold
;
616 PRINT_ER("Threshold Range fail\n");
622 if (cfg_param_attr
->cfg_attr_info
.flag
& PREAMBLE
) {
623 if (cfg_param_attr
->cfg_attr_info
.preamble_type
< 3) {
624 wid_list
[wid_cnt
].id
= WID_PREAMBLE
;
625 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.preamble_type
;
626 wid_list
[wid_cnt
].type
= WID_CHAR
;
627 wid_list
[wid_cnt
].size
= sizeof(char);
628 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->cfg_attr_info
.preamble_type
;
630 PRINT_ER("Preamle Range(0~2) over\n");
636 if (cfg_param_attr
->cfg_attr_info
.flag
& SHORT_SLOT_ALLOWED
) {
637 if (cfg_param_attr
->cfg_attr_info
.short_slot_allowed
< 2) {
638 wid_list
[wid_cnt
].id
= WID_SHORT_SLOT_ALLOWED
;
639 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
640 wid_list
[wid_cnt
].type
= WID_CHAR
;
641 wid_list
[wid_cnt
].size
= sizeof(char);
642 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->cfg_attr_info
.short_slot_allowed
;
644 PRINT_ER("Short slot(2) over\n");
650 if (cfg_param_attr
->cfg_attr_info
.flag
& TXOP_PROT_DISABLE
) {
651 if (cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
< 2) {
652 wid_list
[wid_cnt
].id
= WID_11N_TXOP_PROT_DISABLE
;
653 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
654 wid_list
[wid_cnt
].type
= WID_CHAR
;
655 wid_list
[wid_cnt
].size
= sizeof(char);
656 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->cfg_attr_info
.txop_prot_disabled
;
658 PRINT_ER("TXOP prot disable\n");
664 if (cfg_param_attr
->cfg_attr_info
.flag
& BEACON_INTERVAL
) {
665 if (cfg_param_attr
->cfg_attr_info
.beacon_interval
> 0 &&
666 cfg_param_attr
->cfg_attr_info
.beacon_interval
< 65536) {
667 wid_list
[wid_cnt
].id
= WID_BEACON_INTERVAL
;
668 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.beacon_interval
;
669 wid_list
[wid_cnt
].type
= WID_SHORT
;
670 wid_list
[wid_cnt
].size
= sizeof(u16
);
671 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->cfg_attr_info
.beacon_interval
;
673 PRINT_ER("Beacon interval(1~65535) fail\n");
679 if (cfg_param_attr
->cfg_attr_info
.flag
& DTIM_PERIOD
) {
680 if (cfg_param_attr
->cfg_attr_info
.dtim_period
> 0 &&
681 cfg_param_attr
->cfg_attr_info
.dtim_period
< 256) {
682 wid_list
[wid_cnt
].id
= WID_DTIM_PERIOD
;
683 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.dtim_period
;
684 wid_list
[wid_cnt
].type
= WID_CHAR
;
685 wid_list
[wid_cnt
].size
= sizeof(char);
686 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->cfg_attr_info
.dtim_period
;
688 PRINT_ER("DTIM range(1~255) fail\n");
694 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY
) {
695 if (cfg_param_attr
->cfg_attr_info
.site_survey_enabled
< 3) {
696 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY
;
697 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
698 wid_list
[wid_cnt
].type
= WID_CHAR
;
699 wid_list
[wid_cnt
].size
= sizeof(char);
700 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->cfg_attr_info
.site_survey_enabled
;
702 PRINT_ER("Site survey disable\n");
708 if (cfg_param_attr
->cfg_attr_info
.flag
& SITE_SURVEY_SCAN_TIME
) {
709 if (cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
> 0 &&
710 cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
< 65536) {
711 wid_list
[wid_cnt
].id
= WID_SITE_SURVEY_SCAN_TIME
;
712 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
713 wid_list
[wid_cnt
].type
= WID_SHORT
;
714 wid_list
[wid_cnt
].size
= sizeof(u16
);
715 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->cfg_attr_info
.site_survey_scan_time
;
717 PRINT_ER("Site survey scan time(1~65535) over\n");
723 if (cfg_param_attr
->cfg_attr_info
.flag
& ACTIVE_SCANTIME
) {
724 if (cfg_param_attr
->cfg_attr_info
.active_scan_time
> 0 &&
725 cfg_param_attr
->cfg_attr_info
.active_scan_time
< 65536) {
726 wid_list
[wid_cnt
].id
= WID_ACTIVE_SCAN_TIME
;
727 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.active_scan_time
;
728 wid_list
[wid_cnt
].type
= WID_SHORT
;
729 wid_list
[wid_cnt
].size
= sizeof(u16
);
730 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->cfg_attr_info
.active_scan_time
;
732 PRINT_ER("Active scan time(1~65535) over\n");
738 if (cfg_param_attr
->cfg_attr_info
.flag
& PASSIVE_SCANTIME
) {
739 if (cfg_param_attr
->cfg_attr_info
.passive_scan_time
> 0 &&
740 cfg_param_attr
->cfg_attr_info
.passive_scan_time
< 65536) {
741 wid_list
[wid_cnt
].id
= WID_PASSIVE_SCAN_TIME
;
742 wid_list
[wid_cnt
].val
= (s8
*)&cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
743 wid_list
[wid_cnt
].type
= WID_SHORT
;
744 wid_list
[wid_cnt
].size
= sizeof(u16
);
745 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->cfg_attr_info
.passive_scan_time
;
747 PRINT_ER("Passive scan time(1~65535) over\n");
753 if (cfg_param_attr
->cfg_attr_info
.flag
& CURRENT_TX_RATE
) {
754 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->cfg_attr_info
.curr_tx_rate
;
756 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
757 || curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
758 || curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
759 || curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
760 || curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
761 || curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
|| curr_tx_rate
== MBPS_54
) {
762 wid_list
[wid_cnt
].id
= WID_CURRENT_TX_RATE
;
763 wid_list
[wid_cnt
].val
= (s8
*)&curr_tx_rate
;
764 wid_list
[wid_cnt
].type
= WID_SHORT
;
765 wid_list
[wid_cnt
].size
= sizeof(u16
);
766 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
768 PRINT_ER("out of TX rate\n");
775 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, wid_list
,
776 wid_cnt
, wilc_get_vif_idx(vif
));
779 PRINT_ER("Error in setting CFG params\n");
782 up(&hif_drv
->sem_cfg_values
);
786 static void Handle_wait_msg_q_empty(void)
788 wilc_initialized
= 0;
789 up(&hif_sema_wait_response
);
792 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
793 enum scan_event enuEvent
);
795 static s32
Handle_Scan(struct wilc_vif
*vif
,
796 struct scan_attr
*pstrHostIFscanAttr
)
799 struct wid strWIDList
[5];
800 u32 u32WidsCount
= 0;
804 u8
*pu8HdnNtwrksWidVal
= NULL
;
805 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
807 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
808 PRINT_D(HOSTINF_DBG
, "Scanning: In [%d] state\n", hif_drv
->hif_state
);
810 hif_drv
->usr_scan_req
.scan_result
= pstrHostIFscanAttr
->result
;
811 hif_drv
->usr_scan_req
.arg
= pstrHostIFscanAttr
->arg
;
813 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
814 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
815 PRINT_D(GENERIC_DBG
, "Don't scan already in [%d] state\n",
817 PRINT_ER("Already scan\n");
822 if (wilc_optaining_ip
|| wilc_connecting
) {
823 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
824 PRINT_ER("Don't do obss scan\n");
829 PRINT_D(HOSTINF_DBG
, "Setting SCAN params\n");
831 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
833 strWIDList
[u32WidsCount
].id
= (u16
)WID_SSID_PROBE_REQ
;
834 strWIDList
[u32WidsCount
].type
= WID_STR
;
836 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.u8ssidnum
; i
++)
837 valuesize
+= ((pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
) + 1);
838 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
839 strWIDList
[u32WidsCount
].val
= pu8HdnNtwrksWidVal
;
840 if (strWIDList
[u32WidsCount
].val
) {
841 pu8Buffer
= strWIDList
[u32WidsCount
].val
;
843 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.u8ssidnum
;
845 PRINT_D(HOSTINF_DBG
, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr
->hidden_network
.u8ssidnum
);
847 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.u8ssidnum
; i
++) {
848 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
849 memcpy(pu8Buffer
, pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].pu8ssid
, pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
);
850 pu8Buffer
+= pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
[i
].u8ssidlen
;
853 strWIDList
[u32WidsCount
].size
= (s32
)(valuesize
+ 1);
858 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_PROBE
;
859 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
860 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ies
;
861 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ies_len
;
865 strWIDList
[u32WidsCount
].id
= WID_SCAN_TYPE
;
866 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
867 strWIDList
[u32WidsCount
].size
= sizeof(char);
868 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->type
;
871 strWIDList
[u32WidsCount
].id
= WID_SCAN_CHANNEL_LIST
;
872 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
874 if (pstrHostIFscanAttr
->ch_freq_list
&&
875 pstrHostIFscanAttr
->ch_list_len
> 0) {
878 for (i
= 0; i
< pstrHostIFscanAttr
->ch_list_len
; i
++) {
879 if (pstrHostIFscanAttr
->ch_freq_list
[i
] > 0)
880 pstrHostIFscanAttr
->ch_freq_list
[i
] = pstrHostIFscanAttr
->ch_freq_list
[i
] - 1;
884 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ch_freq_list
;
885 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ch_list_len
;
888 strWIDList
[u32WidsCount
].id
= WID_START_SCAN_REQ
;
889 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
890 strWIDList
[u32WidsCount
].size
= sizeof(char);
891 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->src
;
894 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
895 scan_while_connected
= true;
896 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
897 scan_while_connected
= false;
899 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, strWIDList
,
901 wilc_get_vif_idx(vif
));
904 PRINT_ER("Failed to send scan paramters config packet\n");
906 PRINT_D(HOSTINF_DBG
, "Successfully sent SCAN params config packet\n");
910 del_timer(&hif_drv
->scan_timer
);
911 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
914 kfree(pstrHostIFscanAttr
->ch_freq_list
);
915 pstrHostIFscanAttr
->ch_freq_list
= NULL
;
917 kfree(pstrHostIFscanAttr
->ies
);
918 pstrHostIFscanAttr
->ies
= NULL
;
919 kfree(pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
);
920 pstrHostIFscanAttr
->hidden_network
.pstrHiddenNetworkInfo
= NULL
;
922 kfree(pu8HdnNtwrksWidVal
);
927 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
928 enum scan_event enuEvent
)
931 u8 u8abort_running_scan
;
933 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
935 PRINT_D(HOSTINF_DBG
, "in Handle_ScanDone()\n");
937 if (enuEvent
== SCAN_EVENT_ABORTED
) {
938 PRINT_D(GENERIC_DBG
, "Abort running scan\n");
939 u8abort_running_scan
= 1;
940 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
942 wid
.val
= (s8
*)&u8abort_running_scan
;
943 wid
.size
= sizeof(char);
945 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
946 wilc_get_vif_idx(vif
));
949 PRINT_ER("Failed to set abort running scan\n");
955 PRINT_ER("Driver handler is NULL\n");
959 if (hif_drv
->usr_scan_req
.scan_result
) {
960 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
961 hif_drv
->usr_scan_req
.arg
, NULL
);
962 hif_drv
->usr_scan_req
.scan_result
= NULL
;
968 u8 wilc_connected_ssid
[6] = {0};
969 static s32
Handle_Connect(struct wilc_vif
*vif
,
970 struct connect_attr
*pstrHostIFconnectAttr
)
973 struct wid strWIDList
[8];
974 u32 u32WidsCount
= 0, dummyval
= 0;
975 u8
*pu8CurrByte
= NULL
;
976 struct join_bss_param
*ptstrJoinBssParam
;
977 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
979 PRINT_D(GENERIC_DBG
, "Handling connect request\n");
981 if (memcmp(pstrHostIFconnectAttr
->bssid
, wilc_connected_ssid
, ETH_ALEN
) == 0) {
983 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
987 PRINT_INFO(HOSTINF_DBG
, "Saving connection parameters in global structure\n");
989 ptstrJoinBssParam
= (struct join_bss_param
*)pstrHostIFconnectAttr
->params
;
990 if (!ptstrJoinBssParam
) {
991 PRINT_ER("Required BSSID not found\n");
996 if (pstrHostIFconnectAttr
->bssid
) {
997 hif_drv
->usr_conn_req
.pu8bssid
= kmalloc(6, GFP_KERNEL
);
998 memcpy(hif_drv
->usr_conn_req
.pu8bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1001 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
1002 if (pstrHostIFconnectAttr
->ssid
) {
1003 hif_drv
->usr_conn_req
.pu8ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
1004 memcpy(hif_drv
->usr_conn_req
.pu8ssid
,
1005 pstrHostIFconnectAttr
->ssid
,
1006 pstrHostIFconnectAttr
->ssid_len
);
1007 hif_drv
->usr_conn_req
.pu8ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1010 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
1011 if (pstrHostIFconnectAttr
->ies
) {
1012 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1013 memcpy(hif_drv
->usr_conn_req
.ies
,
1014 pstrHostIFconnectAttr
->ies
,
1015 pstrHostIFconnectAttr
->ies_len
);
1018 hif_drv
->usr_conn_req
.u8security
= pstrHostIFconnectAttr
->security
;
1019 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
1020 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
1021 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
1023 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
1024 strWIDList
[u32WidsCount
].type
= WID_INT
;
1025 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1026 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1029 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
1030 strWIDList
[u32WidsCount
].type
= WID_INT
;
1031 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1032 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1035 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
1036 strWIDList
[u32WidsCount
].type
= WID_INT
;
1037 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1038 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1042 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1043 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1044 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
1045 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
1048 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1049 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
1050 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
1051 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
1055 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1056 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1057 strWIDList
[u32WidsCount
].size
= sizeof(char);
1058 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.u8security
;
1061 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1062 mode_11i
= hif_drv
->usr_conn_req
.u8security
;
1064 PRINT_INFO(HOSTINF_DBG
, "Encrypt Mode = %x\n", hif_drv
->usr_conn_req
.u8security
);
1066 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1067 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1068 strWIDList
[u32WidsCount
].size
= sizeof(char);
1069 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
1072 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1073 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
1075 PRINT_INFO(HOSTINF_DBG
, "Authentication Type = %x\n",
1076 hif_drv
->usr_conn_req
.auth_type
);
1077 PRINT_D(HOSTINF_DBG
, "Connecting to network of SSID %s on channel %d\n",
1078 hif_drv
->usr_conn_req
.pu8ssid
, pstrHostIFconnectAttr
->ch
);
1080 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1081 strWIDList
[u32WidsCount
].type
= WID_STR
;
1082 strWIDList
[u32WidsCount
].size
= 112;
1083 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
1085 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1086 join_req_size
= strWIDList
[u32WidsCount
].size
;
1087 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
1089 if (!strWIDList
[u32WidsCount
].val
) {
1094 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1096 if (pstrHostIFconnectAttr
->ssid
) {
1097 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
1098 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1100 pu8CurrByte
+= MAX_SSID_LEN
;
1101 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1103 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
1104 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1106 PRINT_ER("Channel out of range\n");
1107 *(pu8CurrByte
++) = 0xFF;
1109 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1110 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1111 PRINT_D(HOSTINF_DBG
, "* Cap Info %0x*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1113 if (pstrHostIFconnectAttr
->bssid
)
1114 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1117 if (pstrHostIFconnectAttr
->bssid
)
1118 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1121 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1122 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1123 PRINT_D(HOSTINF_DBG
, "* Beacon Period %d*\n", (*(pu8CurrByte
- 2) | ((*(pu8CurrByte
- 1)) << 8)));
1124 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1125 PRINT_D(HOSTINF_DBG
, "* DTIM Period %d*\n", (*(pu8CurrByte
- 1)));
1127 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1128 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1130 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1131 PRINT_D(HOSTINF_DBG
, "* wmm cap%d*\n", (*(pu8CurrByte
- 1)));
1132 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1134 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1135 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1137 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1138 PRINT_D(HOSTINF_DBG
, "* rsn found %d*\n", *(pu8CurrByte
- 1));
1139 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1140 PRINT_D(HOSTINF_DBG
, "* rsn group policy %0x*\n", (*(pu8CurrByte
- 1)));
1141 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1142 PRINT_D(HOSTINF_DBG
, "* mode_802_11i %d*\n", (*(pu8CurrByte
- 1)));
1144 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1145 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1147 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1148 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1150 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1151 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1153 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1154 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1156 if (ptstrJoinBssParam
->noa_enabled
) {
1157 PRINT_D(HOSTINF_DBG
, "NOA present\n");
1159 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1160 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1161 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1162 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1164 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1165 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1167 if (ptstrJoinBssParam
->opp_enabled
)
1168 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1170 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1172 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1173 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1175 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1176 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1178 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1179 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1181 PRINT_D(HOSTINF_DBG
, "NOA not present\n");
1183 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1186 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1187 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1191 PRINT_D(GENERIC_DBG
, "send HOST_IF_WAITING_CONN_RESP\n");
1193 if (pstrHostIFconnectAttr
->bssid
) {
1194 memcpy(wilc_connected_ssid
,
1195 pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1196 PRINT_D(GENERIC_DBG
, "save Bssid = %pM\n",
1197 pstrHostIFconnectAttr
->bssid
);
1198 PRINT_D(GENERIC_DBG
, "save bssid = %pM\n", wilc_connected_ssid
);
1201 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, strWIDList
,
1203 wilc_get_vif_idx(vif
));
1205 PRINT_ER("failed to send config packet\n");
1209 PRINT_D(GENERIC_DBG
, "set HOST_IF_WAITING_CONN_RESP\n");
1210 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1215 tstrConnectInfo strConnectInfo
;
1217 del_timer(&hif_drv
->connect_timer
);
1219 PRINT_D(HOSTINF_DBG
, "could not start wilc_connecting to the required network\n");
1221 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1223 if (pstrHostIFconnectAttr
->result
) {
1224 if (pstrHostIFconnectAttr
->bssid
)
1225 memcpy(strConnectInfo
.au8bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1227 if (pstrHostIFconnectAttr
->ies
) {
1228 strConnectInfo
.ReqIEsLen
= pstrHostIFconnectAttr
->ies_len
;
1229 strConnectInfo
.pu8ReqIEs
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1230 memcpy(strConnectInfo
.pu8ReqIEs
,
1231 pstrHostIFconnectAttr
->ies
,
1232 pstrHostIFconnectAttr
->ies_len
);
1235 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1239 pstrHostIFconnectAttr
->arg
);
1240 hif_drv
->hif_state
= HOST_IF_IDLE
;
1241 kfree(strConnectInfo
.pu8ReqIEs
);
1242 strConnectInfo
.pu8ReqIEs
= NULL
;
1245 PRINT_ER("Connect callback function pointer is NULL\n");
1249 PRINT_D(HOSTINF_DBG
, "Deallocating connection parameters\n");
1250 kfree(pstrHostIFconnectAttr
->bssid
);
1251 pstrHostIFconnectAttr
->bssid
= NULL
;
1253 kfree(pstrHostIFconnectAttr
->ssid
);
1254 pstrHostIFconnectAttr
->ssid
= NULL
;
1256 kfree(pstrHostIFconnectAttr
->ies
);
1257 pstrHostIFconnectAttr
->ies
= NULL
;
1263 static s32
Handle_FlushConnect(struct wilc_vif
*vif
)
1266 struct wid strWIDList
[5];
1267 u32 u32WidsCount
= 0;
1268 u8
*pu8CurrByte
= NULL
;
1270 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1271 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1272 strWIDList
[u32WidsCount
].val
= info_element
;
1273 strWIDList
[u32WidsCount
].size
= info_element_size
;
1276 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1277 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1278 strWIDList
[u32WidsCount
].size
= sizeof(char);
1279 strWIDList
[u32WidsCount
].val
= (s8
*)(&(mode_11i
));
1282 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1283 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1284 strWIDList
[u32WidsCount
].size
= sizeof(char);
1285 strWIDList
[u32WidsCount
].val
= (s8
*)(&auth_type
);
1288 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1289 strWIDList
[u32WidsCount
].type
= WID_STR
;
1290 strWIDList
[u32WidsCount
].size
= join_req_size
;
1291 strWIDList
[u32WidsCount
].val
= (s8
*)join_req
;
1292 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1294 pu8CurrByte
+= FLUSHED_BYTE_POS
;
1295 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
1299 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, strWIDList
,
1301 wilc_get_vif_idx(join_req_vif
));
1303 PRINT_ER("failed to send config packet\n");
1310 static s32
Handle_ConnectTimeout(struct wilc_vif
*vif
)
1313 tstrConnectInfo strConnectInfo
;
1315 u16 u16DummyReasonCode
= 0;
1316 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1319 PRINT_ER("Driver handler is NULL\n");
1323 hif_drv
->hif_state
= HOST_IF_IDLE
;
1325 scan_while_connected
= false;
1327 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1329 if (hif_drv
->usr_conn_req
.conn_result
) {
1330 if (hif_drv
->usr_conn_req
.pu8bssid
) {
1331 memcpy(strConnectInfo
.au8bssid
,
1332 hif_drv
->usr_conn_req
.pu8bssid
, 6);
1335 if (hif_drv
->usr_conn_req
.ies
) {
1336 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1337 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1338 memcpy(strConnectInfo
.pu8ReqIEs
,
1339 hif_drv
->usr_conn_req
.ies
,
1340 hif_drv
->usr_conn_req
.ies_len
);
1343 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1347 hif_drv
->usr_conn_req
.arg
);
1349 kfree(strConnectInfo
.pu8ReqIEs
);
1350 strConnectInfo
.pu8ReqIEs
= NULL
;
1352 PRINT_ER("Connect callback function pointer is NULL\n");
1355 wid
.id
= (u16
)WID_DISCONNECT
;
1356 wid
.type
= WID_CHAR
;
1357 wid
.val
= (s8
*)&u16DummyReasonCode
;
1358 wid
.size
= sizeof(char);
1360 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
1362 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
1363 wilc_get_vif_idx(vif
));
1365 PRINT_ER("Failed to send dissconect config packet\n");
1367 hif_drv
->usr_conn_req
.ssid_len
= 0;
1368 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1369 hif_drv
->usr_conn_req
.pu8ssid
= NULL
;
1370 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1371 hif_drv
->usr_conn_req
.pu8bssid
= NULL
;
1372 hif_drv
->usr_conn_req
.ies_len
= 0;
1373 kfree(hif_drv
->usr_conn_req
.ies
);
1374 hif_drv
->usr_conn_req
.ies
= NULL
;
1376 eth_zero_addr(wilc_connected_ssid
);
1378 if (join_req
&& join_req_vif
== vif
) {
1383 if (info_element
&& join_req_vif
== vif
) {
1384 kfree(info_element
);
1385 info_element
= NULL
;
1391 static s32
Handle_RcvdNtwrkInfo(struct wilc_vif
*vif
,
1392 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1395 bool bNewNtwrkFound
;
1397 tstrNetworkInfo
*pstrNetworkInfo
= NULL
;
1398 void *pJoinParams
= NULL
;
1399 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1401 bNewNtwrkFound
= true;
1402 PRINT_INFO(HOSTINF_DBG
, "Handling received network info\n");
1404 if (hif_drv
->usr_scan_req
.scan_result
) {
1405 PRINT_D(HOSTINF_DBG
, "State: Scanning, parsing network information received\n");
1406 wilc_parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1407 if ((!pstrNetworkInfo
) ||
1408 (!hif_drv
->usr_scan_req
.scan_result
)) {
1409 PRINT_ER("driver is null\n");
1414 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1415 if ((hif_drv
->usr_scan_req
.net_info
[i
].au8bssid
) &&
1416 (pstrNetworkInfo
->au8bssid
)) {
1417 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].au8bssid
,
1418 pstrNetworkInfo
->au8bssid
, 6) == 0) {
1419 if (pstrNetworkInfo
->s8rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].s8rssi
) {
1420 PRINT_D(HOSTINF_DBG
, "Network previously discovered\n");
1423 hif_drv
->usr_scan_req
.net_info
[i
].s8rssi
= pstrNetworkInfo
->s8rssi
;
1424 bNewNtwrkFound
= false;
1431 if (bNewNtwrkFound
) {
1432 PRINT_D(HOSTINF_DBG
, "New network found\n");
1434 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1435 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].s8rssi
= pstrNetworkInfo
->s8rssi
;
1437 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].au8bssid
&&
1438 pstrNetworkInfo
->au8bssid
) {
1439 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].au8bssid
,
1440 pstrNetworkInfo
->au8bssid
, 6);
1442 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1444 pstrNetworkInfo
->bNewNetwork
= true;
1445 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1447 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1448 hif_drv
->usr_scan_req
.arg
,
1452 PRINT_WRN(HOSTINF_DBG
, "Discovered networks exceeded max. limit\n");
1455 pstrNetworkInfo
->bNewNetwork
= false;
1456 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1457 hif_drv
->usr_scan_req
.arg
, NULL
);
1462 kfree(pstrRcvdNetworkInfo
->buffer
);
1463 pstrRcvdNetworkInfo
->buffer
= NULL
;
1465 if (pstrNetworkInfo
) {
1466 wilc_dealloc_network_info(pstrNetworkInfo
);
1467 pstrNetworkInfo
= NULL
;
1473 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
1474 u8
*pu8AssocRespInfo
,
1475 u32 u32MaxAssocRespInfoLen
,
1476 u32
*pu32RcvdAssocRespInfoLen
);
1478 static s32
Handle_RcvdGnrlAsyncInfo(struct wilc_vif
*vif
,
1479 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1485 u16 u16WidID
= (u16
)WID_NIL
;
1488 u8 u8MacStatusReasonCode
;
1489 u8 u8MacStatusAdditionalInfo
;
1490 tstrConnectInfo strConnectInfo
;
1491 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1493 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1496 PRINT_ER("Driver handler is NULL\n");
1499 PRINT_D(GENERIC_DBG
, "Current State = %d,Received state = %d\n",
1500 hif_drv
->hif_state
, pstrRcvdGnrlAsyncInfo
->buffer
[7]);
1502 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1503 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1504 hif_drv
->usr_scan_req
.scan_result
) {
1505 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1506 !hif_drv
->usr_conn_req
.conn_result
) {
1507 PRINT_ER("driver is null\n");
1511 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1513 if ('I' != u8MsgType
) {
1514 PRINT_ER("Received Message format incorrect.\n");
1518 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1519 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1520 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1521 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1522 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1523 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1524 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1525 PRINT_INFO(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
1526 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1527 u32 u32RcvdAssocRespInfoLen
= 0;
1528 tstrConnectRespInfo
*pstrConnectRespInfo
= NULL
;
1530 PRINT_D(HOSTINF_DBG
, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus
, u8MacStatusReasonCode
, u8MacStatusAdditionalInfo
);
1532 memset(&strConnectInfo
, 0, sizeof(tstrConnectInfo
));
1534 if (u8MacStatus
== MAC_CONNECTED
) {
1535 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1537 host_int_get_assoc_res_info(vif
,
1539 MAX_ASSOC_RESP_FRAME_SIZE
,
1540 &u32RcvdAssocRespInfoLen
);
1542 PRINT_INFO(HOSTINF_DBG
, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen
);
1544 if (u32RcvdAssocRespInfoLen
!= 0) {
1545 PRINT_D(HOSTINF_DBG
, "Parsing association response\n");
1546 s32Err
= wilc_parse_assoc_resp_info(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1547 &pstrConnectRespInfo
);
1549 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err
);
1551 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->u16ConnectStatus
;
1553 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
1554 PRINT_INFO(HOSTINF_DBG
, "Association response received : Successful connection status\n");
1555 if (pstrConnectRespInfo
->pu8RespIEs
) {
1556 strConnectInfo
.u16RespIEsLen
= pstrConnectRespInfo
->u16RespIEsLen
;
1557 strConnectInfo
.pu8RespIEs
= kmalloc(pstrConnectRespInfo
->u16RespIEsLen
, GFP_KERNEL
);
1558 memcpy(strConnectInfo
.pu8RespIEs
, pstrConnectRespInfo
->pu8RespIEs
,
1559 pstrConnectRespInfo
->u16RespIEsLen
);
1563 if (pstrConnectRespInfo
) {
1564 wilc_dealloc_assoc_resp_info(pstrConnectRespInfo
);
1565 pstrConnectRespInfo
= NULL
;
1571 if ((u8MacStatus
== MAC_CONNECTED
) &&
1572 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
1573 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1574 eth_zero_addr(wilc_connected_ssid
);
1575 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1576 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1577 eth_zero_addr(wilc_connected_ssid
);
1580 if (hif_drv
->usr_conn_req
.pu8bssid
) {
1581 PRINT_D(HOSTINF_DBG
, "Retrieving actual BSSID from AP\n");
1582 memcpy(strConnectInfo
.au8bssid
, hif_drv
->usr_conn_req
.pu8bssid
, 6);
1584 if ((u8MacStatus
== MAC_CONNECTED
) &&
1585 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1586 memcpy(hif_drv
->assoc_bssid
,
1587 hif_drv
->usr_conn_req
.pu8bssid
, ETH_ALEN
);
1591 if (hif_drv
->usr_conn_req
.ies
) {
1592 strConnectInfo
.ReqIEsLen
= hif_drv
->usr_conn_req
.ies_len
;
1593 strConnectInfo
.pu8ReqIEs
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1594 memcpy(strConnectInfo
.pu8ReqIEs
,
1595 hif_drv
->usr_conn_req
.ies
,
1596 hif_drv
->usr_conn_req
.ies_len
);
1599 del_timer(&hif_drv
->connect_timer
);
1600 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1604 hif_drv
->usr_conn_req
.arg
);
1606 if ((u8MacStatus
== MAC_CONNECTED
) &&
1607 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1608 wilc_set_power_mgmt(vif
, 0, 0);
1610 PRINT_D(HOSTINF_DBG
, "MAC status : CONNECTED and Connect Status : Successful\n");
1611 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1613 PRINT_D(GENERIC_DBG
, "Obtaining an IP, Disable Scan\n");
1614 wilc_optaining_ip
= true;
1615 mod_timer(&wilc_during_ip_timer
,
1616 jiffies
+ msecs_to_jiffies(10000));
1618 PRINT_D(HOSTINF_DBG
, "MAC status : %d and Connect Status : %d\n", u8MacStatus
, strConnectInfo
.u16ConnectStatus
);
1619 hif_drv
->hif_state
= HOST_IF_IDLE
;
1620 scan_while_connected
= false;
1623 kfree(strConnectInfo
.pu8RespIEs
);
1624 strConnectInfo
.pu8RespIEs
= NULL
;
1626 kfree(strConnectInfo
.pu8ReqIEs
);
1627 strConnectInfo
.pu8ReqIEs
= NULL
;
1628 hif_drv
->usr_conn_req
.ssid_len
= 0;
1629 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1630 hif_drv
->usr_conn_req
.pu8ssid
= NULL
;
1631 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1632 hif_drv
->usr_conn_req
.pu8bssid
= NULL
;
1633 hif_drv
->usr_conn_req
.ies_len
= 0;
1634 kfree(hif_drv
->usr_conn_req
.ies
);
1635 hif_drv
->usr_conn_req
.ies
= NULL
;
1636 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1637 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1638 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW\n");
1640 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1642 if (hif_drv
->usr_scan_req
.scan_result
) {
1643 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running OBSS Scan >>\n\n");
1644 del_timer(&hif_drv
->scan_timer
);
1645 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1648 strDisconnectNotifInfo
.u16reason
= 0;
1649 strDisconnectNotifInfo
.ie
= NULL
;
1650 strDisconnectNotifInfo
.ie_len
= 0;
1652 if (hif_drv
->usr_conn_req
.conn_result
) {
1653 wilc_optaining_ip
= false;
1654 wilc_set_power_mgmt(vif
, 0, 0);
1656 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1659 &strDisconnectNotifInfo
,
1660 hif_drv
->usr_conn_req
.arg
);
1662 PRINT_ER("Connect result callback function is NULL\n");
1665 eth_zero_addr(hif_drv
->assoc_bssid
);
1667 hif_drv
->usr_conn_req
.ssid_len
= 0;
1668 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
1669 hif_drv
->usr_conn_req
.pu8ssid
= NULL
;
1670 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
1671 hif_drv
->usr_conn_req
.pu8bssid
= NULL
;
1672 hif_drv
->usr_conn_req
.ies_len
= 0;
1673 kfree(hif_drv
->usr_conn_req
.ies
);
1674 hif_drv
->usr_conn_req
.ies
= NULL
;
1676 if (join_req
&& join_req_vif
== vif
) {
1681 if (info_element
&& join_req_vif
== vif
) {
1682 kfree(info_element
);
1683 info_element
= NULL
;
1686 hif_drv
->hif_state
= HOST_IF_IDLE
;
1687 scan_while_connected
= false;
1689 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1690 (hif_drv
->usr_scan_req
.scan_result
)) {
1691 PRINT_D(HOSTINF_DBG
, "Received MAC_DISCONNECTED from the FW while scanning\n");
1692 PRINT_D(HOSTINF_DBG
, "\n\n<< Abort the running Scan >>\n\n");
1694 del_timer(&hif_drv
->scan_timer
);
1695 if (hif_drv
->usr_scan_req
.scan_result
)
1696 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1700 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1701 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1706 static int Handle_Key(struct wilc_vif
*vif
,
1707 struct key_attr
*pstrHostIFkeyAttr
)
1711 struct wid strWIDList
[5];
1716 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1718 switch (pstrHostIFkeyAttr
->type
) {
1721 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1722 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
1723 PRINT_D(GENERIC_DBG
, "ID Hostint is %d\n", pstrHostIFkeyAttr
->attr
.wep
.index
);
1724 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1725 strWIDList
[0].type
= WID_CHAR
;
1726 strWIDList
[0].size
= sizeof(char);
1727 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1729 strWIDList
[1].id
= WID_AUTH_TYPE
;
1730 strWIDList
[1].type
= WID_CHAR
;
1731 strWIDList
[1].size
= sizeof(char);
1732 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1734 strWIDList
[2].id
= (u16
)WID_KEY_ID
;
1735 strWIDList
[2].type
= WID_CHAR
;
1737 strWIDList
[2].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1738 strWIDList
[2].size
= sizeof(char);
1740 pu8keybuf
= kmemdup(pstrHostIFkeyAttr
->attr
.wep
.key
,
1741 pstrHostIFkeyAttr
->attr
.wep
.key_len
,
1744 if (pu8keybuf
== NULL
) {
1745 PRINT_ER("No buffer to send Key\n");
1749 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1751 strWIDList
[3].id
= (u16
)WID_WEP_KEY_VALUE
;
1752 strWIDList
[3].type
= WID_STR
;
1753 strWIDList
[3].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1754 strWIDList
[3].val
= (s8
*)pu8keybuf
;
1756 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1758 wilc_get_vif_idx(vif
));
1760 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1761 PRINT_D(HOSTINF_DBG
, "Handling WEP key\n");
1762 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1764 PRINT_ER("No buffer to send Key\n");
1767 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1768 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1769 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1770 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1771 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1773 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1775 wid
.val
= (s8
*)pu8keybuf
;
1776 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1778 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1780 wilc_get_vif_idx(vif
));
1782 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1783 PRINT_D(HOSTINF_DBG
, "Removing key\n");
1784 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1787 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1788 wid
.val
= s8idxarray
;
1791 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1793 wilc_get_vif_idx(vif
));
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
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1804 wilc_get_vif_idx(vif
));
1806 up(&hif_drv
->sem_test_key_block
);
1810 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1811 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1813 PRINT_ER("No buffer to send RxGTK Key\n");
1815 goto _WPARxGtk_end_case_
;
1818 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1819 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1821 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1822 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1823 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1824 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1826 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1827 strWIDList
[0].type
= WID_CHAR
;
1828 strWIDList
[0].size
= sizeof(char);
1829 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1831 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1832 strWIDList
[1].type
= WID_STR
;
1833 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1834 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1836 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1838 wilc_get_vif_idx(vif
));
1841 up(&hif_drv
->sem_test_key_block
);
1842 } else 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
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1870 wilc_get_vif_idx(vif
));
1873 up(&hif_drv
->sem_test_key_block
);
1875 _WPARxGtk_end_case_
:
1876 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1877 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1884 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1885 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1887 PRINT_ER("No buffer to send PTK Key\n");
1889 goto _WPAPtk_end_case_
;
1892 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1893 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1894 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1895 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1896 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1898 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1899 strWIDList
[0].type
= WID_CHAR
;
1900 strWIDList
[0].size
= sizeof(char);
1901 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1903 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1904 strWIDList
[1].type
= WID_STR
;
1905 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1906 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1908 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1910 wilc_get_vif_idx(vif
));
1912 up(&hif_drv
->sem_test_key_block
);
1913 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1914 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1916 PRINT_ER("No buffer to send PTK Key\n");
1918 goto _WPAPtk_end_case_
;
1921 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1922 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1923 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1924 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1926 wid
.id
= (u16
)WID_ADD_PTK
;
1928 wid
.val
= (s8
*)pu8keybuf
;
1929 wid
.size
= PTK_KEY_MSG_LEN
;
1931 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
,
1933 wilc_get_vif_idx(vif
));
1935 up(&hif_drv
->sem_test_key_block
);
1939 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1947 PRINT_D(HOSTINF_DBG
, "Handling PMKSA key\n");
1949 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1951 PRINT_ER("No buffer to send PMKSA Key\n");
1955 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1957 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1958 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1959 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1962 wid
.id
= (u16
)WID_PMKID_INFO
;
1964 wid
.val
= (s8
*)pu8keybuf
;
1965 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1967 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
1968 wilc_get_vif_idx(vif
));
1975 PRINT_ER("Failed to send key config packet\n");
1980 static void Handle_Disconnect(struct wilc_vif
*vif
)
1983 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1986 u16 u16DummyReasonCode
= 0;
1988 wid
.id
= (u16
)WID_DISCONNECT
;
1989 wid
.type
= WID_CHAR
;
1990 wid
.val
= (s8
*)&u16DummyReasonCode
;
1991 wid
.size
= sizeof(char);
1993 PRINT_D(HOSTINF_DBG
, "Sending disconnect request\n");
1995 wilc_optaining_ip
= false;
1996 wilc_set_power_mgmt(vif
, 0, 0);
1998 eth_zero_addr(wilc_connected_ssid
);
2000 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2001 wilc_get_vif_idx(vif
));
2004 PRINT_ER("Failed to send dissconect config packet\n");
2006 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
2008 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
2010 strDisconnectNotifInfo
.u16reason
= 0;
2011 strDisconnectNotifInfo
.ie
= NULL
;
2012 strDisconnectNotifInfo
.ie_len
= 0;
2014 if (hif_drv
->usr_scan_req
.scan_result
) {
2015 del_timer(&hif_drv
->scan_timer
);
2016 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
2018 hif_drv
->usr_scan_req
.arg
,
2020 hif_drv
->usr_scan_req
.scan_result
= NULL
;
2023 if (hif_drv
->usr_conn_req
.conn_result
) {
2024 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2025 PRINT_D(HOSTINF_DBG
, "Upper layer requested termination of connection\n");
2026 del_timer(&hif_drv
->connect_timer
);
2029 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
2032 &strDisconnectNotifInfo
,
2033 hif_drv
->usr_conn_req
.arg
);
2035 PRINT_ER("usr_conn_req.conn_result = NULL\n");
2038 scan_while_connected
= false;
2040 hif_drv
->hif_state
= HOST_IF_IDLE
;
2042 eth_zero_addr(hif_drv
->assoc_bssid
);
2044 hif_drv
->usr_conn_req
.ssid_len
= 0;
2045 kfree(hif_drv
->usr_conn_req
.pu8ssid
);
2046 hif_drv
->usr_conn_req
.pu8ssid
= NULL
;
2047 kfree(hif_drv
->usr_conn_req
.pu8bssid
);
2048 hif_drv
->usr_conn_req
.pu8bssid
= NULL
;
2049 hif_drv
->usr_conn_req
.ies_len
= 0;
2050 kfree(hif_drv
->usr_conn_req
.ies
);
2051 hif_drv
->usr_conn_req
.ies
= NULL
;
2053 if (join_req
&& join_req_vif
== vif
) {
2058 if (info_element
&& join_req_vif
== vif
) {
2059 kfree(info_element
);
2060 info_element
= NULL
;
2064 up(&hif_drv
->sem_test_disconn_block
);
2067 void wilc_resolve_disconnect_aberration(struct wilc_vif
*vif
)
2071 if ((vif
->hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
2072 (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTING
)) {
2073 PRINT_D(HOSTINF_DBG
, "\n\n<< correcting Supplicant state machine >>\n\n");
2074 wilc_disconnect(vif
, 1);
2078 static s32
Handle_GetChnl(struct wilc_vif
*vif
)
2082 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2084 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
2085 wid
.type
= WID_CHAR
;
2086 wid
.val
= (s8
*)&ch_no
;
2087 wid
.size
= sizeof(char);
2089 PRINT_D(HOSTINF_DBG
, "Getting channel value\n");
2091 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
2092 wilc_get_vif_idx(vif
));
2095 PRINT_ER("Failed to get channel number\n");
2099 up(&hif_drv
->sem_get_chnl
);
2104 static void Handle_GetRssi(struct wilc_vif
*vif
)
2109 wid
.id
= (u16
)WID_RSSI
;
2110 wid
.type
= WID_CHAR
;
2112 wid
.size
= sizeof(char);
2114 PRINT_D(HOSTINF_DBG
, "Getting RSSI value\n");
2116 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
2117 wilc_get_vif_idx(vif
));
2119 PRINT_ER("Failed to get RSSI value\n");
2123 up(&vif
->hif_drv
->sem_get_rssi
);
2126 static void Handle_GetLinkspeed(struct wilc_vif
*vif
)
2130 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2134 wid
.id
= (u16
)WID_LINKSPEED
;
2135 wid
.type
= WID_CHAR
;
2136 wid
.val
= &link_speed
;
2137 wid
.size
= sizeof(char);
2139 PRINT_D(HOSTINF_DBG
, "Getting LINKSPEED value\n");
2141 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
2142 wilc_get_vif_idx(vif
));
2144 PRINT_ER("Failed to get LINKSPEED value\n");
2148 up(&hif_drv
->sem_get_link_speed
);
2151 static s32
Handle_GetStatistics(struct wilc_vif
*vif
,
2152 struct rf_info
*pstrStatistics
)
2154 struct wid strWIDList
[5];
2155 u32 u32WidsCount
= 0, result
= 0;
2157 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
2158 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2159 strWIDList
[u32WidsCount
].size
= sizeof(char);
2160 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
2163 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
2164 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2165 strWIDList
[u32WidsCount
].size
= sizeof(char);
2166 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
2169 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
2170 strWIDList
[u32WidsCount
].type
= WID_INT
;
2171 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2172 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
2175 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
2176 strWIDList
[u32WidsCount
].type
= WID_INT
;
2177 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2178 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
2181 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
2182 strWIDList
[u32WidsCount
].type
= WID_INT
;
2183 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2184 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
2187 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, strWIDList
,
2189 wilc_get_vif_idx(vif
));
2192 PRINT_ER("Failed to send scan paramters config packet\n");
2194 up(&hif_sema_wait_response
);
2198 static s32
Handle_Get_InActiveTime(struct wilc_vif
*vif
,
2199 struct sta_inactive_t
*strHostIfStaInactiveT
)
2204 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2206 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
2208 wid
.size
= ETH_ALEN
;
2209 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2212 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
2214 PRINT_D(CFG80211_DBG
, "SETING STA inactive time\n");
2216 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2217 wilc_get_vif_idx(vif
));
2220 PRINT_ER("Failed to SET incative time\n");
2224 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
2226 wid
.val
= (s8
*)&inactive_time
;
2227 wid
.size
= sizeof(u32
);
2229 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
2230 wilc_get_vif_idx(vif
));
2233 PRINT_ER("Failed to get incative time\n");
2237 PRINT_D(CFG80211_DBG
, "Getting inactive time : %d\n", inactive_time
);
2239 up(&hif_drv
->sem_inactive_time
);
2244 static void Handle_AddBeacon(struct wilc_vif
*vif
,
2245 struct beacon_attr
*pstrSetBeaconParam
)
2251 PRINT_D(HOSTINF_DBG
, "Adding BEACON\n");
2253 wid
.id
= (u16
)WID_ADD_BEACON
;
2255 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
2256 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2260 pu8CurrByte
= wid
.val
;
2261 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
2262 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
2263 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
2264 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
2266 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
2267 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
2268 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
2269 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
2271 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
2272 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
2273 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
2274 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
2276 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
2277 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2279 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2280 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2281 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2282 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2284 if (pstrSetBeaconParam
->tail
)
2285 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2286 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2288 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2289 wilc_get_vif_idx(vif
));
2291 PRINT_ER("Failed to send add beacon config packet\n");
2295 kfree(pstrSetBeaconParam
->head
);
2296 kfree(pstrSetBeaconParam
->tail
);
2299 static void Handle_DelBeacon(struct wilc_vif
*vif
)
2305 wid
.id
= (u16
)WID_DEL_BEACON
;
2306 wid
.type
= WID_CHAR
;
2307 wid
.size
= sizeof(char);
2308 wid
.val
= &del_beacon
;
2313 pu8CurrByte
= wid
.val
;
2315 PRINT_D(HOSTINF_DBG
, "Deleting BEACON\n");
2317 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2318 wilc_get_vif_idx(vif
));
2320 PRINT_ER("Failed to send delete beacon config packet\n");
2323 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2324 struct add_sta_param
*pstrStationParam
)
2328 pu8CurrByte
= pu8Buffer
;
2330 PRINT_D(HOSTINF_DBG
, "Packing STA params\n");
2331 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2332 pu8CurrByte
+= ETH_ALEN
;
2334 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2335 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2337 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2338 if (pstrStationParam
->rates_len
> 0)
2339 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2340 pstrStationParam
->rates_len
);
2341 pu8CurrByte
+= pstrStationParam
->rates_len
;
2343 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2344 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2345 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2347 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2348 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2349 WILC_SUPP_MCS_SET_SIZE
);
2350 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2352 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2353 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2355 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2356 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2357 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2358 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2360 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2362 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2363 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2365 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2366 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2368 return pu8CurrByte
- pu8Buffer
;
2371 static void Handle_AddStation(struct wilc_vif
*vif
,
2372 struct add_sta_param
*pstrStationParam
)
2378 PRINT_D(HOSTINF_DBG
, "Handling add station\n");
2379 wid
.id
= (u16
)WID_ADD_STA
;
2381 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2383 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2387 pu8CurrByte
= wid
.val
;
2388 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2390 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2391 wilc_get_vif_idx(vif
));
2393 PRINT_ER("Failed to send add station config packet\n");
2396 kfree(pstrStationParam
->rates
);
2400 static void Handle_DelAllSta(struct wilc_vif
*vif
,
2401 struct del_all_sta
*pstrDelAllStaParam
)
2407 u8 au8Zero_Buff
[6] = {0};
2409 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2411 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2413 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
2415 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2419 pu8CurrByte
= wid
.val
;
2421 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2423 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2424 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2425 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2429 pu8CurrByte
+= ETH_ALEN
;
2432 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2433 wilc_get_vif_idx(vif
));
2435 PRINT_ER("Failed to send add station config packet\n");
2440 up(&hif_sema_wait_response
);
2443 static void Handle_DelStation(struct wilc_vif
*vif
,
2444 struct del_sta
*pstrDelStaParam
)
2450 wid
.id
= (u16
)WID_REMOVE_STA
;
2452 wid
.size
= ETH_ALEN
;
2454 PRINT_D(HOSTINF_DBG
, "Handling delete station\n");
2456 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2460 pu8CurrByte
= wid
.val
;
2462 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2464 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2465 wilc_get_vif_idx(vif
));
2467 PRINT_ER("Failed to send add station config packet\n");
2473 static void Handle_EditStation(struct wilc_vif
*vif
,
2474 struct add_sta_param
*pstrStationParam
)
2480 wid
.id
= (u16
)WID_EDIT_STA
;
2482 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2484 PRINT_D(HOSTINF_DBG
, "Handling edit station\n");
2485 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2489 pu8CurrByte
= wid
.val
;
2490 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2492 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2493 wilc_get_vif_idx(vif
));
2495 PRINT_ER("Failed to send edit station config packet\n");
2498 kfree(pstrStationParam
->rates
);
2502 static int Handle_RemainOnChan(struct wilc_vif
*vif
,
2503 struct remain_ch
*pstrHostIfRemainOnChan
)
2506 u8 u8remain_on_chan_flag
;
2508 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2510 if (!hif_drv
->remain_on_ch_pending
) {
2511 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2512 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2513 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2514 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2515 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2517 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2520 if (hif_drv
->usr_scan_req
.scan_result
) {
2521 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while scanning return\n");
2522 hif_drv
->remain_on_ch_pending
= 1;
2526 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2527 PRINT_INFO(GENERIC_DBG
, "Required to remain on chan while connecting return\n");
2532 if (wilc_optaining_ip
|| wilc_connecting
) {
2533 PRINT_D(GENERIC_DBG
, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2538 PRINT_D(HOSTINF_DBG
, "Setting channel :%d\n",
2539 pstrHostIfRemainOnChan
->ch
);
2541 u8remain_on_chan_flag
= true;
2542 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2545 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2551 wid
.val
[0] = u8remain_on_chan_flag
;
2552 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2554 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2555 wilc_get_vif_idx(vif
));
2557 PRINT_ER("Failed to set remain on channel\n");
2561 P2P_LISTEN_STATE
= 1;
2562 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)vif
;
2563 mod_timer(&hif_drv
->remain_on_ch_timer
,
2565 msecs_to_jiffies(pstrHostIfRemainOnChan
->u32duration
));
2567 if (hif_drv
->remain_on_ch
.ready
)
2568 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2570 if (hif_drv
->remain_on_ch_pending
)
2571 hif_drv
->remain_on_ch_pending
= 0;
2577 static int Handle_RegisterFrame(struct wilc_vif
*vif
,
2578 struct reg_frame
*pstrHostIfRegisterFrame
)
2584 PRINT_D(HOSTINF_DBG
, "Handling frame register : %d FrameType: %d\n",
2585 pstrHostIfRegisterFrame
->reg
,
2586 pstrHostIfRegisterFrame
->frame_type
);
2588 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2590 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2594 pu8CurrByte
= wid
.val
;
2596 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2597 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2598 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2600 wid
.size
= sizeof(u16
) + 2;
2602 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2603 wilc_get_vif_idx(vif
));
2605 PRINT_ER("Failed to frame register config packet\n");
2612 static u32
Handle_ListenStateExpired(struct wilc_vif
*vif
,
2613 struct remain_ch
*pstrHostIfRemainOnChan
)
2615 u8 u8remain_on_chan_flag
;
2618 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2620 PRINT_D(HOSTINF_DBG
, "CANCEL REMAIN ON CHAN\n");
2622 if (P2P_LISTEN_STATE
) {
2623 u8remain_on_chan_flag
= false;
2624 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2627 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2630 PRINT_ER("Failed to allocate memory\n");
2634 wid
.val
[0] = u8remain_on_chan_flag
;
2635 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2637 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2638 wilc_get_vif_idx(vif
));
2640 PRINT_ER("Failed to set remain on channel\n");
2644 if (hif_drv
->remain_on_ch
.expired
) {
2645 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2646 pstrHostIfRemainOnChan
->id
);
2648 P2P_LISTEN_STATE
= 0;
2650 PRINT_D(GENERIC_DBG
, "Not in listen state\n");
2658 static void ListenTimerCB(unsigned long arg
)
2661 struct host_if_msg msg
;
2662 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2664 del_timer(&vif
->hif_drv
->remain_on_ch_timer
);
2666 memset(&msg
, 0, sizeof(struct host_if_msg
));
2667 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2669 msg
.body
.remain_on_ch
.id
= vif
->hif_drv
->remain_on_ch
.id
;
2671 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2673 PRINT_ER("wilc_mq_send fail\n");
2676 static void Handle_PowerManagement(struct wilc_vif
*vif
,
2677 struct power_mgmt_param
*strPowerMgmtParam
)
2683 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2685 if (strPowerMgmtParam
->enabled
)
2686 s8PowerMode
= MIN_FAST_PS
;
2688 s8PowerMode
= NO_POWERSAVE
;
2689 PRINT_D(HOSTINF_DBG
, "Handling power mgmt to %d\n", s8PowerMode
);
2690 wid
.val
= &s8PowerMode
;
2691 wid
.size
= sizeof(char);
2693 PRINT_D(HOSTINF_DBG
, "Handling Power Management\n");
2695 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2696 wilc_get_vif_idx(vif
));
2698 PRINT_ER("Failed to send power management config packet\n");
2701 static void Handle_SetMulticastFilter(struct wilc_vif
*vif
,
2702 struct set_multicast
*strHostIfSetMulti
)
2708 PRINT_D(HOSTINF_DBG
, "Setup Multicast Filter\n");
2710 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2712 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2713 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2717 pu8CurrByte
= wid
.val
;
2718 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2723 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2724 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2725 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2726 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2728 if ((strHostIfSetMulti
->cnt
) > 0)
2729 memcpy(pu8CurrByte
, wilc_multicast_mac_addr_list
,
2730 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2732 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2733 wilc_get_vif_idx(vif
));
2735 PRINT_ER("Failed to send setup multicast config packet\n");
2741 static s32
Handle_DelAllRxBASessions(struct wilc_vif
*vif
,
2742 struct ba_session_info
*strHostIfBASessionInfo
)
2748 PRINT_D(GENERIC_DBG
, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2749 strHostIfBASessionInfo
->bssid
[0],
2750 strHostIfBASessionInfo
->bssid
[1],
2751 strHostIfBASessionInfo
->bssid
[2],
2752 strHostIfBASessionInfo
->tid
);
2754 wid
.id
= (u16
)WID_DEL_ALL_RX_BA
;
2756 wid
.val
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
2757 wid
.size
= BLOCK_ACK_REQ_SIZE
;
2762 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2764 *ptr
++ = strHostIfBASessionInfo
->tid
;
2768 result
= wilc_send_config_pkt(vif
->wilc
, SET_CFG
, &wid
, 1,
2769 wilc_get_vif_idx(vif
));
2771 PRINT_D(HOSTINF_DBG
, "Couldn't delete BA Session\n");
2775 up(&hif_sema_wait_response
);
2780 static int hostIFthread(void *pvArg
)
2783 struct host_if_msg msg
;
2784 struct wilc
*wilc
= (struct wilc
*)pvArg
;
2785 struct wilc_vif
*vif
;
2787 memset(&msg
, 0, sizeof(struct host_if_msg
));
2790 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2792 if (msg
.id
== HOST_IF_MSG_EXIT
) {
2793 PRINT_D(GENERIC_DBG
, "THREAD: Exiting HostIfThread\n");
2797 if ((!wilc_initialized
)) {
2798 PRINT_D(GENERIC_DBG
, "--WAIT--");
2799 usleep_range(200 * 1000, 200 * 1000);
2800 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2804 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2805 vif
->hif_drv
->usr_scan_req
.scan_result
) {
2806 PRINT_D(HOSTINF_DBG
, "Requeue connect request till scan done received\n");
2807 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2808 usleep_range(2 * 1000, 2 * 1000);
2813 case HOST_IF_MSG_Q_IDLE
:
2814 Handle_wait_msg_q_empty();
2817 case HOST_IF_MSG_SCAN
:
2818 Handle_Scan(msg
.vif
, &msg
.body
.scan_info
);
2821 case HOST_IF_MSG_CONNECT
:
2822 Handle_Connect(msg
.vif
, &msg
.body
.con_info
);
2825 case HOST_IF_MSG_FLUSH_CONNECT
:
2826 Handle_FlushConnect(msg
.vif
);
2829 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2830 Handle_RcvdNtwrkInfo(msg
.vif
, &msg
.body
.net_info
);
2833 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2834 Handle_RcvdGnrlAsyncInfo(vif
,
2835 &msg
.body
.async_info
);
2838 case HOST_IF_MSG_KEY
:
2839 Handle_Key(msg
.vif
, &msg
.body
.key_info
);
2842 case HOST_IF_MSG_CFG_PARAMS
:
2843 handle_cfg_param(msg
.vif
, &msg
.body
.cfg_info
);
2846 case HOST_IF_MSG_SET_CHANNEL
:
2847 handle_set_channel(msg
.vif
, &msg
.body
.channel_info
);
2850 case HOST_IF_MSG_DISCONNECT
:
2851 Handle_Disconnect(msg
.vif
);
2854 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2855 del_timer(&vif
->hif_drv
->scan_timer
);
2856 PRINT_D(HOSTINF_DBG
, "scan completed successfully\n");
2858 if (!wilc_wlan_get_num_conn_ifcs(wilc
))
2859 wilc_chip_sleep_manually(wilc
);
2861 Handle_ScanDone(msg
.vif
, SCAN_EVENT_DONE
);
2863 if (vif
->hif_drv
->remain_on_ch_pending
)
2864 Handle_RemainOnChan(msg
.vif
,
2865 &msg
.body
.remain_on_ch
);
2869 case HOST_IF_MSG_GET_RSSI
:
2870 Handle_GetRssi(msg
.vif
);
2873 case HOST_IF_MSG_GET_LINKSPEED
:
2874 Handle_GetLinkspeed(msg
.vif
);
2877 case HOST_IF_MSG_GET_STATISTICS
:
2878 Handle_GetStatistics(msg
.vif
,
2879 (struct rf_info
*)msg
.body
.data
);
2882 case HOST_IF_MSG_GET_CHNL
:
2883 Handle_GetChnl(msg
.vif
);
2886 case HOST_IF_MSG_ADD_BEACON
:
2887 Handle_AddBeacon(msg
.vif
, &msg
.body
.beacon_info
);
2890 case HOST_IF_MSG_DEL_BEACON
:
2891 Handle_DelBeacon(msg
.vif
);
2894 case HOST_IF_MSG_ADD_STATION
:
2895 Handle_AddStation(msg
.vif
, &msg
.body
.add_sta_info
);
2898 case HOST_IF_MSG_DEL_STATION
:
2899 Handle_DelStation(msg
.vif
, &msg
.body
.del_sta_info
);
2902 case HOST_IF_MSG_EDIT_STATION
:
2903 Handle_EditStation(msg
.vif
, &msg
.body
.edit_sta_info
);
2906 case HOST_IF_MSG_GET_INACTIVETIME
:
2907 Handle_Get_InActiveTime(msg
.vif
, &msg
.body
.mac_info
);
2910 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2911 PRINT_D(HOSTINF_DBG
, "Scan Timeout\n");
2913 Handle_ScanDone(msg
.vif
, SCAN_EVENT_ABORTED
);
2916 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2917 PRINT_D(HOSTINF_DBG
, "Connect Timeout\n");
2918 Handle_ConnectTimeout(msg
.vif
);
2921 case HOST_IF_MSG_POWER_MGMT
:
2922 Handle_PowerManagement(msg
.vif
,
2923 &msg
.body
.pwr_mgmt_info
);
2926 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2927 handle_set_wfi_drv_handler(msg
.vif
, &msg
.body
.drv
);
2930 case HOST_IF_MSG_SET_OPERATION_MODE
:
2931 handle_set_operation_mode(msg
.vif
, &msg
.body
.mode
);
2934 case HOST_IF_MSG_SET_IPADDRESS
:
2935 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
2936 handle_set_ip_address(vif
,
2937 msg
.body
.ip_info
.ip_addr
,
2938 msg
.body
.ip_info
.idx
);
2941 case HOST_IF_MSG_GET_IPADDRESS
:
2942 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_IPADDRESS\n");
2943 handle_get_ip_address(vif
, msg
.body
.ip_info
.idx
);
2946 case HOST_IF_MSG_SET_MAC_ADDRESS
:
2947 handle_set_mac_address(msg
.vif
,
2948 &msg
.body
.set_mac_info
);
2951 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2952 handle_get_mac_address(msg
.vif
,
2953 &msg
.body
.get_mac_info
);
2956 case HOST_IF_MSG_REMAIN_ON_CHAN
:
2957 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
2958 Handle_RemainOnChan(msg
.vif
, &msg
.body
.remain_on_ch
);
2961 case HOST_IF_MSG_REGISTER_FRAME
:
2962 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_REGISTER_FRAME\n");
2963 Handle_RegisterFrame(msg
.vif
, &msg
.body
.reg_frame
);
2966 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
2967 Handle_ListenStateExpired(msg
.vif
, &msg
.body
.remain_on_ch
);
2970 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
2971 PRINT_D(HOSTINF_DBG
, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
2972 Handle_SetMulticastFilter(msg
.vif
, &msg
.body
.multicast_info
);
2975 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
2976 Handle_DelAllRxBASessions(msg
.vif
, &msg
.body
.session_info
);
2979 case HOST_IF_MSG_DEL_ALL_STA
:
2980 Handle_DelAllSta(msg
.vif
, &msg
.body
.del_all_sta_info
);
2984 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
2989 PRINT_D(HOSTINF_DBG
, "Releasing thread exit semaphore\n");
2990 up(&hif_sema_thread
);
2994 static void TimerCB_Scan(unsigned long arg
)
2996 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2997 struct host_if_msg msg
;
2999 memset(&msg
, 0, sizeof(struct host_if_msg
));
3001 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
3003 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3006 static void TimerCB_Connect(unsigned long arg
)
3008 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3009 struct host_if_msg msg
;
3011 memset(&msg
, 0, sizeof(struct host_if_msg
));
3013 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
3015 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3018 s32
wilc_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
3022 wid
.id
= (u16
)WID_REMOVE_KEY
;
3024 wid
.val
= (s8
*)pu8StaAddress
;
3030 int wilc_remove_wep_key(struct wilc_vif
*vif
, u8 index
)
3033 struct host_if_msg msg
;
3034 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3038 PRINT_ER("Failed to send setup multicast config packet\n");
3042 memset(&msg
, 0, sizeof(struct host_if_msg
));
3044 msg
.id
= HOST_IF_MSG_KEY
;
3045 msg
.body
.key_info
.type
= WEP
;
3046 msg
.body
.key_info
.action
= REMOVEKEY
;
3048 msg
.body
.key_info
.attr
.wep
.index
= index
;
3050 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3052 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
3053 down(&hif_drv
->sem_test_key_block
);
3058 int wilc_set_wep_default_keyid(struct wilc_vif
*vif
, u8 index
)
3061 struct host_if_msg msg
;
3062 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3066 PRINT_ER("driver is null\n");
3070 memset(&msg
, 0, sizeof(struct host_if_msg
));
3072 msg
.id
= HOST_IF_MSG_KEY
;
3073 msg
.body
.key_info
.type
= WEP
;
3074 msg
.body
.key_info
.action
= DEFAULTKEY
;
3076 msg
.body
.key_info
.attr
.wep
.index
= index
;
3078 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3080 PRINT_ER("Error in sending message queue : Default key index\n");
3081 down(&hif_drv
->sem_test_key_block
);
3086 int wilc_add_wep_key_bss_sta(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
3090 struct host_if_msg msg
;
3091 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3094 PRINT_ER("driver is null\n");
3098 memset(&msg
, 0, sizeof(struct host_if_msg
));
3100 msg
.id
= HOST_IF_MSG_KEY
;
3101 msg
.body
.key_info
.type
= WEP
;
3102 msg
.body
.key_info
.action
= ADDKEY
;
3104 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3105 if (!msg
.body
.key_info
.attr
.wep
.key
)
3108 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3109 msg
.body
.key_info
.attr
.wep
.index
= index
;
3111 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3113 PRINT_ER("Error in sending message queue :WEP Key\n");
3114 down(&hif_drv
->sem_test_key_block
);
3119 int wilc_add_wep_key_bss_ap(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
3120 u8 index
, u8 mode
, enum AUTHTYPE auth_type
)
3123 struct host_if_msg msg
;
3124 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3128 PRINT_ER("driver is null\n");
3132 memset(&msg
, 0, sizeof(struct host_if_msg
));
3135 for (i
= 0; i
< len
; i
++)
3136 PRINT_INFO(HOSTAPD_DBG
, "KEY is %x\n", key
[i
]);
3138 msg
.id
= HOST_IF_MSG_KEY
;
3139 msg
.body
.key_info
.type
= WEP
;
3140 msg
.body
.key_info
.action
= ADDKEY_AP
;
3142 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3143 if (!msg
.body
.key_info
.attr
.wep
.key
)
3146 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3147 msg
.body
.key_info
.attr
.wep
.index
= index
;
3148 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
3149 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
3151 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3154 PRINT_ER("Error in sending message queue :WEP Key\n");
3155 down(&hif_drv
->sem_test_key_block
);
3160 int wilc_add_ptk(struct wilc_vif
*vif
, const u8
*ptk
, u8 ptk_key_len
,
3161 const u8
*mac_addr
, const u8
*rx_mic
, const u8
*tx_mic
,
3162 u8 mode
, u8 cipher_mode
, u8 index
)
3165 struct host_if_msg msg
;
3166 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3167 u8 key_len
= ptk_key_len
;
3171 PRINT_ER("driver is null\n");
3176 key_len
+= RX_MIC_KEY_LEN
;
3179 key_len
+= TX_MIC_KEY_LEN
;
3181 memset(&msg
, 0, sizeof(struct host_if_msg
));
3183 msg
.id
= HOST_IF_MSG_KEY
;
3184 msg
.body
.key_info
.type
= WPA_PTK
;
3185 if (mode
== AP_MODE
) {
3186 msg
.body
.key_info
.action
= ADDKEY_AP
;
3187 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3189 if (mode
== STATION_MODE
)
3190 msg
.body
.key_info
.action
= ADDKEY
;
3192 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
3193 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3197 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
3199 for (i
= 0; i
< RX_MIC_KEY_LEN
; i
++)
3200 PRINT_INFO(CFG80211_DBG
, "PairwiseRx[%d] = %x\n", i
, rx_mic
[i
]);
3204 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
3206 for (i
= 0; i
< TX_MIC_KEY_LEN
; i
++)
3207 PRINT_INFO(CFG80211_DBG
, "PairwiseTx[%d] = %x\n", i
, tx_mic
[i
]);
3211 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3212 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
3213 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3216 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3219 PRINT_ER("Error in sending message queue: PTK Key\n");
3221 down(&hif_drv
->sem_test_key_block
);
3226 int wilc_add_rx_gtk(struct wilc_vif
*vif
, const u8
*rx_gtk
, u8 gtk_key_len
,
3227 u8 index
, u32 key_rsc_len
, const u8
*key_rsc
,
3228 const u8
*rx_mic
, const u8
*tx_mic
, u8 mode
,
3232 struct host_if_msg msg
;
3233 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3234 u8 key_len
= gtk_key_len
;
3237 PRINT_ER("driver is null\n");
3240 memset(&msg
, 0, sizeof(struct host_if_msg
));
3243 key_len
+= RX_MIC_KEY_LEN
;
3246 key_len
+= TX_MIC_KEY_LEN
;
3249 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
3252 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
3256 msg
.id
= HOST_IF_MSG_KEY
;
3257 msg
.body
.key_info
.type
= WPA_RX_GTK
;
3260 if (mode
== AP_MODE
) {
3261 msg
.body
.key_info
.action
= ADDKEY_AP
;
3262 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3264 if (mode
== STATION_MODE
)
3265 msg
.body
.key_info
.action
= ADDKEY
;
3267 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
3270 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3274 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
3278 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
3281 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3282 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3283 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
3285 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3287 PRINT_ER("Error in sending message queue: RX GTK\n");
3289 down(&hif_drv
->sem_test_key_block
);
3294 int wilc_set_pmkid_info(struct wilc_vif
*vif
,
3295 struct host_if_pmkid_attr
*pu8PmkidInfoArray
)
3298 struct host_if_msg msg
;
3299 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3303 PRINT_ER("driver is null\n");
3307 memset(&msg
, 0, sizeof(struct host_if_msg
));
3309 msg
.id
= HOST_IF_MSG_KEY
;
3310 msg
.body
.key_info
.type
= PMKSA
;
3311 msg
.body
.key_info
.action
= ADDKEY
;
3314 for (i
= 0; i
< pu8PmkidInfoArray
->numpmkid
; i
++) {
3315 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
3316 &pu8PmkidInfoArray
->pmkidlist
[i
].bssid
, ETH_ALEN
);
3317 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
3318 &pu8PmkidInfoArray
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
3321 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3323 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3328 s32
wilc_get_mac_address(struct wilc_vif
*vif
, u8
*pu8MacAddress
)
3331 struct host_if_msg msg
;
3333 memset(&msg
, 0, sizeof(struct host_if_msg
));
3335 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
3336 msg
.body
.get_mac_info
.mac_addr
= pu8MacAddress
;
3339 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3341 PRINT_ER("Failed to send get mac address\n");
3345 down(&hif_sema_wait_response
);
3349 s32
wilc_set_mac_address(struct wilc_vif
*vif
, u8
*pu8MacAddress
)
3352 struct host_if_msg msg
;
3354 PRINT_D(GENERIC_DBG
, "mac addr = %x:%x:%x\n", pu8MacAddress
[0], pu8MacAddress
[1], pu8MacAddress
[2]);
3356 memset(&msg
, 0, sizeof(struct host_if_msg
));
3357 msg
.id
= HOST_IF_MSG_SET_MAC_ADDRESS
;
3358 memcpy(msg
.body
.set_mac_info
.mac_addr
, pu8MacAddress
, ETH_ALEN
);
3361 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3363 PRINT_ER("Failed to send message queue: Set mac address\n");
3368 s32
wilc_set_join_req(struct wilc_vif
*vif
, u8
*pu8bssid
, const u8
*pu8ssid
,
3369 size_t ssidLen
, const u8
*pu8IEs
, size_t IEsLen
,
3370 wilc_connect_result pfConnectResult
, void *pvUserArg
,
3371 u8 u8security
, enum AUTHTYPE tenuAuth_type
,
3372 u8 u8channel
, void *pJoinParams
)
3375 struct host_if_msg msg
;
3376 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3378 if (!hif_drv
|| !pfConnectResult
) {
3379 PRINT_ER("Driver is null\n");
3384 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3388 memset(&msg
, 0, sizeof(struct host_if_msg
));
3390 msg
.id
= HOST_IF_MSG_CONNECT
;
3392 msg
.body
.con_info
.security
= u8security
;
3393 msg
.body
.con_info
.auth_type
= tenuAuth_type
;
3394 msg
.body
.con_info
.ch
= u8channel
;
3395 msg
.body
.con_info
.result
= pfConnectResult
;
3396 msg
.body
.con_info
.arg
= pvUserArg
;
3397 msg
.body
.con_info
.params
= pJoinParams
;
3401 msg
.body
.con_info
.bssid
= kmalloc(6, GFP_KERNEL
);
3402 memcpy(msg
.body
.con_info
.bssid
, pu8bssid
, 6);
3406 msg
.body
.con_info
.ssid_len
= ssidLen
;
3407 msg
.body
.con_info
.ssid
= kmalloc(ssidLen
, GFP_KERNEL
);
3408 memcpy(msg
.body
.con_info
.ssid
, pu8ssid
, ssidLen
);
3412 msg
.body
.con_info
.ies_len
= IEsLen
;
3413 msg
.body
.con_info
.ies
= kmalloc(IEsLen
, GFP_KERNEL
);
3414 memcpy(msg
.body
.con_info
.ies
, pu8IEs
, IEsLen
);
3416 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3417 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3419 PRINT_D(GENERIC_DBG
, "Don't set state to 'connecting' : %d\n",
3420 hif_drv
->hif_state
);
3422 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3424 PRINT_ER("Failed to send message queue: Set join request\n");
3428 hif_drv
->connect_timer
.data
= (unsigned long)vif
;
3429 mod_timer(&hif_drv
->connect_timer
,
3430 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3435 s32
wilc_flush_join_req(struct wilc_vif
*vif
)
3438 struct host_if_msg msg
;
3439 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3445 PRINT_ER("Driver is null\n");
3449 msg
.id
= HOST_IF_MSG_FLUSH_CONNECT
;
3452 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3454 PRINT_ER("Failed to send message queue: Flush join request\n");
3461 s32
wilc_disconnect(struct wilc_vif
*vif
, u16 u16ReasonCode
)
3464 struct host_if_msg msg
;
3465 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3468 PRINT_ER("Driver is null\n");
3472 memset(&msg
, 0, sizeof(struct host_if_msg
));
3474 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3477 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3479 PRINT_ER("Failed to send message queue: disconnect\n");
3481 down(&hif_drv
->sem_test_disconn_block
);
3486 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
3487 u8
*pu8AssocRespInfo
,
3488 u32 u32MaxAssocRespInfoLen
,
3489 u32
*pu32RcvdAssocRespInfoLen
)
3493 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3496 PRINT_ER("Driver is null\n");
3500 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3502 wid
.val
= pu8AssocRespInfo
;
3503 wid
.size
= u32MaxAssocRespInfoLen
;
3505 result
= wilc_send_config_pkt(vif
->wilc
, GET_CFG
, &wid
, 1,
3506 wilc_get_vif_idx(vif
));
3508 *pu32RcvdAssocRespInfoLen
= 0;
3509 PRINT_ER("Failed to send association response config packet\n");
3512 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3518 int wilc_set_mac_chnl_num(struct wilc_vif
*vif
, u8 channel
)
3521 struct host_if_msg msg
;
3522 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3525 PRINT_ER("driver is null\n");
3529 memset(&msg
, 0, sizeof(struct host_if_msg
));
3530 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3531 msg
.body
.channel_info
.set_ch
= channel
;
3534 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3536 PRINT_ER("wilc mq send fail\n");
3543 int wilc_wait_msg_queue_idle(void)
3546 struct host_if_msg msg
;
3548 memset(&msg
, 0, sizeof(struct host_if_msg
));
3549 msg
.id
= HOST_IF_MSG_Q_IDLE
;
3550 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3552 PRINT_ER("wilc mq send fail\n");
3556 down(&hif_sema_wait_response
);
3561 int wilc_set_wfi_drv_handler(struct wilc_vif
*vif
, int index
)
3564 struct host_if_msg msg
;
3566 memset(&msg
, 0, sizeof(struct host_if_msg
));
3567 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3568 msg
.body
.drv
.handler
= index
;
3571 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3573 PRINT_ER("wilc mq send fail\n");
3580 int wilc_set_operation_mode(struct wilc_vif
*vif
, u32 mode
)
3583 struct host_if_msg msg
;
3585 memset(&msg
, 0, sizeof(struct host_if_msg
));
3586 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3587 msg
.body
.mode
.mode
= mode
;
3590 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3592 PRINT_ER("wilc mq send fail\n");
3599 s32
wilc_get_inactive_time(struct wilc_vif
*vif
, const u8
*mac
,
3600 u32
*pu32InactiveTime
)
3603 struct host_if_msg msg
;
3604 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3607 PRINT_ER("driver is null\n");
3611 memset(&msg
, 0, sizeof(struct host_if_msg
));
3612 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3614 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3617 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3619 PRINT_ER("Failed to send get host channel param's message queue ");
3621 down(&hif_drv
->sem_inactive_time
);
3623 *pu32InactiveTime
= inactive_time
;
3628 s32
wilc_get_rssi(struct wilc_vif
*vif
, s8
*ps8Rssi
)
3631 struct host_if_msg msg
;
3632 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3634 memset(&msg
, 0, sizeof(struct host_if_msg
));
3635 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3638 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3640 PRINT_ER("Failed to send get host channel param's message queue ");
3644 down(&hif_drv
->sem_get_rssi
);
3647 PRINT_ER("RSS pointer value is null");
3656 s32
wilc_get_statistics(struct wilc_vif
*vif
, struct rf_info
*pstrStatistics
)
3659 struct host_if_msg msg
;
3661 memset(&msg
, 0, sizeof(struct host_if_msg
));
3662 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3663 msg
.body
.data
= (char *)pstrStatistics
;
3666 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3668 PRINT_ER("Failed to send get host channel param's message queue ");
3672 down(&hif_sema_wait_response
);
3676 s32
wilc_scan(struct wilc_vif
*vif
, u8 u8ScanSource
, u8 u8ScanType
,
3677 u8
*pu8ChnlFreqList
, u8 u8ChnlListLen
, const u8
*pu8IEs
,
3678 size_t IEsLen
, wilc_scan_result ScanResult
, void *pvUserArg
,
3679 struct hidden_network
*pstrHiddenNetwork
)
3682 struct host_if_msg msg
;
3683 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3685 if (!hif_drv
|| !ScanResult
) {
3686 PRINT_ER("hif_drv or ScanResult = NULL\n");
3690 memset(&msg
, 0, sizeof(struct host_if_msg
));
3692 msg
.id
= HOST_IF_MSG_SCAN
;
3694 if (pstrHiddenNetwork
) {
3695 msg
.body
.scan_info
.hidden_network
.pstrHiddenNetworkInfo
= pstrHiddenNetwork
->pstrHiddenNetworkInfo
;
3696 msg
.body
.scan_info
.hidden_network
.u8ssidnum
= pstrHiddenNetwork
->u8ssidnum
;
3699 PRINT_D(HOSTINF_DBG
, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3702 msg
.body
.scan_info
.src
= u8ScanSource
;
3703 msg
.body
.scan_info
.type
= u8ScanType
;
3704 msg
.body
.scan_info
.result
= ScanResult
;
3705 msg
.body
.scan_info
.arg
= pvUserArg
;
3707 msg
.body
.scan_info
.ch_list_len
= u8ChnlListLen
;
3708 msg
.body
.scan_info
.ch_freq_list
= kmalloc(u8ChnlListLen
, GFP_KERNEL
);
3709 memcpy(msg
.body
.scan_info
.ch_freq_list
, pu8ChnlFreqList
, u8ChnlListLen
);
3711 msg
.body
.scan_info
.ies_len
= IEsLen
;
3712 msg
.body
.scan_info
.ies
= kmalloc(IEsLen
, GFP_KERNEL
);
3713 memcpy(msg
.body
.scan_info
.ies
, pu8IEs
, IEsLen
);
3715 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3717 PRINT_ER("Error in sending message queue\n");
3721 PRINT_D(HOSTINF_DBG
, ">> Starting the SCAN timer\n");
3722 hif_drv
->scan_timer
.data
= (unsigned long)vif
;
3723 mod_timer(&hif_drv
->scan_timer
,
3724 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3729 s32
wilc_hif_set_cfg(struct wilc_vif
*vif
,
3730 struct cfg_param_val
*pstrCfgParamVal
)
3733 struct host_if_msg msg
;
3734 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3737 PRINT_ER("hif_drv NULL\n");
3741 memset(&msg
, 0, sizeof(struct host_if_msg
));
3742 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3743 msg
.body
.cfg_info
.cfg_attr_info
= *pstrCfgParamVal
;
3746 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3751 static void GetPeriodicRSSI(unsigned long arg
)
3753 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3755 if (!vif
->hif_drv
) {
3756 PRINT_ER("Driver handler is NULL\n");
3760 if (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTED
) {
3762 struct host_if_msg msg
;
3764 memset(&msg
, 0, sizeof(struct host_if_msg
));
3766 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3769 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3771 PRINT_ER("Failed to send get host channel param's message queue ");
3775 periodic_rssi
.data
= (unsigned long)vif
;
3776 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3779 s32
wilc_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
3782 struct host_if_drv
*hif_drv
;
3783 struct wilc_vif
*vif
;
3787 vif
= netdev_priv(dev
);
3790 PRINT_D(HOSTINF_DBG
, "Initializing host interface for client %d\n", clients_count
+ 1);
3792 scan_while_connected
= false;
3794 sema_init(&hif_sema_wait_response
, 0);
3796 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
3801 *hif_drv_handler
= hif_drv
;
3802 for (i
= 0; i
< wilc
->vif_num
; i
++)
3803 if (dev
== wilc
->vif
[i
]->ndev
) {
3804 wilc
->vif
[i
]->hif_drv
= hif_drv
;
3808 wilc_optaining_ip
= false;
3810 PRINT_D(HOSTINF_DBG
, "Global handle pointer value=%p\n", hif_drv
);
3811 if (clients_count
== 0) {
3812 sema_init(&hif_sema_thread
, 0);
3813 sema_init(&hif_sema_driver
, 0);
3814 sema_init(&hif_sema_deinit
, 1);
3817 sema_init(&hif_drv
->sem_test_key_block
, 0);
3818 sema_init(&hif_drv
->sem_test_disconn_block
, 0);
3819 sema_init(&hif_drv
->sem_get_rssi
, 0);
3820 sema_init(&hif_drv
->sem_get_link_speed
, 0);
3821 sema_init(&hif_drv
->sem_get_chnl
, 0);
3822 sema_init(&hif_drv
->sem_inactive_time
, 0);
3824 PRINT_D(HOSTINF_DBG
, "INIT: CLIENT COUNT %d\n", clients_count
);
3826 if (clients_count
== 0) {
3827 result
= wilc_mq_create(&hif_msg_q
);
3830 PRINT_ER("Failed to creat MQ\n");
3834 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
3837 if (IS_ERR(hif_thread_handler
)) {
3838 PRINT_ER("Failed to creat Thread\n");
3842 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
3843 (unsigned long)vif
);
3844 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3847 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
3848 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
3849 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
3851 sema_init(&hif_drv
->sem_cfg_values
, 1);
3852 down(&hif_drv
->sem_cfg_values
);
3854 hif_drv
->hif_state
= HOST_IF_IDLE
;
3855 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
3856 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
3857 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
3858 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
3859 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
3861 hif_drv
->p2p_timeout
= 0;
3863 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",
3864 hif_drv
->cfg_values
.site_survey_enabled
,
3865 hif_drv
->cfg_values
.scan_source
,
3866 hif_drv
->cfg_values
.active_scan_time
,
3867 hif_drv
->cfg_values
.passive_scan_time
,
3868 hif_drv
->cfg_values
.curr_tx_rate
);
3870 up(&hif_drv
->sem_cfg_values
);
3877 wilc_mq_destroy(&hif_msg_q
);
3882 s32
wilc_deinit(struct wilc_vif
*vif
)
3885 struct host_if_msg msg
;
3886 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3889 PRINT_ER("hif_drv = NULL\n");
3893 down(&hif_sema_deinit
);
3895 terminated_handle
= hif_drv
;
3896 PRINT_D(HOSTINF_DBG
, "De-initializing host interface for client %d\n", clients_count
);
3898 if (del_timer_sync(&hif_drv
->scan_timer
))
3899 PRINT_D(HOSTINF_DBG
, ">> Scan timer is active\n");
3901 if (del_timer_sync(&hif_drv
->connect_timer
))
3902 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
3904 if (del_timer_sync(&periodic_rssi
))
3905 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
3907 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
3909 wilc_set_wfi_drv_handler(vif
, 0);
3910 down(&hif_sema_driver
);
3912 if (hif_drv
->usr_scan_req
.scan_result
) {
3913 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
3914 hif_drv
->usr_scan_req
.arg
, NULL
);
3915 hif_drv
->usr_scan_req
.scan_result
= NULL
;
3918 hif_drv
->hif_state
= HOST_IF_IDLE
;
3920 scan_while_connected
= false;
3922 memset(&msg
, 0, sizeof(struct host_if_msg
));
3924 if (clients_count
== 1) {
3925 if (del_timer_sync(&periodic_rssi
))
3926 PRINT_D(HOSTINF_DBG
, ">> Connect timer is active\n");
3928 msg
.id
= HOST_IF_MSG_EXIT
;
3931 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3933 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result
);
3935 down(&hif_sema_thread
);
3937 wilc_mq_destroy(&hif_msg_q
);
3943 terminated_handle
= NULL
;
3944 up(&hif_sema_deinit
);
3948 void wilc_network_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3952 struct host_if_msg msg
;
3954 struct host_if_drv
*hif_drv
= NULL
;
3955 struct wilc_vif
*vif
;
3957 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3958 vif
= wilc_get_vif_from_idx(wilc
, id
);
3961 hif_drv
= vif
->hif_drv
;
3963 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3964 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv
);
3968 memset(&msg
, 0, sizeof(struct host_if_msg
));
3970 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
3973 msg
.body
.net_info
.len
= u32Length
;
3974 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3975 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
3977 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3979 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result
);
3982 void wilc_gnrl_async_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3986 struct host_if_msg msg
;
3988 struct host_if_drv
*hif_drv
= NULL
;
3989 struct wilc_vif
*vif
;
3991 down(&hif_sema_deinit
);
3993 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3994 vif
= wilc_get_vif_from_idx(wilc
, id
);
3996 up(&hif_sema_deinit
);
4000 hif_drv
= vif
->hif_drv
;
4001 PRINT_D(HOSTINF_DBG
, "General asynchronous info packet received\n");
4003 if (!hif_drv
|| hif_drv
== terminated_handle
) {
4004 PRINT_D(HOSTINF_DBG
, "Wifi driver handler is equal to NULL\n");
4005 up(&hif_sema_deinit
);
4009 if (!hif_drv
->usr_conn_req
.conn_result
) {
4010 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
4011 up(&hif_sema_deinit
);
4015 memset(&msg
, 0, sizeof(struct host_if_msg
));
4017 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
4020 msg
.body
.async_info
.len
= u32Length
;
4021 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
4022 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
4024 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4026 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result
);
4028 up(&hif_sema_deinit
);
4031 void wilc_scan_complete_received(struct wilc
*wilc
, u8
*pu8Buffer
,
4035 struct host_if_msg msg
;
4037 struct host_if_drv
*hif_drv
= NULL
;
4038 struct wilc_vif
*vif
;
4040 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
4041 vif
= wilc_get_vif_from_idx(wilc
, id
);
4044 hif_drv
= vif
->hif_drv
;
4046 PRINT_D(GENERIC_DBG
, "Scan notification received %p\n", hif_drv
);
4048 if (!hif_drv
|| hif_drv
== terminated_handle
)
4051 if (hif_drv
->usr_scan_req
.scan_result
) {
4052 memset(&msg
, 0, sizeof(struct host_if_msg
));
4054 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
4057 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4059 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result
);
4065 s32
wilc_remain_on_channel(struct wilc_vif
*vif
, u32 u32SessionID
,
4066 u32 u32duration
, u16 chan
,
4067 wilc_remain_on_chan_expired RemainOnChanExpired
,
4068 wilc_remain_on_chan_ready RemainOnChanReady
,
4072 struct host_if_msg msg
;
4073 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4076 PRINT_ER("driver is null\n");
4080 memset(&msg
, 0, sizeof(struct host_if_msg
));
4082 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
4083 msg
.body
.remain_on_ch
.ch
= chan
;
4084 msg
.body
.remain_on_ch
.expired
= RemainOnChanExpired
;
4085 msg
.body
.remain_on_ch
.ready
= RemainOnChanReady
;
4086 msg
.body
.remain_on_ch
.arg
= pvUserArg
;
4087 msg
.body
.remain_on_ch
.u32duration
= u32duration
;
4088 msg
.body
.remain_on_ch
.id
= u32SessionID
;
4091 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4093 PRINT_ER("wilc mq send fail\n");
4098 s32
wilc_listen_state_expired(struct wilc_vif
*vif
, u32 u32SessionID
)
4101 struct host_if_msg msg
;
4102 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4105 PRINT_ER("driver is null\n");
4109 del_timer(&hif_drv
->remain_on_ch_timer
);
4111 memset(&msg
, 0, sizeof(struct host_if_msg
));
4112 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
4114 msg
.body
.remain_on_ch
.id
= u32SessionID
;
4116 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4118 PRINT_ER("wilc mq send fail\n");
4123 s32
wilc_frame_register(struct wilc_vif
*vif
, u16 u16FrameType
, bool bReg
)
4126 struct host_if_msg msg
;
4127 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4130 PRINT_ER("driver is null\n");
4134 memset(&msg
, 0, sizeof(struct host_if_msg
));
4136 msg
.id
= HOST_IF_MSG_REGISTER_FRAME
;
4137 switch (u16FrameType
) {
4139 PRINT_D(HOSTINF_DBG
, "ACTION\n");
4140 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
4144 PRINT_D(HOSTINF_DBG
, "PROBE REQ\n");
4145 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
4149 PRINT_D(HOSTINF_DBG
, "Not valid frame type\n");
4152 msg
.body
.reg_frame
.frame_type
= u16FrameType
;
4153 msg
.body
.reg_frame
.reg
= bReg
;
4156 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4158 PRINT_ER("wilc mq send fail\n");
4163 s32
wilc_add_beacon(struct wilc_vif
*vif
, u32 u32Interval
, u32 u32DTIMPeriod
,
4164 u32 u32HeadLen
, u8
*pu8Head
, u32 u32TailLen
, u8
*pu8Tail
)
4167 struct host_if_msg msg
;
4168 struct beacon_attr
*pstrSetBeaconParam
= &msg
.body
.beacon_info
;
4169 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4172 PRINT_ER("driver is null\n");
4176 memset(&msg
, 0, sizeof(struct host_if_msg
));
4178 PRINT_D(HOSTINF_DBG
, "Setting adding beacon message queue params\n");
4180 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
4182 pstrSetBeaconParam
->interval
= u32Interval
;
4183 pstrSetBeaconParam
->dtim_period
= u32DTIMPeriod
;
4184 pstrSetBeaconParam
->head_len
= u32HeadLen
;
4185 pstrSetBeaconParam
->head
= kmemdup(pu8Head
, u32HeadLen
, GFP_KERNEL
);
4186 if (!pstrSetBeaconParam
->head
) {
4190 pstrSetBeaconParam
->tail_len
= u32TailLen
;
4192 if (u32TailLen
> 0) {
4193 pstrSetBeaconParam
->tail
= kmemdup(pu8Tail
, u32TailLen
,
4195 if (!pstrSetBeaconParam
->tail
) {
4200 pstrSetBeaconParam
->tail
= NULL
;
4203 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4205 PRINT_ER("wilc mq send fail\n");
4209 kfree(pstrSetBeaconParam
->head
);
4211 kfree(pstrSetBeaconParam
->tail
);
4217 int wilc_del_beacon(struct wilc_vif
*vif
)
4220 struct host_if_msg msg
;
4221 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4224 PRINT_ER("driver is null\n");
4228 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
4230 PRINT_D(HOSTINF_DBG
, "Setting deleting beacon message queue params\n");
4232 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4234 PRINT_ER("wilc_mq_send fail\n");
4239 int wilc_add_station(struct wilc_vif
*vif
, struct add_sta_param
*sta_param
)
4242 struct host_if_msg msg
;
4243 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
4244 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4247 PRINT_ER("driver is null\n");
4251 memset(&msg
, 0, sizeof(struct host_if_msg
));
4253 PRINT_D(HOSTINF_DBG
, "Setting adding station message queue params\n");
4255 msg
.id
= HOST_IF_MSG_ADD_STATION
;
4258 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
4259 if (add_sta_info
->rates_len
> 0) {
4260 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
4261 add_sta_info
->rates_len
,
4263 if (!add_sta_info
->rates
)
4267 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4269 PRINT_ER("wilc_mq_send fail\n");
4273 int wilc_del_station(struct wilc_vif
*vif
, const u8
*mac_addr
)
4276 struct host_if_msg msg
;
4277 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
4278 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4281 PRINT_ER("driver is null\n");
4285 memset(&msg
, 0, sizeof(struct host_if_msg
));
4287 PRINT_D(HOSTINF_DBG
, "Setting deleting station message queue params\n");
4289 msg
.id
= HOST_IF_MSG_DEL_STATION
;
4293 eth_broadcast_addr(del_sta_info
->mac_addr
);
4295 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
4297 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4299 PRINT_ER("wilc_mq_send fail\n");
4303 s32
wilc_del_allstation(struct wilc_vif
*vif
, u8 pu8MacAddr
[][ETH_ALEN
])
4306 struct host_if_msg msg
;
4307 struct del_all_sta
*pstrDelAllStationMsg
= &msg
.body
.del_all_sta_info
;
4308 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4309 u8 au8Zero_Buff
[ETH_ALEN
] = {0};
4314 PRINT_ER("driver is null\n");
4318 memset(&msg
, 0, sizeof(struct host_if_msg
));
4320 PRINT_D(HOSTINF_DBG
, "Setting deauthenticating station message queue params\n");
4322 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
4325 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
4326 if (memcmp(pu8MacAddr
[i
], au8Zero_Buff
, ETH_ALEN
)) {
4327 memcpy(pstrDelAllStationMsg
->del_all_sta
[i
], pu8MacAddr
[i
], ETH_ALEN
);
4328 PRINT_D(CFG80211_DBG
, "BSSID = %x%x%x%x%x%x\n",
4329 pstrDelAllStationMsg
->del_all_sta
[i
][0],
4330 pstrDelAllStationMsg
->del_all_sta
[i
][1],
4331 pstrDelAllStationMsg
->del_all_sta
[i
][2],
4332 pstrDelAllStationMsg
->del_all_sta
[i
][3],
4333 pstrDelAllStationMsg
->del_all_sta
[i
][4],
4334 pstrDelAllStationMsg
->del_all_sta
[i
][5]);
4339 PRINT_D(CFG80211_DBG
, "NO ASSOCIATED STAS\n");
4343 pstrDelAllStationMsg
->assoc_sta
= u8AssocNumb
;
4344 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4347 PRINT_ER("wilc_mq_send fail\n");
4349 down(&hif_sema_wait_response
);
4354 s32
wilc_edit_station(struct wilc_vif
*vif
,
4355 struct add_sta_param
*pstrStaParams
)
4358 struct host_if_msg msg
;
4359 struct add_sta_param
*pstrAddStationMsg
= &msg
.body
.add_sta_info
;
4360 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4363 PRINT_ER("driver is null\n");
4367 PRINT_D(HOSTINF_DBG
, "Setting editing station message queue params\n");
4369 memset(&msg
, 0, sizeof(struct host_if_msg
));
4371 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
4374 memcpy(pstrAddStationMsg
, pstrStaParams
, sizeof(struct add_sta_param
));
4375 if (pstrAddStationMsg
->rates_len
> 0) {
4376 u8
*rates
= kmalloc(pstrAddStationMsg
->rates_len
, GFP_KERNEL
);
4381 memcpy(rates
, pstrStaParams
->rates
,
4382 pstrAddStationMsg
->rates_len
);
4383 pstrAddStationMsg
->rates
= rates
;
4386 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4388 PRINT_ER("wilc_mq_send fail\n");
4393 s32
wilc_set_power_mgmt(struct wilc_vif
*vif
, bool bIsEnabled
, u32 u32Timeout
)
4396 struct host_if_msg msg
;
4397 struct power_mgmt_param
*pstrPowerMgmtParam
= &msg
.body
.pwr_mgmt_info
;
4398 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4400 PRINT_INFO(HOSTINF_DBG
, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled
);
4403 PRINT_ER("driver is null\n");
4407 PRINT_D(HOSTINF_DBG
, "Setting Power management message queue params\n");
4409 memset(&msg
, 0, sizeof(struct host_if_msg
));
4411 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
4414 pstrPowerMgmtParam
->enabled
= bIsEnabled
;
4415 pstrPowerMgmtParam
->timeout
= u32Timeout
;
4417 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4419 PRINT_ER("wilc_mq_send fail\n");
4423 s32
wilc_setup_multicast_filter(struct wilc_vif
*vif
, bool bIsEnabled
,
4427 struct host_if_msg msg
;
4428 struct set_multicast
*pstrMulticastFilterParam
= &msg
.body
.multicast_info
;
4429 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4432 PRINT_ER("driver is null\n");
4436 PRINT_D(HOSTINF_DBG
, "Setting Multicast Filter params\n");
4438 memset(&msg
, 0, sizeof(struct host_if_msg
));
4440 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
4443 pstrMulticastFilterParam
->enabled
= bIsEnabled
;
4444 pstrMulticastFilterParam
->cnt
= u32count
;
4446 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4448 PRINT_ER("wilc_mq_send fail\n");
4452 static void *host_int_ParseJoinBssParam(tstrNetworkInfo
*ptstrNetworkInfo
)
4454 struct join_bss_param
*pNewJoinBssParam
= NULL
;
4463 u8 pcipherTotalCount
= 0;
4464 u8 authTotalCount
= 0;
4467 pu8IEs
= ptstrNetworkInfo
->pu8IEs
;
4468 u16IEsLen
= ptstrNetworkInfo
->u16IEsLen
;
4470 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
4471 if (pNewJoinBssParam
) {
4472 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->u8DtimPeriod
;
4473 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->u16BeaconPeriod
;
4474 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->u16CapInfo
;
4475 memcpy(pNewJoinBssParam
->au8bssid
, ptstrNetworkInfo
->au8bssid
, 6);
4476 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->au8ssid
, ptstrNetworkInfo
->u8SsidLen
+ 1);
4477 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->u8SsidLen
;
4478 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
4479 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
4481 while (index
< u16IEsLen
) {
4482 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
4483 suppRatesNo
= pu8IEs
[index
+ 1];
4484 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
4487 for (i
= 0; i
< suppRatesNo
; i
++)
4488 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
4490 index
+= suppRatesNo
;
4492 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
4493 extSuppRatesNo
= pu8IEs
[index
+ 1];
4494 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
4495 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
4497 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
4499 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
4500 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
4502 index
+= extSuppRatesNo
;
4504 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
4505 pNewJoinBssParam
->ht_capable
= true;
4506 index
+= pu8IEs
[index
+ 1] + 2;
4508 } else if ((pu8IEs
[index
] == WMM_IE
) &&
4509 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
4510 (pu8IEs
[index
+ 4] == 0xF2) &&
4511 (pu8IEs
[index
+ 5] == 0x02) &&
4512 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
4513 (pu8IEs
[index
+ 7] == 0x01)) {
4514 pNewJoinBssParam
->wmm_cap
= true;
4516 if (pu8IEs
[index
+ 8] & BIT(7))
4517 pNewJoinBssParam
->uapsd_cap
= true;
4518 index
+= pu8IEs
[index
+ 1] + 2;
4520 } else if ((pu8IEs
[index
] == P2P_IE
) &&
4521 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
4522 (pu8IEs
[index
+ 4] == 0x9a) &&
4523 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
4526 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->u32Tsf
;
4527 pNewJoinBssParam
->noa_enabled
= 1;
4528 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
4530 if (pu8IEs
[index
+ 10] & BIT(7)) {
4531 pNewJoinBssParam
->opp_enabled
= 1;
4532 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
4534 pNewJoinBssParam
->opp_enabled
= 0;
4537 PRINT_D(GENERIC_DBG
, "P2P Dump\n");
4538 for (i
= 0; i
< pu8IEs
[index
+ 7]; i
++)
4539 PRINT_D(GENERIC_DBG
, " %x\n", pu8IEs
[index
+ 9 + i
]);
4541 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
4542 u16P2P_count
= index
+ 12;
4544 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
4547 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
4550 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
4552 index
+= pu8IEs
[index
+ 1] + 2;
4555 } else if ((pu8IEs
[index
] == RSN_IE
) ||
4556 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
4557 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
4558 (pu8IEs
[index
+ 5] == 0x01))) {
4559 u16 rsnIndex
= index
;
4561 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
4562 pNewJoinBssParam
->mode_802_11i
= 2;
4564 if (pNewJoinBssParam
->mode_802_11i
== 0)
4565 pNewJoinBssParam
->mode_802_11i
= 1;
4570 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4572 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4573 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4576 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4577 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4579 pcipherTotalCount
+= pcipherCount
;
4580 rsnIndex
+= jumpOffset
;
4582 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4584 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4587 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4588 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4590 authTotalCount
+= authCount
;
4591 rsnIndex
+= jumpOffset
;
4593 if (pu8IEs
[index
] == RSN_IE
) {
4594 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4595 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4598 pNewJoinBssParam
->rsn_found
= true;
4599 index
+= pu8IEs
[index
+ 1] + 2;
4602 index
+= pu8IEs
[index
+ 1] + 2;
4606 return (void *)pNewJoinBssParam
;
4609 void wilc_free_join_params(void *pJoinParams
)
4611 if ((struct bss_param
*)pJoinParams
)
4612 kfree((struct bss_param
*)pJoinParams
);
4614 PRINT_ER("Unable to FREE null pointer\n");
4617 s32
wilc_del_all_rx_ba_session(struct wilc_vif
*vif
, char *pBSSID
, char TID
)
4620 struct host_if_msg msg
;
4621 struct ba_session_info
*pBASessionInfo
= &msg
.body
.session_info
;
4622 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4625 PRINT_ER("driver is null\n");
4629 memset(&msg
, 0, sizeof(struct host_if_msg
));
4631 msg
.id
= HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
;
4633 memcpy(pBASessionInfo
->bssid
, pBSSID
, ETH_ALEN
);
4634 pBASessionInfo
->tid
= TID
;
4637 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4639 PRINT_ER("wilc_mq_send fail\n");
4641 down(&hif_sema_wait_response
);
4646 s32
wilc_setup_ipaddress(struct wilc_vif
*vif
, u8
*u16ipadd
, u8 idx
)
4649 struct host_if_msg msg
;
4650 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4655 PRINT_ER("driver is null\n");
4659 memset(&msg
, 0, sizeof(struct host_if_msg
));
4661 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
4663 msg
.body
.ip_info
.ip_addr
= u16ipadd
;
4665 msg
.body
.ip_info
.idx
= idx
;
4667 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4669 PRINT_ER("wilc_mq_send fail\n");
4674 static s32
host_int_get_ipaddress(struct wilc_vif
*vif
,
4675 struct host_if_drv
*hif_drv
,
4676 u8
*u16ipadd
, u8 idx
)
4679 struct host_if_msg msg
;
4682 PRINT_ER("driver is null\n");
4686 memset(&msg
, 0, sizeof(struct host_if_msg
));
4688 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
4690 msg
.body
.ip_info
.ip_addr
= u16ipadd
;
4692 msg
.body
.ip_info
.idx
= idx
;
4694 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4696 PRINT_ER("wilc_mq_send fail\n");