blob: b56830f6d4748c6d8f07d5763e63d0b72286d395 [file] [log] [blame]
Kalle Valobdcd8172011-07-18 00:22:30 +03001/*
2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <linux/ip.h>
18#include "core.h"
19#include "debug.h"
Kalle Valo003353b0d2011-09-01 10:14:21 +030020#include "testmode.h"
Kalle Valobdcd8172011-07-18 00:22:30 +030021
22static int ath6kl_wmi_sync_point(struct wmi *wmi);
23
24static const s32 wmi_rate_tbl[][2] = {
25 /* {W/O SGI, with SGI} */
26 {1000, 1000},
27 {2000, 2000},
28 {5500, 5500},
29 {11000, 11000},
30 {6000, 6000},
31 {9000, 9000},
32 {12000, 12000},
33 {18000, 18000},
34 {24000, 24000},
35 {36000, 36000},
36 {48000, 48000},
37 {54000, 54000},
38 {6500, 7200},
39 {13000, 14400},
40 {19500, 21700},
41 {26000, 28900},
42 {39000, 43300},
43 {52000, 57800},
44 {58500, 65000},
45 {65000, 72200},
46 {13500, 15000},
47 {27000, 30000},
48 {40500, 45000},
49 {54000, 60000},
50 {81000, 90000},
51 {108000, 120000},
52 {121500, 135000},
53 {135000, 150000},
54 {0, 0}
55};
56
57/* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
58static const u8 up_to_ac[] = {
59 WMM_AC_BE,
60 WMM_AC_BK,
61 WMM_AC_BK,
62 WMM_AC_BE,
63 WMM_AC_VI,
64 WMM_AC_VI,
65 WMM_AC_VO,
66 WMM_AC_VO,
67};
68
69void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id)
70{
71 if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX))
72 return;
73
74 wmi->ep_id = ep_id;
75}
76
77enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi)
78{
79 return wmi->ep_id;
80}
81
82/* Performs DIX to 802.3 encapsulation for transmit packets.
83 * Assumes the entire DIX header is contigous and that there is
84 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
85 */
86int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb)
87{
88 struct ath6kl_llc_snap_hdr *llc_hdr;
89 struct ethhdr *eth_hdr;
90 size_t new_len;
91 __be16 type;
92 u8 *datap;
93 u16 size;
94
95 if (WARN_ON(skb == NULL))
96 return -EINVAL;
97
98 size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr);
99 if (skb_headroom(skb) < size)
100 return -ENOMEM;
101
102 eth_hdr = (struct ethhdr *) skb->data;
103 type = eth_hdr->h_proto;
104
105 if (!is_ethertype(be16_to_cpu(type))) {
106 ath6kl_dbg(ATH6KL_DBG_WMI,
107 "%s: pkt is already in 802.3 format\n", __func__);
108 return 0;
109 }
110
111 new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr);
112
113 skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr));
114 datap = skb->data;
115
116 eth_hdr->h_proto = cpu_to_be16(new_len);
117
118 memcpy(datap, eth_hdr, sizeof(*eth_hdr));
119
120 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr));
121 llc_hdr->dsap = 0xAA;
122 llc_hdr->ssap = 0xAA;
123 llc_hdr->cntl = 0x03;
124 llc_hdr->org_code[0] = 0x0;
125 llc_hdr->org_code[1] = 0x0;
126 llc_hdr->org_code[2] = 0x0;
127 llc_hdr->eth_type = type;
128
129 return 0;
130}
131
132static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb,
133 u8 *version, void *tx_meta_info)
134{
135 struct wmi_tx_meta_v1 *v1;
136 struct wmi_tx_meta_v2 *v2;
137
138 if (WARN_ON(skb == NULL || version == NULL))
139 return -EINVAL;
140
141 switch (*version) {
142 case WMI_META_VERSION_1:
143 skb_push(skb, WMI_MAX_TX_META_SZ);
144 v1 = (struct wmi_tx_meta_v1 *) skb->data;
145 v1->pkt_id = 0;
146 v1->rate_plcy_id = 0;
147 *version = WMI_META_VERSION_1;
148 break;
149 case WMI_META_VERSION_2:
150 skb_push(skb, WMI_MAX_TX_META_SZ);
151 v2 = (struct wmi_tx_meta_v2 *) skb->data;
152 memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info,
153 sizeof(struct wmi_tx_meta_v2));
154 break;
155 }
156
157 return 0;
158}
159
160int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
161 u8 msg_type, bool more_data,
162 enum wmi_data_hdr_data_type data_type,
163 u8 meta_ver, void *tx_meta_info)
164{
165 struct wmi_data_hdr *data_hdr;
166 int ret;
167
168 if (WARN_ON(skb == NULL))
169 return -EINVAL;
170
Vasanthakumar Thiagarajan3ce6ff52011-08-22 20:40:21 +0530171 if (tx_meta_info) {
172 ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info);
173 if (ret)
174 return ret;
175 }
Kalle Valobdcd8172011-07-18 00:22:30 +0300176
177 skb_push(skb, sizeof(struct wmi_data_hdr));
178
179 data_hdr = (struct wmi_data_hdr *)skb->data;
180 memset(data_hdr, 0, sizeof(struct wmi_data_hdr));
181
182 data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT;
183 data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT;
184
185 if (more_data)
186 data_hdr->info |=
187 WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT;
188
189 data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT);
190 data_hdr->info3 = 0;
191
192 return 0;
193}
194
195static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri)
196{
197 struct iphdr *ip_hdr = (struct iphdr *) pkt;
198 u8 ip_pri;
199
200 /*
201 * Determine IPTOS priority
202 *
203 * IP-TOS - 8bits
204 * : DSCP(6-bits) ECN(2-bits)
205 * : DSCP - P2 P1 P0 X X X
206 * where (P2 P1 P0) form 802.1D
207 */
208 ip_pri = ip_hdr->tos >> 5;
209 ip_pri &= 0x7;
210
211 if ((layer2_pri & 0x7) > ip_pri)
212 return (u8) layer2_pri & 0x7;
213 else
214 return ip_pri;
215}
216
217int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb,
218 u32 layer2_priority, bool wmm_enabled,
219 u8 *ac)
220{
221 struct wmi_data_hdr *data_hdr;
222 struct ath6kl_llc_snap_hdr *llc_hdr;
223 struct wmi_create_pstream_cmd cmd;
224 u32 meta_size, hdr_size;
225 u16 ip_type = IP_ETHERTYPE;
226 u8 stream_exist, usr_pri;
227 u8 traffic_class = WMM_AC_BE;
228 u8 *datap;
229
230 if (WARN_ON(skb == NULL))
231 return -EINVAL;
232
233 datap = skb->data;
234 data_hdr = (struct wmi_data_hdr *) datap;
235
236 meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
237 WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0;
238
239 if (!wmm_enabled) {
240 /* If WMM is disabled all traffic goes as BE traffic */
241 usr_pri = 0;
242 } else {
243 hdr_size = sizeof(struct ethhdr);
244
245 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap +
246 sizeof(struct
247 wmi_data_hdr) +
248 meta_size + hdr_size);
249
250 if (llc_hdr->eth_type == htons(ip_type)) {
251 /*
252 * Extract the endpoint info from the TOS field
253 * in the IP header.
254 */
255 usr_pri =
256 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
257 sizeof(struct ath6kl_llc_snap_hdr),
258 layer2_priority);
259 } else
260 usr_pri = layer2_priority & 0x7;
261 }
262
263 /* workaround for WMM S5 */
264 if ((wmi->traffic_class == WMM_AC_VI) &&
265 ((usr_pri == 5) || (usr_pri == 4)))
266 usr_pri = 1;
267
268 /* Convert user priority to traffic class */
269 traffic_class = up_to_ac[usr_pri & 0x7];
270
271 wmi_data_hdr_set_up(data_hdr, usr_pri);
272
273 spin_lock_bh(&wmi->lock);
274 stream_exist = wmi->fat_pipe_exist;
275 spin_unlock_bh(&wmi->lock);
276
277 if (!(stream_exist & (1 << traffic_class))) {
278 memset(&cmd, 0, sizeof(cmd));
279 cmd.traffic_class = traffic_class;
280 cmd.user_pri = usr_pri;
281 cmd.inactivity_int =
282 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT);
283 /* Implicit streams are created with TSID 0xFF */
284 cmd.tsid = WMI_IMPLICIT_PSTREAM;
285 ath6kl_wmi_create_pstream_cmd(wmi, &cmd);
286 }
287
288 *ac = traffic_class;
289
290 return 0;
291}
292
293int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
294{
295 struct ieee80211_hdr_3addr *pwh, wh;
296 struct ath6kl_llc_snap_hdr *llc_hdr;
297 struct ethhdr eth_hdr;
298 u32 hdr_size;
299 u8 *datap;
300 __le16 sub_type;
301
302 if (WARN_ON(skb == NULL))
303 return -EINVAL;
304
305 datap = skb->data;
306 pwh = (struct ieee80211_hdr_3addr *) datap;
307
308 sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
309
310 memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr));
311
312 /* Strip off the 802.11 header */
313 if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
314 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
315 sizeof(u32));
316 skb_pull(skb, hdr_size);
317 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA))
318 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
319
320 datap = skb->data;
321 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
322
Raja Manic8790cba2011-07-19 19:27:32 +0530323 memset(&eth_hdr, 0, sizeof(eth_hdr));
Kalle Valobdcd8172011-07-18 00:22:30 +0300324 eth_hdr.h_proto = llc_hdr->eth_type;
Kalle Valobdcd8172011-07-18 00:22:30 +0300325
326 switch ((le16_to_cpu(wh.frame_control)) &
327 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
328 case 0:
329 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
330 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
331 break;
332 case IEEE80211_FCTL_TODS:
333 memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
334 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
335 break;
336 case IEEE80211_FCTL_FROMDS:
337 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
338 memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN);
339 break;
340 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
341 break;
342 }
343
344 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
345 skb_push(skb, sizeof(eth_hdr));
346
347 datap = skb->data;
348
349 memcpy(datap, &eth_hdr, sizeof(eth_hdr));
350
351 return 0;
352}
353
354/*
355 * Performs 802.3 to DIX encapsulation for received packets.
356 * Assumes the entire 802.3 header is contigous.
357 */
358int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
359{
360 struct ath6kl_llc_snap_hdr *llc_hdr;
361 struct ethhdr eth_hdr;
362 u8 *datap;
363
364 if (WARN_ON(skb == NULL))
365 return -EINVAL;
366
367 datap = skb->data;
368
369 memcpy(&eth_hdr, datap, sizeof(eth_hdr));
370
371 llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr));
372 eth_hdr.h_proto = llc_hdr->eth_type;
373
374 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
375 datap = skb->data;
376
377 memcpy(datap, &eth_hdr, sizeof(eth_hdr));
378
379 return 0;
380}
381
Kalle Valobdcd8172011-07-18 00:22:30 +0300382static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb,
383 u8 *datap)
384{
385 struct wmi_bss_info_hdr2 bih2;
386 struct wmi_bss_info_hdr *bih;
387
388 memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2));
389
390 skb_push(skb, 4);
391 bih = (struct wmi_bss_info_hdr *) skb->data;
392
393 bih->ch = bih2.ch;
394 bih->frame_type = bih2.frame_type;
395 bih->snr = bih2.snr;
396 bih->rssi = a_cpu_to_sle16(bih2.snr - 95);
397 bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask));
398 memcpy(bih->bssid, bih2.bssid, ETH_ALEN);
399}
400
401static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
402{
403 struct tx_complete_msg_v1 *msg_v1;
404 struct wmi_tx_complete_event *evt;
405 int index;
406 u16 size;
407
408 evt = (struct wmi_tx_complete_event *) datap;
409
410 ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
411 evt->num_msg, evt->msg_len, evt->msg_type);
412
413 if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI))
414 return 0;
415
416 for (index = 0; index < evt->num_msg; index++) {
417 size = sizeof(struct wmi_tx_complete_event) +
418 (index * sizeof(struct tx_complete_msg_v1));
419 msg_v1 = (struct tx_complete_msg_v1 *)(datap + size);
420
421 ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n",
422 msg_v1->status, msg_v1->pkt_id,
423 msg_v1->rate_idx, msg_v1->ack_failures);
424 }
425
426 return 0;
427}
428
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300429static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap,
430 int len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300431{
432 struct wmi_remain_on_chnl_event *ev;
433 u32 freq;
434 u32 dur;
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300435 struct ieee80211_channel *chan;
436 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300437
438 if (len < sizeof(*ev))
439 return -EINVAL;
440
441 ev = (struct wmi_remain_on_chnl_event *) datap;
442 freq = le32_to_cpu(ev->freq);
443 dur = le32_to_cpu(ev->duration);
444 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
445 freq, dur);
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300446 chan = ieee80211_get_channel(ar->wdev->wiphy, freq);
447 if (!chan) {
448 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel "
449 "(freq=%u)\n", freq);
450 return -EINVAL;
451 }
452 cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT,
453 dur, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300454
455 return 0;
456}
457
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300458static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
459 u8 *datap, int len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300460{
461 struct wmi_cancel_remain_on_chnl_event *ev;
462 u32 freq;
463 u32 dur;
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300464 struct ieee80211_channel *chan;
465 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300466
467 if (len < sizeof(*ev))
468 return -EINVAL;
469
470 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
471 freq = le32_to_cpu(ev->freq);
472 dur = le32_to_cpu(ev->duration);
473 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u "
474 "status=%u\n", freq, dur, ev->status);
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300475 chan = ieee80211_get_channel(ar->wdev->wiphy, freq);
476 if (!chan) {
477 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown "
478 "channel (freq=%u)\n", freq);
479 return -EINVAL;
480 }
481 cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan,
482 NL80211_CHAN_NO_HT, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300483
484 return 0;
485}
486
Jouni Malinena0df5db2011-08-30 21:58:02 +0300487static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300488{
489 struct wmi_tx_status_event *ev;
490 u32 id;
Jouni Malinena0df5db2011-08-30 21:58:02 +0300491 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300492
493 if (len < sizeof(*ev))
494 return -EINVAL;
495
496 ev = (struct wmi_tx_status_event *) datap;
497 id = le32_to_cpu(ev->id);
498 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
499 id, ev->ack_status);
Jouni Malinena0df5db2011-08-30 21:58:02 +0300500 if (wmi->last_mgmt_tx_frame) {
501 cfg80211_mgmt_tx_status(ar->net_dev, id,
502 wmi->last_mgmt_tx_frame,
503 wmi->last_mgmt_tx_frame_len,
504 !!ev->ack_status, GFP_ATOMIC);
505 kfree(wmi->last_mgmt_tx_frame);
506 wmi->last_mgmt_tx_frame = NULL;
507 wmi->last_mgmt_tx_frame_len = 0;
508 }
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300509
510 return 0;
511}
512
Jouni Malinenae32c302011-08-30 21:58:01 +0300513static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300514{
515 struct wmi_p2p_rx_probe_req_event *ev;
Jouni Malinenae32c302011-08-30 21:58:01 +0300516 u32 freq;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300517 u16 dlen;
Jouni Malinenae32c302011-08-30 21:58:01 +0300518 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300519
520 if (len < sizeof(*ev))
521 return -EINVAL;
522
523 ev = (struct wmi_p2p_rx_probe_req_event *) datap;
Jouni Malinenae32c302011-08-30 21:58:01 +0300524 freq = le32_to_cpu(ev->freq);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300525 dlen = le16_to_cpu(ev->len);
Jouni Malinenae32c302011-08-30 21:58:01 +0300526 if (datap + len < ev->data + dlen) {
527 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
528 "len=%d dlen=%u\n", len, dlen);
529 return -EINVAL;
530 }
531 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u "
532 "probe_req_report=%d\n",
533 dlen, freq, ar->probe_req_report);
534
535 if (ar->probe_req_report || ar->nw_type == AP_NETWORK)
536 cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300537
538 return 0;
539}
540
541static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
542{
543 struct wmi_p2p_capabilities_event *ev;
544 u16 dlen;
545
546 if (len < sizeof(*ev))
547 return -EINVAL;
548
549 ev = (struct wmi_p2p_capabilities_event *) datap;
550 dlen = le16_to_cpu(ev->len);
551 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
552
553 return 0;
554}
555
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300556static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300557{
558 struct wmi_rx_action_event *ev;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300559 u32 freq;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300560 u16 dlen;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300561 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300562
563 if (len < sizeof(*ev))
564 return -EINVAL;
565
566 ev = (struct wmi_rx_action_event *) datap;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300567 freq = le32_to_cpu(ev->freq);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300568 dlen = le16_to_cpu(ev->len);
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300569 if (datap + len < ev->data + dlen) {
570 ath6kl_err("invalid wmi_rx_action_event: "
571 "len=%d dlen=%u\n", len, dlen);
572 return -EINVAL;
573 }
574 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
575 cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300576
577 return 0;
578}
579
580static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
581{
582 struct wmi_p2p_info_event *ev;
583 u32 flags;
584 u16 dlen;
585
586 if (len < sizeof(*ev))
587 return -EINVAL;
588
589 ev = (struct wmi_p2p_info_event *) datap;
590 flags = le32_to_cpu(ev->info_req_flags);
591 dlen = le16_to_cpu(ev->len);
592 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
593
594 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
595 struct wmi_p2p_capabilities *cap;
596 if (dlen < sizeof(*cap))
597 return -EINVAL;
598 cap = (struct wmi_p2p_capabilities *) ev->data;
599 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
600 cap->go_power_save);
601 }
602
603 if (flags & P2P_FLAG_MACADDR_REQ) {
604 struct wmi_p2p_macaddr *mac;
605 if (dlen < sizeof(*mac))
606 return -EINVAL;
607 mac = (struct wmi_p2p_macaddr *) ev->data;
608 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
609 mac->mac_addr);
610 }
611
612 if (flags & P2P_FLAG_HMODEL_REQ) {
613 struct wmi_p2p_hmodel *mod;
614 if (dlen < sizeof(*mod))
615 return -EINVAL;
616 mod = (struct wmi_p2p_hmodel *) ev->data;
617 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
618 mod->p2p_model,
619 mod->p2p_model ? "host" : "firmware");
620 }
621 return 0;
622}
623
Kalle Valobdcd8172011-07-18 00:22:30 +0300624static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
625{
626 struct sk_buff *skb;
627
628 skb = ath6kl_buf_alloc(size);
629 if (!skb)
630 return NULL;
631
632 skb_put(skb, size);
633 if (size)
634 memset(skb->data, 0, size);
635
636 return skb;
637}
638
639/* Send a "simple" wmi command -- one with no arguments */
640static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id)
641{
642 struct sk_buff *skb;
643 int ret;
644
645 skb = ath6kl_wmi_get_new_buf(0);
646 if (!skb)
647 return -ENOMEM;
648
649 ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG);
650
651 return ret;
652}
653
654static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
655{
656 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
657
658 if (len < sizeof(struct wmi_ready_event_2))
659 return -EINVAL;
660
661 wmi->ready = true;
662 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
663 le32_to_cpu(ev->sw_version),
664 le32_to_cpu(ev->abi_version));
665
666 return 0;
667}
668
Vivek Natarajane5090442011-08-31 15:02:19 +0530669/*
670 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
671 * at which the station has to roam can be passed with
672 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
673 * in dBm.
674 */
675int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
676{
677 struct sk_buff *skb;
678 struct roam_ctrl_cmd *cmd;
679
680 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
681 if (!skb)
682 return -ENOMEM;
683
684 cmd = (struct roam_ctrl_cmd *) skb->data;
685
686 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
687 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
688 DEF_SCAN_FOR_ROAM_INTVL);
689 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
690 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
691 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
692
693 ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG);
694
695 return 0;
696}
697
Kalle Valobdcd8172011-07-18 00:22:30 +0300698static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len)
699{
700 struct wmi_connect_event *ev;
701 u8 *pie, *peie;
Jouni Malinen572e27c2011-09-05 17:38:45 +0300702 struct ath6kl *ar = wmi->parent_dev;
Kalle Valobdcd8172011-07-18 00:22:30 +0300703
704 if (len < sizeof(struct wmi_connect_event))
705 return -EINVAL;
706
707 ev = (struct wmi_connect_event *) datap;
708
Jouni Malinen572e27c2011-09-05 17:38:45 +0300709 if (ar->nw_type == AP_NETWORK) {
710 /* AP mode start/STA connected event */
711 struct net_device *dev = ar->net_dev;
712 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
713 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM "
714 "(AP started)\n",
715 __func__, le16_to_cpu(ev->u.ap_bss.ch),
716 ev->u.ap_bss.bssid);
717 ath6kl_connect_ap_mode_bss(
718 ar, le16_to_cpu(ev->u.ap_bss.ch));
719 } else {
720 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM "
721 "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
722 "(STA connected)\n",
723 __func__, ev->u.ap_sta.aid,
724 ev->u.ap_sta.mac_addr,
725 ev->u.ap_sta.auth,
726 ev->u.ap_sta.keymgmt,
727 le16_to_cpu(ev->u.ap_sta.cipher),
728 ev->u.ap_sta.apsd_info);
729 ath6kl_connect_ap_mode_sta(
730 ar, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
731 ev->u.ap_sta.keymgmt,
732 le16_to_cpu(ev->u.ap_sta.cipher),
733 ev->u.ap_sta.auth, ev->assoc_req_len,
734 ev->assoc_info + ev->beacon_ie_len);
735 }
736 return 0;
737 }
738
739 /* STA/IBSS mode connection event */
740
Kalle Valobdcd8172011-07-18 00:22:30 +0300741 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n",
Jouni Malinen572e27c2011-09-05 17:38:45 +0300742 __func__, le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid);
Kalle Valobdcd8172011-07-18 00:22:30 +0300743
Kalle Valobdcd8172011-07-18 00:22:30 +0300744 /* Start of assoc rsp IEs */
745 pie = ev->assoc_info + ev->beacon_ie_len +
746 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
747
748 /* End of assoc rsp IEs */
749 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
750 ev->assoc_resp_len;
751
752 while (pie < peie) {
753 switch (*pie) {
754 case WLAN_EID_VENDOR_SPECIFIC:
755 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
756 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
757 /* WMM OUT (00:50:F2) */
758 if (pie[1] > 5
759 && pie[6] == WMM_PARAM_OUI_SUBTYPE)
760 wmi->is_wmm_enabled = true;
761 }
762 break;
763 }
764
765 if (wmi->is_wmm_enabled)
766 break;
767
768 pie += pie[1] + 2;
769 }
770
Jouni Malinen572e27c2011-09-05 17:38:45 +0300771 ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->u.sta.ch),
772 ev->u.sta.bssid,
773 le16_to_cpu(ev->u.sta.listen_intvl),
774 le16_to_cpu(ev->u.sta.beacon_intvl),
775 le32_to_cpu(ev->u.sta.nw_type),
Kalle Valobdcd8172011-07-18 00:22:30 +0300776 ev->beacon_ie_len, ev->assoc_req_len,
777 ev->assoc_resp_len, ev->assoc_info);
778
779 return 0;
780}
781
782static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len)
783{
784 struct wmi_disconnect_event *ev;
785 wmi->traffic_class = 100;
786
787 if (len < sizeof(struct wmi_disconnect_event))
788 return -EINVAL;
789
790 ev = (struct wmi_disconnect_event *) datap;
Kalle Valobdcd8172011-07-18 00:22:30 +0300791
792 wmi->is_wmm_enabled = false;
793 wmi->pair_crypto_type = NONE_CRYPT;
794 wmi->grp_crypto_type = NONE_CRYPT;
795
796 ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason,
797 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
798 le16_to_cpu(ev->proto_reason_status));
799
800 return 0;
801}
802
803static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
804{
805 struct wmi_peer_node_event *ev;
806
807 if (len < sizeof(struct wmi_peer_node_event))
808 return -EINVAL;
809
810 ev = (struct wmi_peer_node_event *) datap;
811
812 if (ev->event_code == PEER_NODE_JOIN_EVENT)
813 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
814 ev->peer_mac_addr);
815 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
816 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
817 ev->peer_mac_addr);
818
819 return 0;
820}
821
822static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len)
823{
824 struct wmi_tkip_micerr_event *ev;
825
826 if (len < sizeof(struct wmi_tkip_micerr_event))
827 return -EINVAL;
828
829 ev = (struct wmi_tkip_micerr_event *) datap;
830
831 ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast);
832
833 return 0;
834}
835
836static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len,
837 struct ath6kl_common_ie *cie)
838{
839 u8 *frm, *efrm;
840 u8 elemid_ssid = false;
841
842 frm = buf;
843 efrm = (u8 *) (frm + frame_len);
844
845 /*
846 * beacon/probe response frame format
847 * [8] time stamp
848 * [2] beacon interval
849 * [2] capability information
850 * [tlv] ssid
851 * [tlv] supported rates
852 * [tlv] country information
853 * [tlv] parameter set (FH/DS)
854 * [tlv] erp information
855 * [tlv] extended supported rates
856 * [tlv] WMM
857 * [tlv] WPA or RSN
858 * [tlv] Atheros Advanced Capabilities
859 */
860 if ((efrm - frm) < 12)
861 return -EINVAL;
862
863 memset(cie, 0, sizeof(*cie));
864
865 cie->ie_tstamp = frm;
866 frm += 8;
867 cie->ie_beaconInt = *(u16 *) frm;
868 frm += 2;
869 cie->ie_capInfo = *(u16 *) frm;
870 frm += 2;
871 cie->ie_chan = 0;
872
873 while (frm < efrm) {
874 switch (*frm) {
875 case WLAN_EID_SSID:
876 if (!elemid_ssid) {
877 cie->ie_ssid = frm;
878 elemid_ssid = true;
879 }
880 break;
881 case WLAN_EID_SUPP_RATES:
882 cie->ie_rates = frm;
883 break;
884 case WLAN_EID_COUNTRY:
885 cie->ie_country = frm;
886 break;
887 case WLAN_EID_FH_PARAMS:
888 break;
889 case WLAN_EID_DS_PARAMS:
890 cie->ie_chan = frm[2];
891 break;
892 case WLAN_EID_TIM:
893 cie->ie_tim = frm;
894 break;
895 case WLAN_EID_IBSS_PARAMS:
896 break;
897 case WLAN_EID_EXT_SUPP_RATES:
898 cie->ie_xrates = frm;
899 break;
900 case WLAN_EID_ERP_INFO:
901 if (frm[1] != 1)
902 return -EINVAL;
903
904 cie->ie_erp = frm[2];
905 break;
906 case WLAN_EID_RSN:
907 cie->ie_rsn = frm;
908 break;
909 case WLAN_EID_HT_CAPABILITY:
910 cie->ie_htcap = frm;
911 break;
912 case WLAN_EID_HT_INFORMATION:
913 cie->ie_htop = frm;
914 break;
915 case WLAN_EID_VENDOR_SPECIFIC:
916 if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 &&
917 frm[4] == 0xf2) {
918 /* OUT Type (00:50:F2) */
919
920 if (frm[5] == WPA_OUI_TYPE) {
921 /* WPA OUT */
922 cie->ie_wpa = frm;
923 } else if (frm[5] == WMM_OUI_TYPE) {
924 /* WMM OUT */
925 cie->ie_wmm = frm;
926 } else if (frm[5] == WSC_OUT_TYPE) {
927 /* WSC OUT */
928 cie->ie_wsc = frm;
929 }
930
931 } else if (frm[1] > 3 && frm[2] == 0x00
932 && frm[3] == 0x03 && frm[4] == 0x7f
933 && frm[5] == ATH_OUI_TYPE) {
934 /* Atheros OUI (00:03:7f) */
935 cie->ie_ath = frm;
936 }
937 break;
938 default:
939 break;
940 }
941 frm += frm[1] + 2;
942 }
943
944 if ((cie->ie_rates == NULL)
945 || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE))
946 return -EINVAL;
947
948 if ((cie->ie_ssid == NULL)
949 || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN))
950 return -EINVAL;
951
952 return 0;
953}
954
955static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len)
956{
957 struct bss *bss = NULL;
958 struct wmi_bss_info_hdr *bih;
959 u8 cached_ssid_len = 0;
960 u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 };
961 u8 beacon_ssid_len = 0;
962 u8 *buf, *ie_ssid;
963 u8 *ni_buf;
964 int buf_len;
965
966 int ret;
967
968 if (len <= sizeof(struct wmi_bss_info_hdr))
969 return -EINVAL;
970
971 bih = (struct wmi_bss_info_hdr *) datap;
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +0530972 bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid);
Kalle Valobdcd8172011-07-18 00:22:30 +0300973
974 if (a_sle16_to_cpu(bih->rssi) > 0) {
975 if (bss == NULL)
976 return 0;
977 else
978 bih->rssi = a_cpu_to_sle16(bss->ni_rssi);
979 }
980
981 buf = datap + sizeof(struct wmi_bss_info_hdr);
982 len -= sizeof(struct wmi_bss_info_hdr);
983
984 ath6kl_dbg(ATH6KL_DBG_WMI,
985 "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n",
986 bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid);
987
988 if (bss != NULL) {
989 /*
990 * Free up the node. We are about to allocate a new node.
991 * In case of hidden AP, beacon will not have ssid,
992 * but a directed probe response will have it,
993 * so cache the probe-resp-ssid if already present.
994 */
995 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) {
996 ie_ssid = bss->ni_cie.ie_ssid;
997 if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) &&
998 (ie_ssid[2] != 0)) {
999 cached_ssid_len = ie_ssid[1];
1000 memcpy(cached_ssid, ie_ssid + 2,
1001 cached_ssid_len);
1002 }
1003 }
1004
1005 /*
1006 * Use the current average rssi of associated AP base on
1007 * assumption
1008 * 1. Most os with GUI will update RSSI by
1009 * ath6kl_wmi_get_stats_cmd() periodically.
1010 * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling
1011 * ath6kl_wmi_startscan_cmd(...)
1012 * The average value of RSSI give end-user better feeling for
1013 * instance value of scan result. It also sync up RSSI info
1014 * in GUI between scan result and RSSI signal icon.
1015 */
Vasanthakumar Thiagarajan70df0512011-07-21 14:09:07 +05301016 if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) {
Kalle Valobdcd8172011-07-18 00:22:30 +03001017 bih->rssi = a_cpu_to_sle16(bss->ni_rssi);
1018 bih->snr = bss->ni_snr;
1019 }
1020
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05301021 wlan_node_reclaim(&wmi->parent_dev->scan_table, bss);
Kalle Valobdcd8172011-07-18 00:22:30 +03001022 }
1023
1024 /*
1025 * beacon/probe response frame format
1026 * [8] time stamp
1027 * [2] beacon interval
1028 * [2] capability information
1029 * [tlv] ssid
1030 */
1031 beacon_ssid_len = buf[SSID_IE_LEN_INDEX];
1032
1033 /*
1034 * If ssid is cached for this hidden AP, then change
1035 * buffer len accordingly.
1036 */
1037 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) &&
1038 (cached_ssid_len != 0) &&
1039 (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len &&
1040 buf[SSID_IE_LEN_INDEX + 1] == 0))) {
1041
1042 len += (cached_ssid_len - beacon_ssid_len);
1043 }
1044
1045 bss = wlan_node_alloc(len);
1046 if (!bss)
1047 return -ENOMEM;
1048
1049 bss->ni_snr = bih->snr;
1050 bss->ni_rssi = a_sle16_to_cpu(bih->rssi);
1051
1052 if (WARN_ON(!bss->ni_buf))
1053 return -EINVAL;
1054
1055 /*
1056 * In case of hidden AP, beacon will not have ssid,
1057 * but a directed probe response will have it,
1058 * so place the cached-ssid(probe-resp) in the bss info.
1059 */
1060 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) &&
1061 (cached_ssid_len != 0) &&
1062 (beacon_ssid_len == 0 || (beacon_ssid_len &&
1063 buf[SSID_IE_LEN_INDEX + 1] == 0))) {
1064 ni_buf = bss->ni_buf;
1065 buf_len = len;
1066
1067 /*
1068 * Copy the first 14 bytes:
1069 * time-stamp(8), beacon-interval(2),
1070 * cap-info(2), ssid-id(1), ssid-len(1).
1071 */
1072 memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1);
1073
1074 ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len;
1075 ni_buf += (SSID_IE_LEN_INDEX + 1);
1076
1077 buf += (SSID_IE_LEN_INDEX + 1);
1078 buf_len -= (SSID_IE_LEN_INDEX + 1);
1079
1080 memcpy(ni_buf, cached_ssid, cached_ssid_len);
1081 ni_buf += cached_ssid_len;
1082
1083 buf += beacon_ssid_len;
1084 buf_len -= beacon_ssid_len;
1085
1086 if (cached_ssid_len > beacon_ssid_len)
1087 buf_len -= (cached_ssid_len - beacon_ssid_len);
1088
1089 memcpy(ni_buf, buf, buf_len);
1090 } else
1091 memcpy(bss->ni_buf, buf, len);
1092
1093 bss->ni_framelen = len;
1094
1095 ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie);
1096 if (ret) {
1097 wlan_node_free(bss);
1098 return -EINVAL;
1099 }
1100
1101 /*
1102 * Update the frequency in ie_chan, overwriting of channel number
1103 * which is done in ath6kl_wlan_parse_beacon
1104 */
1105 bss->ni_cie.ie_chan = le16_to_cpu(bih->ch);
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05301106 wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid);
Kalle Valobdcd8172011-07-18 00:22:30 +03001107
1108 return 0;
1109}
1110
1111static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len)
1112{
1113 struct bss *bss;
1114 struct wmi_opt_rx_info_hdr *bih;
1115 u8 *buf;
1116
1117 if (len <= sizeof(struct wmi_opt_rx_info_hdr))
1118 return -EINVAL;
1119
1120 bih = (struct wmi_opt_rx_info_hdr *) datap;
1121 buf = datap + sizeof(struct wmi_opt_rx_info_hdr);
1122 len -= sizeof(struct wmi_opt_rx_info_hdr);
1123
1124 ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n",
1125 bih->bssid[4], bih->bssid[5]);
1126
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05301127 bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid);
Kalle Valobdcd8172011-07-18 00:22:30 +03001128 if (bss != NULL) {
1129 /* Free up the node. We are about to allocate a new node. */
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05301130 wlan_node_reclaim(&wmi->parent_dev->scan_table, bss);
Kalle Valobdcd8172011-07-18 00:22:30 +03001131 }
1132
1133 bss = wlan_node_alloc(len);
1134 if (!bss)
1135 return -ENOMEM;
1136
1137 bss->ni_snr = bih->snr;
1138 bss->ni_cie.ie_chan = le16_to_cpu(bih->ch);
1139
1140 if (WARN_ON(!bss->ni_buf))
1141 return -EINVAL;
1142
1143 memcpy(bss->ni_buf, buf, len);
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05301144 wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid);
Kalle Valobdcd8172011-07-18 00:22:30 +03001145
1146 return 0;
1147}
1148
1149/* Inactivity timeout of a fatpipe(pstream) at the target */
1150static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1151 int len)
1152{
1153 struct wmi_pstream_timeout_event *ev;
1154
1155 if (len < sizeof(struct wmi_pstream_timeout_event))
1156 return -EINVAL;
1157
1158 ev = (struct wmi_pstream_timeout_event *) datap;
1159
1160 /*
1161 * When the pstream (fat pipe == AC) timesout, it means there were
1162 * no thinStreams within this pstream & it got implicitly created
1163 * due to data flow on this AC. We start the inactivity timer only
1164 * for implicitly created pstream. Just reset the host state.
1165 */
1166 spin_lock_bh(&wmi->lock);
1167 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1168 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1169 spin_unlock_bh(&wmi->lock);
1170
1171 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1172 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1173
1174 return 0;
1175}
1176
1177static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1178{
1179 struct wmi_bit_rate_reply *reply;
1180 s32 rate;
1181 u32 sgi, index;
1182
1183 if (len < sizeof(struct wmi_bit_rate_reply))
1184 return -EINVAL;
1185
1186 reply = (struct wmi_bit_rate_reply *) datap;
1187
1188 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1189
1190 if (reply->rate_index == (s8) RATE_AUTO) {
1191 rate = RATE_AUTO;
1192 } else {
1193 index = reply->rate_index & 0x7f;
1194 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1195 rate = wmi_rate_tbl[index][sgi];
1196 }
1197
1198 ath6kl_wakeup_event(wmi->parent_dev);
1199
1200 return 0;
1201}
1202
Kalle Valo003353b0d2011-09-01 10:14:21 +03001203static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len)
1204{
1205 ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len);
1206
1207 return 0;
1208}
1209
Kalle Valobdcd8172011-07-18 00:22:30 +03001210static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1211{
1212 if (len < sizeof(struct wmi_fix_rates_reply))
1213 return -EINVAL;
1214
1215 ath6kl_wakeup_event(wmi->parent_dev);
1216
1217 return 0;
1218}
1219
1220static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1221{
1222 if (len < sizeof(struct wmi_channel_list_reply))
1223 return -EINVAL;
1224
1225 ath6kl_wakeup_event(wmi->parent_dev);
1226
1227 return 0;
1228}
1229
1230static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1231{
1232 struct wmi_tx_pwr_reply *reply;
1233
1234 if (len < sizeof(struct wmi_tx_pwr_reply))
1235 return -EINVAL;
1236
1237 reply = (struct wmi_tx_pwr_reply *) datap;
1238 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1239
1240 return 0;
1241}
1242
1243static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1244{
1245 if (len < sizeof(struct wmi_get_keepalive_cmd))
1246 return -EINVAL;
1247
1248 ath6kl_wakeup_event(wmi->parent_dev);
1249
1250 return 0;
1251}
1252
1253static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len)
1254{
1255 struct wmi_scan_complete_event *ev;
1256
1257 ev = (struct wmi_scan_complete_event *) datap;
1258
1259 if (a_sle32_to_cpu(ev->status) == 0)
Vasanthakumar Thiagarajane4c7ffc2011-07-21 13:49:32 +05301260 wlan_refresh_inactive_nodes(wmi->parent_dev);
Kalle Valobdcd8172011-07-18 00:22:30 +03001261
1262 ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status));
1263 wmi->is_probe_ssid = false;
1264
1265 return 0;
1266}
1267
1268/*
1269 * Target is reporting a programming error. This is for
1270 * developer aid only. Target only checks a few common violations
1271 * and it is responsibility of host to do all error checking.
1272 * Behavior of target after wmi error event is undefined.
1273 * A reset is recommended.
1274 */
1275static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1276{
1277 const char *type = "unknown error";
1278 struct wmi_cmd_error_event *ev;
1279 ev = (struct wmi_cmd_error_event *) datap;
1280
1281 switch (ev->err_code) {
1282 case INVALID_PARAM:
1283 type = "invalid parameter";
1284 break;
1285 case ILLEGAL_STATE:
1286 type = "invalid state";
1287 break;
1288 case INTERNAL_ERROR:
1289 type = "internal error";
1290 break;
1291 }
1292
1293 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1294 ev->cmd_id, type);
1295
1296 return 0;
1297}
1298
1299static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len)
1300{
1301 ath6kl_tgt_stats_event(wmi->parent_dev, datap, len);
1302
1303 return 0;
1304}
1305
1306static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1307 struct sq_threshold_params *sq_thresh,
1308 u32 size)
1309{
1310 u32 index;
1311 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1312
1313 /* The list is already in sorted order. Get the next lower value */
1314 for (index = 0; index < size; index++) {
1315 if (rssi < sq_thresh->upper_threshold[index]) {
1316 threshold = (u8) sq_thresh->upper_threshold[index];
1317 break;
1318 }
1319 }
1320
1321 return threshold;
1322}
1323
1324static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1325 struct sq_threshold_params *sq_thresh,
1326 u32 size)
1327{
1328 u32 index;
1329 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1330
1331 /* The list is already in sorted order. Get the next lower value */
1332 for (index = 0; index < size; index++) {
1333 if (rssi > sq_thresh->lower_threshold[index]) {
1334 threshold = (u8) sq_thresh->lower_threshold[index];
1335 break;
1336 }
1337 }
1338
1339 return threshold;
1340}
1341
1342static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1343 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1344{
1345 struct sk_buff *skb;
1346 struct wmi_rssi_threshold_params_cmd *cmd;
1347
1348 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1349 if (!skb)
1350 return -ENOMEM;
1351
1352 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1353 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1354
1355 return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
1356 NO_SYNC_WMIFLAG);
1357}
1358
1359static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1360 int len)
1361{
1362 struct wmi_rssi_threshold_event *reply;
1363 struct wmi_rssi_threshold_params_cmd cmd;
1364 struct sq_threshold_params *sq_thresh;
1365 enum wmi_rssi_threshold_val new_threshold;
1366 u8 upper_rssi_threshold, lower_rssi_threshold;
1367 s16 rssi;
1368 int ret;
1369
1370 if (len < sizeof(struct wmi_rssi_threshold_event))
1371 return -EINVAL;
1372
1373 reply = (struct wmi_rssi_threshold_event *) datap;
1374 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1375 rssi = a_sle16_to_cpu(reply->rssi);
1376
1377 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1378
1379 /*
1380 * Identify the threshold breached and communicate that to the app.
1381 * After that install a new set of thresholds based on the signal
1382 * quality reported by the target
1383 */
1384 if (new_threshold) {
1385 /* Upper threshold breached */
1386 if (rssi < sq_thresh->upper_threshold[0]) {
1387 ath6kl_dbg(ATH6KL_DBG_WMI,
1388 "spurious upper rssi threshold event: %d\n",
1389 rssi);
1390 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1391 (rssi >= sq_thresh->upper_threshold[0])) {
1392 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1393 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1394 (rssi >= sq_thresh->upper_threshold[1])) {
1395 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1396 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1397 (rssi >= sq_thresh->upper_threshold[2])) {
1398 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1399 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1400 (rssi >= sq_thresh->upper_threshold[3])) {
1401 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1402 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1403 (rssi >= sq_thresh->upper_threshold[4])) {
1404 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1405 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1406 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1407 }
1408 } else {
1409 /* Lower threshold breached */
1410 if (rssi > sq_thresh->lower_threshold[0]) {
1411 ath6kl_dbg(ATH6KL_DBG_WMI,
1412 "spurious lower rssi threshold event: %d %d\n",
1413 rssi, sq_thresh->lower_threshold[0]);
1414 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1415 (rssi <= sq_thresh->lower_threshold[0])) {
1416 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1417 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1418 (rssi <= sq_thresh->lower_threshold[1])) {
1419 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1420 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1421 (rssi <= sq_thresh->lower_threshold[2])) {
1422 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1423 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1424 (rssi <= sq_thresh->lower_threshold[3])) {
1425 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1426 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1427 (rssi <= sq_thresh->lower_threshold[4])) {
1428 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1429 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1430 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1431 }
1432 }
1433
1434 /* Calculate and install the next set of thresholds */
1435 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1436 sq_thresh->lower_threshold_valid_count);
1437 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1438 sq_thresh->upper_threshold_valid_count);
1439
1440 /* Issue a wmi command to install the thresholds */
1441 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1442 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1443 cmd.weight = sq_thresh->weight;
1444 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1445
1446 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1447 if (ret) {
1448 ath6kl_err("unable to configure rssi thresholds\n");
1449 return -EIO;
1450 }
1451
1452 return 0;
1453}
1454
1455static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len)
1456{
1457 struct wmi_cac_event *reply;
1458 struct ieee80211_tspec_ie *ts;
1459 u16 active_tsids, tsinfo;
1460 u8 tsid, index;
1461 u8 ts_id;
1462
1463 if (len < sizeof(struct wmi_cac_event))
1464 return -EINVAL;
1465
1466 reply = (struct wmi_cac_event *) datap;
1467
1468 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1469 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1470
1471 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1472 tsinfo = le16_to_cpu(ts->tsinfo);
1473 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1474 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1475
1476 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid);
1477 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1478 /*
1479 * Following assumes that there is only one outstanding
1480 * ADDTS request when this event is received
1481 */
1482 spin_lock_bh(&wmi->lock);
1483 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1484 spin_unlock_bh(&wmi->lock);
1485
1486 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1487 if ((active_tsids >> index) & 1)
1488 break;
1489 }
1490 if (index < (sizeof(active_tsids) * 8))
1491 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index);
1492 }
1493
1494 /*
1495 * Clear active tsids and Add missing handling
1496 * for delete qos stream from AP
1497 */
1498 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1499
1500 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1501 tsinfo = le16_to_cpu(ts->tsinfo);
1502 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1503 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1504
1505 spin_lock_bh(&wmi->lock);
1506 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1507 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1508 spin_unlock_bh(&wmi->lock);
1509
1510 /* Indicate stream inactivity to driver layer only if all tsids
1511 * within this AC are deleted.
1512 */
1513 if (!active_tsids) {
1514 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1515 false);
1516 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1517 }
1518 }
1519
1520 return 0;
1521}
1522
1523static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1524 struct wmi_snr_threshold_params_cmd *snr_cmd)
1525{
1526 struct sk_buff *skb;
1527 struct wmi_snr_threshold_params_cmd *cmd;
1528
1529 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1530 if (!skb)
1531 return -ENOMEM;
1532
1533 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1534 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1535
1536 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
1537 NO_SYNC_WMIFLAG);
1538}
1539
1540static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1541 int len)
1542{
1543 struct wmi_snr_threshold_event *reply;
1544 struct sq_threshold_params *sq_thresh;
1545 struct wmi_snr_threshold_params_cmd cmd;
1546 enum wmi_snr_threshold_val new_threshold;
1547 u8 upper_snr_threshold, lower_snr_threshold;
1548 s16 snr;
1549 int ret;
1550
1551 if (len < sizeof(struct wmi_snr_threshold_event))
1552 return -EINVAL;
1553
1554 reply = (struct wmi_snr_threshold_event *) datap;
1555
1556 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1557 snr = reply->snr;
1558
1559 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1560
1561 /*
1562 * Identify the threshold breached and communicate that to the app.
1563 * After that install a new set of thresholds based on the signal
1564 * quality reported by the target.
1565 */
1566 if (new_threshold) {
1567 /* Upper threshold breached */
1568 if (snr < sq_thresh->upper_threshold[0]) {
1569 ath6kl_dbg(ATH6KL_DBG_WMI,
1570 "spurious upper snr threshold event: %d\n",
1571 snr);
1572 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1573 (snr >= sq_thresh->upper_threshold[0])) {
1574 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1575 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1576 (snr >= sq_thresh->upper_threshold[1])) {
1577 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1578 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1579 (snr >= sq_thresh->upper_threshold[2])) {
1580 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1581 } else if (snr >= sq_thresh->upper_threshold[3]) {
1582 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1583 }
1584 } else {
1585 /* Lower threshold breached */
1586 if (snr > sq_thresh->lower_threshold[0]) {
1587 ath6kl_dbg(ATH6KL_DBG_WMI,
1588 "spurious lower snr threshold event: %d\n",
1589 sq_thresh->lower_threshold[0]);
1590 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1591 (snr <= sq_thresh->lower_threshold[0])) {
1592 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1593 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1594 (snr <= sq_thresh->lower_threshold[1])) {
1595 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1596 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1597 (snr <= sq_thresh->lower_threshold[2])) {
1598 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1599 } else if (snr <= sq_thresh->lower_threshold[3]) {
1600 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1601 }
1602 }
1603
1604 /* Calculate and install the next set of thresholds */
1605 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1606 sq_thresh->lower_threshold_valid_count);
1607 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1608 sq_thresh->upper_threshold_valid_count);
1609
1610 /* Issue a wmi command to install the thresholds */
1611 cmd.thresh_above1_val = upper_snr_threshold;
1612 cmd.thresh_below1_val = lower_snr_threshold;
1613 cmd.weight = sq_thresh->weight;
1614 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1615
1616 ath6kl_dbg(ATH6KL_DBG_WMI,
1617 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1618 snr, new_threshold,
1619 lower_snr_threshold, upper_snr_threshold);
1620
1621 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1622 if (ret) {
1623 ath6kl_err("unable to configure snr threshold\n");
1624 return -EIO;
1625 }
1626
1627 return 0;
1628}
1629
1630static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1631{
1632 u16 ap_info_entry_size;
1633 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1634 struct wmi_ap_info_v1 *ap_info_v1;
1635 u8 index;
1636
1637 if (len < sizeof(struct wmi_aplist_event) ||
1638 ev->ap_list_ver != APLIST_VER1)
1639 return -EINVAL;
1640
1641 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1642 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1643
1644 ath6kl_dbg(ATH6KL_DBG_WMI,
1645 "number of APs in aplist event: %d\n", ev->num_ap);
1646
1647 if (len < (int) (sizeof(struct wmi_aplist_event) +
1648 (ev->num_ap - 1) * ap_info_entry_size))
1649 return -EINVAL;
1650
1651 /* AP list version 1 contents */
1652 for (index = 0; index < ev->num_ap; index++) {
1653 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1654 index, ap_info_v1->bssid, ap_info_v1->channel);
1655 ap_info_v1++;
1656 }
1657
1658 return 0;
1659}
1660
1661int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb,
1662 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1663{
1664 struct wmi_cmd_hdr *cmd_hdr;
1665 enum htc_endpoint_id ep_id = wmi->ep_id;
1666 int ret;
1667
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03001668 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id);
1669
Kalle Valobdcd8172011-07-18 00:22:30 +03001670 if (WARN_ON(skb == NULL))
1671 return -EINVAL;
1672
1673 if (sync_flag >= END_WMIFLAG) {
1674 dev_kfree_skb(skb);
1675 return -EINVAL;
1676 }
1677
1678 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1679 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1680 /*
1681 * Make sure all data currently queued is transmitted before
1682 * the cmd execution. Establish a new sync point.
1683 */
1684 ath6kl_wmi_sync_point(wmi);
1685 }
1686
1687 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1688
1689 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1690 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
1691 cmd_hdr->info1 = 0; /* added for virtual interface */
1692
1693 /* Only for OPT_TX_CMD, use BE endpoint. */
1694 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1695 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
1696 false, false, 0, NULL);
1697 if (ret) {
1698 dev_kfree_skb(skb);
1699 return ret;
1700 }
1701 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1702 }
1703
1704 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1705
1706 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1707 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1708 /*
1709 * Make sure all new data queued waits for the command to
1710 * execute. Establish a new sync point.
1711 */
1712 ath6kl_wmi_sync_point(wmi);
1713 }
1714
1715 return 0;
1716}
1717
1718int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type,
1719 enum dot11_auth_mode dot11_auth_mode,
1720 enum auth_mode auth_mode,
1721 enum crypto_type pairwise_crypto,
1722 u8 pairwise_crypto_len,
1723 enum crypto_type group_crypto,
1724 u8 group_crypto_len, int ssid_len, u8 *ssid,
1725 u8 *bssid, u16 channel, u32 ctrl_flags)
1726{
1727 struct sk_buff *skb;
1728 struct wmi_connect_cmd *cc;
1729 int ret;
1730
1731 wmi->traffic_class = 100;
1732
1733 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1734 return -EINVAL;
1735
1736 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1737 return -EINVAL;
1738
1739 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1740 if (!skb)
1741 return -ENOMEM;
1742
1743 cc = (struct wmi_connect_cmd *) skb->data;
1744
1745 if (ssid_len)
1746 memcpy(cc->ssid, ssid, ssid_len);
1747
1748 cc->ssid_len = ssid_len;
1749 cc->nw_type = nw_type;
1750 cc->dot11_auth_mode = dot11_auth_mode;
1751 cc->auth_mode = auth_mode;
1752 cc->prwise_crypto_type = pairwise_crypto;
1753 cc->prwise_crypto_len = pairwise_crypto_len;
1754 cc->grp_crypto_type = group_crypto;
1755 cc->grp_crypto_len = group_crypto_len;
1756 cc->ch = cpu_to_le16(channel);
1757 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
1758
1759 if (bssid != NULL)
1760 memcpy(cc->bssid, bssid, ETH_ALEN);
1761
1762 wmi->pair_crypto_type = pairwise_crypto;
1763 wmi->grp_crypto_type = group_crypto;
1764
1765 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG);
1766
1767 return ret;
1768}
1769
1770int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel)
1771{
1772 struct sk_buff *skb;
1773 struct wmi_reconnect_cmd *cc;
1774 int ret;
1775
1776 wmi->traffic_class = 100;
1777
1778 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1779 if (!skb)
1780 return -ENOMEM;
1781
1782 cc = (struct wmi_reconnect_cmd *) skb->data;
1783 cc->channel = cpu_to_le16(channel);
1784
1785 if (bssid != NULL)
1786 memcpy(cc->bssid, bssid, ETH_ALEN);
1787
1788 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID,
1789 NO_SYNC_WMIFLAG);
1790
1791 return ret;
1792}
1793
1794int ath6kl_wmi_disconnect_cmd(struct wmi *wmi)
1795{
1796 int ret;
1797
1798 wmi->traffic_class = 100;
1799
1800 /* Disconnect command does not need to do a SYNC before. */
1801 ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID);
1802
1803 return ret;
1804}
1805
1806int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type,
1807 u32 force_fgscan, u32 is_legacy,
1808 u32 home_dwell_time, u32 force_scan_interval,
1809 s8 num_chan, u16 *ch_list)
1810{
1811 struct sk_buff *skb;
1812 struct wmi_start_scan_cmd *sc;
1813 s8 size;
Edward Lu1276c9e2011-08-30 21:58:00 +03001814 int i, ret;
Kalle Valobdcd8172011-07-18 00:22:30 +03001815
1816 size = sizeof(struct wmi_start_scan_cmd);
1817
1818 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1819 return -EINVAL;
1820
1821 if (num_chan > WMI_MAX_CHANNELS)
1822 return -EINVAL;
1823
1824 if (num_chan)
1825 size += sizeof(u16) * (num_chan - 1);
1826
1827 skb = ath6kl_wmi_get_new_buf(size);
1828 if (!skb)
1829 return -ENOMEM;
1830
1831 sc = (struct wmi_start_scan_cmd *) skb->data;
1832 sc->scan_type = scan_type;
1833 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1834 sc->is_legacy = cpu_to_le32(is_legacy);
1835 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1836 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1837 sc->num_ch = num_chan;
1838
Edward Lu1276c9e2011-08-30 21:58:00 +03001839 for (i = 0; i < num_chan; i++)
1840 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
Kalle Valobdcd8172011-07-18 00:22:30 +03001841
1842 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID,
1843 NO_SYNC_WMIFLAG);
1844
1845 return ret;
1846}
1847
1848int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec,
1849 u16 fg_end_sec, u16 bg_sec,
1850 u16 minact_chdw_msec, u16 maxact_chdw_msec,
1851 u16 pas_chdw_msec, u8 short_scan_ratio,
1852 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
1853 u16 maxact_scan_per_ssid)
1854{
1855 struct sk_buff *skb;
1856 struct wmi_scan_params_cmd *sc;
1857 int ret;
1858
1859 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
1860 if (!skb)
1861 return -ENOMEM;
1862
1863 sc = (struct wmi_scan_params_cmd *) skb->data;
1864 sc->fg_start_period = cpu_to_le16(fg_start_sec);
1865 sc->fg_end_period = cpu_to_le16(fg_end_sec);
1866 sc->bg_period = cpu_to_le16(bg_sec);
1867 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
1868 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
1869 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
1870 sc->short_scan_ratio = short_scan_ratio;
1871 sc->scan_ctrl_flags = scan_ctrl_flag;
1872 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
1873 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
1874
1875 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID,
1876 NO_SYNC_WMIFLAG);
1877 return ret;
1878}
1879
1880int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask)
1881{
1882 struct sk_buff *skb;
1883 struct wmi_bss_filter_cmd *cmd;
1884 int ret;
1885
1886 if (filter >= LAST_BSS_FILTER)
1887 return -EINVAL;
1888
1889 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1890 if (!skb)
1891 return -ENOMEM;
1892
1893 cmd = (struct wmi_bss_filter_cmd *) skb->data;
1894 cmd->bss_filter = filter;
1895 cmd->ie_mask = cpu_to_le32(ie_mask);
1896
1897 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID,
1898 NO_SYNC_WMIFLAG);
1899 return ret;
1900}
1901
1902int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag,
1903 u8 ssid_len, u8 *ssid)
1904{
1905 struct sk_buff *skb;
1906 struct wmi_probed_ssid_cmd *cmd;
1907 int ret;
1908
1909 if (index > MAX_PROBED_SSID_INDEX)
1910 return -EINVAL;
1911
1912 if (ssid_len > sizeof(cmd->ssid))
1913 return -EINVAL;
1914
1915 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
1916 return -EINVAL;
1917
1918 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
1919 return -EINVAL;
1920
1921 if (flag & SPECIFIC_SSID_FLAG)
1922 wmi->is_probe_ssid = true;
1923
1924 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1925 if (!skb)
1926 return -ENOMEM;
1927
1928 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
1929 cmd->entry_index = index;
1930 cmd->flag = flag;
1931 cmd->ssid_len = ssid_len;
1932 memcpy(cmd->ssid, ssid, ssid_len);
1933
1934 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID,
1935 NO_SYNC_WMIFLAG);
1936 return ret;
1937}
1938
1939int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval,
1940 u16 listen_beacons)
1941{
1942 struct sk_buff *skb;
1943 struct wmi_listen_int_cmd *cmd;
1944 int ret;
1945
1946 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1947 if (!skb)
1948 return -ENOMEM;
1949
1950 cmd = (struct wmi_listen_int_cmd *) skb->data;
1951 cmd->listen_intvl = cpu_to_le16(listen_interval);
1952 cmd->num_beacons = cpu_to_le16(listen_beacons);
1953
1954 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID,
1955 NO_SYNC_WMIFLAG);
1956 return ret;
1957}
1958
1959int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode)
1960{
1961 struct sk_buff *skb;
1962 struct wmi_power_mode_cmd *cmd;
1963 int ret;
1964
1965 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1966 if (!skb)
1967 return -ENOMEM;
1968
1969 cmd = (struct wmi_power_mode_cmd *) skb->data;
1970 cmd->pwr_mode = pwr_mode;
1971 wmi->pwr_mode = pwr_mode;
1972
1973 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID,
1974 NO_SYNC_WMIFLAG);
1975 return ret;
1976}
1977
1978int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period,
1979 u16 ps_poll_num, u16 dtim_policy,
1980 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
1981 u16 ps_fail_event_policy)
1982{
1983 struct sk_buff *skb;
1984 struct wmi_power_params_cmd *pm;
1985 int ret;
1986
1987 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
1988 if (!skb)
1989 return -ENOMEM;
1990
1991 pm = (struct wmi_power_params_cmd *)skb->data;
1992 pm->idle_period = cpu_to_le16(idle_period);
1993 pm->pspoll_number = cpu_to_le16(ps_poll_num);
1994 pm->dtim_policy = cpu_to_le16(dtim_policy);
1995 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
1996 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
1997 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
1998
1999 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID,
2000 NO_SYNC_WMIFLAG);
2001 return ret;
2002}
2003
2004int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout)
2005{
2006 struct sk_buff *skb;
2007 struct wmi_disc_timeout_cmd *cmd;
2008 int ret;
2009
2010 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2011 if (!skb)
2012 return -ENOMEM;
2013
2014 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
2015 cmd->discon_timeout = timeout;
2016
2017 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID,
2018 NO_SYNC_WMIFLAG);
2019 return ret;
2020}
2021
2022int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index,
2023 enum crypto_type key_type,
2024 u8 key_usage, u8 key_len,
2025 u8 *key_rsc, u8 *key_material,
2026 u8 key_op_ctrl, u8 *mac_addr,
2027 enum wmi_sync_flag sync_flag)
2028{
2029 struct sk_buff *skb;
2030 struct wmi_add_cipher_key_cmd *cmd;
2031 int ret;
2032
Jouni Malinen9a5b1312011-08-30 21:57:52 +03002033 ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
2034 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
2035 key_index, key_type, key_usage, key_len, key_op_ctrl);
2036
Kalle Valobdcd8172011-07-18 00:22:30 +03002037 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
2038 (key_material == NULL))
2039 return -EINVAL;
2040
2041 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
2042 return -EINVAL;
2043
2044 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2045 if (!skb)
2046 return -ENOMEM;
2047
2048 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
2049 cmd->key_index = key_index;
2050 cmd->key_type = key_type;
2051 cmd->key_usage = key_usage;
2052 cmd->key_len = key_len;
2053 memcpy(cmd->key, key_material, key_len);
2054
2055 if (key_rsc != NULL)
2056 memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc));
2057
2058 cmd->key_op_ctrl = key_op_ctrl;
2059
2060 if (mac_addr)
2061 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
2062
2063 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID,
2064 sync_flag);
2065
2066 return ret;
2067}
2068
2069int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk)
2070{
2071 struct sk_buff *skb;
2072 struct wmi_add_krk_cmd *cmd;
2073 int ret;
2074
2075 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2076 if (!skb)
2077 return -ENOMEM;
2078
2079 cmd = (struct wmi_add_krk_cmd *) skb->data;
2080 memcpy(cmd->krk, krk, WMI_KRK_LEN);
2081
2082 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG);
2083
2084 return ret;
2085}
2086
2087int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index)
2088{
2089 struct sk_buff *skb;
2090 struct wmi_delete_cipher_key_cmd *cmd;
2091 int ret;
2092
2093 if (key_index > WMI_MAX_KEY_INDEX)
2094 return -EINVAL;
2095
2096 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2097 if (!skb)
2098 return -ENOMEM;
2099
2100 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
2101 cmd->key_index = key_index;
2102
2103 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID,
2104 NO_SYNC_WMIFLAG);
2105
2106 return ret;
2107}
2108
2109int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid,
2110 const u8 *pmkid, bool set)
2111{
2112 struct sk_buff *skb;
2113 struct wmi_setpmkid_cmd *cmd;
2114 int ret;
2115
2116 if (bssid == NULL)
2117 return -EINVAL;
2118
2119 if (set && pmkid == NULL)
2120 return -EINVAL;
2121
2122 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2123 if (!skb)
2124 return -ENOMEM;
2125
2126 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2127 memcpy(cmd->bssid, bssid, ETH_ALEN);
2128 if (set) {
2129 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2130 cmd->enable = PMKID_ENABLE;
2131 } else {
2132 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2133 cmd->enable = PMKID_DISABLE;
2134 }
2135
2136 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID,
2137 NO_SYNC_WMIFLAG);
2138
2139 return ret;
2140}
2141
2142static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
2143 enum htc_endpoint_id ep_id)
2144{
2145 struct wmi_data_hdr *data_hdr;
2146 int ret;
2147
2148 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id))
2149 return -EINVAL;
2150
2151 skb_push(skb, sizeof(struct wmi_data_hdr));
2152
2153 data_hdr = (struct wmi_data_hdr *) skb->data;
2154 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
2155 data_hdr->info3 = 0;
2156
2157 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2158
2159 return ret;
2160}
2161
2162static int ath6kl_wmi_sync_point(struct wmi *wmi)
2163{
2164 struct sk_buff *skb;
2165 struct wmi_sync_cmd *cmd;
2166 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2167 enum htc_endpoint_id ep_id;
2168 u8 index, num_pri_streams = 0;
2169 int ret = 0;
2170
2171 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2172
2173 spin_lock_bh(&wmi->lock);
2174
2175 for (index = 0; index < WMM_NUM_AC; index++) {
2176 if (wmi->fat_pipe_exist & (1 << index)) {
2177 num_pri_streams++;
2178 data_sync_bufs[num_pri_streams - 1].traffic_class =
2179 index;
2180 }
2181 }
2182
2183 spin_unlock_bh(&wmi->lock);
2184
2185 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2186 if (!skb) {
2187 ret = -ENOMEM;
2188 goto free_skb;
2189 }
2190
2191 cmd = (struct wmi_sync_cmd *) skb->data;
2192
2193 /*
2194 * In the SYNC cmd sent on the control Ep, send a bitmap
2195 * of the data eps on which the Data Sync will be sent
2196 */
2197 cmd->data_sync_map = wmi->fat_pipe_exist;
2198
2199 for (index = 0; index < num_pri_streams; index++) {
2200 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2201 if (data_sync_bufs[index].skb == NULL) {
2202 ret = -ENOMEM;
2203 break;
2204 }
2205 }
2206
2207 /*
2208 * If buffer allocation for any of the dataSync fails,
2209 * then do not send the Synchronize cmd on the control ep
2210 */
2211 if (ret)
2212 goto free_skb;
2213
2214 /*
2215 * Send sync cmd followed by sync data messages on all
2216 * endpoints being used
2217 */
2218 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID,
2219 NO_SYNC_WMIFLAG);
2220
2221 if (ret)
2222 goto free_skb;
2223
2224 /* cmd buffer sent, we no longer own it */
2225 skb = NULL;
2226
2227 for (index = 0; index < num_pri_streams; index++) {
2228
2229 if (WARN_ON(!data_sync_bufs[index].skb))
2230 break;
2231
2232 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2233 data_sync_bufs[index].
2234 traffic_class);
2235 ret =
2236 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
2237 ep_id);
2238
2239 if (ret)
2240 break;
2241
2242 data_sync_bufs[index].skb = NULL;
2243 }
2244
2245free_skb:
2246 /* free up any resources left over (possibly due to an error) */
2247 if (skb)
2248 dev_kfree_skb(skb);
2249
2250 for (index = 0; index < num_pri_streams; index++) {
2251 if (data_sync_bufs[index].skb != NULL) {
2252 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].
2253 skb);
2254 }
2255 }
2256
2257 return ret;
2258}
2259
2260int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi,
2261 struct wmi_create_pstream_cmd *params)
2262{
2263 struct sk_buff *skb;
2264 struct wmi_create_pstream_cmd *cmd;
2265 u8 fatpipe_exist_for_ac = 0;
2266 s32 min_phy = 0;
2267 s32 nominal_phy = 0;
2268 int ret;
2269
2270 if (!((params->user_pri < 8) &&
2271 (params->user_pri <= 0x7) &&
2272 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2273 (params->traffic_direc == UPLINK_TRAFFIC ||
2274 params->traffic_direc == DNLINK_TRAFFIC ||
2275 params->traffic_direc == BIDIR_TRAFFIC) &&
2276 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2277 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2278 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2279 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2280 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2281 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2282 params->tsid <= WMI_MAX_THINSTREAM))) {
2283 return -EINVAL;
2284 }
2285
2286 /*
2287 * Check nominal PHY rate is >= minimalPHY,
2288 * so that DUT can allow TSRS IE
2289 */
2290
2291 /* Get the physical rate (units of bps) */
2292 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2293
2294 /* Check minimal phy < nominal phy rate */
2295 if (params->nominal_phy >= min_phy) {
2296 /* unit of 500 kbps */
2297 nominal_phy = (params->nominal_phy * 1000) / 500;
2298 ath6kl_dbg(ATH6KL_DBG_WMI,
2299 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2300 min_phy, nominal_phy);
2301
2302 params->nominal_phy = nominal_phy;
2303 } else {
2304 params->nominal_phy = 0;
2305 }
2306
2307 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2308 if (!skb)
2309 return -ENOMEM;
2310
2311 ath6kl_dbg(ATH6KL_DBG_WMI,
2312 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2313 params->traffic_class, params->tsid);
2314
2315 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2316 memcpy(cmd, params, sizeof(*cmd));
2317
2318 /* This is an implicitly created Fat pipe */
2319 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2320 spin_lock_bh(&wmi->lock);
2321 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2322 (1 << params->traffic_class));
2323 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2324 spin_unlock_bh(&wmi->lock);
2325 } else {
2326 /* explicitly created thin stream within a fat pipe */
2327 spin_lock_bh(&wmi->lock);
2328 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2329 (1 << params->traffic_class));
2330 wmi->stream_exist_for_ac[params->traffic_class] |=
2331 (1 << params->tsid);
2332 /*
2333 * If a thinstream becomes active, the fat pipe automatically
2334 * becomes active
2335 */
2336 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2337 spin_unlock_bh(&wmi->lock);
2338 }
2339
2340 /*
2341 * Indicate activty change to driver layer only if this is the
2342 * first TSID to get created in this AC explicitly or an implicit
2343 * fat pipe is getting created.
2344 */
2345 if (!fatpipe_exist_for_ac)
2346 ath6kl_indicate_tx_activity(wmi->parent_dev,
2347 params->traffic_class, true);
2348
2349 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID,
2350 NO_SYNC_WMIFLAG);
2351 return ret;
2352}
2353
2354int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid)
2355{
2356 struct sk_buff *skb;
2357 struct wmi_delete_pstream_cmd *cmd;
2358 u16 active_tsids = 0;
2359 int ret;
2360
2361 if (traffic_class > 3) {
2362 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2363 return -EINVAL;
2364 }
2365
2366 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2367 if (!skb)
2368 return -ENOMEM;
2369
2370 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2371 cmd->traffic_class = traffic_class;
2372 cmd->tsid = tsid;
2373
2374 spin_lock_bh(&wmi->lock);
2375 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2376 spin_unlock_bh(&wmi->lock);
2377
2378 if (!(active_tsids & (1 << tsid))) {
2379 dev_kfree_skb(skb);
2380 ath6kl_dbg(ATH6KL_DBG_WMI,
2381 "TSID %d doesn't exist for traffic class: %d\n",
2382 tsid, traffic_class);
2383 return -ENODATA;
2384 }
2385
2386 ath6kl_dbg(ATH6KL_DBG_WMI,
2387 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2388 traffic_class, tsid);
2389
2390 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID,
2391 SYNC_BEFORE_WMIFLAG);
2392
2393 spin_lock_bh(&wmi->lock);
2394 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2395 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2396 spin_unlock_bh(&wmi->lock);
2397
2398 /*
2399 * Indicate stream inactivity to driver layer only if all tsids
2400 * within this AC are deleted.
2401 */
2402 if (!active_tsids) {
2403 ath6kl_indicate_tx_activity(wmi->parent_dev,
2404 traffic_class, false);
2405 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2406 }
2407
2408 return ret;
2409}
2410
2411int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd)
2412{
2413 struct sk_buff *skb;
2414 struct wmi_set_ip_cmd *cmd;
2415 int ret;
2416
2417 /* Multicast address are not valid */
2418 if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) ||
2419 (*((u8 *) &ip_cmd->ips[1]) >= 0xE0))
2420 return -EINVAL;
2421
2422 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2423 if (!skb)
2424 return -ENOMEM;
2425
2426 cmd = (struct wmi_set_ip_cmd *) skb->data;
2427 memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd));
2428
2429 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG);
2430 return ret;
2431}
2432
2433static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap,
2434 int len)
2435{
2436 if (len < sizeof(struct wmi_get_wow_list_reply))
2437 return -EINVAL;
2438
2439 return 0;
2440}
2441
2442static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
2443 enum wmix_command_id cmd_id,
2444 enum wmi_sync_flag sync_flag)
2445{
2446 struct wmix_cmd_hdr *cmd_hdr;
2447 int ret;
2448
2449 skb_push(skb, sizeof(struct wmix_cmd_hdr));
2450
2451 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
2452 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
2453
2454 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag);
2455
2456 return ret;
2457}
2458
2459int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
2460{
2461 struct sk_buff *skb;
2462 struct wmix_hb_challenge_resp_cmd *cmd;
2463 int ret;
2464
2465 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2466 if (!skb)
2467 return -ENOMEM;
2468
2469 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
2470 cmd->cookie = cpu_to_le32(cookie);
2471 cmd->source = cpu_to_le32(source);
2472
2473 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
2474 NO_SYNC_WMIFLAG);
2475 return ret;
2476}
2477
Kalle Valo939f1cc2011-09-02 10:32:04 +03002478int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
2479{
2480 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
2481 struct sk_buff *skb;
2482 int ret;
2483
2484 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2485 if (!skb)
2486 return -ENOMEM;
2487
2488 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
2489 cmd->valid = cpu_to_le32(valid);
2490 cmd->config = cpu_to_le32(config);
2491
2492 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
2493 NO_SYNC_WMIFLAG);
2494 return ret;
2495}
2496
Kalle Valobdcd8172011-07-18 00:22:30 +03002497int ath6kl_wmi_get_stats_cmd(struct wmi *wmi)
2498{
2499 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID);
2500}
2501
2502int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM)
2503{
2504 struct sk_buff *skb;
2505 struct wmi_set_tx_pwr_cmd *cmd;
2506 int ret;
2507
2508 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
2509 if (!skb)
2510 return -ENOMEM;
2511
2512 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
2513 cmd->dbM = dbM;
2514
2515 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID,
2516 NO_SYNC_WMIFLAG);
2517
2518 return ret;
2519}
2520
2521int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi)
2522{
2523 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID);
2524}
2525
Kalle Valobdcd8172011-07-18 00:22:30 +03002526int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy)
2527{
2528 struct sk_buff *skb;
2529 struct wmi_set_lpreamble_cmd *cmd;
2530 int ret;
2531
2532 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
2533 if (!skb)
2534 return -ENOMEM;
2535
2536 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
2537 cmd->status = status;
2538 cmd->preamble_policy = preamble_policy;
2539
2540 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID,
2541 NO_SYNC_WMIFLAG);
2542 return ret;
2543}
2544
2545int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
2546{
2547 struct sk_buff *skb;
2548 struct wmi_set_rts_cmd *cmd;
2549 int ret;
2550
2551 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
2552 if (!skb)
2553 return -ENOMEM;
2554
2555 cmd = (struct wmi_set_rts_cmd *) skb->data;
2556 cmd->threshold = cpu_to_le16(threshold);
2557
2558 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG);
2559 return ret;
2560}
2561
2562int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg)
2563{
2564 struct sk_buff *skb;
2565 struct wmi_set_wmm_txop_cmd *cmd;
2566 int ret;
2567
2568 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
2569 return -EINVAL;
2570
2571 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
2572 if (!skb)
2573 return -ENOMEM;
2574
2575 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
2576 cmd->txop_enable = cfg;
2577
2578 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID,
2579 NO_SYNC_WMIFLAG);
2580 return ret;
2581}
2582
2583int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl)
2584{
2585 struct sk_buff *skb;
2586 struct wmi_set_keepalive_cmd *cmd;
2587 int ret;
2588
2589 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2590 if (!skb)
2591 return -ENOMEM;
2592
2593 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
2594 cmd->keep_alive_intvl = keep_alive_intvl;
2595 wmi->keep_alive_intvl = keep_alive_intvl;
2596
2597 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID,
2598 NO_SYNC_WMIFLAG);
2599 return ret;
2600}
2601
Kalle Valo003353b0d2011-09-01 10:14:21 +03002602int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
2603{
2604 struct sk_buff *skb;
2605 int ret;
2606
2607 skb = ath6kl_wmi_get_new_buf(len);
2608 if (!skb)
2609 return -ENOMEM;
2610
2611 memcpy(skb->data, buf, len);
2612
2613 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
2614
2615 return ret;
2616}
2617
2618
Kalle Valobdcd8172011-07-18 00:22:30 +03002619s32 ath6kl_wmi_get_rate(s8 rate_index)
2620{
2621 if (rate_index == RATE_AUTO)
2622 return 0;
2623
2624 return wmi_rate_tbl[(u32) rate_index][0];
2625}
2626
2627void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss)
2628{
2629 if (bss)
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05302630 wlan_node_return(&wmi->parent_dev->scan_table, bss);
Kalle Valobdcd8172011-07-18 00:22:30 +03002631}
2632
2633struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid,
2634 u32 ssid_len, bool is_wpa2,
2635 bool match_ssid)
2636{
2637 struct bss *node = NULL;
2638
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05302639 node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid,
Kalle Valobdcd8172011-07-18 00:22:30 +03002640 ssid_len, is_wpa2, match_ssid);
2641 return node;
2642}
2643
2644struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr)
2645{
2646 struct bss *ni = NULL;
2647
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05302648 ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr);
Kalle Valobdcd8172011-07-18 00:22:30 +03002649
2650 return ni;
2651}
2652
2653void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr)
2654{
2655 struct bss *ni = NULL;
2656
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05302657 ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr);
Kalle Valobdcd8172011-07-18 00:22:30 +03002658 if (ni != NULL)
Vasanthakumar Thiagarajan7c3075e2011-07-21 13:38:33 +05302659 wlan_node_reclaim(&wmi->parent_dev->scan_table, ni);
Kalle Valobdcd8172011-07-18 00:22:30 +03002660
2661 return;
2662}
2663
2664static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
2665 u32 len)
2666{
2667 struct wmi_pmkid_list_reply *reply;
2668 u32 expected_len;
2669
2670 if (len < sizeof(struct wmi_pmkid_list_reply))
2671 return -EINVAL;
2672
2673 reply = (struct wmi_pmkid_list_reply *)datap;
2674 expected_len = sizeof(reply->num_pmkid) +
2675 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
2676
2677 if (len < expected_len)
2678 return -EINVAL;
2679
2680 return 0;
2681}
2682
2683static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len)
2684{
2685 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
2686
2687 aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid,
2688 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
2689
2690 return 0;
2691}
2692
2693static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len)
2694{
2695 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
2696
2697 aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid);
2698
2699 return 0;
2700}
2701
2702/* AP mode functions */
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002703
2704int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p)
2705{
2706 struct sk_buff *skb;
2707 struct wmi_connect_cmd *cm;
2708 int res;
2709
2710 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2711 if (!skb)
2712 return -ENOMEM;
2713
2714 cm = (struct wmi_connect_cmd *) skb->data;
2715 memcpy(cm, p, sizeof(*cm));
2716
2717 res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID,
2718 NO_SYNC_WMIFLAG);
2719 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
2720 "ctrl_flags=0x%x-> res=%d\n",
2721 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
2722 le32_to_cpu(p->ctrl_flags), res);
2723 return res;
2724}
2725
Jouni Malinen23875132011-08-30 21:57:53 +03002726int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason)
2727{
2728 struct sk_buff *skb;
2729 struct wmi_ap_set_mlme_cmd *cm;
2730
2731 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2732 if (!skb)
2733 return -ENOMEM;
2734
2735 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
2736 memcpy(cm->mac, mac, ETH_ALEN);
2737 cm->reason = cpu_to_le16(reason);
2738 cm->cmd = cmd;
2739
2740 return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID,
2741 NO_SYNC_WMIFLAG);
2742}
2743
Kalle Valobdcd8172011-07-18 00:22:30 +03002744static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len)
2745{
2746 struct wmi_pspoll_event *ev;
2747
2748 if (len < sizeof(struct wmi_pspoll_event))
2749 return -EINVAL;
2750
2751 ev = (struct wmi_pspoll_event *) datap;
2752
2753 ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid));
2754
2755 return 0;
2756}
2757
2758static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len)
2759{
2760 ath6kl_dtimexpiry_event(wmi->parent_dev);
2761
2762 return 0;
2763}
2764
2765int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag)
2766{
2767 struct sk_buff *skb;
2768 struct wmi_ap_set_pvb_cmd *cmd;
2769 int ret;
2770
2771 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
2772 if (!skb)
2773 return -ENOMEM;
2774
2775 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
2776 cmd->aid = cpu_to_le16(aid);
Jouni Malinend6e51e62011-09-05 17:38:44 +03002777 cmd->rsvd = cpu_to_le16(0);
Kalle Valobdcd8172011-07-18 00:22:30 +03002778 cmd->flag = cpu_to_le32(flag);
2779
2780 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID,
2781 NO_SYNC_WMIFLAG);
2782
2783 return 0;
2784}
2785
2786int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver,
2787 bool rx_dot11_hdr, bool defrag_on_host)
2788{
2789 struct sk_buff *skb;
2790 struct wmi_rx_frame_format_cmd *cmd;
2791 int ret;
2792
2793 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2794 if (!skb)
2795 return -ENOMEM;
2796
2797 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
2798 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
2799 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
2800 cmd->meta_ver = rx_meta_ver;
2801
2802 /* Delete the local aggr state, on host */
2803 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID,
2804 NO_SYNC_WMIFLAG);
2805
2806 return ret;
2807}
2808
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002809int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie,
2810 u8 ie_len)
2811{
2812 struct sk_buff *skb;
2813 struct wmi_set_appie_cmd *p;
2814
2815 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
2816 if (!skb)
2817 return -ENOMEM;
2818
2819 ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
2820 "ie_len=%u\n", mgmt_frm_type, ie_len);
2821 p = (struct wmi_set_appie_cmd *) skb->data;
2822 p->mgmt_frm_type = mgmt_frm_type;
2823 p->ie_len = ie_len;
2824 memcpy(p->ie_info, ie, ie_len);
2825 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID,
2826 NO_SYNC_WMIFLAG);
2827}
2828
Jouni Malinen6465ddc2011-08-30 21:57:54 +03002829int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
2830{
2831 struct sk_buff *skb;
2832 struct wmi_disable_11b_rates_cmd *cmd;
2833
2834 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2835 if (!skb)
2836 return -ENOMEM;
2837
2838 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
2839 disable);
2840 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
2841 cmd->disable = disable ? 1 : 0;
2842
2843 return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID,
2844 NO_SYNC_WMIFLAG);
2845}
2846
2847int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur)
2848{
2849 struct sk_buff *skb;
2850 struct wmi_remain_on_chnl_cmd *p;
2851
2852 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2853 if (!skb)
2854 return -ENOMEM;
2855
2856 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2857 freq, dur);
2858 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
2859 p->freq = cpu_to_le32(freq);
2860 p->duration = cpu_to_le32(dur);
2861 return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID,
2862 NO_SYNC_WMIFLAG);
2863}
2864
2865int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait,
2866 const u8 *data, u16 data_len)
2867{
2868 struct sk_buff *skb;
2869 struct wmi_send_action_cmd *p;
Jouni Malinena0df5db2011-08-30 21:58:02 +03002870 u8 *buf;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03002871
2872 if (wait)
2873 return -EINVAL; /* Offload for wait not supported */
2874
Jouni Malinena0df5db2011-08-30 21:58:02 +03002875 buf = kmalloc(data_len, GFP_KERNEL);
2876 if (!buf)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03002877 return -ENOMEM;
2878
Jouni Malinena0df5db2011-08-30 21:58:02 +03002879 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
2880 if (!skb) {
2881 kfree(buf);
2882 return -ENOMEM;
2883 }
2884
2885 kfree(wmi->last_mgmt_tx_frame);
2886 wmi->last_mgmt_tx_frame = buf;
2887 wmi->last_mgmt_tx_frame_len = data_len;
2888
Jouni Malinen6465ddc2011-08-30 21:57:54 +03002889 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
2890 "len=%u\n", id, freq, wait, data_len);
2891 p = (struct wmi_send_action_cmd *) skb->data;
2892 p->id = cpu_to_le32(id);
2893 p->freq = cpu_to_le32(freq);
2894 p->wait = cpu_to_le32(wait);
2895 p->len = cpu_to_le16(data_len);
2896 memcpy(p->data, data, data_len);
2897 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID,
2898 NO_SYNC_WMIFLAG);
2899}
2900
2901int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq,
2902 const u8 *dst,
2903 const u8 *data, u16 data_len)
2904{
2905 struct sk_buff *skb;
2906 struct wmi_p2p_probe_response_cmd *p;
2907
2908 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
2909 if (!skb)
2910 return -ENOMEM;
2911
2912 ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
2913 "len=%u\n", freq, dst, data_len);
2914 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
2915 p->freq = cpu_to_le32(freq);
2916 memcpy(p->destination_addr, dst, ETH_ALEN);
2917 p->len = cpu_to_le16(data_len);
2918 memcpy(p->data, data, data_len);
2919 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID,
2920 NO_SYNC_WMIFLAG);
2921}
2922
2923int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable)
2924{
2925 struct sk_buff *skb;
2926 struct wmi_probe_req_report_cmd *p;
2927
2928 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2929 if (!skb)
2930 return -ENOMEM;
2931
2932 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
2933 enable);
2934 p = (struct wmi_probe_req_report_cmd *) skb->data;
2935 p->enable = enable ? 1 : 0;
2936 return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID,
2937 NO_SYNC_WMIFLAG);
2938}
2939
2940int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags)
2941{
2942 struct sk_buff *skb;
2943 struct wmi_get_p2p_info *p;
2944
2945 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2946 if (!skb)
2947 return -ENOMEM;
2948
2949 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
2950 info_req_flags);
2951 p = (struct wmi_get_p2p_info *) skb->data;
2952 p->info_req_flags = cpu_to_le32(info_req_flags);
2953 return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID,
2954 NO_SYNC_WMIFLAG);
2955}
2956
2957int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi)
2958{
2959 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
2960 return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
2961}
2962
Kalle Valobdcd8172011-07-18 00:22:30 +03002963static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
2964{
2965 struct wmix_cmd_hdr *cmd;
2966 u32 len;
2967 u16 id;
2968 u8 *datap;
2969 int ret = 0;
2970
2971 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
2972 ath6kl_err("bad packet 1\n");
2973 wmi->stat.cmd_len_err++;
2974 return -EINVAL;
2975 }
2976
2977 cmd = (struct wmix_cmd_hdr *) skb->data;
2978 id = le32_to_cpu(cmd->cmd_id);
2979
2980 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
2981
2982 datap = skb->data;
2983 len = skb->len;
2984
2985 switch (id) {
2986 case WMIX_HB_CHALLENGE_RESP_EVENTID:
2987 break;
2988 case WMIX_DBGLOG_EVENTID:
Kalle Valobdf53962011-09-02 10:32:04 +03002989 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03002990 break;
2991 default:
2992 ath6kl_err("unknown cmd id 0x%x\n", id);
2993 wmi->stat.cmd_id_err++;
2994 ret = -EINVAL;
2995 break;
2996 }
2997
2998 return ret;
2999}
3000
3001/* Control Path */
3002int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
3003{
3004 struct wmi_cmd_hdr *cmd;
3005 u32 len;
3006 u16 id;
3007 u8 *datap;
3008 int ret = 0;
3009
3010 if (WARN_ON(skb == NULL))
3011 return -EINVAL;
3012
3013 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
3014 ath6kl_err("bad packet 1\n");
3015 dev_kfree_skb(skb);
3016 wmi->stat.cmd_len_err++;
3017 return -EINVAL;
3018 }
3019
3020 cmd = (struct wmi_cmd_hdr *) skb->data;
3021 id = le16_to_cpu(cmd->cmd_id);
3022
3023 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
3024
3025 datap = skb->data;
3026 len = skb->len;
3027
3028 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id);
3029 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len);
3030
3031 switch (id) {
3032 case WMI_GET_BITRATE_CMDID:
3033 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
3034 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
3035 break;
3036 case WMI_GET_CHANNEL_LIST_CMDID:
3037 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
3038 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
3039 break;
3040 case WMI_GET_TX_PWR_CMDID:
3041 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
3042 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
3043 break;
3044 case WMI_READY_EVENTID:
3045 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
3046 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
3047 break;
3048 case WMI_CONNECT_EVENTID:
3049 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
3050 ret = ath6kl_wmi_connect_event_rx(wmi, datap, len);
3051 break;
3052 case WMI_DISCONNECT_EVENTID:
3053 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
3054 ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len);
3055 break;
3056 case WMI_PEER_NODE_EVENTID:
3057 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
3058 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
3059 break;
3060 case WMI_TKIP_MICERR_EVENTID:
3061 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
3062 ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len);
3063 break;
3064 case WMI_BSSINFO_EVENTID:
3065 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
3066 ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap);
3067 ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len);
3068 break;
3069 case WMI_REGDOMAIN_EVENTID:
3070 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
3071 break;
3072 case WMI_PSTREAM_TIMEOUT_EVENTID:
3073 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
3074 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
3075 break;
3076 case WMI_NEIGHBOR_REPORT_EVENTID:
3077 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3078 break;
3079 case WMI_SCAN_COMPLETE_EVENTID:
3080 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
3081 ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len);
3082 break;
3083 case WMI_CMDERROR_EVENTID:
3084 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
3085 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
3086 break;
3087 case WMI_REPORT_STATISTICS_EVENTID:
3088 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
3089 ret = ath6kl_wmi_stats_event_rx(wmi, datap, len);
3090 break;
3091 case WMI_RSSI_THRESHOLD_EVENTID:
3092 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
3093 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
3094 break;
3095 case WMI_ERROR_REPORT_EVENTID:
3096 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
3097 break;
3098 case WMI_OPT_RX_FRAME_EVENTID:
3099 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
3100 ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len);
3101 break;
3102 case WMI_REPORT_ROAM_TBL_EVENTID:
3103 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
3104 break;
3105 case WMI_EXTENSION_EVENTID:
3106 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
3107 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
3108 break;
3109 case WMI_CAC_EVENTID:
3110 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
3111 ret = ath6kl_wmi_cac_event_rx(wmi, datap, len);
3112 break;
3113 case WMI_CHANNEL_CHANGE_EVENTID:
3114 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
3115 break;
3116 case WMI_REPORT_ROAM_DATA_EVENTID:
3117 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
3118 break;
Kalle Valo003353b0d2011-09-01 10:14:21 +03003119 case WMI_TEST_EVENTID:
3120 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
3121 ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len);
3122 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003123 case WMI_GET_FIXRATES_CMDID:
3124 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
3125 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
3126 break;
3127 case WMI_TX_RETRY_ERR_EVENTID:
3128 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
3129 break;
3130 case WMI_SNR_THRESHOLD_EVENTID:
3131 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
3132 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
3133 break;
3134 case WMI_LQ_THRESHOLD_EVENTID:
3135 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
3136 break;
3137 case WMI_APLIST_EVENTID:
3138 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
3139 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
3140 break;
3141 case WMI_GET_KEEPALIVE_CMDID:
3142 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
3143 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
3144 break;
3145 case WMI_GET_WOW_LIST_EVENTID:
3146 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
3147 ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len);
3148 break;
3149 case WMI_GET_PMKID_LIST_EVENTID:
3150 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
3151 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
3152 break;
3153 case WMI_PSPOLL_EVENTID:
3154 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
3155 ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len);
3156 break;
3157 case WMI_DTIMEXPIRY_EVENTID:
3158 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
3159 ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len);
3160 break;
3161 case WMI_SET_PARAMS_REPLY_EVENTID:
3162 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3163 break;
3164 case WMI_ADDBA_REQ_EVENTID:
3165 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
3166 ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len);
3167 break;
3168 case WMI_ADDBA_RESP_EVENTID:
3169 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
3170 break;
3171 case WMI_DELBA_REQ_EVENTID:
3172 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
3173 ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len);
3174 break;
3175 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
3176 ath6kl_dbg(ATH6KL_DBG_WMI,
3177 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3178 break;
3179 case WMI_REPORT_BTCOEX_STATS_EVENTID:
3180 ath6kl_dbg(ATH6KL_DBG_WMI,
3181 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3182 break;
3183 case WMI_TX_COMPLETE_EVENTID:
3184 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
3185 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
3186 break;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003187 case WMI_REMAIN_ON_CHNL_EVENTID:
3188 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
Jouni Malinenf9e5f052011-08-30 21:57:58 +03003189 ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003190 break;
3191 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3192 ath6kl_dbg(ATH6KL_DBG_WMI,
3193 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
Jouni Malinenf9e5f052011-08-30 21:57:58 +03003194 ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
3195 len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003196 break;
3197 case WMI_TX_STATUS_EVENTID:
3198 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
Jouni Malinena0df5db2011-08-30 21:58:02 +03003199 ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003200 break;
3201 case WMI_RX_PROBE_REQ_EVENTID:
3202 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
Jouni Malinenae32c302011-08-30 21:58:01 +03003203 ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003204 break;
3205 case WMI_P2P_CAPABILITIES_EVENTID:
3206 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
3207 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
3208 break;
3209 case WMI_RX_ACTION_EVENTID:
3210 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
Jouni Malinen9809d8e2011-08-30 21:58:03 +03003211 ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003212 break;
3213 case WMI_P2P_INFO_EVENTID:
3214 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
3215 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
3216 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003217 default:
3218 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id);
3219 wmi->stat.cmd_id_err++;
3220 ret = -EINVAL;
3221 break;
3222 }
3223
3224 dev_kfree_skb(skb);
3225
3226 return ret;
3227}
3228
3229static void ath6kl_wmi_qos_state_init(struct wmi *wmi)
3230{
3231 if (!wmi)
3232 return;
3233
3234 spin_lock_bh(&wmi->lock);
3235
3236 wmi->fat_pipe_exist = 0;
3237 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
3238
3239 spin_unlock_bh(&wmi->lock);
3240}
3241
Vasanthakumar Thiagarajan28657852011-07-21 12:00:49 +05303242void *ath6kl_wmi_init(struct ath6kl *dev)
Kalle Valobdcd8172011-07-18 00:22:30 +03003243{
3244 struct wmi *wmi;
3245
3246 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
3247 if (!wmi)
3248 return NULL;
3249
3250 spin_lock_init(&wmi->lock);
3251
3252 wmi->parent_dev = dev;
3253
Kalle Valobdcd8172011-07-18 00:22:30 +03003254 ath6kl_wmi_qos_state_init(wmi);
3255
3256 wmi->pwr_mode = REC_POWER;
3257 wmi->phy_mode = WMI_11G_MODE;
3258
3259 wmi->pair_crypto_type = NONE_CRYPT;
3260 wmi->grp_crypto_type = NONE_CRYPT;
3261
3262 wmi->ht_allowed[A_BAND_24GHZ] = 1;
3263 wmi->ht_allowed[A_BAND_5GHZ] = 1;
3264
3265 return wmi;
3266}
3267
3268void ath6kl_wmi_shutdown(struct wmi *wmi)
3269{
3270 if (!wmi)
3271 return;
3272
Jouni Malinena0df5db2011-08-30 21:58:02 +03003273 kfree(wmi->last_mgmt_tx_frame);
Kalle Valobdcd8172011-07-18 00:22:30 +03003274 kfree(wmi);
3275}