1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/ip.h>
19#include <linux/in.h>
20#include "core.h"
21#include "debug.h"
22#include "testmode.h"
23#include "trace.h"
24#include "../regd.h"
25#include "../regd_common.h"
26
27static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx);
28
29static const s32 wmi_rate_tbl[][2] = {
30
31 {1000, 1000},
32 {2000, 2000},
33 {5500, 5500},
34 {11000, 11000},
35 {6000, 6000},
36 {9000, 9000},
37 {12000, 12000},
38 {18000, 18000},
39 {24000, 24000},
40 {36000, 36000},
41 {48000, 48000},
42 {54000, 54000},
43 {6500, 7200},
44 {13000, 14400},
45 {19500, 21700},
46 {26000, 28900},
47 {39000, 43300},
48 {52000, 57800},
49 {58500, 65000},
50 {65000, 72200},
51 {13500, 15000},
52 {27000, 30000},
53 {40500, 45000},
54 {54000, 60000},
55 {81000, 90000},
56 {108000, 120000},
57 {121500, 135000},
58 {135000, 150000},
59 {0, 0}
60};
61
62static const s32 wmi_rate_tbl_mcs15[][2] = {
63
64 {1000, 1000},
65 {2000, 2000},
66 {5500, 5500},
67 {11000, 11000},
68 {6000, 6000},
69 {9000, 9000},
70 {12000, 12000},
71 {18000, 18000},
72 {24000, 24000},
73 {36000, 36000},
74 {48000, 48000},
75 {54000, 54000},
76 {6500, 7200},
77 {13000, 14400},
78 {19500, 21700},
79 {26000, 28900},
80 {39000, 43300},
81 {52000, 57800},
82 {58500, 65000},
83 {65000, 72200},
84 {13000, 14400},
85 {26000, 28900},
86 {39000, 43300},
87 {52000, 57800},
88 {78000, 86700},
89 {104000, 115600},
90 {117000, 130000},
91 {130000, 144400},
92 {13500, 15000},
93 {27000, 30000},
94 {40500, 45000},
95 {54000, 60000},
96 {81000, 90000},
97 {108000, 120000},
98 {121500, 135000},
99 {135000, 150000},
100 {27000, 30000},
101 {54000, 60000},
102 {81000, 90000},
103 {108000, 120000},
104 {162000, 180000},
105 {216000, 240000},
106 {243000, 270000},
107 {270000, 300000},
108 {0, 0}
109};
110
111
112static const u8 up_to_ac[] = {
113 WMM_AC_BE,
114 WMM_AC_BK,
115 WMM_AC_BK,
116 WMM_AC_BE,
117 WMM_AC_VI,
118 WMM_AC_VI,
119 WMM_AC_VO,
120 WMM_AC_VO,
121};
122
123void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id)
124{
125 if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX))
126 return;
127
128 wmi->ep_id = ep_id;
129}
130
131enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi)
132{
133 return wmi->ep_id;
134}
135
136struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx)
137{
138 struct ath6kl_vif *vif, *found = NULL;
139
140 if (WARN_ON(if_idx > (ar->vif_max - 1)))
141 return NULL;
142
143
144 spin_lock_bh(&ar->list_lock);
145 list_for_each_entry(vif, &ar->vif_list, list) {
146 if (vif->fw_vif_idx == if_idx) {
147 found = vif;
148 break;
149 }
150 }
151 spin_unlock_bh(&ar->list_lock);
152
153 return found;
154}
155
156
157
158
159
160int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb)
161{
162 struct ath6kl_llc_snap_hdr *llc_hdr;
163 struct ethhdr *eth_hdr;
164 size_t new_len;
165 __be16 type;
166 u8 *datap;
167 u16 size;
168
169 if (WARN_ON(skb == NULL))
170 return -EINVAL;
171
172 size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr);
173 if (skb_headroom(skb) < size)
174 return -ENOMEM;
175
176 eth_hdr = (struct ethhdr *) skb->data;
177 type = eth_hdr->h_proto;
178
179 if (!is_ethertype(be16_to_cpu(type))) {
180 ath6kl_dbg(ATH6KL_DBG_WMI,
181 "%s: pkt is already in 802.3 format\n", __func__);
182 return 0;
183 }
184
185 new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr);
186
187 skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr));
188 datap = skb->data;
189
190 eth_hdr->h_proto = cpu_to_be16(new_len);
191
192 memcpy(datap, eth_hdr, sizeof(*eth_hdr));
193
194 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr));
195 llc_hdr->dsap = 0xAA;
196 llc_hdr->ssap = 0xAA;
197 llc_hdr->cntl = 0x03;
198 llc_hdr->org_code[0] = 0x0;
199 llc_hdr->org_code[1] = 0x0;
200 llc_hdr->org_code[2] = 0x0;
201 llc_hdr->eth_type = type;
202
203 return 0;
204}
205
206static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb,
207 u8 *version, void *tx_meta_info)
208{
209 struct wmi_tx_meta_v1 *v1;
210 struct wmi_tx_meta_v2 *v2;
211
212 if (WARN_ON(skb == NULL || version == NULL))
213 return -EINVAL;
214
215 switch (*version) {
216 case WMI_META_VERSION_1:
217 skb_push(skb, WMI_MAX_TX_META_SZ);
218 v1 = (struct wmi_tx_meta_v1 *) skb->data;
219 v1->pkt_id = 0;
220 v1->rate_plcy_id = 0;
221 *version = WMI_META_VERSION_1;
222 break;
223 case WMI_META_VERSION_2:
224 skb_push(skb, WMI_MAX_TX_META_SZ);
225 v2 = (struct wmi_tx_meta_v2 *) skb->data;
226 memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info,
227 sizeof(struct wmi_tx_meta_v2));
228 break;
229 }
230
231 return 0;
232}
233
234int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
235 u8 msg_type, u32 flags,
236 enum wmi_data_hdr_data_type data_type,
237 u8 meta_ver, void *tx_meta_info, u8 if_idx)
238{
239 struct wmi_data_hdr *data_hdr;
240 int ret;
241
242 if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1)))
243 return -EINVAL;
244
245 if (tx_meta_info) {
246 ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info);
247 if (ret)
248 return ret;
249 }
250
251 skb_push(skb, sizeof(struct wmi_data_hdr));
252
253 data_hdr = (struct wmi_data_hdr *)skb->data;
254 memset(data_hdr, 0, sizeof(struct wmi_data_hdr));
255
256 data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT;
257 data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT;
258
259 if (flags & WMI_DATA_HDR_FLAGS_MORE)
260 data_hdr->info |= WMI_DATA_HDR_MORE;
261
262 if (flags & WMI_DATA_HDR_FLAGS_EOSP)
263 data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP);
264
265 data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT);
266 data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
267
268 return 0;
269}
270
271u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri)
272{
273 struct iphdr *ip_hdr = (struct iphdr *) pkt;
274 u8 ip_pri;
275
276
277
278
279
280
281
282
283
284 ip_pri = ip_hdr->tos >> 5;
285 ip_pri &= 0x7;
286
287 if ((layer2_pri & 0x7) > ip_pri)
288 return (u8) layer2_pri & 0x7;
289 else
290 return ip_pri;
291}
292
293u8 ath6kl_wmi_get_traffic_class(u8 user_priority)
294{
295 return up_to_ac[user_priority & 0x7];
296}
297
298int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx,
299 struct sk_buff *skb,
300 u32 layer2_priority, bool wmm_enabled,
301 u8 *ac)
302{
303 struct wmi_data_hdr *data_hdr;
304 struct ath6kl_llc_snap_hdr *llc_hdr;
305 struct wmi_create_pstream_cmd cmd;
306 u32 meta_size, hdr_size;
307 u16 ip_type = IP_ETHERTYPE;
308 u8 stream_exist, usr_pri;
309 u8 traffic_class = WMM_AC_BE;
310 u8 *datap;
311
312 if (WARN_ON(skb == NULL))
313 return -EINVAL;
314
315 datap = skb->data;
316 data_hdr = (struct wmi_data_hdr *) datap;
317
318 meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
319 WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0;
320
321 if (!wmm_enabled) {
322
323 usr_pri = 0;
324 } else {
325 hdr_size = sizeof(struct ethhdr);
326
327 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap +
328 sizeof(struct
329 wmi_data_hdr) +
330 meta_size + hdr_size);
331
332 if (llc_hdr->eth_type == htons(ip_type)) {
333
334
335
336
337 usr_pri =
338 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
339 sizeof(struct ath6kl_llc_snap_hdr),
340 layer2_priority);
341 } else {
342 usr_pri = layer2_priority & 0x7;
343 }
344
345
346
347
348
349 if (skb->protocol == cpu_to_be16(ETH_P_PAE))
350 usr_pri = WMI_VOICE_USER_PRIORITY;
351 }
352
353
354
355
356
357
358
359 if ((wmi->traffic_class == WMM_AC_VI) &&
360 ((usr_pri == 5) || (usr_pri == 4)))
361 usr_pri = 1;
362
363
364 traffic_class = up_to_ac[usr_pri & 0x7];
365
366 wmi_data_hdr_set_up(data_hdr, usr_pri);
367
368 spin_lock_bh(&wmi->lock);
369 stream_exist = wmi->fat_pipe_exist;
370 spin_unlock_bh(&wmi->lock);
371
372 if (!(stream_exist & (1 << traffic_class))) {
373 memset(&cmd, 0, sizeof(cmd));
374 cmd.traffic_class = traffic_class;
375 cmd.user_pri = usr_pri;
376 cmd.inactivity_int =
377 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT);
378
379 cmd.tsid = WMI_IMPLICIT_PSTREAM;
380 ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd);
381 }
382
383 *ac = traffic_class;
384
385 return 0;
386}
387
388int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
389{
390 struct ieee80211_hdr_3addr *pwh, wh;
391 struct ath6kl_llc_snap_hdr *llc_hdr;
392 struct ethhdr eth_hdr;
393 u32 hdr_size;
394 u8 *datap;
395 __le16 sub_type;
396
397 if (WARN_ON(skb == NULL))
398 return -EINVAL;
399
400 datap = skb->data;
401 pwh = (struct ieee80211_hdr_3addr *) datap;
402
403 sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
404
405 memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr));
406
407
408 if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
409 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
410 sizeof(u32));
411 skb_pull(skb, hdr_size);
412 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) {
413 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
414 }
415
416 datap = skb->data;
417 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
418
419 memset(ð_hdr, 0, sizeof(eth_hdr));
420 eth_hdr.h_proto = llc_hdr->eth_type;
421
422 switch ((le16_to_cpu(wh.frame_control)) &
423 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
424 case IEEE80211_FCTL_TODS:
425 memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
426 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
427 break;
428 case IEEE80211_FCTL_FROMDS:
429 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
430 memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN);
431 break;
432 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
433 break;
434 default:
435 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
436 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
437 break;
438 }
439
440 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
441 skb_push(skb, sizeof(eth_hdr));
442
443 datap = skb->data;
444
445 memcpy(datap, ð_hdr, sizeof(eth_hdr));
446
447 return 0;
448}
449
450
451
452
453
454int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
455{
456 struct ath6kl_llc_snap_hdr *llc_hdr;
457 struct ethhdr eth_hdr;
458 u8 *datap;
459
460 if (WARN_ON(skb == NULL))
461 return -EINVAL;
462
463 datap = skb->data;
464
465 memcpy(ð_hdr, datap, sizeof(eth_hdr));
466
467 llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr));
468 eth_hdr.h_proto = llc_hdr->eth_type;
469
470 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
471 datap = skb->data;
472
473 memcpy(datap, ð_hdr, sizeof(eth_hdr));
474
475 return 0;
476}
477
478static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
479{
480 struct tx_complete_msg_v1 *msg_v1;
481 struct wmi_tx_complete_event *evt;
482 int index;
483 u16 size;
484
485 evt = (struct wmi_tx_complete_event *) datap;
486
487 ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
488 evt->num_msg, evt->msg_len, evt->msg_type);
489
490 for (index = 0; index < evt->num_msg; index++) {
491 size = sizeof(struct wmi_tx_complete_event) +
492 (index * sizeof(struct tx_complete_msg_v1));
493 msg_v1 = (struct tx_complete_msg_v1 *)(datap + size);
494
495 ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n",
496 msg_v1->status, msg_v1->pkt_id,
497 msg_v1->rate_idx, msg_v1->ack_failures);
498 }
499
500 return 0;
501}
502
503static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap,
504 int len, struct ath6kl_vif *vif)
505{
506 struct wmi_remain_on_chnl_event *ev;
507 u32 freq;
508 u32 dur;
509 struct ieee80211_channel *chan;
510 struct ath6kl *ar = wmi->parent_dev;
511 u32 id;
512
513 if (len < sizeof(*ev))
514 return -EINVAL;
515
516 ev = (struct wmi_remain_on_chnl_event *) datap;
517 freq = le32_to_cpu(ev->freq);
518 dur = le32_to_cpu(ev->duration);
519 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
520 freq, dur);
521 chan = ieee80211_get_channel(ar->wiphy, freq);
522 if (!chan) {
523 ath6kl_dbg(ATH6KL_DBG_WMI,
524 "remain_on_chnl: Unknown channel (freq=%u)\n",
525 freq);
526 return -EINVAL;
527 }
528 id = vif->last_roc_id;
529 cfg80211_ready_on_channel(&vif->wdev, id, chan,
530 dur, GFP_ATOMIC);
531
532 return 0;
533}
534
535static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
536 u8 *datap, int len,
537 struct ath6kl_vif *vif)
538{
539 struct wmi_cancel_remain_on_chnl_event *ev;
540 u32 freq;
541 u32 dur;
542 struct ieee80211_channel *chan;
543 struct ath6kl *ar = wmi->parent_dev;
544 u32 id;
545
546 if (len < sizeof(*ev))
547 return -EINVAL;
548
549 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
550 freq = le32_to_cpu(ev->freq);
551 dur = le32_to_cpu(ev->duration);
552 ath6kl_dbg(ATH6KL_DBG_WMI,
553 "cancel_remain_on_chnl: freq=%u dur=%u status=%u\n",
554 freq, dur, ev->status);
555 chan = ieee80211_get_channel(ar->wiphy, freq);
556 if (!chan) {
557 ath6kl_dbg(ATH6KL_DBG_WMI,
558 "cancel_remain_on_chnl: Unknown channel (freq=%u)\n",
559 freq);
560 return -EINVAL;
561 }
562 if (vif->last_cancel_roc_id &&
563 vif->last_cancel_roc_id + 1 == vif->last_roc_id)
564 id = vif->last_cancel_roc_id;
565 else
566 id = vif->last_roc_id;
567 vif->last_cancel_roc_id = 0;
568 cfg80211_remain_on_channel_expired(&vif->wdev, id, chan, GFP_ATOMIC);
569
570 return 0;
571}
572
573static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len,
574 struct ath6kl_vif *vif)
575{
576 struct wmi_tx_status_event *ev;
577 u32 id;
578
579 if (len < sizeof(*ev))
580 return -EINVAL;
581
582 ev = (struct wmi_tx_status_event *) datap;
583 id = le32_to_cpu(ev->id);
584 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
585 id, ev->ack_status);
586 if (wmi->last_mgmt_tx_frame) {
587 cfg80211_mgmt_tx_status(&vif->wdev, id,
588 wmi->last_mgmt_tx_frame,
589 wmi->last_mgmt_tx_frame_len,
590 !!ev->ack_status, GFP_ATOMIC);
591 kfree(wmi->last_mgmt_tx_frame);
592 wmi->last_mgmt_tx_frame = NULL;
593 wmi->last_mgmt_tx_frame_len = 0;
594 }
595
596 return 0;
597}
598
599static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len,
600 struct ath6kl_vif *vif)
601{
602 struct wmi_p2p_rx_probe_req_event *ev;
603 u32 freq;
604 u16 dlen;
605
606 if (len < sizeof(*ev))
607 return -EINVAL;
608
609 ev = (struct wmi_p2p_rx_probe_req_event *) datap;
610 freq = le32_to_cpu(ev->freq);
611 dlen = le16_to_cpu(ev->len);
612 if (datap + len < ev->data + dlen) {
613 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: len=%d dlen=%u\n",
614 len, dlen);
615 return -EINVAL;
616 }
617 ath6kl_dbg(ATH6KL_DBG_WMI,
618 "rx_probe_req: len=%u freq=%u probe_req_report=%d\n",
619 dlen, freq, vif->probe_req_report);
620
621 if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
622 cfg80211_rx_mgmt(&vif->wdev, freq, 0, ev->data, dlen, 0);
623
624 return 0;
625}
626
627static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
628{
629 struct wmi_p2p_capabilities_event *ev;
630 u16 dlen;
631
632 if (len < sizeof(*ev))
633 return -EINVAL;
634
635 ev = (struct wmi_p2p_capabilities_event *) datap;
636 dlen = le16_to_cpu(ev->len);
637 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
638
639 return 0;
640}
641
642static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
643 struct ath6kl_vif *vif)
644{
645 struct wmi_rx_action_event *ev;
646 u32 freq;
647 u16 dlen;
648
649 if (len < sizeof(*ev))
650 return -EINVAL;
651
652 ev = (struct wmi_rx_action_event *) datap;
653 freq = le32_to_cpu(ev->freq);
654 dlen = le16_to_cpu(ev->len);
655 if (datap + len < ev->data + dlen) {
656 ath6kl_err("invalid wmi_rx_action_event: len=%d dlen=%u\n",
657 len, dlen);
658 return -EINVAL;
659 }
660 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
661 cfg80211_rx_mgmt(&vif->wdev, freq, 0, ev->data, dlen, 0);
662
663 return 0;
664}
665
666static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
667{
668 struct wmi_p2p_info_event *ev;
669 u32 flags;
670 u16 dlen;
671
672 if (len < sizeof(*ev))
673 return -EINVAL;
674
675 ev = (struct wmi_p2p_info_event *) datap;
676 flags = le32_to_cpu(ev->info_req_flags);
677 dlen = le16_to_cpu(ev->len);
678 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
679
680 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
681 struct wmi_p2p_capabilities *cap;
682 if (dlen < sizeof(*cap))
683 return -EINVAL;
684 cap = (struct wmi_p2p_capabilities *) ev->data;
685 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
686 cap->go_power_save);
687 }
688
689 if (flags & P2P_FLAG_MACADDR_REQ) {
690 struct wmi_p2p_macaddr *mac;
691 if (dlen < sizeof(*mac))
692 return -EINVAL;
693 mac = (struct wmi_p2p_macaddr *) ev->data;
694 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
695 mac->mac_addr);
696 }
697
698 if (flags & P2P_FLAG_HMODEL_REQ) {
699 struct wmi_p2p_hmodel *mod;
700 if (dlen < sizeof(*mod))
701 return -EINVAL;
702 mod = (struct wmi_p2p_hmodel *) ev->data;
703 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
704 mod->p2p_model,
705 mod->p2p_model ? "host" : "firmware");
706 }
707 return 0;
708}
709
710static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
711{
712 struct sk_buff *skb;
713
714 skb = ath6kl_buf_alloc(size);
715 if (!skb)
716 return NULL;
717
718 skb_put(skb, size);
719 if (size)
720 memset(skb->data, 0, size);
721
722 return skb;
723}
724
725
726static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx,
727 enum wmi_cmd_id cmd_id)
728{
729 struct sk_buff *skb;
730 int ret;
731
732 skb = ath6kl_wmi_get_new_buf(0);
733 if (!skb)
734 return -ENOMEM;
735
736 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG);
737
738 return ret;
739}
740
741static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
742{
743 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
744
745 if (len < sizeof(struct wmi_ready_event_2))
746 return -EINVAL;
747
748 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
749 le32_to_cpu(ev->sw_version),
750 le32_to_cpu(ev->abi_version), ev->phy_cap);
751
752 return 0;
753}
754
755
756
757
758
759
760
761int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
762{
763 struct sk_buff *skb;
764 struct roam_ctrl_cmd *cmd;
765
766 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
767 if (!skb)
768 return -ENOMEM;
769
770 cmd = (struct roam_ctrl_cmd *) skb->data;
771
772 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
773 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
774 DEF_SCAN_FOR_ROAM_INTVL);
775 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
776 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
777 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
778
779 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
780 NO_SYNC_WMIFLAG);
781}
782
783int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid)
784{
785 struct sk_buff *skb;
786 struct roam_ctrl_cmd *cmd;
787
788 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
789 if (!skb)
790 return -ENOMEM;
791
792 cmd = (struct roam_ctrl_cmd *) skb->data;
793
794 memcpy(cmd->info.bssid, bssid, ETH_ALEN);
795 cmd->roam_ctrl = WMI_FORCE_ROAM;
796
797 ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid);
798 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
799 NO_SYNC_WMIFLAG);
800}
801
802int ath6kl_wmi_ap_set_beacon_intvl_cmd(struct wmi *wmi, u8 if_idx,
803 u32 beacon_intvl)
804{
805 struct sk_buff *skb;
806 struct set_beacon_int_cmd *cmd;
807
808 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
809 if (!skb)
810 return -ENOMEM;
811
812 cmd = (struct set_beacon_int_cmd *) skb->data;
813
814 cmd->beacon_intvl = cpu_to_le32(beacon_intvl);
815 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
816 WMI_SET_BEACON_INT_CMDID, NO_SYNC_WMIFLAG);
817}
818
819int ath6kl_wmi_ap_set_dtim_cmd(struct wmi *wmi, u8 if_idx, u32 dtim_period)
820{
821 struct sk_buff *skb;
822 struct set_dtim_cmd *cmd;
823
824 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
825 if (!skb)
826 return -ENOMEM;
827
828 cmd = (struct set_dtim_cmd *) skb->data;
829
830 cmd->dtim_period = cpu_to_le32(dtim_period);
831 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
832 WMI_AP_SET_DTIM_CMDID, NO_SYNC_WMIFLAG);
833}
834
835int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode)
836{
837 struct sk_buff *skb;
838 struct roam_ctrl_cmd *cmd;
839
840 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
841 if (!skb)
842 return -ENOMEM;
843
844 cmd = (struct roam_ctrl_cmd *) skb->data;
845
846 cmd->info.roam_mode = mode;
847 cmd->roam_ctrl = WMI_SET_ROAM_MODE;
848
849 ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode);
850 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
851 NO_SYNC_WMIFLAG);
852}
853
854static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
855 struct ath6kl_vif *vif)
856{
857 struct wmi_connect_event *ev;
858 u8 *pie, *peie;
859
860 if (len < sizeof(struct wmi_connect_event))
861 return -EINVAL;
862
863 ev = (struct wmi_connect_event *) datap;
864
865 if (vif->nw_type == AP_NETWORK) {
866
867 struct net_device *dev = vif->ndev;
868 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
869 ath6kl_dbg(ATH6KL_DBG_WMI,
870 "%s: freq %d bssid %pM (AP started)\n",
871 __func__, le16_to_cpu(ev->u.ap_bss.ch),
872 ev->u.ap_bss.bssid);
873 ath6kl_connect_ap_mode_bss(
874 vif, le16_to_cpu(ev->u.ap_bss.ch));
875 } else {
876 ath6kl_dbg(ATH6KL_DBG_WMI,
877 "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n",
878 __func__, ev->u.ap_sta.aid,
879 ev->u.ap_sta.mac_addr,
880 ev->u.ap_sta.auth,
881 ev->u.ap_sta.keymgmt,
882 le16_to_cpu(ev->u.ap_sta.cipher),
883 ev->u.ap_sta.apsd_info);
884
885 ath6kl_connect_ap_mode_sta(
886 vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
887 ev->u.ap_sta.keymgmt,
888 le16_to_cpu(ev->u.ap_sta.cipher),
889 ev->u.ap_sta.auth, ev->assoc_req_len,
890 ev->assoc_info + ev->beacon_ie_len,
891 ev->u.ap_sta.apsd_info);
892 }
893 return 0;
894 }
895
896
897
898 ath6kl_dbg(ATH6KL_DBG_WMI,
899 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
900 le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid,
901 le16_to_cpu(ev->u.sta.listen_intvl),
902 le16_to_cpu(ev->u.sta.beacon_intvl),
903 le32_to_cpu(ev->u.sta.nw_type));
904
905
906 pie = ev->assoc_info + ev->beacon_ie_len +
907 ev->assoc_req_len + (sizeof(u16) * 3);
908
909
910 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
911 ev->assoc_resp_len;
912
913 while (pie < peie) {
914 switch (*pie) {
915 case WLAN_EID_VENDOR_SPECIFIC:
916 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
917 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
918
919 if (pie[1] > 5 &&
920 pie[6] == WMM_PARAM_OUI_SUBTYPE)
921 wmi->is_wmm_enabled = true;
922 }
923 break;
924 }
925
926 if (wmi->is_wmm_enabled)
927 break;
928
929 pie += pie[1] + 2;
930 }
931
932 ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch),
933 ev->u.sta.bssid,
934 le16_to_cpu(ev->u.sta.listen_intvl),
935 le16_to_cpu(ev->u.sta.beacon_intvl),
936 le32_to_cpu(ev->u.sta.nw_type),
937 ev->beacon_ie_len, ev->assoc_req_len,
938 ev->assoc_resp_len, ev->assoc_info);
939
940 return 0;
941}
942
943static struct country_code_to_enum_rd *
944ath6kl_regd_find_country(u16 countryCode)
945{
946 int i;
947
948 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
949 if (allCountries[i].countryCode == countryCode)
950 return &allCountries[i];
951 }
952
953 return NULL;
954}
955
956static struct reg_dmn_pair_mapping *
957ath6kl_get_regpair(u16 regdmn)
958{
959 int i;
960
961 if (regdmn == NO_ENUMRD)
962 return NULL;
963
964 for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
965 if (regDomainPairs[i].reg_domain == regdmn)
966 return ®DomainPairs[i];
967 }
968
969 return NULL;
970}
971
972static struct country_code_to_enum_rd *
973ath6kl_regd_find_country_by_rd(u16 regdmn)
974{
975 int i;
976
977 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
978 if (allCountries[i].regDmnEnum == regdmn)
979 return &allCountries[i];
980 }
981
982 return NULL;
983}
984
985static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
986{
987 struct ath6kl_wmi_regdomain *ev;
988 struct country_code_to_enum_rd *country = NULL;
989 struct reg_dmn_pair_mapping *regpair = NULL;
990 char alpha2[2];
991 u32 reg_code;
992
993 ev = (struct ath6kl_wmi_regdomain *) datap;
994 reg_code = le32_to_cpu(ev->reg_code);
995
996 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) {
997 country = ath6kl_regd_find_country((u16) reg_code);
998 } else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
999 regpair = ath6kl_get_regpair((u16) reg_code);
1000 country = ath6kl_regd_find_country_by_rd((u16) reg_code);
1001 if (regpair)
1002 ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
1003 regpair->reg_domain);
1004 else
1005 ath6kl_warn("Regpair not found reg_code 0x%0x\n",
1006 reg_code);
1007 }
1008
1009 if (country && wmi->parent_dev->wiphy_registered) {
1010 alpha2[0] = country->isoName[0];
1011 alpha2[1] = country->isoName[1];
1012
1013 regulatory_hint(wmi->parent_dev->wiphy, alpha2);
1014
1015 ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n",
1016 alpha2[0], alpha2[1]);
1017 }
1018}
1019
1020static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len,
1021 struct ath6kl_vif *vif)
1022{
1023 struct wmi_disconnect_event *ev;
1024 wmi->traffic_class = 100;
1025
1026 if (len < sizeof(struct wmi_disconnect_event))
1027 return -EINVAL;
1028
1029 ev = (struct wmi_disconnect_event *) datap;
1030
1031 ath6kl_dbg(ATH6KL_DBG_WMI,
1032 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
1033 le16_to_cpu(ev->proto_reason_status), ev->bssid,
1034 ev->disconn_reason, ev->assoc_resp_len);
1035
1036 wmi->is_wmm_enabled = false;
1037
1038 ath6kl_disconnect_event(vif, ev->disconn_reason,
1039 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
1040 le16_to_cpu(ev->proto_reason_status));
1041
1042 return 0;
1043}
1044
1045static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
1046{
1047 struct wmi_peer_node_event *ev;
1048
1049 if (len < sizeof(struct wmi_peer_node_event))
1050 return -EINVAL;
1051
1052 ev = (struct wmi_peer_node_event *) datap;
1053
1054 if (ev->event_code == PEER_NODE_JOIN_EVENT)
1055 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
1056 ev->peer_mac_addr);
1057 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
1058 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
1059 ev->peer_mac_addr);
1060
1061 return 0;
1062}
1063
1064static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,
1065 struct ath6kl_vif *vif)
1066{
1067 struct wmi_tkip_micerr_event *ev;
1068
1069 if (len < sizeof(struct wmi_tkip_micerr_event))
1070 return -EINVAL;
1071
1072 ev = (struct wmi_tkip_micerr_event *) datap;
1073
1074 ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);
1075
1076 return 0;
1077}
1078
1079void ath6kl_wmi_sscan_timer(struct timer_list *t)
1080{
1081 struct ath6kl_vif *vif = from_timer(vif, t, sched_scan_timer);
1082
1083 cfg80211_sched_scan_results(vif->ar->wiphy, 0);
1084}
1085
1086static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
1087 struct ath6kl_vif *vif)
1088{
1089 struct wmi_bss_info_hdr2 *bih;
1090 u8 *buf;
1091 struct ieee80211_channel *channel;
1092 struct ath6kl *ar = wmi->parent_dev;
1093 struct cfg80211_bss *bss;
1094
1095 if (len <= sizeof(struct wmi_bss_info_hdr2))
1096 return -EINVAL;
1097
1098 bih = (struct wmi_bss_info_hdr2 *) datap;
1099 buf = datap + sizeof(struct wmi_bss_info_hdr2);
1100 len -= sizeof(struct wmi_bss_info_hdr2);
1101
1102 ath6kl_dbg(ATH6KL_DBG_WMI,
1103 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1104 "frame_type=%d\n",
1105 bih->ch, bih->snr, bih->snr - 95, bih->bssid,
1106 bih->frame_type);
1107
1108 if (bih->frame_type != BEACON_FTYPE &&
1109 bih->frame_type != PROBERESP_FTYPE)
1110 return 0;
1111
1112 if (bih->frame_type == BEACON_FTYPE &&
1113 test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) {
1114 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
1115 ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
1116 NONE_BSS_FILTER, 0);
1117 }
1118
1119 channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch));
1120 if (channel == NULL)
1121 return -EINVAL;
1122
1123 if (len < 8 + 2 + 2)
1124 return -EINVAL;
1125
1126 if (bih->frame_type == BEACON_FTYPE &&
1127 test_bit(CONNECTED, &vif->flags) &&
1128 memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) {
1129 const u8 *tim;
1130 tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2,
1131 len - 8 - 2 - 2);
1132 if (tim && tim[1] >= 2) {
1133 vif->assoc_bss_dtim_period = tim[3];
1134 set_bit(DTIM_PERIOD_AVAIL, &vif->flags);
1135 }
1136 }
1137
1138 bss = cfg80211_inform_bss(ar->wiphy, channel,
1139 bih->frame_type == BEACON_FTYPE ?
1140 CFG80211_BSS_FTYPE_BEACON :
1141 CFG80211_BSS_FTYPE_PRESP,
1142 bih->bssid, get_unaligned_le64((__le64 *)buf),
1143 get_unaligned_le16(((__le16 *)buf) + 5),
1144 get_unaligned_le16(((__le16 *)buf) + 4),
1145 buf + 8 + 2 + 2, len - 8 - 2 - 2,
1146 (bih->snr - 95) * 100, GFP_ATOMIC);
1147 if (bss == NULL)
1148 return -ENOMEM;
1149 cfg80211_put_bss(ar->wiphy, bss);
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160 if (test_bit(SCHED_SCANNING, &vif->flags) &&
1161 !timer_pending(&vif->sched_scan_timer)) {
1162 mod_timer(&vif->sched_scan_timer, jiffies +
1163 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY));
1164 }
1165
1166 return 0;
1167}
1168
1169
1170static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1171 int len)
1172{
1173 struct wmi_pstream_timeout_event *ev;
1174
1175 if (len < sizeof(struct wmi_pstream_timeout_event))
1176 return -EINVAL;
1177
1178 ev = (struct wmi_pstream_timeout_event *) datap;
1179 if (ev->traffic_class >= WMM_NUM_AC) {
1180 ath6kl_err("invalid traffic class: %d\n", ev->traffic_class);
1181 return -EINVAL;
1182 }
1183
1184
1185
1186
1187
1188
1189
1190 spin_lock_bh(&wmi->lock);
1191 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1192 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1193 spin_unlock_bh(&wmi->lock);
1194
1195
1196 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1197
1198 return 0;
1199}
1200
1201static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1202{
1203 struct wmi_bit_rate_reply *reply;
1204 s32 rate;
1205 u32 sgi, index;
1206
1207 if (len < sizeof(struct wmi_bit_rate_reply))
1208 return -EINVAL;
1209
1210 reply = (struct wmi_bit_rate_reply *) datap;
1211
1212 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1213
1214 if (reply->rate_index == (s8) RATE_AUTO) {
1215 rate = RATE_AUTO;
1216 } else {
1217 index = reply->rate_index & 0x7f;
1218 if (WARN_ON_ONCE(index > (RATE_MCS_7_40 + 1)))
1219 return -EINVAL;
1220
1221 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1222 rate = wmi_rate_tbl[index][sgi];
1223 }
1224
1225 ath6kl_wakeup_event(wmi->parent_dev);
1226
1227 return 0;
1228}
1229
1230static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len)
1231{
1232 ath6kl_tm_rx_event(wmi->parent_dev, datap, len);
1233
1234 return 0;
1235}
1236
1237static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1238{
1239 if (len < sizeof(struct wmi_fix_rates_reply))
1240 return -EINVAL;
1241
1242 ath6kl_wakeup_event(wmi->parent_dev);
1243
1244 return 0;
1245}
1246
1247static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1248{
1249 if (len < sizeof(struct wmi_channel_list_reply))
1250 return -EINVAL;
1251
1252 ath6kl_wakeup_event(wmi->parent_dev);
1253
1254 return 0;
1255}
1256
1257static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1258{
1259 struct wmi_tx_pwr_reply *reply;
1260
1261 if (len < sizeof(struct wmi_tx_pwr_reply))
1262 return -EINVAL;
1263
1264 reply = (struct wmi_tx_pwr_reply *) datap;
1265 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1266
1267 return 0;
1268}
1269
1270static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1271{
1272 if (len < sizeof(struct wmi_get_keepalive_cmd))
1273 return -EINVAL;
1274
1275 ath6kl_wakeup_event(wmi->parent_dev);
1276
1277 return 0;
1278}
1279
1280static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len,
1281 struct ath6kl_vif *vif)
1282{
1283 struct wmi_scan_complete_event *ev;
1284
1285 ev = (struct wmi_scan_complete_event *) datap;
1286
1287 ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status));
1288 wmi->is_probe_ssid = false;
1289
1290 return 0;
1291}
1292
1293static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap,
1294 int len, struct ath6kl_vif *vif)
1295{
1296 struct wmi_neighbor_report_event *ev;
1297 u8 i;
1298
1299 if (len < sizeof(*ev))
1300 return -EINVAL;
1301 ev = (struct wmi_neighbor_report_event *) datap;
1302 if (struct_size(ev, neighbor, ev->num_neighbors) > len) {
1303 ath6kl_dbg(ATH6KL_DBG_WMI,
1304 "truncated neighbor event (num=%d len=%d)\n",
1305 ev->num_neighbors, len);
1306 return -EINVAL;
1307 }
1308 for (i = 0; i < ev->num_neighbors; i++) {
1309 ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n",
1310 i + 1, ev->num_neighbors, ev->neighbor[i].bssid,
1311 ev->neighbor[i].bss_flags);
1312 cfg80211_pmksa_candidate_notify(vif->ndev, i,
1313 ev->neighbor[i].bssid,
1314 !!(ev->neighbor[i].bss_flags &
1315 WMI_PREAUTH_CAPABLE_BSS),
1316 GFP_ATOMIC);
1317 }
1318
1319 return 0;
1320}
1321
1322
1323
1324
1325
1326
1327
1328
1329static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1330{
1331 const char *type = "unknown error";
1332 struct wmi_cmd_error_event *ev;
1333 ev = (struct wmi_cmd_error_event *) datap;
1334
1335 switch (ev->err_code) {
1336 case INVALID_PARAM:
1337 type = "invalid parameter";
1338 break;
1339 case ILLEGAL_STATE:
1340 type = "invalid state";
1341 break;
1342 case INTERNAL_ERROR:
1343 type = "internal error";
1344 break;
1345 }
1346
1347 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1348 ev->cmd_id, type);
1349
1350 return 0;
1351}
1352
1353static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len,
1354 struct ath6kl_vif *vif)
1355{
1356 ath6kl_tgt_stats_event(vif, datap, len);
1357
1358 return 0;
1359}
1360
1361static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1362 struct sq_threshold_params *sq_thresh,
1363 u32 size)
1364{
1365 u32 index;
1366 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1367
1368
1369 for (index = 0; index < size; index++) {
1370 if (rssi < sq_thresh->upper_threshold[index]) {
1371 threshold = (u8) sq_thresh->upper_threshold[index];
1372 break;
1373 }
1374 }
1375
1376 return threshold;
1377}
1378
1379static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1380 struct sq_threshold_params *sq_thresh,
1381 u32 size)
1382{
1383 u32 index;
1384 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1385
1386
1387 for (index = 0; index < size; index++) {
1388 if (rssi > sq_thresh->lower_threshold[index]) {
1389 threshold = (u8) sq_thresh->lower_threshold[index];
1390 break;
1391 }
1392 }
1393
1394 return threshold;
1395}
1396
1397static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1398 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1399{
1400 struct sk_buff *skb;
1401 struct wmi_rssi_threshold_params_cmd *cmd;
1402
1403 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1404 if (!skb)
1405 return -ENOMEM;
1406
1407 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1408 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1409
1410 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
1411 NO_SYNC_WMIFLAG);
1412}
1413
1414static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1415 int len)
1416{
1417 struct wmi_rssi_threshold_event *reply;
1418 struct wmi_rssi_threshold_params_cmd cmd;
1419 struct sq_threshold_params *sq_thresh;
1420 enum wmi_rssi_threshold_val new_threshold;
1421 u8 upper_rssi_threshold, lower_rssi_threshold;
1422 s16 rssi;
1423 int ret;
1424
1425 if (len < sizeof(struct wmi_rssi_threshold_event))
1426 return -EINVAL;
1427
1428 reply = (struct wmi_rssi_threshold_event *) datap;
1429 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1430 rssi = a_sle16_to_cpu(reply->rssi);
1431
1432 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1433
1434
1435
1436
1437
1438
1439 if (new_threshold) {
1440
1441 if (rssi < sq_thresh->upper_threshold[0]) {
1442 ath6kl_dbg(ATH6KL_DBG_WMI,
1443 "spurious upper rssi threshold event: %d\n",
1444 rssi);
1445 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1446 (rssi >= sq_thresh->upper_threshold[0])) {
1447 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1448 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1449 (rssi >= sq_thresh->upper_threshold[1])) {
1450 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1451 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1452 (rssi >= sq_thresh->upper_threshold[2])) {
1453 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1454 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1455 (rssi >= sq_thresh->upper_threshold[3])) {
1456 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1457 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1458 (rssi >= sq_thresh->upper_threshold[4])) {
1459 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1460 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1461 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1462 }
1463 } else {
1464
1465 if (rssi > sq_thresh->lower_threshold[0]) {
1466 ath6kl_dbg(ATH6KL_DBG_WMI,
1467 "spurious lower rssi threshold event: %d %d\n",
1468 rssi, sq_thresh->lower_threshold[0]);
1469 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1470 (rssi <= sq_thresh->lower_threshold[0])) {
1471 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1472 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1473 (rssi <= sq_thresh->lower_threshold[1])) {
1474 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1475 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1476 (rssi <= sq_thresh->lower_threshold[2])) {
1477 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1478 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1479 (rssi <= sq_thresh->lower_threshold[3])) {
1480 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1481 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1482 (rssi <= sq_thresh->lower_threshold[4])) {
1483 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1484 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1485 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1486 }
1487 }
1488
1489
1490 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1491 sq_thresh->lower_threshold_valid_count);
1492 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1493 sq_thresh->upper_threshold_valid_count);
1494
1495
1496 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1497 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1498 cmd.weight = sq_thresh->weight;
1499 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1500
1501 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1502 if (ret) {
1503 ath6kl_err("unable to configure rssi thresholds\n");
1504 return -EIO;
1505 }
1506
1507 return 0;
1508}
1509
1510static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1511 struct ath6kl_vif *vif)
1512{
1513 struct wmi_cac_event *reply;
1514 struct ieee80211_tspec_ie *ts;
1515 u16 active_tsids, tsinfo;
1516 u8 tsid, index;
1517 u8 ts_id;
1518
1519 if (len < sizeof(struct wmi_cac_event))
1520 return -EINVAL;
1521
1522 reply = (struct wmi_cac_event *) datap;
1523 if (reply->ac >= WMM_NUM_AC) {
1524 ath6kl_err("invalid AC: %d\n", reply->ac);
1525 return -EINVAL;
1526 }
1527
1528 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1529 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1530 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1531 tsinfo = le16_to_cpu(ts->tsinfo);
1532 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1533 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1534
1535 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1536 reply->ac, tsid);
1537 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1538
1539
1540
1541
1542 spin_lock_bh(&wmi->lock);
1543 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1544 spin_unlock_bh(&wmi->lock);
1545
1546 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1547 if ((active_tsids >> index) & 1)
1548 break;
1549 }
1550 if (index < (sizeof(active_tsids) * 8))
1551 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1552 reply->ac, index);
1553 }
1554
1555
1556
1557
1558
1559 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1560 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1561 tsinfo = le16_to_cpu(ts->tsinfo);
1562 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1563 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1564
1565 spin_lock_bh(&wmi->lock);
1566 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1567 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1568 spin_unlock_bh(&wmi->lock);
1569
1570
1571
1572
1573 if (!active_tsids) {
1574 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1575 false);
1576 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1577 }
1578 }
1579
1580 return 0;
1581}
1582
1583static int ath6kl_wmi_txe_notify_event_rx(struct wmi *wmi, u8 *datap, int len,
1584 struct ath6kl_vif *vif)
1585{
1586 struct wmi_txe_notify_event *ev;
1587 u32 rate, pkts;
1588
1589 if (len < sizeof(*ev))
1590 return -EINVAL;
1591
1592 if (vif->nw_type != INFRA_NETWORK ||
1593 !test_bit(ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY,
1594 vif->ar->fw_capabilities))
1595 return -EOPNOTSUPP;
1596
1597 if (vif->sme_state != SME_CONNECTED)
1598 return -ENOTCONN;
1599
1600 ev = (struct wmi_txe_notify_event *) datap;
1601 rate = le32_to_cpu(ev->rate);
1602 pkts = le32_to_cpu(ev->pkts);
1603
1604 ath6kl_dbg(ATH6KL_DBG_WMI, "TXE notify event: peer %pM rate %d%% pkts %d intvl %ds\n",
1605 vif->bssid, rate, pkts, vif->txe_intvl);
1606
1607 cfg80211_cqm_txe_notify(vif->ndev, vif->bssid, pkts,
1608 rate, vif->txe_intvl, GFP_KERNEL);
1609
1610 return 0;
1611}
1612
1613int ath6kl_wmi_set_txe_notify(struct wmi *wmi, u8 idx,
1614 u32 rate, u32 pkts, u32 intvl)
1615{
1616 struct sk_buff *skb;
1617 struct wmi_txe_notify_cmd *cmd;
1618
1619 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1620 if (!skb)
1621 return -ENOMEM;
1622
1623 cmd = (struct wmi_txe_notify_cmd *) skb->data;
1624 cmd->rate = cpu_to_le32(rate);
1625 cmd->pkts = cpu_to_le32(pkts);
1626 cmd->intvl = cpu_to_le32(intvl);
1627
1628 return ath6kl_wmi_cmd_send(wmi, idx, skb, WMI_SET_TXE_NOTIFY_CMDID,
1629 NO_SYNC_WMIFLAG);
1630}
1631
1632int ath6kl_wmi_set_rssi_filter_cmd(struct wmi *wmi, u8 if_idx, s8 rssi)
1633{
1634 struct sk_buff *skb;
1635 struct wmi_set_rssi_filter_cmd *cmd;
1636 int ret;
1637
1638 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1639 if (!skb)
1640 return -ENOMEM;
1641
1642 cmd = (struct wmi_set_rssi_filter_cmd *) skb->data;
1643 cmd->rssi = rssi;
1644
1645 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_RSSI_FILTER_CMDID,
1646 NO_SYNC_WMIFLAG);
1647 return ret;
1648}
1649
1650static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1651 struct wmi_snr_threshold_params_cmd *snr_cmd)
1652{
1653 struct sk_buff *skb;
1654 struct wmi_snr_threshold_params_cmd *cmd;
1655
1656 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1657 if (!skb)
1658 return -ENOMEM;
1659
1660 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1661 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1662
1663 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
1664 NO_SYNC_WMIFLAG);
1665}
1666
1667static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1668 int len)
1669{
1670 struct wmi_snr_threshold_event *reply;
1671 struct sq_threshold_params *sq_thresh;
1672 struct wmi_snr_threshold_params_cmd cmd;
1673 enum wmi_snr_threshold_val new_threshold;
1674 u8 upper_snr_threshold, lower_snr_threshold;
1675 s16 snr;
1676 int ret;
1677
1678 if (len < sizeof(struct wmi_snr_threshold_event))
1679 return -EINVAL;
1680
1681 reply = (struct wmi_snr_threshold_event *) datap;
1682
1683 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1684 snr = reply->snr;
1685
1686 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1687
1688
1689
1690
1691
1692
1693 if (new_threshold) {
1694
1695 if (snr < sq_thresh->upper_threshold[0]) {
1696 ath6kl_dbg(ATH6KL_DBG_WMI,
1697 "spurious upper snr threshold event: %d\n",
1698 snr);
1699 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1700 (snr >= sq_thresh->upper_threshold[0])) {
1701 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1702 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1703 (snr >= sq_thresh->upper_threshold[1])) {
1704 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1705 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1706 (snr >= sq_thresh->upper_threshold[2])) {
1707 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1708 } else if (snr >= sq_thresh->upper_threshold[3]) {
1709 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1710 }
1711 } else {
1712
1713 if (snr > sq_thresh->lower_threshold[0]) {
1714 ath6kl_dbg(ATH6KL_DBG_WMI,
1715 "spurious lower snr threshold event: %d\n",
1716 sq_thresh->lower_threshold[0]);
1717 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1718 (snr <= sq_thresh->lower_threshold[0])) {
1719 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1720 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1721 (snr <= sq_thresh->lower_threshold[1])) {
1722 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1723 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1724 (snr <= sq_thresh->lower_threshold[2])) {
1725 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1726 } else if (snr <= sq_thresh->lower_threshold[3]) {
1727 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1728 }
1729 }
1730
1731
1732 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1733 sq_thresh->lower_threshold_valid_count);
1734 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1735 sq_thresh->upper_threshold_valid_count);
1736
1737
1738 cmd.thresh_above1_val = upper_snr_threshold;
1739 cmd.thresh_below1_val = lower_snr_threshold;
1740 cmd.weight = sq_thresh->weight;
1741 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1742
1743 ath6kl_dbg(ATH6KL_DBG_WMI,
1744 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1745 snr, new_threshold,
1746 lower_snr_threshold, upper_snr_threshold);
1747
1748 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1749 if (ret) {
1750 ath6kl_err("unable to configure snr threshold\n");
1751 return -EIO;
1752 }
1753
1754 return 0;
1755}
1756
1757static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1758{
1759 u16 ap_info_entry_size;
1760 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1761 struct wmi_ap_info_v1 *ap_info_v1;
1762 u8 index;
1763
1764 if (len < sizeof(struct wmi_aplist_event) ||
1765 ev->ap_list_ver != APLIST_VER1)
1766 return -EINVAL;
1767
1768 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1769 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1770
1771 ath6kl_dbg(ATH6KL_DBG_WMI,
1772 "number of APs in aplist event: %d\n", ev->num_ap);
1773
1774 if (len < (int) (sizeof(struct wmi_aplist_event) +
1775 (ev->num_ap - 1) * ap_info_entry_size))
1776 return -EINVAL;
1777
1778
1779 for (index = 0; index < ev->num_ap; index++) {
1780 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1781 index, ap_info_v1->bssid, ap_info_v1->channel);
1782 ap_info_v1++;
1783 }
1784
1785 return 0;
1786}
1787
1788int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb,
1789 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1790{
1791 struct wmi_cmd_hdr *cmd_hdr;
1792 enum htc_endpoint_id ep_id = wmi->ep_id;
1793 int ret;
1794 u16 info1;
1795
1796 if (WARN_ON(skb == NULL ||
1797 (if_idx > (wmi->parent_dev->vif_max - 1)))) {
1798 dev_kfree_skb(skb);
1799 return -EINVAL;
1800 }
1801
1802 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n",
1803 cmd_id, skb->len, sync_flag);
1804 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ",
1805 skb->data, skb->len);
1806
1807 if (sync_flag >= END_WMIFLAG) {
1808 dev_kfree_skb(skb);
1809 return -EINVAL;
1810 }
1811
1812 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1813 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1814
1815
1816
1817
1818 ath6kl_wmi_sync_point(wmi, if_idx);
1819 }
1820
1821 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1822
1823 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1824 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
1825 info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK;
1826 cmd_hdr->info1 = cpu_to_le16(info1);
1827
1828
1829 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1830 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
1831 false, false, 0, NULL, if_idx);
1832 if (ret) {
1833 dev_kfree_skb(skb);
1834 return ret;
1835 }
1836 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1837 }
1838
1839 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1840
1841 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1842 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1843
1844
1845
1846
1847 ath6kl_wmi_sync_point(wmi, if_idx);
1848 }
1849
1850 return 0;
1851}
1852
1853int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx,
1854 enum network_type nw_type,
1855 enum dot11_auth_mode dot11_auth_mode,
1856 enum auth_mode auth_mode,
1857 enum ath6kl_crypto_type pairwise_crypto,
1858 u8 pairwise_crypto_len,
1859 enum ath6kl_crypto_type group_crypto,
1860 u8 group_crypto_len, int ssid_len, u8 *ssid,
1861 u8 *bssid, u16 channel, u32 ctrl_flags,
1862 u8 nw_subtype)
1863{
1864 struct sk_buff *skb;
1865 struct wmi_connect_cmd *cc;
1866 int ret;
1867
1868 ath6kl_dbg(ATH6KL_DBG_WMI,
1869 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1870 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1871 bssid, channel, ctrl_flags, ssid_len, nw_type,
1872 dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto);
1873 ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len);
1874
1875 wmi->traffic_class = 100;
1876
1877 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1878 return -EINVAL;
1879
1880 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1881 return -EINVAL;
1882
1883 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1884 if (!skb)
1885 return -ENOMEM;
1886
1887 cc = (struct wmi_connect_cmd *) skb->data;
1888
1889 if (ssid_len)
1890 memcpy(cc->ssid, ssid, ssid_len);
1891
1892 cc->ssid_len = ssid_len;
1893 cc->nw_type = nw_type;
1894 cc->dot11_auth_mode = dot11_auth_mode;
1895 cc->auth_mode = auth_mode;
1896 cc->prwise_crypto_type = pairwise_crypto;
1897 cc->prwise_crypto_len = pairwise_crypto_len;
1898 cc->grp_crypto_type = group_crypto;
1899 cc->grp_crypto_len = group_crypto_len;
1900 cc->ch = cpu_to_le16(channel);
1901 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
1902 cc->nw_subtype = nw_subtype;
1903
1904 if (bssid != NULL)
1905 memcpy(cc->bssid, bssid, ETH_ALEN);
1906
1907 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID,
1908 NO_SYNC_WMIFLAG);
1909
1910 return ret;
1911}
1912
1913int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid,
1914 u16 channel)
1915{
1916 struct sk_buff *skb;
1917 struct wmi_reconnect_cmd *cc;
1918 int ret;
1919
1920 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n",
1921 bssid, channel);
1922
1923 wmi->traffic_class = 100;
1924
1925 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1926 if (!skb)
1927 return -ENOMEM;
1928
1929 cc = (struct wmi_reconnect_cmd *) skb->data;
1930 cc->channel = cpu_to_le16(channel);
1931
1932 if (bssid != NULL)
1933 memcpy(cc->bssid, bssid, ETH_ALEN);
1934
1935 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID,
1936 NO_SYNC_WMIFLAG);
1937
1938 return ret;
1939}
1940
1941int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx)
1942{
1943 int ret;
1944
1945 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n");
1946
1947 wmi->traffic_class = 100;
1948
1949
1950 ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID);
1951
1952 return ret;
1953}
1954
1955
1956
1957
1958
1959static int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx,
1960 enum wmi_scan_type scan_type,
1961 u32 force_fgscan, u32 is_legacy,
1962 u32 home_dwell_time,
1963 u32 force_scan_interval,
1964 s8 num_chan, u16 *ch_list)
1965{
1966 struct sk_buff *skb;
1967 struct wmi_start_scan_cmd *sc;
1968 s8 size;
1969 int i, ret;
1970
1971 size = sizeof(struct wmi_start_scan_cmd);
1972
1973 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1974 return -EINVAL;
1975
1976 if (num_chan > WMI_MAX_CHANNELS)
1977 return -EINVAL;
1978
1979 if (num_chan)
1980 size += sizeof(u16) * (num_chan - 1);
1981
1982 skb = ath6kl_wmi_get_new_buf(size);
1983 if (!skb)
1984 return -ENOMEM;
1985
1986 sc = (struct wmi_start_scan_cmd *) skb->data;
1987 sc->scan_type = scan_type;
1988 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1989 sc->is_legacy = cpu_to_le32(is_legacy);
1990 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1991 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1992 sc->num_ch = num_chan;
1993
1994 for (i = 0; i < num_chan; i++)
1995 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
1996
1997 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID,
1998 NO_SYNC_WMIFLAG);
1999
2000 return ret;
2001}
2002
2003
2004
2005
2006
2007
2008int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx,
2009 enum wmi_scan_type scan_type,
2010 u32 force_fgscan, u32 is_legacy,
2011 u32 home_dwell_time, u32 force_scan_interval,
2012 s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
2013{
2014 struct ieee80211_supported_band *sband;
2015 struct sk_buff *skb;
2016 struct wmi_begin_scan_cmd *sc;
2017 s8 size, *supp_rates;
2018 int i, band, ret;
2019 struct ath6kl *ar = wmi->parent_dev;
2020 int num_rates;
2021 u32 ratemask;
2022
2023 if (!test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
2024 ar->fw_capabilities)) {
2025 return ath6kl_wmi_startscan_cmd(wmi, if_idx,
2026 scan_type, force_fgscan,
2027 is_legacy, home_dwell_time,
2028 force_scan_interval,
2029 num_chan, ch_list);
2030 }
2031
2032 size = sizeof(struct wmi_begin_scan_cmd);
2033
2034 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
2035 return -EINVAL;
2036
2037 if (num_chan > WMI_MAX_CHANNELS)
2038 return -EINVAL;
2039
2040 if (num_chan)
2041 size += sizeof(u16) * (num_chan - 1);
2042
2043 skb = ath6kl_wmi_get_new_buf(size);
2044 if (!skb)
2045 return -ENOMEM;
2046
2047 sc = (struct wmi_begin_scan_cmd *) skb->data;
2048 sc->scan_type = scan_type;
2049 sc->force_fg_scan = cpu_to_le32(force_fgscan);
2050 sc->is_legacy = cpu_to_le32(is_legacy);
2051 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
2052 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
2053 sc->no_cck = cpu_to_le32(no_cck);
2054 sc->num_ch = num_chan;
2055
2056 for (band = 0; band < NUM_NL80211_BANDS; band++) {
2057 sband = ar->wiphy->bands[band];
2058
2059 if (!sband)
2060 continue;
2061
2062 if (WARN_ON(band >= ATH6KL_NUM_BANDS))
2063 break;
2064
2065 ratemask = rates[band];
2066 supp_rates = sc->supp_rates[band].rates;
2067 num_rates = 0;
2068
2069 for (i = 0; i < sband->n_bitrates; i++) {
2070 if ((BIT(i) & ratemask) == 0)
2071 continue;
2072 supp_rates[num_rates++] =
2073 (u8) (sband->bitrates[i].bitrate / 5);
2074 }
2075 sc->supp_rates[band].nrates = num_rates;
2076 }
2077
2078 for (i = 0; i < num_chan; i++)
2079 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
2080
2081 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID,
2082 NO_SYNC_WMIFLAG);
2083
2084 return ret;
2085}
2086
2087int ath6kl_wmi_enable_sched_scan_cmd(struct wmi *wmi, u8 if_idx, bool enable)
2088{
2089 struct sk_buff *skb;
2090 struct wmi_enable_sched_scan_cmd *sc;
2091 int ret;
2092
2093 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
2094 if (!skb)
2095 return -ENOMEM;
2096
2097 ath6kl_dbg(ATH6KL_DBG_WMI, "%s scheduled scan on vif %d\n",
2098 enable ? "enabling" : "disabling", if_idx);
2099 sc = (struct wmi_enable_sched_scan_cmd *) skb->data;
2100 sc->enable = enable ? 1 : 0;
2101
2102 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2103 WMI_ENABLE_SCHED_SCAN_CMDID,
2104 NO_SYNC_WMIFLAG);
2105 return ret;
2106}
2107
2108int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx,
2109 u16 fg_start_sec,
2110 u16 fg_end_sec, u16 bg_sec,
2111 u16 minact_chdw_msec, u16 maxact_chdw_msec,
2112 u16 pas_chdw_msec, u8 short_scan_ratio,
2113 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
2114 u16 maxact_scan_per_ssid)
2115{
2116 struct sk_buff *skb;
2117 struct wmi_scan_params_cmd *sc;
2118 int ret;
2119
2120 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
2121 if (!skb)
2122 return -ENOMEM;
2123
2124 sc = (struct wmi_scan_params_cmd *) skb->data;
2125 sc->fg_start_period = cpu_to_le16(fg_start_sec);
2126 sc->fg_end_period = cpu_to_le16(fg_end_sec);
2127 sc->bg_period = cpu_to_le16(bg_sec);
2128 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
2129 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
2130 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
2131 sc->short_scan_ratio = short_scan_ratio;
2132 sc->scan_ctrl_flags = scan_ctrl_flag;
2133 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
2134 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
2135
2136 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID,
2137 NO_SYNC_WMIFLAG);
2138 return ret;
2139}
2140
2141int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask)
2142{
2143 struct sk_buff *skb;
2144 struct wmi_bss_filter_cmd *cmd;
2145 int ret;
2146
2147 if (filter >= LAST_BSS_FILTER)
2148 return -EINVAL;
2149
2150 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2151 if (!skb)
2152 return -ENOMEM;
2153
2154 cmd = (struct wmi_bss_filter_cmd *) skb->data;
2155 cmd->bss_filter = filter;
2156 cmd->ie_mask = cpu_to_le32(ie_mask);
2157
2158 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID,
2159 NO_SYNC_WMIFLAG);
2160 return ret;
2161}
2162
2163int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag,
2164 u8 ssid_len, u8 *ssid)
2165{
2166 struct sk_buff *skb;
2167 struct wmi_probed_ssid_cmd *cmd;
2168 int ret;
2169
2170 if (index >= MAX_PROBED_SSIDS)
2171 return -EINVAL;
2172
2173 if (ssid_len > sizeof(cmd->ssid))
2174 return -EINVAL;
2175
2176 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
2177 return -EINVAL;
2178
2179 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
2180 return -EINVAL;
2181
2182 if (flag & SPECIFIC_SSID_FLAG)
2183 wmi->is_probe_ssid = true;
2184
2185 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2186 if (!skb)
2187 return -ENOMEM;
2188
2189 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
2190 cmd->entry_index = index;
2191 cmd->flag = flag;
2192 cmd->ssid_len = ssid_len;
2193 memcpy(cmd->ssid, ssid, ssid_len);
2194
2195 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID,
2196 NO_SYNC_WMIFLAG);
2197 return ret;
2198}
2199
2200int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx,
2201 u16 listen_interval,
2202 u16 listen_beacons)
2203{
2204 struct sk_buff *skb;
2205 struct wmi_listen_int_cmd *cmd;
2206 int ret;
2207
2208 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2209 if (!skb)
2210 return -ENOMEM;
2211
2212 cmd = (struct wmi_listen_int_cmd *) skb->data;
2213 cmd->listen_intvl = cpu_to_le16(listen_interval);
2214 cmd->num_beacons = cpu_to_le16(listen_beacons);
2215
2216 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID,
2217 NO_SYNC_WMIFLAG);
2218 return ret;
2219}
2220
2221int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx,
2222 u16 bmiss_time, u16 num_beacons)
2223{
2224 struct sk_buff *skb;
2225 struct wmi_bmiss_time_cmd *cmd;
2226 int ret;
2227
2228 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2229 if (!skb)
2230 return -ENOMEM;
2231
2232 cmd = (struct wmi_bmiss_time_cmd *) skb->data;
2233 cmd->bmiss_time = cpu_to_le16(bmiss_time);
2234 cmd->num_beacons = cpu_to_le16(num_beacons);
2235
2236 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BMISS_TIME_CMDID,
2237 NO_SYNC_WMIFLAG);
2238 return ret;
2239}
2240
2241int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode)
2242{
2243 struct sk_buff *skb;
2244 struct wmi_power_mode_cmd *cmd;
2245 int ret;
2246
2247 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2248 if (!skb)
2249 return -ENOMEM;
2250
2251 cmd = (struct wmi_power_mode_cmd *) skb->data;
2252 cmd->pwr_mode = pwr_mode;
2253 wmi->pwr_mode = pwr_mode;
2254
2255 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID,
2256 NO_SYNC_WMIFLAG);
2257 return ret;
2258}
2259
2260int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period,
2261 u16 ps_poll_num, u16 dtim_policy,
2262 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
2263 u16 ps_fail_event_policy)
2264{
2265 struct sk_buff *skb;
2266 struct wmi_power_params_cmd *pm;
2267 int ret;
2268
2269 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
2270 if (!skb)
2271 return -ENOMEM;
2272
2273 pm = (struct wmi_power_params_cmd *)skb->data;
2274 pm->idle_period = cpu_to_le16(idle_period);
2275 pm->pspoll_number = cpu_to_le16(ps_poll_num);
2276 pm->dtim_policy = cpu_to_le16(dtim_policy);
2277 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
2278 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
2279 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
2280
2281 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID,
2282 NO_SYNC_WMIFLAG);
2283 return ret;
2284}
2285
2286int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout)
2287{
2288 struct sk_buff *skb;
2289 struct wmi_disc_timeout_cmd *cmd;
2290 int ret;
2291
2292 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2293 if (!skb)
2294 return -ENOMEM;
2295
2296 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
2297 cmd->discon_timeout = timeout;
2298
2299 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID,
2300 NO_SYNC_WMIFLAG);
2301
2302 if (ret == 0)
2303 ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout);
2304
2305 return ret;
2306}
2307
2308int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
2309 enum ath6kl_crypto_type key_type,
2310 u8 key_usage, u8 key_len,
2311 u8 *key_rsc, unsigned int key_rsc_len,
2312 u8 *key_material,
2313 u8 key_op_ctrl, u8 *mac_addr,
2314 enum wmi_sync_flag sync_flag)
2315{
2316 struct sk_buff *skb;
2317 struct wmi_add_cipher_key_cmd *cmd;
2318 int ret;
2319
2320 ath6kl_dbg(ATH6KL_DBG_WMI,
2321 "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n",
2322 key_index, key_type, key_usage, key_len, key_op_ctrl);
2323
2324 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
2325 (key_material == NULL) || key_rsc_len > 8)
2326 return -EINVAL;
2327
2328 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
2329 return -EINVAL;
2330
2331 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2332 if (!skb)
2333 return -ENOMEM;
2334
2335 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
2336 cmd->key_index = key_index;
2337 cmd->key_type = key_type;
2338 cmd->key_usage = key_usage;
2339 cmd->key_len = key_len;
2340 memcpy(cmd->key, key_material, key_len);
2341
2342 if (key_rsc != NULL)
2343 memcpy(cmd->key_rsc, key_rsc, key_rsc_len);
2344
2345 cmd->key_op_ctrl = key_op_ctrl;
2346
2347 if (mac_addr)
2348 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
2349
2350 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID,
2351 sync_flag);
2352
2353 return ret;
2354}
2355
2356int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, const u8 *krk)
2357{
2358 struct sk_buff *skb;
2359 struct wmi_add_krk_cmd *cmd;
2360 int ret;
2361
2362 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2363 if (!skb)
2364 return -ENOMEM;
2365
2366 cmd = (struct wmi_add_krk_cmd *) skb->data;
2367 memcpy(cmd->krk, krk, WMI_KRK_LEN);
2368
2369 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID,
2370 NO_SYNC_WMIFLAG);
2371
2372 return ret;
2373}
2374
2375int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index)
2376{
2377 struct sk_buff *skb;
2378 struct wmi_delete_cipher_key_cmd *cmd;
2379 int ret;
2380
2381 if (key_index > WMI_MAX_KEY_INDEX)
2382 return -EINVAL;
2383
2384 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2385 if (!skb)
2386 return -ENOMEM;
2387
2388 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
2389 cmd->key_index = key_index;
2390
2391 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID,
2392 NO_SYNC_WMIFLAG);
2393
2394 return ret;
2395}
2396
2397int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
2398 const u8 *pmkid, bool set)
2399{
2400 struct sk_buff *skb;
2401 struct wmi_setpmkid_cmd *cmd;
2402 int ret;
2403
2404 if (bssid == NULL)
2405 return -EINVAL;
2406
2407 if (set && pmkid == NULL)
2408 return -EINVAL;
2409
2410 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2411 if (!skb)
2412 return -ENOMEM;
2413
2414 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2415 memcpy(cmd->bssid, bssid, ETH_ALEN);
2416 if (set) {
2417 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2418 cmd->enable = PMKID_ENABLE;
2419 } else {
2420 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2421 cmd->enable = PMKID_DISABLE;
2422 }
2423
2424 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID,
2425 NO_SYNC_WMIFLAG);
2426
2427 return ret;
2428}
2429
2430static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
2431 enum htc_endpoint_id ep_id, u8 if_idx)
2432{
2433 struct wmi_data_hdr *data_hdr;
2434 int ret;
2435
2436 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) {
2437 dev_kfree_skb(skb);
2438 return -EINVAL;
2439 }
2440
2441 skb_push(skb, sizeof(struct wmi_data_hdr));
2442
2443 data_hdr = (struct wmi_data_hdr *) skb->data;
2444 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
2445 data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
2446
2447 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2448
2449 return ret;
2450}
2451
2452static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
2453{
2454 struct sk_buff *skb;
2455 struct wmi_sync_cmd *cmd;
2456 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2457 enum htc_endpoint_id ep_id;
2458 u8 index, num_pri_streams = 0;
2459 int ret = 0;
2460
2461 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2462
2463 spin_lock_bh(&wmi->lock);
2464
2465 for (index = 0; index < WMM_NUM_AC; index++) {
2466 if (wmi->fat_pipe_exist & (1 << index)) {
2467 num_pri_streams++;
2468 data_sync_bufs[num_pri_streams - 1].traffic_class =
2469 index;
2470 }
2471 }
2472
2473 spin_unlock_bh(&wmi->lock);
2474
2475 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2476 if (!skb)
2477 return -ENOMEM;
2478
2479 cmd = (struct wmi_sync_cmd *) skb->data;
2480
2481
2482
2483
2484
2485 cmd->data_sync_map = wmi->fat_pipe_exist;
2486
2487 for (index = 0; index < num_pri_streams; index++) {
2488 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2489 if (data_sync_bufs[index].skb == NULL) {
2490 ret = -ENOMEM;
2491 break;
2492 }
2493 }
2494
2495
2496
2497
2498
2499 if (ret)
2500 goto free_cmd_skb;
2501
2502
2503
2504
2505
2506 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID,
2507 NO_SYNC_WMIFLAG);
2508
2509 if (ret)
2510 goto free_data_skb;
2511
2512 for (index = 0; index < num_pri_streams; index++) {
2513 if (WARN_ON(!data_sync_bufs[index].skb))
2514 goto free_data_skb;
2515
2516 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2517 data_sync_bufs[index].
2518 traffic_class);
2519 ret =
2520 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
2521 ep_id, if_idx);
2522
2523 data_sync_bufs[index].skb = NULL;
2524
2525 if (ret)
2526 goto free_data_skb;
2527 }
2528
2529 return 0;
2530
2531free_cmd_skb:
2532
2533 dev_kfree_skb(skb);
2534
2535free_data_skb:
2536 for (index = 0; index < num_pri_streams; index++)
2537 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].skb);
2538
2539 return ret;
2540}
2541
2542int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx,
2543 struct wmi_create_pstream_cmd *params)
2544{
2545 struct sk_buff *skb;
2546 struct wmi_create_pstream_cmd *cmd;
2547 u8 fatpipe_exist_for_ac = 0;
2548 s32 min_phy = 0;
2549 s32 nominal_phy = 0;
2550 int ret;
2551
2552 if (!((params->user_pri <= 0x7) &&
2553 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2554 (params->traffic_direc == UPLINK_TRAFFIC ||
2555 params->traffic_direc == DNLINK_TRAFFIC ||
2556 params->traffic_direc == BIDIR_TRAFFIC) &&
2557 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2558 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2559 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2560 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2561 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2562 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2563 params->tsid <= WMI_MAX_THINSTREAM))) {
2564 return -EINVAL;
2565 }
2566
2567
2568
2569
2570
2571
2572
2573 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2574
2575
2576 if (params->nominal_phy >= min_phy) {
2577
2578 nominal_phy = (params->nominal_phy * 1000) / 500;
2579 ath6kl_dbg(ATH6KL_DBG_WMI,
2580 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2581 min_phy, nominal_phy);
2582
2583 params->nominal_phy = nominal_phy;
2584 } else {
2585 params->nominal_phy = 0;
2586 }
2587
2588 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2589 if (!skb)
2590 return -ENOMEM;
2591
2592 ath6kl_dbg(ATH6KL_DBG_WMI,
2593 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2594 params->traffic_class, params->tsid);
2595
2596 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2597 memcpy(cmd, params, sizeof(*cmd));
2598
2599
2600 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2601 spin_lock_bh(&wmi->lock);
2602 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2603 (1 << params->traffic_class));
2604 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2605 spin_unlock_bh(&wmi->lock);
2606 } else {
2607
2608 spin_lock_bh(&wmi->lock);
2609 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2610 (1 << params->traffic_class));
2611 wmi->stream_exist_for_ac[params->traffic_class] |=
2612 (1 << params->tsid);
2613
2614
2615
2616
2617 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2618 spin_unlock_bh(&wmi->lock);
2619 }
2620
2621
2622
2623
2624
2625
2626 if (!fatpipe_exist_for_ac)
2627 ath6kl_indicate_tx_activity(wmi->parent_dev,
2628 params->traffic_class, true);
2629
2630 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID,
2631 NO_SYNC_WMIFLAG);
2632 return ret;
2633}
2634
2635int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
2636 u8 tsid)
2637{
2638 struct sk_buff *skb;
2639 struct wmi_delete_pstream_cmd *cmd;
2640 u16 active_tsids = 0;
2641 int ret;
2642
2643 if (traffic_class >= WMM_NUM_AC) {
2644 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2645 return -EINVAL;
2646 }
2647
2648 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2649 if (!skb)
2650 return -ENOMEM;
2651
2652 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2653 cmd->traffic_class = traffic_class;
2654 cmd->tsid = tsid;
2655
2656 spin_lock_bh(&wmi->lock);
2657 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2658 spin_unlock_bh(&wmi->lock);
2659
2660 if (!(active_tsids & (1 << tsid))) {
2661 dev_kfree_skb(skb);
2662 ath6kl_dbg(ATH6KL_DBG_WMI,
2663 "TSID %d doesn't exist for traffic class: %d\n",
2664 tsid, traffic_class);
2665 return -ENODATA;
2666 }
2667
2668 ath6kl_dbg(ATH6KL_DBG_WMI,
2669 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2670 traffic_class, tsid);
2671
2672 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID,
2673 SYNC_BEFORE_WMIFLAG);
2674
2675 spin_lock_bh(&wmi->lock);
2676 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2677 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2678 spin_unlock_bh(&wmi->lock);
2679
2680
2681
2682
2683
2684 if (!active_tsids) {
2685 ath6kl_indicate_tx_activity(wmi->parent_dev,
2686 traffic_class, false);
2687 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2688 }
2689
2690 return ret;
2691}
2692
2693int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
2694 __be32 ips0, __be32 ips1)
2695{
2696 struct sk_buff *skb;
2697 struct wmi_set_ip_cmd *cmd;
2698 int ret;
2699
2700
2701 if (ipv4_is_multicast(ips0) ||
2702 ipv4_is_multicast(ips1))
2703 return -EINVAL;
2704
2705 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2706 if (!skb)
2707 return -ENOMEM;
2708
2709 cmd = (struct wmi_set_ip_cmd *) skb->data;
2710 cmd->ips[0] = ips0;
2711 cmd->ips[1] = ips1;
2712
2713 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID,
2714 NO_SYNC_WMIFLAG);
2715 return ret;
2716}
2717
2718static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
2719{
2720 u16 active_tsids;
2721 u8 stream_exist;
2722 int i;
2723
2724
2725
2726
2727
2728
2729
2730 spin_lock_bh(&wmi->lock);
2731 stream_exist = wmi->fat_pipe_exist;
2732 spin_unlock_bh(&wmi->lock);
2733
2734 for (i = 0; i < WMM_NUM_AC; i++) {
2735 if (stream_exist & (1 << i)) {
2736
2737
2738
2739
2740 spin_lock_bh(&wmi->lock);
2741 active_tsids = wmi->stream_exist_for_ac[i];
2742 spin_unlock_bh(&wmi->lock);
2743
2744
2745
2746
2747
2748 if (!active_tsids) {
2749 stream_exist &= ~(1 << i);
2750
2751
2752
2753
2754 ath6kl_indicate_tx_activity(wmi->parent_dev,
2755 i, false);
2756 }
2757 }
2758 }
2759
2760
2761 spin_lock_bh(&wmi->lock);
2762 wmi->fat_pipe_exist = stream_exist;
2763 spin_unlock_bh(&wmi->lock);
2764}
2765
2766static int ath6kl_set_bitrate_mask64(struct wmi *wmi, u8 if_idx,
2767 const struct cfg80211_bitrate_mask *mask)
2768{
2769 struct sk_buff *skb;
2770 int ret, mode, band;
2771 u64 mcsrate, ratemask[ATH6KL_NUM_BANDS];
2772 struct wmi_set_tx_select_rates64_cmd *cmd;
2773
2774 memset(&ratemask, 0, sizeof(ratemask));
2775
2776
2777 for (band = 0; band <= NL80211_BAND_5GHZ; band++) {
2778
2779 ratemask[band] = mask->control[band].legacy;
2780 if (band == NL80211_BAND_5GHZ)
2781 ratemask[band] =
2782 mask->control[band].legacy << 4;
2783
2784
2785 mcsrate = mask->control[band].ht_mcs[1];
2786 mcsrate <<= 8;
2787 mcsrate |= mask->control[band].ht_mcs[0];
2788 ratemask[band] |= mcsrate << 12;
2789 ratemask[band] |= mcsrate << 28;
2790 }
2791
2792 ath6kl_dbg(ATH6KL_DBG_WMI,
2793 "Ratemask 64 bit: 2.4:%llx 5:%llx\n",
2794 ratemask[0], ratemask[1]);
2795
2796 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX);
2797 if (!skb)
2798 return -ENOMEM;
2799
2800 cmd = (struct wmi_set_tx_select_rates64_cmd *) skb->data;
2801 for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) {
2802
2803 if (mode == WMI_RATES_MODE_11A ||
2804 mode == WMI_RATES_MODE_11A_HT20 ||
2805 mode == WMI_RATES_MODE_11A_HT40)
2806 band = NL80211_BAND_5GHZ;
2807 else
2808 band = NL80211_BAND_2GHZ;
2809 cmd->ratemask[mode] = cpu_to_le64(ratemask[band]);
2810 }
2811
2812 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2813 WMI_SET_TX_SELECT_RATES_CMDID,
2814 NO_SYNC_WMIFLAG);
2815 return ret;
2816}
2817
2818static int ath6kl_set_bitrate_mask32(struct wmi *wmi, u8 if_idx,
2819 const struct cfg80211_bitrate_mask *mask)
2820{
2821 struct sk_buff *skb;
2822 int ret, mode, band;
2823 u32 mcsrate, ratemask[ATH6KL_NUM_BANDS];
2824 struct wmi_set_tx_select_rates32_cmd *cmd;
2825
2826 memset(&ratemask, 0, sizeof(ratemask));
2827
2828
2829 for (band = 0; band <= NL80211_BAND_5GHZ; band++) {
2830
2831 ratemask[band] = mask->control[band].legacy;
2832 if (band == NL80211_BAND_5GHZ)
2833 ratemask[band] =
2834 mask->control[band].legacy << 4;
2835
2836
2837 mcsrate = mask->control[band].ht_mcs[0];
2838 ratemask[band] |= mcsrate << 12;
2839 ratemask[band] |= mcsrate << 20;
2840 }
2841
2842 ath6kl_dbg(ATH6KL_DBG_WMI,
2843 "Ratemask 32 bit: 2.4:%x 5:%x\n",
2844 ratemask[0], ratemask[1]);
2845
2846 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX);
2847 if (!skb)
2848 return -ENOMEM;
2849
2850 cmd = (struct wmi_set_tx_select_rates32_cmd *) skb->data;
2851 for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) {
2852
2853 if (mode == WMI_RATES_MODE_11A ||
2854 mode == WMI_RATES_MODE_11A_HT20 ||
2855 mode == WMI_RATES_MODE_11A_HT40)
2856 band = NL80211_BAND_5GHZ;
2857 else
2858 band = NL80211_BAND_2GHZ;
2859 cmd->ratemask[mode] = cpu_to_le32(ratemask[band]);
2860 }
2861
2862 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2863 WMI_SET_TX_SELECT_RATES_CMDID,
2864 NO_SYNC_WMIFLAG);
2865 return ret;
2866}
2867
2868int ath6kl_wmi_set_bitrate_mask(struct wmi *wmi, u8 if_idx,
2869 const struct cfg80211_bitrate_mask *mask)
2870{
2871 struct ath6kl *ar = wmi->parent_dev;
2872
2873 if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES,
2874 ar->fw_capabilities))
2875 return ath6kl_set_bitrate_mask64(wmi, if_idx, mask);
2876 else
2877 return ath6kl_set_bitrate_mask32(wmi, if_idx, mask);
2878}
2879
2880int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
2881 enum ath6kl_host_mode host_mode)
2882{
2883 struct sk_buff *skb;
2884 struct wmi_set_host_sleep_mode_cmd *cmd;
2885 int ret;
2886
2887 if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) &&
2888 (host_mode != ATH6KL_HOST_MODE_AWAKE)) {
2889 ath6kl_err("invalid host sleep mode: %d\n", host_mode);
2890 return -EINVAL;
2891 }
2892
2893 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2894 if (!skb)
2895 return -ENOMEM;
2896
2897 cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data;
2898
2899 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
2900 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
2901 cmd->asleep = cpu_to_le32(1);
2902 } else {
2903 cmd->awake = cpu_to_le32(1);
2904 }
2905
2906 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2907 WMI_SET_HOST_SLEEP_MODE_CMDID,
2908 NO_SYNC_WMIFLAG);
2909 return ret;
2910}
2911
2912
2913static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi,
2914 struct ath6kl_vif *vif)
2915{
2916 struct ath6kl *ar = wmi->parent_dev;
2917
2918 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags);
2919 wake_up(&ar->event_wq);
2920
2921 return 0;
2922}
2923
2924int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx,
2925 enum ath6kl_wow_mode wow_mode,
2926 u32 filter, u16 host_req_delay)
2927{
2928 struct sk_buff *skb;
2929 struct wmi_set_wow_mode_cmd *cmd;
2930 int ret;
2931
2932 if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) &&
2933 wow_mode != ATH6KL_WOW_MODE_DISABLE) {
2934 ath6kl_err("invalid wow mode: %d\n", wow_mode);
2935 return -EINVAL;
2936 }
2937
2938 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2939 if (!skb)
2940 return -ENOMEM;
2941
2942 cmd = (struct wmi_set_wow_mode_cmd *) skb->data;
2943 cmd->enable_wow = cpu_to_le32(wow_mode);
2944 cmd->filter = cpu_to_le32(filter);
2945 cmd->host_req_delay = cpu_to_le16(host_req_delay);
2946
2947 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID,
2948 NO_SYNC_WMIFLAG);
2949 return ret;
2950}
2951
2952int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2953 u8 list_id, u8 filter_size,
2954 u8 filter_offset, const u8 *filter,
2955 const u8 *mask)
2956{
2957 struct sk_buff *skb;
2958 struct wmi_add_wow_pattern_cmd *cmd;
2959 u16 size;
2960 u8 *filter_mask;
2961 int ret;
2962
2963
2964
2965
2966
2967 size = sizeof(*cmd) + (2 * filter_size);
2968
2969 skb = ath6kl_wmi_get_new_buf(size);
2970 if (!skb)
2971 return -ENOMEM;
2972
2973 cmd = (struct wmi_add_wow_pattern_cmd *) skb->data;
2974 cmd->filter_list_id = list_id;
2975 cmd->filter_size = filter_size;
2976 cmd->filter_offset = filter_offset;
2977
2978 memcpy(cmd->filter, filter, filter_size);
2979
2980 filter_mask = (u8 *) (cmd->filter + filter_size);
2981 memcpy(filter_mask, mask, filter_size);
2982
2983 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID,
2984 NO_SYNC_WMIFLAG);
2985
2986 return ret;
2987}
2988
2989int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2990 u16 list_id, u16 filter_id)
2991{
2992 struct sk_buff *skb;
2993 struct wmi_del_wow_pattern_cmd *cmd;
2994 int ret;
2995
2996 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2997 if (!skb)
2998 return -ENOMEM;
2999
3000 cmd = (struct wmi_del_wow_pattern_cmd *) skb->data;
3001 cmd->filter_list_id = cpu_to_le16(list_id);
3002 cmd->filter_id = cpu_to_le16(filter_id);
3003
3004 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID,
3005 NO_SYNC_WMIFLAG);
3006 return ret;
3007}
3008
3009static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
3010 enum wmix_command_id cmd_id,
3011 enum wmi_sync_flag sync_flag)
3012{
3013 struct wmix_cmd_hdr *cmd_hdr;
3014 int ret;
3015
3016 skb_push(skb, sizeof(struct wmix_cmd_hdr));
3017
3018 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
3019 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
3020
3021 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag);
3022
3023 return ret;
3024}
3025
3026int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
3027{
3028 struct sk_buff *skb;
3029 struct wmix_hb_challenge_resp_cmd *cmd;
3030 int ret;
3031
3032 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3033 if (!skb)
3034 return -ENOMEM;
3035
3036 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
3037 cmd->cookie = cpu_to_le32(cookie);
3038 cmd->source = cpu_to_le32(source);
3039
3040 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
3041 NO_SYNC_WMIFLAG);
3042 return ret;
3043}
3044
3045int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
3046{
3047 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
3048 struct sk_buff *skb;
3049 int ret;
3050
3051 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3052 if (!skb)
3053 return -ENOMEM;
3054
3055 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
3056 cmd->valid = cpu_to_le32(valid);
3057 cmd->config = cpu_to_le32(config);
3058
3059 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
3060 NO_SYNC_WMIFLAG);
3061 return ret;
3062}
3063
3064int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx)
3065{
3066 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID);
3067}
3068
3069int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM)
3070{
3071 struct sk_buff *skb;
3072 struct wmi_set_tx_pwr_cmd *cmd;
3073 int ret;
3074
3075 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
3076 if (!skb)
3077 return -ENOMEM;
3078
3079 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
3080 cmd->dbM = dbM;
3081
3082 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID,
3083 NO_SYNC_WMIFLAG);
3084
3085 return ret;
3086}
3087
3088int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx)
3089{
3090 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID);
3091}
3092
3093int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi)
3094{
3095 return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID);
3096}
3097
3098int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status,
3099 u8 preamble_policy)
3100{
3101 struct sk_buff *skb;
3102 struct wmi_set_lpreamble_cmd *cmd;
3103 int ret;
3104
3105 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
3106 if (!skb)
3107 return -ENOMEM;
3108
3109 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
3110 cmd->status = status;
3111 cmd->preamble_policy = preamble_policy;
3112
3113 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID,
3114 NO_SYNC_WMIFLAG);
3115 return ret;
3116}
3117
3118int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
3119{
3120 struct sk_buff *skb;
3121 struct wmi_set_rts_cmd *cmd;
3122 int ret;
3123
3124 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
3125 if (!skb)
3126 return -ENOMEM;
3127
3128 cmd = (struct wmi_set_rts_cmd *) skb->data;
3129 cmd->threshold = cpu_to_le16(threshold);
3130
3131 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID,
3132 NO_SYNC_WMIFLAG);
3133 return ret;
3134}
3135
3136int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg)
3137{
3138 struct sk_buff *skb;
3139 struct wmi_set_wmm_txop_cmd *cmd;
3140 int ret;
3141
3142 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
3143 return -EINVAL;
3144
3145 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
3146 if (!skb)
3147 return -ENOMEM;
3148
3149 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
3150 cmd->txop_enable = cfg;
3151
3152 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID,
3153 NO_SYNC_WMIFLAG);
3154 return ret;
3155}
3156
3157int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx,
3158 u8 keep_alive_intvl)
3159{
3160 struct sk_buff *skb;
3161 struct wmi_set_keepalive_cmd *cmd;
3162 int ret;
3163
3164 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3165 if (!skb)
3166 return -ENOMEM;
3167
3168 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
3169 cmd->keep_alive_intvl = keep_alive_intvl;
3170
3171 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID,
3172 NO_SYNC_WMIFLAG);
3173
3174 if (ret == 0)
3175 ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl);
3176
3177 return ret;
3178}
3179
3180int ath6kl_wmi_set_htcap_cmd(struct wmi *wmi, u8 if_idx,
3181 enum nl80211_band band,
3182 struct ath6kl_htcap *htcap)
3183{
3184 struct sk_buff *skb;
3185 struct wmi_set_htcap_cmd *cmd;
3186
3187 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3188 if (!skb)
3189 return -ENOMEM;
3190
3191 cmd = (struct wmi_set_htcap_cmd *) skb->data;
3192
3193
3194
3195
3196
3197
3198 cmd->band = band;
3199 cmd->ht_enable = !!htcap->ht_enable;
3200 cmd->ht20_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_20);
3201 cmd->ht40_supported =
3202 !!(htcap->cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
3203 cmd->ht40_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_40);
3204 cmd->intolerant_40mhz =
3205 !!(htcap->cap_info & IEEE80211_HT_CAP_40MHZ_INTOLERANT);
3206 cmd->max_ampdu_len_exp = htcap->ampdu_factor;
3207
3208 ath6kl_dbg(ATH6KL_DBG_WMI,
3209 "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n",
3210 cmd->band, cmd->ht_enable, cmd->ht40_supported,
3211 cmd->ht20_sgi, cmd->ht40_sgi, cmd->intolerant_40mhz,
3212 cmd->max_ampdu_len_exp);
3213 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_HT_CAP_CMDID,
3214 NO_SYNC_WMIFLAG);
3215}
3216
3217int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
3218{
3219 struct sk_buff *skb;
3220 int ret;
3221
3222 skb = ath6kl_wmi_get_new_buf(len);
3223 if (!skb)
3224 return -ENOMEM;
3225
3226 memcpy(skb->data, buf, len);
3227
3228 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
3229
3230 return ret;
3231}
3232
3233int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on)
3234{
3235 struct sk_buff *skb;
3236 struct wmi_mcast_filter_cmd *cmd;
3237 int ret;
3238
3239 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3240 if (!skb)
3241 return -ENOMEM;
3242
3243 cmd = (struct wmi_mcast_filter_cmd *) skb->data;
3244 cmd->mcast_all_enable = mc_all_on;
3245
3246 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID,
3247 NO_SYNC_WMIFLAG);
3248 return ret;
3249}
3250
3251int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx,
3252 u8 *filter, bool add_filter)
3253{
3254 struct sk_buff *skb;
3255 struct wmi_mcast_filter_add_del_cmd *cmd;
3256 int ret;
3257
3258 if ((filter[0] != 0x33 || filter[1] != 0x33) &&
3259 (filter[0] != 0x01 || filter[1] != 0x00 ||
3260 filter[2] != 0x5e || filter[3] > 0x7f)) {
3261 ath6kl_warn("invalid multicast filter address\n");
3262 return -EINVAL;
3263 }
3264
3265 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3266 if (!skb)
3267 return -ENOMEM;
3268
3269 cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data;
3270 memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE);
3271 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3272 add_filter ? WMI_SET_MCAST_FILTER_CMDID :
3273 WMI_DEL_MCAST_FILTER_CMDID,
3274 NO_SYNC_WMIFLAG);
3275
3276 return ret;
3277}
3278
3279int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi *wmi, u8 if_idx, bool enhance)
3280{
3281 struct sk_buff *skb;
3282 struct wmi_sta_bmiss_enhance_cmd *cmd;
3283 int ret;
3284
3285 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3286 if (!skb)
3287 return -ENOMEM;
3288
3289 cmd = (struct wmi_sta_bmiss_enhance_cmd *) skb->data;
3290 cmd->enable = enhance ? 1 : 0;
3291
3292 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3293 WMI_STA_BMISS_ENHANCE_CMDID,
3294 NO_SYNC_WMIFLAG);
3295 return ret;
3296}
3297
3298int ath6kl_wmi_set_regdomain_cmd(struct wmi *wmi, const char *alpha2)
3299{
3300 struct sk_buff *skb;
3301 struct wmi_set_regdomain_cmd *cmd;
3302
3303 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3304 if (!skb)
3305 return -ENOMEM;
3306
3307 cmd = (struct wmi_set_regdomain_cmd *) skb->data;
3308 memcpy(cmd->iso_name, alpha2, 2);
3309
3310 return ath6kl_wmi_cmd_send(wmi, 0, skb,
3311 WMI_SET_REGDOMAIN_CMDID,
3312 NO_SYNC_WMIFLAG);
3313}
3314
3315s32 ath6kl_wmi_get_rate(struct wmi *wmi, s8 rate_index)
3316{
3317 struct ath6kl *ar = wmi->parent_dev;
3318 u8 sgi = 0;
3319 s32 ret;
3320
3321 if (rate_index == RATE_AUTO)
3322 return 0;
3323
3324
3325 if (rate_index & RATE_INDEX_MSB) {
3326 rate_index &= RATE_INDEX_WITHOUT_SGI_MASK;
3327 sgi = 1;
3328 }
3329
3330 if (test_bit(ATH6KL_FW_CAPABILITY_RATETABLE_MCS15,
3331 ar->fw_capabilities)) {
3332 if (WARN_ON(rate_index >= ARRAY_SIZE(wmi_rate_tbl_mcs15)))
3333 return 0;
3334
3335 ret = wmi_rate_tbl_mcs15[(u32) rate_index][sgi];
3336 } else {
3337 if (WARN_ON(rate_index >= ARRAY_SIZE(wmi_rate_tbl)))
3338 return 0;
3339
3340 ret = wmi_rate_tbl[(u32) rate_index][sgi];
3341 }
3342
3343 return ret;
3344}
3345
3346static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
3347 u32 len)
3348{
3349 struct wmi_pmkid_list_reply *reply;
3350 u32 expected_len;
3351
3352 if (len < sizeof(struct wmi_pmkid_list_reply))
3353 return -EINVAL;
3354
3355 reply = (struct wmi_pmkid_list_reply *)datap;
3356 expected_len = sizeof(reply->num_pmkid) +
3357 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
3358
3359 if (len < expected_len)
3360 return -EINVAL;
3361
3362 return 0;
3363}
3364
3365static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
3366 struct ath6kl_vif *vif)
3367{
3368 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
3369
3370 aggr_recv_addba_req_evt(vif, cmd->tid,
3371 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
3372
3373 return 0;
3374}
3375
3376static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
3377 struct ath6kl_vif *vif)
3378{
3379 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
3380
3381 aggr_recv_delba_req_evt(vif, cmd->tid);
3382
3383 return 0;
3384}
3385
3386
3387
3388int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx,
3389 struct wmi_connect_cmd *p)
3390{
3391 struct sk_buff *skb;
3392 struct wmi_connect_cmd *cm;
3393 int res;
3394
3395 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3396 if (!skb)
3397 return -ENOMEM;
3398
3399 cm = (struct wmi_connect_cmd *) skb->data;
3400 memcpy(cm, p, sizeof(*cm));
3401
3402 res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
3403 NO_SYNC_WMIFLAG);
3404 ath6kl_dbg(ATH6KL_DBG_WMI,
3405 "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n",
3406 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
3407 le32_to_cpu(p->ctrl_flags), res);
3408 return res;
3409}
3410
3411int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac,
3412 u16 reason)
3413{
3414 struct sk_buff *skb;
3415 struct wmi_ap_set_mlme_cmd *cm;
3416
3417 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3418 if (!skb)
3419 return -ENOMEM;
3420
3421 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
3422 memcpy(cm->mac, mac, ETH_ALEN);
3423 cm->reason = cpu_to_le16(reason);
3424 cm->cmd = cmd;
3425
3426 ath6kl_dbg(ATH6KL_DBG_WMI, "ap_set_mlme: cmd=%d reason=%d\n", cm->cmd,
3427 cm->reason);
3428
3429 return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID,
3430 NO_SYNC_WMIFLAG);
3431}
3432
3433int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable)
3434{
3435 struct sk_buff *skb;
3436 struct wmi_ap_hidden_ssid_cmd *cmd;
3437
3438 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3439 if (!skb)
3440 return -ENOMEM;
3441
3442 cmd = (struct wmi_ap_hidden_ssid_cmd *) skb->data;
3443 cmd->hidden_ssid = enable ? 1 : 0;
3444
3445 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_HIDDEN_SSID_CMDID,
3446 NO_SYNC_WMIFLAG);
3447}
3448
3449
3450int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable)
3451{
3452 struct wmi_ap_set_apsd_cmd *cmd;
3453 struct sk_buff *skb;
3454
3455 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3456 if (!skb)
3457 return -ENOMEM;
3458
3459 cmd = (struct wmi_ap_set_apsd_cmd *)skb->data;
3460 cmd->enable = enable;
3461
3462 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID,
3463 NO_SYNC_WMIFLAG);
3464}
3465
3466int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx,
3467 u16 aid, u16 bitmap, u32 flags)
3468{
3469 struct wmi_ap_apsd_buffered_traffic_cmd *cmd;
3470 struct sk_buff *skb;
3471
3472 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3473 if (!skb)
3474 return -ENOMEM;
3475
3476 cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data;
3477 cmd->aid = cpu_to_le16(aid);
3478 cmd->bitmap = cpu_to_le16(bitmap);
3479 cmd->flags = cpu_to_le32(flags);
3480
3481 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3482 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
3483 NO_SYNC_WMIFLAG);
3484}
3485
3486static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len,
3487 struct ath6kl_vif *vif)
3488{
3489 struct wmi_pspoll_event *ev;
3490
3491 if (len < sizeof(struct wmi_pspoll_event))
3492 return -EINVAL;
3493
3494 ev = (struct wmi_pspoll_event *) datap;
3495
3496 ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid));
3497
3498 return 0;
3499}
3500
3501static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len,
3502 struct ath6kl_vif *vif)
3503{
3504 ath6kl_dtimexpiry_event(vif);
3505
3506 return 0;
3507}
3508
3509int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
3510 bool flag)
3511{
3512 struct sk_buff *skb;
3513 struct wmi_ap_set_pvb_cmd *cmd;
3514 int ret;
3515
3516 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
3517 if (!skb)
3518 return -ENOMEM;
3519
3520 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
3521 cmd->aid = cpu_to_le16(aid);
3522 cmd->rsvd = cpu_to_le16(0);
3523 cmd->flag = cpu_to_le32(flag);
3524
3525 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
3526 NO_SYNC_WMIFLAG);
3527
3528 return ret;
3529}
3530
3531int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
3532 u8 rx_meta_ver,
3533 bool rx_dot11_hdr, bool defrag_on_host)
3534{
3535 struct sk_buff *skb;
3536 struct wmi_rx_frame_format_cmd *cmd;
3537 int ret;
3538
3539 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3540 if (!skb)
3541 return -ENOMEM;
3542
3543 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
3544 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
3545 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
3546 cmd->meta_ver = rx_meta_ver;
3547
3548
3549 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID,
3550 NO_SYNC_WMIFLAG);
3551
3552 return ret;
3553}
3554
3555int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,
3556 const u8 *ie, u8 ie_len)
3557{
3558 struct sk_buff *skb;
3559 struct wmi_set_appie_cmd *p;
3560
3561 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3562 if (!skb)
3563 return -ENOMEM;
3564
3565 ath6kl_dbg(ATH6KL_DBG_WMI,
3566 "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n",
3567 mgmt_frm_type, ie_len);
3568 p = (struct wmi_set_appie_cmd *) skb->data;
3569 p->mgmt_frm_type = mgmt_frm_type;
3570 p->ie_len = ie_len;
3571
3572 if (ie != NULL && ie_len > 0)
3573 memcpy(p->ie_info, ie, ie_len);
3574
3575 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID,
3576 NO_SYNC_WMIFLAG);
3577}
3578
3579int ath6kl_wmi_set_ie_cmd(struct wmi *wmi, u8 if_idx, u8 ie_id, u8 ie_field,
3580 const u8 *ie_info, u8 ie_len)
3581{
3582 struct sk_buff *skb;
3583 struct wmi_set_ie_cmd *p;
3584
3585 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3586 if (!skb)
3587 return -ENOMEM;
3588
3589 ath6kl_dbg(ATH6KL_DBG_WMI, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n",
3590 ie_id, ie_field, ie_len);
3591 p = (struct wmi_set_ie_cmd *) skb->data;
3592 p->ie_id = ie_id;
3593 p->ie_field = ie_field;
3594 p->ie_len = ie_len;
3595 if (ie_info && ie_len > 0)
3596 memcpy(p->ie_info, ie_info, ie_len);
3597
3598 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IE_CMDID,
3599 NO_SYNC_WMIFLAG);
3600}
3601
3602int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
3603{
3604 struct sk_buff *skb;
3605 struct wmi_disable_11b_rates_cmd *cmd;
3606
3607 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3608 if (!skb)
3609 return -ENOMEM;
3610
3611 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
3612 disable);
3613 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
3614 cmd->disable = disable ? 1 : 0;
3615
3616 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID,
3617 NO_SYNC_WMIFLAG);
3618}
3619
3620int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur)
3621{
3622 struct sk_buff *skb;
3623 struct wmi_remain_on_chnl_cmd *p;
3624
3625 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3626 if (!skb)
3627 return -ENOMEM;
3628
3629 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3630 freq, dur);
3631 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
3632 p->freq = cpu_to_le32(freq);
3633 p->duration = cpu_to_le32(dur);
3634 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID,
3635 NO_SYNC_WMIFLAG);
3636}
3637
3638
3639
3640
3641
3642static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id,
3643 u32 freq, u32 wait, const u8 *data,
3644 u16 data_len)
3645{
3646 struct sk_buff *skb;
3647 struct wmi_send_action_cmd *p;
3648 u8 *buf;
3649
3650 if (wait)
3651 return -EINVAL;
3652
3653 buf = kmemdup(data, data_len, GFP_KERNEL);
3654 if (!buf)
3655 return -ENOMEM;
3656
3657 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3658 if (!skb) {
3659 kfree(buf);
3660 return -ENOMEM;
3661 }
3662
3663 kfree(wmi->last_mgmt_tx_frame);
3664 wmi->last_mgmt_tx_frame = buf;
3665 wmi->last_mgmt_tx_frame_len = data_len;
3666
3667 ath6kl_dbg(ATH6KL_DBG_WMI,
3668 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3669 id, freq, wait, data_len);
3670 p = (struct wmi_send_action_cmd *) skb->data;
3671 p->id = cpu_to_le32(id);
3672 p->freq = cpu_to_le32(freq);
3673 p->wait = cpu_to_le32(wait);
3674 p->len = cpu_to_le16(data_len);
3675 memcpy(p->data, data, data_len);
3676 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID,
3677 NO_SYNC_WMIFLAG);
3678}
3679
3680static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id,
3681 u32 freq, u32 wait, const u8 *data,
3682 u16 data_len, u32 no_cck)
3683{
3684 struct sk_buff *skb;
3685 struct wmi_send_mgmt_cmd *p;
3686 u8 *buf;
3687
3688 if (wait)
3689 return -EINVAL;
3690
3691 buf = kmemdup(data, data_len, GFP_KERNEL);
3692 if (!buf)
3693 return -ENOMEM;
3694
3695 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3696 if (!skb) {
3697 kfree(buf);
3698 return -ENOMEM;
3699 }
3700
3701 kfree(wmi->last_mgmt_tx_frame);
3702 wmi->last_mgmt_tx_frame = buf;
3703 wmi->last_mgmt_tx_frame_len = data_len;
3704
3705 ath6kl_dbg(ATH6KL_DBG_WMI,
3706 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3707 id, freq, wait, data_len);
3708 p = (struct wmi_send_mgmt_cmd *) skb->data;
3709 p->id = cpu_to_le32(id);
3710 p->freq = cpu_to_le32(freq);
3711 p->wait = cpu_to_le32(wait);
3712 p->no_cck = cpu_to_le32(no_cck);
3713 p->len = cpu_to_le16(data_len);
3714 memcpy(p->data, data, data_len);
3715 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID,
3716 NO_SYNC_WMIFLAG);
3717}
3718
3719int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3720 u32 wait, const u8 *data, u16 data_len,
3721 u32 no_cck)
3722{
3723 int status;
3724 struct ath6kl *ar = wmi->parent_dev;
3725
3726 if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
3727 ar->fw_capabilities)) {
3728
3729
3730
3731
3732
3733
3734 status = __ath6kl_wmi_send_mgmt_cmd(ar->wmi, if_idx, id, freq,
3735 wait, data, data_len,
3736 no_cck);
3737 } else {
3738 status = ath6kl_wmi_send_action_cmd(ar->wmi, if_idx, id, freq,
3739 wait, data, data_len);
3740 }
3741
3742 return status;
3743}
3744
3745int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq,
3746 const u8 *dst, const u8 *data,
3747 u16 data_len)
3748{
3749 struct sk_buff *skb;
3750 struct wmi_p2p_probe_response_cmd *p;
3751 size_t cmd_len = sizeof(*p) + data_len;
3752
3753 if (data_len == 0)
3754 cmd_len++;
3755
3756 skb = ath6kl_wmi_get_new_buf(cmd_len);
3757 if (!skb)
3758 return -ENOMEM;
3759
3760 ath6kl_dbg(ATH6KL_DBG_WMI,
3761 "send_probe_response_cmd: freq=%u dst=%pM len=%u\n",
3762 freq, dst, data_len);
3763 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
3764 p->freq = cpu_to_le32(freq);
3765 memcpy(p->destination_addr, dst, ETH_ALEN);
3766 p->len = cpu_to_le16(data_len);
3767 memcpy(p->data, data, data_len);
3768 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3769 WMI_SEND_PROBE_RESPONSE_CMDID,
3770 NO_SYNC_WMIFLAG);
3771}
3772
3773int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable)
3774{
3775 struct sk_buff *skb;
3776 struct wmi_probe_req_report_cmd *p;
3777
3778 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3779 if (!skb)
3780 return -ENOMEM;
3781
3782 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
3783 enable);
3784 p = (struct wmi_probe_req_report_cmd *) skb->data;
3785 p->enable = enable ? 1 : 0;
3786 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID,
3787 NO_SYNC_WMIFLAG);
3788}
3789
3790int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags)
3791{
3792 struct sk_buff *skb;
3793 struct wmi_get_p2p_info *p;
3794
3795 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3796 if (!skb)
3797 return -ENOMEM;
3798
3799 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
3800 info_req_flags);
3801 p = (struct wmi_get_p2p_info *) skb->data;
3802 p->info_req_flags = cpu_to_le32(info_req_flags);
3803 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID,
3804 NO_SYNC_WMIFLAG);
3805}
3806
3807int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx)
3808{
3809 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
3810 return ath6kl_wmi_simple_cmd(wmi, if_idx,
3811 WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
3812}
3813
3814int ath6kl_wmi_set_inact_period(struct wmi *wmi, u8 if_idx, int inact_timeout)
3815{
3816 struct sk_buff *skb;
3817 struct wmi_set_inact_period_cmd *cmd;
3818
3819 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3820 if (!skb)
3821 return -ENOMEM;
3822
3823 cmd = (struct wmi_set_inact_period_cmd *) skb->data;
3824 cmd->inact_period = cpu_to_le32(inact_timeout);
3825 cmd->num_null_func = 0;
3826
3827 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_CONN_INACT_CMDID,
3828 NO_SYNC_WMIFLAG);
3829}
3830
3831static void ath6kl_wmi_hb_challenge_resp_event(struct wmi *wmi, u8 *datap,
3832 int len)
3833{
3834 struct wmix_hb_challenge_resp_cmd *cmd;
3835
3836 if (len < sizeof(struct wmix_hb_challenge_resp_cmd))
3837 return;
3838
3839 cmd = (struct wmix_hb_challenge_resp_cmd *) datap;
3840 ath6kl_recovery_hb_event(wmi->parent_dev,
3841 le32_to_cpu(cmd->cookie));
3842}
3843
3844static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
3845{
3846 struct wmix_cmd_hdr *cmd;
3847 u32 len;
3848 u16 id;
3849 u8 *datap;
3850 int ret = 0;
3851
3852 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
3853 ath6kl_err("bad packet 1\n");
3854 return -EINVAL;
3855 }
3856
3857 cmd = (struct wmix_cmd_hdr *) skb->data;
3858 id = le32_to_cpu(cmd->cmd_id);
3859
3860 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
3861
3862 datap = skb->data;
3863 len = skb->len;
3864
3865 switch (id) {
3866 case WMIX_HB_CHALLENGE_RESP_EVENTID:
3867 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n");
3868 ath6kl_wmi_hb_challenge_resp_event(wmi, datap, len);
3869 break;
3870 case WMIX_DBGLOG_EVENTID:
3871 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len);
3872 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
3873 break;
3874 default:
3875 ath6kl_warn("unknown cmd id 0x%x\n", id);
3876 ret = -EINVAL;
3877 break;
3878 }
3879
3880 return ret;
3881}
3882
3883static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len)
3884{
3885 return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len);
3886}
3887
3888
3889static int ath6kl_wmi_proc_events_vif(struct wmi *wmi, u16 if_idx, u16 cmd_id,
3890 u8 *datap, u32 len)
3891{
3892 struct ath6kl_vif *vif;
3893
3894 vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx);
3895 if (!vif) {
3896 ath6kl_dbg(ATH6KL_DBG_WMI,
3897 "Wmi event for unavailable vif, vif_index:%d\n",
3898 if_idx);
3899 return -EINVAL;
3900 }
3901
3902 switch (cmd_id) {
3903 case WMI_CONNECT_EVENTID:
3904 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
3905 return ath6kl_wmi_connect_event_rx(wmi, datap, len, vif);
3906 case WMI_DISCONNECT_EVENTID:
3907 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
3908 return ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif);
3909 case WMI_TKIP_MICERR_EVENTID:
3910 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
3911 return ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif);
3912 case WMI_BSSINFO_EVENTID:
3913 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
3914 return ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif);
3915 case WMI_NEIGHBOR_REPORT_EVENTID:
3916 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3917 return ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len,
3918 vif);
3919 case WMI_SCAN_COMPLETE_EVENTID:
3920 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
3921 return ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif);
3922 case WMI_REPORT_STATISTICS_EVENTID:
3923 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
3924 return ath6kl_wmi_stats_event_rx(wmi, datap, len, vif);
3925 case WMI_CAC_EVENTID:
3926 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
3927 return ath6kl_wmi_cac_event_rx(wmi, datap, len, vif);
3928 case WMI_PSPOLL_EVENTID:
3929 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
3930 return ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif);
3931 case WMI_DTIMEXPIRY_EVENTID:
3932 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
3933 return ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif);
3934 case WMI_ADDBA_REQ_EVENTID:
3935 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
3936 return ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif);
3937 case WMI_DELBA_REQ_EVENTID:
3938 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
3939 return ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif);
3940 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID:
3941 ath6kl_dbg(ATH6KL_DBG_WMI,
3942 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3943 return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif);
3944 case WMI_REMAIN_ON_CHNL_EVENTID:
3945 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3946 return ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif);
3947 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3948 ath6kl_dbg(ATH6KL_DBG_WMI,
3949 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3950 return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
3951 len, vif);
3952 case WMI_TX_STATUS_EVENTID:
3953 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
3954 return ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif);
3955 case WMI_RX_PROBE_REQ_EVENTID:
3956 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
3957 return ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif);
3958 case WMI_RX_ACTION_EVENTID:
3959 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
3960 return ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif);
3961 case WMI_TXE_NOTIFY_EVENTID:
3962 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TXE_NOTIFY_EVENTID\n");
3963 return ath6kl_wmi_txe_notify_event_rx(wmi, datap, len, vif);
3964 default:
3965 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", cmd_id);
3966 return -EINVAL;
3967 }
3968
3969 return 0;
3970}
3971
3972static int ath6kl_wmi_proc_events(struct wmi *wmi, struct sk_buff *skb)
3973{
3974 struct wmi_cmd_hdr *cmd;
3975 int ret = 0;
3976 u32 len;
3977 u16 id;
3978 u8 if_idx;
3979 u8 *datap;
3980
3981 cmd = (struct wmi_cmd_hdr *) skb->data;
3982 id = le16_to_cpu(cmd->cmd_id);
3983 if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK;
3984
3985 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
3986 datap = skb->data;
3987 len = skb->len;
3988
3989 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len);
3990 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ",
3991 datap, len);
3992
3993 switch (id) {
3994 case WMI_GET_BITRATE_CMDID:
3995 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
3996 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
3997 break;
3998 case WMI_GET_CHANNEL_LIST_CMDID:
3999 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
4000 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
4001 break;
4002 case WMI_GET_TX_PWR_CMDID:
4003 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
4004 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
4005 break;
4006 case WMI_READY_EVENTID:
4007 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
4008 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
4009 break;
4010 case WMI_PEER_NODE_EVENTID:
4011 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
4012 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
4013 break;
4014 case WMI_REGDOMAIN_EVENTID:
4015 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
4016 ath6kl_wmi_regdomain_event(wmi, datap, len);
4017 break;
4018 case WMI_PSTREAM_TIMEOUT_EVENTID:
4019 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
4020 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
4021 break;
4022 case WMI_CMDERROR_EVENTID:
4023 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
4024 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
4025 break;
4026 case WMI_RSSI_THRESHOLD_EVENTID:
4027 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
4028 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
4029 break;
4030 case WMI_ERROR_REPORT_EVENTID:
4031 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
4032 break;
4033 case WMI_OPT_RX_FRAME_EVENTID:
4034 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
4035
4036 break;
4037 case WMI_REPORT_ROAM_TBL_EVENTID:
4038 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
4039 ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len);
4040 break;
4041 case WMI_EXTENSION_EVENTID:
4042 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
4043 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
4044 break;
4045 case WMI_CHANNEL_CHANGE_EVENTID:
4046 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
4047 break;
4048 case WMI_REPORT_ROAM_DATA_EVENTID:
4049 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
4050 break;
4051 case WMI_TEST_EVENTID:
4052 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
4053 ret = ath6kl_wmi_test_rx(wmi, datap, len);
4054 break;
4055 case WMI_GET_FIXRATES_CMDID:
4056 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
4057 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
4058 break;
4059 case WMI_TX_RETRY_ERR_EVENTID:
4060 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
4061 break;
4062 case WMI_SNR_THRESHOLD_EVENTID:
4063 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
4064 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
4065 break;
4066 case WMI_LQ_THRESHOLD_EVENTID:
4067 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
4068 break;
4069 case WMI_APLIST_EVENTID:
4070 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
4071 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
4072 break;
4073 case WMI_GET_KEEPALIVE_CMDID:
4074 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
4075 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
4076 break;
4077 case WMI_GET_WOW_LIST_EVENTID:
4078 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
4079 break;
4080 case WMI_GET_PMKID_LIST_EVENTID:
4081 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
4082 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
4083 break;
4084 case WMI_SET_PARAMS_REPLY_EVENTID:
4085 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
4086 break;
4087 case WMI_ADDBA_RESP_EVENTID:
4088 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
4089 break;
4090 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
4091 ath6kl_dbg(ATH6KL_DBG_WMI,
4092 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
4093 break;
4094 case WMI_REPORT_BTCOEX_STATS_EVENTID:
4095 ath6kl_dbg(ATH6KL_DBG_WMI,
4096 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
4097 break;
4098 case WMI_TX_COMPLETE_EVENTID:
4099 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
4100 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
4101 break;
4102 case WMI_P2P_CAPABILITIES_EVENTID:
4103 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
4104 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
4105 break;
4106 case WMI_P2P_INFO_EVENTID:
4107 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
4108 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
4109 break;
4110 default:
4111
4112 ret = ath6kl_wmi_proc_events_vif(wmi, if_idx, id, datap, len);
4113 break;
4114 }
4115
4116 dev_kfree_skb(skb);
4117 return ret;
4118}
4119
4120
4121int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
4122{
4123 if (WARN_ON(skb == NULL))
4124 return -EINVAL;
4125
4126 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
4127 ath6kl_err("bad packet 1\n");
4128 dev_kfree_skb(skb);
4129 return -EINVAL;
4130 }
4131
4132 trace_ath6kl_wmi_event(skb->data, skb->len);
4133
4134 return ath6kl_wmi_proc_events(wmi, skb);
4135}
4136
4137void ath6kl_wmi_reset(struct wmi *wmi)
4138{
4139 spin_lock_bh(&wmi->lock);
4140
4141 wmi->fat_pipe_exist = 0;
4142 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
4143
4144 spin_unlock_bh(&wmi->lock);
4145}
4146
4147void *ath6kl_wmi_init(struct ath6kl *dev)
4148{
4149 struct wmi *wmi;
4150
4151 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
4152 if (!wmi)
4153 return NULL;
4154
4155 spin_lock_init(&wmi->lock);
4156
4157 wmi->parent_dev = dev;
4158
4159 wmi->pwr_mode = REC_POWER;
4160
4161 ath6kl_wmi_reset(wmi);
4162
4163 return wmi;
4164}
4165
4166void ath6kl_wmi_shutdown(struct wmi *wmi)
4167{
4168 if (!wmi)
4169 return;
4170
4171 kfree(wmi->last_mgmt_tx_frame);
4172 kfree(wmi);
4173}
4174