1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
13 #define HOST_IF_MSG_SCAN 0
14 #define HOST_IF_MSG_CONNECT 1
15 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16 #define HOST_IF_MSG_KEY 3
17 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19 #define HOST_IF_MSG_CFG_PARAMS 6
20 #define HOST_IF_MSG_SET_CHANNEL 7
21 #define HOST_IF_MSG_DISCONNECT 8
22 #define HOST_IF_MSG_GET_RSSI 9
23 #define HOST_IF_MSG_GET_CHNL 10
24 #define HOST_IF_MSG_ADD_BEACON 11
25 #define HOST_IF_MSG_DEL_BEACON 12
26 #define HOST_IF_MSG_ADD_STATION 13
27 #define HOST_IF_MSG_DEL_STATION 14
28 #define HOST_IF_MSG_EDIT_STATION 15
29 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
30 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
31 #define HOST_IF_MSG_POWER_MGMT 18
32 #define HOST_IF_MSG_GET_INACTIVETIME 19
33 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
34 #define HOST_IF_MSG_REGISTER_FRAME 21
35 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
36 #define HOST_IF_MSG_GET_LINKSPEED 23
37 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
38 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
39 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
40 #define HOST_IF_MSG_SET_OPERATION_MODE 27
41 #define HOST_IF_MSG_SET_IPADDRESS 28
42 #define HOST_IF_MSG_GET_IPADDRESS 29
43 #define HOST_IF_MSG_FLUSH_CONNECT 30
44 #define HOST_IF_MSG_GET_STATISTICS 31
45 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
46 #define HOST_IF_MSG_DEL_BA_SESSION 34
47 #define HOST_IF_MSG_Q_IDLE 35
48 #define HOST_IF_MSG_DEL_ALL_STA 36
49 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 37
50 #define HOST_IF_MSG_SET_TX_POWER 38
51 #define HOST_IF_MSG_GET_TX_POWER 39
52 #define HOST_IF_MSG_EXIT 100
54 #define HOST_IF_SCAN_TIMEOUT 4000
55 #define HOST_IF_CONNECT_TIMEOUT 9500
57 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
58 #define BA_SESSION_DEFAULT_TIMEOUT 1000
59 #define BLOCK_ACK_REQ_SIZE 0x14
60 #define FALSE_FRMWR_CHANNEL 100
62 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
63 #define DEFAULT_LINK_SPEED 72
65 struct host_if_wpa_attr
{
75 struct host_if_wep_attr
{
80 enum AUTHTYPE auth_type
;
83 union host_if_key_attr
{
84 struct host_if_wep_attr wep
;
85 struct host_if_wpa_attr wpa
;
86 struct host_if_pmkid_attr pmkid
;
92 union host_if_key_attr attr
;
102 wilc_scan_result result
;
104 struct hidden_network hidden_network
;
107 struct connect_attr
{
114 wilc_connect_result result
;
116 enum AUTHTYPE auth_type
;
121 struct rcvd_async_info
{
126 struct channel_attr
{
139 struct set_multicast
{
145 u8 del_all_sta
[MAX_NUM_STA
][ETH_ALEN
];
150 u8 mac_addr
[ETH_ALEN
];
153 struct power_mgmt_param
{
163 struct sta_inactive_t
{
172 struct scan_attr scan_info
;
173 struct connect_attr con_info
;
174 struct rcvd_net_info net_info
;
175 struct rcvd_async_info async_info
;
176 struct key_attr key_info
;
177 struct cfg_param_attr cfg_info
;
178 struct channel_attr channel_info
;
179 struct beacon_attr beacon_info
;
180 struct add_sta_param add_sta_info
;
181 struct del_sta del_sta_info
;
182 struct add_sta_param edit_sta_info
;
183 struct power_mgmt_param pwr_mgmt_info
;
184 struct sta_inactive_t mac_info
;
185 struct set_ip_addr ip_info
;
186 struct drv_handler drv
;
187 struct set_multicast multicast_info
;
189 struct set_mac_addr set_mac_info
;
190 struct get_mac_addr get_mac_info
;
191 struct ba_session_info session_info
;
192 struct remain_ch remain_on_ch
;
193 struct reg_frame reg_frame
;
195 struct del_all_sta del_all_sta_info
;
196 struct tx_power tx_power
;
201 union message_body body
;
202 struct wilc_vif
*vif
;
205 struct join_bss_param
{
211 char ssid
[MAX_SSID_LEN
];
213 u8 supp_rates
[MAX_RATES_SUPPORTED
+ 1];
220 u8 rsn_pcip_policy
[3];
221 u8 rsn_auth_policy
[3];
234 static struct host_if_drv
*terminated_handle
;
235 bool wilc_optaining_ip
;
236 static u8 P2P_LISTEN_STATE
;
237 static struct task_struct
*hif_thread_handler
;
238 static struct message_queue hif_msg_q
;
239 static struct semaphore hif_sema_thread
;
240 static struct semaphore hif_sema_driver
;
241 static struct semaphore hif_sema_wait_response
;
242 static struct semaphore hif_sema_deinit
;
243 static struct timer_list periodic_rssi
;
245 u8 wilc_multicast_mac_addr_list
[WILC_MULTICAST_TABLE_SIZE
][ETH_ALEN
];
247 static u8 rcv_assoc_resp
[MAX_ASSOC_RESP_FRAME_SIZE
];
249 static bool scan_while_connected
;
252 static s8 link_speed
;
254 static u8 set_ip
[2][4];
255 static u8 get_ip
[2][4];
256 static u32 inactive_time
;
257 static u8 del_beacon
;
258 static u32 clients_count
;
261 static u8
*info_element
;
264 static u32 join_req_size
;
265 static u32 info_element_size
;
266 static struct wilc_vif
*join_req_vif
;
267 #define REAL_JOIN_REQ 0
268 #define FLUSHED_JOIN_REQ 1
269 #define FLUSHED_BYTE_POS 79
271 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
);
272 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
);
274 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
275 * special purpose in wilc device, so we add 1 to the index to starts from 1.
276 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
278 int wilc_get_vif_idx(struct wilc_vif
*vif
)
283 /* We need to minus 1 from idx which is from wilc device to get real index
284 * of wilc->vif[], because we add 1 when pass to wilc device in the function
286 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
288 static struct wilc_vif
*wilc_get_vif_from_idx(struct wilc
*wilc
, int idx
)
292 if (index
< 0 || index
>= NUM_CONCURRENT_IFC
)
295 return wilc
->vif
[index
];
298 static void handle_set_channel(struct wilc_vif
*vif
,
299 struct channel_attr
*hif_set_ch
)
304 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
306 wid
.val
= (char *)&hif_set_ch
->set_ch
;
307 wid
.size
= sizeof(char);
309 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
310 wilc_get_vif_idx(vif
));
313 netdev_err(vif
->ndev
, "Failed to set channel\n");
316 static s32
handle_set_wfi_drv_handler(struct wilc_vif
*vif
,
317 struct drv_handler
*hif_drv_handler
)
322 wid
.id
= (u16
)WID_SET_DRV_HANDLER
;
324 wid
.val
= (s8
*)hif_drv_handler
;
325 wid
.size
= sizeof(*hif_drv_handler
);
327 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
328 hif_drv_handler
->handler
);
330 if (!hif_drv_handler
->handler
)
331 up(&hif_sema_driver
);
334 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
341 static s32
handle_set_operation_mode(struct wilc_vif
*vif
,
342 struct op_mode
*hif_op_mode
)
347 wid
.id
= (u16
)WID_SET_OPERATION_MODE
;
349 wid
.val
= (s8
*)&hif_op_mode
->mode
;
350 wid
.size
= sizeof(u32
);
352 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
353 wilc_get_vif_idx(vif
));
355 if ((hif_op_mode
->mode
) == IDLE_MODE
)
356 up(&hif_sema_driver
);
359 netdev_err(vif
->ndev
, "Failed to set driver handler\n");
366 static s32
handle_set_ip_address(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
370 char firmware_ip_addr
[4] = {0};
372 if (ip_addr
[0] < 192)
375 memcpy(set_ip
[idx
], ip_addr
, IP_ALEN
);
377 wid
.id
= (u16
)WID_IP_ADDRESS
;
379 wid
.val
= (u8
*)ip_addr
;
382 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
383 wilc_get_vif_idx(vif
));
385 host_int_get_ipaddress(vif
, firmware_ip_addr
, idx
);
388 netdev_err(vif
->ndev
, "Failed to set IP address\n");
395 static s32
handle_get_ip_address(struct wilc_vif
*vif
, u8 idx
)
400 wid
.id
= (u16
)WID_IP_ADDRESS
;
402 wid
.val
= kmalloc(IP_ALEN
, GFP_KERNEL
);
405 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
406 wilc_get_vif_idx(vif
));
408 memcpy(get_ip
[idx
], wid
.val
, IP_ALEN
);
412 if (memcmp(get_ip
[idx
], set_ip
[idx
], IP_ALEN
) != 0)
413 wilc_setup_ipaddress(vif
, set_ip
[idx
], idx
);
416 netdev_err(vif
->ndev
, "Failed to get IP address\n");
423 static void handle_set_mac_address(struct wilc_vif
*vif
,
424 struct set_mac_addr
*set_mac_addr
)
430 mac_buf
= kmemdup(set_mac_addr
->mac_addr
, ETH_ALEN
, GFP_KERNEL
);
434 wid
.id
= (u16
)WID_MAC_ADDR
;
439 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
440 wilc_get_vif_idx(vif
));
442 netdev_err(vif
->ndev
, "Failed to set mac address\n");
447 static s32
handle_get_mac_address(struct wilc_vif
*vif
,
448 struct get_mac_addr
*get_mac_addr
)
453 wid
.id
= (u16
)WID_MAC_ADDR
;
455 wid
.val
= get_mac_addr
->mac_addr
;
458 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
459 wilc_get_vif_idx(vif
));
462 netdev_err(vif
->ndev
, "Failed to get mac address\n");
465 up(&hif_sema_wait_response
);
470 static s32
handle_cfg_param(struct wilc_vif
*vif
,
471 struct cfg_param_attr
*cfg_param_attr
)
474 struct wid wid_list
[32];
475 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
478 down(&hif_drv
->sem_cfg_values
);
480 if (cfg_param_attr
->flag
& BSS_TYPE
) {
481 if (cfg_param_attr
->bss_type
< 6) {
482 wid_list
[i
].id
= WID_BSS_TYPE
;
483 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->bss_type
;
484 wid_list
[i
].type
= WID_CHAR
;
485 wid_list
[i
].size
= sizeof(char);
486 hif_drv
->cfg_values
.bss_type
= (u8
)cfg_param_attr
->bss_type
;
488 netdev_err(vif
->ndev
, "check value 6 over\n");
494 if (cfg_param_attr
->flag
& AUTH_TYPE
) {
495 if (cfg_param_attr
->auth_type
== 1 ||
496 cfg_param_attr
->auth_type
== 2 ||
497 cfg_param_attr
->auth_type
== 5) {
498 wid_list
[i
].id
= WID_AUTH_TYPE
;
499 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_type
;
500 wid_list
[i
].type
= WID_CHAR
;
501 wid_list
[i
].size
= sizeof(char);
502 hif_drv
->cfg_values
.auth_type
= (u8
)cfg_param_attr
->auth_type
;
504 netdev_err(vif
->ndev
, "Impossible value\n");
510 if (cfg_param_attr
->flag
& AUTHEN_TIMEOUT
) {
511 if (cfg_param_attr
->auth_timeout
> 0 &&
512 cfg_param_attr
->auth_timeout
< 65536) {
513 wid_list
[i
].id
= WID_AUTH_TIMEOUT
;
514 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->auth_timeout
;
515 wid_list
[i
].type
= WID_SHORT
;
516 wid_list
[i
].size
= sizeof(u16
);
517 hif_drv
->cfg_values
.auth_timeout
= cfg_param_attr
->auth_timeout
;
519 netdev_err(vif
->ndev
, "Range(1 ~ 65535) over\n");
525 if (cfg_param_attr
->flag
& POWER_MANAGEMENT
) {
526 if (cfg_param_attr
->power_mgmt_mode
< 5) {
527 wid_list
[i
].id
= WID_POWER_MANAGEMENT
;
528 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->power_mgmt_mode
;
529 wid_list
[i
].type
= WID_CHAR
;
530 wid_list
[i
].size
= sizeof(char);
531 hif_drv
->cfg_values
.power_mgmt_mode
= (u8
)cfg_param_attr
->power_mgmt_mode
;
533 netdev_err(vif
->ndev
, "Invalid power mode\n");
539 if (cfg_param_attr
->flag
& RETRY_SHORT
) {
540 if (cfg_param_attr
->short_retry_limit
> 0 &&
541 cfg_param_attr
->short_retry_limit
< 256) {
542 wid_list
[i
].id
= WID_SHORT_RETRY_LIMIT
;
543 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_retry_limit
;
544 wid_list
[i
].type
= WID_SHORT
;
545 wid_list
[i
].size
= sizeof(u16
);
546 hif_drv
->cfg_values
.short_retry_limit
= cfg_param_attr
->short_retry_limit
;
548 netdev_err(vif
->ndev
, "Range(1~256) over\n");
554 if (cfg_param_attr
->flag
& RETRY_LONG
) {
555 if (cfg_param_attr
->long_retry_limit
> 0 &&
556 cfg_param_attr
->long_retry_limit
< 256) {
557 wid_list
[i
].id
= WID_LONG_RETRY_LIMIT
;
558 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->long_retry_limit
;
559 wid_list
[i
].type
= WID_SHORT
;
560 wid_list
[i
].size
= sizeof(u16
);
561 hif_drv
->cfg_values
.long_retry_limit
= cfg_param_attr
->long_retry_limit
;
563 netdev_err(vif
->ndev
, "Range(1~256) over\n");
569 if (cfg_param_attr
->flag
& FRAG_THRESHOLD
) {
570 if (cfg_param_attr
->frag_threshold
> 255 &&
571 cfg_param_attr
->frag_threshold
< 7937) {
572 wid_list
[i
].id
= WID_FRAG_THRESHOLD
;
573 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->frag_threshold
;
574 wid_list
[i
].type
= WID_SHORT
;
575 wid_list
[i
].size
= sizeof(u16
);
576 hif_drv
->cfg_values
.frag_threshold
= cfg_param_attr
->frag_threshold
;
578 netdev_err(vif
->ndev
, "Threshold Range fail\n");
584 if (cfg_param_attr
->flag
& RTS_THRESHOLD
) {
585 if (cfg_param_attr
->rts_threshold
> 255 &&
586 cfg_param_attr
->rts_threshold
< 65536) {
587 wid_list
[i
].id
= WID_RTS_THRESHOLD
;
588 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->rts_threshold
;
589 wid_list
[i
].type
= WID_SHORT
;
590 wid_list
[i
].size
= sizeof(u16
);
591 hif_drv
->cfg_values
.rts_threshold
= cfg_param_attr
->rts_threshold
;
593 netdev_err(vif
->ndev
, "Threshold Range fail\n");
599 if (cfg_param_attr
->flag
& PREAMBLE
) {
600 if (cfg_param_attr
->preamble_type
< 3) {
601 wid_list
[i
].id
= WID_PREAMBLE
;
602 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->preamble_type
;
603 wid_list
[i
].type
= WID_CHAR
;
604 wid_list
[i
].size
= sizeof(char);
605 hif_drv
->cfg_values
.preamble_type
= cfg_param_attr
->preamble_type
;
607 netdev_err(vif
->ndev
, "Preamle Range(0~2) over\n");
613 if (cfg_param_attr
->flag
& SHORT_SLOT_ALLOWED
) {
614 if (cfg_param_attr
->short_slot_allowed
< 2) {
615 wid_list
[i
].id
= WID_SHORT_SLOT_ALLOWED
;
616 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->short_slot_allowed
;
617 wid_list
[i
].type
= WID_CHAR
;
618 wid_list
[i
].size
= sizeof(char);
619 hif_drv
->cfg_values
.short_slot_allowed
= (u8
)cfg_param_attr
->short_slot_allowed
;
621 netdev_err(vif
->ndev
, "Short slot(2) over\n");
627 if (cfg_param_attr
->flag
& TXOP_PROT_DISABLE
) {
628 if (cfg_param_attr
->txop_prot_disabled
< 2) {
629 wid_list
[i
].id
= WID_11N_TXOP_PROT_DISABLE
;
630 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->txop_prot_disabled
;
631 wid_list
[i
].type
= WID_CHAR
;
632 wid_list
[i
].size
= sizeof(char);
633 hif_drv
->cfg_values
.txop_prot_disabled
= (u8
)cfg_param_attr
->txop_prot_disabled
;
635 netdev_err(vif
->ndev
, "TXOP prot disable\n");
641 if (cfg_param_attr
->flag
& BEACON_INTERVAL
) {
642 if (cfg_param_attr
->beacon_interval
> 0 &&
643 cfg_param_attr
->beacon_interval
< 65536) {
644 wid_list
[i
].id
= WID_BEACON_INTERVAL
;
645 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->beacon_interval
;
646 wid_list
[i
].type
= WID_SHORT
;
647 wid_list
[i
].size
= sizeof(u16
);
648 hif_drv
->cfg_values
.beacon_interval
= cfg_param_attr
->beacon_interval
;
650 netdev_err(vif
->ndev
, "Beacon interval(1~65535)fail\n");
656 if (cfg_param_attr
->flag
& DTIM_PERIOD
) {
657 if (cfg_param_attr
->dtim_period
> 0 &&
658 cfg_param_attr
->dtim_period
< 256) {
659 wid_list
[i
].id
= WID_DTIM_PERIOD
;
660 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->dtim_period
;
661 wid_list
[i
].type
= WID_CHAR
;
662 wid_list
[i
].size
= sizeof(char);
663 hif_drv
->cfg_values
.dtim_period
= cfg_param_attr
->dtim_period
;
665 netdev_err(vif
->ndev
, "DTIM range(1~255) fail\n");
671 if (cfg_param_attr
->flag
& SITE_SURVEY
) {
672 if (cfg_param_attr
->site_survey_enabled
< 3) {
673 wid_list
[i
].id
= WID_SITE_SURVEY
;
674 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_enabled
;
675 wid_list
[i
].type
= WID_CHAR
;
676 wid_list
[i
].size
= sizeof(char);
677 hif_drv
->cfg_values
.site_survey_enabled
= (u8
)cfg_param_attr
->site_survey_enabled
;
679 netdev_err(vif
->ndev
, "Site survey disable\n");
685 if (cfg_param_attr
->flag
& SITE_SURVEY_SCAN_TIME
) {
686 if (cfg_param_attr
->site_survey_scan_time
> 0 &&
687 cfg_param_attr
->site_survey_scan_time
< 65536) {
688 wid_list
[i
].id
= WID_SITE_SURVEY_SCAN_TIME
;
689 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->site_survey_scan_time
;
690 wid_list
[i
].type
= WID_SHORT
;
691 wid_list
[i
].size
= sizeof(u16
);
692 hif_drv
->cfg_values
.site_survey_scan_time
= cfg_param_attr
->site_survey_scan_time
;
694 netdev_err(vif
->ndev
, "Site scan time(1~65535) over\n");
700 if (cfg_param_attr
->flag
& ACTIVE_SCANTIME
) {
701 if (cfg_param_attr
->active_scan_time
> 0 &&
702 cfg_param_attr
->active_scan_time
< 65536) {
703 wid_list
[i
].id
= WID_ACTIVE_SCAN_TIME
;
704 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->active_scan_time
;
705 wid_list
[i
].type
= WID_SHORT
;
706 wid_list
[i
].size
= sizeof(u16
);
707 hif_drv
->cfg_values
.active_scan_time
= cfg_param_attr
->active_scan_time
;
709 netdev_err(vif
->ndev
, "Active time(1~65535) over\n");
715 if (cfg_param_attr
->flag
& PASSIVE_SCANTIME
) {
716 if (cfg_param_attr
->passive_scan_time
> 0 &&
717 cfg_param_attr
->passive_scan_time
< 65536) {
718 wid_list
[i
].id
= WID_PASSIVE_SCAN_TIME
;
719 wid_list
[i
].val
= (s8
*)&cfg_param_attr
->passive_scan_time
;
720 wid_list
[i
].type
= WID_SHORT
;
721 wid_list
[i
].size
= sizeof(u16
);
722 hif_drv
->cfg_values
.passive_scan_time
= cfg_param_attr
->passive_scan_time
;
724 netdev_err(vif
->ndev
, "Passive time(1~65535) over\n");
730 if (cfg_param_attr
->flag
& CURRENT_TX_RATE
) {
731 enum CURRENT_TXRATE curr_tx_rate
= cfg_param_attr
->curr_tx_rate
;
733 if (curr_tx_rate
== AUTORATE
|| curr_tx_rate
== MBPS_1
||
734 curr_tx_rate
== MBPS_2
|| curr_tx_rate
== MBPS_5_5
||
735 curr_tx_rate
== MBPS_11
|| curr_tx_rate
== MBPS_6
||
736 curr_tx_rate
== MBPS_9
|| curr_tx_rate
== MBPS_12
||
737 curr_tx_rate
== MBPS_18
|| curr_tx_rate
== MBPS_24
||
738 curr_tx_rate
== MBPS_36
|| curr_tx_rate
== MBPS_48
||
739 curr_tx_rate
== MBPS_54
) {
740 wid_list
[i
].id
= WID_CURRENT_TX_RATE
;
741 wid_list
[i
].val
= (s8
*)&curr_tx_rate
;
742 wid_list
[i
].type
= WID_SHORT
;
743 wid_list
[i
].size
= sizeof(u16
);
744 hif_drv
->cfg_values
.curr_tx_rate
= (u8
)curr_tx_rate
;
746 netdev_err(vif
->ndev
, "out of TX rate\n");
753 result
= wilc_send_config_pkt(vif
, SET_CFG
, wid_list
,
754 i
, wilc_get_vif_idx(vif
));
757 netdev_err(vif
->ndev
, "Error in setting CFG params\n");
760 up(&hif_drv
->sem_cfg_values
);
764 static void Handle_wait_msg_q_empty(void)
766 wilc_initialized
= 0;
767 up(&hif_sema_wait_response
);
770 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
771 enum scan_event enuEvent
);
773 static s32
Handle_Scan(struct wilc_vif
*vif
,
774 struct scan_attr
*pstrHostIFscanAttr
)
777 struct wid strWIDList
[5];
778 u32 u32WidsCount
= 0;
782 u8
*pu8HdnNtwrksWidVal
= NULL
;
783 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
785 hif_drv
->usr_scan_req
.scan_result
= pstrHostIFscanAttr
->result
;
786 hif_drv
->usr_scan_req
.arg
= pstrHostIFscanAttr
->arg
;
788 if ((hif_drv
->hif_state
>= HOST_IF_SCANNING
) &&
789 (hif_drv
->hif_state
< HOST_IF_CONNECTED
)) {
790 netdev_err(vif
->ndev
, "Already scan\n");
795 if (wilc_optaining_ip
|| wilc_connecting
) {
796 netdev_err(vif
->ndev
, "Don't do obss scan\n");
801 hif_drv
->usr_scan_req
.rcvd_ch_cnt
= 0;
803 strWIDList
[u32WidsCount
].id
= (u16
)WID_SSID_PROBE_REQ
;
804 strWIDList
[u32WidsCount
].type
= WID_STR
;
806 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++)
807 valuesize
+= ((pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
) + 1);
808 pu8HdnNtwrksWidVal
= kmalloc(valuesize
+ 1, GFP_KERNEL
);
809 strWIDList
[u32WidsCount
].val
= pu8HdnNtwrksWidVal
;
810 if (strWIDList
[u32WidsCount
].val
) {
811 pu8Buffer
= strWIDList
[u32WidsCount
].val
;
813 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.n_ssids
;
815 for (i
= 0; i
< pstrHostIFscanAttr
->hidden_network
.n_ssids
; i
++) {
816 *pu8Buffer
++ = pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
817 memcpy(pu8Buffer
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid
, pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
);
818 pu8Buffer
+= pstrHostIFscanAttr
->hidden_network
.net_info
[i
].ssid_len
;
821 strWIDList
[u32WidsCount
].size
= (s32
)(valuesize
+ 1);
826 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_PROBE
;
827 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
828 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ies
;
829 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ies_len
;
833 strWIDList
[u32WidsCount
].id
= WID_SCAN_TYPE
;
834 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
835 strWIDList
[u32WidsCount
].size
= sizeof(char);
836 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->type
;
839 strWIDList
[u32WidsCount
].id
= WID_SCAN_CHANNEL_LIST
;
840 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
842 if (pstrHostIFscanAttr
->ch_freq_list
&&
843 pstrHostIFscanAttr
->ch_list_len
> 0) {
846 for (i
= 0; i
< pstrHostIFscanAttr
->ch_list_len
; i
++) {
847 if (pstrHostIFscanAttr
->ch_freq_list
[i
] > 0)
848 pstrHostIFscanAttr
->ch_freq_list
[i
] = pstrHostIFscanAttr
->ch_freq_list
[i
] - 1;
852 strWIDList
[u32WidsCount
].val
= pstrHostIFscanAttr
->ch_freq_list
;
853 strWIDList
[u32WidsCount
].size
= pstrHostIFscanAttr
->ch_list_len
;
856 strWIDList
[u32WidsCount
].id
= WID_START_SCAN_REQ
;
857 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
858 strWIDList
[u32WidsCount
].size
= sizeof(char);
859 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrHostIFscanAttr
->src
;
862 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
863 scan_while_connected
= true;
864 else if (hif_drv
->hif_state
== HOST_IF_IDLE
)
865 scan_while_connected
= false;
867 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
869 wilc_get_vif_idx(vif
));
872 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
876 del_timer(&hif_drv
->scan_timer
);
877 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
880 kfree(pstrHostIFscanAttr
->ch_freq_list
);
881 pstrHostIFscanAttr
->ch_freq_list
= NULL
;
883 kfree(pstrHostIFscanAttr
->ies
);
884 pstrHostIFscanAttr
->ies
= NULL
;
885 kfree(pstrHostIFscanAttr
->hidden_network
.net_info
);
886 pstrHostIFscanAttr
->hidden_network
.net_info
= NULL
;
888 kfree(pu8HdnNtwrksWidVal
);
893 static s32
Handle_ScanDone(struct wilc_vif
*vif
,
894 enum scan_event enuEvent
)
897 u8 u8abort_running_scan
;
899 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
901 if (enuEvent
== SCAN_EVENT_ABORTED
) {
902 u8abort_running_scan
= 1;
903 wid
.id
= (u16
)WID_ABORT_RUNNING_SCAN
;
905 wid
.val
= (s8
*)&u8abort_running_scan
;
906 wid
.size
= sizeof(char);
908 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
909 wilc_get_vif_idx(vif
));
912 netdev_err(vif
->ndev
, "Failed to set abort running\n");
918 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
922 if (hif_drv
->usr_scan_req
.scan_result
) {
923 hif_drv
->usr_scan_req
.scan_result(enuEvent
, NULL
,
924 hif_drv
->usr_scan_req
.arg
, NULL
);
925 hif_drv
->usr_scan_req
.scan_result
= NULL
;
931 u8 wilc_connected_ssid
[6] = {0};
932 static s32
Handle_Connect(struct wilc_vif
*vif
,
933 struct connect_attr
*pstrHostIFconnectAttr
)
936 struct wid strWIDList
[8];
937 u32 u32WidsCount
= 0, dummyval
= 0;
938 u8
*pu8CurrByte
= NULL
;
939 struct join_bss_param
*ptstrJoinBssParam
;
940 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
942 if (memcmp(pstrHostIFconnectAttr
->bssid
, wilc_connected_ssid
, ETH_ALEN
) == 0) {
944 netdev_err(vif
->ndev
, "Discard connect request\n");
948 ptstrJoinBssParam
= pstrHostIFconnectAttr
->params
;
949 if (!ptstrJoinBssParam
) {
950 netdev_err(vif
->ndev
, "Required BSSID not found\n");
955 if (pstrHostIFconnectAttr
->bssid
) {
956 hif_drv
->usr_conn_req
.bssid
= kmalloc(6, GFP_KERNEL
);
957 memcpy(hif_drv
->usr_conn_req
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
960 hif_drv
->usr_conn_req
.ssid_len
= pstrHostIFconnectAttr
->ssid_len
;
961 if (pstrHostIFconnectAttr
->ssid
) {
962 hif_drv
->usr_conn_req
.ssid
= kmalloc(pstrHostIFconnectAttr
->ssid_len
+ 1, GFP_KERNEL
);
963 memcpy(hif_drv
->usr_conn_req
.ssid
,
964 pstrHostIFconnectAttr
->ssid
,
965 pstrHostIFconnectAttr
->ssid_len
);
966 hif_drv
->usr_conn_req
.ssid
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
969 hif_drv
->usr_conn_req
.ies_len
= pstrHostIFconnectAttr
->ies_len
;
970 if (pstrHostIFconnectAttr
->ies
) {
971 hif_drv
->usr_conn_req
.ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
972 memcpy(hif_drv
->usr_conn_req
.ies
,
973 pstrHostIFconnectAttr
->ies
,
974 pstrHostIFconnectAttr
->ies_len
);
977 hif_drv
->usr_conn_req
.security
= pstrHostIFconnectAttr
->security
;
978 hif_drv
->usr_conn_req
.auth_type
= pstrHostIFconnectAttr
->auth_type
;
979 hif_drv
->usr_conn_req
.conn_result
= pstrHostIFconnectAttr
->result
;
980 hif_drv
->usr_conn_req
.arg
= pstrHostIFconnectAttr
->arg
;
982 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
983 strWIDList
[u32WidsCount
].type
= WID_INT
;
984 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
985 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
988 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
989 strWIDList
[u32WidsCount
].type
= WID_INT
;
990 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
991 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
994 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
995 strWIDList
[u32WidsCount
].type
= WID_INT
;
996 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
997 strWIDList
[u32WidsCount
].val
= (s8
*)(&(dummyval
));
1001 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1002 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1003 strWIDList
[u32WidsCount
].val
= hif_drv
->usr_conn_req
.ies
;
1004 strWIDList
[u32WidsCount
].size
= hif_drv
->usr_conn_req
.ies_len
;
1007 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1008 info_element_size
= hif_drv
->usr_conn_req
.ies_len
;
1009 info_element
= kmalloc(info_element_size
, GFP_KERNEL
);
1010 memcpy(info_element
, hif_drv
->usr_conn_req
.ies
,
1014 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1015 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1016 strWIDList
[u32WidsCount
].size
= sizeof(char);
1017 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.security
;
1020 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1021 mode_11i
= hif_drv
->usr_conn_req
.security
;
1023 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1024 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1025 strWIDList
[u32WidsCount
].size
= sizeof(char);
1026 strWIDList
[u32WidsCount
].val
= (s8
*)&hif_drv
->usr_conn_req
.auth_type
;
1029 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7))
1030 auth_type
= (u8
)hif_drv
->usr_conn_req
.auth_type
;
1032 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1033 strWIDList
[u32WidsCount
].type
= WID_STR
;
1034 strWIDList
[u32WidsCount
].size
= 112;
1035 strWIDList
[u32WidsCount
].val
= kmalloc(strWIDList
[u32WidsCount
].size
, GFP_KERNEL
);
1037 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1038 join_req_size
= strWIDList
[u32WidsCount
].size
;
1039 join_req
= kmalloc(join_req_size
, GFP_KERNEL
);
1041 if (!strWIDList
[u32WidsCount
].val
) {
1046 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1048 if (pstrHostIFconnectAttr
->ssid
) {
1049 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->ssid
, pstrHostIFconnectAttr
->ssid_len
);
1050 pu8CurrByte
[pstrHostIFconnectAttr
->ssid_len
] = '\0';
1052 pu8CurrByte
+= MAX_SSID_LEN
;
1053 *(pu8CurrByte
++) = INFRASTRUCTURE
;
1055 if ((pstrHostIFconnectAttr
->ch
>= 1) && (pstrHostIFconnectAttr
->ch
<= 14)) {
1056 *(pu8CurrByte
++) = pstrHostIFconnectAttr
->ch
;
1058 netdev_err(vif
->ndev
, "Channel out of range\n");
1059 *(pu8CurrByte
++) = 0xFF;
1061 *(pu8CurrByte
++) = (ptstrJoinBssParam
->cap_info
) & 0xFF;
1062 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->cap_info
) >> 8) & 0xFF;
1064 if (pstrHostIFconnectAttr
->bssid
)
1065 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1068 if (pstrHostIFconnectAttr
->bssid
)
1069 memcpy(pu8CurrByte
, pstrHostIFconnectAttr
->bssid
, 6);
1072 *(pu8CurrByte
++) = (ptstrJoinBssParam
->beacon_period
) & 0xFF;
1073 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->beacon_period
) >> 8) & 0xFF;
1074 *(pu8CurrByte
++) = ptstrJoinBssParam
->dtim_period
;
1076 memcpy(pu8CurrByte
, ptstrJoinBssParam
->supp_rates
, MAX_RATES_SUPPORTED
+ 1);
1077 pu8CurrByte
+= (MAX_RATES_SUPPORTED
+ 1);
1079 *(pu8CurrByte
++) = ptstrJoinBssParam
->wmm_cap
;
1080 *(pu8CurrByte
++) = ptstrJoinBssParam
->uapsd_cap
;
1082 *(pu8CurrByte
++) = ptstrJoinBssParam
->ht_capable
;
1083 hif_drv
->usr_conn_req
.ht_capable
= ptstrJoinBssParam
->ht_capable
;
1085 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_found
;
1086 *(pu8CurrByte
++) = ptstrJoinBssParam
->rsn_grp_policy
;
1087 *(pu8CurrByte
++) = ptstrJoinBssParam
->mode_802_11i
;
1089 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_pcip_policy
, sizeof(ptstrJoinBssParam
->rsn_pcip_policy
));
1090 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_pcip_policy
);
1092 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_auth_policy
, sizeof(ptstrJoinBssParam
->rsn_auth_policy
));
1093 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_auth_policy
);
1095 memcpy(pu8CurrByte
, ptstrJoinBssParam
->rsn_cap
, sizeof(ptstrJoinBssParam
->rsn_cap
));
1096 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->rsn_cap
);
1098 *(pu8CurrByte
++) = REAL_JOIN_REQ
;
1099 *(pu8CurrByte
++) = ptstrJoinBssParam
->noa_enabled
;
1101 if (ptstrJoinBssParam
->noa_enabled
) {
1102 *(pu8CurrByte
++) = (ptstrJoinBssParam
->tsf
) & 0xFF;
1103 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 8) & 0xFF;
1104 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 16) & 0xFF;
1105 *(pu8CurrByte
++) = ((ptstrJoinBssParam
->tsf
) >> 24) & 0xFF;
1107 *(pu8CurrByte
++) = ptstrJoinBssParam
->opp_enabled
;
1108 *(pu8CurrByte
++) = ptstrJoinBssParam
->idx
;
1110 if (ptstrJoinBssParam
->opp_enabled
)
1111 *(pu8CurrByte
++) = ptstrJoinBssParam
->ct_window
;
1113 *(pu8CurrByte
++) = ptstrJoinBssParam
->cnt
;
1115 memcpy(pu8CurrByte
, ptstrJoinBssParam
->duration
, sizeof(ptstrJoinBssParam
->duration
));
1116 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->duration
);
1118 memcpy(pu8CurrByte
, ptstrJoinBssParam
->interval
, sizeof(ptstrJoinBssParam
->interval
));
1119 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->interval
);
1121 memcpy(pu8CurrByte
, ptstrJoinBssParam
->start_time
, sizeof(ptstrJoinBssParam
->start_time
));
1122 pu8CurrByte
+= sizeof(ptstrJoinBssParam
->start_time
);
1125 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1128 if (memcmp("DIRECT-", pstrHostIFconnectAttr
->ssid
, 7)) {
1129 memcpy(join_req
, pu8CurrByte
, join_req_size
);
1133 if (pstrHostIFconnectAttr
->bssid
)
1134 memcpy(wilc_connected_ssid
,
1135 pstrHostIFconnectAttr
->bssid
, ETH_ALEN
);
1137 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1139 wilc_get_vif_idx(vif
));
1141 netdev_err(vif
->ndev
, "failed to send config packet\n");
1145 hif_drv
->hif_state
= HOST_IF_WAITING_CONN_RESP
;
1150 struct connect_info strConnectInfo
;
1152 del_timer(&hif_drv
->connect_timer
);
1154 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1156 if (pstrHostIFconnectAttr
->result
) {
1157 if (pstrHostIFconnectAttr
->bssid
)
1158 memcpy(strConnectInfo
.bssid
, pstrHostIFconnectAttr
->bssid
, 6);
1160 if (pstrHostIFconnectAttr
->ies
) {
1161 strConnectInfo
.req_ies_len
= pstrHostIFconnectAttr
->ies_len
;
1162 strConnectInfo
.req_ies
= kmalloc(pstrHostIFconnectAttr
->ies_len
, GFP_KERNEL
);
1163 memcpy(strConnectInfo
.req_ies
,
1164 pstrHostIFconnectAttr
->ies
,
1165 pstrHostIFconnectAttr
->ies_len
);
1168 pstrHostIFconnectAttr
->result(CONN_DISCONN_EVENT_CONN_RESP
,
1172 pstrHostIFconnectAttr
->arg
);
1173 hif_drv
->hif_state
= HOST_IF_IDLE
;
1174 kfree(strConnectInfo
.req_ies
);
1175 strConnectInfo
.req_ies
= NULL
;
1178 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1182 kfree(pstrHostIFconnectAttr
->bssid
);
1183 pstrHostIFconnectAttr
->bssid
= NULL
;
1185 kfree(pstrHostIFconnectAttr
->ssid
);
1186 pstrHostIFconnectAttr
->ssid
= NULL
;
1188 kfree(pstrHostIFconnectAttr
->ies
);
1189 pstrHostIFconnectAttr
->ies
= NULL
;
1195 static s32
Handle_FlushConnect(struct wilc_vif
*vif
)
1198 struct wid strWIDList
[5];
1199 u32 u32WidsCount
= 0;
1200 u8
*pu8CurrByte
= NULL
;
1202 strWIDList
[u32WidsCount
].id
= WID_INFO_ELEMENT_ASSOCIATE
;
1203 strWIDList
[u32WidsCount
].type
= WID_BIN_DATA
;
1204 strWIDList
[u32WidsCount
].val
= info_element
;
1205 strWIDList
[u32WidsCount
].size
= info_element_size
;
1208 strWIDList
[u32WidsCount
].id
= (u16
)WID_11I_MODE
;
1209 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1210 strWIDList
[u32WidsCount
].size
= sizeof(char);
1211 strWIDList
[u32WidsCount
].val
= (s8
*)(&(mode_11i
));
1214 strWIDList
[u32WidsCount
].id
= (u16
)WID_AUTH_TYPE
;
1215 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
1216 strWIDList
[u32WidsCount
].size
= sizeof(char);
1217 strWIDList
[u32WidsCount
].val
= (s8
*)(&auth_type
);
1220 strWIDList
[u32WidsCount
].id
= (u16
)WID_JOIN_REQ_EXTENDED
;
1221 strWIDList
[u32WidsCount
].type
= WID_STR
;
1222 strWIDList
[u32WidsCount
].size
= join_req_size
;
1223 strWIDList
[u32WidsCount
].val
= (s8
*)join_req
;
1224 pu8CurrByte
= strWIDList
[u32WidsCount
].val
;
1226 pu8CurrByte
+= FLUSHED_BYTE_POS
;
1227 *(pu8CurrByte
) = FLUSHED_JOIN_REQ
;
1231 result
= wilc_send_config_pkt(vif
, SET_CFG
, strWIDList
,
1233 wilc_get_vif_idx(join_req_vif
));
1235 netdev_err(vif
->ndev
, "failed to send config packet\n");
1242 static s32
Handle_ConnectTimeout(struct wilc_vif
*vif
)
1245 struct connect_info strConnectInfo
;
1247 u16 u16DummyReasonCode
= 0;
1248 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1251 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1255 hif_drv
->hif_state
= HOST_IF_IDLE
;
1257 scan_while_connected
= false;
1259 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1261 if (hif_drv
->usr_conn_req
.conn_result
) {
1262 if (hif_drv
->usr_conn_req
.bssid
) {
1263 memcpy(strConnectInfo
.bssid
,
1264 hif_drv
->usr_conn_req
.bssid
, 6);
1267 if (hif_drv
->usr_conn_req
.ies
) {
1268 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1269 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1270 memcpy(strConnectInfo
.req_ies
,
1271 hif_drv
->usr_conn_req
.ies
,
1272 hif_drv
->usr_conn_req
.ies_len
);
1275 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1279 hif_drv
->usr_conn_req
.arg
);
1281 kfree(strConnectInfo
.req_ies
);
1282 strConnectInfo
.req_ies
= NULL
;
1284 netdev_err(vif
->ndev
, "Connect callback is NULL\n");
1287 wid
.id
= (u16
)WID_DISCONNECT
;
1288 wid
.type
= WID_CHAR
;
1289 wid
.val
= (s8
*)&u16DummyReasonCode
;
1290 wid
.size
= sizeof(char);
1292 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1293 wilc_get_vif_idx(vif
));
1295 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1297 hif_drv
->usr_conn_req
.ssid_len
= 0;
1298 kfree(hif_drv
->usr_conn_req
.ssid
);
1299 hif_drv
->usr_conn_req
.ssid
= NULL
;
1300 kfree(hif_drv
->usr_conn_req
.bssid
);
1301 hif_drv
->usr_conn_req
.bssid
= NULL
;
1302 hif_drv
->usr_conn_req
.ies_len
= 0;
1303 kfree(hif_drv
->usr_conn_req
.ies
);
1304 hif_drv
->usr_conn_req
.ies
= NULL
;
1306 eth_zero_addr(wilc_connected_ssid
);
1308 if (join_req
&& join_req_vif
== vif
) {
1313 if (info_element
&& join_req_vif
== vif
) {
1314 kfree(info_element
);
1315 info_element
= NULL
;
1321 static s32
Handle_RcvdNtwrkInfo(struct wilc_vif
*vif
,
1322 struct rcvd_net_info
*pstrRcvdNetworkInfo
)
1325 bool bNewNtwrkFound
;
1327 struct network_info
*pstrNetworkInfo
= NULL
;
1328 void *pJoinParams
= NULL
;
1329 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1331 bNewNtwrkFound
= true;
1333 if (hif_drv
->usr_scan_req
.scan_result
) {
1334 wilc_parse_network_info(pstrRcvdNetworkInfo
->buffer
, &pstrNetworkInfo
);
1335 if ((!pstrNetworkInfo
) ||
1336 (!hif_drv
->usr_scan_req
.scan_result
)) {
1337 netdev_err(vif
->ndev
, "driver is null\n");
1342 for (i
= 0; i
< hif_drv
->usr_scan_req
.rcvd_ch_cnt
; i
++) {
1343 if ((hif_drv
->usr_scan_req
.net_info
[i
].bssid
) &&
1344 (pstrNetworkInfo
->bssid
)) {
1345 if (memcmp(hif_drv
->usr_scan_req
.net_info
[i
].bssid
,
1346 pstrNetworkInfo
->bssid
, 6) == 0) {
1347 if (pstrNetworkInfo
->rssi
<= hif_drv
->usr_scan_req
.net_info
[i
].rssi
) {
1350 hif_drv
->usr_scan_req
.net_info
[i
].rssi
= pstrNetworkInfo
->rssi
;
1351 bNewNtwrkFound
= false;
1358 if (bNewNtwrkFound
) {
1359 if (hif_drv
->usr_scan_req
.rcvd_ch_cnt
< MAX_NUM_SCANNED_NETWORKS
) {
1360 hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].rssi
= pstrNetworkInfo
->rssi
;
1362 if (hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
&&
1363 pstrNetworkInfo
->bssid
) {
1364 memcpy(hif_drv
->usr_scan_req
.net_info
[hif_drv
->usr_scan_req
.rcvd_ch_cnt
].bssid
,
1365 pstrNetworkInfo
->bssid
, 6);
1367 hif_drv
->usr_scan_req
.rcvd_ch_cnt
++;
1369 pstrNetworkInfo
->new_network
= true;
1370 pJoinParams
= host_int_ParseJoinBssParam(pstrNetworkInfo
);
1372 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1373 hif_drv
->usr_scan_req
.arg
,
1378 pstrNetworkInfo
->new_network
= false;
1379 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_NETWORK_FOUND
, pstrNetworkInfo
,
1380 hif_drv
->usr_scan_req
.arg
, NULL
);
1385 kfree(pstrRcvdNetworkInfo
->buffer
);
1386 pstrRcvdNetworkInfo
->buffer
= NULL
;
1388 if (pstrNetworkInfo
) {
1389 kfree(pstrNetworkInfo
->ies
);
1390 kfree(pstrNetworkInfo
);
1396 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
1397 u8
*pu8AssocRespInfo
,
1398 u32 u32MaxAssocRespInfoLen
,
1399 u32
*pu32RcvdAssocRespInfoLen
);
1401 static s32
Handle_RcvdGnrlAsyncInfo(struct wilc_vif
*vif
,
1402 struct rcvd_async_info
*pstrRcvdGnrlAsyncInfo
)
1408 u16 u16WidID
= (u16
)WID_NIL
;
1411 u8 u8MacStatusReasonCode
;
1412 u8 u8MacStatusAdditionalInfo
;
1413 struct connect_info strConnectInfo
;
1414 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1416 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1419 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
1423 if ((hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1424 (hif_drv
->hif_state
== HOST_IF_CONNECTED
) ||
1425 hif_drv
->usr_scan_req
.scan_result
) {
1426 if (!pstrRcvdGnrlAsyncInfo
->buffer
||
1427 !hif_drv
->usr_conn_req
.conn_result
) {
1428 netdev_err(vif
->ndev
, "driver is null\n");
1432 u8MsgType
= pstrRcvdGnrlAsyncInfo
->buffer
[0];
1434 if ('I' != u8MsgType
) {
1435 netdev_err(vif
->ndev
, "Received Message incorrect.\n");
1439 u8MsgID
= pstrRcvdGnrlAsyncInfo
->buffer
[1];
1440 u16MsgLen
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[2], pstrRcvdGnrlAsyncInfo
->buffer
[3]);
1441 u16WidID
= MAKE_WORD16(pstrRcvdGnrlAsyncInfo
->buffer
[4], pstrRcvdGnrlAsyncInfo
->buffer
[5]);
1442 u8WidLen
= pstrRcvdGnrlAsyncInfo
->buffer
[6];
1443 u8MacStatus
= pstrRcvdGnrlAsyncInfo
->buffer
[7];
1444 u8MacStatusReasonCode
= pstrRcvdGnrlAsyncInfo
->buffer
[8];
1445 u8MacStatusAdditionalInfo
= pstrRcvdGnrlAsyncInfo
->buffer
[9];
1446 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
1447 u32 u32RcvdAssocRespInfoLen
= 0;
1448 struct connect_resp_info
*pstrConnectRespInfo
= NULL
;
1450 memset(&strConnectInfo
, 0, sizeof(struct connect_info
));
1452 if (u8MacStatus
== MAC_CONNECTED
) {
1453 memset(rcv_assoc_resp
, 0, MAX_ASSOC_RESP_FRAME_SIZE
);
1455 host_int_get_assoc_res_info(vif
,
1457 MAX_ASSOC_RESP_FRAME_SIZE
,
1458 &u32RcvdAssocRespInfoLen
);
1460 if (u32RcvdAssocRespInfoLen
!= 0) {
1461 s32Err
= wilc_parse_assoc_resp_info(rcv_assoc_resp
, u32RcvdAssocRespInfoLen
,
1462 &pstrConnectRespInfo
);
1464 netdev_err(vif
->ndev
, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err
);
1466 strConnectInfo
.u16ConnectStatus
= pstrConnectRespInfo
->status
;
1468 if (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
) {
1469 if (pstrConnectRespInfo
->ies
) {
1470 strConnectInfo
.resp_ies_len
= pstrConnectRespInfo
->ies_len
;
1471 strConnectInfo
.resp_ies
= kmalloc(pstrConnectRespInfo
->ies_len
, GFP_KERNEL
);
1472 memcpy(strConnectInfo
.resp_ies
, pstrConnectRespInfo
->ies
,
1473 pstrConnectRespInfo
->ies_len
);
1477 if (pstrConnectRespInfo
) {
1478 kfree(pstrConnectRespInfo
->ies
);
1479 kfree(pstrConnectRespInfo
);
1485 if ((u8MacStatus
== MAC_CONNECTED
) &&
1486 (strConnectInfo
.u16ConnectStatus
!= SUCCESSFUL_STATUSCODE
)) {
1487 netdev_err(vif
->ndev
, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1488 eth_zero_addr(wilc_connected_ssid
);
1489 } else if (u8MacStatus
== MAC_DISCONNECTED
) {
1490 netdev_err(vif
->ndev
, "Received MAC status is MAC_DISCONNECTED\n");
1491 eth_zero_addr(wilc_connected_ssid
);
1494 if (hif_drv
->usr_conn_req
.bssid
) {
1495 memcpy(strConnectInfo
.bssid
, hif_drv
->usr_conn_req
.bssid
, 6);
1497 if ((u8MacStatus
== MAC_CONNECTED
) &&
1498 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1499 memcpy(hif_drv
->assoc_bssid
,
1500 hif_drv
->usr_conn_req
.bssid
, ETH_ALEN
);
1504 if (hif_drv
->usr_conn_req
.ies
) {
1505 strConnectInfo
.req_ies_len
= hif_drv
->usr_conn_req
.ies_len
;
1506 strConnectInfo
.req_ies
= kmalloc(hif_drv
->usr_conn_req
.ies_len
, GFP_KERNEL
);
1507 memcpy(strConnectInfo
.req_ies
,
1508 hif_drv
->usr_conn_req
.ies
,
1509 hif_drv
->usr_conn_req
.ies_len
);
1512 del_timer(&hif_drv
->connect_timer
);
1513 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_CONN_RESP
,
1517 hif_drv
->usr_conn_req
.arg
);
1519 if ((u8MacStatus
== MAC_CONNECTED
) &&
1520 (strConnectInfo
.u16ConnectStatus
== SUCCESSFUL_STATUSCODE
)) {
1521 wilc_set_power_mgmt(vif
, 0, 0);
1523 hif_drv
->hif_state
= HOST_IF_CONNECTED
;
1525 wilc_optaining_ip
= true;
1526 mod_timer(&wilc_during_ip_timer
,
1527 jiffies
+ msecs_to_jiffies(10000));
1529 hif_drv
->hif_state
= HOST_IF_IDLE
;
1530 scan_while_connected
= false;
1533 kfree(strConnectInfo
.resp_ies
);
1534 strConnectInfo
.resp_ies
= NULL
;
1536 kfree(strConnectInfo
.req_ies
);
1537 strConnectInfo
.req_ies
= NULL
;
1538 hif_drv
->usr_conn_req
.ssid_len
= 0;
1539 kfree(hif_drv
->usr_conn_req
.ssid
);
1540 hif_drv
->usr_conn_req
.ssid
= NULL
;
1541 kfree(hif_drv
->usr_conn_req
.bssid
);
1542 hif_drv
->usr_conn_req
.bssid
= NULL
;
1543 hif_drv
->usr_conn_req
.ies_len
= 0;
1544 kfree(hif_drv
->usr_conn_req
.ies
);
1545 hif_drv
->usr_conn_req
.ies
= NULL
;
1546 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1547 (hif_drv
->hif_state
== HOST_IF_CONNECTED
)) {
1548 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1550 if (hif_drv
->usr_scan_req
.scan_result
) {
1551 del_timer(&hif_drv
->scan_timer
);
1552 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1555 strDisconnectNotifInfo
.u16reason
= 0;
1556 strDisconnectNotifInfo
.ie
= NULL
;
1557 strDisconnectNotifInfo
.ie_len
= 0;
1559 if (hif_drv
->usr_conn_req
.conn_result
) {
1560 wilc_optaining_ip
= false;
1561 wilc_set_power_mgmt(vif
, 0, 0);
1563 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1566 &strDisconnectNotifInfo
,
1567 hif_drv
->usr_conn_req
.arg
);
1569 netdev_err(vif
->ndev
, "Connect result NULL\n");
1572 eth_zero_addr(hif_drv
->assoc_bssid
);
1574 hif_drv
->usr_conn_req
.ssid_len
= 0;
1575 kfree(hif_drv
->usr_conn_req
.ssid
);
1576 hif_drv
->usr_conn_req
.ssid
= NULL
;
1577 kfree(hif_drv
->usr_conn_req
.bssid
);
1578 hif_drv
->usr_conn_req
.bssid
= NULL
;
1579 hif_drv
->usr_conn_req
.ies_len
= 0;
1580 kfree(hif_drv
->usr_conn_req
.ies
);
1581 hif_drv
->usr_conn_req
.ies
= NULL
;
1583 if (join_req
&& join_req_vif
== vif
) {
1588 if (info_element
&& join_req_vif
== vif
) {
1589 kfree(info_element
);
1590 info_element
= NULL
;
1593 hif_drv
->hif_state
= HOST_IF_IDLE
;
1594 scan_while_connected
= false;
1596 } else if ((u8MacStatus
== MAC_DISCONNECTED
) &&
1597 (hif_drv
->usr_scan_req
.scan_result
)) {
1598 del_timer(&hif_drv
->scan_timer
);
1599 if (hif_drv
->usr_scan_req
.scan_result
)
1600 Handle_ScanDone(vif
, SCAN_EVENT_ABORTED
);
1604 kfree(pstrRcvdGnrlAsyncInfo
->buffer
);
1605 pstrRcvdGnrlAsyncInfo
->buffer
= NULL
;
1610 static int Handle_Key(struct wilc_vif
*vif
,
1611 struct key_attr
*pstrHostIFkeyAttr
)
1615 struct wid strWIDList
[5];
1620 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1622 switch (pstrHostIFkeyAttr
->type
) {
1625 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1626 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1627 strWIDList
[0].type
= WID_CHAR
;
1628 strWIDList
[0].size
= sizeof(char);
1629 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.mode
;
1631 strWIDList
[1].id
= WID_AUTH_TYPE
;
1632 strWIDList
[1].type
= WID_CHAR
;
1633 strWIDList
[1].size
= sizeof(char);
1634 strWIDList
[1].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.auth_type
;
1636 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2,
1641 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1642 pu8keybuf
[1] = pstrHostIFkeyAttr
->attr
.wep
.key_len
;
1644 memcpy(&pu8keybuf
[2], pstrHostIFkeyAttr
->attr
.wep
.key
,
1645 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1647 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1649 strWIDList
[2].id
= (u16
)WID_WEP_KEY_VALUE
;
1650 strWIDList
[2].type
= WID_STR
;
1651 strWIDList
[2].size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1652 strWIDList
[2].val
= (s8
*)pu8keybuf
;
1654 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1656 wilc_get_vif_idx(vif
));
1658 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1659 pu8keybuf
= kmalloc(pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2, GFP_KERNEL
);
1662 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.wep
.index
;
1663 memcpy(pu8keybuf
+ 1, &pstrHostIFkeyAttr
->attr
.wep
.key_len
, 1);
1664 memcpy(pu8keybuf
+ 2, pstrHostIFkeyAttr
->attr
.wep
.key
,
1665 pstrHostIFkeyAttr
->attr
.wep
.key_len
);
1666 kfree(pstrHostIFkeyAttr
->attr
.wep
.key
);
1668 wid
.id
= (u16
)WID_ADD_WEP_KEY
;
1670 wid
.val
= (s8
*)pu8keybuf
;
1671 wid
.size
= pstrHostIFkeyAttr
->attr
.wep
.key_len
+ 2;
1673 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1675 wilc_get_vif_idx(vif
));
1677 } else if (pstrHostIFkeyAttr
->action
& REMOVEKEY
) {
1678 wid
.id
= (u16
)WID_REMOVE_WEP_KEY
;
1681 s8idxarray
[0] = (s8
)pstrHostIFkeyAttr
->attr
.wep
.index
;
1682 wid
.val
= s8idxarray
;
1685 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1687 wilc_get_vif_idx(vif
));
1688 } else if (pstrHostIFkeyAttr
->action
& DEFAULTKEY
) {
1689 wid
.id
= (u16
)WID_KEY_ID
;
1690 wid
.type
= WID_CHAR
;
1691 wid
.val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wep
.index
;
1692 wid
.size
= sizeof(char);
1694 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1696 wilc_get_vif_idx(vif
));
1698 up(&hif_drv
->sem_test_key_block
);
1702 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1703 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1706 goto _WPARxGtk_end_case_
;
1709 if (pstrHostIFkeyAttr
->attr
.wpa
.seq
)
1710 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1712 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1713 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1714 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1715 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1717 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1718 strWIDList
[0].type
= WID_CHAR
;
1719 strWIDList
[0].size
= sizeof(char);
1720 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1722 strWIDList
[1].id
= (u16
)WID_ADD_RX_GTK
;
1723 strWIDList
[1].type
= WID_STR
;
1724 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1725 strWIDList
[1].size
= RX_MIC_KEY_MSG_LEN
;
1727 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1729 wilc_get_vif_idx(vif
));
1732 up(&hif_drv
->sem_test_key_block
);
1733 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1734 pu8keybuf
= kzalloc(RX_MIC_KEY_MSG_LEN
, GFP_KERNEL
);
1735 if (pu8keybuf
== NULL
) {
1737 goto _WPARxGtk_end_case_
;
1740 if (hif_drv
->hif_state
== HOST_IF_CONNECTED
)
1741 memcpy(pu8keybuf
, hif_drv
->assoc_bssid
, ETH_ALEN
);
1743 netdev_err(vif
->ndev
, "Couldn't handle\n");
1745 memcpy(pu8keybuf
+ 6, pstrHostIFkeyAttr
->attr
.wpa
.seq
, 8);
1746 memcpy(pu8keybuf
+ 14, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1747 memcpy(pu8keybuf
+ 15, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1748 memcpy(pu8keybuf
+ 16, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1749 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1751 wid
.id
= (u16
)WID_ADD_RX_GTK
;
1753 wid
.val
= (s8
*)pu8keybuf
;
1754 wid
.size
= RX_MIC_KEY_MSG_LEN
;
1756 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1758 wilc_get_vif_idx(vif
));
1761 up(&hif_drv
->sem_test_key_block
);
1763 _WPARxGtk_end_case_
:
1764 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1765 kfree(pstrHostIFkeyAttr
->attr
.wpa
.seq
);
1772 if (pstrHostIFkeyAttr
->action
& ADDKEY_AP
) {
1773 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
+ 1, GFP_KERNEL
);
1776 goto _WPAPtk_end_case_
;
1779 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1780 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.index
, 1);
1781 memcpy(pu8keybuf
+ 7, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1782 memcpy(pu8keybuf
+ 8, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1783 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1785 strWIDList
[0].id
= (u16
)WID_11I_MODE
;
1786 strWIDList
[0].type
= WID_CHAR
;
1787 strWIDList
[0].size
= sizeof(char);
1788 strWIDList
[0].val
= (s8
*)&pstrHostIFkeyAttr
->attr
.wpa
.mode
;
1790 strWIDList
[1].id
= (u16
)WID_ADD_PTK
;
1791 strWIDList
[1].type
= WID_STR
;
1792 strWIDList
[1].val
= (s8
*)pu8keybuf
;
1793 strWIDList
[1].size
= PTK_KEY_MSG_LEN
+ 1;
1795 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1797 wilc_get_vif_idx(vif
));
1799 up(&hif_drv
->sem_test_key_block
);
1800 } else if (pstrHostIFkeyAttr
->action
& ADDKEY
) {
1801 pu8keybuf
= kmalloc(PTK_KEY_MSG_LEN
, GFP_KERNEL
);
1803 netdev_err(vif
->ndev
, "No buffer send PTK\n");
1805 goto _WPAPtk_end_case_
;
1808 memcpy(pu8keybuf
, pstrHostIFkeyAttr
->attr
.wpa
.mac_addr
, 6);
1809 memcpy(pu8keybuf
+ 6, &pstrHostIFkeyAttr
->attr
.wpa
.key_len
, 1);
1810 memcpy(pu8keybuf
+ 7, pstrHostIFkeyAttr
->attr
.wpa
.key
,
1811 pstrHostIFkeyAttr
->attr
.wpa
.key_len
);
1813 wid
.id
= (u16
)WID_ADD_PTK
;
1815 wid
.val
= (s8
*)pu8keybuf
;
1816 wid
.size
= PTK_KEY_MSG_LEN
;
1818 result
= wilc_send_config_pkt(vif
, SET_CFG
,
1820 wilc_get_vif_idx(vif
));
1822 up(&hif_drv
->sem_test_key_block
);
1826 kfree(pstrHostIFkeyAttr
->attr
.wpa
.key
);
1833 pu8keybuf
= kmalloc((pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1, GFP_KERNEL
);
1835 netdev_err(vif
->ndev
, "No buffer to send PMKSA Key\n");
1839 pu8keybuf
[0] = pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
;
1841 for (i
= 0; i
< pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
; i
++) {
1842 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].bssid
, ETH_ALEN
);
1843 memcpy(pu8keybuf
+ ((PMKSA_KEY_LEN
* i
) + ETH_ALEN
+ 1), pstrHostIFkeyAttr
->attr
.pmkid
.pmkidlist
[i
].pmkid
, PMKID_LEN
);
1846 wid
.id
= (u16
)WID_PMKID_INFO
;
1848 wid
.val
= (s8
*)pu8keybuf
;
1849 wid
.size
= (pstrHostIFkeyAttr
->attr
.pmkid
.numpmkid
* PMKSA_KEY_LEN
) + 1;
1851 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1852 wilc_get_vif_idx(vif
));
1859 netdev_err(vif
->ndev
, "Failed to send key config packet\n");
1864 static void Handle_Disconnect(struct wilc_vif
*vif
)
1867 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
1870 u16 u16DummyReasonCode
= 0;
1872 wid
.id
= (u16
)WID_DISCONNECT
;
1873 wid
.type
= WID_CHAR
;
1874 wid
.val
= (s8
*)&u16DummyReasonCode
;
1875 wid
.size
= sizeof(char);
1877 wilc_optaining_ip
= false;
1878 wilc_set_power_mgmt(vif
, 0, 0);
1880 eth_zero_addr(wilc_connected_ssid
);
1882 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
1883 wilc_get_vif_idx(vif
));
1886 netdev_err(vif
->ndev
, "Failed to send dissconect\n");
1888 tstrDisconnectNotifInfo strDisconnectNotifInfo
;
1890 memset(&strDisconnectNotifInfo
, 0, sizeof(tstrDisconnectNotifInfo
));
1892 strDisconnectNotifInfo
.u16reason
= 0;
1893 strDisconnectNotifInfo
.ie
= NULL
;
1894 strDisconnectNotifInfo
.ie_len
= 0;
1896 if (hif_drv
->usr_scan_req
.scan_result
) {
1897 del_timer(&hif_drv
->scan_timer
);
1898 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
,
1900 hif_drv
->usr_scan_req
.arg
,
1902 hif_drv
->usr_scan_req
.scan_result
= NULL
;
1905 if (hif_drv
->usr_conn_req
.conn_result
) {
1906 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
)
1907 del_timer(&hif_drv
->connect_timer
);
1909 hif_drv
->usr_conn_req
.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF
,
1912 &strDisconnectNotifInfo
,
1913 hif_drv
->usr_conn_req
.arg
);
1915 netdev_err(vif
->ndev
, "conn_result = NULL\n");
1918 scan_while_connected
= false;
1920 hif_drv
->hif_state
= HOST_IF_IDLE
;
1922 eth_zero_addr(hif_drv
->assoc_bssid
);
1924 hif_drv
->usr_conn_req
.ssid_len
= 0;
1925 kfree(hif_drv
->usr_conn_req
.ssid
);
1926 hif_drv
->usr_conn_req
.ssid
= NULL
;
1927 kfree(hif_drv
->usr_conn_req
.bssid
);
1928 hif_drv
->usr_conn_req
.bssid
= NULL
;
1929 hif_drv
->usr_conn_req
.ies_len
= 0;
1930 kfree(hif_drv
->usr_conn_req
.ies
);
1931 hif_drv
->usr_conn_req
.ies
= NULL
;
1933 if (join_req
&& join_req_vif
== vif
) {
1938 if (info_element
&& join_req_vif
== vif
) {
1939 kfree(info_element
);
1940 info_element
= NULL
;
1944 up(&hif_drv
->sem_test_disconn_block
);
1947 void wilc_resolve_disconnect_aberration(struct wilc_vif
*vif
)
1951 if ((vif
->hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) ||
1952 (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTING
))
1953 wilc_disconnect(vif
, 1);
1956 static s32
Handle_GetChnl(struct wilc_vif
*vif
)
1961 wid
.id
= (u16
)WID_CURRENT_CHANNEL
;
1962 wid
.type
= WID_CHAR
;
1963 wid
.val
= (s8
*)&ch_no
;
1964 wid
.size
= sizeof(char);
1966 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1967 wilc_get_vif_idx(vif
));
1970 netdev_err(vif
->ndev
, "Failed to get channel number\n");
1977 static void Handle_GetRssi(struct wilc_vif
*vif
)
1982 wid
.id
= (u16
)WID_RSSI
;
1983 wid
.type
= WID_CHAR
;
1985 wid
.size
= sizeof(char);
1987 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
1988 wilc_get_vif_idx(vif
));
1990 netdev_err(vif
->ndev
, "Failed to get RSSI value\n");
1994 up(&vif
->hif_drv
->sem_get_rssi
);
1997 static void Handle_GetLinkspeed(struct wilc_vif
*vif
)
2004 wid
.id
= (u16
)WID_LINKSPEED
;
2005 wid
.type
= WID_CHAR
;
2006 wid
.val
= &link_speed
;
2007 wid
.size
= sizeof(char);
2009 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2010 wilc_get_vif_idx(vif
));
2012 netdev_err(vif
->ndev
, "Failed to get LINKSPEED value\n");
2018 static s32
Handle_GetStatistics(struct wilc_vif
*vif
,
2019 struct rf_info
*pstrStatistics
)
2021 struct wid strWIDList
[5];
2022 u32 u32WidsCount
= 0, result
= 0;
2024 strWIDList
[u32WidsCount
].id
= WID_LINKSPEED
;
2025 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2026 strWIDList
[u32WidsCount
].size
= sizeof(char);
2027 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->link_speed
;
2030 strWIDList
[u32WidsCount
].id
= WID_RSSI
;
2031 strWIDList
[u32WidsCount
].type
= WID_CHAR
;
2032 strWIDList
[u32WidsCount
].size
= sizeof(char);
2033 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rssi
;
2036 strWIDList
[u32WidsCount
].id
= WID_SUCCESS_FRAME_COUNT
;
2037 strWIDList
[u32WidsCount
].type
= WID_INT
;
2038 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2039 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_cnt
;
2042 strWIDList
[u32WidsCount
].id
= WID_RECEIVED_FRAGMENT_COUNT
;
2043 strWIDList
[u32WidsCount
].type
= WID_INT
;
2044 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2045 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->rx_cnt
;
2048 strWIDList
[u32WidsCount
].id
= WID_FAILED_COUNT
;
2049 strWIDList
[u32WidsCount
].type
= WID_INT
;
2050 strWIDList
[u32WidsCount
].size
= sizeof(u32
);
2051 strWIDList
[u32WidsCount
].val
= (s8
*)&pstrStatistics
->tx_fail_cnt
;
2054 result
= wilc_send_config_pkt(vif
, GET_CFG
, strWIDList
,
2056 wilc_get_vif_idx(vif
));
2059 netdev_err(vif
->ndev
, "Failed to send scan parameters\n");
2061 if (pstrStatistics
->link_speed
> TCP_ACK_FILTER_LINK_SPEED_THRESH
&&
2062 pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
2063 wilc_enable_tcp_ack_filter(true);
2064 else if (pstrStatistics
->link_speed
!= DEFAULT_LINK_SPEED
)
2065 wilc_enable_tcp_ack_filter(false);
2067 if (pstrStatistics
!= &vif
->wilc
->dummy_statistics
)
2068 up(&hif_sema_wait_response
);
2072 static s32
Handle_Get_InActiveTime(struct wilc_vif
*vif
,
2073 struct sta_inactive_t
*strHostIfStaInactiveT
)
2078 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2080 wid
.id
= (u16
)WID_SET_STA_MAC_INACTIVE_TIME
;
2082 wid
.size
= ETH_ALEN
;
2083 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2086 memcpy(stamac
, strHostIfStaInactiveT
->mac
, ETH_ALEN
);
2088 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2089 wilc_get_vif_idx(vif
));
2092 netdev_err(vif
->ndev
, "Failed to SET incative time\n");
2096 wid
.id
= (u16
)WID_GET_INACTIVE_TIME
;
2098 wid
.val
= (s8
*)&inactive_time
;
2099 wid
.size
= sizeof(u32
);
2101 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2102 wilc_get_vif_idx(vif
));
2105 netdev_err(vif
->ndev
, "Failed to get incative time\n");
2109 up(&hif_drv
->sem_inactive_time
);
2114 static void Handle_AddBeacon(struct wilc_vif
*vif
,
2115 struct beacon_attr
*pstrSetBeaconParam
)
2121 wid
.id
= (u16
)WID_ADD_BEACON
;
2123 wid
.size
= pstrSetBeaconParam
->head_len
+ pstrSetBeaconParam
->tail_len
+ 16;
2124 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2128 pu8CurrByte
= wid
.val
;
2129 *pu8CurrByte
++ = (pstrSetBeaconParam
->interval
& 0xFF);
2130 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 8) & 0xFF);
2131 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 16) & 0xFF);
2132 *pu8CurrByte
++ = ((pstrSetBeaconParam
->interval
>> 24) & 0xFF);
2134 *pu8CurrByte
++ = (pstrSetBeaconParam
->dtim_period
& 0xFF);
2135 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 8) & 0xFF);
2136 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 16) & 0xFF);
2137 *pu8CurrByte
++ = ((pstrSetBeaconParam
->dtim_period
>> 24) & 0xFF);
2139 *pu8CurrByte
++ = (pstrSetBeaconParam
->head_len
& 0xFF);
2140 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 8) & 0xFF);
2141 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 16) & 0xFF);
2142 *pu8CurrByte
++ = ((pstrSetBeaconParam
->head_len
>> 24) & 0xFF);
2144 memcpy(pu8CurrByte
, pstrSetBeaconParam
->head
, pstrSetBeaconParam
->head_len
);
2145 pu8CurrByte
+= pstrSetBeaconParam
->head_len
;
2147 *pu8CurrByte
++ = (pstrSetBeaconParam
->tail_len
& 0xFF);
2148 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 8) & 0xFF);
2149 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 16) & 0xFF);
2150 *pu8CurrByte
++ = ((pstrSetBeaconParam
->tail_len
>> 24) & 0xFF);
2152 if (pstrSetBeaconParam
->tail
)
2153 memcpy(pu8CurrByte
, pstrSetBeaconParam
->tail
, pstrSetBeaconParam
->tail_len
);
2154 pu8CurrByte
+= pstrSetBeaconParam
->tail_len
;
2156 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2157 wilc_get_vif_idx(vif
));
2159 netdev_err(vif
->ndev
, "Failed to send add beacon\n");
2163 kfree(pstrSetBeaconParam
->head
);
2164 kfree(pstrSetBeaconParam
->tail
);
2167 static void Handle_DelBeacon(struct wilc_vif
*vif
)
2173 wid
.id
= (u16
)WID_DEL_BEACON
;
2174 wid
.type
= WID_CHAR
;
2175 wid
.size
= sizeof(char);
2176 wid
.val
= &del_beacon
;
2181 pu8CurrByte
= wid
.val
;
2183 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2184 wilc_get_vif_idx(vif
));
2186 netdev_err(vif
->ndev
, "Failed to send delete beacon\n");
2189 static u32
WILC_HostIf_PackStaParam(u8
*pu8Buffer
,
2190 struct add_sta_param
*pstrStationParam
)
2194 pu8CurrByte
= pu8Buffer
;
2196 memcpy(pu8CurrByte
, pstrStationParam
->bssid
, ETH_ALEN
);
2197 pu8CurrByte
+= ETH_ALEN
;
2199 *pu8CurrByte
++ = pstrStationParam
->aid
& 0xFF;
2200 *pu8CurrByte
++ = (pstrStationParam
->aid
>> 8) & 0xFF;
2202 *pu8CurrByte
++ = pstrStationParam
->rates_len
;
2203 if (pstrStationParam
->rates_len
> 0)
2204 memcpy(pu8CurrByte
, pstrStationParam
->rates
,
2205 pstrStationParam
->rates_len
);
2206 pu8CurrByte
+= pstrStationParam
->rates_len
;
2208 *pu8CurrByte
++ = pstrStationParam
->ht_supported
;
2209 *pu8CurrByte
++ = pstrStationParam
->ht_capa_info
& 0xFF;
2210 *pu8CurrByte
++ = (pstrStationParam
->ht_capa_info
>> 8) & 0xFF;
2212 *pu8CurrByte
++ = pstrStationParam
->ht_ampdu_params
;
2213 memcpy(pu8CurrByte
, pstrStationParam
->ht_supp_mcs_set
,
2214 WILC_SUPP_MCS_SET_SIZE
);
2215 pu8CurrByte
+= WILC_SUPP_MCS_SET_SIZE
;
2217 *pu8CurrByte
++ = pstrStationParam
->ht_ext_params
& 0xFF;
2218 *pu8CurrByte
++ = (pstrStationParam
->ht_ext_params
>> 8) & 0xFF;
2220 *pu8CurrByte
++ = pstrStationParam
->ht_tx_bf_cap
& 0xFF;
2221 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 8) & 0xFF;
2222 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 16) & 0xFF;
2223 *pu8CurrByte
++ = (pstrStationParam
->ht_tx_bf_cap
>> 24) & 0xFF;
2225 *pu8CurrByte
++ = pstrStationParam
->ht_ante_sel
;
2227 *pu8CurrByte
++ = pstrStationParam
->flags_mask
& 0xFF;
2228 *pu8CurrByte
++ = (pstrStationParam
->flags_mask
>> 8) & 0xFF;
2230 *pu8CurrByte
++ = pstrStationParam
->flags_set
& 0xFF;
2231 *pu8CurrByte
++ = (pstrStationParam
->flags_set
>> 8) & 0xFF;
2233 return pu8CurrByte
- pu8Buffer
;
2236 static void Handle_AddStation(struct wilc_vif
*vif
,
2237 struct add_sta_param
*pstrStationParam
)
2243 wid
.id
= (u16
)WID_ADD_STA
;
2245 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2247 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2251 pu8CurrByte
= wid
.val
;
2252 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2254 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2255 wilc_get_vif_idx(vif
));
2257 netdev_err(vif
->ndev
, "Failed to send add station\n");
2260 kfree(pstrStationParam
->rates
);
2264 static void Handle_DelAllSta(struct wilc_vif
*vif
,
2265 struct del_all_sta
*pstrDelAllStaParam
)
2271 u8 au8Zero_Buff
[6] = {0};
2273 wid
.id
= (u16
)WID_DEL_ALL_STA
;
2275 wid
.size
= (pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1;
2277 wid
.val
= kmalloc((pstrDelAllStaParam
->assoc_sta
* ETH_ALEN
) + 1, GFP_KERNEL
);
2281 pu8CurrByte
= wid
.val
;
2283 *(pu8CurrByte
++) = pstrDelAllStaParam
->assoc_sta
;
2285 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
2286 if (memcmp(pstrDelAllStaParam
->del_all_sta
[i
], au8Zero_Buff
, ETH_ALEN
))
2287 memcpy(pu8CurrByte
, pstrDelAllStaParam
->del_all_sta
[i
], ETH_ALEN
);
2291 pu8CurrByte
+= ETH_ALEN
;
2294 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2295 wilc_get_vif_idx(vif
));
2297 netdev_err(vif
->ndev
, "Failed to send add station\n");
2302 up(&hif_sema_wait_response
);
2305 static void Handle_DelStation(struct wilc_vif
*vif
,
2306 struct del_sta
*pstrDelStaParam
)
2312 wid
.id
= (u16
)WID_REMOVE_STA
;
2314 wid
.size
= ETH_ALEN
;
2316 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2320 pu8CurrByte
= wid
.val
;
2322 memcpy(pu8CurrByte
, pstrDelStaParam
->mac_addr
, ETH_ALEN
);
2324 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2325 wilc_get_vif_idx(vif
));
2327 netdev_err(vif
->ndev
, "Failed to send add station\n");
2333 static void Handle_EditStation(struct wilc_vif
*vif
,
2334 struct add_sta_param
*pstrStationParam
)
2340 wid
.id
= (u16
)WID_EDIT_STA
;
2342 wid
.size
= WILC_ADD_STA_LENGTH
+ pstrStationParam
->rates_len
;
2344 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2348 pu8CurrByte
= wid
.val
;
2349 pu8CurrByte
+= WILC_HostIf_PackStaParam(pu8CurrByte
, pstrStationParam
);
2351 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2352 wilc_get_vif_idx(vif
));
2354 netdev_err(vif
->ndev
, "Failed to send edit station\n");
2357 kfree(pstrStationParam
->rates
);
2361 static int Handle_RemainOnChan(struct wilc_vif
*vif
,
2362 struct remain_ch
*pstrHostIfRemainOnChan
)
2365 u8 u8remain_on_chan_flag
;
2367 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2369 if (!hif_drv
->remain_on_ch_pending
) {
2370 hif_drv
->remain_on_ch
.arg
= pstrHostIfRemainOnChan
->arg
;
2371 hif_drv
->remain_on_ch
.expired
= pstrHostIfRemainOnChan
->expired
;
2372 hif_drv
->remain_on_ch
.ready
= pstrHostIfRemainOnChan
->ready
;
2373 hif_drv
->remain_on_ch
.ch
= pstrHostIfRemainOnChan
->ch
;
2374 hif_drv
->remain_on_ch
.id
= pstrHostIfRemainOnChan
->id
;
2376 pstrHostIfRemainOnChan
->ch
= hif_drv
->remain_on_ch
.ch
;
2379 if (hif_drv
->usr_scan_req
.scan_result
) {
2380 hif_drv
->remain_on_ch_pending
= 1;
2384 if (hif_drv
->hif_state
== HOST_IF_WAITING_CONN_RESP
) {
2389 if (wilc_optaining_ip
|| wilc_connecting
) {
2394 u8remain_on_chan_flag
= true;
2395 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2398 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2404 wid
.val
[0] = u8remain_on_chan_flag
;
2405 wid
.val
[1] = (s8
)pstrHostIfRemainOnChan
->ch
;
2407 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2408 wilc_get_vif_idx(vif
));
2410 netdev_err(vif
->ndev
, "Failed to set remain on channel\n");
2414 P2P_LISTEN_STATE
= 1;
2415 hif_drv
->remain_on_ch_timer
.data
= (unsigned long)vif
;
2416 mod_timer(&hif_drv
->remain_on_ch_timer
,
2418 msecs_to_jiffies(pstrHostIfRemainOnChan
->duration
));
2420 if (hif_drv
->remain_on_ch
.ready
)
2421 hif_drv
->remain_on_ch
.ready(hif_drv
->remain_on_ch
.arg
);
2423 if (hif_drv
->remain_on_ch_pending
)
2424 hif_drv
->remain_on_ch_pending
= 0;
2430 static int Handle_RegisterFrame(struct wilc_vif
*vif
,
2431 struct reg_frame
*pstrHostIfRegisterFrame
)
2437 wid
.id
= (u16
)WID_REGISTER_FRAME
;
2439 wid
.val
= kmalloc(sizeof(u16
) + 2, GFP_KERNEL
);
2443 pu8CurrByte
= wid
.val
;
2445 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg
;
2446 *pu8CurrByte
++ = pstrHostIfRegisterFrame
->reg_id
;
2447 memcpy(pu8CurrByte
, &pstrHostIfRegisterFrame
->frame_type
, sizeof(u16
));
2449 wid
.size
= sizeof(u16
) + 2;
2451 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2452 wilc_get_vif_idx(vif
));
2454 netdev_err(vif
->ndev
, "Failed to frame register\n");
2461 static u32
Handle_ListenStateExpired(struct wilc_vif
*vif
,
2462 struct remain_ch
*pstrHostIfRemainOnChan
)
2464 u8 u8remain_on_chan_flag
;
2467 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2469 if (P2P_LISTEN_STATE
) {
2470 u8remain_on_chan_flag
= false;
2471 wid
.id
= (u16
)WID_REMAIN_ON_CHAN
;
2474 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2477 netdev_err(vif
->ndev
, "Failed to allocate memory\n");
2481 wid
.val
[0] = u8remain_on_chan_flag
;
2482 wid
.val
[1] = FALSE_FRMWR_CHANNEL
;
2484 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2485 wilc_get_vif_idx(vif
));
2487 netdev_err(vif
->ndev
, "Failed to set remain channel\n");
2491 if (hif_drv
->remain_on_ch
.expired
) {
2492 hif_drv
->remain_on_ch
.expired(hif_drv
->remain_on_ch
.arg
,
2493 pstrHostIfRemainOnChan
->id
);
2495 P2P_LISTEN_STATE
= 0;
2497 netdev_dbg(vif
->ndev
, "Not in listen state\n");
2505 static void ListenTimerCB(unsigned long arg
)
2508 struct host_if_msg msg
;
2509 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2511 del_timer(&vif
->hif_drv
->remain_on_ch_timer
);
2513 memset(&msg
, 0, sizeof(struct host_if_msg
));
2514 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
2516 msg
.body
.remain_on_ch
.id
= vif
->hif_drv
->remain_on_ch
.id
;
2518 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2520 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
2523 static void Handle_PowerManagement(struct wilc_vif
*vif
,
2524 struct power_mgmt_param
*strPowerMgmtParam
)
2530 wid
.id
= (u16
)WID_POWER_MANAGEMENT
;
2532 if (strPowerMgmtParam
->enabled
)
2533 s8PowerMode
= MIN_FAST_PS
;
2535 s8PowerMode
= NO_POWERSAVE
;
2537 wid
.val
= &s8PowerMode
;
2538 wid
.size
= sizeof(char);
2540 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2541 wilc_get_vif_idx(vif
));
2543 netdev_err(vif
->ndev
, "Failed to send power management\n");
2546 static void Handle_SetMulticastFilter(struct wilc_vif
*vif
,
2547 struct set_multicast
*strHostIfSetMulti
)
2553 wid
.id
= (u16
)WID_SETUP_MULTICAST_FILTER
;
2555 wid
.size
= sizeof(struct set_multicast
) + ((strHostIfSetMulti
->cnt
) * ETH_ALEN
);
2556 wid
.val
= kmalloc(wid
.size
, GFP_KERNEL
);
2560 pu8CurrByte
= wid
.val
;
2561 *pu8CurrByte
++ = (strHostIfSetMulti
->enabled
& 0xFF);
2566 *pu8CurrByte
++ = (strHostIfSetMulti
->cnt
& 0xFF);
2567 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 8) & 0xFF);
2568 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 16) & 0xFF);
2569 *pu8CurrByte
++ = ((strHostIfSetMulti
->cnt
>> 24) & 0xFF);
2571 if ((strHostIfSetMulti
->cnt
) > 0)
2572 memcpy(pu8CurrByte
, wilc_multicast_mac_addr_list
,
2573 ((strHostIfSetMulti
->cnt
) * ETH_ALEN
));
2575 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2576 wilc_get_vif_idx(vif
));
2578 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2584 static s32
Handle_DelAllRxBASessions(struct wilc_vif
*vif
,
2585 struct ba_session_info
*strHostIfBASessionInfo
)
2591 wid
.id
= (u16
)WID_DEL_ALL_RX_BA
;
2593 wid
.val
= kmalloc(BLOCK_ACK_REQ_SIZE
, GFP_KERNEL
);
2594 wid
.size
= BLOCK_ACK_REQ_SIZE
;
2599 memcpy(ptr
, strHostIfBASessionInfo
->bssid
, ETH_ALEN
);
2601 *ptr
++ = strHostIfBASessionInfo
->tid
;
2605 result
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2606 wilc_get_vif_idx(vif
));
2610 up(&hif_sema_wait_response
);
2615 static void handle_set_tx_pwr(struct wilc_vif
*vif
, u8 tx_pwr
)
2620 wid
.id
= (u16
)WID_TX_POWER
;
2621 wid
.type
= WID_CHAR
;
2623 wid
.size
= sizeof(char);
2625 ret
= wilc_send_config_pkt(vif
, SET_CFG
, &wid
, 1,
2626 wilc_get_vif_idx(vif
));
2628 netdev_err(vif
->ndev
, "Failed to set TX PWR\n");
2631 static void handle_get_tx_pwr(struct wilc_vif
*vif
, u8
*tx_pwr
)
2636 wid
.id
= (u16
)WID_TX_POWER
;
2637 wid
.type
= WID_CHAR
;
2638 wid
.val
= (s8
*)tx_pwr
;
2639 wid
.size
= sizeof(char);
2641 ret
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
2642 wilc_get_vif_idx(vif
));
2644 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
2646 up(&hif_sema_wait_response
);
2649 static int hostIFthread(void *pvArg
)
2652 struct host_if_msg msg
;
2653 struct wilc
*wilc
= pvArg
;
2654 struct wilc_vif
*vif
;
2656 memset(&msg
, 0, sizeof(struct host_if_msg
));
2659 wilc_mq_recv(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
), &u32Ret
);
2661 if (msg
.id
== HOST_IF_MSG_EXIT
)
2664 if ((!wilc_initialized
)) {
2665 usleep_range(200 * 1000, 200 * 1000);
2666 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2670 if (msg
.id
== HOST_IF_MSG_CONNECT
&&
2671 vif
->hif_drv
->usr_scan_req
.scan_result
) {
2672 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2673 usleep_range(2 * 1000, 2 * 1000);
2678 case HOST_IF_MSG_Q_IDLE
:
2679 Handle_wait_msg_q_empty();
2682 case HOST_IF_MSG_SCAN
:
2683 Handle_Scan(msg
.vif
, &msg
.body
.scan_info
);
2686 case HOST_IF_MSG_CONNECT
:
2687 Handle_Connect(msg
.vif
, &msg
.body
.con_info
);
2690 case HOST_IF_MSG_FLUSH_CONNECT
:
2691 Handle_FlushConnect(msg
.vif
);
2694 case HOST_IF_MSG_RCVD_NTWRK_INFO
:
2695 Handle_RcvdNtwrkInfo(msg
.vif
, &msg
.body
.net_info
);
2698 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
:
2699 Handle_RcvdGnrlAsyncInfo(vif
,
2700 &msg
.body
.async_info
);
2703 case HOST_IF_MSG_KEY
:
2704 Handle_Key(msg
.vif
, &msg
.body
.key_info
);
2707 case HOST_IF_MSG_CFG_PARAMS
:
2708 handle_cfg_param(msg
.vif
, &msg
.body
.cfg_info
);
2711 case HOST_IF_MSG_SET_CHANNEL
:
2712 handle_set_channel(msg
.vif
, &msg
.body
.channel_info
);
2715 case HOST_IF_MSG_DISCONNECT
:
2716 Handle_Disconnect(msg
.vif
);
2719 case HOST_IF_MSG_RCVD_SCAN_COMPLETE
:
2720 del_timer(&vif
->hif_drv
->scan_timer
);
2722 if (!wilc_wlan_get_num_conn_ifcs(wilc
))
2723 wilc_chip_sleep_manually(wilc
);
2725 Handle_ScanDone(msg
.vif
, SCAN_EVENT_DONE
);
2727 if (vif
->hif_drv
->remain_on_ch_pending
)
2728 Handle_RemainOnChan(msg
.vif
,
2729 &msg
.body
.remain_on_ch
);
2733 case HOST_IF_MSG_GET_RSSI
:
2734 Handle_GetRssi(msg
.vif
);
2737 case HOST_IF_MSG_GET_LINKSPEED
:
2738 Handle_GetLinkspeed(msg
.vif
);
2741 case HOST_IF_MSG_GET_STATISTICS
:
2742 Handle_GetStatistics(msg
.vif
,
2743 (struct rf_info
*)msg
.body
.data
);
2746 case HOST_IF_MSG_GET_CHNL
:
2747 Handle_GetChnl(msg
.vif
);
2750 case HOST_IF_MSG_ADD_BEACON
:
2751 Handle_AddBeacon(msg
.vif
, &msg
.body
.beacon_info
);
2754 case HOST_IF_MSG_DEL_BEACON
:
2755 Handle_DelBeacon(msg
.vif
);
2758 case HOST_IF_MSG_ADD_STATION
:
2759 Handle_AddStation(msg
.vif
, &msg
.body
.add_sta_info
);
2762 case HOST_IF_MSG_DEL_STATION
:
2763 Handle_DelStation(msg
.vif
, &msg
.body
.del_sta_info
);
2766 case HOST_IF_MSG_EDIT_STATION
:
2767 Handle_EditStation(msg
.vif
, &msg
.body
.edit_sta_info
);
2770 case HOST_IF_MSG_GET_INACTIVETIME
:
2771 Handle_Get_InActiveTime(msg
.vif
, &msg
.body
.mac_info
);
2774 case HOST_IF_MSG_SCAN_TIMER_FIRED
:
2776 Handle_ScanDone(msg
.vif
, SCAN_EVENT_ABORTED
);
2779 case HOST_IF_MSG_CONNECT_TIMER_FIRED
:
2780 Handle_ConnectTimeout(msg
.vif
);
2783 case HOST_IF_MSG_POWER_MGMT
:
2784 Handle_PowerManagement(msg
.vif
,
2785 &msg
.body
.pwr_mgmt_info
);
2788 case HOST_IF_MSG_SET_WFIDRV_HANDLER
:
2789 handle_set_wfi_drv_handler(msg
.vif
, &msg
.body
.drv
);
2792 case HOST_IF_MSG_SET_OPERATION_MODE
:
2793 handle_set_operation_mode(msg
.vif
, &msg
.body
.mode
);
2796 case HOST_IF_MSG_SET_IPADDRESS
:
2797 handle_set_ip_address(vif
,
2798 msg
.body
.ip_info
.ip_addr
,
2799 msg
.body
.ip_info
.idx
);
2802 case HOST_IF_MSG_GET_IPADDRESS
:
2803 handle_get_ip_address(vif
, msg
.body
.ip_info
.idx
);
2806 case HOST_IF_MSG_SET_MAC_ADDRESS
:
2807 handle_set_mac_address(msg
.vif
,
2808 &msg
.body
.set_mac_info
);
2811 case HOST_IF_MSG_GET_MAC_ADDRESS
:
2812 handle_get_mac_address(msg
.vif
,
2813 &msg
.body
.get_mac_info
);
2816 case HOST_IF_MSG_REMAIN_ON_CHAN
:
2817 Handle_RemainOnChan(msg
.vif
, &msg
.body
.remain_on_ch
);
2820 case HOST_IF_MSG_REGISTER_FRAME
:
2821 Handle_RegisterFrame(msg
.vif
, &msg
.body
.reg_frame
);
2824 case HOST_IF_MSG_LISTEN_TIMER_FIRED
:
2825 Handle_ListenStateExpired(msg
.vif
, &msg
.body
.remain_on_ch
);
2828 case HOST_IF_MSG_SET_MULTICAST_FILTER
:
2829 Handle_SetMulticastFilter(msg
.vif
, &msg
.body
.multicast_info
);
2832 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS
:
2833 Handle_DelAllRxBASessions(msg
.vif
, &msg
.body
.session_info
);
2836 case HOST_IF_MSG_DEL_ALL_STA
:
2837 Handle_DelAllSta(msg
.vif
, &msg
.body
.del_all_sta_info
);
2840 case HOST_IF_MSG_SET_TX_POWER
:
2841 handle_set_tx_pwr(msg
.vif
, msg
.body
.tx_power
.tx_pwr
);
2844 case HOST_IF_MSG_GET_TX_POWER
:
2845 handle_get_tx_pwr(msg
.vif
, &msg
.body
.tx_power
.tx_pwr
);
2848 netdev_err(vif
->ndev
, "[Host Interface] undefined\n");
2853 up(&hif_sema_thread
);
2857 static void TimerCB_Scan(unsigned long arg
)
2859 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2860 struct host_if_msg msg
;
2862 memset(&msg
, 0, sizeof(struct host_if_msg
));
2864 msg
.id
= HOST_IF_MSG_SCAN_TIMER_FIRED
;
2866 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2869 static void TimerCB_Connect(unsigned long arg
)
2871 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
2872 struct host_if_msg msg
;
2874 memset(&msg
, 0, sizeof(struct host_if_msg
));
2876 msg
.id
= HOST_IF_MSG_CONNECT_TIMER_FIRED
;
2878 wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2881 s32
wilc_remove_key(struct host_if_drv
*hif_drv
, const u8
*pu8StaAddress
)
2885 wid
.id
= (u16
)WID_REMOVE_KEY
;
2887 wid
.val
= (s8
*)pu8StaAddress
;
2893 int wilc_remove_wep_key(struct wilc_vif
*vif
, u8 index
)
2896 struct host_if_msg msg
;
2897 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2901 netdev_err(vif
->ndev
, "Failed to send setup multicast\n");
2905 memset(&msg
, 0, sizeof(struct host_if_msg
));
2907 msg
.id
= HOST_IF_MSG_KEY
;
2908 msg
.body
.key_info
.type
= WEP
;
2909 msg
.body
.key_info
.action
= REMOVEKEY
;
2911 msg
.body
.key_info
.attr
.wep
.index
= index
;
2913 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2915 netdev_err(vif
->ndev
, "Request to remove WEP key\n");
2916 down(&hif_drv
->sem_test_key_block
);
2921 int wilc_set_wep_default_keyid(struct wilc_vif
*vif
, u8 index
)
2924 struct host_if_msg msg
;
2925 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2929 netdev_err(vif
->ndev
, "driver is null\n");
2933 memset(&msg
, 0, sizeof(struct host_if_msg
));
2935 msg
.id
= HOST_IF_MSG_KEY
;
2936 msg
.body
.key_info
.type
= WEP
;
2937 msg
.body
.key_info
.action
= DEFAULTKEY
;
2939 msg
.body
.key_info
.attr
.wep
.index
= index
;
2941 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2943 netdev_err(vif
->ndev
, "Default key index\n");
2944 down(&hif_drv
->sem_test_key_block
);
2949 int wilc_add_wep_key_bss_sta(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2953 struct host_if_msg msg
;
2954 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2957 netdev_err(vif
->ndev
, "driver is null\n");
2961 memset(&msg
, 0, sizeof(struct host_if_msg
));
2963 msg
.id
= HOST_IF_MSG_KEY
;
2964 msg
.body
.key_info
.type
= WEP
;
2965 msg
.body
.key_info
.action
= ADDKEY
;
2967 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
2968 if (!msg
.body
.key_info
.attr
.wep
.key
)
2971 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
2972 msg
.body
.key_info
.attr
.wep
.index
= index
;
2974 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
2976 netdev_err(vif
->ndev
, "STA - WEP Key\n");
2977 down(&hif_drv
->sem_test_key_block
);
2982 int wilc_add_wep_key_bss_ap(struct wilc_vif
*vif
, const u8
*key
, u8 len
,
2983 u8 index
, u8 mode
, enum AUTHTYPE auth_type
)
2986 struct host_if_msg msg
;
2987 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
2990 netdev_err(vif
->ndev
, "driver is null\n");
2994 memset(&msg
, 0, sizeof(struct host_if_msg
));
2996 msg
.id
= HOST_IF_MSG_KEY
;
2997 msg
.body
.key_info
.type
= WEP
;
2998 msg
.body
.key_info
.action
= ADDKEY_AP
;
3000 msg
.body
.key_info
.attr
.wep
.key
= kmemdup(key
, len
, GFP_KERNEL
);
3001 if (!msg
.body
.key_info
.attr
.wep
.key
)
3004 msg
.body
.key_info
.attr
.wep
.key_len
= len
;
3005 msg
.body
.key_info
.attr
.wep
.index
= index
;
3006 msg
.body
.key_info
.attr
.wep
.mode
= mode
;
3007 msg
.body
.key_info
.attr
.wep
.auth_type
= auth_type
;
3009 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3012 netdev_err(vif
->ndev
, "AP - WEP Key\n");
3013 down(&hif_drv
->sem_test_key_block
);
3018 int wilc_add_ptk(struct wilc_vif
*vif
, const u8
*ptk
, u8 ptk_key_len
,
3019 const u8
*mac_addr
, const u8
*rx_mic
, const u8
*tx_mic
,
3020 u8 mode
, u8 cipher_mode
, u8 index
)
3023 struct host_if_msg msg
;
3024 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3025 u8 key_len
= ptk_key_len
;
3028 netdev_err(vif
->ndev
, "driver is null\n");
3033 key_len
+= RX_MIC_KEY_LEN
;
3036 key_len
+= TX_MIC_KEY_LEN
;
3038 memset(&msg
, 0, sizeof(struct host_if_msg
));
3040 msg
.id
= HOST_IF_MSG_KEY
;
3041 msg
.body
.key_info
.type
= WPA_PTK
;
3042 if (mode
== AP_MODE
) {
3043 msg
.body
.key_info
.action
= ADDKEY_AP
;
3044 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3046 if (mode
== STATION_MODE
)
3047 msg
.body
.key_info
.action
= ADDKEY
;
3049 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(ptk
, ptk_key_len
, GFP_KERNEL
);
3050 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3054 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
, RX_MIC_KEY_LEN
);
3057 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
, TX_MIC_KEY_LEN
);
3059 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3060 msg
.body
.key_info
.attr
.wpa
.mac_addr
= mac_addr
;
3061 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3064 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3067 netdev_err(vif
->ndev
, "PTK Key\n");
3069 down(&hif_drv
->sem_test_key_block
);
3074 int wilc_add_rx_gtk(struct wilc_vif
*vif
, const u8
*rx_gtk
, u8 gtk_key_len
,
3075 u8 index
, u32 key_rsc_len
, const u8
*key_rsc
,
3076 const u8
*rx_mic
, const u8
*tx_mic
, u8 mode
,
3080 struct host_if_msg msg
;
3081 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3082 u8 key_len
= gtk_key_len
;
3085 netdev_err(vif
->ndev
, "driver is null\n");
3088 memset(&msg
, 0, sizeof(struct host_if_msg
));
3091 key_len
+= RX_MIC_KEY_LEN
;
3094 key_len
+= TX_MIC_KEY_LEN
;
3097 msg
.body
.key_info
.attr
.wpa
.seq
= kmemdup(key_rsc
,
3100 if (!msg
.body
.key_info
.attr
.wpa
.seq
)
3104 msg
.id
= HOST_IF_MSG_KEY
;
3105 msg
.body
.key_info
.type
= WPA_RX_GTK
;
3108 if (mode
== AP_MODE
) {
3109 msg
.body
.key_info
.action
= ADDKEY_AP
;
3110 msg
.body
.key_info
.attr
.wpa
.mode
= cipher_mode
;
3112 if (mode
== STATION_MODE
)
3113 msg
.body
.key_info
.action
= ADDKEY
;
3115 msg
.body
.key_info
.attr
.wpa
.key
= kmemdup(rx_gtk
,
3118 if (!msg
.body
.key_info
.attr
.wpa
.key
)
3122 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 16, rx_mic
,
3126 memcpy(msg
.body
.key_info
.attr
.wpa
.key
+ 24, tx_mic
,
3129 msg
.body
.key_info
.attr
.wpa
.index
= index
;
3130 msg
.body
.key_info
.attr
.wpa
.key_len
= key_len
;
3131 msg
.body
.key_info
.attr
.wpa
.seq_len
= key_rsc_len
;
3133 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3135 netdev_err(vif
->ndev
, "RX GTK\n");
3137 down(&hif_drv
->sem_test_key_block
);
3142 int wilc_set_pmkid_info(struct wilc_vif
*vif
,
3143 struct host_if_pmkid_attr
*pmkid
)
3146 struct host_if_msg msg
;
3147 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3151 netdev_err(vif
->ndev
, "driver is null\n");
3155 memset(&msg
, 0, sizeof(struct host_if_msg
));
3157 msg
.id
= HOST_IF_MSG_KEY
;
3158 msg
.body
.key_info
.type
= PMKSA
;
3159 msg
.body
.key_info
.action
= ADDKEY
;
3162 for (i
= 0; i
< pmkid
->numpmkid
; i
++) {
3163 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].bssid
,
3164 &pmkid
->pmkidlist
[i
].bssid
, ETH_ALEN
);
3165 memcpy(msg
.body
.key_info
.attr
.pmkid
.pmkidlist
[i
].pmkid
,
3166 &pmkid
->pmkidlist
[i
].pmkid
, PMKID_LEN
);
3169 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3171 netdev_err(vif
->ndev
, "PMKID Info\n");
3176 int wilc_get_mac_address(struct wilc_vif
*vif
, u8
*mac_addr
)
3179 struct host_if_msg msg
;
3181 memset(&msg
, 0, sizeof(struct host_if_msg
));
3183 msg
.id
= HOST_IF_MSG_GET_MAC_ADDRESS
;
3184 msg
.body
.get_mac_info
.mac_addr
= mac_addr
;
3187 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3189 netdev_err(vif
->ndev
, "Failed to send get mac address\n");
3193 down(&hif_sema_wait_response
);
3197 int wilc_set_join_req(struct wilc_vif
*vif
, u8
*bssid
, const u8
*ssid
,
3198 size_t ssid_len
, const u8
*ies
, size_t ies_len
,
3199 wilc_connect_result connect_result
, void *user_arg
,
3200 u8 security
, enum AUTHTYPE auth_type
,
3201 u8 channel
, void *join_params
)
3204 struct host_if_msg msg
;
3205 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3207 if (!hif_drv
|| !connect_result
) {
3208 netdev_err(vif
->ndev
, "Driver is null\n");
3213 netdev_err(vif
->ndev
, "Unable to Join - JoinParams is NULL\n");
3217 memset(&msg
, 0, sizeof(struct host_if_msg
));
3219 msg
.id
= HOST_IF_MSG_CONNECT
;
3221 msg
.body
.con_info
.security
= security
;
3222 msg
.body
.con_info
.auth_type
= auth_type
;
3223 msg
.body
.con_info
.ch
= channel
;
3224 msg
.body
.con_info
.result
= connect_result
;
3225 msg
.body
.con_info
.arg
= user_arg
;
3226 msg
.body
.con_info
.params
= join_params
;
3230 msg
.body
.con_info
.bssid
= kmemdup(bssid
, 6, GFP_KERNEL
);
3231 if (!msg
.body
.con_info
.bssid
)
3236 msg
.body
.con_info
.ssid_len
= ssid_len
;
3237 msg
.body
.con_info
.ssid
= kmemdup(ssid
, ssid_len
, GFP_KERNEL
);
3238 if (!msg
.body
.con_info
.ssid
)
3243 msg
.body
.con_info
.ies_len
= ies_len
;
3244 msg
.body
.con_info
.ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3245 if (!msg
.body
.con_info
.ies
)
3248 if (hif_drv
->hif_state
< HOST_IF_CONNECTING
)
3249 hif_drv
->hif_state
= HOST_IF_CONNECTING
;
3251 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3253 netdev_err(vif
->ndev
, "send message: Set join request\n");
3257 hif_drv
->connect_timer
.data
= (unsigned long)vif
;
3258 mod_timer(&hif_drv
->connect_timer
,
3259 jiffies
+ msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT
));
3264 int wilc_disconnect(struct wilc_vif
*vif
, u16 reason_code
)
3267 struct host_if_msg msg
;
3268 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3271 netdev_err(vif
->ndev
, "Driver is null\n");
3275 memset(&msg
, 0, sizeof(struct host_if_msg
));
3277 msg
.id
= HOST_IF_MSG_DISCONNECT
;
3280 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3282 netdev_err(vif
->ndev
, "Failed to send message: disconnect\n");
3284 down(&hif_drv
->sem_test_disconn_block
);
3289 static s32
host_int_get_assoc_res_info(struct wilc_vif
*vif
,
3290 u8
*pu8AssocRespInfo
,
3291 u32 u32MaxAssocRespInfoLen
,
3292 u32
*pu32RcvdAssocRespInfoLen
)
3296 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3299 netdev_err(vif
->ndev
, "Driver is null\n");
3303 wid
.id
= (u16
)WID_ASSOC_RES_INFO
;
3305 wid
.val
= pu8AssocRespInfo
;
3306 wid
.size
= u32MaxAssocRespInfoLen
;
3308 result
= wilc_send_config_pkt(vif
, GET_CFG
, &wid
, 1,
3309 wilc_get_vif_idx(vif
));
3311 *pu32RcvdAssocRespInfoLen
= 0;
3312 netdev_err(vif
->ndev
, "Failed to send association response\n");
3316 *pu32RcvdAssocRespInfoLen
= wid
.size
;
3320 int wilc_set_mac_chnl_num(struct wilc_vif
*vif
, u8 channel
)
3323 struct host_if_msg msg
;
3324 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3327 netdev_err(vif
->ndev
, "driver is null\n");
3331 memset(&msg
, 0, sizeof(struct host_if_msg
));
3332 msg
.id
= HOST_IF_MSG_SET_CHANNEL
;
3333 msg
.body
.channel_info
.set_ch
= channel
;
3336 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3338 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3345 int wilc_set_wfi_drv_handler(struct wilc_vif
*vif
, int index
, u8 mac_idx
)
3348 struct host_if_msg msg
;
3350 memset(&msg
, 0, sizeof(struct host_if_msg
));
3351 msg
.id
= HOST_IF_MSG_SET_WFIDRV_HANDLER
;
3352 msg
.body
.drv
.handler
= index
;
3353 msg
.body
.drv
.mac_idx
= mac_idx
;
3356 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3358 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3365 int wilc_set_operation_mode(struct wilc_vif
*vif
, u32 mode
)
3368 struct host_if_msg msg
;
3370 memset(&msg
, 0, sizeof(struct host_if_msg
));
3371 msg
.id
= HOST_IF_MSG_SET_OPERATION_MODE
;
3372 msg
.body
.mode
.mode
= mode
;
3375 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3377 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3384 s32
wilc_get_inactive_time(struct wilc_vif
*vif
, const u8
*mac
,
3385 u32
*pu32InactiveTime
)
3388 struct host_if_msg msg
;
3389 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3392 netdev_err(vif
->ndev
, "driver is null\n");
3396 memset(&msg
, 0, sizeof(struct host_if_msg
));
3397 memcpy(msg
.body
.mac_info
.mac
, mac
, ETH_ALEN
);
3399 msg
.id
= HOST_IF_MSG_GET_INACTIVETIME
;
3402 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3404 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3406 down(&hif_drv
->sem_inactive_time
);
3408 *pu32InactiveTime
= inactive_time
;
3413 int wilc_get_rssi(struct wilc_vif
*vif
, s8
*rssi_level
)
3416 struct host_if_msg msg
;
3417 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3419 memset(&msg
, 0, sizeof(struct host_if_msg
));
3420 msg
.id
= HOST_IF_MSG_GET_RSSI
;
3423 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3425 netdev_err(vif
->ndev
, "Failed to send get host ch param\n");
3429 down(&hif_drv
->sem_get_rssi
);
3432 netdev_err(vif
->ndev
, "RSS pointer value is null\n");
3441 int wilc_get_statistics(struct wilc_vif
*vif
, struct rf_info
*stats
)
3444 struct host_if_msg msg
;
3446 memset(&msg
, 0, sizeof(struct host_if_msg
));
3447 msg
.id
= HOST_IF_MSG_GET_STATISTICS
;
3448 msg
.body
.data
= (char *)stats
;
3451 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3453 netdev_err(vif
->ndev
, "Failed to send get host channel\n");
3457 if (stats
!= &vif
->wilc
->dummy_statistics
)
3458 down(&hif_sema_wait_response
);
3462 int wilc_scan(struct wilc_vif
*vif
, u8 scan_source
, u8 scan_type
,
3463 u8
*ch_freq_list
, u8 ch_list_len
, const u8
*ies
,
3464 size_t ies_len
, wilc_scan_result scan_result
, void *user_arg
,
3465 struct hidden_network
*hidden_network
)
3468 struct host_if_msg msg
;
3469 struct scan_attr
*scan_info
= &msg
.body
.scan_info
;
3470 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3472 if (!hif_drv
|| !scan_result
) {
3473 netdev_err(vif
->ndev
, "hif_drv or scan_result = NULL\n");
3477 memset(&msg
, 0, sizeof(struct host_if_msg
));
3479 msg
.id
= HOST_IF_MSG_SCAN
;
3481 if (hidden_network
) {
3482 scan_info
->hidden_network
.net_info
= hidden_network
->net_info
;
3483 scan_info
->hidden_network
.n_ssids
= hidden_network
->n_ssids
;
3487 scan_info
->src
= scan_source
;
3488 scan_info
->type
= scan_type
;
3489 scan_info
->result
= scan_result
;
3490 scan_info
->arg
= user_arg
;
3492 scan_info
->ch_list_len
= ch_list_len
;
3493 scan_info
->ch_freq_list
= kmemdup(ch_freq_list
,
3496 if (!scan_info
->ch_freq_list
)
3499 scan_info
->ies_len
= ies_len
;
3500 scan_info
->ies
= kmemdup(ies
, ies_len
, GFP_KERNEL
);
3501 if (!scan_info
->ies
)
3504 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3506 netdev_err(vif
->ndev
, "Error in sending message queue\n");
3510 hif_drv
->scan_timer
.data
= (unsigned long)vif
;
3511 mod_timer(&hif_drv
->scan_timer
,
3512 jiffies
+ msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT
));
3517 int wilc_hif_set_cfg(struct wilc_vif
*vif
,
3518 struct cfg_param_attr
*cfg_param
)
3521 struct host_if_msg msg
;
3522 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3525 netdev_err(vif
->ndev
, "hif_drv NULL\n");
3529 memset(&msg
, 0, sizeof(struct host_if_msg
));
3530 msg
.id
= HOST_IF_MSG_CFG_PARAMS
;
3531 msg
.body
.cfg_info
= *cfg_param
;
3534 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3539 static void GetPeriodicRSSI(unsigned long arg
)
3541 struct wilc_vif
*vif
= (struct wilc_vif
*)arg
;
3543 if (!vif
->hif_drv
) {
3544 netdev_err(vif
->ndev
, "Driver handler is NULL\n");
3548 if (vif
->hif_drv
->hif_state
== HOST_IF_CONNECTED
)
3549 wilc_get_statistics(vif
, &vif
->wilc
->dummy_statistics
);
3551 periodic_rssi
.data
= (unsigned long)vif
;
3552 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3555 int wilc_init(struct net_device
*dev
, struct host_if_drv
**hif_drv_handler
)
3558 struct host_if_drv
*hif_drv
;
3559 struct wilc_vif
*vif
;
3563 vif
= netdev_priv(dev
);
3566 scan_while_connected
= false;
3568 sema_init(&hif_sema_wait_response
, 0);
3570 hif_drv
= kzalloc(sizeof(struct host_if_drv
), GFP_KERNEL
);
3575 *hif_drv_handler
= hif_drv
;
3576 for (i
= 0; i
< wilc
->vif_num
; i
++)
3577 if (dev
== wilc
->vif
[i
]->ndev
) {
3578 wilc
->vif
[i
]->hif_drv
= hif_drv
;
3582 wilc_optaining_ip
= false;
3584 if (clients_count
== 0) {
3585 sema_init(&hif_sema_thread
, 0);
3586 sema_init(&hif_sema_driver
, 0);
3587 sema_init(&hif_sema_deinit
, 1);
3590 sema_init(&hif_drv
->sem_test_key_block
, 0);
3591 sema_init(&hif_drv
->sem_test_disconn_block
, 0);
3592 sema_init(&hif_drv
->sem_get_rssi
, 0);
3593 sema_init(&hif_drv
->sem_inactive_time
, 0);
3595 if (clients_count
== 0) {
3596 result
= wilc_mq_create(&hif_msg_q
);
3599 netdev_err(vif
->ndev
, "Failed to creat MQ\n");
3603 hif_thread_handler
= kthread_run(hostIFthread
, wilc
,
3606 if (IS_ERR(hif_thread_handler
)) {
3607 netdev_err(vif
->ndev
, "Failed to creat Thread\n");
3611 setup_timer(&periodic_rssi
, GetPeriodicRSSI
,
3612 (unsigned long)vif
);
3613 mod_timer(&periodic_rssi
, jiffies
+ msecs_to_jiffies(5000));
3616 setup_timer(&hif_drv
->scan_timer
, TimerCB_Scan
, 0);
3617 setup_timer(&hif_drv
->connect_timer
, TimerCB_Connect
, 0);
3618 setup_timer(&hif_drv
->remain_on_ch_timer
, ListenTimerCB
, 0);
3620 sema_init(&hif_drv
->sem_cfg_values
, 1);
3621 down(&hif_drv
->sem_cfg_values
);
3623 hif_drv
->hif_state
= HOST_IF_IDLE
;
3624 hif_drv
->cfg_values
.site_survey_enabled
= SITE_SURVEY_OFF
;
3625 hif_drv
->cfg_values
.scan_source
= DEFAULT_SCAN
;
3626 hif_drv
->cfg_values
.active_scan_time
= ACTIVE_SCAN_TIME
;
3627 hif_drv
->cfg_values
.passive_scan_time
= PASSIVE_SCAN_TIME
;
3628 hif_drv
->cfg_values
.curr_tx_rate
= AUTORATE
;
3630 hif_drv
->p2p_timeout
= 0;
3632 up(&hif_drv
->sem_cfg_values
);
3639 wilc_mq_destroy(&hif_msg_q
);
3644 int wilc_deinit(struct wilc_vif
*vif
)
3647 struct host_if_msg msg
;
3648 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3651 netdev_err(vif
->ndev
, "hif_drv = NULL\n");
3655 down(&hif_sema_deinit
);
3657 terminated_handle
= hif_drv
;
3659 del_timer_sync(&hif_drv
->scan_timer
);
3660 del_timer_sync(&hif_drv
->connect_timer
);
3661 del_timer_sync(&periodic_rssi
);
3662 del_timer_sync(&hif_drv
->remain_on_ch_timer
);
3664 wilc_set_wfi_drv_handler(vif
, 0, 0);
3665 down(&hif_sema_driver
);
3667 if (hif_drv
->usr_scan_req
.scan_result
) {
3668 hif_drv
->usr_scan_req
.scan_result(SCAN_EVENT_ABORTED
, NULL
,
3669 hif_drv
->usr_scan_req
.arg
, NULL
);
3670 hif_drv
->usr_scan_req
.scan_result
= NULL
;
3673 hif_drv
->hif_state
= HOST_IF_IDLE
;
3675 scan_while_connected
= false;
3677 memset(&msg
, 0, sizeof(struct host_if_msg
));
3679 if (clients_count
== 1) {
3680 del_timer_sync(&periodic_rssi
);
3681 msg
.id
= HOST_IF_MSG_EXIT
;
3684 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3686 netdev_err(vif
->ndev
, "deinit : Error(%d)\n", result
);
3688 down(&hif_sema_thread
);
3690 wilc_mq_destroy(&hif_msg_q
);
3696 terminated_handle
= NULL
;
3697 up(&hif_sema_deinit
);
3701 void wilc_network_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3705 struct host_if_msg msg
;
3707 struct host_if_drv
*hif_drv
= NULL
;
3708 struct wilc_vif
*vif
;
3710 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3711 vif
= wilc_get_vif_from_idx(wilc
, id
);
3714 hif_drv
= vif
->hif_drv
;
3716 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3717 netdev_err(vif
->ndev
, "driver not init[%p]\n", hif_drv
);
3721 memset(&msg
, 0, sizeof(struct host_if_msg
));
3723 msg
.id
= HOST_IF_MSG_RCVD_NTWRK_INFO
;
3726 msg
.body
.net_info
.len
= u32Length
;
3727 msg
.body
.net_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3728 memcpy(msg
.body
.net_info
.buffer
, pu8Buffer
, u32Length
);
3730 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3732 netdev_err(vif
->ndev
, "message parameters (%d)\n", result
);
3735 void wilc_gnrl_async_info_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3739 struct host_if_msg msg
;
3741 struct host_if_drv
*hif_drv
= NULL
;
3742 struct wilc_vif
*vif
;
3744 down(&hif_sema_deinit
);
3746 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3747 vif
= wilc_get_vif_from_idx(wilc
, id
);
3749 up(&hif_sema_deinit
);
3753 hif_drv
= vif
->hif_drv
;
3755 if (!hif_drv
|| hif_drv
== terminated_handle
) {
3756 up(&hif_sema_deinit
);
3760 if (!hif_drv
->usr_conn_req
.conn_result
) {
3761 netdev_err(vif
->ndev
, "there is no current Connect Request\n");
3762 up(&hif_sema_deinit
);
3766 memset(&msg
, 0, sizeof(struct host_if_msg
));
3768 msg
.id
= HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO
;
3771 msg
.body
.async_info
.len
= u32Length
;
3772 msg
.body
.async_info
.buffer
= kmalloc(u32Length
, GFP_KERNEL
);
3773 memcpy(msg
.body
.async_info
.buffer
, pu8Buffer
, u32Length
);
3775 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3777 netdev_err(vif
->ndev
, "synchronous info (%d)\n", result
);
3779 up(&hif_sema_deinit
);
3782 void wilc_scan_complete_received(struct wilc
*wilc
, u8
*pu8Buffer
,
3786 struct host_if_msg msg
;
3788 struct host_if_drv
*hif_drv
= NULL
;
3789 struct wilc_vif
*vif
;
3791 id
= ((pu8Buffer
[u32Length
- 4]) | (pu8Buffer
[u32Length
- 3] << 8) | (pu8Buffer
[u32Length
- 2] << 16) | (pu8Buffer
[u32Length
- 1] << 24));
3792 vif
= wilc_get_vif_from_idx(wilc
, id
);
3795 hif_drv
= vif
->hif_drv
;
3797 if (!hif_drv
|| hif_drv
== terminated_handle
)
3800 if (hif_drv
->usr_scan_req
.scan_result
) {
3801 memset(&msg
, 0, sizeof(struct host_if_msg
));
3803 msg
.id
= HOST_IF_MSG_RCVD_SCAN_COMPLETE
;
3806 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3808 netdev_err(vif
->ndev
, "complete param (%d)\n", result
);
3812 int wilc_remain_on_channel(struct wilc_vif
*vif
, u32 session_id
,
3813 u32 duration
, u16 chan
,
3814 wilc_remain_on_chan_expired expired
,
3815 wilc_remain_on_chan_ready ready
,
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 memset(&msg
, 0, sizeof(struct host_if_msg
));
3829 msg
.id
= HOST_IF_MSG_REMAIN_ON_CHAN
;
3830 msg
.body
.remain_on_ch
.ch
= chan
;
3831 msg
.body
.remain_on_ch
.expired
= expired
;
3832 msg
.body
.remain_on_ch
.ready
= ready
;
3833 msg
.body
.remain_on_ch
.arg
= user_arg
;
3834 msg
.body
.remain_on_ch
.duration
= duration
;
3835 msg
.body
.remain_on_ch
.id
= session_id
;
3838 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3840 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3845 int wilc_listen_state_expired(struct wilc_vif
*vif
, u32 session_id
)
3848 struct host_if_msg msg
;
3849 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3852 netdev_err(vif
->ndev
, "driver is null\n");
3856 del_timer(&hif_drv
->remain_on_ch_timer
);
3858 memset(&msg
, 0, sizeof(struct host_if_msg
));
3859 msg
.id
= HOST_IF_MSG_LISTEN_TIMER_FIRED
;
3861 msg
.body
.remain_on_ch
.id
= session_id
;
3863 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3865 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3870 int wilc_frame_register(struct wilc_vif
*vif
, u16 frame_type
, bool reg
)
3873 struct host_if_msg msg
;
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_REGISTER_FRAME
;
3884 switch (frame_type
) {
3886 msg
.body
.reg_frame
.reg_id
= ACTION_FRM_IDX
;
3890 msg
.body
.reg_frame
.reg_id
= PROBE_REQ_IDX
;
3896 msg
.body
.reg_frame
.frame_type
= frame_type
;
3897 msg
.body
.reg_frame
.reg
= reg
;
3900 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3902 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3907 int wilc_add_beacon(struct wilc_vif
*vif
, u32 interval
, u32 dtim_period
,
3908 u32 head_len
, u8
*head
, u32 tail_len
, u8
*tail
)
3911 struct host_if_msg msg
;
3912 struct beacon_attr
*beacon_info
= &msg
.body
.beacon_info
;
3913 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3916 netdev_err(vif
->ndev
, "driver is null\n");
3920 memset(&msg
, 0, sizeof(struct host_if_msg
));
3922 msg
.id
= HOST_IF_MSG_ADD_BEACON
;
3924 beacon_info
->interval
= interval
;
3925 beacon_info
->dtim_period
= dtim_period
;
3926 beacon_info
->head_len
= head_len
;
3927 beacon_info
->head
= kmemdup(head
, head_len
, GFP_KERNEL
);
3928 if (!beacon_info
->head
) {
3932 beacon_info
->tail_len
= tail_len
;
3935 beacon_info
->tail
= kmemdup(tail
, tail_len
, GFP_KERNEL
);
3936 if (!beacon_info
->tail
) {
3941 beacon_info
->tail
= NULL
;
3944 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3946 netdev_err(vif
->ndev
, "wilc mq send fail\n");
3950 kfree(beacon_info
->head
);
3952 kfree(beacon_info
->tail
);
3958 int wilc_del_beacon(struct wilc_vif
*vif
)
3961 struct host_if_msg msg
;
3962 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3965 netdev_err(vif
->ndev
, "driver is null\n");
3969 msg
.id
= HOST_IF_MSG_DEL_BEACON
;
3972 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
3974 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
3979 int wilc_add_station(struct wilc_vif
*vif
, struct add_sta_param
*sta_param
)
3982 struct host_if_msg msg
;
3983 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
3984 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
3987 netdev_err(vif
->ndev
, "driver is null\n");
3991 memset(&msg
, 0, sizeof(struct host_if_msg
));
3993 msg
.id
= HOST_IF_MSG_ADD_STATION
;
3996 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
3997 if (add_sta_info
->rates_len
> 0) {
3998 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
3999 add_sta_info
->rates_len
,
4001 if (!add_sta_info
->rates
)
4005 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4007 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4011 int wilc_del_station(struct wilc_vif
*vif
, const u8
*mac_addr
)
4014 struct host_if_msg msg
;
4015 struct del_sta
*del_sta_info
= &msg
.body
.del_sta_info
;
4016 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4019 netdev_err(vif
->ndev
, "driver is null\n");
4023 memset(&msg
, 0, sizeof(struct host_if_msg
));
4025 msg
.id
= HOST_IF_MSG_DEL_STATION
;
4029 eth_broadcast_addr(del_sta_info
->mac_addr
);
4031 memcpy(del_sta_info
->mac_addr
, mac_addr
, ETH_ALEN
);
4033 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4035 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4039 int wilc_del_allstation(struct wilc_vif
*vif
, u8 mac_addr
[][ETH_ALEN
])
4042 struct host_if_msg msg
;
4043 struct del_all_sta
*del_all_sta_info
= &msg
.body
.del_all_sta_info
;
4044 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4045 u8 zero_addr
[ETH_ALEN
] = {0};
4050 netdev_err(vif
->ndev
, "driver is null\n");
4054 memset(&msg
, 0, sizeof(struct host_if_msg
));
4056 msg
.id
= HOST_IF_MSG_DEL_ALL_STA
;
4059 for (i
= 0; i
< MAX_NUM_STA
; i
++) {
4060 if (memcmp(mac_addr
[i
], zero_addr
, ETH_ALEN
)) {
4061 memcpy(del_all_sta_info
->del_all_sta
[i
], mac_addr
[i
], ETH_ALEN
);
4068 del_all_sta_info
->assoc_sta
= assoc_sta
;
4069 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4072 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4074 down(&hif_sema_wait_response
);
4079 int wilc_edit_station(struct wilc_vif
*vif
,
4080 struct add_sta_param
*sta_param
)
4083 struct host_if_msg msg
;
4084 struct add_sta_param
*add_sta_info
= &msg
.body
.add_sta_info
;
4085 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4088 netdev_err(vif
->ndev
, "driver is null\n");
4092 memset(&msg
, 0, sizeof(struct host_if_msg
));
4094 msg
.id
= HOST_IF_MSG_EDIT_STATION
;
4097 memcpy(add_sta_info
, sta_param
, sizeof(struct add_sta_param
));
4098 if (add_sta_info
->rates_len
> 0) {
4099 add_sta_info
->rates
= kmemdup(sta_param
->rates
,
4100 add_sta_info
->rates_len
,
4102 if (!add_sta_info
->rates
)
4106 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4108 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4113 int wilc_set_power_mgmt(struct wilc_vif
*vif
, bool enabled
, u32 timeout
)
4116 struct host_if_msg msg
;
4117 struct power_mgmt_param
*pwr_mgmt_info
= &msg
.body
.pwr_mgmt_info
;
4118 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4121 netdev_err(vif
->ndev
, "driver is null\n");
4125 if (wilc_wlan_get_num_conn_ifcs(vif
->wilc
) == 2 && enabled
)
4128 memset(&msg
, 0, sizeof(struct host_if_msg
));
4130 msg
.id
= HOST_IF_MSG_POWER_MGMT
;
4133 pwr_mgmt_info
->enabled
= enabled
;
4134 pwr_mgmt_info
->timeout
= timeout
;
4136 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4138 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4142 int wilc_setup_multicast_filter(struct wilc_vif
*vif
, bool enabled
,
4146 struct host_if_msg msg
;
4147 struct set_multicast
*multicast_filter_param
= &msg
.body
.multicast_info
;
4148 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4151 netdev_err(vif
->ndev
, "driver is null\n");
4155 memset(&msg
, 0, sizeof(struct host_if_msg
));
4157 msg
.id
= HOST_IF_MSG_SET_MULTICAST_FILTER
;
4160 multicast_filter_param
->enabled
= enabled
;
4161 multicast_filter_param
->cnt
= count
;
4163 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4165 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4169 static void *host_int_ParseJoinBssParam(struct network_info
*ptstrNetworkInfo
)
4171 struct join_bss_param
*pNewJoinBssParam
= NULL
;
4180 u8 pcipherTotalCount
= 0;
4181 u8 authTotalCount
= 0;
4184 pu8IEs
= ptstrNetworkInfo
->ies
;
4185 u16IEsLen
= ptstrNetworkInfo
->ies_len
;
4187 pNewJoinBssParam
= kzalloc(sizeof(struct join_bss_param
), GFP_KERNEL
);
4188 if (pNewJoinBssParam
) {
4189 pNewJoinBssParam
->dtim_period
= ptstrNetworkInfo
->dtim_period
;
4190 pNewJoinBssParam
->beacon_period
= ptstrNetworkInfo
->beacon_period
;
4191 pNewJoinBssParam
->cap_info
= ptstrNetworkInfo
->cap_info
;
4192 memcpy(pNewJoinBssParam
->bssid
, ptstrNetworkInfo
->bssid
, 6);
4193 memcpy((u8
*)pNewJoinBssParam
->ssid
, ptstrNetworkInfo
->ssid
,
4194 ptstrNetworkInfo
->ssid_len
+ 1);
4195 pNewJoinBssParam
->ssid_len
= ptstrNetworkInfo
->ssid_len
;
4196 memset(pNewJoinBssParam
->rsn_pcip_policy
, 0xFF, 3);
4197 memset(pNewJoinBssParam
->rsn_auth_policy
, 0xFF, 3);
4199 while (index
< u16IEsLen
) {
4200 if (pu8IEs
[index
] == SUPP_RATES_IE
) {
4201 suppRatesNo
= pu8IEs
[index
+ 1];
4202 pNewJoinBssParam
->supp_rates
[0] = suppRatesNo
;
4205 for (i
= 0; i
< suppRatesNo
; i
++)
4206 pNewJoinBssParam
->supp_rates
[i
+ 1] = pu8IEs
[index
+ i
];
4208 index
+= suppRatesNo
;
4210 } else if (pu8IEs
[index
] == EXT_SUPP_RATES_IE
) {
4211 extSuppRatesNo
= pu8IEs
[index
+ 1];
4212 if (extSuppRatesNo
> (MAX_RATES_SUPPORTED
- suppRatesNo
))
4213 pNewJoinBssParam
->supp_rates
[0] = MAX_RATES_SUPPORTED
;
4215 pNewJoinBssParam
->supp_rates
[0] += extSuppRatesNo
;
4217 for (i
= 0; i
< (pNewJoinBssParam
->supp_rates
[0] - suppRatesNo
); i
++)
4218 pNewJoinBssParam
->supp_rates
[suppRatesNo
+ i
+ 1] = pu8IEs
[index
+ i
];
4220 index
+= extSuppRatesNo
;
4222 } else if (pu8IEs
[index
] == HT_CAPABILITY_IE
) {
4223 pNewJoinBssParam
->ht_capable
= true;
4224 index
+= pu8IEs
[index
+ 1] + 2;
4226 } else if ((pu8IEs
[index
] == WMM_IE
) &&
4227 (pu8IEs
[index
+ 2] == 0x00) && (pu8IEs
[index
+ 3] == 0x50) &&
4228 (pu8IEs
[index
+ 4] == 0xF2) &&
4229 (pu8IEs
[index
+ 5] == 0x02) &&
4230 ((pu8IEs
[index
+ 6] == 0x00) || (pu8IEs
[index
+ 6] == 0x01)) &&
4231 (pu8IEs
[index
+ 7] == 0x01)) {
4232 pNewJoinBssParam
->wmm_cap
= true;
4234 if (pu8IEs
[index
+ 8] & BIT(7))
4235 pNewJoinBssParam
->uapsd_cap
= true;
4236 index
+= pu8IEs
[index
+ 1] + 2;
4238 } else if ((pu8IEs
[index
] == P2P_IE
) &&
4239 (pu8IEs
[index
+ 2] == 0x50) && (pu8IEs
[index
+ 3] == 0x6f) &&
4240 (pu8IEs
[index
+ 4] == 0x9a) &&
4241 (pu8IEs
[index
+ 5] == 0x09) && (pu8IEs
[index
+ 6] == 0x0c)) {
4244 pNewJoinBssParam
->tsf
= ptstrNetworkInfo
->tsf_lo
;
4245 pNewJoinBssParam
->noa_enabled
= 1;
4246 pNewJoinBssParam
->idx
= pu8IEs
[index
+ 9];
4248 if (pu8IEs
[index
+ 10] & BIT(7)) {
4249 pNewJoinBssParam
->opp_enabled
= 1;
4250 pNewJoinBssParam
->ct_window
= pu8IEs
[index
+ 10];
4252 pNewJoinBssParam
->opp_enabled
= 0;
4255 pNewJoinBssParam
->cnt
= pu8IEs
[index
+ 11];
4256 u16P2P_count
= index
+ 12;
4258 memcpy(pNewJoinBssParam
->duration
, pu8IEs
+ u16P2P_count
, 4);
4261 memcpy(pNewJoinBssParam
->interval
, pu8IEs
+ u16P2P_count
, 4);
4264 memcpy(pNewJoinBssParam
->start_time
, pu8IEs
+ u16P2P_count
, 4);
4266 index
+= pu8IEs
[index
+ 1] + 2;
4269 } else if ((pu8IEs
[index
] == RSN_IE
) ||
4270 ((pu8IEs
[index
] == WPA_IE
) && (pu8IEs
[index
+ 2] == 0x00) &&
4271 (pu8IEs
[index
+ 3] == 0x50) && (pu8IEs
[index
+ 4] == 0xF2) &&
4272 (pu8IEs
[index
+ 5] == 0x01))) {
4273 u16 rsnIndex
= index
;
4275 if (pu8IEs
[rsnIndex
] == RSN_IE
) {
4276 pNewJoinBssParam
->mode_802_11i
= 2;
4278 if (pNewJoinBssParam
->mode_802_11i
== 0)
4279 pNewJoinBssParam
->mode_802_11i
= 1;
4284 pNewJoinBssParam
->rsn_grp_policy
= pu8IEs
[rsnIndex
];
4286 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4287 pcipherCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4290 for (i
= pcipherTotalCount
, j
= 0; i
< pcipherCount
+ pcipherTotalCount
&& i
< 3; i
++, j
++)
4291 pNewJoinBssParam
->rsn_pcip_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4293 pcipherTotalCount
+= pcipherCount
;
4294 rsnIndex
+= jumpOffset
;
4296 jumpOffset
= pu8IEs
[rsnIndex
] * 4;
4298 authCount
= (pu8IEs
[rsnIndex
] > 3) ? 3 : pu8IEs
[rsnIndex
];
4301 for (i
= authTotalCount
, j
= 0; i
< authTotalCount
+ authCount
; i
++, j
++)
4302 pNewJoinBssParam
->rsn_auth_policy
[i
] = pu8IEs
[rsnIndex
+ ((j
+ 1) * 4) - 1];
4304 authTotalCount
+= authCount
;
4305 rsnIndex
+= jumpOffset
;
4307 if (pu8IEs
[index
] == RSN_IE
) {
4308 pNewJoinBssParam
->rsn_cap
[0] = pu8IEs
[rsnIndex
];
4309 pNewJoinBssParam
->rsn_cap
[1] = pu8IEs
[rsnIndex
+ 1];
4312 pNewJoinBssParam
->rsn_found
= true;
4313 index
+= pu8IEs
[index
+ 1] + 2;
4316 index
+= pu8IEs
[index
+ 1] + 2;
4320 return (void *)pNewJoinBssParam
;
4323 int wilc_setup_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4326 struct host_if_msg msg
;
4327 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4330 netdev_err(vif
->ndev
, "driver is null\n");
4334 memset(&msg
, 0, sizeof(struct host_if_msg
));
4336 msg
.id
= HOST_IF_MSG_SET_IPADDRESS
;
4338 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4340 msg
.body
.ip_info
.idx
= idx
;
4342 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4344 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4349 static int host_int_get_ipaddress(struct wilc_vif
*vif
, u8
*ip_addr
, u8 idx
)
4352 struct host_if_msg msg
;
4353 struct host_if_drv
*hif_drv
= vif
->hif_drv
;
4356 netdev_err(vif
->ndev
, "driver is null\n");
4360 memset(&msg
, 0, sizeof(struct host_if_msg
));
4362 msg
.id
= HOST_IF_MSG_GET_IPADDRESS
;
4364 msg
.body
.ip_info
.ip_addr
= ip_addr
;
4366 msg
.body
.ip_info
.idx
= idx
;
4368 result
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4370 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4375 int wilc_set_tx_power(struct wilc_vif
*vif
, u8 tx_power
)
4378 struct host_if_msg msg
;
4380 memset(&msg
, 0, sizeof(struct host_if_msg
));
4382 msg
.id
= HOST_IF_MSG_SET_TX_POWER
;
4383 msg
.body
.tx_power
.tx_pwr
= tx_power
;
4386 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4388 netdev_err(vif
->ndev
, "wilc_mq_send fail\n");
4393 int wilc_get_tx_power(struct wilc_vif
*vif
, u8
*tx_power
)
4396 struct host_if_msg msg
;
4398 memset(&msg
, 0, sizeof(struct host_if_msg
));
4400 msg
.id
= HOST_IF_MSG_GET_TX_POWER
;
4403 ret
= wilc_mq_send(&hif_msg_q
, &msg
, sizeof(struct host_if_msg
));
4405 netdev_err(vif
->ndev
, "Failed to get TX PWR\n");
4407 down(&hif_sema_wait_response
);
4408 *tx_power
= msg
.body
.tx_power
.tx_pwr
;