staging: wilc1000: remove typedef from pstrNetworkInfo
[deliverable/linux.git] / drivers / staging / wilc1000 / host_interface.c
1 #include <linux/slab.h>
2 #include <linux/time.h>
3 #include <linux/kthread.h>
4 #include <linux/delay.h>
5 #include "host_interface.h"
6 #include "coreconfigurator.h"
7 #include "wilc_wlan.h"
8 #include "wilc_wlan_if.h"
9 #include "wilc_msgqueue.h"
10 #include <linux/etherdevice.h>
11 #include "wilc_wfi_netdevice.h"
12
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
53
54 #define HOST_IF_SCAN_TIMEOUT 4000
55 #define HOST_IF_CONNECT_TIMEOUT 9500
56
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
61
62 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
63 #define DEFAULT_LINK_SPEED 72
64
65 struct cfg_param_attr {
66 struct cfg_param_val cfg_attr_info;
67 };
68
69 struct host_if_wpa_attr {
70 u8 *key;
71 const u8 *mac_addr;
72 u8 *seq;
73 u8 seq_len;
74 u8 index;
75 u8 key_len;
76 u8 mode;
77 };
78
79 struct host_if_wep_attr {
80 u8 *key;
81 u8 key_len;
82 u8 index;
83 u8 mode;
84 enum AUTHTYPE auth_type;
85 };
86
87 union host_if_key_attr {
88 struct host_if_wep_attr wep;
89 struct host_if_wpa_attr wpa;
90 struct host_if_pmkid_attr pmkid;
91 };
92
93 struct key_attr {
94 enum KEY_TYPE type;
95 u8 action;
96 union host_if_key_attr attr;
97 };
98
99 struct scan_attr {
100 u8 src;
101 u8 type;
102 u8 *ch_freq_list;
103 u8 ch_list_len;
104 u8 *ies;
105 size_t ies_len;
106 wilc_scan_result result;
107 void *arg;
108 struct hidden_network hidden_network;
109 };
110
111 struct connect_attr {
112 u8 *bssid;
113 u8 *ssid;
114 size_t ssid_len;
115 u8 *ies;
116 size_t ies_len;
117 u8 security;
118 wilc_connect_result result;
119 void *arg;
120 enum AUTHTYPE auth_type;
121 u8 ch;
122 void *params;
123 };
124
125 struct rcvd_async_info {
126 u8 *buffer;
127 u32 len;
128 };
129
130 struct channel_attr {
131 u8 set_ch;
132 };
133
134 struct beacon_attr {
135 u32 interval;
136 u32 dtim_period;
137 u32 head_len;
138 u8 *head;
139 u32 tail_len;
140 u8 *tail;
141 };
142
143 struct set_multicast {
144 bool enabled;
145 u32 cnt;
146 };
147
148 struct del_all_sta {
149 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
150 u8 assoc_sta;
151 };
152
153 struct del_sta {
154 u8 mac_addr[ETH_ALEN];
155 };
156
157 struct power_mgmt_param {
158 bool enabled;
159 u32 timeout;
160 };
161
162 struct set_ip_addr {
163 u8 *ip_addr;
164 u8 idx;
165 };
166
167 struct sta_inactive_t {
168 u8 mac[6];
169 };
170
171 struct tx_power {
172 u8 tx_pwr;
173 };
174
175 union message_body {
176 struct scan_attr scan_info;
177 struct connect_attr con_info;
178 struct rcvd_net_info net_info;
179 struct rcvd_async_info async_info;
180 struct key_attr key_info;
181 struct cfg_param_attr cfg_info;
182 struct channel_attr channel_info;
183 struct beacon_attr beacon_info;
184 struct add_sta_param add_sta_info;
185 struct del_sta del_sta_info;
186 struct add_sta_param edit_sta_info;
187 struct power_mgmt_param pwr_mgmt_info;
188 struct sta_inactive_t mac_info;
189 struct set_ip_addr ip_info;
190 struct drv_handler drv;
191 struct set_multicast multicast_info;
192 struct op_mode mode;
193 struct set_mac_addr set_mac_info;
194 struct get_mac_addr get_mac_info;
195 struct ba_session_info session_info;
196 struct remain_ch remain_on_ch;
197 struct reg_frame reg_frame;
198 char *data;
199 struct del_all_sta del_all_sta_info;
200 struct tx_power tx_power;
201 };
202
203 struct host_if_msg {
204 u16 id;
205 union message_body body;
206 struct wilc_vif *vif;
207 };
208
209 struct join_bss_param {
210 BSSTYPE_T bss_type;
211 u8 dtim_period;
212 u16 beacon_period;
213 u16 cap_info;
214 u8 au8bssid[6];
215 char ssid[MAX_SSID_LEN];
216 u8 ssid_len;
217 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
218 u8 ht_capable;
219 u8 wmm_cap;
220 u8 uapsd_cap;
221 bool rsn_found;
222 u8 rsn_grp_policy;
223 u8 mode_802_11i;
224 u8 rsn_pcip_policy[3];
225 u8 rsn_auth_policy[3];
226 u8 rsn_cap[2];
227 u32 tsf;
228 u8 noa_enabled;
229 u8 opp_enabled;
230 u8 ct_window;
231 u8 cnt;
232 u8 idx;
233 u8 duration[4];
234 u8 interval[4];
235 u8 start_time[4];
236 };
237
238 static struct host_if_drv *terminated_handle;
239 bool wilc_optaining_ip;
240 static u8 P2P_LISTEN_STATE;
241 static struct task_struct *hif_thread_handler;
242 static struct message_queue hif_msg_q;
243 static struct semaphore hif_sema_thread;
244 static struct semaphore hif_sema_driver;
245 static struct semaphore hif_sema_wait_response;
246 static struct semaphore hif_sema_deinit;
247 static struct timer_list periodic_rssi;
248
249 u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
250
251 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
252
253 static bool scan_while_connected;
254
255 static s8 rssi;
256 static s8 link_speed;
257 static u8 ch_no;
258 static u8 set_ip[2][4];
259 static u8 get_ip[2][4];
260 static u32 inactive_time;
261 static u8 del_beacon;
262 static u32 clients_count;
263
264 static u8 *join_req;
265 static u8 *info_element;
266 static u8 mode_11i;
267 static u8 auth_type;
268 static u32 join_req_size;
269 static u32 info_element_size;
270 static struct wilc_vif *join_req_vif;
271 #define REAL_JOIN_REQ 0
272 #define FLUSHED_JOIN_REQ 1
273 #define FLUSHED_BYTE_POS 79
274
275 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo);
276 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
277
278 /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
279 * special purpose in wilc device, so we add 1 to the index to starts from 1.
280 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
281 */
282 int wilc_get_vif_idx(struct wilc_vif *vif)
283 {
284 return vif->idx + 1;
285 }
286
287 /* We need to minus 1 from idx which is from wilc device to get real index
288 * of wilc->vif[], because we add 1 when pass to wilc device in the function
289 * wilc_get_vif_idx.
290 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
291 */
292 static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
293 {
294 int index = idx - 1;
295
296 if (index < 0 || index >= NUM_CONCURRENT_IFC)
297 return NULL;
298
299 return wilc->vif[index];
300 }
301
302 static s32 handle_set_channel(struct wilc_vif *vif,
303 struct channel_attr *hif_set_ch)
304 {
305 s32 result = 0;
306 struct wid wid;
307
308 wid.id = (u16)WID_CURRENT_CHANNEL;
309 wid.type = WID_CHAR;
310 wid.val = (char *)&hif_set_ch->set_ch;
311 wid.size = sizeof(char);
312
313 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
314 wilc_get_vif_idx(vif));
315
316 if (result) {
317 PRINT_ER("Failed to set channel\n");
318 return -EINVAL;
319 }
320
321 return result;
322 }
323
324 static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
325 struct drv_handler *hif_drv_handler)
326 {
327 s32 result = 0;
328 struct wid wid;
329
330 wid.id = (u16)WID_SET_DRV_HANDLER;
331 wid.type = WID_STR;
332 wid.val = (s8 *)hif_drv_handler;
333 wid.size = sizeof(*hif_drv_handler);
334
335 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
336 hif_drv_handler->handler);
337
338 if (!hif_drv_handler->handler)
339 up(&hif_sema_driver);
340
341 if (result) {
342 PRINT_ER("Failed to set driver handler\n");
343 return -EINVAL;
344 }
345
346 return result;
347 }
348
349 static s32 handle_set_operation_mode(struct wilc_vif *vif,
350 struct op_mode *hif_op_mode)
351 {
352 s32 result = 0;
353 struct wid wid;
354
355 wid.id = (u16)WID_SET_OPERATION_MODE;
356 wid.type = WID_INT;
357 wid.val = (s8 *)&hif_op_mode->mode;
358 wid.size = sizeof(u32);
359
360 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
361 wilc_get_vif_idx(vif));
362
363 if ((hif_op_mode->mode) == IDLE_MODE)
364 up(&hif_sema_driver);
365
366 if (result) {
367 PRINT_ER("Failed to set driver handler\n");
368 return -EINVAL;
369 }
370
371 return result;
372 }
373
374 static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
375 {
376 s32 result = 0;
377 struct wid wid;
378 char firmware_ip_addr[4] = {0};
379
380 if (ip_addr[0] < 192)
381 ip_addr[0] = 0;
382
383 memcpy(set_ip[idx], ip_addr, IP_ALEN);
384
385 wid.id = (u16)WID_IP_ADDRESS;
386 wid.type = WID_STR;
387 wid.val = (u8 *)ip_addr;
388 wid.size = IP_ALEN;
389
390 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
391 wilc_get_vif_idx(vif));
392
393 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
394
395 if (result) {
396 PRINT_ER("Failed to set IP address\n");
397 return -EINVAL;
398 }
399
400 return result;
401 }
402
403 static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
404 {
405 s32 result = 0;
406 struct wid wid;
407
408 wid.id = (u16)WID_IP_ADDRESS;
409 wid.type = WID_STR;
410 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
411 wid.size = IP_ALEN;
412
413 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
414 wilc_get_vif_idx(vif));
415
416 memcpy(get_ip[idx], wid.val, IP_ALEN);
417
418 kfree(wid.val);
419
420 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
421 wilc_setup_ipaddress(vif, set_ip[idx], idx);
422
423 if (result != 0) {
424 PRINT_ER("Failed to get IP address\n");
425 return -EINVAL;
426 }
427
428 return result;
429 }
430
431 static s32 handle_set_mac_address(struct wilc_vif *vif,
432 struct set_mac_addr *set_mac_addr)
433 {
434 s32 result = 0;
435 struct wid wid;
436 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
437
438 if (!mac_buf) {
439 PRINT_ER("No buffer to send mac address\n");
440 return -EFAULT;
441 }
442 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
443
444 wid.id = (u16)WID_MAC_ADDR;
445 wid.type = WID_STR;
446 wid.val = mac_buf;
447 wid.size = ETH_ALEN;
448 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
449
450 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
451 wilc_get_vif_idx(vif));
452 if (result) {
453 PRINT_ER("Failed to set mac address\n");
454 result = -EFAULT;
455 }
456
457 kfree(mac_buf);
458 return result;
459 }
460
461 static s32 handle_get_mac_address(struct wilc_vif *vif,
462 struct get_mac_addr *get_mac_addr)
463 {
464 s32 result = 0;
465 struct wid wid;
466
467 wid.id = (u16)WID_MAC_ADDR;
468 wid.type = WID_STR;
469 wid.val = get_mac_addr->mac_addr;
470 wid.size = ETH_ALEN;
471
472 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
473 wilc_get_vif_idx(vif));
474
475 if (result) {
476 PRINT_ER("Failed to get mac address\n");
477 result = -EFAULT;
478 }
479 up(&hif_sema_wait_response);
480
481 return result;
482 }
483
484 static s32 handle_cfg_param(struct wilc_vif *vif,
485 struct cfg_param_attr *cfg_param_attr)
486 {
487 s32 result = 0;
488 struct wid wid_list[32];
489 struct host_if_drv *hif_drv = vif->hif_drv;
490 u8 wid_cnt = 0;
491
492 down(&hif_drv->sem_cfg_values);
493
494 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
495 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
496 wid_list[wid_cnt].id = WID_BSS_TYPE;
497 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
498 wid_list[wid_cnt].type = WID_CHAR;
499 wid_list[wid_cnt].size = sizeof(char);
500 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
501 } else {
502 PRINT_ER("check value 6 over\n");
503 result = -EINVAL;
504 goto ERRORHANDLER;
505 }
506 wid_cnt++;
507 }
508 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
509 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
510 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
511 cfg_param_attr->cfg_attr_info.auth_type == 5) {
512 wid_list[wid_cnt].id = WID_AUTH_TYPE;
513 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
514 wid_list[wid_cnt].type = WID_CHAR;
515 wid_list[wid_cnt].size = sizeof(char);
516 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
517 } else {
518 PRINT_ER("Impossible value \n");
519 result = -EINVAL;
520 goto ERRORHANDLER;
521 }
522 wid_cnt++;
523 }
524 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
525 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
526 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
527 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
528 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
529 wid_list[wid_cnt].type = WID_SHORT;
530 wid_list[wid_cnt].size = sizeof(u16);
531 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
532 } else {
533 PRINT_ER("Range(1 ~ 65535) over\n");
534 result = -EINVAL;
535 goto ERRORHANDLER;
536 }
537 wid_cnt++;
538 }
539 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
540 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
541 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
542 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
543 wid_list[wid_cnt].type = WID_CHAR;
544 wid_list[wid_cnt].size = sizeof(char);
545 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
546 } else {
547 PRINT_ER("Invalide power mode\n");
548 result = -EINVAL;
549 goto ERRORHANDLER;
550 }
551 wid_cnt++;
552 }
553 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
554 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
555 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
556 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
557 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
558 wid_list[wid_cnt].type = WID_SHORT;
559 wid_list[wid_cnt].size = sizeof(u16);
560 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
561 } else {
562 PRINT_ER("Range(1~256) over\n");
563 result = -EINVAL;
564 goto ERRORHANDLER;
565 }
566 wid_cnt++;
567 }
568 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
569 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
570 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
571 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
572 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
573 wid_list[wid_cnt].type = WID_SHORT;
574 wid_list[wid_cnt].size = sizeof(u16);
575 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
576 } else {
577 PRINT_ER("Range(1~256) over\n");
578 result = -EINVAL;
579 goto ERRORHANDLER;
580 }
581 wid_cnt++;
582 }
583 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
584 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
585 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
586 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
587 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
588 wid_list[wid_cnt].type = WID_SHORT;
589 wid_list[wid_cnt].size = sizeof(u16);
590 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
591 } else {
592 PRINT_ER("Threshold Range fail\n");
593 result = -EINVAL;
594 goto ERRORHANDLER;
595 }
596 wid_cnt++;
597 }
598 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
599 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
600 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
601 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
602 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
603 wid_list[wid_cnt].type = WID_SHORT;
604 wid_list[wid_cnt].size = sizeof(u16);
605 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
606 } else {
607 PRINT_ER("Threshold Range fail\n");
608 result = -EINVAL;
609 goto ERRORHANDLER;
610 }
611 wid_cnt++;
612 }
613 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
614 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
615 wid_list[wid_cnt].id = WID_PREAMBLE;
616 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
617 wid_list[wid_cnt].type = WID_CHAR;
618 wid_list[wid_cnt].size = sizeof(char);
619 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
620 } else {
621 PRINT_ER("Preamle Range(0~2) over\n");
622 result = -EINVAL;
623 goto ERRORHANDLER;
624 }
625 wid_cnt++;
626 }
627 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
628 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
629 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
630 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
631 wid_list[wid_cnt].type = WID_CHAR;
632 wid_list[wid_cnt].size = sizeof(char);
633 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
634 } else {
635 PRINT_ER("Short slot(2) over\n");
636 result = -EINVAL;
637 goto ERRORHANDLER;
638 }
639 wid_cnt++;
640 }
641 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
642 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
643 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
644 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
645 wid_list[wid_cnt].type = WID_CHAR;
646 wid_list[wid_cnt].size = sizeof(char);
647 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
648 } else {
649 PRINT_ER("TXOP prot disable\n");
650 result = -EINVAL;
651 goto ERRORHANDLER;
652 }
653 wid_cnt++;
654 }
655 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
656 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
657 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
658 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
659 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
660 wid_list[wid_cnt].type = WID_SHORT;
661 wid_list[wid_cnt].size = sizeof(u16);
662 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
663 } else {
664 PRINT_ER("Beacon interval(1~65535) fail\n");
665 result = -EINVAL;
666 goto ERRORHANDLER;
667 }
668 wid_cnt++;
669 }
670 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
671 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
672 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
673 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
674 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
675 wid_list[wid_cnt].type = WID_CHAR;
676 wid_list[wid_cnt].size = sizeof(char);
677 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
678 } else {
679 PRINT_ER("DTIM range(1~255) fail\n");
680 result = -EINVAL;
681 goto ERRORHANDLER;
682 }
683 wid_cnt++;
684 }
685 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
686 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
687 wid_list[wid_cnt].id = WID_SITE_SURVEY;
688 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
689 wid_list[wid_cnt].type = WID_CHAR;
690 wid_list[wid_cnt].size = sizeof(char);
691 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
692 } else {
693 PRINT_ER("Site survey disable\n");
694 result = -EINVAL;
695 goto ERRORHANDLER;
696 }
697 wid_cnt++;
698 }
699 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
700 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
701 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
702 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
703 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
704 wid_list[wid_cnt].type = WID_SHORT;
705 wid_list[wid_cnt].size = sizeof(u16);
706 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time;
707 } else {
708 PRINT_ER("Site survey scan time(1~65535) over\n");
709 result = -EINVAL;
710 goto ERRORHANDLER;
711 }
712 wid_cnt++;
713 }
714 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
715 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
716 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
717 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
718 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
719 wid_list[wid_cnt].type = WID_SHORT;
720 wid_list[wid_cnt].size = sizeof(u16);
721 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
722 } else {
723 PRINT_ER("Active scan time(1~65535) over\n");
724 result = -EINVAL;
725 goto ERRORHANDLER;
726 }
727 wid_cnt++;
728 }
729 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
730 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
731 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
732 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
733 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
734 wid_list[wid_cnt].type = WID_SHORT;
735 wid_list[wid_cnt].size = sizeof(u16);
736 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
737 } else {
738 PRINT_ER("Passive scan time(1~65535) over\n");
739 result = -EINVAL;
740 goto ERRORHANDLER;
741 }
742 wid_cnt++;
743 }
744 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
745 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
746
747 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
748 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
749 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
750 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
751 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
752 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
753 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
754 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
755 wid_list[wid_cnt].type = WID_SHORT;
756 wid_list[wid_cnt].size = sizeof(u16);
757 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
758 } else {
759 PRINT_ER("out of TX rate\n");
760 result = -EINVAL;
761 goto ERRORHANDLER;
762 }
763 wid_cnt++;
764 }
765
766 result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
767 wid_cnt, wilc_get_vif_idx(vif));
768
769 if (result)
770 PRINT_ER("Error in setting CFG params\n");
771
772 ERRORHANDLER:
773 up(&hif_drv->sem_cfg_values);
774 return result;
775 }
776
777 static void Handle_wait_msg_q_empty(void)
778 {
779 wilc_initialized = 0;
780 up(&hif_sema_wait_response);
781 }
782
783 static s32 Handle_ScanDone(struct wilc_vif *vif,
784 enum scan_event enuEvent);
785
786 static s32 Handle_Scan(struct wilc_vif *vif,
787 struct scan_attr *pstrHostIFscanAttr)
788 {
789 s32 result = 0;
790 struct wid strWIDList[5];
791 u32 u32WidsCount = 0;
792 u32 i;
793 u8 *pu8Buffer;
794 u8 valuesize = 0;
795 u8 *pu8HdnNtwrksWidVal = NULL;
796 struct host_if_drv *hif_drv = vif->hif_drv;
797
798 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
799 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
800
801 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
802 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
803 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
804 hif_drv->hif_state);
805 PRINT_ER("Already scan\n");
806 result = -EBUSY;
807 goto ERRORHANDLER;
808 }
809
810 if (wilc_optaining_ip || wilc_connecting) {
811 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
812 PRINT_ER("Don't do obss scan\n");
813 result = -EBUSY;
814 goto ERRORHANDLER;
815 }
816
817 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
818
819 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
820 strWIDList[u32WidsCount].type = WID_STR;
821
822 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++)
823 valuesize += ((pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len) + 1);
824 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
825 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
826 if (strWIDList[u32WidsCount].val) {
827 pu8Buffer = strWIDList[u32WidsCount].val;
828
829 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
830
831 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++) {
832 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
833 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.net_info[i].ssid, pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len);
834 pu8Buffer += pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
835 }
836
837 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
838 u32WidsCount++;
839 }
840
841 {
842 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
843 strWIDList[u32WidsCount].type = WID_BIN_DATA;
844 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
845 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
846 u32WidsCount++;
847 }
848
849 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
850 strWIDList[u32WidsCount].type = WID_CHAR;
851 strWIDList[u32WidsCount].size = sizeof(char);
852 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
853 u32WidsCount++;
854
855 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
856 strWIDList[u32WidsCount].type = WID_BIN_DATA;
857
858 if (pstrHostIFscanAttr->ch_freq_list &&
859 pstrHostIFscanAttr->ch_list_len > 0) {
860 int i;
861
862 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
863 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
864 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
865 }
866 }
867
868 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
869 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
870 u32WidsCount++;
871
872 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
873 strWIDList[u32WidsCount].type = WID_CHAR;
874 strWIDList[u32WidsCount].size = sizeof(char);
875 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
876 u32WidsCount++;
877
878 if (hif_drv->hif_state == HOST_IF_CONNECTED)
879 scan_while_connected = true;
880 else if (hif_drv->hif_state == HOST_IF_IDLE)
881 scan_while_connected = false;
882
883 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
884 u32WidsCount,
885 wilc_get_vif_idx(vif));
886
887 if (result)
888 PRINT_ER("Failed to send scan paramters config packet\n");
889
890 ERRORHANDLER:
891 if (result) {
892 del_timer(&hif_drv->scan_timer);
893 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
894 }
895
896 kfree(pstrHostIFscanAttr->ch_freq_list);
897 pstrHostIFscanAttr->ch_freq_list = NULL;
898
899 kfree(pstrHostIFscanAttr->ies);
900 pstrHostIFscanAttr->ies = NULL;
901 kfree(pstrHostIFscanAttr->hidden_network.net_info);
902 pstrHostIFscanAttr->hidden_network.net_info = NULL;
903
904 kfree(pu8HdnNtwrksWidVal);
905
906 return result;
907 }
908
909 static s32 Handle_ScanDone(struct wilc_vif *vif,
910 enum scan_event enuEvent)
911 {
912 s32 result = 0;
913 u8 u8abort_running_scan;
914 struct wid wid;
915 struct host_if_drv *hif_drv = vif->hif_drv;
916
917 if (enuEvent == SCAN_EVENT_ABORTED) {
918 PRINT_D(GENERIC_DBG, "Abort running scan\n");
919 u8abort_running_scan = 1;
920 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
921 wid.type = WID_CHAR;
922 wid.val = (s8 *)&u8abort_running_scan;
923 wid.size = sizeof(char);
924
925 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
926 wilc_get_vif_idx(vif));
927
928 if (result) {
929 PRINT_ER("Failed to set abort running scan\n");
930 result = -EFAULT;
931 }
932 }
933
934 if (!hif_drv) {
935 PRINT_ER("Driver handler is NULL\n");
936 return result;
937 }
938
939 if (hif_drv->usr_scan_req.scan_result) {
940 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
941 hif_drv->usr_scan_req.arg, NULL);
942 hif_drv->usr_scan_req.scan_result = NULL;
943 }
944
945 return result;
946 }
947
948 u8 wilc_connected_ssid[6] = {0};
949 static s32 Handle_Connect(struct wilc_vif *vif,
950 struct connect_attr *pstrHostIFconnectAttr)
951 {
952 s32 result = 0;
953 struct wid strWIDList[8];
954 u32 u32WidsCount = 0, dummyval = 0;
955 u8 *pu8CurrByte = NULL;
956 struct join_bss_param *ptstrJoinBssParam;
957 struct host_if_drv *hif_drv = vif->hif_drv;
958
959 PRINT_D(GENERIC_DBG, "Handling connect request\n");
960
961 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
962 result = 0;
963 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
964 return result;
965 }
966
967 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
968 if (!ptstrJoinBssParam) {
969 PRINT_ER("Required BSSID not found\n");
970 result = -ENOENT;
971 goto ERRORHANDLER;
972 }
973
974 if (pstrHostIFconnectAttr->bssid) {
975 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
976 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
977 }
978
979 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
980 if (pstrHostIFconnectAttr->ssid) {
981 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
982 memcpy(hif_drv->usr_conn_req.pu8ssid,
983 pstrHostIFconnectAttr->ssid,
984 pstrHostIFconnectAttr->ssid_len);
985 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
986 }
987
988 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
989 if (pstrHostIFconnectAttr->ies) {
990 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
991 memcpy(hif_drv->usr_conn_req.ies,
992 pstrHostIFconnectAttr->ies,
993 pstrHostIFconnectAttr->ies_len);
994 }
995
996 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
997 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
998 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
999 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
1000
1001 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1002 strWIDList[u32WidsCount].type = WID_INT;
1003 strWIDList[u32WidsCount].size = sizeof(u32);
1004 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1005 u32WidsCount++;
1006
1007 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1008 strWIDList[u32WidsCount].type = WID_INT;
1009 strWIDList[u32WidsCount].size = sizeof(u32);
1010 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1011 u32WidsCount++;
1012
1013 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1014 strWIDList[u32WidsCount].type = WID_INT;
1015 strWIDList[u32WidsCount].size = sizeof(u32);
1016 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1017 u32WidsCount++;
1018
1019 {
1020 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1021 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1022 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
1023 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
1024 u32WidsCount++;
1025
1026 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1027 info_element_size = hif_drv->usr_conn_req.ies_len;
1028 info_element = kmalloc(info_element_size, GFP_KERNEL);
1029 memcpy(info_element, hif_drv->usr_conn_req.ies,
1030 info_element_size);
1031 }
1032 }
1033 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1034 strWIDList[u32WidsCount].type = WID_CHAR;
1035 strWIDList[u32WidsCount].size = sizeof(char);
1036 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
1037 u32WidsCount++;
1038
1039 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1040 mode_11i = hif_drv->usr_conn_req.u8security;
1041
1042 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1043 strWIDList[u32WidsCount].type = WID_CHAR;
1044 strWIDList[u32WidsCount].size = sizeof(char);
1045 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
1046 u32WidsCount++;
1047
1048 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
1049 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
1050
1051 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1052 strWIDList[u32WidsCount].type = WID_STR;
1053 strWIDList[u32WidsCount].size = 112;
1054 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1055
1056 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1057 join_req_size = strWIDList[u32WidsCount].size;
1058 join_req = kmalloc(join_req_size, GFP_KERNEL);
1059 }
1060 if (!strWIDList[u32WidsCount].val) {
1061 result = -EFAULT;
1062 goto ERRORHANDLER;
1063 }
1064
1065 pu8CurrByte = strWIDList[u32WidsCount].val;
1066
1067 if (pstrHostIFconnectAttr->ssid) {
1068 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1069 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
1070 }
1071 pu8CurrByte += MAX_SSID_LEN;
1072 *(pu8CurrByte++) = INFRASTRUCTURE;
1073
1074 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1075 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
1076 } else {
1077 PRINT_ER("Channel out of range\n");
1078 *(pu8CurrByte++) = 0xFF;
1079 }
1080 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1081 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1082
1083 if (pstrHostIFconnectAttr->bssid)
1084 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1085 pu8CurrByte += 6;
1086
1087 if (pstrHostIFconnectAttr->bssid)
1088 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1089 pu8CurrByte += 6;
1090
1091 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1092 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1093 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1094
1095 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1096 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1097
1098 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1099 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1100
1101 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1102 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
1103
1104 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1105 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1106 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1107
1108 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1109 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1110
1111 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1112 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1113
1114 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1115 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1116
1117 *(pu8CurrByte++) = REAL_JOIN_REQ;
1118 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
1119
1120 if (ptstrJoinBssParam->noa_enabled) {
1121 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1122 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1123 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1124 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1125
1126 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
1127 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
1128
1129 if (ptstrJoinBssParam->opp_enabled)
1130 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
1131
1132 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
1133
1134 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1135 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
1136
1137 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1138 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
1139
1140 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1141 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
1142 }
1143
1144 pu8CurrByte = strWIDList[u32WidsCount].val;
1145 u32WidsCount++;
1146
1147 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
1148 memcpy(join_req, pu8CurrByte, join_req_size);
1149 join_req_vif = vif;
1150 }
1151
1152 if (pstrHostIFconnectAttr->bssid) {
1153 memcpy(wilc_connected_ssid,
1154 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1155 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n",
1156 pstrHostIFconnectAttr->bssid);
1157 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", wilc_connected_ssid);
1158 }
1159
1160 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1161 u32WidsCount,
1162 wilc_get_vif_idx(vif));
1163 if (result) {
1164 PRINT_ER("failed to send config packet\n");
1165 result = -EFAULT;
1166 goto ERRORHANDLER;
1167 } else {
1168 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1169 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
1170 }
1171
1172 ERRORHANDLER:
1173 if (result) {
1174 tstrConnectInfo strConnectInfo;
1175
1176 del_timer(&hif_drv->connect_timer);
1177
1178 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1179
1180 if (pstrHostIFconnectAttr->result) {
1181 if (pstrHostIFconnectAttr->bssid)
1182 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
1183
1184 if (pstrHostIFconnectAttr->ies) {
1185 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1186 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1187 memcpy(strConnectInfo.pu8ReqIEs,
1188 pstrHostIFconnectAttr->ies,
1189 pstrHostIFconnectAttr->ies_len);
1190 }
1191
1192 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
1193 &strConnectInfo,
1194 MAC_DISCONNECTED,
1195 NULL,
1196 pstrHostIFconnectAttr->arg);
1197 hif_drv->hif_state = HOST_IF_IDLE;
1198 kfree(strConnectInfo.pu8ReqIEs);
1199 strConnectInfo.pu8ReqIEs = NULL;
1200
1201 } else {
1202 PRINT_ER("Connect callback function pointer is NULL\n");
1203 }
1204 }
1205
1206 kfree(pstrHostIFconnectAttr->bssid);
1207 pstrHostIFconnectAttr->bssid = NULL;
1208
1209 kfree(pstrHostIFconnectAttr->ssid);
1210 pstrHostIFconnectAttr->ssid = NULL;
1211
1212 kfree(pstrHostIFconnectAttr->ies);
1213 pstrHostIFconnectAttr->ies = NULL;
1214
1215 kfree(pu8CurrByte);
1216 return result;
1217 }
1218
1219 static s32 Handle_FlushConnect(struct wilc_vif *vif)
1220 {
1221 s32 result = 0;
1222 struct wid strWIDList[5];
1223 u32 u32WidsCount = 0;
1224 u8 *pu8CurrByte = NULL;
1225
1226 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1227 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1228 strWIDList[u32WidsCount].val = info_element;
1229 strWIDList[u32WidsCount].size = info_element_size;
1230 u32WidsCount++;
1231
1232 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1233 strWIDList[u32WidsCount].type = WID_CHAR;
1234 strWIDList[u32WidsCount].size = sizeof(char);
1235 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
1236 u32WidsCount++;
1237
1238 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1239 strWIDList[u32WidsCount].type = WID_CHAR;
1240 strWIDList[u32WidsCount].size = sizeof(char);
1241 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
1242 u32WidsCount++;
1243
1244 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1245 strWIDList[u32WidsCount].type = WID_STR;
1246 strWIDList[u32WidsCount].size = join_req_size;
1247 strWIDList[u32WidsCount].val = (s8 *)join_req;
1248 pu8CurrByte = strWIDList[u32WidsCount].val;
1249
1250 pu8CurrByte += FLUSHED_BYTE_POS;
1251 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1252
1253 u32WidsCount++;
1254
1255 result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
1256 u32WidsCount,
1257 wilc_get_vif_idx(join_req_vif));
1258 if (result) {
1259 PRINT_ER("failed to send config packet\n");
1260 result = -EINVAL;
1261 }
1262
1263 return result;
1264 }
1265
1266 static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
1267 {
1268 s32 result = 0;
1269 tstrConnectInfo strConnectInfo;
1270 struct wid wid;
1271 u16 u16DummyReasonCode = 0;
1272 struct host_if_drv *hif_drv = vif->hif_drv;
1273
1274 if (!hif_drv) {
1275 PRINT_ER("Driver handler is NULL\n");
1276 return result;
1277 }
1278
1279 hif_drv->hif_state = HOST_IF_IDLE;
1280
1281 scan_while_connected = false;
1282
1283 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1284
1285 if (hif_drv->usr_conn_req.conn_result) {
1286 if (hif_drv->usr_conn_req.pu8bssid) {
1287 memcpy(strConnectInfo.au8bssid,
1288 hif_drv->usr_conn_req.pu8bssid, 6);
1289 }
1290
1291 if (hif_drv->usr_conn_req.ies) {
1292 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1293 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1294 memcpy(strConnectInfo.pu8ReqIEs,
1295 hif_drv->usr_conn_req.ies,
1296 hif_drv->usr_conn_req.ies_len);
1297 }
1298
1299 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1300 &strConnectInfo,
1301 MAC_DISCONNECTED,
1302 NULL,
1303 hif_drv->usr_conn_req.arg);
1304
1305 kfree(strConnectInfo.pu8ReqIEs);
1306 strConnectInfo.pu8ReqIEs = NULL;
1307 } else {
1308 PRINT_ER("Connect callback function pointer is NULL\n");
1309 }
1310
1311 wid.id = (u16)WID_DISCONNECT;
1312 wid.type = WID_CHAR;
1313 wid.val = (s8 *)&u16DummyReasonCode;
1314 wid.size = sizeof(char);
1315
1316 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1317 wilc_get_vif_idx(vif));
1318 if (result)
1319 PRINT_ER("Failed to send dissconect config packet\n");
1320
1321 hif_drv->usr_conn_req.ssid_len = 0;
1322 kfree(hif_drv->usr_conn_req.pu8ssid);
1323 hif_drv->usr_conn_req.pu8ssid = NULL;
1324 kfree(hif_drv->usr_conn_req.pu8bssid);
1325 hif_drv->usr_conn_req.pu8bssid = NULL;
1326 hif_drv->usr_conn_req.ies_len = 0;
1327 kfree(hif_drv->usr_conn_req.ies);
1328 hif_drv->usr_conn_req.ies = NULL;
1329
1330 eth_zero_addr(wilc_connected_ssid);
1331
1332 if (join_req && join_req_vif == vif) {
1333 kfree(join_req);
1334 join_req = NULL;
1335 }
1336
1337 if (info_element && join_req_vif == vif) {
1338 kfree(info_element);
1339 info_element = NULL;
1340 }
1341
1342 return result;
1343 }
1344
1345 static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
1346 struct rcvd_net_info *pstrRcvdNetworkInfo)
1347 {
1348 u32 i;
1349 bool bNewNtwrkFound;
1350 s32 result = 0;
1351 struct network_info *pstrNetworkInfo = NULL;
1352 void *pJoinParams = NULL;
1353 struct host_if_drv *hif_drv = vif->hif_drv;
1354
1355 bNewNtwrkFound = true;
1356
1357 if (hif_drv->usr_scan_req.scan_result) {
1358 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
1359 if ((!pstrNetworkInfo) ||
1360 (!hif_drv->usr_scan_req.scan_result)) {
1361 PRINT_ER("driver is null\n");
1362 result = -EINVAL;
1363 goto done;
1364 }
1365
1366 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
1367 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
1368 (pstrNetworkInfo->au8bssid)) {
1369 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
1370 pstrNetworkInfo->au8bssid, 6) == 0) {
1371 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
1372 goto done;
1373 } else {
1374 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
1375 bNewNtwrkFound = false;
1376 break;
1377 }
1378 }
1379 }
1380 }
1381
1382 if (bNewNtwrkFound) {
1383 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1384 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].s8rssi = pstrNetworkInfo->s8rssi;
1385
1386 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
1387 pstrNetworkInfo->au8bssid) {
1388 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
1389 pstrNetworkInfo->au8bssid, 6);
1390
1391 hif_drv->usr_scan_req.rcvd_ch_cnt++;
1392
1393 pstrNetworkInfo->bNewNetwork = true;
1394 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
1395
1396 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1397 hif_drv->usr_scan_req.arg,
1398 pJoinParams);
1399 }
1400 }
1401 } else {
1402 pstrNetworkInfo->bNewNetwork = false;
1403 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1404 hif_drv->usr_scan_req.arg, NULL);
1405 }
1406 }
1407
1408 done:
1409 kfree(pstrRcvdNetworkInfo->buffer);
1410 pstrRcvdNetworkInfo->buffer = NULL;
1411
1412 if (pstrNetworkInfo) {
1413 kfree(pstrNetworkInfo->pu8IEs);
1414 kfree(pstrNetworkInfo);
1415 }
1416
1417 return result;
1418 }
1419
1420 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
1421 u8 *pu8AssocRespInfo,
1422 u32 u32MaxAssocRespInfoLen,
1423 u32 *pu32RcvdAssocRespInfoLen);
1424
1425 static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
1426 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
1427 {
1428 s32 result = 0;
1429 u8 u8MsgType = 0;
1430 u8 u8MsgID = 0;
1431 u16 u16MsgLen = 0;
1432 u16 u16WidID = (u16)WID_NIL;
1433 u8 u8WidLen = 0;
1434 u8 u8MacStatus;
1435 u8 u8MacStatusReasonCode;
1436 u8 u8MacStatusAdditionalInfo;
1437 tstrConnectInfo strConnectInfo;
1438 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1439 s32 s32Err = 0;
1440 struct host_if_drv *hif_drv = vif->hif_drv;
1441
1442 if (!hif_drv) {
1443 PRINT_ER("Driver handler is NULL\n");
1444 return -ENODEV;
1445 }
1446 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1447 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
1448
1449 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1450 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
1451 hif_drv->usr_scan_req.scan_result) {
1452 if (!pstrRcvdGnrlAsyncInfo->buffer ||
1453 !hif_drv->usr_conn_req.conn_result) {
1454 PRINT_ER("driver is null\n");
1455 return -EINVAL;
1456 }
1457
1458 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
1459
1460 if ('I' != u8MsgType) {
1461 PRINT_ER("Received Message format incorrect.\n");
1462 return -EFAULT;
1463 }
1464
1465 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1466 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1467 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1468 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1469 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1470 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1471 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
1472 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
1473 u32 u32RcvdAssocRespInfoLen = 0;
1474 struct connect_resp_info *pstrConnectRespInfo = NULL;
1475
1476 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1477
1478 if (u8MacStatus == MAC_CONNECTED) {
1479 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
1480
1481 host_int_get_assoc_res_info(vif,
1482 rcv_assoc_resp,
1483 MAX_ASSOC_RESP_FRAME_SIZE,
1484 &u32RcvdAssocRespInfoLen);
1485
1486 if (u32RcvdAssocRespInfoLen != 0) {
1487 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
1488 &pstrConnectRespInfo);
1489 if (s32Err) {
1490 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
1491 } else {
1492 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->status;
1493
1494 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1495 if (pstrConnectRespInfo->ies) {
1496 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->ies_len;
1497 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL);
1498 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->ies,
1499 pstrConnectRespInfo->ies_len);
1500 }
1501 }
1502
1503 if (pstrConnectRespInfo) {
1504 kfree(pstrConnectRespInfo->ies);
1505 kfree(pstrConnectRespInfo);
1506 }
1507 }
1508 }
1509 }
1510
1511 if ((u8MacStatus == MAC_CONNECTED) &&
1512 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
1513 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
1514 eth_zero_addr(wilc_connected_ssid);
1515 } else if (u8MacStatus == MAC_DISCONNECTED) {
1516 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
1517 eth_zero_addr(wilc_connected_ssid);
1518 }
1519
1520 if (hif_drv->usr_conn_req.pu8bssid) {
1521 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
1522
1523 if ((u8MacStatus == MAC_CONNECTED) &&
1524 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1525 memcpy(hif_drv->assoc_bssid,
1526 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
1527 }
1528 }
1529
1530 if (hif_drv->usr_conn_req.ies) {
1531 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1532 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
1533 memcpy(strConnectInfo.pu8ReqIEs,
1534 hif_drv->usr_conn_req.ies,
1535 hif_drv->usr_conn_req.ies_len);
1536 }
1537
1538 del_timer(&hif_drv->connect_timer);
1539 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1540 &strConnectInfo,
1541 u8MacStatus,
1542 NULL,
1543 hif_drv->usr_conn_req.arg);
1544
1545 if ((u8MacStatus == MAC_CONNECTED) &&
1546 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
1547 wilc_set_power_mgmt(vif, 0, 0);
1548
1549 hif_drv->hif_state = HOST_IF_CONNECTED;
1550
1551 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
1552 wilc_optaining_ip = true;
1553 mod_timer(&wilc_during_ip_timer,
1554 jiffies + msecs_to_jiffies(10000));
1555 } else {
1556 hif_drv->hif_state = HOST_IF_IDLE;
1557 scan_while_connected = false;
1558 }
1559
1560 kfree(strConnectInfo.pu8RespIEs);
1561 strConnectInfo.pu8RespIEs = NULL;
1562
1563 kfree(strConnectInfo.pu8ReqIEs);
1564 strConnectInfo.pu8ReqIEs = NULL;
1565 hif_drv->usr_conn_req.ssid_len = 0;
1566 kfree(hif_drv->usr_conn_req.pu8ssid);
1567 hif_drv->usr_conn_req.pu8ssid = NULL;
1568 kfree(hif_drv->usr_conn_req.pu8bssid);
1569 hif_drv->usr_conn_req.pu8bssid = NULL;
1570 hif_drv->usr_conn_req.ies_len = 0;
1571 kfree(hif_drv->usr_conn_req.ies);
1572 hif_drv->usr_conn_req.ies = NULL;
1573 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1574 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
1575 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1576
1577 if (hif_drv->usr_scan_req.scan_result) {
1578 del_timer(&hif_drv->scan_timer);
1579 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1580 }
1581
1582 strDisconnectNotifInfo.u16reason = 0;
1583 strDisconnectNotifInfo.ie = NULL;
1584 strDisconnectNotifInfo.ie_len = 0;
1585
1586 if (hif_drv->usr_conn_req.conn_result) {
1587 wilc_optaining_ip = false;
1588 wilc_set_power_mgmt(vif, 0, 0);
1589
1590 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1591 NULL,
1592 0,
1593 &strDisconnectNotifInfo,
1594 hif_drv->usr_conn_req.arg);
1595 } else {
1596 PRINT_ER("Connect result callback function is NULL\n");
1597 }
1598
1599 eth_zero_addr(hif_drv->assoc_bssid);
1600
1601 hif_drv->usr_conn_req.ssid_len = 0;
1602 kfree(hif_drv->usr_conn_req.pu8ssid);
1603 hif_drv->usr_conn_req.pu8ssid = NULL;
1604 kfree(hif_drv->usr_conn_req.pu8bssid);
1605 hif_drv->usr_conn_req.pu8bssid = NULL;
1606 hif_drv->usr_conn_req.ies_len = 0;
1607 kfree(hif_drv->usr_conn_req.ies);
1608 hif_drv->usr_conn_req.ies = NULL;
1609
1610 if (join_req && join_req_vif == vif) {
1611 kfree(join_req);
1612 join_req = NULL;
1613 }
1614
1615 if (info_element && join_req_vif == vif) {
1616 kfree(info_element);
1617 info_element = NULL;
1618 }
1619
1620 hif_drv->hif_state = HOST_IF_IDLE;
1621 scan_while_connected = false;
1622
1623 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
1624 (hif_drv->usr_scan_req.scan_result)) {
1625 del_timer(&hif_drv->scan_timer);
1626 if (hif_drv->usr_scan_req.scan_result)
1627 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
1628 }
1629 }
1630
1631 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1632 pstrRcvdGnrlAsyncInfo->buffer = NULL;
1633
1634 return result;
1635 }
1636
1637 static int Handle_Key(struct wilc_vif *vif,
1638 struct key_attr *pstrHostIFkeyAttr)
1639 {
1640 s32 result = 0;
1641 struct wid wid;
1642 struct wid strWIDList[5];
1643 u8 i;
1644 u8 *pu8keybuf;
1645 s8 s8idxarray[1];
1646 s8 ret = 0;
1647 struct host_if_drv *hif_drv = vif->hif_drv;
1648
1649 switch (pstrHostIFkeyAttr->type) {
1650 case WEP:
1651
1652 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1653 strWIDList[0].id = (u16)WID_11I_MODE;
1654 strWIDList[0].type = WID_CHAR;
1655 strWIDList[0].size = sizeof(char);
1656 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
1657
1658 strWIDList[1].id = WID_AUTH_TYPE;
1659 strWIDList[1].type = WID_CHAR;
1660 strWIDList[1].size = sizeof(char);
1661 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
1662
1663 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2,
1664 GFP_KERNEL);
1665
1666 if (pu8keybuf == NULL) {
1667 PRINT_ER("No buffer to send Key\n");
1668 return -ENOMEM;
1669 }
1670
1671 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1672 pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len;
1673
1674 memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key,
1675 pstrHostIFkeyAttr->attr.wep.key_len);
1676
1677 kfree(pstrHostIFkeyAttr->attr.wep.key);
1678
1679 strWIDList[2].id = (u16)WID_WEP_KEY_VALUE;
1680 strWIDList[2].type = WID_STR;
1681 strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1682 strWIDList[2].val = (s8 *)pu8keybuf;
1683
1684 result = wilc_send_config_pkt(vif, SET_CFG,
1685 strWIDList, 3,
1686 wilc_get_vif_idx(vif));
1687 kfree(pu8keybuf);
1688 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1689 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
1690 if (!pu8keybuf) {
1691 PRINT_ER("No buffer to send Key\n");
1692 return -ENOMEM;
1693 }
1694 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1695 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1696 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1697 pstrHostIFkeyAttr->attr.wep.key_len);
1698 kfree(pstrHostIFkeyAttr->attr.wep.key);
1699
1700 wid.id = (u16)WID_ADD_WEP_KEY;
1701 wid.type = WID_STR;
1702 wid.val = (s8 *)pu8keybuf;
1703 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
1704
1705 result = wilc_send_config_pkt(vif, SET_CFG,
1706 &wid, 1,
1707 wilc_get_vif_idx(vif));
1708 kfree(pu8keybuf);
1709 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
1710 wid.id = (u16)WID_REMOVE_WEP_KEY;
1711 wid.type = WID_STR;
1712
1713 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
1714 wid.val = s8idxarray;
1715 wid.size = 1;
1716
1717 result = wilc_send_config_pkt(vif, SET_CFG,
1718 &wid, 1,
1719 wilc_get_vif_idx(vif));
1720 } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) {
1721 wid.id = (u16)WID_KEY_ID;
1722 wid.type = WID_CHAR;
1723 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1724 wid.size = sizeof(char);
1725
1726 result = wilc_send_config_pkt(vif, SET_CFG,
1727 &wid, 1,
1728 wilc_get_vif_idx(vif));
1729 }
1730 up(&hif_drv->sem_test_key_block);
1731 break;
1732
1733 case WPA_RX_GTK:
1734 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1735 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1736 if (!pu8keybuf) {
1737 PRINT_ER("No buffer to send RxGTK Key\n");
1738 ret = -ENOMEM;
1739 goto _WPARxGtk_end_case_;
1740 }
1741
1742 if (pstrHostIFkeyAttr->attr.wpa.seq)
1743 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1744
1745 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1746 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1747 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1748 pstrHostIFkeyAttr->attr.wpa.key_len);
1749
1750 strWIDList[0].id = (u16)WID_11I_MODE;
1751 strWIDList[0].type = WID_CHAR;
1752 strWIDList[0].size = sizeof(char);
1753 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1754
1755 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
1756 strWIDList[1].type = WID_STR;
1757 strWIDList[1].val = (s8 *)pu8keybuf;
1758 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
1759
1760 result = wilc_send_config_pkt(vif, SET_CFG,
1761 strWIDList, 2,
1762 wilc_get_vif_idx(vif));
1763
1764 kfree(pu8keybuf);
1765 up(&hif_drv->sem_test_key_block);
1766 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1767 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
1768 if (pu8keybuf == NULL) {
1769 PRINT_ER("No buffer to send RxGTK Key\n");
1770 ret = -ENOMEM;
1771 goto _WPARxGtk_end_case_;
1772 }
1773
1774 if (hif_drv->hif_state == HOST_IF_CONNECTED)
1775 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
1776 else
1777 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
1778
1779 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
1780 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1781 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1782 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
1783 pstrHostIFkeyAttr->attr.wpa.key_len);
1784
1785 wid.id = (u16)WID_ADD_RX_GTK;
1786 wid.type = WID_STR;
1787 wid.val = (s8 *)pu8keybuf;
1788 wid.size = RX_MIC_KEY_MSG_LEN;
1789
1790 result = wilc_send_config_pkt(vif, SET_CFG,
1791 &wid, 1,
1792 wilc_get_vif_idx(vif));
1793
1794 kfree(pu8keybuf);
1795 up(&hif_drv->sem_test_key_block);
1796 }
1797 _WPARxGtk_end_case_:
1798 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1799 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
1800 if (ret)
1801 return ret;
1802
1803 break;
1804
1805 case WPA_PTK:
1806 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
1807 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
1808 if (!pu8keybuf) {
1809 PRINT_ER("No buffer to send PTK Key\n");
1810 ret = -ENOMEM;
1811 goto _WPAPtk_end_case_;
1812 }
1813
1814 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1815 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
1816 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1817 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
1818 pstrHostIFkeyAttr->attr.wpa.key_len);
1819
1820 strWIDList[0].id = (u16)WID_11I_MODE;
1821 strWIDList[0].type = WID_CHAR;
1822 strWIDList[0].size = sizeof(char);
1823 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
1824
1825 strWIDList[1].id = (u16)WID_ADD_PTK;
1826 strWIDList[1].type = WID_STR;
1827 strWIDList[1].val = (s8 *)pu8keybuf;
1828 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
1829
1830 result = wilc_send_config_pkt(vif, SET_CFG,
1831 strWIDList, 2,
1832 wilc_get_vif_idx(vif));
1833 kfree(pu8keybuf);
1834 up(&hif_drv->sem_test_key_block);
1835 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
1836 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
1837 if (!pu8keybuf) {
1838 PRINT_ER("No buffer to send PTK Key\n");
1839 ret = -ENOMEM;
1840 goto _WPAPtk_end_case_;
1841 }
1842
1843 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
1844 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
1845 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
1846 pstrHostIFkeyAttr->attr.wpa.key_len);
1847
1848 wid.id = (u16)WID_ADD_PTK;
1849 wid.type = WID_STR;
1850 wid.val = (s8 *)pu8keybuf;
1851 wid.size = PTK_KEY_MSG_LEN;
1852
1853 result = wilc_send_config_pkt(vif, SET_CFG,
1854 &wid, 1,
1855 wilc_get_vif_idx(vif));
1856 kfree(pu8keybuf);
1857 up(&hif_drv->sem_test_key_block);
1858 }
1859
1860 _WPAPtk_end_case_:
1861 kfree(pstrHostIFkeyAttr->attr.wpa.key);
1862 if (ret)
1863 return ret;
1864
1865 break;
1866
1867 case PMKSA:
1868 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
1869 if (!pu8keybuf) {
1870 PRINT_ER("No buffer to send PMKSA Key\n");
1871 return -ENOMEM;
1872 }
1873
1874 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
1875
1876 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1877 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1878 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
1879 }
1880
1881 wid.id = (u16)WID_PMKID_INFO;
1882 wid.type = WID_STR;
1883 wid.val = (s8 *)pu8keybuf;
1884 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
1885
1886 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1887 wilc_get_vif_idx(vif));
1888
1889 kfree(pu8keybuf);
1890 break;
1891 }
1892
1893 if (result)
1894 PRINT_ER("Failed to send key config packet\n");
1895
1896 return result;
1897 }
1898
1899 static void Handle_Disconnect(struct wilc_vif *vif)
1900 {
1901 struct wid wid;
1902 struct host_if_drv *hif_drv = vif->hif_drv;
1903
1904 s32 result = 0;
1905 u16 u16DummyReasonCode = 0;
1906
1907 wid.id = (u16)WID_DISCONNECT;
1908 wid.type = WID_CHAR;
1909 wid.val = (s8 *)&u16DummyReasonCode;
1910 wid.size = sizeof(char);
1911
1912 wilc_optaining_ip = false;
1913 wilc_set_power_mgmt(vif, 0, 0);
1914
1915 eth_zero_addr(wilc_connected_ssid);
1916
1917 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
1918 wilc_get_vif_idx(vif));
1919
1920 if (result) {
1921 PRINT_ER("Failed to send dissconect config packet\n");
1922 } else {
1923 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1924
1925 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
1926
1927 strDisconnectNotifInfo.u16reason = 0;
1928 strDisconnectNotifInfo.ie = NULL;
1929 strDisconnectNotifInfo.ie_len = 0;
1930
1931 if (hif_drv->usr_scan_req.scan_result) {
1932 del_timer(&hif_drv->scan_timer);
1933 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
1934 NULL,
1935 hif_drv->usr_scan_req.arg,
1936 NULL);
1937 hif_drv->usr_scan_req.scan_result = NULL;
1938 }
1939
1940 if (hif_drv->usr_conn_req.conn_result) {
1941 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP)
1942 del_timer(&hif_drv->connect_timer);
1943
1944 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1945 NULL,
1946 0,
1947 &strDisconnectNotifInfo,
1948 hif_drv->usr_conn_req.arg);
1949 } else {
1950 PRINT_ER("usr_conn_req.conn_result = NULL\n");
1951 }
1952
1953 scan_while_connected = false;
1954
1955 hif_drv->hif_state = HOST_IF_IDLE;
1956
1957 eth_zero_addr(hif_drv->assoc_bssid);
1958
1959 hif_drv->usr_conn_req.ssid_len = 0;
1960 kfree(hif_drv->usr_conn_req.pu8ssid);
1961 hif_drv->usr_conn_req.pu8ssid = NULL;
1962 kfree(hif_drv->usr_conn_req.pu8bssid);
1963 hif_drv->usr_conn_req.pu8bssid = NULL;
1964 hif_drv->usr_conn_req.ies_len = 0;
1965 kfree(hif_drv->usr_conn_req.ies);
1966 hif_drv->usr_conn_req.ies = NULL;
1967
1968 if (join_req && join_req_vif == vif) {
1969 kfree(join_req);
1970 join_req = NULL;
1971 }
1972
1973 if (info_element && join_req_vif == vif) {
1974 kfree(info_element);
1975 info_element = NULL;
1976 }
1977 }
1978
1979 up(&hif_drv->sem_test_disconn_block);
1980 }
1981
1982 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
1983 {
1984 if (!vif->hif_drv)
1985 return;
1986 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1987 (vif->hif_drv->hif_state == HOST_IF_CONNECTING))
1988 wilc_disconnect(vif, 1);
1989 }
1990
1991 static s32 Handle_GetChnl(struct wilc_vif *vif)
1992 {
1993 s32 result = 0;
1994 struct wid wid;
1995 struct host_if_drv *hif_drv = vif->hif_drv;
1996
1997 wid.id = (u16)WID_CURRENT_CHANNEL;
1998 wid.type = WID_CHAR;
1999 wid.val = (s8 *)&ch_no;
2000 wid.size = sizeof(char);
2001
2002 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2003 wilc_get_vif_idx(vif));
2004
2005 if (result) {
2006 PRINT_ER("Failed to get channel number\n");
2007 result = -EFAULT;
2008 }
2009
2010 up(&hif_drv->sem_get_chnl);
2011
2012 return result;
2013 }
2014
2015 static void Handle_GetRssi(struct wilc_vif *vif)
2016 {
2017 s32 result = 0;
2018 struct wid wid;
2019
2020 wid.id = (u16)WID_RSSI;
2021 wid.type = WID_CHAR;
2022 wid.val = &rssi;
2023 wid.size = sizeof(char);
2024
2025 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2026 wilc_get_vif_idx(vif));
2027 if (result) {
2028 PRINT_ER("Failed to get RSSI value\n");
2029 result = -EFAULT;
2030 }
2031
2032 up(&vif->hif_drv->sem_get_rssi);
2033 }
2034
2035 static void Handle_GetLinkspeed(struct wilc_vif *vif)
2036 {
2037 s32 result = 0;
2038 struct wid wid;
2039 struct host_if_drv *hif_drv = vif->hif_drv;
2040
2041 link_speed = 0;
2042
2043 wid.id = (u16)WID_LINKSPEED;
2044 wid.type = WID_CHAR;
2045 wid.val = &link_speed;
2046 wid.size = sizeof(char);
2047
2048 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2049 wilc_get_vif_idx(vif));
2050 if (result) {
2051 PRINT_ER("Failed to get LINKSPEED value\n");
2052 result = -EFAULT;
2053 }
2054
2055 up(&hif_drv->sem_get_link_speed);
2056 }
2057
2058 static s32 Handle_GetStatistics(struct wilc_vif *vif,
2059 struct rf_info *pstrStatistics)
2060 {
2061 struct wid strWIDList[5];
2062 u32 u32WidsCount = 0, result = 0;
2063
2064 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2065 strWIDList[u32WidsCount].type = WID_CHAR;
2066 strWIDList[u32WidsCount].size = sizeof(char);
2067 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
2068 u32WidsCount++;
2069
2070 strWIDList[u32WidsCount].id = WID_RSSI;
2071 strWIDList[u32WidsCount].type = WID_CHAR;
2072 strWIDList[u32WidsCount].size = sizeof(char);
2073 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
2074 u32WidsCount++;
2075
2076 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2077 strWIDList[u32WidsCount].type = WID_INT;
2078 strWIDList[u32WidsCount].size = sizeof(u32);
2079 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
2080 u32WidsCount++;
2081
2082 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
2083 strWIDList[u32WidsCount].type = WID_INT;
2084 strWIDList[u32WidsCount].size = sizeof(u32);
2085 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
2086 u32WidsCount++;
2087
2088 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
2089 strWIDList[u32WidsCount].type = WID_INT;
2090 strWIDList[u32WidsCount].size = sizeof(u32);
2091 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
2092 u32WidsCount++;
2093
2094 result = wilc_send_config_pkt(vif, GET_CFG, strWIDList,
2095 u32WidsCount,
2096 wilc_get_vif_idx(vif));
2097
2098 if (result)
2099 PRINT_ER("Failed to send scan paramters config packet\n");
2100
2101 if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH &&
2102 pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2103 wilc_enable_tcp_ack_filter(true);
2104 else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED)
2105 wilc_enable_tcp_ack_filter(false);
2106
2107 if (pstrStatistics != &vif->wilc->dummy_statistics)
2108 up(&hif_sema_wait_response);
2109 return 0;
2110 }
2111
2112 static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
2113 struct sta_inactive_t *strHostIfStaInactiveT)
2114 {
2115 s32 result = 0;
2116 u8 *stamac;
2117 struct wid wid;
2118 struct host_if_drv *hif_drv = vif->hif_drv;
2119
2120 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2121 wid.type = WID_STR;
2122 wid.size = ETH_ALEN;
2123 wid.val = kmalloc(wid.size, GFP_KERNEL);
2124
2125 stamac = wid.val;
2126 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
2127
2128 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2129
2130 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2131 wilc_get_vif_idx(vif));
2132
2133 if (result) {
2134 PRINT_ER("Failed to SET incative time\n");
2135 return -EFAULT;
2136 }
2137
2138 wid.id = (u16)WID_GET_INACTIVE_TIME;
2139 wid.type = WID_INT;
2140 wid.val = (s8 *)&inactive_time;
2141 wid.size = sizeof(u32);
2142
2143 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2144 wilc_get_vif_idx(vif));
2145
2146 if (result) {
2147 PRINT_ER("Failed to get incative time\n");
2148 return -EFAULT;
2149 }
2150
2151 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
2152
2153 up(&hif_drv->sem_inactive_time);
2154
2155 return result;
2156 }
2157
2158 static void Handle_AddBeacon(struct wilc_vif *vif,
2159 struct beacon_attr *pstrSetBeaconParam)
2160 {
2161 s32 result = 0;
2162 struct wid wid;
2163 u8 *pu8CurrByte;
2164
2165 wid.id = (u16)WID_ADD_BEACON;
2166 wid.type = WID_BIN;
2167 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2168 wid.val = kmalloc(wid.size, GFP_KERNEL);
2169 if (!wid.val)
2170 goto ERRORHANDLER;
2171
2172 pu8CurrByte = wid.val;
2173 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2174 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2175 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2176 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
2177
2178 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2179 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2180 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2181 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
2182
2183 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2184 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2185 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2186 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
2187
2188 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
2189 pu8CurrByte += pstrSetBeaconParam->head_len;
2190
2191 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2192 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2193 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2194 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
2195
2196 if (pstrSetBeaconParam->tail)
2197 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
2198 pu8CurrByte += pstrSetBeaconParam->tail_len;
2199
2200 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2201 wilc_get_vif_idx(vif));
2202 if (result)
2203 PRINT_ER("Failed to send add beacon config packet\n");
2204
2205 ERRORHANDLER:
2206 kfree(wid.val);
2207 kfree(pstrSetBeaconParam->head);
2208 kfree(pstrSetBeaconParam->tail);
2209 }
2210
2211 static void Handle_DelBeacon(struct wilc_vif *vif)
2212 {
2213 s32 result = 0;
2214 struct wid wid;
2215 u8 *pu8CurrByte;
2216
2217 wid.id = (u16)WID_DEL_BEACON;
2218 wid.type = WID_CHAR;
2219 wid.size = sizeof(char);
2220 wid.val = &del_beacon;
2221
2222 if (!wid.val)
2223 return;
2224
2225 pu8CurrByte = wid.val;
2226
2227 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2228 wilc_get_vif_idx(vif));
2229 if (result)
2230 PRINT_ER("Failed to send delete beacon config packet\n");
2231 }
2232
2233 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2234 struct add_sta_param *pstrStationParam)
2235 {
2236 u8 *pu8CurrByte;
2237
2238 pu8CurrByte = pu8Buffer;
2239
2240 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
2241 pu8CurrByte += ETH_ALEN;
2242
2243 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2244 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
2245
2246 *pu8CurrByte++ = pstrStationParam->rates_len;
2247 if (pstrStationParam->rates_len > 0)
2248 memcpy(pu8CurrByte, pstrStationParam->rates,
2249 pstrStationParam->rates_len);
2250 pu8CurrByte += pstrStationParam->rates_len;
2251
2252 *pu8CurrByte++ = pstrStationParam->ht_supported;
2253 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2254 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
2255
2256 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
2257 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2258 WILC_SUPP_MCS_SET_SIZE);
2259 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2260
2261 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2262 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
2263
2264 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2265 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2266 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2267 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
2268
2269 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
2270
2271 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2272 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
2273
2274 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2275 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
2276
2277 return pu8CurrByte - pu8Buffer;
2278 }
2279
2280 static void Handle_AddStation(struct wilc_vif *vif,
2281 struct add_sta_param *pstrStationParam)
2282 {
2283 s32 result = 0;
2284 struct wid wid;
2285 u8 *pu8CurrByte;
2286
2287 wid.id = (u16)WID_ADD_STA;
2288 wid.type = WID_BIN;
2289 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2290
2291 wid.val = kmalloc(wid.size, GFP_KERNEL);
2292 if (!wid.val)
2293 goto ERRORHANDLER;
2294
2295 pu8CurrByte = wid.val;
2296 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2297
2298 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2299 wilc_get_vif_idx(vif));
2300 if (result != 0)
2301 PRINT_ER("Failed to send add station config packet\n");
2302
2303 ERRORHANDLER:
2304 kfree(pstrStationParam->rates);
2305 kfree(wid.val);
2306 }
2307
2308 static void Handle_DelAllSta(struct wilc_vif *vif,
2309 struct del_all_sta *pstrDelAllStaParam)
2310 {
2311 s32 result = 0;
2312 struct wid wid;
2313 u8 *pu8CurrByte;
2314 u8 i;
2315 u8 au8Zero_Buff[6] = {0};
2316
2317 wid.id = (u16)WID_DEL_ALL_STA;
2318 wid.type = WID_STR;
2319 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
2320
2321 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2322 if (!wid.val)
2323 goto ERRORHANDLER;
2324
2325 pu8CurrByte = wid.val;
2326
2327 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
2328
2329 for (i = 0; i < MAX_NUM_STA; i++) {
2330 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2331 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
2332 else
2333 continue;
2334
2335 pu8CurrByte += ETH_ALEN;
2336 }
2337
2338 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2339 wilc_get_vif_idx(vif));
2340 if (result)
2341 PRINT_ER("Failed to send add station config packet\n");
2342
2343 ERRORHANDLER:
2344 kfree(wid.val);
2345
2346 up(&hif_sema_wait_response);
2347 }
2348
2349 static void Handle_DelStation(struct wilc_vif *vif,
2350 struct del_sta *pstrDelStaParam)
2351 {
2352 s32 result = 0;
2353 struct wid wid;
2354 u8 *pu8CurrByte;
2355
2356 wid.id = (u16)WID_REMOVE_STA;
2357 wid.type = WID_BIN;
2358 wid.size = ETH_ALEN;
2359
2360 wid.val = kmalloc(wid.size, GFP_KERNEL);
2361 if (!wid.val)
2362 goto ERRORHANDLER;
2363
2364 pu8CurrByte = wid.val;
2365
2366 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
2367
2368 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2369 wilc_get_vif_idx(vif));
2370 if (result)
2371 PRINT_ER("Failed to send add station config packet\n");
2372
2373 ERRORHANDLER:
2374 kfree(wid.val);
2375 }
2376
2377 static void Handle_EditStation(struct wilc_vif *vif,
2378 struct add_sta_param *pstrStationParam)
2379 {
2380 s32 result = 0;
2381 struct wid wid;
2382 u8 *pu8CurrByte;
2383
2384 wid.id = (u16)WID_EDIT_STA;
2385 wid.type = WID_BIN;
2386 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
2387
2388 wid.val = kmalloc(wid.size, GFP_KERNEL);
2389 if (!wid.val)
2390 goto ERRORHANDLER;
2391
2392 pu8CurrByte = wid.val;
2393 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2394
2395 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2396 wilc_get_vif_idx(vif));
2397 if (result)
2398 PRINT_ER("Failed to send edit station config packet\n");
2399
2400 ERRORHANDLER:
2401 kfree(pstrStationParam->rates);
2402 kfree(wid.val);
2403 }
2404
2405 static int Handle_RemainOnChan(struct wilc_vif *vif,
2406 struct remain_ch *pstrHostIfRemainOnChan)
2407 {
2408 s32 result = 0;
2409 u8 u8remain_on_chan_flag;
2410 struct wid wid;
2411 struct host_if_drv *hif_drv = vif->hif_drv;
2412
2413 if (!hif_drv->remain_on_ch_pending) {
2414 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
2415 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
2416 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
2417 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
2418 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
2419 } else {
2420 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
2421 }
2422
2423 if (hif_drv->usr_scan_req.scan_result) {
2424 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
2425 hif_drv->remain_on_ch_pending = 1;
2426 result = -EBUSY;
2427 goto ERRORHANDLER;
2428 }
2429 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
2430 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
2431 result = -EBUSY;
2432 goto ERRORHANDLER;
2433 }
2434
2435 if (wilc_optaining_ip || wilc_connecting) {
2436 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
2437 result = -EBUSY;
2438 goto ERRORHANDLER;
2439 }
2440
2441 u8remain_on_chan_flag = true;
2442 wid.id = (u16)WID_REMAIN_ON_CHAN;
2443 wid.type = WID_STR;
2444 wid.size = 2;
2445 wid.val = kmalloc(wid.size, GFP_KERNEL);
2446 if (!wid.val) {
2447 result = -ENOMEM;
2448 goto ERRORHANDLER;
2449 }
2450
2451 wid.val[0] = u8remain_on_chan_flag;
2452 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
2453
2454 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2455 wilc_get_vif_idx(vif));
2456 if (result != 0)
2457 PRINT_ER("Failed to set remain on channel\n");
2458
2459 ERRORHANDLER:
2460 {
2461 P2P_LISTEN_STATE = 1;
2462 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
2463 mod_timer(&hif_drv->remain_on_ch_timer,
2464 jiffies +
2465 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
2466
2467 if (hif_drv->remain_on_ch.ready)
2468 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
2469
2470 if (hif_drv->remain_on_ch_pending)
2471 hif_drv->remain_on_ch_pending = 0;
2472 }
2473
2474 return result;
2475 }
2476
2477 static int Handle_RegisterFrame(struct wilc_vif *vif,
2478 struct reg_frame *pstrHostIfRegisterFrame)
2479 {
2480 s32 result = 0;
2481 struct wid wid;
2482 u8 *pu8CurrByte;
2483
2484 wid.id = (u16)WID_REGISTER_FRAME;
2485 wid.type = WID_STR;
2486 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2487 if (!wid.val)
2488 return -ENOMEM;
2489
2490 pu8CurrByte = wid.val;
2491
2492 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
2493 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
2494 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
2495
2496 wid.size = sizeof(u16) + 2;
2497
2498 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2499 wilc_get_vif_idx(vif));
2500 if (result) {
2501 PRINT_ER("Failed to frame register config packet\n");
2502 result = -EINVAL;
2503 }
2504
2505 return result;
2506 }
2507
2508 static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
2509 struct remain_ch *pstrHostIfRemainOnChan)
2510 {
2511 u8 u8remain_on_chan_flag;
2512 struct wid wid;
2513 s32 result = 0;
2514 struct host_if_drv *hif_drv = vif->hif_drv;
2515
2516 if (P2P_LISTEN_STATE) {
2517 u8remain_on_chan_flag = false;
2518 wid.id = (u16)WID_REMAIN_ON_CHAN;
2519 wid.type = WID_STR;
2520 wid.size = 2;
2521 wid.val = kmalloc(wid.size, GFP_KERNEL);
2522
2523 if (!wid.val) {
2524 PRINT_ER("Failed to allocate memory\n");
2525 return -ENOMEM;
2526 }
2527
2528 wid.val[0] = u8remain_on_chan_flag;
2529 wid.val[1] = FALSE_FRMWR_CHANNEL;
2530
2531 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2532 wilc_get_vif_idx(vif));
2533 if (result != 0) {
2534 PRINT_ER("Failed to set remain on channel\n");
2535 goto _done_;
2536 }
2537
2538 if (hif_drv->remain_on_ch.expired) {
2539 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
2540 pstrHostIfRemainOnChan->id);
2541 }
2542 P2P_LISTEN_STATE = 0;
2543 } else {
2544 PRINT_D(GENERIC_DBG, "Not in listen state\n");
2545 result = -EFAULT;
2546 }
2547
2548 _done_:
2549 return result;
2550 }
2551
2552 static void ListenTimerCB(unsigned long arg)
2553 {
2554 s32 result = 0;
2555 struct host_if_msg msg;
2556 struct wilc_vif *vif = (struct wilc_vif *)arg;
2557
2558 del_timer(&vif->hif_drv->remain_on_ch_timer);
2559
2560 memset(&msg, 0, sizeof(struct host_if_msg));
2561 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
2562 msg.vif = vif;
2563 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
2564
2565 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2566 if (result)
2567 PRINT_ER("wilc_mq_send fail\n");
2568 }
2569
2570 static void Handle_PowerManagement(struct wilc_vif *vif,
2571 struct power_mgmt_param *strPowerMgmtParam)
2572 {
2573 s32 result = 0;
2574 struct wid wid;
2575 s8 s8PowerMode;
2576
2577 wid.id = (u16)WID_POWER_MANAGEMENT;
2578
2579 if (strPowerMgmtParam->enabled)
2580 s8PowerMode = MIN_FAST_PS;
2581 else
2582 s8PowerMode = NO_POWERSAVE;
2583
2584 wid.val = &s8PowerMode;
2585 wid.size = sizeof(char);
2586
2587 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2588 wilc_get_vif_idx(vif));
2589 if (result)
2590 PRINT_ER("Failed to send power management config packet\n");
2591 }
2592
2593 static void Handle_SetMulticastFilter(struct wilc_vif *vif,
2594 struct set_multicast *strHostIfSetMulti)
2595 {
2596 s32 result = 0;
2597 struct wid wid;
2598 u8 *pu8CurrByte;
2599
2600 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2601 wid.type = WID_BIN;
2602 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2603 wid.val = kmalloc(wid.size, GFP_KERNEL);
2604 if (!wid.val)
2605 goto ERRORHANDLER;
2606
2607 pu8CurrByte = wid.val;
2608 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2609 *pu8CurrByte++ = 0;
2610 *pu8CurrByte++ = 0;
2611 *pu8CurrByte++ = 0;
2612
2613 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2614 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2615 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2616 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
2617
2618 if ((strHostIfSetMulti->cnt) > 0)
2619 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
2620 ((strHostIfSetMulti->cnt) * ETH_ALEN));
2621
2622 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2623 wilc_get_vif_idx(vif));
2624 if (result)
2625 PRINT_ER("Failed to send setup multicast config packet\n");
2626
2627 ERRORHANDLER:
2628 kfree(wid.val);
2629 }
2630
2631 static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
2632 struct ba_session_info *strHostIfBASessionInfo)
2633 {
2634 s32 result = 0;
2635 struct wid wid;
2636 char *ptr = NULL;
2637
2638 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
2639 strHostIfBASessionInfo->bssid[0],
2640 strHostIfBASessionInfo->bssid[1],
2641 strHostIfBASessionInfo->bssid[2],
2642 strHostIfBASessionInfo->tid);
2643
2644 wid.id = (u16)WID_DEL_ALL_RX_BA;
2645 wid.type = WID_STR;
2646 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2647 wid.size = BLOCK_ACK_REQ_SIZE;
2648 ptr = wid.val;
2649 *ptr++ = 0x14;
2650 *ptr++ = 0x3;
2651 *ptr++ = 0x2;
2652 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
2653 ptr += ETH_ALEN;
2654 *ptr++ = strHostIfBASessionInfo->tid;
2655 *ptr++ = 0;
2656 *ptr++ = 32;
2657
2658 result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2659 wilc_get_vif_idx(vif));
2660
2661 kfree(wid.val);
2662
2663 up(&hif_sema_wait_response);
2664
2665 return result;
2666 }
2667
2668 static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr)
2669 {
2670 int ret;
2671 struct wid wid;
2672
2673 wid.id = (u16)WID_TX_POWER;
2674 wid.type = WID_CHAR;
2675 wid.val = &tx_pwr;
2676 wid.size = sizeof(char);
2677
2678 ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
2679 wilc_get_vif_idx(vif));
2680 if (ret)
2681 netdev_err(vif->ndev, "Failed to set TX PWR\n");
2682 }
2683
2684 static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr)
2685 {
2686 s32 ret = 0;
2687 struct wid wid;
2688
2689 wid.id = (u16)WID_TX_POWER;
2690 wid.type = WID_CHAR;
2691 wid.val = (s8 *)tx_pwr;
2692 wid.size = sizeof(char);
2693
2694 ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
2695 wilc_get_vif_idx(vif));
2696 if (ret)
2697 netdev_err(vif->ndev, "Failed to get TX PWR\n");
2698
2699 up(&hif_sema_wait_response);
2700 }
2701
2702 static int hostIFthread(void *pvArg)
2703 {
2704 u32 u32Ret;
2705 struct host_if_msg msg;
2706 struct wilc *wilc = (struct wilc*)pvArg;
2707 struct wilc_vif *vif;
2708
2709 memset(&msg, 0, sizeof(struct host_if_msg));
2710
2711 while (1) {
2712 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
2713 vif = msg.vif;
2714 if (msg.id == HOST_IF_MSG_EXIT) {
2715 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2716 break;
2717 }
2718
2719 if ((!wilc_initialized)) {
2720 PRINT_D(GENERIC_DBG, "--WAIT--");
2721 usleep_range(200 * 1000, 200 * 1000);
2722 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2723 continue;
2724 }
2725
2726 if (msg.id == HOST_IF_MSG_CONNECT &&
2727 vif->hif_drv->usr_scan_req.scan_result) {
2728 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2729 usleep_range(2 * 1000, 2 * 1000);
2730 continue;
2731 }
2732
2733 switch (msg.id) {
2734 case HOST_IF_MSG_Q_IDLE:
2735 Handle_wait_msg_q_empty();
2736 break;
2737
2738 case HOST_IF_MSG_SCAN:
2739 Handle_Scan(msg.vif, &msg.body.scan_info);
2740 break;
2741
2742 case HOST_IF_MSG_CONNECT:
2743 Handle_Connect(msg.vif, &msg.body.con_info);
2744 break;
2745
2746 case HOST_IF_MSG_FLUSH_CONNECT:
2747 Handle_FlushConnect(msg.vif);
2748 break;
2749
2750 case HOST_IF_MSG_RCVD_NTWRK_INFO:
2751 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
2752 break;
2753
2754 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
2755 Handle_RcvdGnrlAsyncInfo(vif,
2756 &msg.body.async_info);
2757 break;
2758
2759 case HOST_IF_MSG_KEY:
2760 Handle_Key(msg.vif, &msg.body.key_info);
2761 break;
2762
2763 case HOST_IF_MSG_CFG_PARAMS:
2764 handle_cfg_param(msg.vif, &msg.body.cfg_info);
2765 break;
2766
2767 case HOST_IF_MSG_SET_CHANNEL:
2768 handle_set_channel(msg.vif, &msg.body.channel_info);
2769 break;
2770
2771 case HOST_IF_MSG_DISCONNECT:
2772 Handle_Disconnect(msg.vif);
2773 break;
2774
2775 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
2776 del_timer(&vif->hif_drv->scan_timer);
2777
2778 if (!wilc_wlan_get_num_conn_ifcs(wilc))
2779 wilc_chip_sleep_manually(wilc);
2780
2781 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
2782
2783 if (vif->hif_drv->remain_on_ch_pending)
2784 Handle_RemainOnChan(msg.vif,
2785 &msg.body.remain_on_ch);
2786
2787 break;
2788
2789 case HOST_IF_MSG_GET_RSSI:
2790 Handle_GetRssi(msg.vif);
2791 break;
2792
2793 case HOST_IF_MSG_GET_LINKSPEED:
2794 Handle_GetLinkspeed(msg.vif);
2795 break;
2796
2797 case HOST_IF_MSG_GET_STATISTICS:
2798 Handle_GetStatistics(msg.vif,
2799 (struct rf_info *)msg.body.data);
2800 break;
2801
2802 case HOST_IF_MSG_GET_CHNL:
2803 Handle_GetChnl(msg.vif);
2804 break;
2805
2806 case HOST_IF_MSG_ADD_BEACON:
2807 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
2808 break;
2809
2810 case HOST_IF_MSG_DEL_BEACON:
2811 Handle_DelBeacon(msg.vif);
2812 break;
2813
2814 case HOST_IF_MSG_ADD_STATION:
2815 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
2816 break;
2817
2818 case HOST_IF_MSG_DEL_STATION:
2819 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
2820 break;
2821
2822 case HOST_IF_MSG_EDIT_STATION:
2823 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
2824 break;
2825
2826 case HOST_IF_MSG_GET_INACTIVETIME:
2827 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
2828 break;
2829
2830 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2831
2832 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
2833 break;
2834
2835 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
2836 Handle_ConnectTimeout(msg.vif);
2837 break;
2838
2839 case HOST_IF_MSG_POWER_MGMT:
2840 Handle_PowerManagement(msg.vif,
2841 &msg.body.pwr_mgmt_info);
2842 break;
2843
2844 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
2845 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
2846 break;
2847
2848 case HOST_IF_MSG_SET_OPERATION_MODE:
2849 handle_set_operation_mode(msg.vif, &msg.body.mode);
2850 break;
2851
2852 case HOST_IF_MSG_SET_IPADDRESS:
2853 handle_set_ip_address(vif,
2854 msg.body.ip_info.ip_addr,
2855 msg.body.ip_info.idx);
2856 break;
2857
2858 case HOST_IF_MSG_GET_IPADDRESS:
2859 handle_get_ip_address(vif, msg.body.ip_info.idx);
2860 break;
2861
2862 case HOST_IF_MSG_SET_MAC_ADDRESS:
2863 handle_set_mac_address(msg.vif,
2864 &msg.body.set_mac_info);
2865 break;
2866
2867 case HOST_IF_MSG_GET_MAC_ADDRESS:
2868 handle_get_mac_address(msg.vif,
2869 &msg.body.get_mac_info);
2870 break;
2871
2872 case HOST_IF_MSG_REMAIN_ON_CHAN:
2873 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
2874 break;
2875
2876 case HOST_IF_MSG_REGISTER_FRAME:
2877 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
2878 break;
2879
2880 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
2881 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
2882 break;
2883
2884 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2885 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
2886 break;
2887
2888 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
2889 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
2890 break;
2891
2892 case HOST_IF_MSG_DEL_ALL_STA:
2893 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
2894 break;
2895
2896 case HOST_IF_MSG_SET_TX_POWER:
2897 handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr);
2898 break;
2899
2900 case HOST_IF_MSG_GET_TX_POWER:
2901 handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr);
2902 break;
2903 default:
2904 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
2905 break;
2906 }
2907 }
2908
2909 up(&hif_sema_thread);
2910 return 0;
2911 }
2912
2913 static void TimerCB_Scan(unsigned long arg)
2914 {
2915 struct wilc_vif *vif = (struct wilc_vif *)arg;
2916 struct host_if_msg msg;
2917
2918 memset(&msg, 0, sizeof(struct host_if_msg));
2919 msg.vif = vif;
2920 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
2921
2922 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2923 }
2924
2925 static void TimerCB_Connect(unsigned long arg)
2926 {
2927 struct wilc_vif *vif = (struct wilc_vif *)arg;
2928 struct host_if_msg msg;
2929
2930 memset(&msg, 0, sizeof(struct host_if_msg));
2931 msg.vif = vif;
2932 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
2933
2934 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2935 }
2936
2937 s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
2938 {
2939 struct wid wid;
2940
2941 wid.id = (u16)WID_REMOVE_KEY;
2942 wid.type = WID_STR;
2943 wid.val = (s8 *)pu8StaAddress;
2944 wid.size = 6;
2945
2946 return 0;
2947 }
2948
2949 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
2950 {
2951 int result = 0;
2952 struct host_if_msg msg;
2953 struct host_if_drv *hif_drv = vif->hif_drv;
2954
2955 if (!hif_drv) {
2956 result = -EFAULT;
2957 PRINT_ER("Failed to send setup multicast config packet\n");
2958 return result;
2959 }
2960
2961 memset(&msg, 0, sizeof(struct host_if_msg));
2962
2963 msg.id = HOST_IF_MSG_KEY;
2964 msg.body.key_info.type = WEP;
2965 msg.body.key_info.action = REMOVEKEY;
2966 msg.vif = vif;
2967 msg.body.key_info.attr.wep.index = index;
2968
2969 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2970 if (result)
2971 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
2972 down(&hif_drv->sem_test_key_block);
2973
2974 return result;
2975 }
2976
2977 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
2978 {
2979 int result = 0;
2980 struct host_if_msg msg;
2981 struct host_if_drv *hif_drv = vif->hif_drv;
2982
2983 if (!hif_drv) {
2984 result = -EFAULT;
2985 PRINT_ER("driver is null\n");
2986 return result;
2987 }
2988
2989 memset(&msg, 0, sizeof(struct host_if_msg));
2990
2991 msg.id = HOST_IF_MSG_KEY;
2992 msg.body.key_info.type = WEP;
2993 msg.body.key_info.action = DEFAULTKEY;
2994 msg.vif = vif;
2995 msg.body.key_info.attr.wep.index = index;
2996
2997 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2998 if (result)
2999 PRINT_ER("Error in sending message queue : Default key index\n");
3000 down(&hif_drv->sem_test_key_block);
3001
3002 return result;
3003 }
3004
3005 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
3006 u8 index)
3007 {
3008 int result = 0;
3009 struct host_if_msg msg;
3010 struct host_if_drv *hif_drv = vif->hif_drv;
3011
3012 if (!hif_drv) {
3013 PRINT_ER("driver is null\n");
3014 return -EFAULT;
3015 }
3016
3017 memset(&msg, 0, sizeof(struct host_if_msg));
3018
3019 msg.id = HOST_IF_MSG_KEY;
3020 msg.body.key_info.type = WEP;
3021 msg.body.key_info.action = ADDKEY;
3022 msg.vif = vif;
3023 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3024 if (!msg.body.key_info.attr.wep.key)
3025 return -ENOMEM;
3026
3027 msg.body.key_info.attr.wep.key_len = len;
3028 msg.body.key_info.attr.wep.index = index;
3029
3030 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3031 if (result)
3032 PRINT_ER("Error in sending message queue :WEP Key\n");
3033 down(&hif_drv->sem_test_key_block);
3034
3035 return result;
3036 }
3037
3038 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
3039 u8 index, u8 mode, enum AUTHTYPE auth_type)
3040 {
3041 int result = 0;
3042 struct host_if_msg msg;
3043 struct host_if_drv *hif_drv = vif->hif_drv;
3044 int i;
3045
3046 if (!hif_drv) {
3047 PRINT_ER("driver is null\n");
3048 return -EFAULT;
3049 }
3050
3051 memset(&msg, 0, sizeof(struct host_if_msg));
3052
3053 if (INFO) {
3054 for (i = 0; i < len; i++)
3055 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
3056 }
3057 msg.id = HOST_IF_MSG_KEY;
3058 msg.body.key_info.type = WEP;
3059 msg.body.key_info.action = ADDKEY_AP;
3060 msg.vif = vif;
3061 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3062 if (!msg.body.key_info.attr.wep.key)
3063 return -ENOMEM;
3064
3065 msg.body.key_info.attr.wep.key_len = len;
3066 msg.body.key_info.attr.wep.index = index;
3067 msg.body.key_info.attr.wep.mode = mode;
3068 msg.body.key_info.attr.wep.auth_type = auth_type;
3069
3070 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3071
3072 if (result)
3073 PRINT_ER("Error in sending message queue :WEP Key\n");
3074 down(&hif_drv->sem_test_key_block);
3075
3076 return result;
3077 }
3078
3079 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3080 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3081 u8 mode, u8 cipher_mode, u8 index)
3082 {
3083 int result = 0;
3084 struct host_if_msg msg;
3085 struct host_if_drv *hif_drv = vif->hif_drv;
3086 u8 key_len = ptk_key_len;
3087 int i;
3088
3089 if (!hif_drv) {
3090 PRINT_ER("driver is null\n");
3091 return -EFAULT;
3092 }
3093
3094 if (rx_mic)
3095 key_len += RX_MIC_KEY_LEN;
3096
3097 if (tx_mic)
3098 key_len += TX_MIC_KEY_LEN;
3099
3100 memset(&msg, 0, sizeof(struct host_if_msg));
3101
3102 msg.id = HOST_IF_MSG_KEY;
3103 msg.body.key_info.type = WPA_PTK;
3104 if (mode == AP_MODE) {
3105 msg.body.key_info.action = ADDKEY_AP;
3106 msg.body.key_info.attr.wpa.index = index;
3107 }
3108 if (mode == STATION_MODE)
3109 msg.body.key_info.action = ADDKEY;
3110
3111 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3112 if (!msg.body.key_info.attr.wpa.key)
3113 return -ENOMEM;
3114
3115 if (rx_mic) {
3116 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
3117 if (INFO) {
3118 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3119 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
3120 }
3121 }
3122 if (tx_mic) {
3123 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
3124 if (INFO) {
3125 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3126 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
3127 }
3128 }
3129
3130 msg.body.key_info.attr.wpa.key_len = key_len;
3131 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
3132 msg.body.key_info.attr.wpa.mode = cipher_mode;
3133 msg.vif = vif;
3134
3135 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3136
3137 if (result)
3138 PRINT_ER("Error in sending message queue: PTK Key\n");
3139
3140 down(&hif_drv->sem_test_key_block);
3141
3142 return result;
3143 }
3144
3145 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3146 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3147 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3148 u8 cipher_mode)
3149 {
3150 int result = 0;
3151 struct host_if_msg msg;
3152 struct host_if_drv *hif_drv = vif->hif_drv;
3153 u8 key_len = gtk_key_len;
3154
3155 if (!hif_drv) {
3156 PRINT_ER("driver is null\n");
3157 return -EFAULT;
3158 }
3159 memset(&msg, 0, sizeof(struct host_if_msg));
3160
3161 if (rx_mic)
3162 key_len += RX_MIC_KEY_LEN;
3163
3164 if (tx_mic)
3165 key_len += TX_MIC_KEY_LEN;
3166
3167 if (key_rsc) {
3168 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3169 key_rsc_len,
3170 GFP_KERNEL);
3171 if (!msg.body.key_info.attr.wpa.seq)
3172 return -ENOMEM;
3173 }
3174
3175 msg.id = HOST_IF_MSG_KEY;
3176 msg.body.key_info.type = WPA_RX_GTK;
3177 msg.vif = vif;
3178
3179 if (mode == AP_MODE) {
3180 msg.body.key_info.action = ADDKEY_AP;
3181 msg.body.key_info.attr.wpa.mode = cipher_mode;
3182 }
3183 if (mode == STATION_MODE)
3184 msg.body.key_info.action = ADDKEY;
3185
3186 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3187 key_len,
3188 GFP_KERNEL);
3189 if (!msg.body.key_info.attr.wpa.key)
3190 return -ENOMEM;
3191
3192 if (rx_mic)
3193 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
3194 RX_MIC_KEY_LEN);
3195
3196 if (tx_mic)
3197 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
3198 TX_MIC_KEY_LEN);
3199
3200 msg.body.key_info.attr.wpa.index = index;
3201 msg.body.key_info.attr.wpa.key_len = key_len;
3202 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
3203
3204 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3205 if (result)
3206 PRINT_ER("Error in sending message queue: RX GTK\n");
3207
3208 down(&hif_drv->sem_test_key_block);
3209
3210 return result;
3211 }
3212
3213 int wilc_set_pmkid_info(struct wilc_vif *vif,
3214 struct host_if_pmkid_attr *pmkid)
3215 {
3216 int result = 0;
3217 struct host_if_msg msg;
3218 struct host_if_drv *hif_drv = vif->hif_drv;
3219 int i;
3220
3221 if (!hif_drv) {
3222 PRINT_ER("driver is null\n");
3223 return -EFAULT;
3224 }
3225
3226 memset(&msg, 0, sizeof(struct host_if_msg));
3227
3228 msg.id = HOST_IF_MSG_KEY;
3229 msg.body.key_info.type = PMKSA;
3230 msg.body.key_info.action = ADDKEY;
3231 msg.vif = vif;
3232
3233 for (i = 0; i < pmkid->numpmkid; i++) {
3234 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3235 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
3236 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3237 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
3238 }
3239
3240 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3241 if (result)
3242 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3243
3244 return result;
3245 }
3246
3247 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
3248 {
3249 int result = 0;
3250 struct host_if_msg msg;
3251
3252 memset(&msg, 0, sizeof(struct host_if_msg));
3253
3254 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
3255 msg.body.get_mac_info.mac_addr = mac_addr;
3256 msg.vif = vif;
3257
3258 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3259 if (result) {
3260 PRINT_ER("Failed to send get mac address\n");
3261 return -EFAULT;
3262 }
3263
3264 down(&hif_sema_wait_response);
3265 return result;
3266 }
3267
3268 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
3269 size_t ssid_len, const u8 *ies, size_t ies_len,
3270 wilc_connect_result connect_result, void *user_arg,
3271 u8 security, enum AUTHTYPE auth_type,
3272 u8 channel, void *join_params)
3273 {
3274 int result = 0;
3275 struct host_if_msg msg;
3276 struct host_if_drv *hif_drv = vif->hif_drv;
3277
3278 if (!hif_drv || !connect_result) {
3279 PRINT_ER("Driver is null\n");
3280 return -EFAULT;
3281 }
3282
3283 if (!join_params) {
3284 PRINT_ER("Unable to Join - JoinParams is NULL\n");
3285 return -EFAULT;
3286 }
3287
3288 memset(&msg, 0, sizeof(struct host_if_msg));
3289
3290 msg.id = HOST_IF_MSG_CONNECT;
3291
3292 msg.body.con_info.security = security;
3293 msg.body.con_info.auth_type = auth_type;
3294 msg.body.con_info.ch = channel;
3295 msg.body.con_info.result = connect_result;
3296 msg.body.con_info.arg = user_arg;
3297 msg.body.con_info.params = join_params;
3298 msg.vif = vif;
3299
3300 if (bssid) {
3301 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3302 if (!msg.body.con_info.bssid)
3303 return -ENOMEM;
3304 }
3305
3306 if (ssid) {
3307 msg.body.con_info.ssid_len = ssid_len;
3308 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3309 if (!msg.body.con_info.ssid)
3310 return -ENOMEM;
3311 }
3312
3313 if (ies) {
3314 msg.body.con_info.ies_len = ies_len;
3315 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3316 if (!msg.body.con_info.ies)
3317 return -ENOMEM;
3318 }
3319 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3320 hif_drv->hif_state = HOST_IF_CONNECTING;
3321 else
3322 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3323 hif_drv->hif_state);
3324
3325 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3326 if (result) {
3327 PRINT_ER("Failed to send message queue: Set join request\n");
3328 return -EFAULT;
3329 }
3330
3331 hif_drv->connect_timer.data = (unsigned long)vif;
3332 mod_timer(&hif_drv->connect_timer,
3333 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
3334
3335 return result;
3336 }
3337
3338 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
3339 {
3340 int result = 0;
3341 struct host_if_msg msg;
3342 struct host_if_drv *hif_drv = vif->hif_drv;
3343
3344 if (!hif_drv) {
3345 PRINT_ER("Driver is null\n");
3346 return -EFAULT;
3347 }
3348
3349 memset(&msg, 0, sizeof(struct host_if_msg));
3350
3351 msg.id = HOST_IF_MSG_DISCONNECT;
3352 msg.vif = vif;
3353
3354 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3355 if (result)
3356 PRINT_ER("Failed to send message queue: disconnect\n");
3357
3358 down(&hif_drv->sem_test_disconn_block);
3359
3360 return result;
3361 }
3362
3363 static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
3364 u8 *pu8AssocRespInfo,
3365 u32 u32MaxAssocRespInfoLen,
3366 u32 *pu32RcvdAssocRespInfoLen)
3367 {
3368 s32 result = 0;
3369 struct wid wid;
3370 struct host_if_drv *hif_drv = vif->hif_drv;
3371
3372 if (!hif_drv) {
3373 PRINT_ER("Driver is null\n");
3374 return -EFAULT;
3375 }
3376
3377 wid.id = (u16)WID_ASSOC_RES_INFO;
3378 wid.type = WID_STR;
3379 wid.val = pu8AssocRespInfo;
3380 wid.size = u32MaxAssocRespInfoLen;
3381
3382 result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
3383 wilc_get_vif_idx(vif));
3384 if (result) {
3385 *pu32RcvdAssocRespInfoLen = 0;
3386 PRINT_ER("Failed to send association response config packet\n");
3387 return -EINVAL;
3388 } else {
3389 *pu32RcvdAssocRespInfoLen = wid.size;
3390 }
3391
3392 return result;
3393 }
3394
3395 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
3396 {
3397 int result;
3398 struct host_if_msg msg;
3399 struct host_if_drv *hif_drv = vif->hif_drv;
3400
3401 if (!hif_drv) {
3402 PRINT_ER("driver is null\n");
3403 return -EFAULT;
3404 }
3405
3406 memset(&msg, 0, sizeof(struct host_if_msg));
3407 msg.id = HOST_IF_MSG_SET_CHANNEL;
3408 msg.body.channel_info.set_ch = channel;
3409 msg.vif = vif;
3410
3411 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3412 if (result) {
3413 PRINT_ER("wilc mq send fail\n");
3414 return -EINVAL;
3415 }
3416
3417 return 0;
3418 }
3419
3420 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx)
3421 {
3422 int result = 0;
3423 struct host_if_msg msg;
3424
3425 memset(&msg, 0, sizeof(struct host_if_msg));
3426 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
3427 msg.body.drv.handler = index;
3428 msg.body.drv.mac_idx = mac_idx;
3429 msg.vif = vif;
3430
3431 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3432 if (result) {
3433 PRINT_ER("wilc mq send fail\n");
3434 result = -EINVAL;
3435 }
3436
3437 return result;
3438 }
3439
3440 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
3441 {
3442 int result = 0;
3443 struct host_if_msg msg;
3444
3445 memset(&msg, 0, sizeof(struct host_if_msg));
3446 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
3447 msg.body.mode.mode = mode;
3448 msg.vif = vif;
3449
3450 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3451 if (result) {
3452 PRINT_ER("wilc mq send fail\n");
3453 result = -EINVAL;
3454 }
3455
3456 return result;
3457 }
3458
3459 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3460 u32 *pu32InactiveTime)
3461 {
3462 s32 result = 0;
3463 struct host_if_msg msg;
3464 struct host_if_drv *hif_drv = vif->hif_drv;
3465
3466 if (!hif_drv) {
3467 PRINT_ER("driver is null\n");
3468 return -EFAULT;
3469 }
3470
3471 memset(&msg, 0, sizeof(struct host_if_msg));
3472 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
3473
3474 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
3475 msg.vif = vif;
3476
3477 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3478 if (result)
3479 PRINT_ER("Failed to send get host channel param's message queue ");
3480
3481 down(&hif_drv->sem_inactive_time);
3482
3483 *pu32InactiveTime = inactive_time;
3484
3485 return result;
3486 }
3487
3488 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
3489 {
3490 int result = 0;
3491 struct host_if_msg msg;
3492 struct host_if_drv *hif_drv = vif->hif_drv;
3493
3494 memset(&msg, 0, sizeof(struct host_if_msg));
3495 msg.id = HOST_IF_MSG_GET_RSSI;
3496 msg.vif = vif;
3497
3498 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3499 if (result) {
3500 PRINT_ER("Failed to send get host channel param's message queue ");
3501 return -EFAULT;
3502 }
3503
3504 down(&hif_drv->sem_get_rssi);
3505
3506 if (!rssi_level) {
3507 PRINT_ER("RSS pointer value is null");
3508 return -EFAULT;
3509 }
3510
3511 *rssi_level = rssi;
3512
3513 return result;
3514 }
3515
3516 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
3517 {
3518 int result = 0;
3519 struct host_if_msg msg;
3520
3521 memset(&msg, 0, sizeof(struct host_if_msg));
3522 msg.id = HOST_IF_MSG_GET_STATISTICS;
3523 msg.body.data = (char *)stats;
3524 msg.vif = vif;
3525
3526 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3527 if (result) {
3528 PRINT_ER("Failed to send get host channel param's message queue ");
3529 return -EFAULT;
3530 }
3531
3532 if (stats != &vif->wilc->dummy_statistics)
3533 down(&hif_sema_wait_response);
3534 return result;
3535 }
3536
3537 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
3538 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies,
3539 size_t ies_len, wilc_scan_result scan_result, void *user_arg,
3540 struct hidden_network *hidden_network)
3541 {
3542 int result = 0;
3543 struct host_if_msg msg;
3544 struct host_if_drv *hif_drv = vif->hif_drv;
3545
3546 if (!hif_drv || !scan_result) {
3547 PRINT_ER("hif_drv or scan_result = NULL\n");
3548 return -EFAULT;
3549 }
3550
3551 memset(&msg, 0, sizeof(struct host_if_msg));
3552
3553 msg.id = HOST_IF_MSG_SCAN;
3554
3555 if (hidden_network) {
3556 msg.body.scan_info.hidden_network.net_info = hidden_network->net_info;
3557 msg.body.scan_info.hidden_network.n_ssids = hidden_network->n_ssids;
3558 }
3559
3560 msg.vif = vif;
3561 msg.body.scan_info.src = scan_source;
3562 msg.body.scan_info.type = scan_type;
3563 msg.body.scan_info.result = scan_result;
3564 msg.body.scan_info.arg = user_arg;
3565
3566 msg.body.scan_info.ch_list_len = ch_list_len;
3567 msg.body.scan_info.ch_freq_list = kmemdup(ch_freq_list,
3568 ch_list_len,
3569 GFP_KERNEL);
3570 if (!msg.body.scan_info.ch_freq_list)
3571 return -ENOMEM;
3572
3573 msg.body.scan_info.ies_len = ies_len;
3574 msg.body.scan_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3575 if (!msg.body.scan_info.ies)
3576 return -ENOMEM;
3577
3578 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3579 if (result) {
3580 PRINT_ER("Error in sending message queue\n");
3581 return -EINVAL;
3582 }
3583
3584 hif_drv->scan_timer.data = (unsigned long)vif;
3585 mod_timer(&hif_drv->scan_timer,
3586 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
3587
3588 return result;
3589 }
3590
3591 s32 wilc_hif_set_cfg(struct wilc_vif *vif,
3592 struct cfg_param_val *pstrCfgParamVal)
3593 {
3594 s32 result = 0;
3595 struct host_if_msg msg;
3596 struct host_if_drv *hif_drv = vif->hif_drv;
3597
3598 if (!hif_drv) {
3599 PRINT_ER("hif_drv NULL\n");
3600 return -EFAULT;
3601 }
3602
3603 memset(&msg, 0, sizeof(struct host_if_msg));
3604 msg.id = HOST_IF_MSG_CFG_PARAMS;
3605 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
3606 msg.vif = vif;
3607
3608 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3609
3610 return result;
3611 }
3612
3613 static void GetPeriodicRSSI(unsigned long arg)
3614 {
3615 struct wilc_vif *vif = (struct wilc_vif *)arg;
3616
3617 if (!vif->hif_drv) {
3618 PRINT_ER("Driver handler is NULL\n");
3619 return;
3620 }
3621
3622 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED)
3623 wilc_get_statistics(vif, &vif->wilc->dummy_statistics);
3624
3625 periodic_rssi.data = (unsigned long)vif;
3626 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3627 }
3628
3629 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3630 {
3631 int result = 0;
3632 struct host_if_drv *hif_drv;
3633 struct wilc_vif *vif;
3634 struct wilc *wilc;
3635 int i;
3636
3637 vif = netdev_priv(dev);
3638 wilc = vif->wilc;
3639
3640 scan_while_connected = false;
3641
3642 sema_init(&hif_sema_wait_response, 0);
3643
3644 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3645 if (!hif_drv) {
3646 result = -ENOMEM;
3647 goto _fail_;
3648 }
3649 *hif_drv_handler = hif_drv;
3650 for (i = 0; i < wilc->vif_num; i++)
3651 if (dev == wilc->vif[i]->ndev) {
3652 wilc->vif[i]->hif_drv = hif_drv;
3653 break;
3654 }
3655
3656 wilc_optaining_ip = false;
3657
3658 if (clients_count == 0) {
3659 sema_init(&hif_sema_thread, 0);
3660 sema_init(&hif_sema_driver, 0);
3661 sema_init(&hif_sema_deinit, 1);
3662 }
3663
3664 sema_init(&hif_drv->sem_test_key_block, 0);
3665 sema_init(&hif_drv->sem_test_disconn_block, 0);
3666 sema_init(&hif_drv->sem_get_rssi, 0);
3667 sema_init(&hif_drv->sem_get_link_speed, 0);
3668 sema_init(&hif_drv->sem_get_chnl, 0);
3669 sema_init(&hif_drv->sem_inactive_time, 0);
3670
3671 if (clients_count == 0) {
3672 result = wilc_mq_create(&hif_msg_q);
3673
3674 if (result < 0) {
3675 PRINT_ER("Failed to creat MQ\n");
3676 goto _fail_;
3677 }
3678
3679 hif_thread_handler = kthread_run(hostIFthread, wilc,
3680 "WILC_kthread");
3681
3682 if (IS_ERR(hif_thread_handler)) {
3683 PRINT_ER("Failed to creat Thread\n");
3684 result = -EFAULT;
3685 goto _fail_mq_;
3686 }
3687 setup_timer(&periodic_rssi, GetPeriodicRSSI,
3688 (unsigned long)vif);
3689 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
3690 }
3691
3692 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
3693 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
3694 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
3695
3696 sema_init(&hif_drv->sem_cfg_values, 1);
3697 down(&hif_drv->sem_cfg_values);
3698
3699 hif_drv->hif_state = HOST_IF_IDLE;
3700 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3701 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3702 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3703 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3704 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
3705
3706 hif_drv->p2p_timeout = 0;
3707
3708 up(&hif_drv->sem_cfg_values);
3709
3710 clients_count++;
3711
3712 return result;
3713
3714 _fail_mq_:
3715 wilc_mq_destroy(&hif_msg_q);
3716 _fail_:
3717 return result;
3718 }
3719
3720 s32 wilc_deinit(struct wilc_vif *vif)
3721 {
3722 s32 result = 0;
3723 struct host_if_msg msg;
3724 struct host_if_drv *hif_drv = vif->hif_drv;
3725
3726 if (!hif_drv) {
3727 PRINT_ER("hif_drv = NULL\n");
3728 return 0;
3729 }
3730
3731 down(&hif_sema_deinit);
3732
3733 terminated_handle = hif_drv;
3734
3735 del_timer_sync(&hif_drv->scan_timer);
3736 del_timer_sync(&hif_drv->connect_timer);
3737 del_timer_sync(&periodic_rssi);
3738 del_timer_sync(&hif_drv->remain_on_ch_timer);
3739
3740 wilc_set_wfi_drv_handler(vif, 0, 0);
3741 down(&hif_sema_driver);
3742
3743 if (hif_drv->usr_scan_req.scan_result) {
3744 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
3745 hif_drv->usr_scan_req.arg, NULL);
3746 hif_drv->usr_scan_req.scan_result = NULL;
3747 }
3748
3749 hif_drv->hif_state = HOST_IF_IDLE;
3750
3751 scan_while_connected = false;
3752
3753 memset(&msg, 0, sizeof(struct host_if_msg));
3754
3755 if (clients_count == 1) {
3756 del_timer_sync(&periodic_rssi);
3757 msg.id = HOST_IF_MSG_EXIT;
3758 msg.vif = vif;
3759
3760 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3761 if (result != 0)
3762 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
3763
3764 down(&hif_sema_thread);
3765
3766 wilc_mq_destroy(&hif_msg_q);
3767 }
3768
3769 kfree(hif_drv);
3770
3771 clients_count--;
3772 terminated_handle = NULL;
3773 up(&hif_sema_deinit);
3774 return result;
3775 }
3776
3777 void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3778 u32 u32Length)
3779 {
3780 s32 result = 0;
3781 struct host_if_msg msg;
3782 int id;
3783 struct host_if_drv *hif_drv = NULL;
3784 struct wilc_vif *vif;
3785
3786 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3787 vif = wilc_get_vif_from_idx(wilc, id);
3788 if (!vif)
3789 return;
3790 hif_drv = vif->hif_drv;
3791
3792 if (!hif_drv || hif_drv == terminated_handle) {
3793 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
3794 return;
3795 }
3796
3797 memset(&msg, 0, sizeof(struct host_if_msg));
3798
3799 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
3800 msg.vif = vif;
3801
3802 msg.body.net_info.len = u32Length;
3803 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3804 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
3805
3806 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3807 if (result)
3808 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
3809 }
3810
3811 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3812 u32 u32Length)
3813 {
3814 s32 result = 0;
3815 struct host_if_msg msg;
3816 int id;
3817 struct host_if_drv *hif_drv = NULL;
3818 struct wilc_vif *vif;
3819
3820 down(&hif_sema_deinit);
3821
3822 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3823 vif = wilc_get_vif_from_idx(wilc, id);
3824 if (!vif) {
3825 up(&hif_sema_deinit);
3826 return;
3827 }
3828
3829 hif_drv = vif->hif_drv;
3830
3831 if (!hif_drv || hif_drv == terminated_handle) {
3832 up(&hif_sema_deinit);
3833 return;
3834 }
3835
3836 if (!hif_drv->usr_conn_req.conn_result) {
3837 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
3838 up(&hif_sema_deinit);
3839 return;
3840 }
3841
3842 memset(&msg, 0, sizeof(struct host_if_msg));
3843
3844 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
3845 msg.vif = vif;
3846
3847 msg.body.async_info.len = u32Length;
3848 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3849 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
3850
3851 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3852 if (result)
3853 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
3854
3855 up(&hif_sema_deinit);
3856 }
3857
3858 void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
3859 u32 u32Length)
3860 {
3861 s32 result = 0;
3862 struct host_if_msg msg;
3863 int id;
3864 struct host_if_drv *hif_drv = NULL;
3865 struct wilc_vif *vif;
3866
3867 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
3868 vif = wilc_get_vif_from_idx(wilc, id);
3869 if (!vif)
3870 return;
3871 hif_drv = vif->hif_drv;
3872
3873 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
3874
3875 if (!hif_drv || hif_drv == terminated_handle)
3876 return;
3877
3878 if (hif_drv->usr_scan_req.scan_result) {
3879 memset(&msg, 0, sizeof(struct host_if_msg));
3880
3881 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
3882 msg.vif = vif;
3883
3884 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3885 if (result)
3886 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
3887 }
3888
3889 return;
3890 }
3891
3892 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
3893 u32 duration, u16 chan,
3894 wilc_remain_on_chan_expired expired,
3895 wilc_remain_on_chan_ready ready,
3896 void *user_arg)
3897 {
3898 int result = 0;
3899 struct host_if_msg msg;
3900 struct host_if_drv *hif_drv = vif->hif_drv;
3901
3902 if (!hif_drv) {
3903 PRINT_ER("driver is null\n");
3904 return -EFAULT;
3905 }
3906
3907 memset(&msg, 0, sizeof(struct host_if_msg));
3908
3909 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
3910 msg.body.remain_on_ch.ch = chan;
3911 msg.body.remain_on_ch.expired = expired;
3912 msg.body.remain_on_ch.ready = ready;
3913 msg.body.remain_on_ch.arg = user_arg;
3914 msg.body.remain_on_ch.duration = duration;
3915 msg.body.remain_on_ch.id = session_id;
3916 msg.vif = vif;
3917
3918 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3919 if (result)
3920 PRINT_ER("wilc mq send fail\n");
3921
3922 return result;
3923 }
3924
3925 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
3926 {
3927 int result = 0;
3928 struct host_if_msg msg;
3929 struct host_if_drv *hif_drv = vif->hif_drv;
3930
3931 if (!hif_drv) {
3932 PRINT_ER("driver is null\n");
3933 return -EFAULT;
3934 }
3935
3936 del_timer(&hif_drv->remain_on_ch_timer);
3937
3938 memset(&msg, 0, sizeof(struct host_if_msg));
3939 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3940 msg.vif = vif;
3941 msg.body.remain_on_ch.id = session_id;
3942
3943 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3944 if (result)
3945 PRINT_ER("wilc mq send fail\n");
3946
3947 return result;
3948 }
3949
3950 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
3951 {
3952 int result = 0;
3953 struct host_if_msg msg;
3954 struct host_if_drv *hif_drv = vif->hif_drv;
3955
3956 if (!hif_drv) {
3957 PRINT_ER("driver is null\n");
3958 return -EFAULT;
3959 }
3960
3961 memset(&msg, 0, sizeof(struct host_if_msg));
3962
3963 msg.id = HOST_IF_MSG_REGISTER_FRAME;
3964 switch (frame_type) {
3965 case ACTION:
3966 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
3967 break;
3968
3969 case PROBE_REQ:
3970 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
3971 break;
3972
3973 default:
3974 break;
3975 }
3976 msg.body.reg_frame.frame_type = frame_type;
3977 msg.body.reg_frame.reg = reg;
3978 msg.vif = vif;
3979
3980 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3981 if (result)
3982 PRINT_ER("wilc mq send fail\n");
3983
3984 return result;
3985 }
3986
3987 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
3988 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
3989 {
3990 int result = 0;
3991 struct host_if_msg msg;
3992 struct beacon_attr *beacon_info = &msg.body.beacon_info;
3993 struct host_if_drv *hif_drv = vif->hif_drv;
3994
3995 if (!hif_drv) {
3996 PRINT_ER("driver is null\n");
3997 return -EFAULT;
3998 }
3999
4000 memset(&msg, 0, sizeof(struct host_if_msg));
4001
4002 msg.id = HOST_IF_MSG_ADD_BEACON;
4003 msg.vif = vif;
4004 beacon_info->interval = interval;
4005 beacon_info->dtim_period = dtim_period;
4006 beacon_info->head_len = head_len;
4007 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
4008 if (!beacon_info->head) {
4009 result = -ENOMEM;
4010 goto ERRORHANDLER;
4011 }
4012 beacon_info->tail_len = tail_len;
4013
4014 if (tail_len > 0) {
4015 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
4016 if (!beacon_info->tail) {
4017 result = -ENOMEM;
4018 goto ERRORHANDLER;
4019 }
4020 } else {
4021 beacon_info->tail = NULL;
4022 }
4023
4024 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4025 if (result)
4026 PRINT_ER("wilc mq send fail\n");
4027
4028 ERRORHANDLER:
4029 if (result) {
4030 kfree(beacon_info->head);
4031
4032 kfree(beacon_info->tail);
4033 }
4034
4035 return result;
4036 }
4037
4038 int wilc_del_beacon(struct wilc_vif *vif)
4039 {
4040 int result = 0;
4041 struct host_if_msg msg;
4042 struct host_if_drv *hif_drv = vif->hif_drv;
4043
4044 if (!hif_drv) {
4045 PRINT_ER("driver is null\n");
4046 return -EFAULT;
4047 }
4048
4049 msg.id = HOST_IF_MSG_DEL_BEACON;
4050 msg.vif = vif;
4051
4052 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4053 if (result)
4054 PRINT_ER("wilc_mq_send fail\n");
4055
4056 return result;
4057 }
4058
4059 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
4060 {
4061 int result = 0;
4062 struct host_if_msg msg;
4063 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4064 struct host_if_drv *hif_drv = vif->hif_drv;
4065
4066 if (!hif_drv) {
4067 PRINT_ER("driver is null\n");
4068 return -EFAULT;
4069 }
4070
4071 memset(&msg, 0, sizeof(struct host_if_msg));
4072
4073 msg.id = HOST_IF_MSG_ADD_STATION;
4074 msg.vif = vif;
4075
4076 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4077 if (add_sta_info->rates_len > 0) {
4078 add_sta_info->rates = kmemdup(sta_param->rates,
4079 add_sta_info->rates_len,
4080 GFP_KERNEL);
4081 if (!add_sta_info->rates)
4082 return -ENOMEM;
4083 }
4084
4085 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4086 if (result)
4087 PRINT_ER("wilc_mq_send fail\n");
4088 return result;
4089 }
4090
4091 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
4092 {
4093 int result = 0;
4094 struct host_if_msg msg;
4095 struct del_sta *del_sta_info = &msg.body.del_sta_info;
4096 struct host_if_drv *hif_drv = vif->hif_drv;
4097
4098 if (!hif_drv) {
4099 PRINT_ER("driver is null\n");
4100 return -EFAULT;
4101 }
4102
4103 memset(&msg, 0, sizeof(struct host_if_msg));
4104
4105 msg.id = HOST_IF_MSG_DEL_STATION;
4106 msg.vif = vif;
4107
4108 if (!mac_addr)
4109 eth_broadcast_addr(del_sta_info->mac_addr);
4110 else
4111 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
4112
4113 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4114 if (result)
4115 PRINT_ER("wilc_mq_send fail\n");
4116 return result;
4117 }
4118
4119 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
4120 {
4121 int result = 0;
4122 struct host_if_msg msg;
4123 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
4124 struct host_if_drv *hif_drv = vif->hif_drv;
4125 u8 zero_addr[ETH_ALEN] = {0};
4126 int i;
4127 u8 assoc_sta = 0;
4128
4129 if (!hif_drv) {
4130 PRINT_ER("driver is null\n");
4131 return -EFAULT;
4132 }
4133
4134 memset(&msg, 0, sizeof(struct host_if_msg));
4135
4136 msg.id = HOST_IF_MSG_DEL_ALL_STA;
4137 msg.vif = vif;
4138
4139 for (i = 0; i < MAX_NUM_STA; i++) {
4140 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
4141 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
4142 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4143 del_all_sta_info->del_all_sta[i][0],
4144 del_all_sta_info->del_all_sta[i][1],
4145 del_all_sta_info->del_all_sta[i][2],
4146 del_all_sta_info->del_all_sta[i][3],
4147 del_all_sta_info->del_all_sta[i][4],
4148 del_all_sta_info->del_all_sta[i][5]);
4149 assoc_sta++;
4150 }
4151 }
4152 if (!assoc_sta) {
4153 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4154 return result;
4155 }
4156
4157 del_all_sta_info->assoc_sta = assoc_sta;
4158 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4159
4160 if (result)
4161 PRINT_ER("wilc_mq_send fail\n");
4162
4163 down(&hif_sema_wait_response);
4164
4165 return result;
4166 }
4167
4168 int wilc_edit_station(struct wilc_vif *vif,
4169 struct add_sta_param *sta_param)
4170 {
4171 int result = 0;
4172 struct host_if_msg msg;
4173 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
4174 struct host_if_drv *hif_drv = vif->hif_drv;
4175
4176 if (!hif_drv) {
4177 PRINT_ER("driver is null\n");
4178 return -EFAULT;
4179 }
4180
4181 memset(&msg, 0, sizeof(struct host_if_msg));
4182
4183 msg.id = HOST_IF_MSG_EDIT_STATION;
4184 msg.vif = vif;
4185
4186 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4187 if (add_sta_info->rates_len > 0) {
4188 add_sta_info->rates = kmemdup(sta_param->rates,
4189 add_sta_info->rates_len,
4190 GFP_KERNEL);
4191 if (!add_sta_info->rates)
4192 return -ENOMEM;
4193 }
4194
4195 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4196 if (result)
4197 PRINT_ER("wilc_mq_send fail\n");
4198
4199 return result;
4200 }
4201
4202 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
4203 {
4204 int result = 0;
4205 struct host_if_msg msg;
4206 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
4207 struct host_if_drv *hif_drv = vif->hif_drv;
4208
4209 if (!hif_drv) {
4210 PRINT_ER("driver is null\n");
4211 return -EFAULT;
4212 }
4213
4214 if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled)
4215 return 0;
4216
4217 memset(&msg, 0, sizeof(struct host_if_msg));
4218
4219 msg.id = HOST_IF_MSG_POWER_MGMT;
4220 msg.vif = vif;
4221
4222 pwr_mgmt_info->enabled = enabled;
4223 pwr_mgmt_info->timeout = timeout;
4224
4225 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4226 if (result)
4227 PRINT_ER("wilc_mq_send fail\n");
4228 return result;
4229 }
4230
4231 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
4232 u32 count)
4233 {
4234 int result = 0;
4235 struct host_if_msg msg;
4236 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
4237 struct host_if_drv *hif_drv = vif->hif_drv;
4238
4239 if (!hif_drv) {
4240 PRINT_ER("driver is null\n");
4241 return -EFAULT;
4242 }
4243
4244 memset(&msg, 0, sizeof(struct host_if_msg));
4245
4246 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
4247 msg.vif = vif;
4248
4249 multicast_filter_param->enabled = enabled;
4250 multicast_filter_param->cnt = count;
4251
4252 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4253 if (result)
4254 PRINT_ER("wilc_mq_send fail\n");
4255 return result;
4256 }
4257
4258 static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
4259 {
4260 struct join_bss_param *pNewJoinBssParam = NULL;
4261 u8 *pu8IEs;
4262 u16 u16IEsLen;
4263 u16 index = 0;
4264 u8 suppRatesNo = 0;
4265 u8 extSuppRatesNo;
4266 u16 jumpOffset;
4267 u8 pcipherCount;
4268 u8 authCount;
4269 u8 pcipherTotalCount = 0;
4270 u8 authTotalCount = 0;
4271 u8 i, j;
4272
4273 pu8IEs = ptstrNetworkInfo->pu8IEs;
4274 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4275
4276 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
4277 if (pNewJoinBssParam) {
4278 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4279 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4280 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
4281 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
4282 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
4283 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
4284 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4285 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
4286
4287 while (index < u16IEsLen) {
4288 if (pu8IEs[index] == SUPP_RATES_IE) {
4289 suppRatesNo = pu8IEs[index + 1];
4290 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
4291 index += 2;
4292
4293 for (i = 0; i < suppRatesNo; i++)
4294 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
4295
4296 index += suppRatesNo;
4297 continue;
4298 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
4299 extSuppRatesNo = pu8IEs[index + 1];
4300 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4301 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4302 else
4303 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4304 index += 2;
4305 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
4306 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
4307
4308 index += extSuppRatesNo;
4309 continue;
4310 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
4311 pNewJoinBssParam->ht_capable = true;
4312 index += pu8IEs[index + 1] + 2;
4313 continue;
4314 } else if ((pu8IEs[index] == WMM_IE) &&
4315 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
4316 (pu8IEs[index + 4] == 0xF2) &&
4317 (pu8IEs[index + 5] == 0x02) &&
4318 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
4319 (pu8IEs[index + 7] == 0x01)) {
4320 pNewJoinBssParam->wmm_cap = true;
4321
4322 if (pu8IEs[index + 8] & BIT(7))
4323 pNewJoinBssParam->uapsd_cap = true;
4324 index += pu8IEs[index + 1] + 2;
4325 continue;
4326 } else if ((pu8IEs[index] == P2P_IE) &&
4327 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
4328 (pu8IEs[index + 4] == 0x9a) &&
4329 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
4330 u16 u16P2P_count;
4331
4332 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4333 pNewJoinBssParam->noa_enabled = 1;
4334 pNewJoinBssParam->idx = pu8IEs[index + 9];
4335
4336 if (pu8IEs[index + 10] & BIT(7)) {
4337 pNewJoinBssParam->opp_enabled = 1;
4338 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
4339 } else {
4340 pNewJoinBssParam->opp_enabled = 0;
4341 }
4342
4343 PRINT_D(GENERIC_DBG, "P2P Dump\n");
4344 for (i = 0; i < pu8IEs[index + 7]; i++)
4345 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
4346
4347 pNewJoinBssParam->cnt = pu8IEs[index + 11];
4348 u16P2P_count = index + 12;
4349
4350 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
4351 u16P2P_count += 4;
4352
4353 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
4354 u16P2P_count += 4;
4355
4356 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
4357
4358 index += pu8IEs[index + 1] + 2;
4359 continue;
4360
4361 } else if ((pu8IEs[index] == RSN_IE) ||
4362 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4363 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4364 (pu8IEs[index + 5] == 0x01))) {
4365 u16 rsnIndex = index;
4366
4367 if (pu8IEs[rsnIndex] == RSN_IE) {
4368 pNewJoinBssParam->mode_802_11i = 2;
4369 } else {
4370 if (pNewJoinBssParam->mode_802_11i == 0)
4371 pNewJoinBssParam->mode_802_11i = 1;
4372 rsnIndex += 4;
4373 }
4374
4375 rsnIndex += 7;
4376 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4377 rsnIndex++;
4378 jumpOffset = pu8IEs[rsnIndex] * 4;
4379 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4380 rsnIndex += 2;
4381
4382 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
4383 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4384
4385 pcipherTotalCount += pcipherCount;
4386 rsnIndex += jumpOffset;
4387
4388 jumpOffset = pu8IEs[rsnIndex] * 4;
4389
4390 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
4391 rsnIndex += 2;
4392
4393 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
4394 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
4395
4396 authTotalCount += authCount;
4397 rsnIndex += jumpOffset;
4398
4399 if (pu8IEs[index] == RSN_IE) {
4400 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4401 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4402 rsnIndex += 2;
4403 }
4404 pNewJoinBssParam->rsn_found = true;
4405 index += pu8IEs[index + 1] + 2;
4406 continue;
4407 } else
4408 index += pu8IEs[index + 1] + 2;
4409 }
4410 }
4411
4412 return (void *)pNewJoinBssParam;
4413 }
4414
4415 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4416 {
4417 int result = 0;
4418 struct host_if_msg msg;
4419 struct host_if_drv *hif_drv = vif->hif_drv;
4420
4421 if (!hif_drv) {
4422 PRINT_ER("driver is null\n");
4423 return -EFAULT;
4424 }
4425
4426 memset(&msg, 0, sizeof(struct host_if_msg));
4427
4428 msg.id = HOST_IF_MSG_SET_IPADDRESS;
4429
4430 msg.body.ip_info.ip_addr = ip_addr;
4431 msg.vif = vif;
4432 msg.body.ip_info.idx = idx;
4433
4434 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4435 if (result)
4436 PRINT_ER("wilc_mq_send fail\n");
4437
4438 return result;
4439 }
4440
4441 static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
4442 {
4443 int result = 0;
4444 struct host_if_msg msg;
4445 struct host_if_drv *hif_drv = vif->hif_drv;
4446
4447 if (!hif_drv) {
4448 PRINT_ER("driver is null\n");
4449 return -EFAULT;
4450 }
4451
4452 memset(&msg, 0, sizeof(struct host_if_msg));
4453
4454 msg.id = HOST_IF_MSG_GET_IPADDRESS;
4455
4456 msg.body.ip_info.ip_addr = ip_addr;
4457 msg.vif = vif;
4458 msg.body.ip_info.idx = idx;
4459
4460 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4461 if (result)
4462 PRINT_ER("wilc_mq_send fail\n");
4463
4464 return result;
4465 }
4466
4467 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power)
4468 {
4469 int ret = 0;
4470 struct host_if_msg msg;
4471
4472 memset(&msg, 0, sizeof(struct host_if_msg));
4473
4474 msg.id = HOST_IF_MSG_SET_TX_POWER;
4475 msg.body.tx_power.tx_pwr = tx_power;
4476 msg.vif = vif;
4477
4478 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4479 if (ret)
4480 netdev_err(vif->ndev, "wilc_mq_send fail\n");
4481
4482 return ret;
4483 }
4484
4485 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power)
4486 {
4487 int ret = 0;
4488 struct host_if_msg msg;
4489
4490 memset(&msg, 0, sizeof(struct host_if_msg));
4491
4492 msg.id = HOST_IF_MSG_GET_TX_POWER;
4493 msg.vif = vif;
4494
4495 ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4496 if (ret)
4497 netdev_err(vif->ndev, "Failed to get TX PWR\n");
4498
4499 down(&hif_sema_wait_response);
4500 *tx_power = msg.body.tx_power.tx_pwr;
4501
4502 return ret;
4503 }
This page took 0.194559 seconds and 5 git commands to generate.