blob: 18fa9aa8af92464a4888f37b68d9904293ed2573 [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"
Vivek Natarajan06033762011-09-06 13:01:36 +053021#include "../regd.h"
22#include "../regd_common.h"
Kalle Valobdcd8172011-07-18 00:22:30 +030023
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +053024static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +030025
26static const s32 wmi_rate_tbl[][2] = {
27 /* {W/O SGI, with SGI} */
28 {1000, 1000},
29 {2000, 2000},
30 {5500, 5500},
31 {11000, 11000},
32 {6000, 6000},
33 {9000, 9000},
34 {12000, 12000},
35 {18000, 18000},
36 {24000, 24000},
37 {36000, 36000},
38 {48000, 48000},
39 {54000, 54000},
40 {6500, 7200},
41 {13000, 14400},
42 {19500, 21700},
43 {26000, 28900},
44 {39000, 43300},
45 {52000, 57800},
46 {58500, 65000},
47 {65000, 72200},
48 {13500, 15000},
49 {27000, 30000},
50 {40500, 45000},
51 {54000, 60000},
52 {81000, 90000},
53 {108000, 120000},
54 {121500, 135000},
55 {135000, 150000},
56 {0, 0}
57};
58
59/* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
60static const u8 up_to_ac[] = {
61 WMM_AC_BE,
62 WMM_AC_BK,
63 WMM_AC_BK,
64 WMM_AC_BE,
65 WMM_AC_VI,
66 WMM_AC_VI,
67 WMM_AC_VO,
68 WMM_AC_VO,
69};
70
71void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id)
72{
73 if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX))
74 return;
75
76 wmi->ep_id = ep_id;
77}
78
79enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi)
80{
81 return wmi->ep_id;
82}
83
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +053084struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx)
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +053085{
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +053086 struct ath6kl_vif *vif, *found = NULL;
87
Kalle Valo71f96ee2011-11-14 19:31:30 +020088 if (WARN_ON(if_idx > (ar->vif_max - 1)))
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +053089 return NULL;
90
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +053091 /* FIXME: Locking */
Vasanthakumar Thiagarajan11f6e402011-11-01 16:38:50 +053092 spin_lock_bh(&ar->list_lock);
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +053093 list_for_each_entry(vif, &ar->vif_list, list) {
94 if (vif->fw_vif_idx == if_idx) {
95 found = vif;
96 break;
97 }
98 }
Vasanthakumar Thiagarajan11f6e402011-11-01 16:38:50 +053099 spin_unlock_bh(&ar->list_lock);
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +0530100
101 return found;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530102}
103
Kalle Valobdcd8172011-07-18 00:22:30 +0300104/* Performs DIX to 802.3 encapsulation for transmit packets.
105 * Assumes the entire DIX header is contigous and that there is
106 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
107 */
108int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb)
109{
110 struct ath6kl_llc_snap_hdr *llc_hdr;
111 struct ethhdr *eth_hdr;
112 size_t new_len;
113 __be16 type;
114 u8 *datap;
115 u16 size;
116
117 if (WARN_ON(skb == NULL))
118 return -EINVAL;
119
120 size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr);
121 if (skb_headroom(skb) < size)
122 return -ENOMEM;
123
124 eth_hdr = (struct ethhdr *) skb->data;
125 type = eth_hdr->h_proto;
126
127 if (!is_ethertype(be16_to_cpu(type))) {
128 ath6kl_dbg(ATH6KL_DBG_WMI,
129 "%s: pkt is already in 802.3 format\n", __func__);
130 return 0;
131 }
132
133 new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr);
134
135 skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr));
136 datap = skb->data;
137
138 eth_hdr->h_proto = cpu_to_be16(new_len);
139
140 memcpy(datap, eth_hdr, sizeof(*eth_hdr));
141
142 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr));
143 llc_hdr->dsap = 0xAA;
144 llc_hdr->ssap = 0xAA;
145 llc_hdr->cntl = 0x03;
146 llc_hdr->org_code[0] = 0x0;
147 llc_hdr->org_code[1] = 0x0;
148 llc_hdr->org_code[2] = 0x0;
149 llc_hdr->eth_type = type;
150
151 return 0;
152}
153
154static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb,
155 u8 *version, void *tx_meta_info)
156{
157 struct wmi_tx_meta_v1 *v1;
158 struct wmi_tx_meta_v2 *v2;
159
160 if (WARN_ON(skb == NULL || version == NULL))
161 return -EINVAL;
162
163 switch (*version) {
164 case WMI_META_VERSION_1:
165 skb_push(skb, WMI_MAX_TX_META_SZ);
166 v1 = (struct wmi_tx_meta_v1 *) skb->data;
167 v1->pkt_id = 0;
168 v1->rate_plcy_id = 0;
169 *version = WMI_META_VERSION_1;
170 break;
171 case WMI_META_VERSION_2:
172 skb_push(skb, WMI_MAX_TX_META_SZ);
173 v2 = (struct wmi_tx_meta_v2 *) skb->data;
174 memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info,
175 sizeof(struct wmi_tx_meta_v2));
176 break;
177 }
178
179 return 0;
180}
181
182int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530183 u8 msg_type, u32 flags,
Kalle Valobdcd8172011-07-18 00:22:30 +0300184 enum wmi_data_hdr_data_type data_type,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +0530185 u8 meta_ver, void *tx_meta_info, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +0300186{
187 struct wmi_data_hdr *data_hdr;
188 int ret;
189
Kalle Valo71f96ee2011-11-14 19:31:30 +0200190 if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1)))
Kalle Valobdcd8172011-07-18 00:22:30 +0300191 return -EINVAL;
192
Vasanthakumar Thiagarajan3ce6ff52011-08-22 20:40:21 +0530193 if (tx_meta_info) {
194 ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info);
195 if (ret)
196 return ret;
197 }
Kalle Valobdcd8172011-07-18 00:22:30 +0300198
199 skb_push(skb, sizeof(struct wmi_data_hdr));
200
201 data_hdr = (struct wmi_data_hdr *)skb->data;
202 memset(data_hdr, 0, sizeof(struct wmi_data_hdr));
203
204 data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT;
205 data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT;
206
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530207 if (flags & WMI_DATA_HDR_FLAGS_MORE)
208 data_hdr->info |= WMI_DATA_HDR_MORE;
Kalle Valobdcd8172011-07-18 00:22:30 +0300209
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530210 if (flags & WMI_DATA_HDR_FLAGS_EOSP)
211 data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP);
212
213 data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT);
214 data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
Kalle Valobdcd8172011-07-18 00:22:30 +0300215
216 return 0;
217}
218
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530219u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri)
Kalle Valobdcd8172011-07-18 00:22:30 +0300220{
221 struct iphdr *ip_hdr = (struct iphdr *) pkt;
222 u8 ip_pri;
223
224 /*
225 * Determine IPTOS priority
226 *
227 * IP-TOS - 8bits
228 * : DSCP(6-bits) ECN(2-bits)
229 * : DSCP - P2 P1 P0 X X X
230 * where (P2 P1 P0) form 802.1D
231 */
232 ip_pri = ip_hdr->tos >> 5;
233 ip_pri &= 0x7;
234
235 if ((layer2_pri & 0x7) > ip_pri)
236 return (u8) layer2_pri & 0x7;
237 else
238 return ip_pri;
239}
240
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530241u8 ath6kl_wmi_get_traffic_class(u8 user_priority)
242{
243 return up_to_ac[user_priority & 0x7];
244}
245
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530246int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx,
247 struct sk_buff *skb,
Kalle Valobdcd8172011-07-18 00:22:30 +0300248 u32 layer2_priority, bool wmm_enabled,
249 u8 *ac)
250{
251 struct wmi_data_hdr *data_hdr;
252 struct ath6kl_llc_snap_hdr *llc_hdr;
253 struct wmi_create_pstream_cmd cmd;
254 u32 meta_size, hdr_size;
255 u16 ip_type = IP_ETHERTYPE;
256 u8 stream_exist, usr_pri;
257 u8 traffic_class = WMM_AC_BE;
258 u8 *datap;
259
260 if (WARN_ON(skb == NULL))
261 return -EINVAL;
262
263 datap = skb->data;
264 data_hdr = (struct wmi_data_hdr *) datap;
265
266 meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
267 WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0;
268
269 if (!wmm_enabled) {
270 /* If WMM is disabled all traffic goes as BE traffic */
271 usr_pri = 0;
272 } else {
273 hdr_size = sizeof(struct ethhdr);
274
275 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap +
276 sizeof(struct
277 wmi_data_hdr) +
278 meta_size + hdr_size);
279
280 if (llc_hdr->eth_type == htons(ip_type)) {
281 /*
282 * Extract the endpoint info from the TOS field
283 * in the IP header.
284 */
285 usr_pri =
286 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
287 sizeof(struct ath6kl_llc_snap_hdr),
288 layer2_priority);
289 } else
290 usr_pri = layer2_priority & 0x7;
291 }
292
Kalle Valoa7f0c582011-10-05 12:23:05 +0300293 /*
294 * workaround for WMM S5
295 *
296 * FIXME: wmi->traffic_class is always 100 so this test doesn't
297 * make sense
298 */
Kalle Valobdcd8172011-07-18 00:22:30 +0300299 if ((wmi->traffic_class == WMM_AC_VI) &&
300 ((usr_pri == 5) || (usr_pri == 4)))
301 usr_pri = 1;
302
303 /* Convert user priority to traffic class */
304 traffic_class = up_to_ac[usr_pri & 0x7];
305
306 wmi_data_hdr_set_up(data_hdr, usr_pri);
307
308 spin_lock_bh(&wmi->lock);
309 stream_exist = wmi->fat_pipe_exist;
310 spin_unlock_bh(&wmi->lock);
311
312 if (!(stream_exist & (1 << traffic_class))) {
313 memset(&cmd, 0, sizeof(cmd));
314 cmd.traffic_class = traffic_class;
315 cmd.user_pri = usr_pri;
316 cmd.inactivity_int =
317 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT);
318 /* Implicit streams are created with TSID 0xFF */
319 cmd.tsid = WMI_IMPLICIT_PSTREAM;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530320 ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd);
Kalle Valobdcd8172011-07-18 00:22:30 +0300321 }
322
323 *ac = traffic_class;
324
325 return 0;
326}
327
328int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
329{
330 struct ieee80211_hdr_3addr *pwh, wh;
331 struct ath6kl_llc_snap_hdr *llc_hdr;
332 struct ethhdr eth_hdr;
333 u32 hdr_size;
334 u8 *datap;
335 __le16 sub_type;
336
337 if (WARN_ON(skb == NULL))
338 return -EINVAL;
339
340 datap = skb->data;
341 pwh = (struct ieee80211_hdr_3addr *) datap;
342
343 sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
344
345 memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr));
346
347 /* Strip off the 802.11 header */
348 if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
349 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
350 sizeof(u32));
351 skb_pull(skb, hdr_size);
352 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA))
353 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
354
355 datap = skb->data;
356 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
357
Raja Manic8790cba2011-07-19 19:27:32 +0530358 memset(&eth_hdr, 0, sizeof(eth_hdr));
Kalle Valobdcd8172011-07-18 00:22:30 +0300359 eth_hdr.h_proto = llc_hdr->eth_type;
Kalle Valobdcd8172011-07-18 00:22:30 +0300360
361 switch ((le16_to_cpu(wh.frame_control)) &
362 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
363 case 0:
364 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
365 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
366 break;
367 case IEEE80211_FCTL_TODS:
368 memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
369 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
370 break;
371 case IEEE80211_FCTL_FROMDS:
372 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
373 memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN);
374 break;
375 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
376 break;
377 }
378
379 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
380 skb_push(skb, sizeof(eth_hdr));
381
382 datap = skb->data;
383
384 memcpy(datap, &eth_hdr, sizeof(eth_hdr));
385
386 return 0;
387}
388
389/*
390 * Performs 802.3 to DIX encapsulation for received packets.
391 * Assumes the entire 802.3 header is contigous.
392 */
393int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
394{
395 struct ath6kl_llc_snap_hdr *llc_hdr;
396 struct ethhdr eth_hdr;
397 u8 *datap;
398
399 if (WARN_ON(skb == NULL))
400 return -EINVAL;
401
402 datap = skb->data;
403
404 memcpy(&eth_hdr, datap, sizeof(eth_hdr));
405
406 llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr));
407 eth_hdr.h_proto = llc_hdr->eth_type;
408
409 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
410 datap = skb->data;
411
412 memcpy(datap, &eth_hdr, sizeof(eth_hdr));
413
414 return 0;
415}
416
Kalle Valobdcd8172011-07-18 00:22:30 +0300417static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
418{
419 struct tx_complete_msg_v1 *msg_v1;
420 struct wmi_tx_complete_event *evt;
421 int index;
422 u16 size;
423
424 evt = (struct wmi_tx_complete_event *) datap;
425
426 ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
427 evt->num_msg, evt->msg_len, evt->msg_type);
428
Kalle Valobdcd8172011-07-18 00:22:30 +0300429 for (index = 0; index < evt->num_msg; index++) {
430 size = sizeof(struct wmi_tx_complete_event) +
431 (index * sizeof(struct tx_complete_msg_v1));
432 msg_v1 = (struct tx_complete_msg_v1 *)(datap + size);
433
434 ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n",
435 msg_v1->status, msg_v1->pkt_id,
436 msg_v1->rate_idx, msg_v1->ack_failures);
437 }
438
439 return 0;
440}
441
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300442static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530443 int len, struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300444{
445 struct wmi_remain_on_chnl_event *ev;
446 u32 freq;
447 u32 dur;
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300448 struct ieee80211_channel *chan;
449 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen10522612011-10-27 16:00:13 +0300450 u32 id;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300451
452 if (len < sizeof(*ev))
453 return -EINVAL;
454
455 ev = (struct wmi_remain_on_chnl_event *) datap;
456 freq = le32_to_cpu(ev->freq);
457 dur = le32_to_cpu(ev->duration);
458 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
459 freq, dur);
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +0530460 chan = ieee80211_get_channel(ar->wiphy, freq);
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300461 if (!chan) {
462 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel "
463 "(freq=%u)\n", freq);
464 return -EINVAL;
465 }
Jouni Malinen10522612011-10-27 16:00:13 +0300466 id = vif->last_roc_id;
467 cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT,
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300468 dur, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300469
470 return 0;
471}
472
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300473static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530474 u8 *datap, int len,
475 struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300476{
477 struct wmi_cancel_remain_on_chnl_event *ev;
478 u32 freq;
479 u32 dur;
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300480 struct ieee80211_channel *chan;
481 struct ath6kl *ar = wmi->parent_dev;
Jouni Malinen10522612011-10-27 16:00:13 +0300482 u32 id;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300483
484 if (len < sizeof(*ev))
485 return -EINVAL;
486
487 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
488 freq = le32_to_cpu(ev->freq);
489 dur = le32_to_cpu(ev->duration);
490 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u "
491 "status=%u\n", freq, dur, ev->status);
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +0530492 chan = ieee80211_get_channel(ar->wiphy, freq);
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300493 if (!chan) {
494 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown "
495 "channel (freq=%u)\n", freq);
496 return -EINVAL;
497 }
Jouni Malinen10522612011-10-27 16:00:13 +0300498 if (vif->last_cancel_roc_id &&
499 vif->last_cancel_roc_id + 1 == vif->last_roc_id)
500 id = vif->last_cancel_roc_id; /* event for cancel command */
501 else
502 id = vif->last_roc_id; /* timeout on uncanceled r-o-c */
503 vif->last_cancel_roc_id = 0;
504 cfg80211_remain_on_channel_expired(vif->ndev, id, chan,
Jouni Malinenf9e5f052011-08-30 21:57:58 +0300505 NL80211_CHAN_NO_HT, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300506
507 return 0;
508}
509
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530510static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len,
511 struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300512{
513 struct wmi_tx_status_event *ev;
514 u32 id;
515
516 if (len < sizeof(*ev))
517 return -EINVAL;
518
519 ev = (struct wmi_tx_status_event *) datap;
520 id = le32_to_cpu(ev->id);
521 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
522 id, ev->ack_status);
Jouni Malinena0df5db2011-08-30 21:58:02 +0300523 if (wmi->last_mgmt_tx_frame) {
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530524 cfg80211_mgmt_tx_status(vif->ndev, id,
Jouni Malinena0df5db2011-08-30 21:58:02 +0300525 wmi->last_mgmt_tx_frame,
526 wmi->last_mgmt_tx_frame_len,
527 !!ev->ack_status, GFP_ATOMIC);
528 kfree(wmi->last_mgmt_tx_frame);
529 wmi->last_mgmt_tx_frame = NULL;
530 wmi->last_mgmt_tx_frame_len = 0;
531 }
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300532
533 return 0;
534}
535
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530536static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len,
537 struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300538{
539 struct wmi_p2p_rx_probe_req_event *ev;
Jouni Malinenae32c302011-08-30 21:58:01 +0300540 u32 freq;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300541 u16 dlen;
542
543 if (len < sizeof(*ev))
544 return -EINVAL;
545
546 ev = (struct wmi_p2p_rx_probe_req_event *) datap;
Jouni Malinenae32c302011-08-30 21:58:01 +0300547 freq = le32_to_cpu(ev->freq);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300548 dlen = le16_to_cpu(ev->len);
Jouni Malinenae32c302011-08-30 21:58:01 +0300549 if (datap + len < ev->data + dlen) {
550 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
551 "len=%d dlen=%u\n", len, dlen);
552 return -EINVAL;
553 }
554 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u "
555 "probe_req_report=%d\n",
Vasanthakumar Thiagarajancf5333d2011-10-25 19:34:10 +0530556 dlen, freq, vif->probe_req_report);
Jouni Malinenae32c302011-08-30 21:58:01 +0300557
Vasanthakumar Thiagarajancf5333d2011-10-25 19:34:10 +0530558 if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530559 cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300560
561 return 0;
562}
563
564static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
565{
566 struct wmi_p2p_capabilities_event *ev;
567 u16 dlen;
568
569 if (len < sizeof(*ev))
570 return -EINVAL;
571
572 ev = (struct wmi_p2p_capabilities_event *) datap;
573 dlen = le16_to_cpu(ev->len);
574 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
575
576 return 0;
577}
578
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530579static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
580 struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300581{
582 struct wmi_rx_action_event *ev;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300583 u32 freq;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300584 u16 dlen;
585
586 if (len < sizeof(*ev))
587 return -EINVAL;
588
589 ev = (struct wmi_rx_action_event *) datap;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300590 freq = le32_to_cpu(ev->freq);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300591 dlen = le16_to_cpu(ev->len);
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300592 if (datap + len < ev->data + dlen) {
593 ath6kl_err("invalid wmi_rx_action_event: "
594 "len=%d dlen=%u\n", len, dlen);
595 return -EINVAL;
596 }
597 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530598 cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300599
600 return 0;
601}
602
603static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
604{
605 struct wmi_p2p_info_event *ev;
606 u32 flags;
607 u16 dlen;
608
609 if (len < sizeof(*ev))
610 return -EINVAL;
611
612 ev = (struct wmi_p2p_info_event *) datap;
613 flags = le32_to_cpu(ev->info_req_flags);
614 dlen = le16_to_cpu(ev->len);
615 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
616
617 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
618 struct wmi_p2p_capabilities *cap;
619 if (dlen < sizeof(*cap))
620 return -EINVAL;
621 cap = (struct wmi_p2p_capabilities *) ev->data;
622 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
623 cap->go_power_save);
624 }
625
626 if (flags & P2P_FLAG_MACADDR_REQ) {
627 struct wmi_p2p_macaddr *mac;
628 if (dlen < sizeof(*mac))
629 return -EINVAL;
630 mac = (struct wmi_p2p_macaddr *) ev->data;
631 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
632 mac->mac_addr);
633 }
634
635 if (flags & P2P_FLAG_HMODEL_REQ) {
636 struct wmi_p2p_hmodel *mod;
637 if (dlen < sizeof(*mod))
638 return -EINVAL;
639 mod = (struct wmi_p2p_hmodel *) ev->data;
640 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
641 mod->p2p_model,
642 mod->p2p_model ? "host" : "firmware");
643 }
644 return 0;
645}
646
Kalle Valobdcd8172011-07-18 00:22:30 +0300647static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
648{
649 struct sk_buff *skb;
650
651 skb = ath6kl_buf_alloc(size);
652 if (!skb)
653 return NULL;
654
655 skb_put(skb, size);
656 if (size)
657 memset(skb->data, 0, size);
658
659 return skb;
660}
661
662/* Send a "simple" wmi command -- one with no arguments */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530663static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx,
664 enum wmi_cmd_id cmd_id)
Kalle Valobdcd8172011-07-18 00:22:30 +0300665{
666 struct sk_buff *skb;
667 int ret;
668
669 skb = ath6kl_wmi_get_new_buf(0);
670 if (!skb)
671 return -ENOMEM;
672
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530673 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +0300674
675 return ret;
676}
677
678static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
679{
680 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
681
682 if (len < sizeof(struct wmi_ready_event_2))
683 return -EINVAL;
684
Kalle Valobdcd8172011-07-18 00:22:30 +0300685 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
686 le32_to_cpu(ev->sw_version),
687 le32_to_cpu(ev->abi_version));
688
689 return 0;
690}
691
Vivek Natarajane5090442011-08-31 15:02:19 +0530692/*
693 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
694 * at which the station has to roam can be passed with
695 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
696 * in dBm.
697 */
698int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
699{
700 struct sk_buff *skb;
701 struct roam_ctrl_cmd *cmd;
702
703 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
704 if (!skb)
705 return -ENOMEM;
706
707 cmd = (struct roam_ctrl_cmd *) skb->data;
708
709 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
710 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
711 DEF_SCAN_FOR_ROAM_INTVL);
712 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
713 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
714 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
715
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530716 ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
717 NO_SYNC_WMIFLAG);
Vivek Natarajane5090442011-08-31 15:02:19 +0530718
719 return 0;
720}
721
Jouni Malinen12618752011-10-11 17:31:55 +0300722int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid)
723{
724 struct sk_buff *skb;
725 struct roam_ctrl_cmd *cmd;
726
727 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
728 if (!skb)
729 return -ENOMEM;
730
731 cmd = (struct roam_ctrl_cmd *) skb->data;
732 memset(cmd, 0, sizeof(*cmd));
733
734 memcpy(cmd->info.bssid, bssid, ETH_ALEN);
735 cmd->roam_ctrl = WMI_FORCE_ROAM;
736
737 ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530738 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
Jouni Malinen12618752011-10-11 17:31:55 +0300739 NO_SYNC_WMIFLAG);
740}
741
742int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode)
743{
744 struct sk_buff *skb;
745 struct roam_ctrl_cmd *cmd;
746
747 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
748 if (!skb)
749 return -ENOMEM;
750
751 cmd = (struct roam_ctrl_cmd *) skb->data;
752 memset(cmd, 0, sizeof(*cmd));
753
754 cmd->info.roam_mode = mode;
755 cmd->roam_ctrl = WMI_SET_ROAM_MODE;
756
757 ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530758 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
Jouni Malinen12618752011-10-11 17:31:55 +0300759 NO_SYNC_WMIFLAG);
760}
761
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530762static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
763 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300764{
765 struct wmi_connect_event *ev;
766 u8 *pie, *peie;
767
768 if (len < sizeof(struct wmi_connect_event))
769 return -EINVAL;
770
771 ev = (struct wmi_connect_event *) datap;
772
Vasanthakumar Thiagarajanf5938f22011-10-25 19:34:03 +0530773 if (vif->nw_type == AP_NETWORK) {
Jouni Malinen572e27c2011-09-05 17:38:45 +0300774 /* AP mode start/STA connected event */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530775 struct net_device *dev = vif->ndev;
Jouni Malinen572e27c2011-09-05 17:38:45 +0300776 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
777 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM "
778 "(AP started)\n",
779 __func__, le16_to_cpu(ev->u.ap_bss.ch),
780 ev->u.ap_bss.bssid);
781 ath6kl_connect_ap_mode_bss(
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530782 vif, le16_to_cpu(ev->u.ap_bss.ch));
Jouni Malinen572e27c2011-09-05 17:38:45 +0300783 } else {
784 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM "
785 "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
786 "(STA connected)\n",
787 __func__, ev->u.ap_sta.aid,
788 ev->u.ap_sta.mac_addr,
789 ev->u.ap_sta.auth,
790 ev->u.ap_sta.keymgmt,
791 le16_to_cpu(ev->u.ap_sta.cipher),
792 ev->u.ap_sta.apsd_info);
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530793
Jouni Malinen572e27c2011-09-05 17:38:45 +0300794 ath6kl_connect_ap_mode_sta(
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530795 vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
Jouni Malinen572e27c2011-09-05 17:38:45 +0300796 ev->u.ap_sta.keymgmt,
797 le16_to_cpu(ev->u.ap_sta.cipher),
798 ev->u.ap_sta.auth, ev->assoc_req_len,
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530799 ev->assoc_info + ev->beacon_ie_len,
800 ev->u.ap_sta.apsd_info);
Jouni Malinen572e27c2011-09-05 17:38:45 +0300801 }
802 return 0;
803 }
804
805 /* STA/IBSS mode connection event */
806
Kalle Valob9b6ee62011-09-27 14:31:21 +0300807 ath6kl_dbg(ATH6KL_DBG_WMI,
808 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
809 le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid,
810 le16_to_cpu(ev->u.sta.listen_intvl),
811 le16_to_cpu(ev->u.sta.beacon_intvl),
812 le32_to_cpu(ev->u.sta.nw_type));
Kalle Valobdcd8172011-07-18 00:22:30 +0300813
Kalle Valobdcd8172011-07-18 00:22:30 +0300814 /* Start of assoc rsp IEs */
815 pie = ev->assoc_info + ev->beacon_ie_len +
816 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
817
818 /* End of assoc rsp IEs */
819 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
820 ev->assoc_resp_len;
821
822 while (pie < peie) {
823 switch (*pie) {
824 case WLAN_EID_VENDOR_SPECIFIC:
825 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
826 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
827 /* WMM OUT (00:50:F2) */
828 if (pie[1] > 5
829 && pie[6] == WMM_PARAM_OUI_SUBTYPE)
830 wmi->is_wmm_enabled = true;
831 }
832 break;
833 }
834
835 if (wmi->is_wmm_enabled)
836 break;
837
838 pie += pie[1] + 2;
839 }
840
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530841 ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch),
Jouni Malinen572e27c2011-09-05 17:38:45 +0300842 ev->u.sta.bssid,
843 le16_to_cpu(ev->u.sta.listen_intvl),
844 le16_to_cpu(ev->u.sta.beacon_intvl),
845 le32_to_cpu(ev->u.sta.nw_type),
Kalle Valobdcd8172011-07-18 00:22:30 +0300846 ev->beacon_ie_len, ev->assoc_req_len,
847 ev->assoc_resp_len, ev->assoc_info);
848
849 return 0;
850}
851
Vivek Natarajan06033762011-09-06 13:01:36 +0530852static struct country_code_to_enum_rd *
853ath6kl_regd_find_country(u16 countryCode)
854{
855 int i;
856
857 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
858 if (allCountries[i].countryCode == countryCode)
859 return &allCountries[i];
860 }
861
862 return NULL;
863}
864
865static struct reg_dmn_pair_mapping *
866ath6kl_get_regpair(u16 regdmn)
867{
868 int i;
869
870 if (regdmn == NO_ENUMRD)
871 return NULL;
872
873 for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
874 if (regDomainPairs[i].regDmnEnum == regdmn)
875 return &regDomainPairs[i];
876 }
877
878 return NULL;
879}
880
881static struct country_code_to_enum_rd *
882ath6kl_regd_find_country_by_rd(u16 regdmn)
883{
884 int i;
885
886 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
887 if (allCountries[i].regDmnEnum == regdmn)
888 return &allCountries[i];
889 }
890
891 return NULL;
892}
893
894static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
895{
896
897 struct ath6kl_wmi_regdomain *ev;
898 struct country_code_to_enum_rd *country = NULL;
899 struct reg_dmn_pair_mapping *regpair = NULL;
900 char alpha2[2];
901 u32 reg_code;
902
903 ev = (struct ath6kl_wmi_regdomain *) datap;
904 reg_code = le32_to_cpu(ev->reg_code);
905
906 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
907 country = ath6kl_regd_find_country((u16) reg_code);
908 else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
909
910 regpair = ath6kl_get_regpair((u16) reg_code);
911 country = ath6kl_regd_find_country_by_rd((u16) reg_code);
Kalle Valob9b6ee62011-09-27 14:31:21 +0300912 ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
Vivek Natarajan06033762011-09-06 13:01:36 +0530913 regpair->regDmnEnum);
914 }
915
916 if (country) {
917 alpha2[0] = country->isoName[0];
918 alpha2[1] = country->isoName[1];
919
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +0530920 regulatory_hint(wmi->parent_dev->wiphy, alpha2);
Vivek Natarajan06033762011-09-06 13:01:36 +0530921
Kalle Valob9b6ee62011-09-27 14:31:21 +0300922 ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n",
Vivek Natarajan06033762011-09-06 13:01:36 +0530923 alpha2[0], alpha2[1]);
924 }
925}
926
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530927static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len,
928 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300929{
930 struct wmi_disconnect_event *ev;
931 wmi->traffic_class = 100;
932
933 if (len < sizeof(struct wmi_disconnect_event))
934 return -EINVAL;
935
936 ev = (struct wmi_disconnect_event *) datap;
Kalle Valobdcd8172011-07-18 00:22:30 +0300937
Kalle Valob9b6ee62011-09-27 14:31:21 +0300938 ath6kl_dbg(ATH6KL_DBG_WMI,
939 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
940 le16_to_cpu(ev->proto_reason_status), ev->bssid,
941 ev->disconn_reason, ev->assoc_resp_len);
942
Kalle Valobdcd8172011-07-18 00:22:30 +0300943 wmi->is_wmm_enabled = false;
Kalle Valobdcd8172011-07-18 00:22:30 +0300944
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530945 ath6kl_disconnect_event(vif, ev->disconn_reason,
Kalle Valobdcd8172011-07-18 00:22:30 +0300946 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
947 le16_to_cpu(ev->proto_reason_status));
948
949 return 0;
950}
951
952static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
953{
954 struct wmi_peer_node_event *ev;
955
956 if (len < sizeof(struct wmi_peer_node_event))
957 return -EINVAL;
958
959 ev = (struct wmi_peer_node_event *) datap;
960
961 if (ev->event_code == PEER_NODE_JOIN_EVENT)
962 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
963 ev->peer_mac_addr);
964 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
965 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
966 ev->peer_mac_addr);
967
968 return 0;
969}
970
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530971static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,
972 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300973{
974 struct wmi_tkip_micerr_event *ev;
975
976 if (len < sizeof(struct wmi_tkip_micerr_event))
977 return -EINVAL;
978
979 ev = (struct wmi_tkip_micerr_event *) datap;
980
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530981 ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);
Kalle Valobdcd8172011-07-18 00:22:30 +0300982
983 return 0;
984}
985
Kalle Valo10509f92011-12-13 14:52:07 +0200986void ath6kl_wmi_sscan_timer(unsigned long ptr)
987{
988 struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
989
990 cfg80211_sched_scan_results(vif->ar->wiphy);
991}
992
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530993static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
994 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300995{
Jouni Malinen82e14f52011-09-19 19:15:05 +0300996 struct wmi_bss_info_hdr2 *bih;
Jouni Malinen1aaa8c72011-09-19 19:15:03 +0300997 u8 *buf;
998 struct ieee80211_channel *channel;
999 struct ath6kl *ar = wmi->parent_dev;
1000 struct ieee80211_mgmt *mgmt;
1001 struct cfg80211_bss *bss;
Kalle Valobdcd8172011-07-18 00:22:30 +03001002
Jouni Malinen82e14f52011-09-19 19:15:05 +03001003 if (len <= sizeof(struct wmi_bss_info_hdr2))
Kalle Valobdcd8172011-07-18 00:22:30 +03001004 return -EINVAL;
1005
Jouni Malinen82e14f52011-09-19 19:15:05 +03001006 bih = (struct wmi_bss_info_hdr2 *) datap;
1007 buf = datap + sizeof(struct wmi_bss_info_hdr2);
1008 len -= sizeof(struct wmi_bss_info_hdr2);
Kalle Valobdcd8172011-07-18 00:22:30 +03001009
1010 ath6kl_dbg(ATH6KL_DBG_WMI,
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001011 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1012 "frame_type=%d\n",
Jouni Malinen82e14f52011-09-19 19:15:05 +03001013 bih->ch, bih->snr, bih->snr - 95, bih->bssid,
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001014 bih->frame_type);
Kalle Valobdcd8172011-07-18 00:22:30 +03001015
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001016 if (bih->frame_type != BEACON_FTYPE &&
1017 bih->frame_type != PROBERESP_FTYPE)
1018 return 0; /* Only update BSS table for now */
Kalle Valobdcd8172011-07-18 00:22:30 +03001019
Jouni Malinen551185c2011-09-19 19:15:06 +03001020 if (bih->frame_type == BEACON_FTYPE &&
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301021 test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) {
1022 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301023 ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
1024 NONE_BSS_FILTER, 0);
Jouni Malinen551185c2011-09-19 19:15:06 +03001025 }
1026
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +05301027 channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch));
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001028 if (channel == NULL)
1029 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001030
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001031 if (len < 8 + 2 + 2)
1032 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001033
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301034 if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags)
Vasanthakumar Thiagarajan8c8b65e2011-10-25 19:34:04 +05301035 && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) {
Jouni Malinen32c10872011-09-19 19:15:07 +03001036 const u8 *tim;
1037 tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2,
1038 len - 8 - 2 - 2);
1039 if (tim && tim[1] >= 2) {
Vasanthakumar Thiagarajancf5333d2011-10-25 19:34:10 +05301040 vif->assoc_bss_dtim_period = tim[3];
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301041 set_bit(DTIM_PERIOD_AVAIL, &vif->flags);
Jouni Malinen32c10872011-09-19 19:15:07 +03001042 }
1043 }
1044
Kalle Valobdcd8172011-07-18 00:22:30 +03001045 /*
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001046 * In theory, use of cfg80211_inform_bss() would be more natural here
1047 * since we do not have the full frame. However, at least for now,
1048 * cfg80211 can only distinguish Beacon and Probe Response frames from
1049 * each other when using cfg80211_inform_bss_frame(), so let's build a
1050 * fake IEEE 802.11 header to be able to take benefit of this.
Kalle Valobdcd8172011-07-18 00:22:30 +03001051 */
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001052 mgmt = kmalloc(24 + len, GFP_ATOMIC);
1053 if (mgmt == NULL)
1054 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001055
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001056 if (bih->frame_type == BEACON_FTYPE) {
1057 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1058 IEEE80211_STYPE_BEACON);
1059 memset(mgmt->da, 0xff, ETH_ALEN);
1060 } else {
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301061 struct net_device *dev = vif->ndev;
Kalle Valobdcd8172011-07-18 00:22:30 +03001062
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001063 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1064 IEEE80211_STYPE_PROBE_RESP);
1065 memcpy(mgmt->da, dev->dev_addr, ETH_ALEN);
Kalle Valobdcd8172011-07-18 00:22:30 +03001066 }
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001067 mgmt->duration = cpu_to_le16(0);
1068 memcpy(mgmt->sa, bih->bssid, ETH_ALEN);
1069 memcpy(mgmt->bssid, bih->bssid, ETH_ALEN);
1070 mgmt->seq_ctrl = cpu_to_le16(0);
Kalle Valobdcd8172011-07-18 00:22:30 +03001071
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001072 memcpy(&mgmt->u.beacon, buf, len);
1073
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +05301074 bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt,
Jouni Malinen82e14f52011-09-19 19:15:05 +03001075 24 + len, (bih->snr - 95) * 100,
1076 GFP_ATOMIC);
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001077 kfree(mgmt);
1078 if (bss == NULL)
Kalle Valobdcd8172011-07-18 00:22:30 +03001079 return -ENOMEM;
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001080 cfg80211_put_bss(bss);
Kalle Valobdcd8172011-07-18 00:22:30 +03001081
Kalle Valo10509f92011-12-13 14:52:07 +02001082 /*
1083 * Firmware doesn't return any event when scheduled scan has
1084 * finished, so we need to use a timer to find out when there are
1085 * no more results.
1086 *
1087 * The timer is started from the first bss info received, otherwise
1088 * the timer would not ever fire if the scan interval is short
1089 * enough.
1090 */
1091 if (ar->state == ATH6KL_STATE_SCHED_SCAN &&
1092 !timer_pending(&vif->sched_scan_timer)) {
1093 mod_timer(&vif->sched_scan_timer, jiffies +
1094 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY));
1095 }
1096
Kalle Valobdcd8172011-07-18 00:22:30 +03001097 return 0;
1098}
1099
Kalle Valobdcd8172011-07-18 00:22:30 +03001100/* Inactivity timeout of a fatpipe(pstream) at the target */
1101static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1102 int len)
1103{
1104 struct wmi_pstream_timeout_event *ev;
1105
1106 if (len < sizeof(struct wmi_pstream_timeout_event))
1107 return -EINVAL;
1108
1109 ev = (struct wmi_pstream_timeout_event *) datap;
1110
1111 /*
1112 * When the pstream (fat pipe == AC) timesout, it means there were
1113 * no thinStreams within this pstream & it got implicitly created
1114 * due to data flow on this AC. We start the inactivity timer only
1115 * for implicitly created pstream. Just reset the host state.
1116 */
1117 spin_lock_bh(&wmi->lock);
1118 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1119 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1120 spin_unlock_bh(&wmi->lock);
1121
1122 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1123 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1124
1125 return 0;
1126}
1127
1128static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1129{
1130 struct wmi_bit_rate_reply *reply;
1131 s32 rate;
1132 u32 sgi, index;
1133
1134 if (len < sizeof(struct wmi_bit_rate_reply))
1135 return -EINVAL;
1136
1137 reply = (struct wmi_bit_rate_reply *) datap;
1138
1139 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1140
1141 if (reply->rate_index == (s8) RATE_AUTO) {
1142 rate = RATE_AUTO;
1143 } else {
1144 index = reply->rate_index & 0x7f;
1145 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1146 rate = wmi_rate_tbl[index][sgi];
1147 }
1148
1149 ath6kl_wakeup_event(wmi->parent_dev);
1150
1151 return 0;
1152}
1153
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08001154static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len)
Kalle Valo003353b0d2011-09-01 10:14:21 +03001155{
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08001156 ath6kl_tm_rx_event(wmi->parent_dev, datap, len);
Kalle Valo003353b0d2011-09-01 10:14:21 +03001157
1158 return 0;
1159}
1160
Kalle Valobdcd8172011-07-18 00:22:30 +03001161static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1162{
1163 if (len < sizeof(struct wmi_fix_rates_reply))
1164 return -EINVAL;
1165
1166 ath6kl_wakeup_event(wmi->parent_dev);
1167
1168 return 0;
1169}
1170
1171static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1172{
1173 if (len < sizeof(struct wmi_channel_list_reply))
1174 return -EINVAL;
1175
1176 ath6kl_wakeup_event(wmi->parent_dev);
1177
1178 return 0;
1179}
1180
1181static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1182{
1183 struct wmi_tx_pwr_reply *reply;
1184
1185 if (len < sizeof(struct wmi_tx_pwr_reply))
1186 return -EINVAL;
1187
1188 reply = (struct wmi_tx_pwr_reply *) datap;
1189 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1190
1191 return 0;
1192}
1193
1194static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1195{
1196 if (len < sizeof(struct wmi_get_keepalive_cmd))
1197 return -EINVAL;
1198
1199 ath6kl_wakeup_event(wmi->parent_dev);
1200
1201 return 0;
1202}
1203
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301204static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len,
1205 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001206{
1207 struct wmi_scan_complete_event *ev;
1208
1209 ev = (struct wmi_scan_complete_event *) datap;
1210
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301211 ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status));
Kalle Valobdcd8172011-07-18 00:22:30 +03001212 wmi->is_probe_ssid = false;
1213
1214 return 0;
1215}
1216
Jouni Malinen86512132011-09-21 16:57:29 +03001217static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301218 int len, struct ath6kl_vif *vif)
Jouni Malinen86512132011-09-21 16:57:29 +03001219{
1220 struct wmi_neighbor_report_event *ev;
1221 u8 i;
1222
1223 if (len < sizeof(*ev))
1224 return -EINVAL;
1225 ev = (struct wmi_neighbor_report_event *) datap;
1226 if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info)
1227 > len) {
1228 ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event "
1229 "(num=%d len=%d)\n", ev->num_neighbors, len);
1230 return -EINVAL;
1231 }
1232 for (i = 0; i < ev->num_neighbors; i++) {
1233 ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n",
1234 i + 1, ev->num_neighbors, ev->neighbor[i].bssid,
1235 ev->neighbor[i].bss_flags);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301236 cfg80211_pmksa_candidate_notify(vif->ndev, i,
Jouni Malinen86512132011-09-21 16:57:29 +03001237 ev->neighbor[i].bssid,
1238 !!(ev->neighbor[i].bss_flags &
1239 WMI_PREAUTH_CAPABLE_BSS),
1240 GFP_ATOMIC);
1241 }
1242
1243 return 0;
1244}
1245
Kalle Valobdcd8172011-07-18 00:22:30 +03001246/*
1247 * Target is reporting a programming error. This is for
1248 * developer aid only. Target only checks a few common violations
1249 * and it is responsibility of host to do all error checking.
1250 * Behavior of target after wmi error event is undefined.
1251 * A reset is recommended.
1252 */
1253static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1254{
1255 const char *type = "unknown error";
1256 struct wmi_cmd_error_event *ev;
1257 ev = (struct wmi_cmd_error_event *) datap;
1258
1259 switch (ev->err_code) {
1260 case INVALID_PARAM:
1261 type = "invalid parameter";
1262 break;
1263 case ILLEGAL_STATE:
1264 type = "invalid state";
1265 break;
1266 case INTERNAL_ERROR:
1267 type = "internal error";
1268 break;
1269 }
1270
1271 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1272 ev->cmd_id, type);
1273
1274 return 0;
1275}
1276
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301277static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len,
1278 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001279{
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301280 ath6kl_tgt_stats_event(vif, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03001281
1282 return 0;
1283}
1284
1285static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1286 struct sq_threshold_params *sq_thresh,
1287 u32 size)
1288{
1289 u32 index;
1290 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1291
1292 /* The list is already in sorted order. Get the next lower value */
1293 for (index = 0; index < size; index++) {
1294 if (rssi < sq_thresh->upper_threshold[index]) {
1295 threshold = (u8) sq_thresh->upper_threshold[index];
1296 break;
1297 }
1298 }
1299
1300 return threshold;
1301}
1302
1303static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1304 struct sq_threshold_params *sq_thresh,
1305 u32 size)
1306{
1307 u32 index;
1308 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1309
1310 /* The list is already in sorted order. Get the next lower value */
1311 for (index = 0; index < size; index++) {
1312 if (rssi > sq_thresh->lower_threshold[index]) {
1313 threshold = (u8) sq_thresh->lower_threshold[index];
1314 break;
1315 }
1316 }
1317
1318 return threshold;
1319}
1320
1321static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1322 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1323{
1324 struct sk_buff *skb;
1325 struct wmi_rssi_threshold_params_cmd *cmd;
1326
1327 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1328 if (!skb)
1329 return -ENOMEM;
1330
1331 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1332 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1333
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301334 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001335 NO_SYNC_WMIFLAG);
1336}
1337
1338static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1339 int len)
1340{
1341 struct wmi_rssi_threshold_event *reply;
1342 struct wmi_rssi_threshold_params_cmd cmd;
1343 struct sq_threshold_params *sq_thresh;
1344 enum wmi_rssi_threshold_val new_threshold;
1345 u8 upper_rssi_threshold, lower_rssi_threshold;
1346 s16 rssi;
1347 int ret;
1348
1349 if (len < sizeof(struct wmi_rssi_threshold_event))
1350 return -EINVAL;
1351
1352 reply = (struct wmi_rssi_threshold_event *) datap;
1353 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1354 rssi = a_sle16_to_cpu(reply->rssi);
1355
1356 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1357
1358 /*
1359 * Identify the threshold breached and communicate that to the app.
1360 * After that install a new set of thresholds based on the signal
1361 * quality reported by the target
1362 */
1363 if (new_threshold) {
1364 /* Upper threshold breached */
1365 if (rssi < sq_thresh->upper_threshold[0]) {
1366 ath6kl_dbg(ATH6KL_DBG_WMI,
1367 "spurious upper rssi threshold event: %d\n",
1368 rssi);
1369 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1370 (rssi >= sq_thresh->upper_threshold[0])) {
1371 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1372 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1373 (rssi >= sq_thresh->upper_threshold[1])) {
1374 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1375 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1376 (rssi >= sq_thresh->upper_threshold[2])) {
1377 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1378 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1379 (rssi >= sq_thresh->upper_threshold[3])) {
1380 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1381 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1382 (rssi >= sq_thresh->upper_threshold[4])) {
1383 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1384 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1385 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1386 }
1387 } else {
1388 /* Lower threshold breached */
1389 if (rssi > sq_thresh->lower_threshold[0]) {
1390 ath6kl_dbg(ATH6KL_DBG_WMI,
1391 "spurious lower rssi threshold event: %d %d\n",
1392 rssi, sq_thresh->lower_threshold[0]);
1393 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1394 (rssi <= sq_thresh->lower_threshold[0])) {
1395 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1396 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1397 (rssi <= sq_thresh->lower_threshold[1])) {
1398 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1399 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1400 (rssi <= sq_thresh->lower_threshold[2])) {
1401 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1402 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1403 (rssi <= sq_thresh->lower_threshold[3])) {
1404 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1405 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1406 (rssi <= sq_thresh->lower_threshold[4])) {
1407 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1408 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1409 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1410 }
1411 }
1412
1413 /* Calculate and install the next set of thresholds */
1414 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1415 sq_thresh->lower_threshold_valid_count);
1416 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1417 sq_thresh->upper_threshold_valid_count);
1418
1419 /* Issue a wmi command to install the thresholds */
1420 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1421 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1422 cmd.weight = sq_thresh->weight;
1423 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1424
1425 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1426 if (ret) {
1427 ath6kl_err("unable to configure rssi thresholds\n");
1428 return -EIO;
1429 }
1430
1431 return 0;
1432}
1433
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301434static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1435 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001436{
1437 struct wmi_cac_event *reply;
1438 struct ieee80211_tspec_ie *ts;
1439 u16 active_tsids, tsinfo;
1440 u8 tsid, index;
1441 u8 ts_id;
1442
1443 if (len < sizeof(struct wmi_cac_event))
1444 return -EINVAL;
1445
1446 reply = (struct wmi_cac_event *) datap;
1447
1448 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1449 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1450
1451 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1452 tsinfo = le16_to_cpu(ts->tsinfo);
1453 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1454 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1455
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301456 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1457 reply->ac, tsid);
Kalle Valobdcd8172011-07-18 00:22:30 +03001458 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1459 /*
1460 * Following assumes that there is only one outstanding
1461 * ADDTS request when this event is received
1462 */
1463 spin_lock_bh(&wmi->lock);
1464 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1465 spin_unlock_bh(&wmi->lock);
1466
1467 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1468 if ((active_tsids >> index) & 1)
1469 break;
1470 }
1471 if (index < (sizeof(active_tsids) * 8))
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301472 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1473 reply->ac, index);
Kalle Valobdcd8172011-07-18 00:22:30 +03001474 }
1475
1476 /*
1477 * Clear active tsids and Add missing handling
1478 * for delete qos stream from AP
1479 */
1480 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1481
1482 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1483 tsinfo = le16_to_cpu(ts->tsinfo);
1484 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1485 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1486
1487 spin_lock_bh(&wmi->lock);
1488 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1489 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1490 spin_unlock_bh(&wmi->lock);
1491
1492 /* Indicate stream inactivity to driver layer only if all tsids
1493 * within this AC are deleted.
1494 */
1495 if (!active_tsids) {
1496 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1497 false);
1498 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1499 }
1500 }
1501
1502 return 0;
1503}
1504
1505static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1506 struct wmi_snr_threshold_params_cmd *snr_cmd)
1507{
1508 struct sk_buff *skb;
1509 struct wmi_snr_threshold_params_cmd *cmd;
1510
1511 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1512 if (!skb)
1513 return -ENOMEM;
1514
1515 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1516 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1517
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301518 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001519 NO_SYNC_WMIFLAG);
1520}
1521
1522static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1523 int len)
1524{
1525 struct wmi_snr_threshold_event *reply;
1526 struct sq_threshold_params *sq_thresh;
1527 struct wmi_snr_threshold_params_cmd cmd;
1528 enum wmi_snr_threshold_val new_threshold;
1529 u8 upper_snr_threshold, lower_snr_threshold;
1530 s16 snr;
1531 int ret;
1532
1533 if (len < sizeof(struct wmi_snr_threshold_event))
1534 return -EINVAL;
1535
1536 reply = (struct wmi_snr_threshold_event *) datap;
1537
1538 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1539 snr = reply->snr;
1540
1541 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1542
1543 /*
1544 * Identify the threshold breached and communicate that to the app.
1545 * After that install a new set of thresholds based on the signal
1546 * quality reported by the target.
1547 */
1548 if (new_threshold) {
1549 /* Upper threshold breached */
1550 if (snr < sq_thresh->upper_threshold[0]) {
1551 ath6kl_dbg(ATH6KL_DBG_WMI,
1552 "spurious upper snr threshold event: %d\n",
1553 snr);
1554 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1555 (snr >= sq_thresh->upper_threshold[0])) {
1556 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1557 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1558 (snr >= sq_thresh->upper_threshold[1])) {
1559 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1560 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1561 (snr >= sq_thresh->upper_threshold[2])) {
1562 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1563 } else if (snr >= sq_thresh->upper_threshold[3]) {
1564 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1565 }
1566 } else {
1567 /* Lower threshold breached */
1568 if (snr > sq_thresh->lower_threshold[0]) {
1569 ath6kl_dbg(ATH6KL_DBG_WMI,
1570 "spurious lower snr threshold event: %d\n",
1571 sq_thresh->lower_threshold[0]);
1572 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1573 (snr <= sq_thresh->lower_threshold[0])) {
1574 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1575 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1576 (snr <= sq_thresh->lower_threshold[1])) {
1577 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1578 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1579 (snr <= sq_thresh->lower_threshold[2])) {
1580 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1581 } else if (snr <= sq_thresh->lower_threshold[3]) {
1582 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1583 }
1584 }
1585
1586 /* Calculate and install the next set of thresholds */
1587 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1588 sq_thresh->lower_threshold_valid_count);
1589 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1590 sq_thresh->upper_threshold_valid_count);
1591
1592 /* Issue a wmi command to install the thresholds */
1593 cmd.thresh_above1_val = upper_snr_threshold;
1594 cmd.thresh_below1_val = lower_snr_threshold;
1595 cmd.weight = sq_thresh->weight;
1596 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1597
1598 ath6kl_dbg(ATH6KL_DBG_WMI,
1599 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1600 snr, new_threshold,
1601 lower_snr_threshold, upper_snr_threshold);
1602
1603 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1604 if (ret) {
1605 ath6kl_err("unable to configure snr threshold\n");
1606 return -EIO;
1607 }
1608
1609 return 0;
1610}
1611
1612static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1613{
1614 u16 ap_info_entry_size;
1615 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1616 struct wmi_ap_info_v1 *ap_info_v1;
1617 u8 index;
1618
1619 if (len < sizeof(struct wmi_aplist_event) ||
1620 ev->ap_list_ver != APLIST_VER1)
1621 return -EINVAL;
1622
1623 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1624 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1625
1626 ath6kl_dbg(ATH6KL_DBG_WMI,
1627 "number of APs in aplist event: %d\n", ev->num_ap);
1628
1629 if (len < (int) (sizeof(struct wmi_aplist_event) +
1630 (ev->num_ap - 1) * ap_info_entry_size))
1631 return -EINVAL;
1632
1633 /* AP list version 1 contents */
1634 for (index = 0; index < ev->num_ap; index++) {
1635 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1636 index, ap_info_v1->bssid, ap_info_v1->channel);
1637 ap_info_v1++;
1638 }
1639
1640 return 0;
1641}
1642
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301643int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb,
Kalle Valobdcd8172011-07-18 00:22:30 +03001644 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1645{
1646 struct wmi_cmd_hdr *cmd_hdr;
1647 enum htc_endpoint_id ep_id = wmi->ep_id;
1648 int ret;
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301649 u16 info1;
Kalle Valobdcd8172011-07-18 00:22:30 +03001650
Kalle Valo71f96ee2011-11-14 19:31:30 +02001651 if (WARN_ON(skb == NULL || (if_idx > (wmi->parent_dev->vif_max - 1))))
Kalle Valobdcd8172011-07-18 00:22:30 +03001652 return -EINVAL;
1653
Kalle Valob9b6ee62011-09-27 14:31:21 +03001654 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n",
1655 cmd_id, skb->len, sync_flag);
1656 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ",
1657 skb->data, skb->len);
1658
Kalle Valobdcd8172011-07-18 00:22:30 +03001659 if (sync_flag >= END_WMIFLAG) {
1660 dev_kfree_skb(skb);
1661 return -EINVAL;
1662 }
1663
1664 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1665 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1666 /*
1667 * Make sure all data currently queued is transmitted before
1668 * the cmd execution. Establish a new sync point.
1669 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301670 ath6kl_wmi_sync_point(wmi, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001671 }
1672
1673 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1674
1675 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1676 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301677 info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK;
1678 cmd_hdr->info1 = cpu_to_le16(info1);
Kalle Valobdcd8172011-07-18 00:22:30 +03001679
1680 /* Only for OPT_TX_CMD, use BE endpoint. */
1681 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1682 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05301683 false, false, 0, NULL, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001684 if (ret) {
1685 dev_kfree_skb(skb);
1686 return ret;
1687 }
1688 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1689 }
1690
1691 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1692
1693 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1694 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1695 /*
1696 * Make sure all new data queued waits for the command to
1697 * execute. Establish a new sync point.
1698 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301699 ath6kl_wmi_sync_point(wmi, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001700 }
1701
1702 return 0;
1703}
1704
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301705int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx,
1706 enum network_type nw_type,
Kalle Valobdcd8172011-07-18 00:22:30 +03001707 enum dot11_auth_mode dot11_auth_mode,
1708 enum auth_mode auth_mode,
1709 enum crypto_type pairwise_crypto,
1710 u8 pairwise_crypto_len,
1711 enum crypto_type group_crypto,
1712 u8 group_crypto_len, int ssid_len, u8 *ssid,
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001713 u8 *bssid, u16 channel, u32 ctrl_flags,
1714 u8 nw_subtype)
Kalle Valobdcd8172011-07-18 00:22:30 +03001715{
1716 struct sk_buff *skb;
1717 struct wmi_connect_cmd *cc;
1718 int ret;
1719
Kalle Valob9b6ee62011-09-27 14:31:21 +03001720 ath6kl_dbg(ATH6KL_DBG_WMI,
1721 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1722 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1723 bssid, channel, ctrl_flags, ssid_len, nw_type,
1724 dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto);
1725 ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len);
1726
Kalle Valobdcd8172011-07-18 00:22:30 +03001727 wmi->traffic_class = 100;
1728
1729 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1730 return -EINVAL;
1731
1732 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1733 return -EINVAL;
1734
1735 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1736 if (!skb)
1737 return -ENOMEM;
1738
1739 cc = (struct wmi_connect_cmd *) skb->data;
1740
1741 if (ssid_len)
1742 memcpy(cc->ssid, ssid, ssid_len);
1743
1744 cc->ssid_len = ssid_len;
1745 cc->nw_type = nw_type;
1746 cc->dot11_auth_mode = dot11_auth_mode;
1747 cc->auth_mode = auth_mode;
1748 cc->prwise_crypto_type = pairwise_crypto;
1749 cc->prwise_crypto_len = pairwise_crypto_len;
1750 cc->grp_crypto_type = group_crypto;
1751 cc->grp_crypto_len = group_crypto_len;
1752 cc->ch = cpu_to_le16(channel);
1753 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001754 cc->nw_subtype = nw_subtype;
Kalle Valobdcd8172011-07-18 00:22:30 +03001755
1756 if (bssid != NULL)
1757 memcpy(cc->bssid, bssid, ETH_ALEN);
1758
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301759 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID,
1760 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03001761
1762 return ret;
1763}
1764
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301765int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid,
1766 u16 channel)
Kalle Valobdcd8172011-07-18 00:22:30 +03001767{
1768 struct sk_buff *skb;
1769 struct wmi_reconnect_cmd *cc;
1770 int ret;
1771
Kalle Valob9b6ee62011-09-27 14:31:21 +03001772 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n",
1773 bssid, channel);
1774
Kalle Valobdcd8172011-07-18 00:22:30 +03001775 wmi->traffic_class = 100;
1776
1777 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1778 if (!skb)
1779 return -ENOMEM;
1780
1781 cc = (struct wmi_reconnect_cmd *) skb->data;
1782 cc->channel = cpu_to_le16(channel);
1783
1784 if (bssid != NULL)
1785 memcpy(cc->bssid, bssid, ETH_ALEN);
1786
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301787 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001788 NO_SYNC_WMIFLAG);
1789
1790 return ret;
1791}
1792
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301793int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03001794{
1795 int ret;
1796
Kalle Valob9b6ee62011-09-27 14:31:21 +03001797 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n");
1798
Kalle Valobdcd8172011-07-18 00:22:30 +03001799 wmi->traffic_class = 100;
1800
1801 /* Disconnect command does not need to do a SYNC before. */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301802 ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03001803
1804 return ret;
1805}
1806
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001807int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx,
1808 enum wmi_scan_type scan_type,
1809 u32 force_fgscan, u32 is_legacy,
1810 u32 home_dwell_time, u32 force_scan_interval,
1811 s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
1812{
1813 struct sk_buff *skb;
1814 struct wmi_begin_scan_cmd *sc;
1815 s8 size;
1816 int i, band, ret;
1817 struct ath6kl *ar = wmi->parent_dev;
1818 int num_rates;
1819
1820 size = sizeof(struct wmi_begin_scan_cmd);
1821
1822 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1823 return -EINVAL;
1824
1825 if (num_chan > WMI_MAX_CHANNELS)
1826 return -EINVAL;
1827
1828 if (num_chan)
1829 size += sizeof(u16) * (num_chan - 1);
1830
1831 skb = ath6kl_wmi_get_new_buf(size);
1832 if (!skb)
1833 return -ENOMEM;
1834
1835 sc = (struct wmi_begin_scan_cmd *) skb->data;
1836 sc->scan_type = scan_type;
1837 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1838 sc->is_legacy = cpu_to_le32(is_legacy);
1839 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1840 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1841 sc->no_cck = cpu_to_le32(no_cck);
1842 sc->num_ch = num_chan;
1843
1844 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1845 struct ieee80211_supported_band *sband =
1846 ar->wiphy->bands[band];
1847 u32 ratemask = rates[band];
1848 u8 *supp_rates = sc->supp_rates[band].rates;
1849 num_rates = 0;
1850
1851 for (i = 0; i < sband->n_bitrates; i++) {
1852 if ((BIT(i) & ratemask) == 0)
1853 continue; /* skip rate */
1854 supp_rates[num_rates++] =
1855 (u8) (sband->bitrates[i].bitrate / 5);
1856 }
1857 sc->supp_rates[band].nrates = num_rates;
1858 }
1859
1860 for (i = 0; i < num_chan; i++)
1861 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
1862
1863 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID,
1864 NO_SYNC_WMIFLAG);
1865
1866 return ret;
1867}
1868
1869/* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
1870 * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
1871 * mgmt operations using station interface.
1872 */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301873int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx,
1874 enum wmi_scan_type scan_type,
Kalle Valobdcd8172011-07-18 00:22:30 +03001875 u32 force_fgscan, u32 is_legacy,
1876 u32 home_dwell_time, u32 force_scan_interval,
1877 s8 num_chan, u16 *ch_list)
1878{
1879 struct sk_buff *skb;
1880 struct wmi_start_scan_cmd *sc;
1881 s8 size;
Edward Lu1276c9e2011-08-30 21:58:00 +03001882 int i, ret;
Kalle Valobdcd8172011-07-18 00:22:30 +03001883
1884 size = sizeof(struct wmi_start_scan_cmd);
1885
1886 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1887 return -EINVAL;
1888
1889 if (num_chan > WMI_MAX_CHANNELS)
1890 return -EINVAL;
1891
1892 if (num_chan)
1893 size += sizeof(u16) * (num_chan - 1);
1894
1895 skb = ath6kl_wmi_get_new_buf(size);
1896 if (!skb)
1897 return -ENOMEM;
1898
1899 sc = (struct wmi_start_scan_cmd *) skb->data;
1900 sc->scan_type = scan_type;
1901 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1902 sc->is_legacy = cpu_to_le32(is_legacy);
1903 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1904 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1905 sc->num_ch = num_chan;
1906
Edward Lu1276c9e2011-08-30 21:58:00 +03001907 for (i = 0; i < num_chan; i++)
1908 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
Kalle Valobdcd8172011-07-18 00:22:30 +03001909
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301910 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001911 NO_SYNC_WMIFLAG);
1912
1913 return ret;
1914}
1915
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301916int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx,
1917 u16 fg_start_sec,
Kalle Valobdcd8172011-07-18 00:22:30 +03001918 u16 fg_end_sec, u16 bg_sec,
1919 u16 minact_chdw_msec, u16 maxact_chdw_msec,
1920 u16 pas_chdw_msec, u8 short_scan_ratio,
1921 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
1922 u16 maxact_scan_per_ssid)
1923{
1924 struct sk_buff *skb;
1925 struct wmi_scan_params_cmd *sc;
1926 int ret;
1927
1928 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
1929 if (!skb)
1930 return -ENOMEM;
1931
1932 sc = (struct wmi_scan_params_cmd *) skb->data;
1933 sc->fg_start_period = cpu_to_le16(fg_start_sec);
1934 sc->fg_end_period = cpu_to_le16(fg_end_sec);
1935 sc->bg_period = cpu_to_le16(bg_sec);
1936 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
1937 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
1938 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
1939 sc->short_scan_ratio = short_scan_ratio;
1940 sc->scan_ctrl_flags = scan_ctrl_flag;
1941 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
1942 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
1943
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301944 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001945 NO_SYNC_WMIFLAG);
1946 return ret;
1947}
1948
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301949int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask)
Kalle Valobdcd8172011-07-18 00:22:30 +03001950{
1951 struct sk_buff *skb;
1952 struct wmi_bss_filter_cmd *cmd;
1953 int ret;
1954
1955 if (filter >= LAST_BSS_FILTER)
1956 return -EINVAL;
1957
1958 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1959 if (!skb)
1960 return -ENOMEM;
1961
1962 cmd = (struct wmi_bss_filter_cmd *) skb->data;
1963 cmd->bss_filter = filter;
1964 cmd->ie_mask = cpu_to_le32(ie_mask);
1965
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301966 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001967 NO_SYNC_WMIFLAG);
1968 return ret;
1969}
1970
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301971int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag,
Kalle Valobdcd8172011-07-18 00:22:30 +03001972 u8 ssid_len, u8 *ssid)
1973{
1974 struct sk_buff *skb;
1975 struct wmi_probed_ssid_cmd *cmd;
1976 int ret;
1977
1978 if (index > MAX_PROBED_SSID_INDEX)
1979 return -EINVAL;
1980
1981 if (ssid_len > sizeof(cmd->ssid))
1982 return -EINVAL;
1983
1984 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
1985 return -EINVAL;
1986
1987 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
1988 return -EINVAL;
1989
1990 if (flag & SPECIFIC_SSID_FLAG)
1991 wmi->is_probe_ssid = true;
1992
1993 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1994 if (!skb)
1995 return -ENOMEM;
1996
1997 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
1998 cmd->entry_index = index;
1999 cmd->flag = flag;
2000 cmd->ssid_len = ssid_len;
2001 memcpy(cmd->ssid, ssid, ssid_len);
2002
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302003 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002004 NO_SYNC_WMIFLAG);
2005 return ret;
2006}
2007
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302008int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx,
2009 u16 listen_interval,
Kalle Valobdcd8172011-07-18 00:22:30 +03002010 u16 listen_beacons)
2011{
2012 struct sk_buff *skb;
2013 struct wmi_listen_int_cmd *cmd;
2014 int ret;
2015
2016 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2017 if (!skb)
2018 return -ENOMEM;
2019
2020 cmd = (struct wmi_listen_int_cmd *) skb->data;
2021 cmd->listen_intvl = cpu_to_le16(listen_interval);
2022 cmd->num_beacons = cpu_to_le16(listen_beacons);
2023
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302024 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002025 NO_SYNC_WMIFLAG);
2026 return ret;
2027}
2028
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302029int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode)
Kalle Valobdcd8172011-07-18 00:22:30 +03002030{
2031 struct sk_buff *skb;
2032 struct wmi_power_mode_cmd *cmd;
2033 int ret;
2034
2035 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2036 if (!skb)
2037 return -ENOMEM;
2038
2039 cmd = (struct wmi_power_mode_cmd *) skb->data;
2040 cmd->pwr_mode = pwr_mode;
2041 wmi->pwr_mode = pwr_mode;
2042
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302043 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002044 NO_SYNC_WMIFLAG);
2045 return ret;
2046}
2047
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302048int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period,
Kalle Valobdcd8172011-07-18 00:22:30 +03002049 u16 ps_poll_num, u16 dtim_policy,
2050 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
2051 u16 ps_fail_event_policy)
2052{
2053 struct sk_buff *skb;
2054 struct wmi_power_params_cmd *pm;
2055 int ret;
2056
2057 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
2058 if (!skb)
2059 return -ENOMEM;
2060
2061 pm = (struct wmi_power_params_cmd *)skb->data;
2062 pm->idle_period = cpu_to_le16(idle_period);
2063 pm->pspoll_number = cpu_to_le16(ps_poll_num);
2064 pm->dtim_policy = cpu_to_le16(dtim_policy);
2065 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
2066 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
2067 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
2068
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302069 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002070 NO_SYNC_WMIFLAG);
2071 return ret;
2072}
2073
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302074int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout)
Kalle Valobdcd8172011-07-18 00:22:30 +03002075{
2076 struct sk_buff *skb;
2077 struct wmi_disc_timeout_cmd *cmd;
2078 int ret;
2079
2080 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2081 if (!skb)
2082 return -ENOMEM;
2083
2084 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
2085 cmd->discon_timeout = timeout;
2086
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302087 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002088 NO_SYNC_WMIFLAG);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302089
Jouni Malinenff0b0072011-10-11 17:31:56 +03002090 if (ret == 0)
2091 ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302092
Kalle Valobdcd8172011-07-18 00:22:30 +03002093 return ret;
2094}
2095
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302096int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
Kalle Valobdcd8172011-07-18 00:22:30 +03002097 enum crypto_type key_type,
2098 u8 key_usage, u8 key_len,
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002099 u8 *key_rsc, unsigned int key_rsc_len,
2100 u8 *key_material,
Kalle Valobdcd8172011-07-18 00:22:30 +03002101 u8 key_op_ctrl, u8 *mac_addr,
2102 enum wmi_sync_flag sync_flag)
2103{
2104 struct sk_buff *skb;
2105 struct wmi_add_cipher_key_cmd *cmd;
2106 int ret;
2107
Jouni Malinen9a5b1312011-08-30 21:57:52 +03002108 ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
2109 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
2110 key_index, key_type, key_usage, key_len, key_op_ctrl);
2111
Kalle Valobdcd8172011-07-18 00:22:30 +03002112 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002113 (key_material == NULL) || key_rsc_len > 8)
Kalle Valobdcd8172011-07-18 00:22:30 +03002114 return -EINVAL;
2115
2116 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
2117 return -EINVAL;
2118
2119 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2120 if (!skb)
2121 return -ENOMEM;
2122
2123 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
2124 cmd->key_index = key_index;
2125 cmd->key_type = key_type;
2126 cmd->key_usage = key_usage;
2127 cmd->key_len = key_len;
2128 memcpy(cmd->key, key_material, key_len);
2129
2130 if (key_rsc != NULL)
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002131 memcpy(cmd->key_rsc, key_rsc, key_rsc_len);
Kalle Valobdcd8172011-07-18 00:22:30 +03002132
2133 cmd->key_op_ctrl = key_op_ctrl;
2134
2135 if (mac_addr)
2136 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
2137
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302138 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002139 sync_flag);
2140
2141 return ret;
2142}
2143
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302144int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk)
Kalle Valobdcd8172011-07-18 00:22:30 +03002145{
2146 struct sk_buff *skb;
2147 struct wmi_add_krk_cmd *cmd;
2148 int ret;
2149
2150 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2151 if (!skb)
2152 return -ENOMEM;
2153
2154 cmd = (struct wmi_add_krk_cmd *) skb->data;
2155 memcpy(cmd->krk, krk, WMI_KRK_LEN);
2156
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302157 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID,
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302158 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002159
2160 return ret;
2161}
2162
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302163int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index)
Kalle Valobdcd8172011-07-18 00:22:30 +03002164{
2165 struct sk_buff *skb;
2166 struct wmi_delete_cipher_key_cmd *cmd;
2167 int ret;
2168
2169 if (key_index > WMI_MAX_KEY_INDEX)
2170 return -EINVAL;
2171
2172 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2173 if (!skb)
2174 return -ENOMEM;
2175
2176 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
2177 cmd->key_index = key_index;
2178
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302179 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002180 NO_SYNC_WMIFLAG);
2181
2182 return ret;
2183}
2184
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302185int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
Kalle Valobdcd8172011-07-18 00:22:30 +03002186 const u8 *pmkid, bool set)
2187{
2188 struct sk_buff *skb;
2189 struct wmi_setpmkid_cmd *cmd;
2190 int ret;
2191
2192 if (bssid == NULL)
2193 return -EINVAL;
2194
2195 if (set && pmkid == NULL)
2196 return -EINVAL;
2197
2198 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2199 if (!skb)
2200 return -ENOMEM;
2201
2202 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2203 memcpy(cmd->bssid, bssid, ETH_ALEN);
2204 if (set) {
2205 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2206 cmd->enable = PMKID_ENABLE;
2207 } else {
2208 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2209 cmd->enable = PMKID_DISABLE;
2210 }
2211
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302212 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002213 NO_SYNC_WMIFLAG);
2214
2215 return ret;
2216}
2217
2218static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302219 enum htc_endpoint_id ep_id, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002220{
2221 struct wmi_data_hdr *data_hdr;
2222 int ret;
2223
2224 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id))
2225 return -EINVAL;
2226
2227 skb_push(skb, sizeof(struct wmi_data_hdr));
2228
2229 data_hdr = (struct wmi_data_hdr *) skb->data;
2230 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302231 data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
Kalle Valobdcd8172011-07-18 00:22:30 +03002232
2233 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2234
2235 return ret;
2236}
2237
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302238static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002239{
2240 struct sk_buff *skb;
2241 struct wmi_sync_cmd *cmd;
2242 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2243 enum htc_endpoint_id ep_id;
2244 u8 index, num_pri_streams = 0;
2245 int ret = 0;
2246
2247 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2248
2249 spin_lock_bh(&wmi->lock);
2250
2251 for (index = 0; index < WMM_NUM_AC; index++) {
2252 if (wmi->fat_pipe_exist & (1 << index)) {
2253 num_pri_streams++;
2254 data_sync_bufs[num_pri_streams - 1].traffic_class =
2255 index;
2256 }
2257 }
2258
2259 spin_unlock_bh(&wmi->lock);
2260
2261 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2262 if (!skb) {
2263 ret = -ENOMEM;
2264 goto free_skb;
2265 }
2266
2267 cmd = (struct wmi_sync_cmd *) skb->data;
2268
2269 /*
2270 * In the SYNC cmd sent on the control Ep, send a bitmap
2271 * of the data eps on which the Data Sync will be sent
2272 */
2273 cmd->data_sync_map = wmi->fat_pipe_exist;
2274
2275 for (index = 0; index < num_pri_streams; index++) {
2276 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2277 if (data_sync_bufs[index].skb == NULL) {
2278 ret = -ENOMEM;
2279 break;
2280 }
2281 }
2282
2283 /*
2284 * If buffer allocation for any of the dataSync fails,
2285 * then do not send the Synchronize cmd on the control ep
2286 */
2287 if (ret)
2288 goto free_skb;
2289
2290 /*
2291 * Send sync cmd followed by sync data messages on all
2292 * endpoints being used
2293 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302294 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002295 NO_SYNC_WMIFLAG);
2296
2297 if (ret)
2298 goto free_skb;
2299
2300 /* cmd buffer sent, we no longer own it */
2301 skb = NULL;
2302
2303 for (index = 0; index < num_pri_streams; index++) {
2304
2305 if (WARN_ON(!data_sync_bufs[index].skb))
2306 break;
2307
2308 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2309 data_sync_bufs[index].
2310 traffic_class);
2311 ret =
2312 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302313 ep_id, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03002314
2315 if (ret)
2316 break;
2317
2318 data_sync_bufs[index].skb = NULL;
2319 }
2320
2321free_skb:
2322 /* free up any resources left over (possibly due to an error) */
2323 if (skb)
2324 dev_kfree_skb(skb);
2325
2326 for (index = 0; index < num_pri_streams; index++) {
2327 if (data_sync_bufs[index].skb != NULL) {
2328 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].
2329 skb);
2330 }
2331 }
2332
2333 return ret;
2334}
2335
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302336int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx,
Kalle Valobdcd8172011-07-18 00:22:30 +03002337 struct wmi_create_pstream_cmd *params)
2338{
2339 struct sk_buff *skb;
2340 struct wmi_create_pstream_cmd *cmd;
2341 u8 fatpipe_exist_for_ac = 0;
2342 s32 min_phy = 0;
2343 s32 nominal_phy = 0;
2344 int ret;
2345
2346 if (!((params->user_pri < 8) &&
2347 (params->user_pri <= 0x7) &&
2348 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2349 (params->traffic_direc == UPLINK_TRAFFIC ||
2350 params->traffic_direc == DNLINK_TRAFFIC ||
2351 params->traffic_direc == BIDIR_TRAFFIC) &&
2352 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2353 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2354 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2355 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2356 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2357 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2358 params->tsid <= WMI_MAX_THINSTREAM))) {
2359 return -EINVAL;
2360 }
2361
2362 /*
2363 * Check nominal PHY rate is >= minimalPHY,
2364 * so that DUT can allow TSRS IE
2365 */
2366
2367 /* Get the physical rate (units of bps) */
2368 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2369
2370 /* Check minimal phy < nominal phy rate */
2371 if (params->nominal_phy >= min_phy) {
2372 /* unit of 500 kbps */
2373 nominal_phy = (params->nominal_phy * 1000) / 500;
2374 ath6kl_dbg(ATH6KL_DBG_WMI,
2375 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2376 min_phy, nominal_phy);
2377
2378 params->nominal_phy = nominal_phy;
2379 } else {
2380 params->nominal_phy = 0;
2381 }
2382
2383 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2384 if (!skb)
2385 return -ENOMEM;
2386
2387 ath6kl_dbg(ATH6KL_DBG_WMI,
2388 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2389 params->traffic_class, params->tsid);
2390
2391 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2392 memcpy(cmd, params, sizeof(*cmd));
2393
2394 /* This is an implicitly created Fat pipe */
2395 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2396 spin_lock_bh(&wmi->lock);
2397 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2398 (1 << params->traffic_class));
2399 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2400 spin_unlock_bh(&wmi->lock);
2401 } else {
2402 /* explicitly created thin stream within a fat pipe */
2403 spin_lock_bh(&wmi->lock);
2404 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2405 (1 << params->traffic_class));
2406 wmi->stream_exist_for_ac[params->traffic_class] |=
2407 (1 << params->tsid);
2408 /*
2409 * If a thinstream becomes active, the fat pipe automatically
2410 * becomes active
2411 */
2412 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2413 spin_unlock_bh(&wmi->lock);
2414 }
2415
2416 /*
2417 * Indicate activty change to driver layer only if this is the
2418 * first TSID to get created in this AC explicitly or an implicit
2419 * fat pipe is getting created.
2420 */
2421 if (!fatpipe_exist_for_ac)
2422 ath6kl_indicate_tx_activity(wmi->parent_dev,
2423 params->traffic_class, true);
2424
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302425 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002426 NO_SYNC_WMIFLAG);
2427 return ret;
2428}
2429
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302430int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
2431 u8 tsid)
Kalle Valobdcd8172011-07-18 00:22:30 +03002432{
2433 struct sk_buff *skb;
2434 struct wmi_delete_pstream_cmd *cmd;
2435 u16 active_tsids = 0;
2436 int ret;
2437
2438 if (traffic_class > 3) {
2439 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2440 return -EINVAL;
2441 }
2442
2443 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2444 if (!skb)
2445 return -ENOMEM;
2446
2447 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2448 cmd->traffic_class = traffic_class;
2449 cmd->tsid = tsid;
2450
2451 spin_lock_bh(&wmi->lock);
2452 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2453 spin_unlock_bh(&wmi->lock);
2454
2455 if (!(active_tsids & (1 << tsid))) {
2456 dev_kfree_skb(skb);
2457 ath6kl_dbg(ATH6KL_DBG_WMI,
2458 "TSID %d doesn't exist for traffic class: %d\n",
2459 tsid, traffic_class);
2460 return -ENODATA;
2461 }
2462
2463 ath6kl_dbg(ATH6KL_DBG_WMI,
2464 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2465 traffic_class, tsid);
2466
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302467 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002468 SYNC_BEFORE_WMIFLAG);
2469
2470 spin_lock_bh(&wmi->lock);
2471 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2472 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2473 spin_unlock_bh(&wmi->lock);
2474
2475 /*
2476 * Indicate stream inactivity to driver layer only if all tsids
2477 * within this AC are deleted.
2478 */
2479 if (!active_tsids) {
2480 ath6kl_indicate_tx_activity(wmi->parent_dev,
2481 traffic_class, false);
2482 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2483 }
2484
2485 return ret;
2486}
2487
Raja Manica1d16a2011-12-16 14:24:23 +05302488int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
2489 __be32 ips0, __be32 ips1)
Kalle Valobdcd8172011-07-18 00:22:30 +03002490{
2491 struct sk_buff *skb;
2492 struct wmi_set_ip_cmd *cmd;
2493 int ret;
2494
2495 /* Multicast address are not valid */
Raja Manica1d16a2011-12-16 14:24:23 +05302496 if (ipv4_is_multicast(ips0) ||
2497 ipv4_is_multicast(ips1))
Kalle Valobdcd8172011-07-18 00:22:30 +03002498 return -EINVAL;
2499
2500 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2501 if (!skb)
2502 return -ENOMEM;
2503
2504 cmd = (struct wmi_set_ip_cmd *) skb->data;
Raja Manica1d16a2011-12-16 14:24:23 +05302505 cmd->ips[0] = ips0;
2506 cmd->ips[1] = ips1;
Kalle Valobdcd8172011-07-18 00:22:30 +03002507
Raja Manica1d16a2011-12-16 14:24:23 +05302508 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID,
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302509 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002510 return ret;
2511}
2512
Raja Mani45cf1102011-11-07 22:52:45 +02002513static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
2514{
2515 u16 active_tsids;
2516 u8 stream_exist;
2517 int i;
2518
2519 /*
2520 * Relinquish credits from all implicitly created pstreams
2521 * since when we go to sleep. If user created explicit
2522 * thinstreams exists with in a fatpipe leave them intact
2523 * for the user to delete.
2524 */
2525 spin_lock_bh(&wmi->lock);
2526 stream_exist = wmi->fat_pipe_exist;
2527 spin_unlock_bh(&wmi->lock);
2528
2529 for (i = 0; i < WMM_NUM_AC; i++) {
2530 if (stream_exist & (1 << i)) {
2531
2532 /*
2533 * FIXME: Is this lock & unlock inside
2534 * for loop correct? may need rework.
2535 */
2536 spin_lock_bh(&wmi->lock);
2537 active_tsids = wmi->stream_exist_for_ac[i];
2538 spin_unlock_bh(&wmi->lock);
2539
2540 /*
2541 * If there are no user created thin streams
2542 * delete the fatpipe
2543 */
2544 if (!active_tsids) {
2545 stream_exist &= ~(1 << i);
2546 /*
2547 * Indicate inactivity to driver layer for
2548 * this fatpipe (pstream)
2549 */
2550 ath6kl_indicate_tx_activity(wmi->parent_dev,
2551 i, false);
2552 }
2553 }
2554 }
2555
2556 /* FIXME: Can we do this assignment without locking ? */
2557 spin_lock_bh(&wmi->lock);
2558 wmi->fat_pipe_exist = stream_exist;
2559 spin_unlock_bh(&wmi->lock);
2560}
2561
2562int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
2563 enum ath6kl_host_mode host_mode)
2564{
2565 struct sk_buff *skb;
2566 struct wmi_set_host_sleep_mode_cmd *cmd;
2567 int ret;
2568
2569 if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) &&
2570 (host_mode != ATH6KL_HOST_MODE_AWAKE)) {
2571 ath6kl_err("invalid host sleep mode: %d\n", host_mode);
2572 return -EINVAL;
2573 }
2574
2575 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2576 if (!skb)
2577 return -ENOMEM;
2578
2579 cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data;
2580
2581 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
2582 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
2583 cmd->asleep = cpu_to_le32(1);
2584 } else
2585 cmd->awake = cpu_to_le32(1);
2586
2587 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2588 WMI_SET_HOST_SLEEP_MODE_CMDID,
2589 NO_SYNC_WMIFLAG);
2590 return ret;
2591}
2592
Raja Mani081c7a82012-01-30 17:13:11 +05302593/* This command has zero length payload */
2594static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi,
2595 struct ath6kl_vif *vif)
2596{
2597 struct ath6kl *ar = wmi->parent_dev;
2598
2599 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags);
2600 wake_up(&ar->event_wq);
2601
2602 return 0;
2603}
2604
Raja Mani45cf1102011-11-07 22:52:45 +02002605int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx,
2606 enum ath6kl_wow_mode wow_mode,
2607 u32 filter, u16 host_req_delay)
2608{
2609 struct sk_buff *skb;
2610 struct wmi_set_wow_mode_cmd *cmd;
2611 int ret;
2612
2613 if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) &&
2614 wow_mode != ATH6KL_WOW_MODE_DISABLE) {
2615 ath6kl_err("invalid wow mode: %d\n", wow_mode);
2616 return -EINVAL;
2617 }
2618
2619 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2620 if (!skb)
2621 return -ENOMEM;
2622
2623 cmd = (struct wmi_set_wow_mode_cmd *) skb->data;
2624 cmd->enable_wow = cpu_to_le32(wow_mode);
2625 cmd->filter = cpu_to_le32(filter);
2626 cmd->host_req_delay = cpu_to_le16(host_req_delay);
2627
2628 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID,
2629 NO_SYNC_WMIFLAG);
2630 return ret;
2631}
2632
Raja Mani5c9b4fa2011-11-07 22:52:45 +02002633int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2634 u8 list_id, u8 filter_size,
Raja Manid91e8ee2012-01-30 17:13:10 +05302635 u8 filter_offset, const u8 *filter,
2636 const u8 *mask)
Raja Mani5c9b4fa2011-11-07 22:52:45 +02002637{
2638 struct sk_buff *skb;
2639 struct wmi_add_wow_pattern_cmd *cmd;
2640 u16 size;
2641 u8 *filter_mask;
2642 int ret;
2643
2644 /*
2645 * Allocate additional memory in the buffer to hold
2646 * filter and mask value, which is twice of filter_size.
2647 */
2648 size = sizeof(*cmd) + (2 * filter_size);
2649
2650 skb = ath6kl_wmi_get_new_buf(size);
2651 if (!skb)
2652 return -ENOMEM;
2653
2654 cmd = (struct wmi_add_wow_pattern_cmd *) skb->data;
2655 cmd->filter_list_id = list_id;
2656 cmd->filter_size = filter_size;
2657 cmd->filter_offset = filter_offset;
2658
2659 memcpy(cmd->filter, filter, filter_size);
2660
2661 filter_mask = (u8 *) (cmd->filter + filter_size);
2662 memcpy(filter_mask, mask, filter_size);
2663
2664 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID,
2665 NO_SYNC_WMIFLAG);
2666
2667 return ret;
2668}
2669
2670int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2671 u16 list_id, u16 filter_id)
2672{
2673 struct sk_buff *skb;
2674 struct wmi_del_wow_pattern_cmd *cmd;
2675 int ret;
2676
2677 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2678 if (!skb)
2679 return -ENOMEM;
2680
2681 cmd = (struct wmi_del_wow_pattern_cmd *) skb->data;
2682 cmd->filter_list_id = cpu_to_le16(list_id);
2683 cmd->filter_id = cpu_to_le16(filter_id);
2684
2685 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID,
2686 NO_SYNC_WMIFLAG);
2687 return ret;
2688}
2689
Kalle Valobdcd8172011-07-18 00:22:30 +03002690static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
2691 enum wmix_command_id cmd_id,
2692 enum wmi_sync_flag sync_flag)
2693{
2694 struct wmix_cmd_hdr *cmd_hdr;
2695 int ret;
2696
2697 skb_push(skb, sizeof(struct wmix_cmd_hdr));
2698
2699 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
2700 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
2701
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302702 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag);
Kalle Valobdcd8172011-07-18 00:22:30 +03002703
2704 return ret;
2705}
2706
2707int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
2708{
2709 struct sk_buff *skb;
2710 struct wmix_hb_challenge_resp_cmd *cmd;
2711 int ret;
2712
2713 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2714 if (!skb)
2715 return -ENOMEM;
2716
2717 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
2718 cmd->cookie = cpu_to_le32(cookie);
2719 cmd->source = cpu_to_le32(source);
2720
2721 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
2722 NO_SYNC_WMIFLAG);
2723 return ret;
2724}
2725
Kalle Valo939f1cc2011-09-02 10:32:04 +03002726int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
2727{
2728 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
2729 struct sk_buff *skb;
2730 int ret;
2731
2732 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2733 if (!skb)
2734 return -ENOMEM;
2735
2736 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
2737 cmd->valid = cpu_to_le32(valid);
2738 cmd->config = cpu_to_le32(config);
2739
2740 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
2741 NO_SYNC_WMIFLAG);
2742 return ret;
2743}
2744
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302745int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002746{
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302747 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03002748}
2749
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302750int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM)
Kalle Valobdcd8172011-07-18 00:22:30 +03002751{
2752 struct sk_buff *skb;
2753 struct wmi_set_tx_pwr_cmd *cmd;
2754 int ret;
2755
2756 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
2757 if (!skb)
2758 return -ENOMEM;
2759
2760 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
2761 cmd->dbM = dbM;
2762
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302763 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002764 NO_SYNC_WMIFLAG);
2765
2766 return ret;
2767}
2768
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302769int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002770{
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302771 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03002772}
2773
Jouni Malinen4b28a802011-10-11 17:31:54 +03002774int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi)
2775{
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302776 return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID);
Jouni Malinen4b28a802011-10-11 17:31:54 +03002777}
2778
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302779int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status,
2780 u8 preamble_policy)
Kalle Valobdcd8172011-07-18 00:22:30 +03002781{
2782 struct sk_buff *skb;
2783 struct wmi_set_lpreamble_cmd *cmd;
2784 int ret;
2785
2786 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
2787 if (!skb)
2788 return -ENOMEM;
2789
2790 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
2791 cmd->status = status;
2792 cmd->preamble_policy = preamble_policy;
2793
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302794 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002795 NO_SYNC_WMIFLAG);
2796 return ret;
2797}
2798
2799int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
2800{
2801 struct sk_buff *skb;
2802 struct wmi_set_rts_cmd *cmd;
2803 int ret;
2804
2805 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
2806 if (!skb)
2807 return -ENOMEM;
2808
2809 cmd = (struct wmi_set_rts_cmd *) skb->data;
2810 cmd->threshold = cpu_to_le16(threshold);
2811
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302812 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID,
2813 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002814 return ret;
2815}
2816
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302817int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg)
Kalle Valobdcd8172011-07-18 00:22:30 +03002818{
2819 struct sk_buff *skb;
2820 struct wmi_set_wmm_txop_cmd *cmd;
2821 int ret;
2822
2823 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
2824 return -EINVAL;
2825
2826 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
2827 if (!skb)
2828 return -ENOMEM;
2829
2830 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
2831 cmd->txop_enable = cfg;
2832
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302833 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002834 NO_SYNC_WMIFLAG);
2835 return ret;
2836}
2837
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302838int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx,
2839 u8 keep_alive_intvl)
Kalle Valobdcd8172011-07-18 00:22:30 +03002840{
2841 struct sk_buff *skb;
2842 struct wmi_set_keepalive_cmd *cmd;
2843 int ret;
2844
2845 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2846 if (!skb)
2847 return -ENOMEM;
2848
2849 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
2850 cmd->keep_alive_intvl = keep_alive_intvl;
Kalle Valobdcd8172011-07-18 00:22:30 +03002851
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302852 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002853 NO_SYNC_WMIFLAG);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302854
Jouni Malinenff0b0072011-10-11 17:31:56 +03002855 if (ret == 0)
2856 ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302857
Kalle Valobdcd8172011-07-18 00:22:30 +03002858 return ret;
2859}
2860
Kalle Valo003353b0d2011-09-01 10:14:21 +03002861int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
2862{
2863 struct sk_buff *skb;
2864 int ret;
2865
2866 skb = ath6kl_wmi_get_new_buf(len);
2867 if (!skb)
2868 return -ENOMEM;
2869
2870 memcpy(skb->data, buf, len);
2871
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302872 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
Kalle Valo003353b0d2011-09-01 10:14:21 +03002873
2874 return ret;
2875}
2876
Vasanthakumar Thiagarajan3f3c4ee2012-01-03 14:41:59 +05302877int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on)
2878{
2879 struct sk_buff *skb;
2880 struct wmi_mcast_filter_cmd *cmd;
2881 int ret;
2882
2883 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2884 if (!skb)
2885 return -ENOMEM;
2886
2887 cmd = (struct wmi_mcast_filter_cmd *) skb->data;
2888 cmd->mcast_all_enable = mc_all_on;
2889
2890 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID,
2891 NO_SYNC_WMIFLAG);
2892 return ret;
2893}
Kalle Valo003353b0d2011-09-01 10:14:21 +03002894
Vasanthakumar Thiagarajanf914edd2012-01-03 14:42:00 +05302895int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx,
2896 u8 *filter, bool add_filter)
2897{
2898 struct sk_buff *skb;
2899 struct wmi_mcast_filter_add_del_cmd *cmd;
2900 int ret;
2901
2902 if ((filter[0] != 0x33 || filter[1] != 0x33) &&
2903 (filter[0] != 0x01 || filter[1] != 0x00 ||
2904 filter[2] != 0x5e || filter[3] > 0x7f)) {
2905 ath6kl_warn("invalid multicast filter address\n");
2906 return -EINVAL;
2907 }
2908
2909 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2910 if (!skb)
2911 return -ENOMEM;
2912
2913 cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data;
2914 memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE);
2915 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2916 add_filter ? WMI_SET_MCAST_FILTER_CMDID :
2917 WMI_DEL_MCAST_FILTER_CMDID,
2918 NO_SYNC_WMIFLAG);
2919
2920 return ret;
2921}
2922
Kalle Valobdcd8172011-07-18 00:22:30 +03002923s32 ath6kl_wmi_get_rate(s8 rate_index)
2924{
2925 if (rate_index == RATE_AUTO)
2926 return 0;
2927
2928 return wmi_rate_tbl[(u32) rate_index][0];
2929}
2930
Kalle Valobdcd8172011-07-18 00:22:30 +03002931static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
2932 u32 len)
2933{
2934 struct wmi_pmkid_list_reply *reply;
2935 u32 expected_len;
2936
2937 if (len < sizeof(struct wmi_pmkid_list_reply))
2938 return -EINVAL;
2939
2940 reply = (struct wmi_pmkid_list_reply *)datap;
2941 expected_len = sizeof(reply->num_pmkid) +
2942 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
2943
2944 if (len < expected_len)
2945 return -EINVAL;
2946
2947 return 0;
2948}
2949
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302950static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
2951 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03002952{
2953 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
2954
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302955 aggr_recv_addba_req_evt(vif, cmd->tid,
Kalle Valobdcd8172011-07-18 00:22:30 +03002956 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
2957
2958 return 0;
2959}
2960
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302961static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
2962 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03002963{
2964 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
2965
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302966 aggr_recv_delba_req_evt(vif, cmd->tid);
Kalle Valobdcd8172011-07-18 00:22:30 +03002967
2968 return 0;
2969}
2970
2971/* AP mode functions */
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002972
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302973int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx,
2974 struct wmi_connect_cmd *p)
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002975{
2976 struct sk_buff *skb;
2977 struct wmi_connect_cmd *cm;
2978 int res;
2979
2980 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2981 if (!skb)
2982 return -ENOMEM;
2983
2984 cm = (struct wmi_connect_cmd *) skb->data;
2985 memcpy(cm, p, sizeof(*cm));
2986
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302987 res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002988 NO_SYNC_WMIFLAG);
2989 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
2990 "ctrl_flags=0x%x-> res=%d\n",
2991 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
2992 le32_to_cpu(p->ctrl_flags), res);
2993 return res;
2994}
2995
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302996int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac,
2997 u16 reason)
Jouni Malinen23875132011-08-30 21:57:53 +03002998{
2999 struct sk_buff *skb;
3000 struct wmi_ap_set_mlme_cmd *cm;
3001
3002 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3003 if (!skb)
3004 return -ENOMEM;
3005
3006 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
3007 memcpy(cm->mac, mac, ETH_ALEN);
3008 cm->reason = cpu_to_le16(reason);
3009 cm->cmd = cmd;
3010
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303011 return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID,
Jouni Malinen23875132011-08-30 21:57:53 +03003012 NO_SYNC_WMIFLAG);
3013}
3014
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +05303015/* This command will be used to enable/disable AP uAPSD feature */
3016int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable)
3017{
3018 struct wmi_ap_set_apsd_cmd *cmd;
3019 struct sk_buff *skb;
3020
3021 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3022 if (!skb)
3023 return -ENOMEM;
3024
3025 cmd = (struct wmi_ap_set_apsd_cmd *)skb->data;
3026 cmd->enable = enable;
3027
3028 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID,
3029 NO_SYNC_WMIFLAG);
3030}
3031
3032int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx,
3033 u16 aid, u16 bitmap, u32 flags)
3034{
3035 struct wmi_ap_apsd_buffered_traffic_cmd *cmd;
3036 struct sk_buff *skb;
3037
3038 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3039 if (!skb)
3040 return -ENOMEM;
3041
3042 cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data;
3043 cmd->aid = cpu_to_le16(aid);
3044 cmd->bitmap = cpu_to_le16(bitmap);
3045 cmd->flags = cpu_to_le32(flags);
3046
3047 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3048 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
3049 NO_SYNC_WMIFLAG);
3050}
3051
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303052static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len,
3053 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03003054{
3055 struct wmi_pspoll_event *ev;
3056
3057 if (len < sizeof(struct wmi_pspoll_event))
3058 return -EINVAL;
3059
3060 ev = (struct wmi_pspoll_event *) datap;
3061
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303062 ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid));
Kalle Valobdcd8172011-07-18 00:22:30 +03003063
3064 return 0;
3065}
3066
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303067static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len,
3068 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03003069{
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303070 ath6kl_dtimexpiry_event(vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003071
3072 return 0;
3073}
3074
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303075int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
3076 bool flag)
Kalle Valobdcd8172011-07-18 00:22:30 +03003077{
3078 struct sk_buff *skb;
3079 struct wmi_ap_set_pvb_cmd *cmd;
3080 int ret;
3081
3082 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
3083 if (!skb)
3084 return -ENOMEM;
3085
3086 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
3087 cmd->aid = cpu_to_le16(aid);
Jouni Malinend6e51e62011-09-05 17:38:44 +03003088 cmd->rsvd = cpu_to_le16(0);
Kalle Valobdcd8172011-07-18 00:22:30 +03003089 cmd->flag = cpu_to_le32(flag);
3090
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303091 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03003092 NO_SYNC_WMIFLAG);
3093
3094 return 0;
3095}
3096
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303097int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
3098 u8 rx_meta_ver,
Kalle Valobdcd8172011-07-18 00:22:30 +03003099 bool rx_dot11_hdr, bool defrag_on_host)
3100{
3101 struct sk_buff *skb;
3102 struct wmi_rx_frame_format_cmd *cmd;
3103 int ret;
3104
3105 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3106 if (!skb)
3107 return -ENOMEM;
3108
3109 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
3110 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
3111 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
3112 cmd->meta_ver = rx_meta_ver;
3113
3114 /* Delete the local aggr state, on host */
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303115 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03003116 NO_SYNC_WMIFLAG);
3117
3118 return ret;
3119}
3120
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303121int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,
3122 const u8 *ie, u8 ie_len)
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03003123{
3124 struct sk_buff *skb;
3125 struct wmi_set_appie_cmd *p;
3126
3127 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3128 if (!skb)
3129 return -ENOMEM;
3130
3131 ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
3132 "ie_len=%u\n", mgmt_frm_type, ie_len);
3133 p = (struct wmi_set_appie_cmd *) skb->data;
3134 p->mgmt_frm_type = mgmt_frm_type;
3135 p->ie_len = ie_len;
Kalle Valo10509f92011-12-13 14:52:07 +02003136
3137 if (ie != NULL && ie_len > 0)
3138 memcpy(p->ie_info, ie, ie_len);
3139
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303140 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID,
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03003141 NO_SYNC_WMIFLAG);
3142}
3143
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003144int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
3145{
3146 struct sk_buff *skb;
3147 struct wmi_disable_11b_rates_cmd *cmd;
3148
3149 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3150 if (!skb)
3151 return -ENOMEM;
3152
3153 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
3154 disable);
3155 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
3156 cmd->disable = disable ? 1 : 0;
3157
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303158 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003159 NO_SYNC_WMIFLAG);
3160}
3161
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303162int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003163{
3164 struct sk_buff *skb;
3165 struct wmi_remain_on_chnl_cmd *p;
3166
3167 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3168 if (!skb)
3169 return -ENOMEM;
3170
3171 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3172 freq, dur);
3173 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
3174 p->freq = cpu_to_le32(freq);
3175 p->duration = cpu_to_le32(dur);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303176 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003177 NO_SYNC_WMIFLAG);
3178}
3179
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08003180/* ath6kl_wmi_send_action_cmd is to be deprecated. Use
3181 * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
3182 * mgmt operations using station interface.
3183 */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303184int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3185 u32 wait, const u8 *data, u16 data_len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003186{
3187 struct sk_buff *skb;
3188 struct wmi_send_action_cmd *p;
Jouni Malinena0df5db2011-08-30 21:58:02 +03003189 u8 *buf;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003190
3191 if (wait)
3192 return -EINVAL; /* Offload for wait not supported */
3193
Jouni Malinena0df5db2011-08-30 21:58:02 +03003194 buf = kmalloc(data_len, GFP_KERNEL);
3195 if (!buf)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003196 return -ENOMEM;
3197
Jouni Malinena0df5db2011-08-30 21:58:02 +03003198 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3199 if (!skb) {
3200 kfree(buf);
3201 return -ENOMEM;
3202 }
3203
3204 kfree(wmi->last_mgmt_tx_frame);
Aarthi Thiruvengadam3101ede2011-10-27 09:35:56 -07003205 memcpy(buf, data, data_len);
Jouni Malinena0df5db2011-08-30 21:58:02 +03003206 wmi->last_mgmt_tx_frame = buf;
3207 wmi->last_mgmt_tx_frame_len = data_len;
3208
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003209 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3210 "len=%u\n", id, freq, wait, data_len);
3211 p = (struct wmi_send_action_cmd *) skb->data;
3212 p->id = cpu_to_le32(id);
3213 p->freq = cpu_to_le32(freq);
3214 p->wait = cpu_to_le32(wait);
3215 p->len = cpu_to_le16(data_len);
3216 memcpy(p->data, data, data_len);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303217 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003218 NO_SYNC_WMIFLAG);
3219}
3220
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08003221int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3222 u32 wait, const u8 *data, u16 data_len,
3223 u32 no_cck)
3224{
3225 struct sk_buff *skb;
3226 struct wmi_send_mgmt_cmd *p;
3227 u8 *buf;
3228
3229 if (wait)
3230 return -EINVAL; /* Offload for wait not supported */
3231
3232 buf = kmalloc(data_len, GFP_KERNEL);
3233 if (!buf)
3234 return -ENOMEM;
3235
3236 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3237 if (!skb) {
3238 kfree(buf);
3239 return -ENOMEM;
3240 }
3241
3242 kfree(wmi->last_mgmt_tx_frame);
3243 memcpy(buf, data, data_len);
3244 wmi->last_mgmt_tx_frame = buf;
3245 wmi->last_mgmt_tx_frame_len = data_len;
3246
3247 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3248 "len=%u\n", id, freq, wait, data_len);
3249 p = (struct wmi_send_mgmt_cmd *) skb->data;
3250 p->id = cpu_to_le32(id);
3251 p->freq = cpu_to_le32(freq);
3252 p->wait = cpu_to_le32(wait);
3253 p->no_cck = cpu_to_le32(no_cck);
3254 p->len = cpu_to_le16(data_len);
3255 memcpy(p->data, data, data_len);
3256 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID,
3257 NO_SYNC_WMIFLAG);
3258}
3259
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303260int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq,
3261 const u8 *dst, const u8 *data,
3262 u16 data_len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003263{
3264 struct sk_buff *skb;
3265 struct wmi_p2p_probe_response_cmd *p;
Aarthi Thiruvengadambd24a502011-11-09 10:05:56 -08003266 size_t cmd_len = sizeof(*p) + data_len;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003267
Aarthi Thiruvengadambd24a502011-11-09 10:05:56 -08003268 if (data_len == 0)
3269 cmd_len++; /* work around target minimum length requirement */
3270
3271 skb = ath6kl_wmi_get_new_buf(cmd_len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003272 if (!skb)
3273 return -ENOMEM;
3274
3275 ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
3276 "len=%u\n", freq, dst, data_len);
3277 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
3278 p->freq = cpu_to_le32(freq);
3279 memcpy(p->destination_addr, dst, ETH_ALEN);
3280 p->len = cpu_to_le16(data_len);
3281 memcpy(p->data, data, data_len);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303282 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3283 WMI_SEND_PROBE_RESPONSE_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003284 NO_SYNC_WMIFLAG);
3285}
3286
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303287int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003288{
3289 struct sk_buff *skb;
3290 struct wmi_probe_req_report_cmd *p;
3291
3292 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3293 if (!skb)
3294 return -ENOMEM;
3295
3296 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
3297 enable);
3298 p = (struct wmi_probe_req_report_cmd *) skb->data;
3299 p->enable = enable ? 1 : 0;
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303300 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003301 NO_SYNC_WMIFLAG);
3302}
3303
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303304int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003305{
3306 struct sk_buff *skb;
3307 struct wmi_get_p2p_info *p;
3308
3309 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3310 if (!skb)
3311 return -ENOMEM;
3312
3313 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
3314 info_req_flags);
3315 p = (struct wmi_get_p2p_info *) skb->data;
3316 p->info_req_flags = cpu_to_le32(info_req_flags);
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303317 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003318 NO_SYNC_WMIFLAG);
3319}
3320
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303321int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003322{
3323 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303324 return ath6kl_wmi_simple_cmd(wmi, if_idx,
3325 WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003326}
3327
Kalle Valobdcd8172011-07-18 00:22:30 +03003328static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
3329{
3330 struct wmix_cmd_hdr *cmd;
3331 u32 len;
3332 u16 id;
3333 u8 *datap;
3334 int ret = 0;
3335
3336 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
3337 ath6kl_err("bad packet 1\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003338 return -EINVAL;
3339 }
3340
3341 cmd = (struct wmix_cmd_hdr *) skb->data;
3342 id = le32_to_cpu(cmd->cmd_id);
3343
3344 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
3345
3346 datap = skb->data;
3347 len = skb->len;
3348
3349 switch (id) {
3350 case WMIX_HB_CHALLENGE_RESP_EVENTID:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003351 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003352 break;
3353 case WMIX_DBGLOG_EVENTID:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003354 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len);
Kalle Valobdf53962011-09-02 10:32:04 +03003355 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003356 break;
3357 default:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003358 ath6kl_warn("unknown cmd id 0x%x\n", id);
Kalle Valobdcd8172011-07-18 00:22:30 +03003359 ret = -EINVAL;
3360 break;
3361 }
3362
3363 return ret;
3364}
3365
Jouni Malinen4b28a802011-10-11 17:31:54 +03003366static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len)
3367{
3368 return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len);
3369}
3370
Kalle Valobdcd8172011-07-18 00:22:30 +03003371/* Control Path */
3372int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
3373{
3374 struct wmi_cmd_hdr *cmd;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303375 struct ath6kl_vif *vif;
Kalle Valobdcd8172011-07-18 00:22:30 +03003376 u32 len;
3377 u16 id;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303378 u8 if_idx;
Kalle Valobdcd8172011-07-18 00:22:30 +03003379 u8 *datap;
3380 int ret = 0;
3381
3382 if (WARN_ON(skb == NULL))
3383 return -EINVAL;
3384
3385 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
3386 ath6kl_err("bad packet 1\n");
3387 dev_kfree_skb(skb);
Kalle Valobdcd8172011-07-18 00:22:30 +03003388 return -EINVAL;
3389 }
3390
3391 cmd = (struct wmi_cmd_hdr *) skb->data;
3392 id = le16_to_cpu(cmd->cmd_id);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303393 if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK;
Kalle Valobdcd8172011-07-18 00:22:30 +03003394
3395 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
3396
3397 datap = skb->data;
3398 len = skb->len;
3399
Kalle Valob9b6ee62011-09-27 14:31:21 +03003400 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len);
3401 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ",
Kalle Valoef094102011-09-27 14:30:45 +03003402 datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003403
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303404 vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx);
3405 if (!vif) {
3406 ath6kl_dbg(ATH6KL_DBG_WMI,
3407 "Wmi event for unavailable vif, vif_index:%d\n",
3408 if_idx);
3409 dev_kfree_skb(skb);
3410 return -EINVAL;
3411 }
3412
Kalle Valobdcd8172011-07-18 00:22:30 +03003413 switch (id) {
3414 case WMI_GET_BITRATE_CMDID:
3415 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
3416 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
3417 break;
3418 case WMI_GET_CHANNEL_LIST_CMDID:
3419 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
3420 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
3421 break;
3422 case WMI_GET_TX_PWR_CMDID:
3423 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
3424 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
3425 break;
3426 case WMI_READY_EVENTID:
3427 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
3428 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
3429 break;
3430 case WMI_CONNECT_EVENTID:
3431 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303432 ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003433 break;
3434 case WMI_DISCONNECT_EVENTID:
3435 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303436 ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003437 break;
3438 case WMI_PEER_NODE_EVENTID:
3439 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
3440 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
3441 break;
3442 case WMI_TKIP_MICERR_EVENTID:
3443 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303444 ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003445 break;
3446 case WMI_BSSINFO_EVENTID:
3447 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303448 ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003449 break;
3450 case WMI_REGDOMAIN_EVENTID:
3451 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
Vivek Natarajan06033762011-09-06 13:01:36 +05303452 ath6kl_wmi_regdomain_event(wmi, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003453 break;
3454 case WMI_PSTREAM_TIMEOUT_EVENTID:
3455 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
3456 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
3457 break;
3458 case WMI_NEIGHBOR_REPORT_EVENTID:
3459 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303460 ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len,
3461 vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003462 break;
3463 case WMI_SCAN_COMPLETE_EVENTID:
3464 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303465 ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003466 break;
3467 case WMI_CMDERROR_EVENTID:
3468 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
3469 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
3470 break;
3471 case WMI_REPORT_STATISTICS_EVENTID:
3472 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303473 ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003474 break;
3475 case WMI_RSSI_THRESHOLD_EVENTID:
3476 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
3477 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
3478 break;
3479 case WMI_ERROR_REPORT_EVENTID:
3480 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
3481 break;
3482 case WMI_OPT_RX_FRAME_EVENTID:
3483 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
Jouni Malinenf195d502011-09-19 19:15:00 +03003484 /* this event has been deprecated */
Kalle Valobdcd8172011-07-18 00:22:30 +03003485 break;
3486 case WMI_REPORT_ROAM_TBL_EVENTID:
3487 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
Jouni Malinen4b28a802011-10-11 17:31:54 +03003488 ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003489 break;
3490 case WMI_EXTENSION_EVENTID:
3491 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
3492 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
3493 break;
3494 case WMI_CAC_EVENTID:
3495 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303496 ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003497 break;
3498 case WMI_CHANNEL_CHANGE_EVENTID:
3499 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
3500 break;
3501 case WMI_REPORT_ROAM_DATA_EVENTID:
3502 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
3503 break;
Kalle Valo003353b0d2011-09-01 10:14:21 +03003504 case WMI_TEST_EVENTID:
3505 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08003506 ret = ath6kl_wmi_test_rx(wmi, datap, len);
Kalle Valo003353b0d2011-09-01 10:14:21 +03003507 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003508 case WMI_GET_FIXRATES_CMDID:
3509 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
3510 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
3511 break;
3512 case WMI_TX_RETRY_ERR_EVENTID:
3513 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
3514 break;
3515 case WMI_SNR_THRESHOLD_EVENTID:
3516 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
3517 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
3518 break;
3519 case WMI_LQ_THRESHOLD_EVENTID:
3520 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
3521 break;
3522 case WMI_APLIST_EVENTID:
3523 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
3524 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
3525 break;
3526 case WMI_GET_KEEPALIVE_CMDID:
3527 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
3528 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
3529 break;
3530 case WMI_GET_WOW_LIST_EVENTID:
3531 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003532 break;
3533 case WMI_GET_PMKID_LIST_EVENTID:
3534 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
3535 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
3536 break;
3537 case WMI_PSPOLL_EVENTID:
3538 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303539 ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003540 break;
3541 case WMI_DTIMEXPIRY_EVENTID:
3542 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303543 ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003544 break;
3545 case WMI_SET_PARAMS_REPLY_EVENTID:
3546 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3547 break;
3548 case WMI_ADDBA_REQ_EVENTID:
3549 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303550 ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003551 break;
3552 case WMI_ADDBA_RESP_EVENTID:
3553 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
3554 break;
3555 case WMI_DELBA_REQ_EVENTID:
3556 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303557 ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003558 break;
3559 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
3560 ath6kl_dbg(ATH6KL_DBG_WMI,
3561 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3562 break;
3563 case WMI_REPORT_BTCOEX_STATS_EVENTID:
3564 ath6kl_dbg(ATH6KL_DBG_WMI,
3565 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3566 break;
3567 case WMI_TX_COMPLETE_EVENTID:
3568 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
3569 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
3570 break;
Raja Mani081c7a82012-01-30 17:13:11 +05303571 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID:
3572 ath6kl_dbg(ATH6KL_DBG_WMI,
3573 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3574 ret = ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif);
3575 break;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003576 case WMI_REMAIN_ON_CHNL_EVENTID:
3577 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303578 ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003579 break;
3580 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3581 ath6kl_dbg(ATH6KL_DBG_WMI,
3582 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
Jouni Malinenf9e5f052011-08-30 21:57:58 +03003583 ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303584 len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003585 break;
3586 case WMI_TX_STATUS_EVENTID:
3587 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303588 ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003589 break;
3590 case WMI_RX_PROBE_REQ_EVENTID:
3591 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303592 ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003593 break;
3594 case WMI_P2P_CAPABILITIES_EVENTID:
3595 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
3596 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
3597 break;
3598 case WMI_RX_ACTION_EVENTID:
3599 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303600 ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003601 break;
3602 case WMI_P2P_INFO_EVENTID:
3603 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
3604 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
3605 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003606 default:
3607 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id);
Kalle Valobdcd8172011-07-18 00:22:30 +03003608 ret = -EINVAL;
3609 break;
3610 }
3611
3612 dev_kfree_skb(skb);
3613
3614 return ret;
3615}
3616
Kalle Valoc89c5912011-10-27 18:48:00 +03003617void ath6kl_wmi_reset(struct wmi *wmi)
Kalle Valobdcd8172011-07-18 00:22:30 +03003618{
Kalle Valobdcd8172011-07-18 00:22:30 +03003619 spin_lock_bh(&wmi->lock);
3620
3621 wmi->fat_pipe_exist = 0;
3622 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
3623
3624 spin_unlock_bh(&wmi->lock);
3625}
3626
Vasanthakumar Thiagarajan28657852011-07-21 12:00:49 +05303627void *ath6kl_wmi_init(struct ath6kl *dev)
Kalle Valobdcd8172011-07-18 00:22:30 +03003628{
3629 struct wmi *wmi;
3630
3631 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
3632 if (!wmi)
3633 return NULL;
3634
3635 spin_lock_init(&wmi->lock);
3636
3637 wmi->parent_dev = dev;
3638
Kalle Valobdcd8172011-07-18 00:22:30 +03003639 wmi->pwr_mode = REC_POWER;
Kalle Valobdcd8172011-07-18 00:22:30 +03003640
Kalle Valoc89c5912011-10-27 18:48:00 +03003641 ath6kl_wmi_reset(wmi);
Kalle Valobdcd8172011-07-18 00:22:30 +03003642
3643 return wmi;
3644}
3645
3646void ath6kl_wmi_shutdown(struct wmi *wmi)
3647{
3648 if (!wmi)
3649 return;
3650
Jouni Malinena0df5db2011-08-30 21:58:02 +03003651 kfree(wmi->last_mgmt_tx_frame);
Kalle Valobdcd8172011-07-18 00:22:30 +03003652 kfree(wmi);
3653}