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