1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include <linux/completion.h>
6 #include "host_interface.h"
7 #include "coreconfigurator.h"
9 #include "wilc_wlan_if.h"
10 #include "wilc_msgqueue.h"
11 #include <linux/etherdevice.h>
12 #include "wilc_wfi_netdevice.h"
14 #define HOST_IF_MSG_SCAN 0
15 #define HOST_IF_MSG_CONNECT 1
16 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
17 #define HOST_IF_MSG_KEY 3
18 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
19 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
20 #define HOST_IF_MSG_CFG_PARAMS 6
21 #define HOST_IF_MSG_SET_CHANNEL 7
22 #define HOST_IF_MSG_DISCONNECT 8
23 #define HOST_IF_MSG_GET_RSSI 9
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_SET_WFIDRV_HANDLER 24
37 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
38 #define HOST_IF_MSG_SET_OPERATION_MODE 27
39 #define HOST_IF_MSG_SET_IPADDRESS 28
40 #define HOST_IF_MSG_GET_IPADDRESS 29
41 #define HOST_IF_MSG_GET_STATISTICS 31
42 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
43 #define HOST_IF_MSG_DEL_BA_SESSION 34
44 #define HOST_IF_MSG_DEL_ALL_STA 36
45 #define HOST_IF_MSG_SET_TX_POWER 38
46 #define HOST_IF_MSG_GET_TX_POWER 39
47 #define HOST_IF_MSG_EXIT 100
49 #define HOST_IF_SCAN_TIMEOUT 4000
50 #define HOST_IF_CONNECT_TIMEOUT 9500
52 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
53 #define BA_SESSION_DEFAULT_TIMEOUT 1000
54 #define BLOCK_ACK_REQ_SIZE 0x14
55 #define FALSE_FRMWR_CHANNEL 100
57 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
58 #define DEFAULT_LINK_SPEED 72
60 struct host_if_wpa_attr
{
70 struct host_if_wep_attr
{
75 enum AUTHTYPE auth_type
;
78 union host_if_key_attr
{
79 struct host_if_wep_attr wep
;
80 struct host_if_wpa_attr wpa
;
81 struct host_if_pmkid_attr pmkid
;
87 union host_if_key_attr attr
;
97 wilc_scan_result result
;
99 struct hidden_network hidden_network
;
102 struct connect_attr
{
109 wilc_connect_result result
;
111 enum AUTHTYPE auth_type
;
116 struct rcvd_async_info
{
121 struct channel_attr
{
134 struct set_multicast
{
140 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
145 u8 mac_addr
[ETH_ALEN
];
148 struct power_mgmt_param
{
158 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
;
191 struct tx_power tx_power
;
196 union message_body body
;
197 struct wilc_vif
*vif
;
200 struct join_bss_param
{
206 char ssid
[MAX_SSID_LEN
];
208 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
215 u8 rsn_pcip_policy
[3];
216 u8 rsn_auth_policy
[3];
229 static struct host_if_drv
*terminated_handle
;
230 bool wilc_optaining_ip
;
231 static u8 P2P_LISTEN_STATE
;
232 static struct task_struct
*hif_thread_handler
;
233 static struct message_queue hif_msg_q
;
234 static struct completion hif_thread_comp
;
235 static struct completion hif_driver_comp
;
236 static struct completion hif_wait_response
;
237 static struct mutex hif_deinit_lock
;
238 static struct timer_list periodic_rssi
;
240 u8 wilc_multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
242 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
244 static bool scan_while_connected
;
247 static u8 set_ip
[2][4];
248 static u8 get_ip
[2][4];
249 static u32 inactive_time
;
250 static u8 del_beacon
;
251 static u32 clients_count
;
254 static u8
*info_element
;
257 static u32 join_req_size
;
258 static u32 info_element_size
;
259 static struct wilc_vif
*join_req_vif
;
260 #define REAL_JOIN_REQ 0
261 #define FLUSHED_JOIN_REQ 1
262 #define FLUSHED_BYTE_POS 79
264 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
);
265 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
);
266 static s32
Handle_ScanDone(struct wilc_vif
*vif
, enum scan_event enuEvent
);
268 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
269 * special purpose in wilc device, so we add 1 to the index to starts from 1.
270 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
272 int wilc_get_vif_idx(struct wilc_vif
*vif
)
277 /* We need to minus 1 from idx which is from wilc device to get real index
278 * of wilc->vif[], because we add 1 when pass to wilc device in the function
280 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
282 static struct wilc_vif
*wilc_get_vif_from_idx(struct wilc
*wilc
, int idx
)
286 if (index
< 0 || index
>= NUM_CONCURRENT_IFC
)
289 return wilc
->vif
[index
];
292 static void handle_set_channel(struct wilc_vif
*vif
,
293 struct channel_attr
*hif_set_ch
)
298 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
300 wid
.val
= (char *)&hif_set_ch
->set_ch
;
301 wid
.size
= sizeof(char);
303 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
304 wilc_get_vif_idx(vif
));
307 netdev_err(vif
->ndev
, "Failed to set channel\n");
310 static void handle_set_wfi_drv_handler(struct wilc_vif
*vif
,
311 struct drv_handler
*hif_drv_handler
)
316 wid
.id
= (u16
)WID_SET_DRV_HANDLER
;
318 wid
.val
= (s8
*)hif_drv_handler
;
319 wid
.size
= sizeof(*hif_drv_handler
);
321 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
322 hif_drv_handler
->handler
);
324 if (!hif_drv_handler
->handler
)
325 complete(&hif_driver_comp
);
328 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
331 static void handle_set_operation_mode(struct wilc_vif
*vif
,
332 struct op_mode
*hif_op_mode
)
337 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
339 wid
.val
= (s8
*)&hif_op_mode
->mode
;
340 wid
.size
= sizeof(u32
);
342 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
343 wilc_get_vif_idx(vif
));
345 if ((hif_op_mode
->mode
) == IDLE_MODE
)
346 complete(&hif_driver_comp
);
349 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
352 static void handle_set_ip_address(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
356 char firmware_ip_addr
[4] = {0};
358 if (ip_addr
[0] < 192)
361 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
363 wid
.id
= (u16
)WID_IP_ADDRESS
;
365 wid
.val
= (u8
*)ip_addr
;
368 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
369 wilc_get_vif_idx(vif
));
371 host_int_get_ipaddress(vif
, firmware_ip_addr
, idx
);
374 netdev_err(vif
->ndev
, "Failed to set IP address\n");
377 static void handle_get_ip_address(struct wilc_vif
*vif
, u8 idx
)
382 wid
.id
= (u16
)WID_IP_ADDRESS
;
384 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
387 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
388 wilc_get_vif_idx(vif
));
390 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
394 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
395 wilc_setup_ipaddress(vif
, set_ip
[idx
], idx
);
398 netdev_err(vif
->ndev
, "Failed to get IP address\n");
401 static s32
handle_get_mac_address(struct wilc_vif
*vif
,
402 struct get_mac_addr
*get_mac_addr
)
407 wid
.id
= (u16
)WID_MAC_ADDR
;
409 wid
.val
= get_mac_addr
->mac_addr
;
412 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
413 wilc_get_vif_idx(vif
));
416 netdev_err(vif
->ndev
, "Failed to get mac address\n");
419 complete(&hif_wait_response
);
424 static s32
handle_cfg_param(struct wilc_vif
*vif
,
425 struct cfg_param_attr
*cfg_param_attr
)
428 struct wid wid_list
[32];
429 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
432 mutex_lock(&hif_drv
->cfg_values_lock
);
434 if (cfg_param_attr
->flag
& BSS_TYPE
) {
435 if (cfg_param_attr
->bss_type
< 6) {
436 wid_list
[i
].id
= WID_BSS_TYPE
;
437 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->bss_type
;
438 wid_list
[i
].type
= WID_CHAR
;
439 wid_list
[i
].size
= sizeof(char);
440 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->bss_type
;
442 netdev_err(vif
->ndev
, "check value 6 over\n");
448 if (cfg_param_attr
->flag
& AUTH_TYPE
) {
449 if (cfg_param_attr
->auth_type
== 1 ||
450 cfg_param_attr
->auth_type
== 2 ||
451 cfg_param_attr
->auth_type
== 5) {
452 wid_list
[i
].id
= WID_AUTH_TYPE
;
453 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_type
;
454 wid_list
[i
].type
= WID_CHAR
;
455 wid_list
[i
].size
= sizeof(char);
456 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->auth_type
;
458 netdev_err(vif
->ndev
, "Impossible value\n");
464 if (cfg_param_attr
->flag
& AUTHEN_TIMEOUT
) {
465 if (cfg_param_attr
->auth_timeout
> 0 &&
466 cfg_param_attr
->auth_timeout
< 65536) {
467 wid_list
[i
].id
= WID_AUTH_TIMEOUT
;
468 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_timeout
;
469 wid_list
[i
].type
= WID_SHORT
;
470 wid_list
[i
].size
= sizeof(u16
);
471 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->auth_timeout
;
473 netdev_err(vif
->ndev
, "Range(1 ~ 65535) over\n");
479 if (cfg_param_attr
->flag
& POWER_MANAGEMENT
) {
480 if (cfg_param_attr
->power_mgmt_mode
< 5) {
481 wid_list
[i
].id
= WID_POWER_MANAGEMENT
;
482 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->power_mgmt_mode
;
483 wid_list
[i
].type
= WID_CHAR
;
484 wid_list
[i
].size
= sizeof(char);
485 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->power_mgmt_mode
;
487 netdev_err(vif
->ndev
, "Invalid power mode\n");
493 if (cfg_param_attr
->flag
& RETRY_SHORT
) {
494 if (cfg_param_attr
->short_retry_limit
> 0 &&
495 cfg_param_attr
->short_retry_limit
< 256) {
496 wid_list
[i
].id
= WID_SHORT_RETRY_LIMIT
;
497 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_retry_limit
;
498 wid_list
[i
].type
= WID_SHORT
;
499 wid_list
[i
].size
= sizeof(u16
);
500 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->short_retry_limit
;
502 netdev_err(vif
->ndev
, "Range(1~256) over\n");
508 if (cfg_param_attr
->flag
& RETRY_LONG
) {
509 if (cfg_param_attr
->long_retry_limit
> 0 &&
510 cfg_param_attr
->long_retry_limit
< 256) {
511 wid_list
[i
].id
= WID_LONG_RETRY_LIMIT
;
512 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->long_retry_limit
;
513 wid_list
[i
].type
= WID_SHORT
;
514 wid_list
[i
].size
= sizeof(u16
);
515 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->long_retry_limit
;
517 netdev_err(vif
->ndev
, "Range(1~256) over\n");
523 if (cfg_param_attr
->flag
& FRAG_THRESHOLD
) {
524 if (cfg_param_attr
->frag_threshold
> 255 &&
525 cfg_param_attr
->frag_threshold
< 7937) {
526 wid_list
[i
].id
= WID_FRAG_THRESHOLD
;
527 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->frag_threshold
;
528 wid_list
[i
].type
= WID_SHORT
;
529 wid_list
[i
].size
= sizeof(u16
);
530 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->frag_threshold
;
532 netdev_err(vif
->ndev
, "Threshold Range fail\n");
538 if (cfg_param_attr
->flag
& RTS_THRESHOLD
) {
539 if (cfg_param_attr
->rts_threshold
> 255 &&
540 cfg_param_attr
->rts_threshold
< 65536) {
541 wid_list
[i
].id
= WID_RTS_THRESHOLD
;
542 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->rts_threshold
;
543 wid_list
[i
].type
= WID_SHORT
;
544 wid_list
[i
].size
= sizeof(u16
);
545 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->rts_threshold
;
547 netdev_err(vif
->ndev
, "Threshold Range fail\n");
553 if (cfg_param_attr
->flag
& PREAMBLE
) {
554 if (cfg_param_attr
->preamble_type
< 3) {
555 wid_list
[i
].id
= WID_PREAMBLE
;
556 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->preamble_type
;
557 wid_list
[i
].type
= WID_CHAR
;
558 wid_list
[i
].size
= sizeof(char);
559 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->preamble_type
;
561 netdev_err(vif
->ndev
, "Preamle Range(0~2) over\n");
567 if (cfg_param_attr
->flag
& SHORT_SLOT_ALLOWED
) {
568 if (cfg_param_attr
->short_slot_allowed
< 2) {
569 wid_list
[i
].id
= WID_SHORT_SLOT_ALLOWED
;
570 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_slot_allowed
;
571 wid_list
[i
].type
= WID_CHAR
;
572 wid_list
[i
].size
= sizeof(char);
573 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->short_slot_allowed
;
575 netdev_err(vif
->ndev
, "Short slot(2) over\n");
581 if (cfg_param_attr
->flag
& TXOP_PROT_DISABLE
) {
582 if (cfg_param_attr
->txop_prot_disabled
< 2) {
583 wid_list
[i
].id
= WID_11N_TXOP_PROT_DISABLE
;
584 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->txop_prot_disabled
;
585 wid_list
[i
].type
= WID_CHAR
;
586 wid_list
[i
].size
= sizeof(char);
587 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->txop_prot_disabled
;
589 netdev_err(vif
->ndev
, "TXOP prot disable\n");
595 if (cfg_param_attr
->flag
& BEACON_INTERVAL
) {
596 if (cfg_param_attr
->beacon_interval
> 0 &&
597 cfg_param_attr
->beacon_interval
< 65536) {
598 wid_list
[i
].id
= WID_BEACON_INTERVAL
;
599 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->beacon_interval
;
600 wid_list
[i
].type
= WID_SHORT
;
601 wid_list
[i
].size
= sizeof(u16
);
602 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->beacon_interval
;
604 netdev_err(vif
->ndev
, "Beacon interval(1~65535)fail\n");
610 if (cfg_param_attr
->flag
& DTIM_PERIOD
) {
611 if (cfg_param_attr
->dtim_period
> 0 &&
612 cfg_param_attr
->dtim_period
< 256) {
613 wid_list
[i
].id
= WID_DTIM_PERIOD
;
614 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->dtim_period
;
615 wid_list
[i
].type
= WID_CHAR
;
616 wid_list
[i
].size
= sizeof(char);
617 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->dtim_period
;
619 netdev_err(vif
->ndev
, "DTIM range(1~255) fail\n");
625 if (cfg_param_attr
->flag
& SITE_SURVEY
) {
626 if (cfg_param_attr
->site_survey_enabled
< 3) {
627 wid_list
[i
].id
= WID_SITE_SURVEY
;
628 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_enabled
;
629 wid_list
[i
].type
= WID_CHAR
;
630 wid_list
[i
].size
= sizeof(char);
631 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->site_survey_enabled
;
633 netdev_err(vif
->ndev
, "Site survey disable\n");
639 if (cfg_param_attr
->flag
& SITE_SURVEY_SCAN_TIME
) {
640 if (cfg_param_attr
->site_survey_scan_time
> 0 &&
641 cfg_param_attr
->site_survey_scan_time
< 65536) {
642 wid_list
[i
].id
= WID_SITE_SURVEY_SCAN_TIME
;
643 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_scan_time
;
644 wid_list
[i
].type
= WID_SHORT
;
645 wid_list
[i
].size
= sizeof(u16
);
646 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->site_survey_scan_time
;
648 netdev_err(vif
->ndev
, "Site scan time(1~65535) over\n");
654 if (cfg_param_attr
->flag
& ACTIVE_SCANTIME
) {
655 if (cfg_param_attr
->active_scan_time
> 0 &&
656 cfg_param_attr
->active_scan_time
< 65536) {
657 wid_list
[i
].id
= WID_ACTIVE_SCAN_TIME
;
658 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->active_scan_time
;
659 wid_list
[i
].type
= WID_SHORT
;
660 wid_list
[i
].size
= sizeof(u16
);
661 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->active_scan_time
;
663 netdev_err(vif
->ndev
, "Active time(1~65535) over\n");
669 if (cfg_param_attr
->flag
& PASSIVE_SCANTIME
) {
670 if (cfg_param_attr
->passive_scan_time
> 0 &&
671 cfg_param_attr
->passive_scan_time
< 65536) {
672 wid_list
[i
].id
= WID_PASSIVE_SCAN_TIME
;
673 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->passive_scan_time
;
674 wid_list
[i
].type
= WID_SHORT
;
675 wid_list
[i
].size
= sizeof(u16
);
676 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->passive_scan_time
;
678 netdev_err(vif
->ndev
, "Passive time(1~65535) over\n");
684 if (cfg_param_attr
->flag
& CURRENT_TX_RATE
) {
685 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->curr_tx_rate
;
687 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
||
688 curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
||
689 curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
||
690 curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
||
691 curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
||
692 curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
||
693 curr_tx_rate
== MBPS_54
) {
694 wid_list
[i
].id
= WID_CURRENT_TX_RATE
;
695 wid_list
[i
].val
= (s8
*)&curr_tx_rate
;
696 wid_list
[i
].type
= WID_SHORT
;
697 wid_list
[i
].size
= sizeof(u16
);
698 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
700 netdev_err(vif
->ndev
, "out of TX rate\n");
707 result
= wilc_send_config_pkt(vif
, SET_CFG
, wid_list
,
708 i
, wilc_get_vif_idx(vif
));
711 netdev_err(vif
->ndev
, "Error in setting CFG params\n");
714 mutex_unlock(&hif_drv
->cfg_values_lock
);
718 static s32
handle_scan(struct wilc_vif
*vif
, struct scan_attr
*scan_info
)
721 struct wid wid_list
[5];
726 u8
*pu8HdnNtwrksWidVal
= NULL
;
727 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
729 hif_drv
->usr_scan_req
.scan_result
= scan_info
->result
;
730 hif_drv
->usr_scan_req
.arg
= scan_info
->arg
;
732 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
733 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
734 netdev_err(vif
->ndev
, "Already scan\n");
739 if (wilc_optaining_ip
|| wilc_connecting
) {
740 netdev_err(vif
->ndev
, "Don't do obss scan\n");
745 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
747 wid_list
[index
].id
= (u16
)WID_SSID_PROBE_REQ
;
748 wid_list
[index
].type
= WID_STR
;
750 for (i
= 0; i
< scan_info
->hidden_network
.n_ssids
; i
++)
751 valuesize
+= ((scan_info
->hidden_network
.net_info
[i
].ssid_len
) + 1);
752 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
753 wid_list
[index
].val
= pu8HdnNtwrksWidVal
;
754 if (wid_list
[index
].val
) {
755 buffer
= wid_list
[index
].val
;
757 *buffer
++ = scan_info
->hidden_network
.n_ssids
;
759 for (i
= 0; i
< scan_info
->hidden_network
.n_ssids
; i
++) {
760 *buffer
++ = scan_info
->hidden_network
.net_info
[i
].ssid_len
;
761 memcpy(buffer
, scan_info
->hidden_network
.net_info
[i
].ssid
, scan_info
->hidden_network
.net_info
[i
].ssid_len
);
762 buffer
+= scan_info
->hidden_network
.net_info
[i
].ssid_len
;
765 wid_list
[index
].size
= (s32
)(valuesize
+ 1);
769 wid_list
[index
].id
= WID_INFO_ELEMENT_PROBE
;
770 wid_list
[index
].type
= WID_BIN_DATA
;
771 wid_list
[index
].val
= scan_info
->ies
;
772 wid_list
[index
].size
= scan_info
->ies_len
;
775 wid_list
[index
].id
= WID_SCAN_TYPE
;
776 wid_list
[index
].type
= WID_CHAR
;
777 wid_list
[index
].size
= sizeof(char);
778 wid_list
[index
].val
= (s8
*)&scan_info
->type
;
781 wid_list
[index
].id
= WID_SCAN_CHANNEL_LIST
;
782 wid_list
[index
].type
= WID_BIN_DATA
;
784 if (scan_info
->ch_freq_list
&&
785 scan_info
->ch_list_len
> 0) {
788 for (i
= 0; i
< scan_info
->ch_list_len
; i
++) {
789 if (scan_info
->ch_freq_list
[i
] > 0)
790 scan_info
->ch_freq_list
[i
] = scan_info
->ch_freq_list
[i
] - 1;
794 wid_list
[index
].val
= scan_info
->ch_freq_list
;
795 wid_list
[index
].size
= scan_info
->ch_list_len
;
798 wid_list
[index
].id
= WID_START_SCAN_REQ
;
799 wid_list
[index
].type
= WID_CHAR
;
800 wid_list
[index
].size
= sizeof(char);
801 wid_list
[index
].val
= (s8
*)&scan_info
->src
;
804 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
805 scan_while_connected
= true;
806 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
807 scan_while_connected
= false;
809 result
= wilc_send_config_pkt(vif
, SET_CFG
, wid_list
,
811 wilc_get_vif_idx(vif
));
814 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
818 del_timer(&hif_drv
->scan_timer
);
819 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
822 kfree(scan_info
->ch_freq_list
);
823 scan_info
->ch_freq_list
= NULL
;
825 kfree(scan_info
->ies
);
826 scan_info
->ies
= NULL
;
827 kfree(scan_info
->hidden_network
.net_info
);
828 scan_info
->hidden_network
.net_info
= NULL
;
830 kfree(pu8HdnNtwrksWidVal
);
835 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
836 enum scan_event enuEvent
)
839 u8 u8abort_running_scan
;
841 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
843 if (enuEvent
== SCAN_EVENT_ABORTED
) {
844 u8abort_running_scan
= 1;
845 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
847 wid
.val
= (s8
*)&u8abort_running_scan
;
848 wid
.size
= sizeof(char);
850 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
851 wilc_get_vif_idx(vif
));
854 netdev_err(vif
->ndev
, "Failed to set abort running\n");
860 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
864 if (hif_drv
->usr_scan_req
.scan_result
) {
865 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
866 hif_drv
->usr_scan_req
.arg
, NULL
);
867 hif_drv
->usr_scan_req
.scan_result
= NULL
;
873 u8 wilc_connected_ssid
[6] = {0};
874 static s32
Handle_Connect(struct wilc_vif
*vif
,
875 struct connect_attr
*pstrHostIFconnectAttr
)
878 struct wid strWIDList
[8];
879 u32 u32WidsCount
= 0, dummyval
= 0;
880 u8
*pu8CurrByte
= NULL
;
881 struct join_bss_param
*ptstrJoinBssParam
;
882 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
884 if (memcmp(pstrHostIFconnectAttr
->bssid
, wilc_connected_ssid
, ETH_ALEN
) == 0) {
886 netdev_err(vif
->ndev
, "Discard connect request\n");
890 ptstrJoinBssParam
= pstrHostIFconnectAttr
->params
;
891 if (!ptstrJoinBssParam
) {
892 netdev_err(vif
->ndev
, "Required BSSID not found\n");
897 if (pstrHostIFconnectAttr
->bssid
) {
898 hif_drv
->usr_conn_req
.bssid
= kmalloc(6, GFP_KERNEL
);
899 memcpy(hif_drv
->usr_conn_req
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
902 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
903 if (pstrHostIFconnectAttr
->ssid
) {
904 hif_drv
->usr_conn_req
.ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
905 memcpy(hif_drv
->usr_conn_req
.ssid
,
906 pstrHostIFconnectAttr
->ssid
,
907 pstrHostIFconnectAttr
->ssid_len
);
908 hif_drv
->usr_conn_req
.ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
911 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
912 if (pstrHostIFconnectAttr
->ies
) {
913 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
914 memcpy(hif_drv
->usr_conn_req
.ies
,
915 pstrHostIFconnectAttr
->ies
,
916 pstrHostIFconnectAttr
->ies_len
);
919 hif_drv
->usr_conn_req
.security
= pstrHostIFconnectAttr
->security
;
920 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
921 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
922 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
924 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
925 strWIDList
[u32WidsCount
].type
= WID_INT
;
926 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
927 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
930 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
931 strWIDList
[u32WidsCount
].type
= WID_INT
;
932 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
933 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
936 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
937 strWIDList
[u32WidsCount
].type
= WID_INT
;
938 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
939 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
943 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
944 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
945 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
946 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
949 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
950 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
951 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
952 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
956 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
957 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
958 strWIDList
[u32WidsCount
].size
= sizeof(char);
959 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.security
;
962 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
963 mode_11i
= hif_drv
->usr_conn_req
.security
;
965 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
966 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
967 strWIDList
[u32WidsCount
].size
= sizeof(char);
968 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
971 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
972 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
974 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
975 strWIDList
[u32WidsCount
].type
= WID_STR
;
976 strWIDList
[u32WidsCount
].size
= 112;
977 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
979 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
980 join_req_size
= strWIDList
[u32WidsCount
].size
;
981 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
983 if (!strWIDList
[u32WidsCount
].val
) {
988 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
990 if (pstrHostIFconnectAttr
->ssid
) {
991 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
992 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
994 pu8CurrByte
+= MAX_SSID_LEN
;
995 *(pu8CurrByte
++) = INFRASTRUCTURE
;
997 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
998 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1000 netdev_err(vif
->ndev
, "Channel out of range\n");
1001 *(pu8CurrByte
++) = 0xFF;
1003 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1004 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1006 if (pstrHostIFconnectAttr
->bssid
)
1007 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1010 if (pstrHostIFconnectAttr
->bssid
)
1011 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1014 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1015 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1016 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1018 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1019 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1021 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1022 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1024 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1025 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1027 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1028 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1029 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1031 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1032 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1034 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1035 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1037 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1038 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1040 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1041 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1043 if (ptstrJoinBssParam
->noa_enabled
) {
1044 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1045 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1046 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1047 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1049 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1050 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1052 if (ptstrJoinBssParam
->opp_enabled
)
1053 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1055 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1057 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1058 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1060 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1061 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1063 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1064 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1067 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1070 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1071 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1075 if (pstrHostIFconnectAttr
->bssid
)
1076 memcpy(wilc_connected_ssid
,
1077 pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1079 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1081 wilc_get_vif_idx(vif
));
1083 netdev_err(vif
->ndev
, "failed to send config packet\n");
1087 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1092 struct connect_info strConnectInfo
;
1094 del_timer(&hif_drv
->connect_timer
);
1096 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1098 if (pstrHostIFconnectAttr
->result
) {
1099 if (pstrHostIFconnectAttr
->bssid
)
1100 memcpy(strConnectInfo
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1102 if (pstrHostIFconnectAttr
->ies
) {
1103 strConnectInfo
.req_ies_len
= pstrHostIFconnectAttr
->ies_len
;
1104 strConnectInfo
.req_ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1105 memcpy(strConnectInfo
.req_ies
,
1106 pstrHostIFconnectAttr
->ies
,
1107 pstrHostIFconnectAttr
->ies_len
);
1110 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1114 pstrHostIFconnectAttr
->arg
);
1115 hif_drv
->hif_state
= HOST_IF_IDLE
;
1116 kfree(strConnectInfo
.req_ies
);
1117 strConnectInfo
.req_ies
= NULL
;
1120 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1124 kfree(pstrHostIFconnectAttr
->bssid
);
1125 pstrHostIFconnectAttr
->bssid
= NULL
;
1127 kfree(pstrHostIFconnectAttr
->ssid
);
1128 pstrHostIFconnectAttr
->ssid
= NULL
;
1130 kfree(pstrHostIFconnectAttr
->ies
);
1131 pstrHostIFconnectAttr
->ies
= NULL
;
1137 static s32
Handle_ConnectTimeout(struct wilc_vif
*vif
)
1140 struct connect_info strConnectInfo
;
1142 u16 u16DummyReasonCode
= 0;
1143 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1146 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1150 hif_drv
->hif_state
= HOST_IF_IDLE
;
1152 scan_while_connected
= false;
1154 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1156 if (hif_drv
->usr_conn_req
.conn_result
) {
1157 if (hif_drv
->usr_conn_req
.bssid
) {
1158 memcpy(strConnectInfo
.bssid
,
1159 hif_drv
->usr_conn_req
.bssid
, 6);
1162 if (hif_drv
->usr_conn_req
.ies
) {
1163 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1164 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1165 memcpy(strConnectInfo
.req_ies
,
1166 hif_drv
->usr_conn_req
.ies
,
1167 hif_drv
->usr_conn_req
.ies_len
);
1170 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1174 hif_drv
->usr_conn_req
.arg
);
1176 kfree(strConnectInfo
.req_ies
);
1177 strConnectInfo
.req_ies
= NULL
;
1179 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1182 wid
.id
= (u16
)WID_DISCONNECT
;
1183 wid
.type
= WID_CHAR
;
1184 wid
.val
= (s8
*)&u16DummyReasonCode
;
1185 wid
.size
= sizeof(char);
1187 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1188 wilc_get_vif_idx(vif
));
1190 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1192 hif_drv
->usr_conn_req
.ssid_len
= 0;
1193 kfree(hif_drv
->usr_conn_req
.ssid
);
1194 hif_drv
->usr_conn_req
.ssid
= NULL
;
1195 kfree(hif_drv
->usr_conn_req
.bssid
);
1196 hif_drv
->usr_conn_req
.bssid
= NULL
;
1197 hif_drv
->usr_conn_req
.ies_len
= 0;
1198 kfree(hif_drv
->usr_conn_req
.ies
);
1199 hif_drv
->usr_conn_req
.ies
= NULL
;
1201 eth_zero_addr(wilc_connected_ssid
);
1203 if (join_req
&& join_req_vif
== vif
) {
1208 if (info_element
&& join_req_vif
== vif
) {
1209 kfree(info_element
);
1210 info_element
= NULL
;
1216 static s32
Handle_RcvdNtwrkInfo(struct wilc_vif
*vif
,
1217 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1220 bool bNewNtwrkFound
;
1222 struct network_info
*pstrNetworkInfo
= NULL
;
1223 void *pJoinParams
= NULL
;
1224 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1226 bNewNtwrkFound
= true;
1228 if (hif_drv
->usr_scan_req
.scan_result
) {
1229 wilc_parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1230 if ((!pstrNetworkInfo
) ||
1231 (!hif_drv
->usr_scan_req
.scan_result
)) {
1232 netdev_err(vif
->ndev
, "driver is null\n");
1237 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1238 if ((hif_drv
->usr_scan_req
.net_info
[i
].bssid
) &&
1239 (pstrNetworkInfo
->bssid
)) {
1240 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].bssid
,
1241 pstrNetworkInfo
->bssid
, 6) == 0) {
1242 if (pstrNetworkInfo
->rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].rssi
) {
1245 hif_drv
->usr_scan_req
.net_info
[i
].rssi
= pstrNetworkInfo
->rssi
;
1246 bNewNtwrkFound
= false;
1253 if (bNewNtwrkFound
) {
1254 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1255 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].rssi
= pstrNetworkInfo
->rssi
;
1257 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
&&
1258 pstrNetworkInfo
->bssid
) {
1259 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
,
1260 pstrNetworkInfo
->bssid
, 6);
1262 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1264 pstrNetworkInfo
->new_network
= true;
1265 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1267 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1268 hif_drv
->usr_scan_req
.arg
,
1273 pstrNetworkInfo
->new_network
= false;
1274 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1275 hif_drv
->usr_scan_req
.arg
, NULL
);
1280 kfree(pstrRcvdNetworkInfo
->buffer
);
1281 pstrRcvdNetworkInfo
->buffer
= NULL
;
1283 if (pstrNetworkInfo
) {
1284 kfree(pstrNetworkInfo
->ies
);
1285 kfree(pstrNetworkInfo
);
1291 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
1292 u8
*pu8AssocRespInfo
,
1293 u32 u32MaxAssocRespInfoLen
,
1294 u32
*pu32RcvdAssocRespInfoLen
);
1296 static s32
Handle_RcvdGnrlAsyncInfo(struct wilc_vif
*vif
,
1297 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1303 u16 u16WidID
= (u16
)WID_NIL
;
1306 u8 u8MacStatusReasonCode
;
1307 u8 u8MacStatusAdditionalInfo
;
1308 struct connect_info strConnectInfo
;
1309 struct disconnect_info strDisconnectNotifInfo
;
1311 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1314 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1318 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1319 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1320 hif_drv
->usr_scan_req
.scan_result
) {
1321 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1322 !hif_drv
->usr_conn_req
.conn_result
) {
1323 netdev_err(vif
->ndev
, "driver is null\n");
1327 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1329 if ('I' != u8MsgType
) {
1330 netdev_err(vif
->ndev
, "Received Message incorrect.\n");
1334 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1335 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1336 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1337 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1338 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1339 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1340 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1341 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1342 u32 u32RcvdAssocRespInfoLen
= 0;
1343 struct connect_resp_info
*pstrConnectRespInfo
= NULL
;
1345 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1347 if (u8MacStatus
== MAC_CONNECTED
) {
1348 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1350 host_int_get_assoc_res_info(vif
,
1352 MAX_ASSOC_RESP_FRAME_SIZE
,
1353 &u32RcvdAssocRespInfoLen
);
1355 if (u32RcvdAssocRespInfoLen
!= 0) {
1356 s32Err
= wilc_parse_assoc_resp_info(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1357 &pstrConnectRespInfo
);
1359 netdev_err(vif
->ndev
, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err
);
1361 strConnectInfo
.status
= pstrConnectRespInfo
->status
;
1363 if (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
) {
1364 if (pstrConnectRespInfo
->ies
) {
1365 strConnectInfo
.resp_ies_len
= pstrConnectRespInfo
->ies_len
;
1366 strConnectInfo
.resp_ies
= kmalloc(pstrConnectRespInfo
->ies_len
, GFP_KERNEL
);
1367 memcpy(strConnectInfo
.resp_ies
, pstrConnectRespInfo
->ies
,
1368 pstrConnectRespInfo
->ies_len
);
1372 if (pstrConnectRespInfo
) {
1373 kfree(pstrConnectRespInfo
->ies
);
1374 kfree(pstrConnectRespInfo
);
1380 if ((u8MacStatus
== MAC_CONNECTED
) &&
1381 (strConnectInfo
.status
!= SUCCESSFUL_STATUSCODE
)) {
1382 netdev_err(vif
->ndev
, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1383 eth_zero_addr(wilc_connected_ssid
);
1384 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1385 netdev_err(vif
->ndev
, "Received MAC status is MAC_DISCONNECTED\n");
1386 eth_zero_addr(wilc_connected_ssid
);
1389 if (hif_drv
->usr_conn_req
.bssid
) {
1390 memcpy(strConnectInfo
.bssid
, hif_drv
->usr_conn_req
.bssid
, 6);
1392 if ((u8MacStatus
== MAC_CONNECTED
) &&
1393 (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
)) {
1394 memcpy(hif_drv
->assoc_bssid
,
1395 hif_drv
->usr_conn_req
.bssid
, ETH_ALEN
);
1399 if (hif_drv
->usr_conn_req
.ies
) {
1400 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1401 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1402 memcpy(strConnectInfo
.req_ies
,
1403 hif_drv
->usr_conn_req
.ies
,
1404 hif_drv
->usr_conn_req
.ies_len
);
1407 del_timer(&hif_drv
->connect_timer
);
1408 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1412 hif_drv
->usr_conn_req
.arg
);
1414 if ((u8MacStatus
== MAC_CONNECTED
) &&
1415 (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
)) {
1416 wilc_set_power_mgmt(vif
, 0, 0);
1418 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1420 wilc_optaining_ip
= true;
1421 mod_timer(&wilc_during_ip_timer
,
1422 jiffies
+ msecs_to_jiffies(10000));
1424 hif_drv
->hif_state
= HOST_IF_IDLE
;
1425 scan_while_connected
= false;
1428 kfree(strConnectInfo
.resp_ies
);
1429 strConnectInfo
.resp_ies
= NULL
;
1431 kfree(strConnectInfo
.req_ies
);
1432 strConnectInfo
.req_ies
= NULL
;
1433 hif_drv
->usr_conn_req
.ssid_len
= 0;
1434 kfree(hif_drv
->usr_conn_req
.ssid
);
1435 hif_drv
->usr_conn_req
.ssid
= NULL
;
1436 kfree(hif_drv
->usr_conn_req
.bssid
);
1437 hif_drv
->usr_conn_req
.bssid
= NULL
;
1438 hif_drv
->usr_conn_req
.ies_len
= 0;
1439 kfree(hif_drv
->usr_conn_req
.ies
);
1440 hif_drv
->usr_conn_req
.ies
= NULL
;
1441 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1442 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1443 memset(&strDisconnectNotifInfo
, 0, sizeof(struct disconnect_info
));
1445 if (hif_drv
->usr_scan_req
.scan_result
) {
1446 del_timer(&hif_drv
->scan_timer
);
1447 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1450 strDisconnectNotifInfo
.reason
= 0;
1451 strDisconnectNotifInfo
.ie
= NULL
;
1452 strDisconnectNotifInfo
.ie_len
= 0;
1454 if (hif_drv
->usr_conn_req
.conn_result
) {
1455 wilc_optaining_ip
= false;
1456 wilc_set_power_mgmt(vif
, 0, 0);
1458 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1461 &strDisconnectNotifInfo
,
1462 hif_drv
->usr_conn_req
.arg
);
1464 netdev_err(vif
->ndev
, "Connect result NULL\n");
1467 eth_zero_addr(hif_drv
->assoc_bssid
);
1469 hif_drv
->usr_conn_req
.ssid_len
= 0;
1470 kfree(hif_drv
->usr_conn_req
.ssid
);
1471 hif_drv
->usr_conn_req
.ssid
= NULL
;
1472 kfree(hif_drv
->usr_conn_req
.bssid
);
1473 hif_drv
->usr_conn_req
.bssid
= NULL
;
1474 hif_drv
->usr_conn_req
.ies_len
= 0;
1475 kfree(hif_drv
->usr_conn_req
.ies
);
1476 hif_drv
->usr_conn_req
.ies
= NULL
;
1478 if (join_req
&& join_req_vif
== vif
) {
1483 if (info_element
&& join_req_vif
== vif
) {
1484 kfree(info_element
);
1485 info_element
= NULL
;
1488 hif_drv
->hif_state
= HOST_IF_IDLE
;
1489 scan_while_connected
= false;
1491 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1492 (hif_drv
->usr_scan_req
.scan_result
)) {
1493 del_timer(&hif_drv
->scan_timer
);
1494 if (hif_drv
->usr_scan_req
.scan_result
)
1495 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1499 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1500 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1505 static int Handle_Key(struct wilc_vif
*vif
,
1506 struct key_attr
*pstrHostIFkeyAttr
)
1510 struct wid strWIDList
[5];
1515 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1517 switch (pstrHostIFkeyAttr
->type
) {
1520 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1521 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1522 strWIDList
[0].type
= WID_CHAR
;
1523 strWIDList
[0].size
= sizeof(char);
1524 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1526 strWIDList
[1].id
= WID_AUTH_TYPE
;
1527 strWIDList
[1].type
= WID_CHAR
;
1528 strWIDList
[1].size
= sizeof(char);
1529 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1531 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2,
1536 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1537 pu8keybuf
[1] = pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1539 memcpy(&pu8keybuf
[2], pstrHostIFkeyAttr
->attr
.wep
.key
,
1540 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1542 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1544 strWIDList
[2].id
= (u16
)WID_WEP_KEY_VALUE
;
1545 strWIDList
[2].type
= WID_STR
;
1546 strWIDList
[2].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1547 strWIDList
[2].val
= (s8
*)pu8keybuf
;
1549 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1551 wilc_get_vif_idx(vif
));
1553 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1554 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1557 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1558 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1559 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1560 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1561 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1563 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1565 wid
.val
= (s8
*)pu8keybuf
;
1566 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1568 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1570 wilc_get_vif_idx(vif
));
1572 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1573 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1576 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1577 wid
.val
= s8idxarray
;
1580 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1582 wilc_get_vif_idx(vif
));
1583 } else if (pstrHostIFkeyAttr
->action
& DEFAULTKEY
) {
1584 wid
.id
= (u16
)WID_KEY_ID
;
1585 wid
.type
= WID_CHAR
;
1586 wid
.val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1587 wid
.size
= sizeof(char);
1589 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1591 wilc_get_vif_idx(vif
));
1593 complete(&hif_drv
->comp_test_key_block
);
1597 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1598 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1601 goto _WPARxGtk_end_case_
;
1604 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1605 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1607 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1608 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1609 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1610 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1612 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1613 strWIDList
[0].type
= WID_CHAR
;
1614 strWIDList
[0].size
= sizeof(char);
1615 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1617 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1618 strWIDList
[1].type
= WID_STR
;
1619 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1620 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1622 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1624 wilc_get_vif_idx(vif
));
1627 complete(&hif_drv
->comp_test_key_block
);
1628 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1629 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1632 goto _WPARxGtk_end_case_
;
1635 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
1636 memcpy(pu8keybuf
, hif_drv
->assoc_bssid
, ETH_ALEN
);
1638 netdev_err(vif
->ndev
, "Couldn't handle\n");
1640 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1641 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1642 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1643 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1644 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1646 wid
.id
= (u16
)WID_ADD_RX_GTK
;
1648 wid
.val
= (s8
*)pu8keybuf
;
1649 wid
.size
= RX_MIC_KEY_MSG_LEN
;
1651 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1653 wilc_get_vif_idx(vif
));
1656 complete(&hif_drv
->comp_test_key_block
);
1658 _WPARxGtk_end_case_
:
1659 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1660 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1667 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1668 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1671 goto _WPAPtk_end_case_
;
1674 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1675 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1676 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1677 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1678 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1680 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1681 strWIDList
[0].type
= WID_CHAR
;
1682 strWIDList
[0].size
= sizeof(char);
1683 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1685 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1686 strWIDList
[1].type
= WID_STR
;
1687 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1688 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1690 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1692 wilc_get_vif_idx(vif
));
1694 complete(&hif_drv
->comp_test_key_block
);
1695 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1696 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1698 netdev_err(vif
->ndev
, "No buffer send PTK\n");
1700 goto _WPAPtk_end_case_
;
1703 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1704 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1705 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1706 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1708 wid
.id
= (u16
)WID_ADD_PTK
;
1710 wid
.val
= (s8
*)pu8keybuf
;
1711 wid
.size
= PTK_KEY_MSG_LEN
;
1713 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1715 wilc_get_vif_idx(vif
));
1717 complete(&hif_drv
->comp_test_key_block
);
1721 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1728 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1730 netdev_err(vif
->ndev
, "No buffer to send PMKSA Key\n");
1734 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1736 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1737 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1738 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1741 wid
.id
= (u16
)WID_PMKID_INFO
;
1743 wid
.val
= (s8
*)pu8keybuf
;
1744 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1746 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1747 wilc_get_vif_idx(vif
));
1754 netdev_err(vif
->ndev
, "Failed to send key config packet\n");
1759 static void Handle_Disconnect(struct wilc_vif
*vif
)
1762 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1765 u16 u16DummyReasonCode
= 0;
1767 wid
.id
= (u16
)WID_DISCONNECT
;
1768 wid
.type
= WID_CHAR
;
1769 wid
.val
= (s8
*)&u16DummyReasonCode
;
1770 wid
.size
= sizeof(char);
1772 wilc_optaining_ip
= false;
1773 wilc_set_power_mgmt(vif
, 0, 0);
1775 eth_zero_addr(wilc_connected_ssid
);
1777 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1778 wilc_get_vif_idx(vif
));
1781 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1783 struct disconnect_info strDisconnectNotifInfo
;
1785 memset(&strDisconnectNotifInfo
, 0, sizeof(struct disconnect_info
));
1787 strDisconnectNotifInfo
.reason
= 0;
1788 strDisconnectNotifInfo
.ie
= NULL
;
1789 strDisconnectNotifInfo
.ie_len
= 0;
1791 if (hif_drv
->usr_scan_req
.scan_result
) {
1792 del_timer(&hif_drv
->scan_timer
);
1793 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
1795 hif_drv
->usr_scan_req
.arg
,
1797 hif_drv
->usr_scan_req
.scan_result
= NULL
;
1800 if (hif_drv
->usr_conn_req
.conn_result
) {
1801 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
)
1802 del_timer(&hif_drv
->connect_timer
);
1804 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1807 &strDisconnectNotifInfo
,
1808 hif_drv
->usr_conn_req
.arg
);
1810 netdev_err(vif
->ndev
, "conn_result = NULL\n");
1813 scan_while_connected
= false;
1815 hif_drv
->hif_state
= HOST_IF_IDLE
;
1817 eth_zero_addr(hif_drv
->assoc_bssid
);
1819 hif_drv
->usr_conn_req
.ssid_len
= 0;
1820 kfree(hif_drv
->usr_conn_req
.ssid
);
1821 hif_drv
->usr_conn_req
.ssid
= NULL
;
1822 kfree(hif_drv
->usr_conn_req
.bssid
);
1823 hif_drv
->usr_conn_req
.bssid
= NULL
;
1824 hif_drv
->usr_conn_req
.ies_len
= 0;
1825 kfree(hif_drv
->usr_conn_req
.ies
);
1826 hif_drv
->usr_conn_req
.ies
= NULL
;
1828 if (join_req
&& join_req_vif
== vif
) {
1833 if (info_element
&& join_req_vif
== vif
) {
1834 kfree(info_element
);
1835 info_element
= NULL
;
1839 complete(&hif_drv
->comp_test_disconn_block
);
1842 void wilc_resolve_disconnect_aberration(struct wilc_vif
*vif
)
1846 if ((vif
->hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1847 (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTING
))
1848 wilc_disconnect(vif
, 1);
1851 static void Handle_GetRssi(struct wilc_vif
*vif
)
1856 wid
.id
= (u16
)WID_RSSI
;
1857 wid
.type
= WID_CHAR
;
1859 wid
.size
= sizeof(char);
1861 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1862 wilc_get_vif_idx(vif
));
1864 netdev_err(vif
->ndev
, "Failed to get RSSI value\n");
1868 complete(&vif
->hif_drv
->comp_get_rssi
);
1871 static s32
Handle_GetStatistics(struct wilc_vif
*vif
,
1872 struct rf_info
*pstrStatistics
)
1874 struct wid strWIDList
[5];
1875 u32 u32WidsCount
= 0, result
= 0;
1877 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
1878 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1879 strWIDList
[u32WidsCount
].size
= sizeof(char);
1880 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
1883 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
1884 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1885 strWIDList
[u32WidsCount
].size
= sizeof(char);
1886 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
1889 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
1890 strWIDList
[u32WidsCount
].type
= WID_INT
;
1891 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1892 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
1895 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
1896 strWIDList
[u32WidsCount
].type
= WID_INT
;
1897 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1898 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
1901 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
1902 strWIDList
[u32WidsCount
].type
= WID_INT
;
1903 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1904 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
1907 result
= wilc_send_config_pkt(vif
, GET_CFG
, strWIDList
,
1909 wilc_get_vif_idx(vif
));
1912 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
1914 if (pstrStatistics
->link_speed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
&&
1915 pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
1916 wilc_enable_tcp_ack_filter(true);
1917 else if (pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
1918 wilc_enable_tcp_ack_filter(false);
1920 if (pstrStatistics
!= &vif
->wilc
->dummy_statistics
)
1921 complete(&hif_wait_response
);
1925 static s32
Handle_Get_InActiveTime(struct wilc_vif
*vif
,
1926 struct sta_inactive_t
*strHostIfStaInactiveT
)
1931 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1933 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
1935 wid
.size
= ETH_ALEN
;
1936 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
1939 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
1941 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1942 wilc_get_vif_idx(vif
));
1945 netdev_err(vif
->ndev
, "Failed to SET incative time\n");
1949 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
1951 wid
.val
= (s8
*)&inactive_time
;
1952 wid
.size
= sizeof(u32
);
1954 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1955 wilc_get_vif_idx(vif
));
1958 netdev_err(vif
->ndev
, "Failed to get incative time\n");
1962 complete(&hif_drv
->comp_inactive_time
);
1967 static void Handle_AddBeacon(struct wilc_vif
*vif
,
1968 struct beacon_attr
*pstrSetBeaconParam
)
1974 wid
.id
= (u16
)WID_ADD_BEACON
;
1976 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
1977 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
1981 pu8CurrByte
= wid
.val
;
1982 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
1983 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
1984 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
1985 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
1987 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
1988 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
1989 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
1990 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
1992 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
1993 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
1994 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
1995 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
1997 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
1998 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2000 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2001 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2002 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2003 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2005 if (pstrSetBeaconParam
->tail
)
2006 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2007 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2009 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2010 wilc_get_vif_idx(vif
));
2012 netdev_err(vif
->ndev
, "Failed to send add beacon\n");
2016 kfree(pstrSetBeaconParam
->head
);
2017 kfree(pstrSetBeaconParam
->tail
);
2020 static void Handle_DelBeacon(struct wilc_vif
*vif
)
2026 wid
.id
= (u16
)WID_DEL_BEACON
;
2027 wid
.type
= WID_CHAR
;
2028 wid
.size
= sizeof(char);
2029 wid
.val
= &del_beacon
;
2034 pu8CurrByte
= wid
.val
;
2036 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2037 wilc_get_vif_idx(vif
));
2039 netdev_err(vif
->ndev
, "Failed to send delete beacon\n");
2042 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2043 struct add_sta_param
*pstrStationParam
)
2047 pu8CurrByte
= pu8Buffer
;
2049 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2050 pu8CurrByte
+= ETH_ALEN
;
2052 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2053 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2055 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2056 if (pstrStationParam
->rates_len
> 0)
2057 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2058 pstrStationParam
->rates_len
);
2059 pu8CurrByte
+= pstrStationParam
->rates_len
;
2061 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2062 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2063 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2065 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2066 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2067 WILC_SUPP_MCS_SET_SIZE
);
2068 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2070 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2071 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2073 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2074 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2075 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2076 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2078 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2080 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2081 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2083 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2084 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2086 return pu8CurrByte
- pu8Buffer
;
2089 static void Handle_AddStation(struct wilc_vif
*vif
,
2090 struct add_sta_param
*pstrStationParam
)
2096 wid
.id
= (u16
)WID_ADD_STA
;
2098 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2100 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2104 pu8CurrByte
= wid
.val
;
2105 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2107 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2108 wilc_get_vif_idx(vif
));
2110 netdev_err(vif
->ndev
, "Failed to send add station\n");
2113 kfree(pstrStationParam
->rates
);
2117 static void Handle_DelAllSta(struct wilc_vif
*vif
,
2118 struct del_all_sta
*pstrDelAllStaParam
)
2124 u8 au8Zero_Buff
[6] = {0};
2126 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2128 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2130 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2134 pu8CurrByte
= wid
.val
;
2136 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2138 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2139 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2140 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2144 pu8CurrByte
+= ETH_ALEN
;
2147 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2148 wilc_get_vif_idx(vif
));
2150 netdev_err(vif
->ndev
, "Failed to send add station\n");
2155 complete(&hif_wait_response
);
2158 static void Handle_DelStation(struct wilc_vif
*vif
,
2159 struct del_sta
*pstrDelStaParam
)
2165 wid
.id
= (u16
)WID_REMOVE_STA
;
2167 wid
.size
= ETH_ALEN
;
2169 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2173 pu8CurrByte
= wid
.val
;
2175 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2177 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2178 wilc_get_vif_idx(vif
));
2180 netdev_err(vif
->ndev
, "Failed to send add station\n");
2186 static void Handle_EditStation(struct wilc_vif
*vif
,
2187 struct add_sta_param
*pstrStationParam
)
2193 wid
.id
= (u16
)WID_EDIT_STA
;
2195 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2197 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2201 pu8CurrByte
= wid
.val
;
2202 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2204 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2205 wilc_get_vif_idx(vif
));
2207 netdev_err(vif
->ndev
, "Failed to send edit station\n");
2210 kfree(pstrStationParam
->rates
);
2214 static int Handle_RemainOnChan(struct wilc_vif
*vif
,
2215 struct remain_ch
*pstrHostIfRemainOnChan
)
2218 u8 u8remain_on_chan_flag
;
2220 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2222 if (!hif_drv
->remain_on_ch_pending
) {
2223 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2224 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2225 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2226 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2227 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2229 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2232 if (hif_drv
->usr_scan_req
.scan_result
) {
2233 hif_drv
->remain_on_ch_pending
= 1;
2237 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2242 if (wilc_optaining_ip
|| wilc_connecting
) {
2247 u8remain_on_chan_flag
= true;
2248 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2251 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2257 wid
.val
[0] = u8remain_on_chan_flag
;
2258 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2260 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2261 wilc_get_vif_idx(vif
));
2263 netdev_err(vif
->ndev
, "Failed to set remain on channel\n");
2267 P2P_LISTEN_STATE
= 1;
2268 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)vif
;
2269 mod_timer(&hif_drv
->remain_on_ch_timer
,
2271 msecs_to_jiffies(pstrHostIfRemainOnChan
->duration
));
2273 if (hif_drv
->remain_on_ch
.ready
)
2274 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2276 if (hif_drv
->remain_on_ch_pending
)
2277 hif_drv
->remain_on_ch_pending
= 0;
2283 static int Handle_RegisterFrame(struct wilc_vif
*vif
,
2284 struct reg_frame
*pstrHostIfRegisterFrame
)
2290 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2292 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2296 pu8CurrByte
= wid
.val
;
2298 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2299 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2300 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2302 wid
.size
= sizeof(u16
) + 2;
2304 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2305 wilc_get_vif_idx(vif
));
2307 netdev_err(vif
->ndev
, "Failed to frame register\n");
2314 static u32
Handle_ListenStateExpired(struct wilc_vif
*vif
,
2315 struct remain_ch
*pstrHostIfRemainOnChan
)
2317 u8 u8remain_on_chan_flag
;
2320 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2322 if (P2P_LISTEN_STATE
) {
2323 u8remain_on_chan_flag
= false;
2324 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2327 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2330 netdev_err(vif
->ndev
, "Failed to allocate memory\n");
2334 wid
.val
[0] = u8remain_on_chan_flag
;
2335 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2337 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2338 wilc_get_vif_idx(vif
));
2340 netdev_err(vif
->ndev
, "Failed to set remain channel\n");
2344 if (hif_drv
->remain_on_ch
.expired
) {
2345 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2346 pstrHostIfRemainOnChan
->id
);
2348 P2P_LISTEN_STATE
= 0;
2350 netdev_dbg(vif
->ndev
, "Not in listen state\n");
2358 static void ListenTimerCB(unsigned long arg
)
2361 struct host_if_msg msg
;
2362 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2364 del_timer(&vif
->hif_drv
->remain_on_ch_timer
);
2366 memset(&msg
, 0, sizeof(struct host_if_msg
));
2367 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2369 msg
.body
.remain_on_ch
.id
= vif
->hif_drv
->remain_on_ch
.id
;
2371 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2373 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
2376 static void Handle_PowerManagement(struct wilc_vif
*vif
,
2377 struct power_mgmt_param
*strPowerMgmtParam
)
2383 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2385 if (strPowerMgmtParam
->enabled
)
2386 s8PowerMode
= MIN_FAST_PS
;
2388 s8PowerMode
= NO_POWERSAVE
;
2390 wid
.val
= &s8PowerMode
;
2391 wid
.size
= sizeof(char);
2393 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2394 wilc_get_vif_idx(vif
));
2396 netdev_err(vif
->ndev
, "Failed to send power management\n");
2399 static void Handle_SetMulticastFilter(struct wilc_vif
*vif
,
2400 struct set_multicast
*strHostIfSetMulti
)
2406 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2408 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2409 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2413 pu8CurrByte
= wid
.val
;
2414 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2419 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2420 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2421 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2422 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2424 if ((strHostIfSetMulti
->cnt
) > 0)
2425 memcpy(pu8CurrByte
, wilc_multicast_mac_addr_list
,
2426 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2428 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2429 wilc_get_vif_idx(vif
));
2431 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2437 static void handle_set_tx_pwr(struct wilc_vif
*vif
, u8 tx_pwr
)
2442 wid
.id
= (u16
)WID_TX_POWER
;
2443 wid
.type
= WID_CHAR
;
2445 wid
.size
= sizeof(char);
2447 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2448 wilc_get_vif_idx(vif
));
2450 netdev_err(vif
->ndev
, "Failed to set TX PWR\n");
2453 static void handle_get_tx_pwr(struct wilc_vif
*vif
, u8
*tx_pwr
)
2458 wid
.id
= (u16
)WID_TX_POWER
;
2459 wid
.type
= WID_CHAR
;
2460 wid
.val
= (s8
*)tx_pwr
;
2461 wid
.size
= sizeof(char);
2463 ret
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2464 wilc_get_vif_idx(vif
));
2466 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
2468 complete(&hif_wait_response
);
2471 static int hostIFthread(void *pvArg
)
2474 struct host_if_msg msg
;
2475 struct wilc
*wilc
= pvArg
;
2476 struct wilc_vif
*vif
;
2478 memset(&msg
, 0, sizeof(struct host_if_msg
));
2481 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2483 if (msg
.id
== HOST_IF_MSG_EXIT
)
2486 if ((!wilc_initialized
)) {
2487 usleep_range(200 * 1000, 200 * 1000);
2488 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2492 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2493 vif
->hif_drv
->usr_scan_req
.scan_result
) {
2494 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2495 usleep_range(2 * 1000, 2 * 1000);
2500 case HOST_IF_MSG_SCAN
:
2501 handle_scan(msg
.vif
, &msg
.body
.scan_info
);
2504 case HOST_IF_MSG_CONNECT
:
2505 Handle_Connect(msg
.vif
, &msg
.body
.con_info
);
2508 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2509 Handle_RcvdNtwrkInfo(msg
.vif
, &msg
.body
.net_info
);
2512 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2513 Handle_RcvdGnrlAsyncInfo(vif
,
2514 &msg
.body
.async_info
);
2517 case HOST_IF_MSG_KEY
:
2518 Handle_Key(msg
.vif
, &msg
.body
.key_info
);
2521 case HOST_IF_MSG_CFG_PARAMS
:
2522 handle_cfg_param(msg
.vif
, &msg
.body
.cfg_info
);
2525 case HOST_IF_MSG_SET_CHANNEL
:
2526 handle_set_channel(msg
.vif
, &msg
.body
.channel_info
);
2529 case HOST_IF_MSG_DISCONNECT
:
2530 Handle_Disconnect(msg
.vif
);
2533 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2534 del_timer(&vif
->hif_drv
->scan_timer
);
2536 if (!wilc_wlan_get_num_conn_ifcs(wilc
))
2537 wilc_chip_sleep_manually(wilc
);
2539 Handle_ScanDone(msg
.vif
, SCAN_EVENT_DONE
);
2541 if (vif
->hif_drv
->remain_on_ch_pending
)
2542 Handle_RemainOnChan(msg
.vif
,
2543 &msg
.body
.remain_on_ch
);
2547 case HOST_IF_MSG_GET_RSSI
:
2548 Handle_GetRssi(msg
.vif
);
2551 case HOST_IF_MSG_GET_STATISTICS
:
2552 Handle_GetStatistics(msg
.vif
,
2553 (struct rf_info
*)msg
.body
.data
);
2556 case HOST_IF_MSG_ADD_BEACON
:
2557 Handle_AddBeacon(msg
.vif
, &msg
.body
.beacon_info
);
2560 case HOST_IF_MSG_DEL_BEACON
:
2561 Handle_DelBeacon(msg
.vif
);
2564 case HOST_IF_MSG_ADD_STATION
:
2565 Handle_AddStation(msg
.vif
, &msg
.body
.add_sta_info
);
2568 case HOST_IF_MSG_DEL_STATION
:
2569 Handle_DelStation(msg
.vif
, &msg
.body
.del_sta_info
);
2572 case HOST_IF_MSG_EDIT_STATION
:
2573 Handle_EditStation(msg
.vif
, &msg
.body
.edit_sta_info
);
2576 case HOST_IF_MSG_GET_INACTIVETIME
:
2577 Handle_Get_InActiveTime(msg
.vif
, &msg
.body
.mac_info
);
2580 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2582 Handle_ScanDone(msg
.vif
, SCAN_EVENT_ABORTED
);
2585 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2586 Handle_ConnectTimeout(msg
.vif
);
2589 case HOST_IF_MSG_POWER_MGMT
:
2590 Handle_PowerManagement(msg
.vif
,
2591 &msg
.body
.pwr_mgmt_info
);
2594 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2595 handle_set_wfi_drv_handler(msg
.vif
, &msg
.body
.drv
);
2598 case HOST_IF_MSG_SET_OPERATION_MODE
:
2599 handle_set_operation_mode(msg
.vif
, &msg
.body
.mode
);
2602 case HOST_IF_MSG_SET_IPADDRESS
:
2603 handle_set_ip_address(vif
,
2604 msg
.body
.ip_info
.ip_addr
,
2605 msg
.body
.ip_info
.idx
);
2608 case HOST_IF_MSG_GET_IPADDRESS
:
2609 handle_get_ip_address(vif
, msg
.body
.ip_info
.idx
);
2612 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2613 handle_get_mac_address(msg
.vif
,
2614 &msg
.body
.get_mac_info
);
2617 case HOST_IF_MSG_REMAIN_ON_CHAN
:
2618 Handle_RemainOnChan(msg
.vif
, &msg
.body
.remain_on_ch
);
2621 case HOST_IF_MSG_REGISTER_FRAME
:
2622 Handle_RegisterFrame(msg
.vif
, &msg
.body
.reg_frame
);
2625 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
2626 Handle_ListenStateExpired(msg
.vif
, &msg
.body
.remain_on_ch
);
2629 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
2630 Handle_SetMulticastFilter(msg
.vif
, &msg
.body
.multicast_info
);
2633 case HOST_IF_MSG_DEL_ALL_STA
:
2634 Handle_DelAllSta(msg
.vif
, &msg
.body
.del_all_sta_info
);
2637 case HOST_IF_MSG_SET_TX_POWER
:
2638 handle_set_tx_pwr(msg
.vif
, msg
.body
.tx_power
.tx_pwr
);
2641 case HOST_IF_MSG_GET_TX_POWER
:
2642 handle_get_tx_pwr(msg
.vif
, &msg
.body
.tx_power
.tx_pwr
);
2645 netdev_err(vif
->ndev
, "[Host Interface] undefined\n");
2650 complete(&hif_thread_comp
);
2654 static void TimerCB_Scan(unsigned long arg
)
2656 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2657 struct host_if_msg msg
;
2659 memset(&msg
, 0, sizeof(struct host_if_msg
));
2661 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
2663 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2666 static void TimerCB_Connect(unsigned long arg
)
2668 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2669 struct host_if_msg msg
;
2671 memset(&msg
, 0, sizeof(struct host_if_msg
));
2673 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
2675 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2678 s32
wilc_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
2682 wid
.id
= (u16
)WID_REMOVE_KEY
;
2684 wid
.val
= (s8
*)pu8StaAddress
;
2690 int wilc_remove_wep_key(struct wilc_vif
*vif
, u8 index
)
2693 struct host_if_msg msg
;
2694 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2698 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2702 memset(&msg
, 0, sizeof(struct host_if_msg
));
2704 msg
.id
= HOST_IF_MSG_KEY
;
2705 msg
.body
.key_info
.type
= WEP
;
2706 msg
.body
.key_info
.action
= REMOVEKEY
;
2708 msg
.body
.key_info
.attr
.wep
.index
= index
;
2710 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2712 netdev_err(vif
->ndev
, "Request to remove WEP key\n");
2714 wait_for_completion(&hif_drv
->comp_test_key_block
);
2719 int wilc_set_wep_default_keyid(struct wilc_vif
*vif
, u8 index
)
2722 struct host_if_msg msg
;
2723 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2727 netdev_err(vif
->ndev
, "driver is null\n");
2731 memset(&msg
, 0, sizeof(struct host_if_msg
));
2733 msg
.id
= HOST_IF_MSG_KEY
;
2734 msg
.body
.key_info
.type
= WEP
;
2735 msg
.body
.key_info
.action
= DEFAULTKEY
;
2737 msg
.body
.key_info
.attr
.wep
.index
= index
;
2739 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2741 netdev_err(vif
->ndev
, "Default key index\n");
2743 wait_for_completion(&hif_drv
->comp_test_key_block
);
2748 int wilc_add_wep_key_bss_sta(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2752 struct host_if_msg msg
;
2753 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2756 netdev_err(vif
->ndev
, "driver is null\n");
2760 memset(&msg
, 0, sizeof(struct host_if_msg
));
2762 msg
.id
= HOST_IF_MSG_KEY
;
2763 msg
.body
.key_info
.type
= WEP
;
2764 msg
.body
.key_info
.action
= ADDKEY
;
2766 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2767 if (!msg
.body
.key_info
.attr
.wep
.key
)
2770 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2771 msg
.body
.key_info
.attr
.wep
.index
= index
;
2773 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2775 netdev_err(vif
->ndev
, "STA - WEP Key\n");
2776 wait_for_completion(&hif_drv
->comp_test_key_block
);
2781 int wilc_add_wep_key_bss_ap(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2782 u8 index
, u8 mode
, enum AUTHTYPE auth_type
)
2785 struct host_if_msg msg
;
2786 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2789 netdev_err(vif
->ndev
, "driver is null\n");
2793 memset(&msg
, 0, sizeof(struct host_if_msg
));
2795 msg
.id
= HOST_IF_MSG_KEY
;
2796 msg
.body
.key_info
.type
= WEP
;
2797 msg
.body
.key_info
.action
= ADDKEY_AP
;
2799 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2800 if (!msg
.body
.key_info
.attr
.wep
.key
)
2803 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2804 msg
.body
.key_info
.attr
.wep
.index
= index
;
2805 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
2806 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
2808 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2811 netdev_err(vif
->ndev
, "AP - WEP Key\n");
2813 wait_for_completion(&hif_drv
->comp_test_key_block
);
2818 int wilc_add_ptk(struct wilc_vif
*vif
, const u8
*ptk
, u8 ptk_key_len
,
2819 const u8
*mac_addr
, const u8
*rx_mic
, const u8
*tx_mic
,
2820 u8 mode
, u8 cipher_mode
, u8 index
)
2823 struct host_if_msg msg
;
2824 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2825 u8 key_len
= ptk_key_len
;
2828 netdev_err(vif
->ndev
, "driver is null\n");
2833 key_len
+= RX_MIC_KEY_LEN
;
2836 key_len
+= TX_MIC_KEY_LEN
;
2838 memset(&msg
, 0, sizeof(struct host_if_msg
));
2840 msg
.id
= HOST_IF_MSG_KEY
;
2841 msg
.body
.key_info
.type
= WPA_PTK
;
2842 if (mode
== AP_MODE
) {
2843 msg
.body
.key_info
.action
= ADDKEY_AP
;
2844 msg
.body
.key_info
.attr
.wpa
.index
= index
;
2846 if (mode
== STATION_MODE
)
2847 msg
.body
.key_info
.action
= ADDKEY
;
2849 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
2850 if (!msg
.body
.key_info
.attr
.wpa
.key
)
2854 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
2857 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
2859 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
2860 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
2861 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
2864 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2867 netdev_err(vif
->ndev
, "PTK Key\n");
2869 wait_for_completion(&hif_drv
->comp_test_key_block
);
2874 int wilc_add_rx_gtk(struct wilc_vif
*vif
, const u8
*rx_gtk
, u8 gtk_key_len
,
2875 u8 index
, u32 key_rsc_len
, const u8
*key_rsc
,
2876 const u8
*rx_mic
, const u8
*tx_mic
, u8 mode
,
2880 struct host_if_msg msg
;
2881 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2882 u8 key_len
= gtk_key_len
;
2885 netdev_err(vif
->ndev
, "driver is null\n");
2888 memset(&msg
, 0, sizeof(struct host_if_msg
));
2891 key_len
+= RX_MIC_KEY_LEN
;
2894 key_len
+= TX_MIC_KEY_LEN
;
2897 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
2900 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
2904 msg
.id
= HOST_IF_MSG_KEY
;
2905 msg
.body
.key_info
.type
= WPA_RX_GTK
;
2908 if (mode
== AP_MODE
) {
2909 msg
.body
.key_info
.action
= ADDKEY_AP
;
2910 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
2912 if (mode
== STATION_MODE
)
2913 msg
.body
.key_info
.action
= ADDKEY
;
2915 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
2918 if (!msg
.body
.key_info
.attr
.wpa
.key
)
2922 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
2926 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
2929 msg
.body
.key_info
.attr
.wpa
.index
= index
;
2930 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
2931 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
2933 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2935 netdev_err(vif
->ndev
, "RX GTK\n");
2937 wait_for_completion(&hif_drv
->comp_test_key_block
);
2942 int wilc_set_pmkid_info(struct wilc_vif
*vif
,
2943 struct host_if_pmkid_attr
*pmkid
)
2946 struct host_if_msg msg
;
2949 memset(&msg
, 0, sizeof(struct host_if_msg
));
2951 msg
.id
= HOST_IF_MSG_KEY
;
2952 msg
.body
.key_info
.type
= PMKSA
;
2953 msg
.body
.key_info
.action
= ADDKEY
;
2956 for (i
= 0; i
< pmkid
->numpmkid
; i
++) {
2957 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
2958 &pmkid
->pmkidlist
[i
].bssid
, ETH_ALEN
);
2959 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
2960 &pmkid
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
2963 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2965 netdev_err(vif
->ndev
, "PMKID Info\n");
2970 int wilc_get_mac_address(struct wilc_vif
*vif
, u8
*mac_addr
)
2973 struct host_if_msg msg
;
2975 memset(&msg
, 0, sizeof(struct host_if_msg
));
2977 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
2978 msg
.body
.get_mac_info
.mac_addr
= mac_addr
;
2981 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2983 netdev_err(vif
->ndev
, "Failed to send get mac address\n");
2987 wait_for_completion(&hif_wait_response
);
2991 int wilc_set_join_req(struct wilc_vif
*vif
, u8
*bssid
, const u8
*ssid
,
2992 size_t ssid_len
, const u8
*ies
, size_t ies_len
,
2993 wilc_connect_result connect_result
, void *user_arg
,
2994 u8 security
, enum AUTHTYPE auth_type
,
2995 u8 channel
, void *join_params
)
2998 struct host_if_msg msg
;
2999 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3001 if (!hif_drv
|| !connect_result
) {
3002 netdev_err(vif
->ndev
, "Driver is null\n");
3007 netdev_err(vif
->ndev
, "Unable to Join - JoinParams is NULL\n");
3011 memset(&msg
, 0, sizeof(struct host_if_msg
));
3013 msg
.id
= HOST_IF_MSG_CONNECT
;
3015 msg
.body
.con_info
.security
= security
;
3016 msg
.body
.con_info
.auth_type
= auth_type
;
3017 msg
.body
.con_info
.ch
= channel
;
3018 msg
.body
.con_info
.result
= connect_result
;
3019 msg
.body
.con_info
.arg
= user_arg
;
3020 msg
.body
.con_info
.params
= join_params
;
3024 msg
.body
.con_info
.bssid
= kmemdup(bssid
, 6, GFP_KERNEL
);
3025 if (!msg
.body
.con_info
.bssid
)
3030 msg
.body
.con_info
.ssid_len
= ssid_len
;
3031 msg
.body
.con_info
.ssid
= kmemdup(ssid
, ssid_len
, GFP_KERNEL
);
3032 if (!msg
.body
.con_info
.ssid
)
3037 msg
.body
.con_info
.ies_len
= ies_len
;
3038 msg
.body
.con_info
.ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3039 if (!msg
.body
.con_info
.ies
)
3042 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3043 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3045 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3047 netdev_err(vif
->ndev
, "send message: Set join request\n");
3051 hif_drv
->connect_timer
.data
= (unsigned long)vif
;
3052 mod_timer(&hif_drv
->connect_timer
,
3053 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3058 int wilc_disconnect(struct wilc_vif
*vif
, u16 reason_code
)
3061 struct host_if_msg msg
;
3062 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3065 netdev_err(vif
->ndev
, "Driver is null\n");
3069 memset(&msg
, 0, sizeof(struct host_if_msg
));
3071 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3074 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3076 netdev_err(vif
->ndev
, "Failed to send message: disconnect\n");
3078 wait_for_completion(&hif_drv
->comp_test_disconn_block
);
3083 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
3084 u8
*pu8AssocRespInfo
,
3085 u32 u32MaxAssocRespInfoLen
,
3086 u32
*pu32RcvdAssocRespInfoLen
)
3091 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3093 wid
.val
= pu8AssocRespInfo
;
3094 wid
.size
= u32MaxAssocRespInfoLen
;
3096 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
3097 wilc_get_vif_idx(vif
));
3099 *pu32RcvdAssocRespInfoLen
= 0;
3100 netdev_err(vif
->ndev
, "Failed to send association response\n");
3104 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3108 int wilc_set_mac_chnl_num(struct wilc_vif
*vif
, u8 channel
)
3111 struct host_if_msg msg
;
3113 memset(&msg
, 0, sizeof(struct host_if_msg
));
3114 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3115 msg
.body
.channel_info
.set_ch
= channel
;
3118 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3120 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3127 int wilc_set_wfi_drv_handler(struct wilc_vif
*vif
, int index
, u8 mac_idx
)
3130 struct host_if_msg msg
;
3132 memset(&msg
, 0, sizeof(struct host_if_msg
));
3133 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3134 msg
.body
.drv
.handler
= index
;
3135 msg
.body
.drv
.mac_idx
= mac_idx
;
3138 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3140 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3147 int wilc_set_operation_mode(struct wilc_vif
*vif
, u32 mode
)
3150 struct host_if_msg msg
;
3152 memset(&msg
, 0, sizeof(struct host_if_msg
));
3153 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3154 msg
.body
.mode
.mode
= mode
;
3157 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3159 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3166 s32
wilc_get_inactive_time(struct wilc_vif
*vif
, const u8
*mac
,
3167 u32
*pu32InactiveTime
)
3170 struct host_if_msg msg
;
3171 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3174 netdev_err(vif
->ndev
, "driver is null\n");
3178 memset(&msg
, 0, sizeof(struct host_if_msg
));
3179 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3181 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3184 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3186 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3188 wait_for_completion(&hif_drv
->comp_inactive_time
);
3190 *pu32InactiveTime
= inactive_time
;
3195 int wilc_get_rssi(struct wilc_vif
*vif
, s8
*rssi_level
)
3198 struct host_if_msg msg
;
3199 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3201 memset(&msg
, 0, sizeof(struct host_if_msg
));
3202 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3205 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3207 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3211 wait_for_completion(&hif_drv
->comp_get_rssi
);
3214 netdev_err(vif
->ndev
, "RSS pointer value is null\n");
3223 int wilc_get_statistics(struct wilc_vif
*vif
, struct rf_info
*stats
)
3226 struct host_if_msg msg
;
3228 memset(&msg
, 0, sizeof(struct host_if_msg
));
3229 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3230 msg
.body
.data
= (char *)stats
;
3233 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3235 netdev_err(vif
->ndev
, "Failed to send get host channel\n");
3239 if (stats
!= &vif
->wilc
->dummy_statistics
)
3240 wait_for_completion(&hif_wait_response
);
3244 int wilc_scan(struct wilc_vif
*vif
, u8 scan_source
, u8 scan_type
,
3245 u8
*ch_freq_list
, u8 ch_list_len
, const u8
*ies
,
3246 size_t ies_len
, wilc_scan_result scan_result
, void *user_arg
,
3247 struct hidden_network
*hidden_network
)
3250 struct host_if_msg msg
;
3251 struct scan_attr
*scan_info
= &msg
.body
.scan_info
;
3252 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3254 if (!hif_drv
|| !scan_result
) {
3255 netdev_err(vif
->ndev
, "hif_drv or scan_result = NULL\n");
3259 memset(&msg
, 0, sizeof(struct host_if_msg
));
3261 msg
.id
= HOST_IF_MSG_SCAN
;
3263 if (hidden_network
) {
3264 scan_info
->hidden_network
.net_info
= hidden_network
->net_info
;
3265 scan_info
->hidden_network
.n_ssids
= hidden_network
->n_ssids
;
3269 scan_info
->src
= scan_source
;
3270 scan_info
->type
= scan_type
;
3271 scan_info
->result
= scan_result
;
3272 scan_info
->arg
= user_arg
;
3274 scan_info
->ch_list_len
= ch_list_len
;
3275 scan_info
->ch_freq_list
= kmemdup(ch_freq_list
,
3278 if (!scan_info
->ch_freq_list
)
3281 scan_info
->ies_len
= ies_len
;
3282 scan_info
->ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3283 if (!scan_info
->ies
)
3286 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3288 netdev_err(vif
->ndev
, "Error in sending message queue\n");
3292 hif_drv
->scan_timer
.data
= (unsigned long)vif
;
3293 mod_timer(&hif_drv
->scan_timer
,
3294 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3299 int wilc_hif_set_cfg(struct wilc_vif
*vif
,
3300 struct cfg_param_attr
*cfg_param
)
3303 struct host_if_msg msg
;
3304 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3307 netdev_err(vif
->ndev
, "hif_drv NULL\n");
3311 memset(&msg
, 0, sizeof(struct host_if_msg
));
3312 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3313 msg
.body
.cfg_info
= *cfg_param
;
3316 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3321 static void GetPeriodicRSSI(unsigned long arg
)
3323 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3325 if (!vif
->hif_drv
) {
3326 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
3330 if (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTED
)
3331 wilc_get_statistics(vif
, &vif
->wilc
->dummy_statistics
);
3333 periodic_rssi
.data
= (unsigned long)vif
;
3334 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3337 int wilc_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
3340 struct host_if_drv
*hif_drv
;
3341 struct wilc_vif
*vif
;
3345 vif
= netdev_priv(dev
);
3348 scan_while_connected
= false;
3350 init_completion(&hif_wait_response
);
3352 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
3357 *hif_drv_handler
= hif_drv
;
3358 for (i
= 0; i
< wilc
->vif_num
; i
++)
3359 if (dev
== wilc
->vif
[i
]->ndev
) {
3360 wilc
->vif
[i
]->hif_drv
= hif_drv
;
3364 wilc_optaining_ip
= false;
3366 if (clients_count
== 0) {
3367 init_completion(&hif_thread_comp
);
3368 init_completion(&hif_driver_comp
);
3369 mutex_init(&hif_deinit_lock
);
3372 init_completion(&hif_drv
->comp_test_key_block
);
3373 init_completion(&hif_drv
->comp_test_disconn_block
);
3374 init_completion(&hif_drv
->comp_get_rssi
);
3375 init_completion(&hif_drv
->comp_inactive_time
);
3377 if (clients_count
== 0) {
3378 result
= wilc_mq_create(&hif_msg_q
);
3381 netdev_err(vif
->ndev
, "Failed to creat MQ\n");
3385 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
3388 if (IS_ERR(hif_thread_handler
)) {
3389 netdev_err(vif
->ndev
, "Failed to creat Thread\n");
3393 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
3394 (unsigned long)vif
);
3395 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3398 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
3399 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
3400 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
3402 mutex_init(&hif_drv
->cfg_values_lock
);
3403 mutex_lock(&hif_drv
->cfg_values_lock
);
3405 hif_drv
->hif_state
= HOST_IF_IDLE
;
3406 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
3407 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
3408 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
3409 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
3410 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
3412 hif_drv
->p2p_timeout
= 0;
3414 mutex_unlock(&hif_drv
->cfg_values_lock
);
3421 wilc_mq_destroy(&hif_msg_q
);
3426 int wilc_deinit(struct wilc_vif
*vif
)
3429 struct host_if_msg msg
;
3430 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3433 netdev_err(vif
->ndev
, "hif_drv = NULL\n");
3437 mutex_lock(&hif_deinit_lock
);
3439 terminated_handle
= hif_drv
;
3441 del_timer_sync(&hif_drv
->scan_timer
);
3442 del_timer_sync(&hif_drv
->connect_timer
);
3443 del_timer_sync(&periodic_rssi
);
3444 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
3446 wilc_set_wfi_drv_handler(vif
, 0, 0);
3447 wait_for_completion(&hif_driver_comp
);
3449 if (hif_drv
->usr_scan_req
.scan_result
) {
3450 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
3451 hif_drv
->usr_scan_req
.arg
, NULL
);
3452 hif_drv
->usr_scan_req
.scan_result
= NULL
;
3455 hif_drv
->hif_state
= HOST_IF_IDLE
;
3457 scan_while_connected
= false;
3459 memset(&msg
, 0, sizeof(struct host_if_msg
));
3461 if (clients_count
== 1) {
3462 msg
.id
= HOST_IF_MSG_EXIT
;
3465 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3467 netdev_err(vif
->ndev
, "deinit : Error(%d)\n", result
);
3469 wait_for_completion(&hif_thread_comp
);
3471 wilc_mq_destroy(&hif_msg_q
);
3477 terminated_handle
= NULL
;
3478 mutex_unlock(&hif_deinit_lock
);
3482 void wilc_network_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3486 struct host_if_msg msg
;
3488 struct host_if_drv
*hif_drv
= NULL
;
3489 struct wilc_vif
*vif
;
3491 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3492 vif
= wilc_get_vif_from_idx(wilc
, id
);
3495 hif_drv
= vif
->hif_drv
;
3497 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3498 netdev_err(vif
->ndev
, "driver not init[%p]\n", hif_drv
);
3502 memset(&msg
, 0, sizeof(struct host_if_msg
));
3504 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
3507 msg
.body
.net_info
.len
= u32Length
;
3508 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3509 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
3511 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3513 netdev_err(vif
->ndev
, "message parameters (%d)\n", result
);
3516 void wilc_gnrl_async_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3520 struct host_if_msg msg
;
3522 struct host_if_drv
*hif_drv
= NULL
;
3523 struct wilc_vif
*vif
;
3525 mutex_lock(&hif_deinit_lock
);
3527 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3528 vif
= wilc_get_vif_from_idx(wilc
, id
);
3530 mutex_unlock(&hif_deinit_lock
);
3534 hif_drv
= vif
->hif_drv
;
3536 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3537 mutex_unlock(&hif_deinit_lock
);
3541 if (!hif_drv
->usr_conn_req
.conn_result
) {
3542 netdev_err(vif
->ndev
, "there is no current Connect Request\n");
3543 mutex_unlock(&hif_deinit_lock
);
3547 memset(&msg
, 0, sizeof(struct host_if_msg
));
3549 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
3552 msg
.body
.async_info
.len
= u32Length
;
3553 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3554 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
3556 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3558 netdev_err(vif
->ndev
, "synchronous info (%d)\n", result
);
3560 mutex_unlock(&hif_deinit_lock
);
3563 void wilc_scan_complete_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3567 struct host_if_msg msg
;
3569 struct host_if_drv
*hif_drv
= NULL
;
3570 struct wilc_vif
*vif
;
3572 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3573 vif
= wilc_get_vif_from_idx(wilc
, id
);
3576 hif_drv
= vif
->hif_drv
;
3578 if (!hif_drv
|| hif_drv
== terminated_handle
)
3581 if (hif_drv
->usr_scan_req
.scan_result
) {
3582 memset(&msg
, 0, sizeof(struct host_if_msg
));
3584 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
3587 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3589 netdev_err(vif
->ndev
, "complete param (%d)\n", result
);
3593 int wilc_remain_on_channel(struct wilc_vif
*vif
, u32 session_id
,
3594 u32 duration
, u16 chan
,
3595 wilc_remain_on_chan_expired expired
,
3596 wilc_remain_on_chan_ready ready
,
3600 struct host_if_msg msg
;
3602 memset(&msg
, 0, sizeof(struct host_if_msg
));
3604 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
3605 msg
.body
.remain_on_ch
.ch
= chan
;
3606 msg
.body
.remain_on_ch
.expired
= expired
;
3607 msg
.body
.remain_on_ch
.ready
= ready
;
3608 msg
.body
.remain_on_ch
.arg
= user_arg
;
3609 msg
.body
.remain_on_ch
.duration
= duration
;
3610 msg
.body
.remain_on_ch
.id
= session_id
;
3613 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3615 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3620 int wilc_listen_state_expired(struct wilc_vif
*vif
, u32 session_id
)
3623 struct host_if_msg msg
;
3624 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3627 netdev_err(vif
->ndev
, "driver is null\n");
3631 del_timer(&hif_drv
->remain_on_ch_timer
);
3633 memset(&msg
, 0, sizeof(struct host_if_msg
));
3634 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3636 msg
.body
.remain_on_ch
.id
= session_id
;
3638 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3640 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3645 int wilc_frame_register(struct wilc_vif
*vif
, u16 frame_type
, bool reg
)
3648 struct host_if_msg msg
;
3650 memset(&msg
, 0, sizeof(struct host_if_msg
));
3652 msg
.id
= HOST_IF_MSG_REGISTER_FRAME
;
3653 switch (frame_type
) {
3655 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
3659 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
3665 msg
.body
.reg_frame
.frame_type
= frame_type
;
3666 msg
.body
.reg_frame
.reg
= reg
;
3669 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3671 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3676 int wilc_add_beacon(struct wilc_vif
*vif
, u32 interval
, u32 dtim_period
,
3677 u32 head_len
, u8
*head
, u32 tail_len
, u8
*tail
)
3680 struct host_if_msg msg
;
3681 struct beacon_attr
*beacon_info
= &msg
.body
.beacon_info
;
3683 memset(&msg
, 0, sizeof(struct host_if_msg
));
3685 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
3687 beacon_info
->interval
= interval
;
3688 beacon_info
->dtim_period
= dtim_period
;
3689 beacon_info
->head_len
= head_len
;
3690 beacon_info
->head
= kmemdup(head
, head_len
, GFP_KERNEL
);
3691 if (!beacon_info
->head
) {
3695 beacon_info
->tail_len
= tail_len
;
3698 beacon_info
->tail
= kmemdup(tail
, tail_len
, GFP_KERNEL
);
3699 if (!beacon_info
->tail
) {
3704 beacon_info
->tail
= NULL
;
3707 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3709 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3713 kfree(beacon_info
->head
);
3715 kfree(beacon_info
->tail
);
3721 int wilc_del_beacon(struct wilc_vif
*vif
)
3724 struct host_if_msg msg
;
3726 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
3729 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3731 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3736 int wilc_add_station(struct wilc_vif
*vif
, struct add_sta_param
*sta_param
)
3739 struct host_if_msg msg
;
3740 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
3742 memset(&msg
, 0, sizeof(struct host_if_msg
));
3744 msg
.id
= HOST_IF_MSG_ADD_STATION
;
3747 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
3748 if (add_sta_info
->rates_len
> 0) {
3749 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
3750 add_sta_info
->rates_len
,
3752 if (!add_sta_info
->rates
)
3756 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3758 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3762 int wilc_del_station(struct wilc_vif
*vif
, const u8
*mac_addr
)
3765 struct host_if_msg msg
;
3766 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
3768 memset(&msg
, 0, sizeof(struct host_if_msg
));
3770 msg
.id
= HOST_IF_MSG_DEL_STATION
;
3774 eth_broadcast_addr(del_sta_info
->mac_addr
);
3776 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
3778 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3780 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3784 int wilc_del_allstation(struct wilc_vif
*vif
, u8 mac_addr
[][ETH_ALEN
])
3787 struct host_if_msg msg
;
3788 struct del_all_sta
*del_all_sta_info
= &msg
.body
.del_all_sta_info
;
3789 u8 zero_addr
[ETH_ALEN
] = {0};
3793 memset(&msg
, 0, sizeof(struct host_if_msg
));
3795 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
3798 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3799 if (memcmp(mac_addr
[i
], zero_addr
, ETH_ALEN
)) {
3800 memcpy(del_all_sta_info
->del_all_sta
[i
], mac_addr
[i
], ETH_ALEN
);
3807 del_all_sta_info
->assoc_sta
= assoc_sta
;
3808 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3811 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3813 wait_for_completion(&hif_wait_response
);
3818 int wilc_edit_station(struct wilc_vif
*vif
,
3819 struct add_sta_param
*sta_param
)
3822 struct host_if_msg msg
;
3823 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
3825 memset(&msg
, 0, sizeof(struct host_if_msg
));
3827 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
3830 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
3831 if (add_sta_info
->rates_len
> 0) {
3832 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
3833 add_sta_info
->rates_len
,
3835 if (!add_sta_info
->rates
)
3839 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3841 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3846 int wilc_set_power_mgmt(struct wilc_vif
*vif
, bool enabled
, u32 timeout
)
3849 struct host_if_msg msg
;
3850 struct power_mgmt_param
*pwr_mgmt_info
= &msg
.body
.pwr_mgmt_info
;
3852 if (wilc_wlan_get_num_conn_ifcs(vif
->wilc
) == 2 && enabled
)
3855 memset(&msg
, 0, sizeof(struct host_if_msg
));
3857 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
3860 pwr_mgmt_info
->enabled
= enabled
;
3861 pwr_mgmt_info
->timeout
= timeout
;
3863 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3865 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3869 int wilc_setup_multicast_filter(struct wilc_vif
*vif
, bool enabled
,
3873 struct host_if_msg msg
;
3874 struct set_multicast
*multicast_filter_param
= &msg
.body
.multicast_info
;
3876 memset(&msg
, 0, sizeof(struct host_if_msg
));
3878 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
3881 multicast_filter_param
->enabled
= enabled
;
3882 multicast_filter_param
->cnt
= count
;
3884 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3886 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3890 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
)
3892 struct join_bss_param
*pNewJoinBssParam
= NULL
;
3901 u8 pcipherTotalCount
= 0;
3902 u8 authTotalCount
= 0;
3905 pu8IEs
= ptstrNetworkInfo
->ies
;
3906 u16IEsLen
= ptstrNetworkInfo
->ies_len
;
3908 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
3909 if (pNewJoinBssParam
) {
3910 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->dtim_period
;
3911 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->beacon_period
;
3912 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->cap_info
;
3913 memcpy(pNewJoinBssParam
->bssid
, ptstrNetworkInfo
->bssid
, 6);
3914 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->ssid
,
3915 ptstrNetworkInfo
->ssid_len
+ 1);
3916 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->ssid_len
;
3917 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
3918 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
3920 while (index
< u16IEsLen
) {
3921 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
3922 suppRatesNo
= pu8IEs
[index
+ 1];
3923 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
3926 for (i
= 0; i
< suppRatesNo
; i
++)
3927 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
3929 index
+= suppRatesNo
;
3931 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
3932 extSuppRatesNo
= pu8IEs
[index
+ 1];
3933 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
3934 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
3936 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
3938 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
3939 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
3941 index
+= extSuppRatesNo
;
3943 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
3944 pNewJoinBssParam
->ht_capable
= true;
3945 index
+= pu8IEs
[index
+ 1] + 2;
3947 } else if ((pu8IEs
[index
] == WMM_IE
) &&
3948 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
3949 (pu8IEs
[index
+ 4] == 0xF2) &&
3950 (pu8IEs
[index
+ 5] == 0x02) &&
3951 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
3952 (pu8IEs
[index
+ 7] == 0x01)) {
3953 pNewJoinBssParam
->wmm_cap
= true;
3955 if (pu8IEs
[index
+ 8] & BIT(7))
3956 pNewJoinBssParam
->uapsd_cap
= true;
3957 index
+= pu8IEs
[index
+ 1] + 2;
3959 } else if ((pu8IEs
[index
] == P2P_IE
) &&
3960 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
3961 (pu8IEs
[index
+ 4] == 0x9a) &&
3962 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
3965 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->tsf_lo
;
3966 pNewJoinBssParam
->noa_enabled
= 1;
3967 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
3969 if (pu8IEs
[index
+ 10] & BIT(7)) {
3970 pNewJoinBssParam
->opp_enabled
= 1;
3971 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
3973 pNewJoinBssParam
->opp_enabled
= 0;
3976 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
3977 u16P2P_count
= index
+ 12;
3979 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
3982 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
3985 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
3987 index
+= pu8IEs
[index
+ 1] + 2;
3990 } else if ((pu8IEs
[index
] == RSN_IE
) ||
3991 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
3992 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
3993 (pu8IEs
[index
+ 5] == 0x01))) {
3994 u16 rsnIndex
= index
;
3996 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
3997 pNewJoinBssParam
->mode_802_11i
= 2;
3999 if (pNewJoinBssParam
->mode_802_11i
== 0)
4000 pNewJoinBssParam
->mode_802_11i
= 1;
4005 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4007 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4008 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4011 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4012 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4014 pcipherTotalCount
+= pcipherCount
;
4015 rsnIndex
+= jumpOffset
;
4017 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4019 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4022 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4023 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4025 authTotalCount
+= authCount
;
4026 rsnIndex
+= jumpOffset
;
4028 if (pu8IEs
[index
] == RSN_IE
) {
4029 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4030 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4033 pNewJoinBssParam
->rsn_found
= true;
4034 index
+= pu8IEs
[index
+ 1] + 2;
4037 index
+= pu8IEs
[index
+ 1] + 2;
4041 return (void *)pNewJoinBssParam
;
4044 int wilc_setup_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4047 struct host_if_msg msg
;
4049 memset(&msg
, 0, sizeof(struct host_if_msg
));
4051 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
4053 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4055 msg
.body
.ip_info
.idx
= idx
;
4057 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4059 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4064 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4067 struct host_if_msg msg
;
4069 memset(&msg
, 0, sizeof(struct host_if_msg
));
4071 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
4073 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4075 msg
.body
.ip_info
.idx
= idx
;
4077 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4079 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4084 int wilc_set_tx_power(struct wilc_vif
*vif
, u8 tx_power
)
4087 struct host_if_msg msg
;
4089 memset(&msg
, 0, sizeof(struct host_if_msg
));
4091 msg
.id
= HOST_IF_MSG_SET_TX_POWER
;
4092 msg
.body
.tx_power
.tx_pwr
= tx_power
;
4095 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4097 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4102 int wilc_get_tx_power(struct wilc_vif
*vif
, u8
*tx_power
)
4105 struct host_if_msg msg
;
4107 memset(&msg
, 0, sizeof(struct host_if_msg
));
4109 msg
.id
= HOST_IF_MSG_GET_TX_POWER
;
4112 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4114 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
4116 wait_for_completion(&hif_wait_response
);
4117 *tx_power
= msg
.body
.tx_power
.tx_pwr
;