1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
13 #define HOST_IF_MSG_SCAN 0
14 #define HOST_IF_MSG_CONNECT 1
15 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16 #define HOST_IF_MSG_KEY 3
17 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19 #define HOST_IF_MSG_CFG_PARAMS 6
20 #define HOST_IF_MSG_SET_CHANNEL 7
21 #define HOST_IF_MSG_DISCONNECT 8
22 #define HOST_IF_MSG_GET_RSSI 9
23 #define HOST_IF_MSG_ADD_BEACON 11
24 #define HOST_IF_MSG_DEL_BEACON 12
25 #define HOST_IF_MSG_ADD_STATION 13
26 #define HOST_IF_MSG_DEL_STATION 14
27 #define HOST_IF_MSG_EDIT_STATION 15
28 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
29 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
30 #define HOST_IF_MSG_POWER_MGMT 18
31 #define HOST_IF_MSG_GET_INACTIVETIME 19
32 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
33 #define HOST_IF_MSG_REGISTER_FRAME 21
34 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
35 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
36 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
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_Q_IDLE 35
45 #define HOST_IF_MSG_DEL_ALL_STA 36
46 #define HOST_IF_MSG_SET_TX_POWER 38
47 #define HOST_IF_MSG_GET_TX_POWER 39
48 #define HOST_IF_MSG_EXIT 100
50 #define HOST_IF_SCAN_TIMEOUT 4000
51 #define HOST_IF_CONNECT_TIMEOUT 9500
53 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
54 #define BA_SESSION_DEFAULT_TIMEOUT 1000
55 #define BLOCK_ACK_REQ_SIZE 0x14
56 #define FALSE_FRMWR_CHANNEL 100
58 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
59 #define DEFAULT_LINK_SPEED 72
61 struct host_if_wpa_attr
{
71 struct host_if_wep_attr
{
76 enum AUTHTYPE auth_type
;
79 union host_if_key_attr
{
80 struct host_if_wep_attr wep
;
81 struct host_if_wpa_attr wpa
;
82 struct host_if_pmkid_attr pmkid
;
88 union host_if_key_attr attr
;
98 wilc_scan_result result
;
100 struct hidden_network hidden_network
;
103 struct connect_attr
{
110 wilc_connect_result result
;
112 enum AUTHTYPE auth_type
;
117 struct rcvd_async_info
{
122 struct channel_attr
{
135 struct set_multicast
{
141 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
146 u8 mac_addr
[ETH_ALEN
];
149 struct power_mgmt_param
{
159 struct sta_inactive_t
{
168 struct scan_attr scan_info
;
169 struct connect_attr con_info
;
170 struct rcvd_net_info net_info
;
171 struct rcvd_async_info async_info
;
172 struct key_attr key_info
;
173 struct cfg_param_attr cfg_info
;
174 struct channel_attr channel_info
;
175 struct beacon_attr beacon_info
;
176 struct add_sta_param add_sta_info
;
177 struct del_sta del_sta_info
;
178 struct add_sta_param edit_sta_info
;
179 struct power_mgmt_param pwr_mgmt_info
;
180 struct sta_inactive_t mac_info
;
181 struct set_ip_addr ip_info
;
182 struct drv_handler drv
;
183 struct set_multicast multicast_info
;
185 struct set_mac_addr set_mac_info
;
186 struct get_mac_addr get_mac_info
;
187 struct ba_session_info session_info
;
188 struct remain_ch remain_on_ch
;
189 struct reg_frame reg_frame
;
191 struct del_all_sta del_all_sta_info
;
192 struct tx_power tx_power
;
197 union message_body body
;
198 struct wilc_vif
*vif
;
201 struct join_bss_param
{
207 char ssid
[MAX_SSID_LEN
];
209 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
216 u8 rsn_pcip_policy
[3];
217 u8 rsn_auth_policy
[3];
230 static struct host_if_drv
*terminated_handle
;
231 bool wilc_optaining_ip
;
232 static u8 P2P_LISTEN_STATE
;
233 static struct task_struct
*hif_thread_handler
;
234 static struct message_queue hif_msg_q
;
235 static struct semaphore hif_sema_thread
;
236 static struct semaphore hif_sema_driver
;
237 static struct semaphore hif_sema_wait_response
;
238 static struct semaphore hif_sema_deinit
;
239 static struct timer_list periodic_rssi
;
241 u8 wilc_multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
243 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
245 static bool scan_while_connected
;
248 static u8 set_ip
[2][4];
249 static u8 get_ip
[2][4];
250 static u32 inactive_time
;
251 static u8 del_beacon
;
252 static u32 clients_count
;
255 static u8
*info_element
;
258 static u32 join_req_size
;
259 static u32 info_element_size
;
260 static struct wilc_vif
*join_req_vif
;
261 #define REAL_JOIN_REQ 0
262 #define FLUSHED_JOIN_REQ 1
263 #define FLUSHED_BYTE_POS 79
265 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
);
266 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
);
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 s32
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 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
322 hif_drv_handler
->handler
);
324 if (!hif_drv_handler
->handler
)
325 up(&hif_sema_driver
);
328 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
335 static s32
handle_set_operation_mode(struct wilc_vif
*vif
,
336 struct op_mode
*hif_op_mode
)
341 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
343 wid
.val
= (s8
*)&hif_op_mode
->mode
;
344 wid
.size
= sizeof(u32
);
346 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
347 wilc_get_vif_idx(vif
));
349 if ((hif_op_mode
->mode
) == IDLE_MODE
)
350 up(&hif_sema_driver
);
353 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
360 static s32
handle_set_ip_address(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
364 char firmware_ip_addr
[4] = {0};
366 if (ip_addr
[0] < 192)
369 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
371 wid
.id
= (u16
)WID_IP_ADDRESS
;
373 wid
.val
= (u8
*)ip_addr
;
376 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
377 wilc_get_vif_idx(vif
));
379 host_int_get_ipaddress(vif
, firmware_ip_addr
, idx
);
382 netdev_err(vif
->ndev
, "Failed to set IP address\n");
389 static s32
handle_get_ip_address(struct wilc_vif
*vif
, u8 idx
)
394 wid
.id
= (u16
)WID_IP_ADDRESS
;
396 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
399 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
400 wilc_get_vif_idx(vif
));
402 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
406 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
407 wilc_setup_ipaddress(vif
, set_ip
[idx
], idx
);
410 netdev_err(vif
->ndev
, "Failed to get IP address\n");
417 static void handle_set_mac_address(struct wilc_vif
*vif
,
418 struct set_mac_addr
*set_mac_addr
)
424 mac_buf
= kmemdup(set_mac_addr
->mac_addr
, ETH_ALEN
, GFP_KERNEL
);
428 wid
.id
= (u16
)WID_MAC_ADDR
;
433 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
434 wilc_get_vif_idx(vif
));
436 netdev_err(vif
->ndev
, "Failed to set mac address\n");
441 static s32
handle_get_mac_address(struct wilc_vif
*vif
,
442 struct get_mac_addr
*get_mac_addr
)
447 wid
.id
= (u16
)WID_MAC_ADDR
;
449 wid
.val
= get_mac_addr
->mac_addr
;
452 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
453 wilc_get_vif_idx(vif
));
456 netdev_err(vif
->ndev
, "Failed to get mac address\n");
459 up(&hif_sema_wait_response
);
464 static s32
handle_cfg_param(struct wilc_vif
*vif
,
465 struct cfg_param_attr
*cfg_param_attr
)
468 struct wid wid_list
[32];
469 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
472 down(&hif_drv
->sem_cfg_values
);
474 if (cfg_param_attr
->flag
& BSS_TYPE
) {
475 if (cfg_param_attr
->bss_type
< 6) {
476 wid_list
[i
].id
= WID_BSS_TYPE
;
477 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->bss_type
;
478 wid_list
[i
].type
= WID_CHAR
;
479 wid_list
[i
].size
= sizeof(char);
480 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->bss_type
;
482 netdev_err(vif
->ndev
, "check value 6 over\n");
488 if (cfg_param_attr
->flag
& AUTH_TYPE
) {
489 if (cfg_param_attr
->auth_type
== 1 ||
490 cfg_param_attr
->auth_type
== 2 ||
491 cfg_param_attr
->auth_type
== 5) {
492 wid_list
[i
].id
= WID_AUTH_TYPE
;
493 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_type
;
494 wid_list
[i
].type
= WID_CHAR
;
495 wid_list
[i
].size
= sizeof(char);
496 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->auth_type
;
498 netdev_err(vif
->ndev
, "Impossible value\n");
504 if (cfg_param_attr
->flag
& AUTHEN_TIMEOUT
) {
505 if (cfg_param_attr
->auth_timeout
> 0 &&
506 cfg_param_attr
->auth_timeout
< 65536) {
507 wid_list
[i
].id
= WID_AUTH_TIMEOUT
;
508 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_timeout
;
509 wid_list
[i
].type
= WID_SHORT
;
510 wid_list
[i
].size
= sizeof(u16
);
511 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->auth_timeout
;
513 netdev_err(vif
->ndev
, "Range(1 ~ 65535) over\n");
519 if (cfg_param_attr
->flag
& POWER_MANAGEMENT
) {
520 if (cfg_param_attr
->power_mgmt_mode
< 5) {
521 wid_list
[i
].id
= WID_POWER_MANAGEMENT
;
522 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->power_mgmt_mode
;
523 wid_list
[i
].type
= WID_CHAR
;
524 wid_list
[i
].size
= sizeof(char);
525 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->power_mgmt_mode
;
527 netdev_err(vif
->ndev
, "Invalid power mode\n");
533 if (cfg_param_attr
->flag
& RETRY_SHORT
) {
534 if (cfg_param_attr
->short_retry_limit
> 0 &&
535 cfg_param_attr
->short_retry_limit
< 256) {
536 wid_list
[i
].id
= WID_SHORT_RETRY_LIMIT
;
537 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_retry_limit
;
538 wid_list
[i
].type
= WID_SHORT
;
539 wid_list
[i
].size
= sizeof(u16
);
540 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->short_retry_limit
;
542 netdev_err(vif
->ndev
, "Range(1~256) over\n");
548 if (cfg_param_attr
->flag
& RETRY_LONG
) {
549 if (cfg_param_attr
->long_retry_limit
> 0 &&
550 cfg_param_attr
->long_retry_limit
< 256) {
551 wid_list
[i
].id
= WID_LONG_RETRY_LIMIT
;
552 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->long_retry_limit
;
553 wid_list
[i
].type
= WID_SHORT
;
554 wid_list
[i
].size
= sizeof(u16
);
555 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->long_retry_limit
;
557 netdev_err(vif
->ndev
, "Range(1~256) over\n");
563 if (cfg_param_attr
->flag
& FRAG_THRESHOLD
) {
564 if (cfg_param_attr
->frag_threshold
> 255 &&
565 cfg_param_attr
->frag_threshold
< 7937) {
566 wid_list
[i
].id
= WID_FRAG_THRESHOLD
;
567 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->frag_threshold
;
568 wid_list
[i
].type
= WID_SHORT
;
569 wid_list
[i
].size
= sizeof(u16
);
570 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->frag_threshold
;
572 netdev_err(vif
->ndev
, "Threshold Range fail\n");
578 if (cfg_param_attr
->flag
& RTS_THRESHOLD
) {
579 if (cfg_param_attr
->rts_threshold
> 255 &&
580 cfg_param_attr
->rts_threshold
< 65536) {
581 wid_list
[i
].id
= WID_RTS_THRESHOLD
;
582 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->rts_threshold
;
583 wid_list
[i
].type
= WID_SHORT
;
584 wid_list
[i
].size
= sizeof(u16
);
585 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->rts_threshold
;
587 netdev_err(vif
->ndev
, "Threshold Range fail\n");
593 if (cfg_param_attr
->flag
& PREAMBLE
) {
594 if (cfg_param_attr
->preamble_type
< 3) {
595 wid_list
[i
].id
= WID_PREAMBLE
;
596 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->preamble_type
;
597 wid_list
[i
].type
= WID_CHAR
;
598 wid_list
[i
].size
= sizeof(char);
599 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->preamble_type
;
601 netdev_err(vif
->ndev
, "Preamle Range(0~2) over\n");
607 if (cfg_param_attr
->flag
& SHORT_SLOT_ALLOWED
) {
608 if (cfg_param_attr
->short_slot_allowed
< 2) {
609 wid_list
[i
].id
= WID_SHORT_SLOT_ALLOWED
;
610 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_slot_allowed
;
611 wid_list
[i
].type
= WID_CHAR
;
612 wid_list
[i
].size
= sizeof(char);
613 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->short_slot_allowed
;
615 netdev_err(vif
->ndev
, "Short slot(2) over\n");
621 if (cfg_param_attr
->flag
& TXOP_PROT_DISABLE
) {
622 if (cfg_param_attr
->txop_prot_disabled
< 2) {
623 wid_list
[i
].id
= WID_11N_TXOP_PROT_DISABLE
;
624 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->txop_prot_disabled
;
625 wid_list
[i
].type
= WID_CHAR
;
626 wid_list
[i
].size
= sizeof(char);
627 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->txop_prot_disabled
;
629 netdev_err(vif
->ndev
, "TXOP prot disable\n");
635 if (cfg_param_attr
->flag
& BEACON_INTERVAL
) {
636 if (cfg_param_attr
->beacon_interval
> 0 &&
637 cfg_param_attr
->beacon_interval
< 65536) {
638 wid_list
[i
].id
= WID_BEACON_INTERVAL
;
639 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->beacon_interval
;
640 wid_list
[i
].type
= WID_SHORT
;
641 wid_list
[i
].size
= sizeof(u16
);
642 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->beacon_interval
;
644 netdev_err(vif
->ndev
, "Beacon interval(1~65535)fail\n");
650 if (cfg_param_attr
->flag
& DTIM_PERIOD
) {
651 if (cfg_param_attr
->dtim_period
> 0 &&
652 cfg_param_attr
->dtim_period
< 256) {
653 wid_list
[i
].id
= WID_DTIM_PERIOD
;
654 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->dtim_period
;
655 wid_list
[i
].type
= WID_CHAR
;
656 wid_list
[i
].size
= sizeof(char);
657 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->dtim_period
;
659 netdev_err(vif
->ndev
, "DTIM range(1~255) fail\n");
665 if (cfg_param_attr
->flag
& SITE_SURVEY
) {
666 if (cfg_param_attr
->site_survey_enabled
< 3) {
667 wid_list
[i
].id
= WID_SITE_SURVEY
;
668 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_enabled
;
669 wid_list
[i
].type
= WID_CHAR
;
670 wid_list
[i
].size
= sizeof(char);
671 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->site_survey_enabled
;
673 netdev_err(vif
->ndev
, "Site survey disable\n");
679 if (cfg_param_attr
->flag
& SITE_SURVEY_SCAN_TIME
) {
680 if (cfg_param_attr
->site_survey_scan_time
> 0 &&
681 cfg_param_attr
->site_survey_scan_time
< 65536) {
682 wid_list
[i
].id
= WID_SITE_SURVEY_SCAN_TIME
;
683 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_scan_time
;
684 wid_list
[i
].type
= WID_SHORT
;
685 wid_list
[i
].size
= sizeof(u16
);
686 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->site_survey_scan_time
;
688 netdev_err(vif
->ndev
, "Site scan time(1~65535) over\n");
694 if (cfg_param_attr
->flag
& ACTIVE_SCANTIME
) {
695 if (cfg_param_attr
->active_scan_time
> 0 &&
696 cfg_param_attr
->active_scan_time
< 65536) {
697 wid_list
[i
].id
= WID_ACTIVE_SCAN_TIME
;
698 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->active_scan_time
;
699 wid_list
[i
].type
= WID_SHORT
;
700 wid_list
[i
].size
= sizeof(u16
);
701 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->active_scan_time
;
703 netdev_err(vif
->ndev
, "Active time(1~65535) over\n");
709 if (cfg_param_attr
->flag
& PASSIVE_SCANTIME
) {
710 if (cfg_param_attr
->passive_scan_time
> 0 &&
711 cfg_param_attr
->passive_scan_time
< 65536) {
712 wid_list
[i
].id
= WID_PASSIVE_SCAN_TIME
;
713 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->passive_scan_time
;
714 wid_list
[i
].type
= WID_SHORT
;
715 wid_list
[i
].size
= sizeof(u16
);
716 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->passive_scan_time
;
718 netdev_err(vif
->ndev
, "Passive time(1~65535) over\n");
724 if (cfg_param_attr
->flag
& CURRENT_TX_RATE
) {
725 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->curr_tx_rate
;
727 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
||
728 curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
||
729 curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
||
730 curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
||
731 curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
||
732 curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
||
733 curr_tx_rate
== MBPS_54
) {
734 wid_list
[i
].id
= WID_CURRENT_TX_RATE
;
735 wid_list
[i
].val
= (s8
*)&curr_tx_rate
;
736 wid_list
[i
].type
= WID_SHORT
;
737 wid_list
[i
].size
= sizeof(u16
);
738 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
740 netdev_err(vif
->ndev
, "out of TX rate\n");
747 result
= wilc_send_config_pkt(vif
, SET_CFG
, wid_list
,
748 i
, wilc_get_vif_idx(vif
));
751 netdev_err(vif
->ndev
, "Error in setting CFG params\n");
754 up(&hif_drv
->sem_cfg_values
);
758 static void Handle_wait_msg_q_empty(void)
760 wilc_initialized
= 0;
761 up(&hif_sema_wait_response
);
764 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
765 enum scan_event enuEvent
);
767 static s32
Handle_Scan(struct wilc_vif
*vif
,
768 struct scan_attr
*pstrHostIFscanAttr
)
771 struct wid strWIDList
[5];
772 u32 u32WidsCount
= 0;
776 u8
*pu8HdnNtwrksWidVal
= NULL
;
777 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
779 hif_drv
->usr_scan_req
.scan_result
= pstrHostIFscanAttr
->result
;
780 hif_drv
->usr_scan_req
.arg
= pstrHostIFscanAttr
->arg
;
782 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
783 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
784 netdev_err(vif
->ndev
, "Already scan\n");
789 if (wilc_optaining_ip
|| wilc_connecting
) {
790 netdev_err(vif
->ndev
, "Don't do obss scan\n");
795 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
797 strWIDList
[u32WidsCount
].id
= (u16
)WID_SSID_PROBE_REQ
;
798 strWIDList
[u32WidsCount
].type
= WID_STR
;
800 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++)
801 valuesize
+= ((pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
) + 1);
802 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
803 strWIDList
[u32WidsCount
].val
= pu8HdnNtwrksWidVal
;
804 if (strWIDList
[u32WidsCount
].val
) {
805 pu8Buffer
= strWIDList
[u32WidsCount
].val
;
807 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.n_ssids
;
809 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++) {
810 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
811 memcpy(pu8Buffer
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
);
812 pu8Buffer
+= pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
815 strWIDList
[u32WidsCount
].size
= (s32
)(valuesize
+ 1);
820 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_PROBE
;
821 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
822 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ies
;
823 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ies_len
;
827 strWIDList
[u32WidsCount
].id
= WID_SCAN_TYPE
;
828 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
829 strWIDList
[u32WidsCount
].size
= sizeof(char);
830 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->type
;
833 strWIDList
[u32WidsCount
].id
= WID_SCAN_CHANNEL_LIST
;
834 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
836 if (pstrHostIFscanAttr
->ch_freq_list
&&
837 pstrHostIFscanAttr
->ch_list_len
> 0) {
840 for (i
= 0; i
< pstrHostIFscanAttr
->ch_list_len
; i
++) {
841 if (pstrHostIFscanAttr
->ch_freq_list
[i
] > 0)
842 pstrHostIFscanAttr
->ch_freq_list
[i
] = pstrHostIFscanAttr
->ch_freq_list
[i
] - 1;
846 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ch_freq_list
;
847 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ch_list_len
;
850 strWIDList
[u32WidsCount
].id
= WID_START_SCAN_REQ
;
851 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
852 strWIDList
[u32WidsCount
].size
= sizeof(char);
853 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->src
;
856 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
857 scan_while_connected
= true;
858 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
859 scan_while_connected
= false;
861 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
863 wilc_get_vif_idx(vif
));
866 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
870 del_timer(&hif_drv
->scan_timer
);
871 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
874 kfree(pstrHostIFscanAttr
->ch_freq_list
);
875 pstrHostIFscanAttr
->ch_freq_list
= NULL
;
877 kfree(pstrHostIFscanAttr
->ies
);
878 pstrHostIFscanAttr
->ies
= NULL
;
879 kfree(pstrHostIFscanAttr
->hidden_network
.net_info
);
880 pstrHostIFscanAttr
->hidden_network
.net_info
= NULL
;
882 kfree(pu8HdnNtwrksWidVal
);
887 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
888 enum scan_event enuEvent
)
891 u8 u8abort_running_scan
;
893 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
895 if (enuEvent
== SCAN_EVENT_ABORTED
) {
896 u8abort_running_scan
= 1;
897 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
899 wid
.val
= (s8
*)&u8abort_running_scan
;
900 wid
.size
= sizeof(char);
902 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
903 wilc_get_vif_idx(vif
));
906 netdev_err(vif
->ndev
, "Failed to set abort running\n");
912 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
916 if (hif_drv
->usr_scan_req
.scan_result
) {
917 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
918 hif_drv
->usr_scan_req
.arg
, NULL
);
919 hif_drv
->usr_scan_req
.scan_result
= NULL
;
925 u8 wilc_connected_ssid
[6] = {0};
926 static s32
Handle_Connect(struct wilc_vif
*vif
,
927 struct connect_attr
*pstrHostIFconnectAttr
)
930 struct wid strWIDList
[8];
931 u32 u32WidsCount
= 0, dummyval
= 0;
932 u8
*pu8CurrByte
= NULL
;
933 struct join_bss_param
*ptstrJoinBssParam
;
934 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
936 if (memcmp(pstrHostIFconnectAttr
->bssid
, wilc_connected_ssid
, ETH_ALEN
) == 0) {
938 netdev_err(vif
->ndev
, "Discard connect request\n");
942 ptstrJoinBssParam
= pstrHostIFconnectAttr
->params
;
943 if (!ptstrJoinBssParam
) {
944 netdev_err(vif
->ndev
, "Required BSSID not found\n");
949 if (pstrHostIFconnectAttr
->bssid
) {
950 hif_drv
->usr_conn_req
.bssid
= kmalloc(6, GFP_KERNEL
);
951 memcpy(hif_drv
->usr_conn_req
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
954 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
955 if (pstrHostIFconnectAttr
->ssid
) {
956 hif_drv
->usr_conn_req
.ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
957 memcpy(hif_drv
->usr_conn_req
.ssid
,
958 pstrHostIFconnectAttr
->ssid
,
959 pstrHostIFconnectAttr
->ssid_len
);
960 hif_drv
->usr_conn_req
.ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
963 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
964 if (pstrHostIFconnectAttr
->ies
) {
965 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
966 memcpy(hif_drv
->usr_conn_req
.ies
,
967 pstrHostIFconnectAttr
->ies
,
968 pstrHostIFconnectAttr
->ies_len
);
971 hif_drv
->usr_conn_req
.security
= pstrHostIFconnectAttr
->security
;
972 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
973 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
974 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
976 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
977 strWIDList
[u32WidsCount
].type
= WID_INT
;
978 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
979 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
982 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
983 strWIDList
[u32WidsCount
].type
= WID_INT
;
984 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
985 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
988 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
989 strWIDList
[u32WidsCount
].type
= WID_INT
;
990 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
991 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
995 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
996 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
997 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
998 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
1001 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1002 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
1003 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
1004 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
1008 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1009 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1010 strWIDList
[u32WidsCount
].size
= sizeof(char);
1011 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.security
;
1014 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1015 mode_11i
= hif_drv
->usr_conn_req
.security
;
1017 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1018 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1019 strWIDList
[u32WidsCount
].size
= sizeof(char);
1020 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
1023 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1024 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
1026 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1027 strWIDList
[u32WidsCount
].type
= WID_STR
;
1028 strWIDList
[u32WidsCount
].size
= 112;
1029 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
1031 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1032 join_req_size
= strWIDList
[u32WidsCount
].size
;
1033 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
1035 if (!strWIDList
[u32WidsCount
].val
) {
1040 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1042 if (pstrHostIFconnectAttr
->ssid
) {
1043 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
1044 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1046 pu8CurrByte
+= MAX_SSID_LEN
;
1047 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1049 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
1050 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1052 netdev_err(vif
->ndev
, "Channel out of range\n");
1053 *(pu8CurrByte
++) = 0xFF;
1055 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1056 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1058 if (pstrHostIFconnectAttr
->bssid
)
1059 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1062 if (pstrHostIFconnectAttr
->bssid
)
1063 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1066 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1067 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1068 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1070 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1071 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1073 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1074 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1076 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1077 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1079 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1080 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1081 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1083 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1084 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1086 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1087 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1089 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1090 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1092 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1093 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1095 if (ptstrJoinBssParam
->noa_enabled
) {
1096 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1097 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1098 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1099 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1101 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1102 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1104 if (ptstrJoinBssParam
->opp_enabled
)
1105 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1107 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1109 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1110 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1112 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1113 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1115 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1116 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1119 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1122 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1123 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1127 if (pstrHostIFconnectAttr
->bssid
)
1128 memcpy(wilc_connected_ssid
,
1129 pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1131 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1133 wilc_get_vif_idx(vif
));
1135 netdev_err(vif
->ndev
, "failed to send config packet\n");
1139 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1144 struct connect_info strConnectInfo
;
1146 del_timer(&hif_drv
->connect_timer
);
1148 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1150 if (pstrHostIFconnectAttr
->result
) {
1151 if (pstrHostIFconnectAttr
->bssid
)
1152 memcpy(strConnectInfo
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1154 if (pstrHostIFconnectAttr
->ies
) {
1155 strConnectInfo
.req_ies_len
= pstrHostIFconnectAttr
->ies_len
;
1156 strConnectInfo
.req_ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1157 memcpy(strConnectInfo
.req_ies
,
1158 pstrHostIFconnectAttr
->ies
,
1159 pstrHostIFconnectAttr
->ies_len
);
1162 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1166 pstrHostIFconnectAttr
->arg
);
1167 hif_drv
->hif_state
= HOST_IF_IDLE
;
1168 kfree(strConnectInfo
.req_ies
);
1169 strConnectInfo
.req_ies
= NULL
;
1172 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1176 kfree(pstrHostIFconnectAttr
->bssid
);
1177 pstrHostIFconnectAttr
->bssid
= NULL
;
1179 kfree(pstrHostIFconnectAttr
->ssid
);
1180 pstrHostIFconnectAttr
->ssid
= NULL
;
1182 kfree(pstrHostIFconnectAttr
->ies
);
1183 pstrHostIFconnectAttr
->ies
= NULL
;
1189 static s32
Handle_ConnectTimeout(struct wilc_vif
*vif
)
1192 struct connect_info strConnectInfo
;
1194 u16 u16DummyReasonCode
= 0;
1195 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1198 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1202 hif_drv
->hif_state
= HOST_IF_IDLE
;
1204 scan_while_connected
= false;
1206 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1208 if (hif_drv
->usr_conn_req
.conn_result
) {
1209 if (hif_drv
->usr_conn_req
.bssid
) {
1210 memcpy(strConnectInfo
.bssid
,
1211 hif_drv
->usr_conn_req
.bssid
, 6);
1214 if (hif_drv
->usr_conn_req
.ies
) {
1215 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1216 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1217 memcpy(strConnectInfo
.req_ies
,
1218 hif_drv
->usr_conn_req
.ies
,
1219 hif_drv
->usr_conn_req
.ies_len
);
1222 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1226 hif_drv
->usr_conn_req
.arg
);
1228 kfree(strConnectInfo
.req_ies
);
1229 strConnectInfo
.req_ies
= NULL
;
1231 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1234 wid
.id
= (u16
)WID_DISCONNECT
;
1235 wid
.type
= WID_CHAR
;
1236 wid
.val
= (s8
*)&u16DummyReasonCode
;
1237 wid
.size
= sizeof(char);
1239 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1240 wilc_get_vif_idx(vif
));
1242 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1244 hif_drv
->usr_conn_req
.ssid_len
= 0;
1245 kfree(hif_drv
->usr_conn_req
.ssid
);
1246 hif_drv
->usr_conn_req
.ssid
= NULL
;
1247 kfree(hif_drv
->usr_conn_req
.bssid
);
1248 hif_drv
->usr_conn_req
.bssid
= NULL
;
1249 hif_drv
->usr_conn_req
.ies_len
= 0;
1250 kfree(hif_drv
->usr_conn_req
.ies
);
1251 hif_drv
->usr_conn_req
.ies
= NULL
;
1253 eth_zero_addr(wilc_connected_ssid
);
1255 if (join_req
&& join_req_vif
== vif
) {
1260 if (info_element
&& join_req_vif
== vif
) {
1261 kfree(info_element
);
1262 info_element
= NULL
;
1268 static s32
Handle_RcvdNtwrkInfo(struct wilc_vif
*vif
,
1269 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1272 bool bNewNtwrkFound
;
1274 struct network_info
*pstrNetworkInfo
= NULL
;
1275 void *pJoinParams
= NULL
;
1276 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1278 bNewNtwrkFound
= true;
1280 if (hif_drv
->usr_scan_req
.scan_result
) {
1281 wilc_parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1282 if ((!pstrNetworkInfo
) ||
1283 (!hif_drv
->usr_scan_req
.scan_result
)) {
1284 netdev_err(vif
->ndev
, "driver is null\n");
1289 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1290 if ((hif_drv
->usr_scan_req
.net_info
[i
].bssid
) &&
1291 (pstrNetworkInfo
->bssid
)) {
1292 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].bssid
,
1293 pstrNetworkInfo
->bssid
, 6) == 0) {
1294 if (pstrNetworkInfo
->rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].rssi
) {
1297 hif_drv
->usr_scan_req
.net_info
[i
].rssi
= pstrNetworkInfo
->rssi
;
1298 bNewNtwrkFound
= false;
1305 if (bNewNtwrkFound
) {
1306 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1307 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].rssi
= pstrNetworkInfo
->rssi
;
1309 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
&&
1310 pstrNetworkInfo
->bssid
) {
1311 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
,
1312 pstrNetworkInfo
->bssid
, 6);
1314 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1316 pstrNetworkInfo
->new_network
= true;
1317 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1319 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1320 hif_drv
->usr_scan_req
.arg
,
1325 pstrNetworkInfo
->new_network
= false;
1326 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1327 hif_drv
->usr_scan_req
.arg
, NULL
);
1332 kfree(pstrRcvdNetworkInfo
->buffer
);
1333 pstrRcvdNetworkInfo
->buffer
= NULL
;
1335 if (pstrNetworkInfo
) {
1336 kfree(pstrNetworkInfo
->ies
);
1337 kfree(pstrNetworkInfo
);
1343 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
1344 u8
*pu8AssocRespInfo
,
1345 u32 u32MaxAssocRespInfoLen
,
1346 u32
*pu32RcvdAssocRespInfoLen
);
1348 static s32
Handle_RcvdGnrlAsyncInfo(struct wilc_vif
*vif
,
1349 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1355 u16 u16WidID
= (u16
)WID_NIL
;
1358 u8 u8MacStatusReasonCode
;
1359 u8 u8MacStatusAdditionalInfo
;
1360 struct connect_info strConnectInfo
;
1361 struct disconnect_info strDisconnectNotifInfo
;
1363 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1366 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1370 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1371 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1372 hif_drv
->usr_scan_req
.scan_result
) {
1373 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1374 !hif_drv
->usr_conn_req
.conn_result
) {
1375 netdev_err(vif
->ndev
, "driver is null\n");
1379 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1381 if ('I' != u8MsgType
) {
1382 netdev_err(vif
->ndev
, "Received Message incorrect.\n");
1386 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1387 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1388 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1389 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1390 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1391 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1392 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1393 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1394 u32 u32RcvdAssocRespInfoLen
= 0;
1395 struct connect_resp_info
*pstrConnectRespInfo
= NULL
;
1397 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1399 if (u8MacStatus
== MAC_CONNECTED
) {
1400 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1402 host_int_get_assoc_res_info(vif
,
1404 MAX_ASSOC_RESP_FRAME_SIZE
,
1405 &u32RcvdAssocRespInfoLen
);
1407 if (u32RcvdAssocRespInfoLen
!= 0) {
1408 s32Err
= wilc_parse_assoc_resp_info(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1409 &pstrConnectRespInfo
);
1411 netdev_err(vif
->ndev
, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err
);
1413 strConnectInfo
.status
= pstrConnectRespInfo
->status
;
1415 if (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
) {
1416 if (pstrConnectRespInfo
->ies
) {
1417 strConnectInfo
.resp_ies_len
= pstrConnectRespInfo
->ies_len
;
1418 strConnectInfo
.resp_ies
= kmalloc(pstrConnectRespInfo
->ies_len
, GFP_KERNEL
);
1419 memcpy(strConnectInfo
.resp_ies
, pstrConnectRespInfo
->ies
,
1420 pstrConnectRespInfo
->ies_len
);
1424 if (pstrConnectRespInfo
) {
1425 kfree(pstrConnectRespInfo
->ies
);
1426 kfree(pstrConnectRespInfo
);
1432 if ((u8MacStatus
== MAC_CONNECTED
) &&
1433 (strConnectInfo
.status
!= SUCCESSFUL_STATUSCODE
)) {
1434 netdev_err(vif
->ndev
, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1435 eth_zero_addr(wilc_connected_ssid
);
1436 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1437 netdev_err(vif
->ndev
, "Received MAC status is MAC_DISCONNECTED\n");
1438 eth_zero_addr(wilc_connected_ssid
);
1441 if (hif_drv
->usr_conn_req
.bssid
) {
1442 memcpy(strConnectInfo
.bssid
, hif_drv
->usr_conn_req
.bssid
, 6);
1444 if ((u8MacStatus
== MAC_CONNECTED
) &&
1445 (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
)) {
1446 memcpy(hif_drv
->assoc_bssid
,
1447 hif_drv
->usr_conn_req
.bssid
, ETH_ALEN
);
1451 if (hif_drv
->usr_conn_req
.ies
) {
1452 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1453 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1454 memcpy(strConnectInfo
.req_ies
,
1455 hif_drv
->usr_conn_req
.ies
,
1456 hif_drv
->usr_conn_req
.ies_len
);
1459 del_timer(&hif_drv
->connect_timer
);
1460 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1464 hif_drv
->usr_conn_req
.arg
);
1466 if ((u8MacStatus
== MAC_CONNECTED
) &&
1467 (strConnectInfo
.status
== SUCCESSFUL_STATUSCODE
)) {
1468 wilc_set_power_mgmt(vif
, 0, 0);
1470 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1472 wilc_optaining_ip
= true;
1473 mod_timer(&wilc_during_ip_timer
,
1474 jiffies
+ msecs_to_jiffies(10000));
1476 hif_drv
->hif_state
= HOST_IF_IDLE
;
1477 scan_while_connected
= false;
1480 kfree(strConnectInfo
.resp_ies
);
1481 strConnectInfo
.resp_ies
= NULL
;
1483 kfree(strConnectInfo
.req_ies
);
1484 strConnectInfo
.req_ies
= NULL
;
1485 hif_drv
->usr_conn_req
.ssid_len
= 0;
1486 kfree(hif_drv
->usr_conn_req
.ssid
);
1487 hif_drv
->usr_conn_req
.ssid
= NULL
;
1488 kfree(hif_drv
->usr_conn_req
.bssid
);
1489 hif_drv
->usr_conn_req
.bssid
= NULL
;
1490 hif_drv
->usr_conn_req
.ies_len
= 0;
1491 kfree(hif_drv
->usr_conn_req
.ies
);
1492 hif_drv
->usr_conn_req
.ies
= NULL
;
1493 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1494 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1495 memset(&strDisconnectNotifInfo
, 0, sizeof(struct disconnect_info
));
1497 if (hif_drv
->usr_scan_req
.scan_result
) {
1498 del_timer(&hif_drv
->scan_timer
);
1499 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1502 strDisconnectNotifInfo
.reason
= 0;
1503 strDisconnectNotifInfo
.ie
= NULL
;
1504 strDisconnectNotifInfo
.ie_len
= 0;
1506 if (hif_drv
->usr_conn_req
.conn_result
) {
1507 wilc_optaining_ip
= false;
1508 wilc_set_power_mgmt(vif
, 0, 0);
1510 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1513 &strDisconnectNotifInfo
,
1514 hif_drv
->usr_conn_req
.arg
);
1516 netdev_err(vif
->ndev
, "Connect result NULL\n");
1519 eth_zero_addr(hif_drv
->assoc_bssid
);
1521 hif_drv
->usr_conn_req
.ssid_len
= 0;
1522 kfree(hif_drv
->usr_conn_req
.ssid
);
1523 hif_drv
->usr_conn_req
.ssid
= NULL
;
1524 kfree(hif_drv
->usr_conn_req
.bssid
);
1525 hif_drv
->usr_conn_req
.bssid
= NULL
;
1526 hif_drv
->usr_conn_req
.ies_len
= 0;
1527 kfree(hif_drv
->usr_conn_req
.ies
);
1528 hif_drv
->usr_conn_req
.ies
= NULL
;
1530 if (join_req
&& join_req_vif
== vif
) {
1535 if (info_element
&& join_req_vif
== vif
) {
1536 kfree(info_element
);
1537 info_element
= NULL
;
1540 hif_drv
->hif_state
= HOST_IF_IDLE
;
1541 scan_while_connected
= false;
1543 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1544 (hif_drv
->usr_scan_req
.scan_result
)) {
1545 del_timer(&hif_drv
->scan_timer
);
1546 if (hif_drv
->usr_scan_req
.scan_result
)
1547 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1551 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1552 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1557 static int Handle_Key(struct wilc_vif
*vif
,
1558 struct key_attr
*pstrHostIFkeyAttr
)
1562 struct wid strWIDList
[5];
1567 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1569 switch (pstrHostIFkeyAttr
->type
) {
1572 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1573 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1574 strWIDList
[0].type
= WID_CHAR
;
1575 strWIDList
[0].size
= sizeof(char);
1576 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1578 strWIDList
[1].id
= WID_AUTH_TYPE
;
1579 strWIDList
[1].type
= WID_CHAR
;
1580 strWIDList
[1].size
= sizeof(char);
1581 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1583 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2,
1588 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1589 pu8keybuf
[1] = pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1591 memcpy(&pu8keybuf
[2], pstrHostIFkeyAttr
->attr
.wep
.key
,
1592 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1594 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1596 strWIDList
[2].id
= (u16
)WID_WEP_KEY_VALUE
;
1597 strWIDList
[2].type
= WID_STR
;
1598 strWIDList
[2].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1599 strWIDList
[2].val
= (s8
*)pu8keybuf
;
1601 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1603 wilc_get_vif_idx(vif
));
1605 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1606 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1609 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1610 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1611 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1612 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1613 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1615 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1617 wid
.val
= (s8
*)pu8keybuf
;
1618 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1620 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1622 wilc_get_vif_idx(vif
));
1624 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1625 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1628 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1629 wid
.val
= s8idxarray
;
1632 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1634 wilc_get_vif_idx(vif
));
1635 } else if (pstrHostIFkeyAttr
->action
& DEFAULTKEY
) {
1636 wid
.id
= (u16
)WID_KEY_ID
;
1637 wid
.type
= WID_CHAR
;
1638 wid
.val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1639 wid
.size
= sizeof(char);
1641 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1643 wilc_get_vif_idx(vif
));
1645 up(&hif_drv
->sem_test_key_block
);
1649 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1650 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1653 goto _WPARxGtk_end_case_
;
1656 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1657 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1659 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1660 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1661 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1662 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1664 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1665 strWIDList
[0].type
= WID_CHAR
;
1666 strWIDList
[0].size
= sizeof(char);
1667 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1669 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1670 strWIDList
[1].type
= WID_STR
;
1671 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1672 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1674 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1676 wilc_get_vif_idx(vif
));
1679 up(&hif_drv
->sem_test_key_block
);
1680 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1681 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1682 if (pu8keybuf
== NULL
) {
1684 goto _WPARxGtk_end_case_
;
1687 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
1688 memcpy(pu8keybuf
, hif_drv
->assoc_bssid
, ETH_ALEN
);
1690 netdev_err(vif
->ndev
, "Couldn't handle\n");
1692 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1693 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1694 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1695 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1696 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1698 wid
.id
= (u16
)WID_ADD_RX_GTK
;
1700 wid
.val
= (s8
*)pu8keybuf
;
1701 wid
.size
= RX_MIC_KEY_MSG_LEN
;
1703 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1705 wilc_get_vif_idx(vif
));
1708 up(&hif_drv
->sem_test_key_block
);
1710 _WPARxGtk_end_case_
:
1711 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1712 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1719 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1720 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1723 goto _WPAPtk_end_case_
;
1726 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1727 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1728 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1729 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1730 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1732 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1733 strWIDList
[0].type
= WID_CHAR
;
1734 strWIDList
[0].size
= sizeof(char);
1735 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1737 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1738 strWIDList
[1].type
= WID_STR
;
1739 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1740 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1742 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1744 wilc_get_vif_idx(vif
));
1746 up(&hif_drv
->sem_test_key_block
);
1747 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1748 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1750 netdev_err(vif
->ndev
, "No buffer send PTK\n");
1752 goto _WPAPtk_end_case_
;
1755 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1756 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1757 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1758 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1760 wid
.id
= (u16
)WID_ADD_PTK
;
1762 wid
.val
= (s8
*)pu8keybuf
;
1763 wid
.size
= PTK_KEY_MSG_LEN
;
1765 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1767 wilc_get_vif_idx(vif
));
1769 up(&hif_drv
->sem_test_key_block
);
1773 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1780 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1782 netdev_err(vif
->ndev
, "No buffer to send PMKSA Key\n");
1786 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1788 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1789 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1790 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1793 wid
.id
= (u16
)WID_PMKID_INFO
;
1795 wid
.val
= (s8
*)pu8keybuf
;
1796 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1798 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1799 wilc_get_vif_idx(vif
));
1806 netdev_err(vif
->ndev
, "Failed to send key config packet\n");
1811 static void Handle_Disconnect(struct wilc_vif
*vif
)
1814 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1817 u16 u16DummyReasonCode
= 0;
1819 wid
.id
= (u16
)WID_DISCONNECT
;
1820 wid
.type
= WID_CHAR
;
1821 wid
.val
= (s8
*)&u16DummyReasonCode
;
1822 wid
.size
= sizeof(char);
1824 wilc_optaining_ip
= false;
1825 wilc_set_power_mgmt(vif
, 0, 0);
1827 eth_zero_addr(wilc_connected_ssid
);
1829 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1830 wilc_get_vif_idx(vif
));
1833 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1835 struct disconnect_info strDisconnectNotifInfo
;
1837 memset(&strDisconnectNotifInfo
, 0, sizeof(struct disconnect_info
));
1839 strDisconnectNotifInfo
.reason
= 0;
1840 strDisconnectNotifInfo
.ie
= NULL
;
1841 strDisconnectNotifInfo
.ie_len
= 0;
1843 if (hif_drv
->usr_scan_req
.scan_result
) {
1844 del_timer(&hif_drv
->scan_timer
);
1845 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
1847 hif_drv
->usr_scan_req
.arg
,
1849 hif_drv
->usr_scan_req
.scan_result
= NULL
;
1852 if (hif_drv
->usr_conn_req
.conn_result
) {
1853 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
)
1854 del_timer(&hif_drv
->connect_timer
);
1856 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1859 &strDisconnectNotifInfo
,
1860 hif_drv
->usr_conn_req
.arg
);
1862 netdev_err(vif
->ndev
, "conn_result = NULL\n");
1865 scan_while_connected
= false;
1867 hif_drv
->hif_state
= HOST_IF_IDLE
;
1869 eth_zero_addr(hif_drv
->assoc_bssid
);
1871 hif_drv
->usr_conn_req
.ssid_len
= 0;
1872 kfree(hif_drv
->usr_conn_req
.ssid
);
1873 hif_drv
->usr_conn_req
.ssid
= NULL
;
1874 kfree(hif_drv
->usr_conn_req
.bssid
);
1875 hif_drv
->usr_conn_req
.bssid
= NULL
;
1876 hif_drv
->usr_conn_req
.ies_len
= 0;
1877 kfree(hif_drv
->usr_conn_req
.ies
);
1878 hif_drv
->usr_conn_req
.ies
= NULL
;
1880 if (join_req
&& join_req_vif
== vif
) {
1885 if (info_element
&& join_req_vif
== vif
) {
1886 kfree(info_element
);
1887 info_element
= NULL
;
1891 up(&hif_drv
->sem_test_disconn_block
);
1894 void wilc_resolve_disconnect_aberration(struct wilc_vif
*vif
)
1898 if ((vif
->hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1899 (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTING
))
1900 wilc_disconnect(vif
, 1);
1903 static void Handle_GetRssi(struct wilc_vif
*vif
)
1908 wid
.id
= (u16
)WID_RSSI
;
1909 wid
.type
= WID_CHAR
;
1911 wid
.size
= sizeof(char);
1913 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1914 wilc_get_vif_idx(vif
));
1916 netdev_err(vif
->ndev
, "Failed to get RSSI value\n");
1920 up(&vif
->hif_drv
->sem_get_rssi
);
1923 static s32
Handle_GetStatistics(struct wilc_vif
*vif
,
1924 struct rf_info
*pstrStatistics
)
1926 struct wid strWIDList
[5];
1927 u32 u32WidsCount
= 0, result
= 0;
1929 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
1930 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1931 strWIDList
[u32WidsCount
].size
= sizeof(char);
1932 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
1935 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
1936 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1937 strWIDList
[u32WidsCount
].size
= sizeof(char);
1938 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
1941 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
1942 strWIDList
[u32WidsCount
].type
= WID_INT
;
1943 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1944 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
1947 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
1948 strWIDList
[u32WidsCount
].type
= WID_INT
;
1949 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1950 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
1953 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
1954 strWIDList
[u32WidsCount
].type
= WID_INT
;
1955 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
1956 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
1959 result
= wilc_send_config_pkt(vif
, GET_CFG
, strWIDList
,
1961 wilc_get_vif_idx(vif
));
1964 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
1966 if (pstrStatistics
->link_speed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
&&
1967 pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
1968 wilc_enable_tcp_ack_filter(true);
1969 else if (pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
1970 wilc_enable_tcp_ack_filter(false);
1972 if (pstrStatistics
!= &vif
->wilc
->dummy_statistics
)
1973 up(&hif_sema_wait_response
);
1977 static s32
Handle_Get_InActiveTime(struct wilc_vif
*vif
,
1978 struct sta_inactive_t
*strHostIfStaInactiveT
)
1983 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1985 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
1987 wid
.size
= ETH_ALEN
;
1988 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
1991 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
1993 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1994 wilc_get_vif_idx(vif
));
1997 netdev_err(vif
->ndev
, "Failed to SET incative time\n");
2001 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
2003 wid
.val
= (s8
*)&inactive_time
;
2004 wid
.size
= sizeof(u32
);
2006 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2007 wilc_get_vif_idx(vif
));
2010 netdev_err(vif
->ndev
, "Failed to get incative time\n");
2014 up(&hif_drv
->sem_inactive_time
);
2019 static void Handle_AddBeacon(struct wilc_vif
*vif
,
2020 struct beacon_attr
*pstrSetBeaconParam
)
2026 wid
.id
= (u16
)WID_ADD_BEACON
;
2028 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
2029 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2033 pu8CurrByte
= wid
.val
;
2034 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
2035 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
2036 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
2037 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
2039 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
2040 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
2041 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
2042 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
2044 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
2045 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
2046 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
2047 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
2049 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
2050 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2052 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2053 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2054 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2055 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2057 if (pstrSetBeaconParam
->tail
)
2058 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2059 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2061 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2062 wilc_get_vif_idx(vif
));
2064 netdev_err(vif
->ndev
, "Failed to send add beacon\n");
2068 kfree(pstrSetBeaconParam
->head
);
2069 kfree(pstrSetBeaconParam
->tail
);
2072 static void Handle_DelBeacon(struct wilc_vif
*vif
)
2078 wid
.id
= (u16
)WID_DEL_BEACON
;
2079 wid
.type
= WID_CHAR
;
2080 wid
.size
= sizeof(char);
2081 wid
.val
= &del_beacon
;
2086 pu8CurrByte
= wid
.val
;
2088 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2089 wilc_get_vif_idx(vif
));
2091 netdev_err(vif
->ndev
, "Failed to send delete beacon\n");
2094 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2095 struct add_sta_param
*pstrStationParam
)
2099 pu8CurrByte
= pu8Buffer
;
2101 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2102 pu8CurrByte
+= ETH_ALEN
;
2104 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2105 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2107 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2108 if (pstrStationParam
->rates_len
> 0)
2109 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2110 pstrStationParam
->rates_len
);
2111 pu8CurrByte
+= pstrStationParam
->rates_len
;
2113 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2114 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2115 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2117 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2118 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2119 WILC_SUPP_MCS_SET_SIZE
);
2120 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2122 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2123 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2125 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2126 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2127 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2128 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2130 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2132 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2133 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2135 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2136 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2138 return pu8CurrByte
- pu8Buffer
;
2141 static void Handle_AddStation(struct wilc_vif
*vif
,
2142 struct add_sta_param
*pstrStationParam
)
2148 wid
.id
= (u16
)WID_ADD_STA
;
2150 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2152 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2156 pu8CurrByte
= wid
.val
;
2157 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2159 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2160 wilc_get_vif_idx(vif
));
2162 netdev_err(vif
->ndev
, "Failed to send add station\n");
2165 kfree(pstrStationParam
->rates
);
2169 static void Handle_DelAllSta(struct wilc_vif
*vif
,
2170 struct del_all_sta
*pstrDelAllStaParam
)
2176 u8 au8Zero_Buff
[6] = {0};
2178 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2180 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2182 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2186 pu8CurrByte
= wid
.val
;
2188 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2190 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2191 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2192 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2196 pu8CurrByte
+= ETH_ALEN
;
2199 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2200 wilc_get_vif_idx(vif
));
2202 netdev_err(vif
->ndev
, "Failed to send add station\n");
2207 up(&hif_sema_wait_response
);
2210 static void Handle_DelStation(struct wilc_vif
*vif
,
2211 struct del_sta
*pstrDelStaParam
)
2217 wid
.id
= (u16
)WID_REMOVE_STA
;
2219 wid
.size
= ETH_ALEN
;
2221 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2225 pu8CurrByte
= wid
.val
;
2227 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2229 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2230 wilc_get_vif_idx(vif
));
2232 netdev_err(vif
->ndev
, "Failed to send add station\n");
2238 static void Handle_EditStation(struct wilc_vif
*vif
,
2239 struct add_sta_param
*pstrStationParam
)
2245 wid
.id
= (u16
)WID_EDIT_STA
;
2247 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2249 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2253 pu8CurrByte
= wid
.val
;
2254 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2256 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2257 wilc_get_vif_idx(vif
));
2259 netdev_err(vif
->ndev
, "Failed to send edit station\n");
2262 kfree(pstrStationParam
->rates
);
2266 static int Handle_RemainOnChan(struct wilc_vif
*vif
,
2267 struct remain_ch
*pstrHostIfRemainOnChan
)
2270 u8 u8remain_on_chan_flag
;
2272 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2274 if (!hif_drv
->remain_on_ch_pending
) {
2275 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2276 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2277 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2278 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2279 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2281 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2284 if (hif_drv
->usr_scan_req
.scan_result
) {
2285 hif_drv
->remain_on_ch_pending
= 1;
2289 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2294 if (wilc_optaining_ip
|| wilc_connecting
) {
2299 u8remain_on_chan_flag
= true;
2300 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2303 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2309 wid
.val
[0] = u8remain_on_chan_flag
;
2310 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2312 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2313 wilc_get_vif_idx(vif
));
2315 netdev_err(vif
->ndev
, "Failed to set remain on channel\n");
2319 P2P_LISTEN_STATE
= 1;
2320 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)vif
;
2321 mod_timer(&hif_drv
->remain_on_ch_timer
,
2323 msecs_to_jiffies(pstrHostIfRemainOnChan
->duration
));
2325 if (hif_drv
->remain_on_ch
.ready
)
2326 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2328 if (hif_drv
->remain_on_ch_pending
)
2329 hif_drv
->remain_on_ch_pending
= 0;
2335 static int Handle_RegisterFrame(struct wilc_vif
*vif
,
2336 struct reg_frame
*pstrHostIfRegisterFrame
)
2342 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2344 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2348 pu8CurrByte
= wid
.val
;
2350 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2351 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2352 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2354 wid
.size
= sizeof(u16
) + 2;
2356 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2357 wilc_get_vif_idx(vif
));
2359 netdev_err(vif
->ndev
, "Failed to frame register\n");
2366 static u32
Handle_ListenStateExpired(struct wilc_vif
*vif
,
2367 struct remain_ch
*pstrHostIfRemainOnChan
)
2369 u8 u8remain_on_chan_flag
;
2372 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2374 if (P2P_LISTEN_STATE
) {
2375 u8remain_on_chan_flag
= false;
2376 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2379 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2382 netdev_err(vif
->ndev
, "Failed to allocate memory\n");
2386 wid
.val
[0] = u8remain_on_chan_flag
;
2387 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2389 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2390 wilc_get_vif_idx(vif
));
2392 netdev_err(vif
->ndev
, "Failed to set remain channel\n");
2396 if (hif_drv
->remain_on_ch
.expired
) {
2397 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2398 pstrHostIfRemainOnChan
->id
);
2400 P2P_LISTEN_STATE
= 0;
2402 netdev_dbg(vif
->ndev
, "Not in listen state\n");
2410 static void ListenTimerCB(unsigned long arg
)
2413 struct host_if_msg msg
;
2414 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2416 del_timer(&vif
->hif_drv
->remain_on_ch_timer
);
2418 memset(&msg
, 0, sizeof(struct host_if_msg
));
2419 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2421 msg
.body
.remain_on_ch
.id
= vif
->hif_drv
->remain_on_ch
.id
;
2423 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2425 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
2428 static void Handle_PowerManagement(struct wilc_vif
*vif
,
2429 struct power_mgmt_param
*strPowerMgmtParam
)
2435 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2437 if (strPowerMgmtParam
->enabled
)
2438 s8PowerMode
= MIN_FAST_PS
;
2440 s8PowerMode
= NO_POWERSAVE
;
2442 wid
.val
= &s8PowerMode
;
2443 wid
.size
= sizeof(char);
2445 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2446 wilc_get_vif_idx(vif
));
2448 netdev_err(vif
->ndev
, "Failed to send power management\n");
2451 static void Handle_SetMulticastFilter(struct wilc_vif
*vif
,
2452 struct set_multicast
*strHostIfSetMulti
)
2458 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2460 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2461 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2465 pu8CurrByte
= wid
.val
;
2466 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2471 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2472 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2473 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2474 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2476 if ((strHostIfSetMulti
->cnt
) > 0)
2477 memcpy(pu8CurrByte
, wilc_multicast_mac_addr_list
,
2478 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2480 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2481 wilc_get_vif_idx(vif
));
2483 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2489 static void handle_set_tx_pwr(struct wilc_vif
*vif
, u8 tx_pwr
)
2494 wid
.id
= (u16
)WID_TX_POWER
;
2495 wid
.type
= WID_CHAR
;
2497 wid
.size
= sizeof(char);
2499 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2500 wilc_get_vif_idx(vif
));
2502 netdev_err(vif
->ndev
, "Failed to set TX PWR\n");
2505 static void handle_get_tx_pwr(struct wilc_vif
*vif
, u8
*tx_pwr
)
2510 wid
.id
= (u16
)WID_TX_POWER
;
2511 wid
.type
= WID_CHAR
;
2512 wid
.val
= (s8
*)tx_pwr
;
2513 wid
.size
= sizeof(char);
2515 ret
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2516 wilc_get_vif_idx(vif
));
2518 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
2520 up(&hif_sema_wait_response
);
2523 static int hostIFthread(void *pvArg
)
2526 struct host_if_msg msg
;
2527 struct wilc
*wilc
= pvArg
;
2528 struct wilc_vif
*vif
;
2530 memset(&msg
, 0, sizeof(struct host_if_msg
));
2533 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2535 if (msg
.id
== HOST_IF_MSG_EXIT
)
2538 if ((!wilc_initialized
)) {
2539 usleep_range(200 * 1000, 200 * 1000);
2540 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2544 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2545 vif
->hif_drv
->usr_scan_req
.scan_result
) {
2546 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2547 usleep_range(2 * 1000, 2 * 1000);
2552 case HOST_IF_MSG_Q_IDLE
:
2553 Handle_wait_msg_q_empty();
2556 case HOST_IF_MSG_SCAN
:
2557 Handle_Scan(msg
.vif
, &msg
.body
.scan_info
);
2560 case HOST_IF_MSG_CONNECT
:
2561 Handle_Connect(msg
.vif
, &msg
.body
.con_info
);
2564 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2565 Handle_RcvdNtwrkInfo(msg
.vif
, &msg
.body
.net_info
);
2568 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2569 Handle_RcvdGnrlAsyncInfo(vif
,
2570 &msg
.body
.async_info
);
2573 case HOST_IF_MSG_KEY
:
2574 Handle_Key(msg
.vif
, &msg
.body
.key_info
);
2577 case HOST_IF_MSG_CFG_PARAMS
:
2578 handle_cfg_param(msg
.vif
, &msg
.body
.cfg_info
);
2581 case HOST_IF_MSG_SET_CHANNEL
:
2582 handle_set_channel(msg
.vif
, &msg
.body
.channel_info
);
2585 case HOST_IF_MSG_DISCONNECT
:
2586 Handle_Disconnect(msg
.vif
);
2589 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2590 del_timer(&vif
->hif_drv
->scan_timer
);
2592 if (!wilc_wlan_get_num_conn_ifcs(wilc
))
2593 wilc_chip_sleep_manually(wilc
);
2595 Handle_ScanDone(msg
.vif
, SCAN_EVENT_DONE
);
2597 if (vif
->hif_drv
->remain_on_ch_pending
)
2598 Handle_RemainOnChan(msg
.vif
,
2599 &msg
.body
.remain_on_ch
);
2603 case HOST_IF_MSG_GET_RSSI
:
2604 Handle_GetRssi(msg
.vif
);
2607 case HOST_IF_MSG_GET_STATISTICS
:
2608 Handle_GetStatistics(msg
.vif
,
2609 (struct rf_info
*)msg
.body
.data
);
2612 case HOST_IF_MSG_ADD_BEACON
:
2613 Handle_AddBeacon(msg
.vif
, &msg
.body
.beacon_info
);
2616 case HOST_IF_MSG_DEL_BEACON
:
2617 Handle_DelBeacon(msg
.vif
);
2620 case HOST_IF_MSG_ADD_STATION
:
2621 Handle_AddStation(msg
.vif
, &msg
.body
.add_sta_info
);
2624 case HOST_IF_MSG_DEL_STATION
:
2625 Handle_DelStation(msg
.vif
, &msg
.body
.del_sta_info
);
2628 case HOST_IF_MSG_EDIT_STATION
:
2629 Handle_EditStation(msg
.vif
, &msg
.body
.edit_sta_info
);
2632 case HOST_IF_MSG_GET_INACTIVETIME
:
2633 Handle_Get_InActiveTime(msg
.vif
, &msg
.body
.mac_info
);
2636 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2638 Handle_ScanDone(msg
.vif
, SCAN_EVENT_ABORTED
);
2641 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2642 Handle_ConnectTimeout(msg
.vif
);
2645 case HOST_IF_MSG_POWER_MGMT
:
2646 Handle_PowerManagement(msg
.vif
,
2647 &msg
.body
.pwr_mgmt_info
);
2650 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2651 handle_set_wfi_drv_handler(msg
.vif
, &msg
.body
.drv
);
2654 case HOST_IF_MSG_SET_OPERATION_MODE
:
2655 handle_set_operation_mode(msg
.vif
, &msg
.body
.mode
);
2658 case HOST_IF_MSG_SET_IPADDRESS
:
2659 handle_set_ip_address(vif
,
2660 msg
.body
.ip_info
.ip_addr
,
2661 msg
.body
.ip_info
.idx
);
2664 case HOST_IF_MSG_GET_IPADDRESS
:
2665 handle_get_ip_address(vif
, msg
.body
.ip_info
.idx
);
2668 case HOST_IF_MSG_SET_MAC_ADDRESS
:
2669 handle_set_mac_address(msg
.vif
,
2670 &msg
.body
.set_mac_info
);
2673 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2674 handle_get_mac_address(msg
.vif
,
2675 &msg
.body
.get_mac_info
);
2678 case HOST_IF_MSG_REMAIN_ON_CHAN
:
2679 Handle_RemainOnChan(msg
.vif
, &msg
.body
.remain_on_ch
);
2682 case HOST_IF_MSG_REGISTER_FRAME
:
2683 Handle_RegisterFrame(msg
.vif
, &msg
.body
.reg_frame
);
2686 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
2687 Handle_ListenStateExpired(msg
.vif
, &msg
.body
.remain_on_ch
);
2690 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
2691 Handle_SetMulticastFilter(msg
.vif
, &msg
.body
.multicast_info
);
2694 case HOST_IF_MSG_DEL_ALL_STA
:
2695 Handle_DelAllSta(msg
.vif
, &msg
.body
.del_all_sta_info
);
2698 case HOST_IF_MSG_SET_TX_POWER
:
2699 handle_set_tx_pwr(msg
.vif
, msg
.body
.tx_power
.tx_pwr
);
2702 case HOST_IF_MSG_GET_TX_POWER
:
2703 handle_get_tx_pwr(msg
.vif
, &msg
.body
.tx_power
.tx_pwr
);
2706 netdev_err(vif
->ndev
, "[Host Interface] undefined\n");
2711 up(&hif_sema_thread
);
2715 static void TimerCB_Scan(unsigned long arg
)
2717 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2718 struct host_if_msg msg
;
2720 memset(&msg
, 0, sizeof(struct host_if_msg
));
2722 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
2724 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2727 static void TimerCB_Connect(unsigned long arg
)
2729 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2730 struct host_if_msg msg
;
2732 memset(&msg
, 0, sizeof(struct host_if_msg
));
2734 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
2736 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2739 s32
wilc_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
2743 wid
.id
= (u16
)WID_REMOVE_KEY
;
2745 wid
.val
= (s8
*)pu8StaAddress
;
2751 int wilc_remove_wep_key(struct wilc_vif
*vif
, u8 index
)
2754 struct host_if_msg msg
;
2755 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2759 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2763 memset(&msg
, 0, sizeof(struct host_if_msg
));
2765 msg
.id
= HOST_IF_MSG_KEY
;
2766 msg
.body
.key_info
.type
= WEP
;
2767 msg
.body
.key_info
.action
= REMOVEKEY
;
2769 msg
.body
.key_info
.attr
.wep
.index
= index
;
2771 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2773 netdev_err(vif
->ndev
, "Request to remove WEP key\n");
2774 down(&hif_drv
->sem_test_key_block
);
2779 int wilc_set_wep_default_keyid(struct wilc_vif
*vif
, u8 index
)
2782 struct host_if_msg msg
;
2783 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2787 netdev_err(vif
->ndev
, "driver is null\n");
2791 memset(&msg
, 0, sizeof(struct host_if_msg
));
2793 msg
.id
= HOST_IF_MSG_KEY
;
2794 msg
.body
.key_info
.type
= WEP
;
2795 msg
.body
.key_info
.action
= DEFAULTKEY
;
2797 msg
.body
.key_info
.attr
.wep
.index
= index
;
2799 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2801 netdev_err(vif
->ndev
, "Default key index\n");
2802 down(&hif_drv
->sem_test_key_block
);
2807 int wilc_add_wep_key_bss_sta(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2811 struct host_if_msg msg
;
2812 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2815 netdev_err(vif
->ndev
, "driver is null\n");
2819 memset(&msg
, 0, sizeof(struct host_if_msg
));
2821 msg
.id
= HOST_IF_MSG_KEY
;
2822 msg
.body
.key_info
.type
= WEP
;
2823 msg
.body
.key_info
.action
= ADDKEY
;
2825 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2826 if (!msg
.body
.key_info
.attr
.wep
.key
)
2829 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2830 msg
.body
.key_info
.attr
.wep
.index
= index
;
2832 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2834 netdev_err(vif
->ndev
, "STA - WEP Key\n");
2835 down(&hif_drv
->sem_test_key_block
);
2840 int wilc_add_wep_key_bss_ap(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2841 u8 index
, u8 mode
, enum AUTHTYPE auth_type
)
2844 struct host_if_msg msg
;
2845 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2848 netdev_err(vif
->ndev
, "driver is null\n");
2852 memset(&msg
, 0, sizeof(struct host_if_msg
));
2854 msg
.id
= HOST_IF_MSG_KEY
;
2855 msg
.body
.key_info
.type
= WEP
;
2856 msg
.body
.key_info
.action
= ADDKEY_AP
;
2858 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2859 if (!msg
.body
.key_info
.attr
.wep
.key
)
2862 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2863 msg
.body
.key_info
.attr
.wep
.index
= index
;
2864 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
2865 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
2867 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2870 netdev_err(vif
->ndev
, "AP - WEP Key\n");
2871 down(&hif_drv
->sem_test_key_block
);
2876 int wilc_add_ptk(struct wilc_vif
*vif
, const u8
*ptk
, u8 ptk_key_len
,
2877 const u8
*mac_addr
, const u8
*rx_mic
, const u8
*tx_mic
,
2878 u8 mode
, u8 cipher_mode
, u8 index
)
2881 struct host_if_msg msg
;
2882 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2883 u8 key_len
= ptk_key_len
;
2886 netdev_err(vif
->ndev
, "driver is null\n");
2891 key_len
+= RX_MIC_KEY_LEN
;
2894 key_len
+= TX_MIC_KEY_LEN
;
2896 memset(&msg
, 0, sizeof(struct host_if_msg
));
2898 msg
.id
= HOST_IF_MSG_KEY
;
2899 msg
.body
.key_info
.type
= WPA_PTK
;
2900 if (mode
== AP_MODE
) {
2901 msg
.body
.key_info
.action
= ADDKEY_AP
;
2902 msg
.body
.key_info
.attr
.wpa
.index
= index
;
2904 if (mode
== STATION_MODE
)
2905 msg
.body
.key_info
.action
= ADDKEY
;
2907 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
2908 if (!msg
.body
.key_info
.attr
.wpa
.key
)
2912 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
2915 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
2917 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
2918 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
2919 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
2922 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2925 netdev_err(vif
->ndev
, "PTK Key\n");
2927 down(&hif_drv
->sem_test_key_block
);
2932 int wilc_add_rx_gtk(struct wilc_vif
*vif
, const u8
*rx_gtk
, u8 gtk_key_len
,
2933 u8 index
, u32 key_rsc_len
, const u8
*key_rsc
,
2934 const u8
*rx_mic
, const u8
*tx_mic
, u8 mode
,
2938 struct host_if_msg msg
;
2939 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2940 u8 key_len
= gtk_key_len
;
2943 netdev_err(vif
->ndev
, "driver is null\n");
2946 memset(&msg
, 0, sizeof(struct host_if_msg
));
2949 key_len
+= RX_MIC_KEY_LEN
;
2952 key_len
+= TX_MIC_KEY_LEN
;
2955 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
2958 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
2962 msg
.id
= HOST_IF_MSG_KEY
;
2963 msg
.body
.key_info
.type
= WPA_RX_GTK
;
2966 if (mode
== AP_MODE
) {
2967 msg
.body
.key_info
.action
= ADDKEY_AP
;
2968 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
2970 if (mode
== STATION_MODE
)
2971 msg
.body
.key_info
.action
= ADDKEY
;
2973 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
2976 if (!msg
.body
.key_info
.attr
.wpa
.key
)
2980 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
2984 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
2987 msg
.body
.key_info
.attr
.wpa
.index
= index
;
2988 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
2989 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
2991 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2993 netdev_err(vif
->ndev
, "RX GTK\n");
2995 down(&hif_drv
->sem_test_key_block
);
3000 int wilc_set_pmkid_info(struct wilc_vif
*vif
,
3001 struct host_if_pmkid_attr
*pmkid
)
3004 struct host_if_msg msg
;
3005 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3009 netdev_err(vif
->ndev
, "driver is null\n");
3013 memset(&msg
, 0, sizeof(struct host_if_msg
));
3015 msg
.id
= HOST_IF_MSG_KEY
;
3016 msg
.body
.key_info
.type
= PMKSA
;
3017 msg
.body
.key_info
.action
= ADDKEY
;
3020 for (i
= 0; i
< pmkid
->numpmkid
; i
++) {
3021 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
3022 &pmkid
->pmkidlist
[i
].bssid
, ETH_ALEN
);
3023 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
3024 &pmkid
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
3027 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3029 netdev_err(vif
->ndev
, "PMKID Info\n");
3034 int wilc_get_mac_address(struct wilc_vif
*vif
, u8
*mac_addr
)
3037 struct host_if_msg msg
;
3039 memset(&msg
, 0, sizeof(struct host_if_msg
));
3041 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
3042 msg
.body
.get_mac_info
.mac_addr
= mac_addr
;
3045 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3047 netdev_err(vif
->ndev
, "Failed to send get mac address\n");
3051 down(&hif_sema_wait_response
);
3055 int wilc_set_join_req(struct wilc_vif
*vif
, u8
*bssid
, const u8
*ssid
,
3056 size_t ssid_len
, const u8
*ies
, size_t ies_len
,
3057 wilc_connect_result connect_result
, void *user_arg
,
3058 u8 security
, enum AUTHTYPE auth_type
,
3059 u8 channel
, void *join_params
)
3062 struct host_if_msg msg
;
3063 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3065 if (!hif_drv
|| !connect_result
) {
3066 netdev_err(vif
->ndev
, "Driver is null\n");
3071 netdev_err(vif
->ndev
, "Unable to Join - JoinParams is NULL\n");
3075 memset(&msg
, 0, sizeof(struct host_if_msg
));
3077 msg
.id
= HOST_IF_MSG_CONNECT
;
3079 msg
.body
.con_info
.security
= security
;
3080 msg
.body
.con_info
.auth_type
= auth_type
;
3081 msg
.body
.con_info
.ch
= channel
;
3082 msg
.body
.con_info
.result
= connect_result
;
3083 msg
.body
.con_info
.arg
= user_arg
;
3084 msg
.body
.con_info
.params
= join_params
;
3088 msg
.body
.con_info
.bssid
= kmemdup(bssid
, 6, GFP_KERNEL
);
3089 if (!msg
.body
.con_info
.bssid
)
3094 msg
.body
.con_info
.ssid_len
= ssid_len
;
3095 msg
.body
.con_info
.ssid
= kmemdup(ssid
, ssid_len
, GFP_KERNEL
);
3096 if (!msg
.body
.con_info
.ssid
)
3101 msg
.body
.con_info
.ies_len
= ies_len
;
3102 msg
.body
.con_info
.ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3103 if (!msg
.body
.con_info
.ies
)
3106 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3107 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3109 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3111 netdev_err(vif
->ndev
, "send message: Set join request\n");
3115 hif_drv
->connect_timer
.data
= (unsigned long)vif
;
3116 mod_timer(&hif_drv
->connect_timer
,
3117 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3122 int wilc_disconnect(struct wilc_vif
*vif
, u16 reason_code
)
3125 struct host_if_msg msg
;
3126 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3129 netdev_err(vif
->ndev
, "Driver is null\n");
3133 memset(&msg
, 0, sizeof(struct host_if_msg
));
3135 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3138 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3140 netdev_err(vif
->ndev
, "Failed to send message: disconnect\n");
3142 down(&hif_drv
->sem_test_disconn_block
);
3147 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
3148 u8
*pu8AssocRespInfo
,
3149 u32 u32MaxAssocRespInfoLen
,
3150 u32
*pu32RcvdAssocRespInfoLen
)
3154 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3157 netdev_err(vif
->ndev
, "Driver is null\n");
3161 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3163 wid
.val
= pu8AssocRespInfo
;
3164 wid
.size
= u32MaxAssocRespInfoLen
;
3166 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
3167 wilc_get_vif_idx(vif
));
3169 *pu32RcvdAssocRespInfoLen
= 0;
3170 netdev_err(vif
->ndev
, "Failed to send association response\n");
3174 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3178 int wilc_set_mac_chnl_num(struct wilc_vif
*vif
, u8 channel
)
3181 struct host_if_msg msg
;
3182 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3185 netdev_err(vif
->ndev
, "driver is null\n");
3189 memset(&msg
, 0, sizeof(struct host_if_msg
));
3190 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3191 msg
.body
.channel_info
.set_ch
= channel
;
3194 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3196 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3203 int wilc_set_wfi_drv_handler(struct wilc_vif
*vif
, int index
, u8 mac_idx
)
3206 struct host_if_msg msg
;
3208 memset(&msg
, 0, sizeof(struct host_if_msg
));
3209 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3210 msg
.body
.drv
.handler
= index
;
3211 msg
.body
.drv
.mac_idx
= mac_idx
;
3214 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3216 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3223 int wilc_set_operation_mode(struct wilc_vif
*vif
, u32 mode
)
3226 struct host_if_msg msg
;
3228 memset(&msg
, 0, sizeof(struct host_if_msg
));
3229 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3230 msg
.body
.mode
.mode
= mode
;
3233 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3235 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3242 s32
wilc_get_inactive_time(struct wilc_vif
*vif
, const u8
*mac
,
3243 u32
*pu32InactiveTime
)
3246 struct host_if_msg msg
;
3247 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3250 netdev_err(vif
->ndev
, "driver is null\n");
3254 memset(&msg
, 0, sizeof(struct host_if_msg
));
3255 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3257 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3260 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3262 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3264 down(&hif_drv
->sem_inactive_time
);
3266 *pu32InactiveTime
= inactive_time
;
3271 int wilc_get_rssi(struct wilc_vif
*vif
, s8
*rssi_level
)
3274 struct host_if_msg msg
;
3275 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3277 memset(&msg
, 0, sizeof(struct host_if_msg
));
3278 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3281 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3283 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3287 down(&hif_drv
->sem_get_rssi
);
3290 netdev_err(vif
->ndev
, "RSS pointer value is null\n");
3299 int wilc_get_statistics(struct wilc_vif
*vif
, struct rf_info
*stats
)
3302 struct host_if_msg msg
;
3304 memset(&msg
, 0, sizeof(struct host_if_msg
));
3305 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3306 msg
.body
.data
= (char *)stats
;
3309 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3311 netdev_err(vif
->ndev
, "Failed to send get host channel\n");
3315 if (stats
!= &vif
->wilc
->dummy_statistics
)
3316 down(&hif_sema_wait_response
);
3320 int wilc_scan(struct wilc_vif
*vif
, u8 scan_source
, u8 scan_type
,
3321 u8
*ch_freq_list
, u8 ch_list_len
, const u8
*ies
,
3322 size_t ies_len
, wilc_scan_result scan_result
, void *user_arg
,
3323 struct hidden_network
*hidden_network
)
3326 struct host_if_msg msg
;
3327 struct scan_attr
*scan_info
= &msg
.body
.scan_info
;
3328 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3330 if (!hif_drv
|| !scan_result
) {
3331 netdev_err(vif
->ndev
, "hif_drv or scan_result = NULL\n");
3335 memset(&msg
, 0, sizeof(struct host_if_msg
));
3337 msg
.id
= HOST_IF_MSG_SCAN
;
3339 if (hidden_network
) {
3340 scan_info
->hidden_network
.net_info
= hidden_network
->net_info
;
3341 scan_info
->hidden_network
.n_ssids
= hidden_network
->n_ssids
;
3345 scan_info
->src
= scan_source
;
3346 scan_info
->type
= scan_type
;
3347 scan_info
->result
= scan_result
;
3348 scan_info
->arg
= user_arg
;
3350 scan_info
->ch_list_len
= ch_list_len
;
3351 scan_info
->ch_freq_list
= kmemdup(ch_freq_list
,
3354 if (!scan_info
->ch_freq_list
)
3357 scan_info
->ies_len
= ies_len
;
3358 scan_info
->ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3359 if (!scan_info
->ies
)
3362 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3364 netdev_err(vif
->ndev
, "Error in sending message queue\n");
3368 hif_drv
->scan_timer
.data
= (unsigned long)vif
;
3369 mod_timer(&hif_drv
->scan_timer
,
3370 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3375 int wilc_hif_set_cfg(struct wilc_vif
*vif
,
3376 struct cfg_param_attr
*cfg_param
)
3379 struct host_if_msg msg
;
3380 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3383 netdev_err(vif
->ndev
, "hif_drv NULL\n");
3387 memset(&msg
, 0, sizeof(struct host_if_msg
));
3388 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3389 msg
.body
.cfg_info
= *cfg_param
;
3392 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3397 static void GetPeriodicRSSI(unsigned long arg
)
3399 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3401 if (!vif
->hif_drv
) {
3402 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
3406 if (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTED
)
3407 wilc_get_statistics(vif
, &vif
->wilc
->dummy_statistics
);
3409 periodic_rssi
.data
= (unsigned long)vif
;
3410 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3413 int wilc_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
3416 struct host_if_drv
*hif_drv
;
3417 struct wilc_vif
*vif
;
3421 vif
= netdev_priv(dev
);
3424 scan_while_connected
= false;
3426 sema_init(&hif_sema_wait_response
, 0);
3428 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
3433 *hif_drv_handler
= hif_drv
;
3434 for (i
= 0; i
< wilc
->vif_num
; i
++)
3435 if (dev
== wilc
->vif
[i
]->ndev
) {
3436 wilc
->vif
[i
]->hif_drv
= hif_drv
;
3440 wilc_optaining_ip
= false;
3442 if (clients_count
== 0) {
3443 sema_init(&hif_sema_thread
, 0);
3444 sema_init(&hif_sema_driver
, 0);
3445 sema_init(&hif_sema_deinit
, 1);
3448 sema_init(&hif_drv
->sem_test_key_block
, 0);
3449 sema_init(&hif_drv
->sem_test_disconn_block
, 0);
3450 sema_init(&hif_drv
->sem_get_rssi
, 0);
3451 sema_init(&hif_drv
->sem_inactive_time
, 0);
3453 if (clients_count
== 0) {
3454 result
= wilc_mq_create(&hif_msg_q
);
3457 netdev_err(vif
->ndev
, "Failed to creat MQ\n");
3461 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
3464 if (IS_ERR(hif_thread_handler
)) {
3465 netdev_err(vif
->ndev
, "Failed to creat Thread\n");
3469 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
3470 (unsigned long)vif
);
3471 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3474 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
3475 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
3476 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
3478 sema_init(&hif_drv
->sem_cfg_values
, 1);
3479 down(&hif_drv
->sem_cfg_values
);
3481 hif_drv
->hif_state
= HOST_IF_IDLE
;
3482 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
3483 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
3484 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
3485 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
3486 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
3488 hif_drv
->p2p_timeout
= 0;
3490 up(&hif_drv
->sem_cfg_values
);
3497 wilc_mq_destroy(&hif_msg_q
);
3502 int wilc_deinit(struct wilc_vif
*vif
)
3505 struct host_if_msg msg
;
3506 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3509 netdev_err(vif
->ndev
, "hif_drv = NULL\n");
3513 down(&hif_sema_deinit
);
3515 terminated_handle
= hif_drv
;
3517 del_timer_sync(&hif_drv
->scan_timer
);
3518 del_timer_sync(&hif_drv
->connect_timer
);
3519 del_timer_sync(&periodic_rssi
);
3520 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
3522 wilc_set_wfi_drv_handler(vif
, 0, 0);
3523 down(&hif_sema_driver
);
3525 if (hif_drv
->usr_scan_req
.scan_result
) {
3526 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
3527 hif_drv
->usr_scan_req
.arg
, NULL
);
3528 hif_drv
->usr_scan_req
.scan_result
= NULL
;
3531 hif_drv
->hif_state
= HOST_IF_IDLE
;
3533 scan_while_connected
= false;
3535 memset(&msg
, 0, sizeof(struct host_if_msg
));
3537 if (clients_count
== 1) {
3538 del_timer_sync(&periodic_rssi
);
3539 msg
.id
= HOST_IF_MSG_EXIT
;
3542 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3544 netdev_err(vif
->ndev
, "deinit : Error(%d)\n", result
);
3546 down(&hif_sema_thread
);
3548 wilc_mq_destroy(&hif_msg_q
);
3554 terminated_handle
= NULL
;
3555 up(&hif_sema_deinit
);
3559 void wilc_network_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3563 struct host_if_msg msg
;
3565 struct host_if_drv
*hif_drv
= NULL
;
3566 struct wilc_vif
*vif
;
3568 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3569 vif
= wilc_get_vif_from_idx(wilc
, id
);
3572 hif_drv
= vif
->hif_drv
;
3574 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3575 netdev_err(vif
->ndev
, "driver not init[%p]\n", hif_drv
);
3579 memset(&msg
, 0, sizeof(struct host_if_msg
));
3581 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
3584 msg
.body
.net_info
.len
= u32Length
;
3585 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3586 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
3588 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3590 netdev_err(vif
->ndev
, "message parameters (%d)\n", result
);
3593 void wilc_gnrl_async_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3597 struct host_if_msg msg
;
3599 struct host_if_drv
*hif_drv
= NULL
;
3600 struct wilc_vif
*vif
;
3602 down(&hif_sema_deinit
);
3604 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3605 vif
= wilc_get_vif_from_idx(wilc
, id
);
3607 up(&hif_sema_deinit
);
3611 hif_drv
= vif
->hif_drv
;
3613 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3614 up(&hif_sema_deinit
);
3618 if (!hif_drv
->usr_conn_req
.conn_result
) {
3619 netdev_err(vif
->ndev
, "there is no current Connect Request\n");
3620 up(&hif_sema_deinit
);
3624 memset(&msg
, 0, sizeof(struct host_if_msg
));
3626 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
3629 msg
.body
.async_info
.len
= u32Length
;
3630 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3631 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
3633 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3635 netdev_err(vif
->ndev
, "synchronous info (%d)\n", result
);
3637 up(&hif_sema_deinit
);
3640 void wilc_scan_complete_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3644 struct host_if_msg msg
;
3646 struct host_if_drv
*hif_drv
= NULL
;
3647 struct wilc_vif
*vif
;
3649 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3650 vif
= wilc_get_vif_from_idx(wilc
, id
);
3653 hif_drv
= vif
->hif_drv
;
3655 if (!hif_drv
|| hif_drv
== terminated_handle
)
3658 if (hif_drv
->usr_scan_req
.scan_result
) {
3659 memset(&msg
, 0, sizeof(struct host_if_msg
));
3661 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
3664 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3666 netdev_err(vif
->ndev
, "complete param (%d)\n", result
);
3670 int wilc_remain_on_channel(struct wilc_vif
*vif
, u32 session_id
,
3671 u32 duration
, u16 chan
,
3672 wilc_remain_on_chan_expired expired
,
3673 wilc_remain_on_chan_ready ready
,
3677 struct host_if_msg msg
;
3678 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3681 netdev_err(vif
->ndev
, "driver is null\n");
3685 memset(&msg
, 0, sizeof(struct host_if_msg
));
3687 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
3688 msg
.body
.remain_on_ch
.ch
= chan
;
3689 msg
.body
.remain_on_ch
.expired
= expired
;
3690 msg
.body
.remain_on_ch
.ready
= ready
;
3691 msg
.body
.remain_on_ch
.arg
= user_arg
;
3692 msg
.body
.remain_on_ch
.duration
= duration
;
3693 msg
.body
.remain_on_ch
.id
= session_id
;
3696 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3698 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3703 int wilc_listen_state_expired(struct wilc_vif
*vif
, u32 session_id
)
3706 struct host_if_msg msg
;
3707 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3710 netdev_err(vif
->ndev
, "driver is null\n");
3714 del_timer(&hif_drv
->remain_on_ch_timer
);
3716 memset(&msg
, 0, sizeof(struct host_if_msg
));
3717 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3719 msg
.body
.remain_on_ch
.id
= session_id
;
3721 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3723 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3728 int wilc_frame_register(struct wilc_vif
*vif
, u16 frame_type
, bool reg
)
3731 struct host_if_msg msg
;
3732 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3735 netdev_err(vif
->ndev
, "driver is null\n");
3739 memset(&msg
, 0, sizeof(struct host_if_msg
));
3741 msg
.id
= HOST_IF_MSG_REGISTER_FRAME
;
3742 switch (frame_type
) {
3744 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
3748 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
3754 msg
.body
.reg_frame
.frame_type
= frame_type
;
3755 msg
.body
.reg_frame
.reg
= reg
;
3758 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3760 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3765 int wilc_add_beacon(struct wilc_vif
*vif
, u32 interval
, u32 dtim_period
,
3766 u32 head_len
, u8
*head
, u32 tail_len
, u8
*tail
)
3769 struct host_if_msg msg
;
3770 struct beacon_attr
*beacon_info
= &msg
.body
.beacon_info
;
3771 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3774 netdev_err(vif
->ndev
, "driver is null\n");
3778 memset(&msg
, 0, sizeof(struct host_if_msg
));
3780 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
3782 beacon_info
->interval
= interval
;
3783 beacon_info
->dtim_period
= dtim_period
;
3784 beacon_info
->head_len
= head_len
;
3785 beacon_info
->head
= kmemdup(head
, head_len
, GFP_KERNEL
);
3786 if (!beacon_info
->head
) {
3790 beacon_info
->tail_len
= tail_len
;
3793 beacon_info
->tail
= kmemdup(tail
, tail_len
, GFP_KERNEL
);
3794 if (!beacon_info
->tail
) {
3799 beacon_info
->tail
= NULL
;
3802 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3804 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3808 kfree(beacon_info
->head
);
3810 kfree(beacon_info
->tail
);
3816 int wilc_del_beacon(struct wilc_vif
*vif
)
3819 struct host_if_msg msg
;
3820 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3823 netdev_err(vif
->ndev
, "driver is null\n");
3827 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
3830 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3832 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3837 int wilc_add_station(struct wilc_vif
*vif
, struct add_sta_param
*sta_param
)
3840 struct host_if_msg msg
;
3841 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
3842 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3845 netdev_err(vif
->ndev
, "driver is null\n");
3849 memset(&msg
, 0, sizeof(struct host_if_msg
));
3851 msg
.id
= HOST_IF_MSG_ADD_STATION
;
3854 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
3855 if (add_sta_info
->rates_len
> 0) {
3856 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
3857 add_sta_info
->rates_len
,
3859 if (!add_sta_info
->rates
)
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_del_station(struct wilc_vif
*vif
, const u8
*mac_addr
)
3872 struct host_if_msg msg
;
3873 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
3874 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3877 netdev_err(vif
->ndev
, "driver is null\n");
3881 memset(&msg
, 0, sizeof(struct host_if_msg
));
3883 msg
.id
= HOST_IF_MSG_DEL_STATION
;
3887 eth_broadcast_addr(del_sta_info
->mac_addr
);
3889 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
3891 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3893 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3897 int wilc_del_allstation(struct wilc_vif
*vif
, u8 mac_addr
[][ETH_ALEN
])
3900 struct host_if_msg msg
;
3901 struct del_all_sta
*del_all_sta_info
= &msg
.body
.del_all_sta_info
;
3902 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3903 u8 zero_addr
[ETH_ALEN
] = {0};
3908 netdev_err(vif
->ndev
, "driver is null\n");
3912 memset(&msg
, 0, sizeof(struct host_if_msg
));
3914 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
3917 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
3918 if (memcmp(mac_addr
[i
], zero_addr
, ETH_ALEN
)) {
3919 memcpy(del_all_sta_info
->del_all_sta
[i
], mac_addr
[i
], ETH_ALEN
);
3926 del_all_sta_info
->assoc_sta
= assoc_sta
;
3927 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3930 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3932 down(&hif_sema_wait_response
);
3937 int wilc_edit_station(struct wilc_vif
*vif
,
3938 struct add_sta_param
*sta_param
)
3941 struct host_if_msg msg
;
3942 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
3943 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3946 netdev_err(vif
->ndev
, "driver is null\n");
3950 memset(&msg
, 0, sizeof(struct host_if_msg
));
3952 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
3955 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
3956 if (add_sta_info
->rates_len
> 0) {
3957 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
3958 add_sta_info
->rates_len
,
3960 if (!add_sta_info
->rates
)
3964 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3966 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3971 int wilc_set_power_mgmt(struct wilc_vif
*vif
, bool enabled
, u32 timeout
)
3974 struct host_if_msg msg
;
3975 struct power_mgmt_param
*pwr_mgmt_info
= &msg
.body
.pwr_mgmt_info
;
3976 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3979 netdev_err(vif
->ndev
, "driver is null\n");
3983 if (wilc_wlan_get_num_conn_ifcs(vif
->wilc
) == 2 && enabled
)
3986 memset(&msg
, 0, sizeof(struct host_if_msg
));
3988 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
3991 pwr_mgmt_info
->enabled
= enabled
;
3992 pwr_mgmt_info
->timeout
= timeout
;
3994 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3996 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4000 int wilc_setup_multicast_filter(struct wilc_vif
*vif
, bool enabled
,
4004 struct host_if_msg msg
;
4005 struct set_multicast
*multicast_filter_param
= &msg
.body
.multicast_info
;
4006 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4009 netdev_err(vif
->ndev
, "driver is null\n");
4013 memset(&msg
, 0, sizeof(struct host_if_msg
));
4015 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
4018 multicast_filter_param
->enabled
= enabled
;
4019 multicast_filter_param
->cnt
= count
;
4021 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4023 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4027 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
)
4029 struct join_bss_param
*pNewJoinBssParam
= NULL
;
4038 u8 pcipherTotalCount
= 0;
4039 u8 authTotalCount
= 0;
4042 pu8IEs
= ptstrNetworkInfo
->ies
;
4043 u16IEsLen
= ptstrNetworkInfo
->ies_len
;
4045 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
4046 if (pNewJoinBssParam
) {
4047 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->dtim_period
;
4048 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->beacon_period
;
4049 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->cap_info
;
4050 memcpy(pNewJoinBssParam
->bssid
, ptstrNetworkInfo
->bssid
, 6);
4051 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->ssid
,
4052 ptstrNetworkInfo
->ssid_len
+ 1);
4053 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->ssid_len
;
4054 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
4055 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
4057 while (index
< u16IEsLen
) {
4058 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
4059 suppRatesNo
= pu8IEs
[index
+ 1];
4060 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
4063 for (i
= 0; i
< suppRatesNo
; i
++)
4064 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
4066 index
+= suppRatesNo
;
4068 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
4069 extSuppRatesNo
= pu8IEs
[index
+ 1];
4070 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
4071 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
4073 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
4075 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
4076 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
4078 index
+= extSuppRatesNo
;
4080 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
4081 pNewJoinBssParam
->ht_capable
= true;
4082 index
+= pu8IEs
[index
+ 1] + 2;
4084 } else if ((pu8IEs
[index
] == WMM_IE
) &&
4085 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
4086 (pu8IEs
[index
+ 4] == 0xF2) &&
4087 (pu8IEs
[index
+ 5] == 0x02) &&
4088 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
4089 (pu8IEs
[index
+ 7] == 0x01)) {
4090 pNewJoinBssParam
->wmm_cap
= true;
4092 if (pu8IEs
[index
+ 8] & BIT(7))
4093 pNewJoinBssParam
->uapsd_cap
= true;
4094 index
+= pu8IEs
[index
+ 1] + 2;
4096 } else if ((pu8IEs
[index
] == P2P_IE
) &&
4097 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
4098 (pu8IEs
[index
+ 4] == 0x9a) &&
4099 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
4102 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->tsf_lo
;
4103 pNewJoinBssParam
->noa_enabled
= 1;
4104 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
4106 if (pu8IEs
[index
+ 10] & BIT(7)) {
4107 pNewJoinBssParam
->opp_enabled
= 1;
4108 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
4110 pNewJoinBssParam
->opp_enabled
= 0;
4113 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
4114 u16P2P_count
= index
+ 12;
4116 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
4119 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
4122 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
4124 index
+= pu8IEs
[index
+ 1] + 2;
4127 } else if ((pu8IEs
[index
] == RSN_IE
) ||
4128 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
4129 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
4130 (pu8IEs
[index
+ 5] == 0x01))) {
4131 u16 rsnIndex
= index
;
4133 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
4134 pNewJoinBssParam
->mode_802_11i
= 2;
4136 if (pNewJoinBssParam
->mode_802_11i
== 0)
4137 pNewJoinBssParam
->mode_802_11i
= 1;
4142 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4144 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4145 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4148 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4149 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4151 pcipherTotalCount
+= pcipherCount
;
4152 rsnIndex
+= jumpOffset
;
4154 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4156 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4159 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4160 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4162 authTotalCount
+= authCount
;
4163 rsnIndex
+= jumpOffset
;
4165 if (pu8IEs
[index
] == RSN_IE
) {
4166 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4167 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4170 pNewJoinBssParam
->rsn_found
= true;
4171 index
+= pu8IEs
[index
+ 1] + 2;
4174 index
+= pu8IEs
[index
+ 1] + 2;
4178 return (void *)pNewJoinBssParam
;
4181 int wilc_setup_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4184 struct host_if_msg msg
;
4185 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4188 netdev_err(vif
->ndev
, "driver is null\n");
4192 memset(&msg
, 0, sizeof(struct host_if_msg
));
4194 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
4196 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4198 msg
.body
.ip_info
.idx
= idx
;
4200 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4202 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4207 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4210 struct host_if_msg msg
;
4211 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4214 netdev_err(vif
->ndev
, "driver is null\n");
4218 memset(&msg
, 0, sizeof(struct host_if_msg
));
4220 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
4222 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4224 msg
.body
.ip_info
.idx
= idx
;
4226 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4228 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4233 int wilc_set_tx_power(struct wilc_vif
*vif
, u8 tx_power
)
4236 struct host_if_msg msg
;
4238 memset(&msg
, 0, sizeof(struct host_if_msg
));
4240 msg
.id
= HOST_IF_MSG_SET_TX_POWER
;
4241 msg
.body
.tx_power
.tx_pwr
= tx_power
;
4244 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4246 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4251 int wilc_get_tx_power(struct wilc_vif
*vif
, u8
*tx_power
)
4254 struct host_if_msg msg
;
4256 memset(&msg
, 0, sizeof(struct host_if_msg
));
4258 msg
.id
= HOST_IF_MSG_GET_TX_POWER
;
4261 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4263 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
4265 down(&hif_sema_wait_response
);
4266 *tx_power
= msg
.body
.tx_power
.tx_pwr
;