blob: 97abf4699b41270883b80357185652253237c59c [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)
Johannes Berg804483e2012-03-05 22:18:41 +0100559 cfg80211_rx_mgmt(vif->ndev, freq, 0,
560 ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300561
562 return 0;
563}
564
565static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
566{
567 struct wmi_p2p_capabilities_event *ev;
568 u16 dlen;
569
570 if (len < sizeof(*ev))
571 return -EINVAL;
572
573 ev = (struct wmi_p2p_capabilities_event *) datap;
574 dlen = le16_to_cpu(ev->len);
575 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
576
577 return 0;
578}
579
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530580static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
581 struct ath6kl_vif *vif)
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300582{
583 struct wmi_rx_action_event *ev;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300584 u32 freq;
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300585 u16 dlen;
586
587 if (len < sizeof(*ev))
588 return -EINVAL;
589
590 ev = (struct wmi_rx_action_event *) datap;
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300591 freq = le32_to_cpu(ev->freq);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300592 dlen = le16_to_cpu(ev->len);
Jouni Malinen9809d8e2011-08-30 21:58:03 +0300593 if (datap + len < ev->data + dlen) {
594 ath6kl_err("invalid wmi_rx_action_event: "
595 "len=%d dlen=%u\n", len, dlen);
596 return -EINVAL;
597 }
598 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
Johannes Berg804483e2012-03-05 22:18:41 +0100599 cfg80211_rx_mgmt(vif->ndev, freq, 0,
600 ev->data, dlen, GFP_ATOMIC);
Jouni Malinen6465ddc2011-08-30 21:57:54 +0300601
602 return 0;
603}
604
605static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
606{
607 struct wmi_p2p_info_event *ev;
608 u32 flags;
609 u16 dlen;
610
611 if (len < sizeof(*ev))
612 return -EINVAL;
613
614 ev = (struct wmi_p2p_info_event *) datap;
615 flags = le32_to_cpu(ev->info_req_flags);
616 dlen = le16_to_cpu(ev->len);
617 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
618
619 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
620 struct wmi_p2p_capabilities *cap;
621 if (dlen < sizeof(*cap))
622 return -EINVAL;
623 cap = (struct wmi_p2p_capabilities *) ev->data;
624 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
625 cap->go_power_save);
626 }
627
628 if (flags & P2P_FLAG_MACADDR_REQ) {
629 struct wmi_p2p_macaddr *mac;
630 if (dlen < sizeof(*mac))
631 return -EINVAL;
632 mac = (struct wmi_p2p_macaddr *) ev->data;
633 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
634 mac->mac_addr);
635 }
636
637 if (flags & P2P_FLAG_HMODEL_REQ) {
638 struct wmi_p2p_hmodel *mod;
639 if (dlen < sizeof(*mod))
640 return -EINVAL;
641 mod = (struct wmi_p2p_hmodel *) ev->data;
642 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
643 mod->p2p_model,
644 mod->p2p_model ? "host" : "firmware");
645 }
646 return 0;
647}
648
Kalle Valobdcd8172011-07-18 00:22:30 +0300649static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
650{
651 struct sk_buff *skb;
652
653 skb = ath6kl_buf_alloc(size);
654 if (!skb)
655 return NULL;
656
657 skb_put(skb, size);
658 if (size)
659 memset(skb->data, 0, size);
660
661 return skb;
662}
663
664/* Send a "simple" wmi command -- one with no arguments */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530665static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx,
666 enum wmi_cmd_id cmd_id)
Kalle Valobdcd8172011-07-18 00:22:30 +0300667{
668 struct sk_buff *skb;
669 int ret;
670
671 skb = ath6kl_wmi_get_new_buf(0);
672 if (!skb)
673 return -ENOMEM;
674
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530675 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +0300676
677 return ret;
678}
679
680static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
681{
682 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
683
684 if (len < sizeof(struct wmi_ready_event_2))
685 return -EINVAL;
686
Kalle Valobdcd8172011-07-18 00:22:30 +0300687 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
688 le32_to_cpu(ev->sw_version),
689 le32_to_cpu(ev->abi_version));
690
691 return 0;
692}
693
Vivek Natarajane5090442011-08-31 15:02:19 +0530694/*
695 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
696 * at which the station has to roam can be passed with
697 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
698 * in dBm.
699 */
700int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
701{
702 struct sk_buff *skb;
703 struct roam_ctrl_cmd *cmd;
704
705 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
706 if (!skb)
707 return -ENOMEM;
708
709 cmd = (struct roam_ctrl_cmd *) skb->data;
710
711 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
712 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
713 DEF_SCAN_FOR_ROAM_INTVL);
714 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
715 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
716 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
717
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530718 ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
719 NO_SYNC_WMIFLAG);
Vivek Natarajane5090442011-08-31 15:02:19 +0530720
721 return 0;
722}
723
Jouni Malinen12618752011-10-11 17:31:55 +0300724int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid)
725{
726 struct sk_buff *skb;
727 struct roam_ctrl_cmd *cmd;
728
729 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
730 if (!skb)
731 return -ENOMEM;
732
733 cmd = (struct roam_ctrl_cmd *) skb->data;
734 memset(cmd, 0, sizeof(*cmd));
735
736 memcpy(cmd->info.bssid, bssid, ETH_ALEN);
737 cmd->roam_ctrl = WMI_FORCE_ROAM;
738
739 ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530740 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
Jouni Malinen12618752011-10-11 17:31:55 +0300741 NO_SYNC_WMIFLAG);
742}
743
744int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode)
745{
746 struct sk_buff *skb;
747 struct roam_ctrl_cmd *cmd;
748
749 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
750 if (!skb)
751 return -ENOMEM;
752
753 cmd = (struct roam_ctrl_cmd *) skb->data;
754 memset(cmd, 0, sizeof(*cmd));
755
756 cmd->info.roam_mode = mode;
757 cmd->roam_ctrl = WMI_SET_ROAM_MODE;
758
759 ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +0530760 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
Jouni Malinen12618752011-10-11 17:31:55 +0300761 NO_SYNC_WMIFLAG);
762}
763
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530764static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
765 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300766{
767 struct wmi_connect_event *ev;
768 u8 *pie, *peie;
769
770 if (len < sizeof(struct wmi_connect_event))
771 return -EINVAL;
772
773 ev = (struct wmi_connect_event *) datap;
774
Vasanthakumar Thiagarajanf5938f22011-10-25 19:34:03 +0530775 if (vif->nw_type == AP_NETWORK) {
Jouni Malinen572e27c2011-09-05 17:38:45 +0300776 /* AP mode start/STA connected event */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530777 struct net_device *dev = vif->ndev;
Jouni Malinen572e27c2011-09-05 17:38:45 +0300778 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
779 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM "
780 "(AP started)\n",
781 __func__, le16_to_cpu(ev->u.ap_bss.ch),
782 ev->u.ap_bss.bssid);
783 ath6kl_connect_ap_mode_bss(
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530784 vif, le16_to_cpu(ev->u.ap_bss.ch));
Jouni Malinen572e27c2011-09-05 17:38:45 +0300785 } else {
786 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM "
787 "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
788 "(STA connected)\n",
789 __func__, ev->u.ap_sta.aid,
790 ev->u.ap_sta.mac_addr,
791 ev->u.ap_sta.auth,
792 ev->u.ap_sta.keymgmt,
793 le16_to_cpu(ev->u.ap_sta.cipher),
794 ev->u.ap_sta.apsd_info);
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530795
Jouni Malinen572e27c2011-09-05 17:38:45 +0300796 ath6kl_connect_ap_mode_sta(
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530797 vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
Jouni Malinen572e27c2011-09-05 17:38:45 +0300798 ev->u.ap_sta.keymgmt,
799 le16_to_cpu(ev->u.ap_sta.cipher),
800 ev->u.ap_sta.auth, ev->assoc_req_len,
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +0530801 ev->assoc_info + ev->beacon_ie_len,
802 ev->u.ap_sta.apsd_info);
Jouni Malinen572e27c2011-09-05 17:38:45 +0300803 }
804 return 0;
805 }
806
807 /* STA/IBSS mode connection event */
808
Kalle Valob9b6ee62011-09-27 14:31:21 +0300809 ath6kl_dbg(ATH6KL_DBG_WMI,
810 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
811 le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid,
812 le16_to_cpu(ev->u.sta.listen_intvl),
813 le16_to_cpu(ev->u.sta.beacon_intvl),
814 le32_to_cpu(ev->u.sta.nw_type));
Kalle Valobdcd8172011-07-18 00:22:30 +0300815
Kalle Valobdcd8172011-07-18 00:22:30 +0300816 /* Start of assoc rsp IEs */
817 pie = ev->assoc_info + ev->beacon_ie_len +
818 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
819
820 /* End of assoc rsp IEs */
821 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
822 ev->assoc_resp_len;
823
824 while (pie < peie) {
825 switch (*pie) {
826 case WLAN_EID_VENDOR_SPECIFIC:
827 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
828 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
829 /* WMM OUT (00:50:F2) */
830 if (pie[1] > 5
831 && pie[6] == WMM_PARAM_OUI_SUBTYPE)
832 wmi->is_wmm_enabled = true;
833 }
834 break;
835 }
836
837 if (wmi->is_wmm_enabled)
838 break;
839
840 pie += pie[1] + 2;
841 }
842
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530843 ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch),
Jouni Malinen572e27c2011-09-05 17:38:45 +0300844 ev->u.sta.bssid,
845 le16_to_cpu(ev->u.sta.listen_intvl),
846 le16_to_cpu(ev->u.sta.beacon_intvl),
847 le32_to_cpu(ev->u.sta.nw_type),
Kalle Valobdcd8172011-07-18 00:22:30 +0300848 ev->beacon_ie_len, ev->assoc_req_len,
849 ev->assoc_resp_len, ev->assoc_info);
850
851 return 0;
852}
853
Vivek Natarajan06033762011-09-06 13:01:36 +0530854static struct country_code_to_enum_rd *
855ath6kl_regd_find_country(u16 countryCode)
856{
857 int i;
858
859 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
860 if (allCountries[i].countryCode == countryCode)
861 return &allCountries[i];
862 }
863
864 return NULL;
865}
866
867static struct reg_dmn_pair_mapping *
868ath6kl_get_regpair(u16 regdmn)
869{
870 int i;
871
872 if (regdmn == NO_ENUMRD)
873 return NULL;
874
875 for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
876 if (regDomainPairs[i].regDmnEnum == regdmn)
877 return &regDomainPairs[i];
878 }
879
880 return NULL;
881}
882
883static struct country_code_to_enum_rd *
884ath6kl_regd_find_country_by_rd(u16 regdmn)
885{
886 int i;
887
888 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
889 if (allCountries[i].regDmnEnum == regdmn)
890 return &allCountries[i];
891 }
892
893 return NULL;
894}
895
896static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
897{
898
899 struct ath6kl_wmi_regdomain *ev;
900 struct country_code_to_enum_rd *country = NULL;
901 struct reg_dmn_pair_mapping *regpair = NULL;
902 char alpha2[2];
903 u32 reg_code;
904
905 ev = (struct ath6kl_wmi_regdomain *) datap;
906 reg_code = le32_to_cpu(ev->reg_code);
907
908 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
909 country = ath6kl_regd_find_country((u16) reg_code);
910 else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
911
912 regpair = ath6kl_get_regpair((u16) reg_code);
913 country = ath6kl_regd_find_country_by_rd((u16) reg_code);
Kalle Valob9b6ee62011-09-27 14:31:21 +0300914 ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
Vivek Natarajan06033762011-09-06 13:01:36 +0530915 regpair->regDmnEnum);
916 }
917
918 if (country) {
919 alpha2[0] = country->isoName[0];
920 alpha2[1] = country->isoName[1];
921
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +0530922 regulatory_hint(wmi->parent_dev->wiphy, alpha2);
Vivek Natarajan06033762011-09-06 13:01:36 +0530923
Kalle Valob9b6ee62011-09-27 14:31:21 +0300924 ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n",
Vivek Natarajan06033762011-09-06 13:01:36 +0530925 alpha2[0], alpha2[1]);
926 }
927}
928
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530929static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len,
930 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300931{
932 struct wmi_disconnect_event *ev;
933 wmi->traffic_class = 100;
934
935 if (len < sizeof(struct wmi_disconnect_event))
936 return -EINVAL;
937
938 ev = (struct wmi_disconnect_event *) datap;
Kalle Valobdcd8172011-07-18 00:22:30 +0300939
Kalle Valob9b6ee62011-09-27 14:31:21 +0300940 ath6kl_dbg(ATH6KL_DBG_WMI,
941 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
942 le16_to_cpu(ev->proto_reason_status), ev->bssid,
943 ev->disconn_reason, ev->assoc_resp_len);
944
Kalle Valobdcd8172011-07-18 00:22:30 +0300945 wmi->is_wmm_enabled = false;
Kalle Valobdcd8172011-07-18 00:22:30 +0300946
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530947 ath6kl_disconnect_event(vif, ev->disconn_reason,
Kalle Valobdcd8172011-07-18 00:22:30 +0300948 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
949 le16_to_cpu(ev->proto_reason_status));
950
951 return 0;
952}
953
954static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
955{
956 struct wmi_peer_node_event *ev;
957
958 if (len < sizeof(struct wmi_peer_node_event))
959 return -EINVAL;
960
961 ev = (struct wmi_peer_node_event *) datap;
962
963 if (ev->event_code == PEER_NODE_JOIN_EVENT)
964 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
965 ev->peer_mac_addr);
966 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
967 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
968 ev->peer_mac_addr);
969
970 return 0;
971}
972
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530973static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,
974 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300975{
976 struct wmi_tkip_micerr_event *ev;
977
978 if (len < sizeof(struct wmi_tkip_micerr_event))
979 return -EINVAL;
980
981 ev = (struct wmi_tkip_micerr_event *) datap;
982
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530983 ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);
Kalle Valobdcd8172011-07-18 00:22:30 +0300984
985 return 0;
986}
987
Kalle Valo10509f92011-12-13 14:52:07 +0200988void ath6kl_wmi_sscan_timer(unsigned long ptr)
989{
990 struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
991
992 cfg80211_sched_scan_results(vif->ar->wiphy);
993}
994
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +0530995static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
996 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +0300997{
Jouni Malinen82e14f52011-09-19 19:15:05 +0300998 struct wmi_bss_info_hdr2 *bih;
Jouni Malinen1aaa8c72011-09-19 19:15:03 +0300999 u8 *buf;
1000 struct ieee80211_channel *channel;
1001 struct ath6kl *ar = wmi->parent_dev;
1002 struct ieee80211_mgmt *mgmt;
1003 struct cfg80211_bss *bss;
Kalle Valobdcd8172011-07-18 00:22:30 +03001004
Jouni Malinen82e14f52011-09-19 19:15:05 +03001005 if (len <= sizeof(struct wmi_bss_info_hdr2))
Kalle Valobdcd8172011-07-18 00:22:30 +03001006 return -EINVAL;
1007
Jouni Malinen82e14f52011-09-19 19:15:05 +03001008 bih = (struct wmi_bss_info_hdr2 *) datap;
1009 buf = datap + sizeof(struct wmi_bss_info_hdr2);
1010 len -= sizeof(struct wmi_bss_info_hdr2);
Kalle Valobdcd8172011-07-18 00:22:30 +03001011
1012 ath6kl_dbg(ATH6KL_DBG_WMI,
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001013 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1014 "frame_type=%d\n",
Jouni Malinen82e14f52011-09-19 19:15:05 +03001015 bih->ch, bih->snr, bih->snr - 95, bih->bssid,
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001016 bih->frame_type);
Kalle Valobdcd8172011-07-18 00:22:30 +03001017
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001018 if (bih->frame_type != BEACON_FTYPE &&
1019 bih->frame_type != PROBERESP_FTYPE)
1020 return 0; /* Only update BSS table for now */
Kalle Valobdcd8172011-07-18 00:22:30 +03001021
Jouni Malinen551185c2011-09-19 19:15:06 +03001022 if (bih->frame_type == BEACON_FTYPE &&
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301023 test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) {
1024 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301025 ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
1026 NONE_BSS_FILTER, 0);
Jouni Malinen551185c2011-09-19 19:15:06 +03001027 }
1028
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +05301029 channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch));
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001030 if (channel == NULL)
1031 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001032
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001033 if (len < 8 + 2 + 2)
1034 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001035
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301036 if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags)
Vasanthakumar Thiagarajan8c8b65e2011-10-25 19:34:04 +05301037 && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) {
Jouni Malinen32c10872011-09-19 19:15:07 +03001038 const u8 *tim;
1039 tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2,
1040 len - 8 - 2 - 2);
1041 if (tim && tim[1] >= 2) {
Vasanthakumar Thiagarajancf5333d2011-10-25 19:34:10 +05301042 vif->assoc_bss_dtim_period = tim[3];
Vasanthakumar Thiagarajan59c98442011-10-25 19:34:01 +05301043 set_bit(DTIM_PERIOD_AVAIL, &vif->flags);
Jouni Malinen32c10872011-09-19 19:15:07 +03001044 }
1045 }
1046
Kalle Valobdcd8172011-07-18 00:22:30 +03001047 /*
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001048 * In theory, use of cfg80211_inform_bss() would be more natural here
1049 * since we do not have the full frame. However, at least for now,
1050 * cfg80211 can only distinguish Beacon and Probe Response frames from
1051 * each other when using cfg80211_inform_bss_frame(), so let's build a
1052 * fake IEEE 802.11 header to be able to take benefit of this.
Kalle Valobdcd8172011-07-18 00:22:30 +03001053 */
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001054 mgmt = kmalloc(24 + len, GFP_ATOMIC);
1055 if (mgmt == NULL)
1056 return -EINVAL;
Kalle Valobdcd8172011-07-18 00:22:30 +03001057
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001058 if (bih->frame_type == BEACON_FTYPE) {
1059 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1060 IEEE80211_STYPE_BEACON);
1061 memset(mgmt->da, 0xff, ETH_ALEN);
1062 } else {
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301063 struct net_device *dev = vif->ndev;
Kalle Valobdcd8172011-07-18 00:22:30 +03001064
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001065 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1066 IEEE80211_STYPE_PROBE_RESP);
1067 memcpy(mgmt->da, dev->dev_addr, ETH_ALEN);
Kalle Valobdcd8172011-07-18 00:22:30 +03001068 }
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001069 mgmt->duration = cpu_to_le16(0);
1070 memcpy(mgmt->sa, bih->bssid, ETH_ALEN);
1071 memcpy(mgmt->bssid, bih->bssid, ETH_ALEN);
1072 mgmt->seq_ctrl = cpu_to_le16(0);
Kalle Valobdcd8172011-07-18 00:22:30 +03001073
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001074 memcpy(&mgmt->u.beacon, buf, len);
1075
Vasanthakumar Thiagarajanbe98e3a2011-10-25 19:33:57 +05301076 bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt,
Jouni Malinen82e14f52011-09-19 19:15:05 +03001077 24 + len, (bih->snr - 95) * 100,
1078 GFP_ATOMIC);
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001079 kfree(mgmt);
1080 if (bss == NULL)
Kalle Valobdcd8172011-07-18 00:22:30 +03001081 return -ENOMEM;
Jouni Malinen1aaa8c72011-09-19 19:15:03 +03001082 cfg80211_put_bss(bss);
Kalle Valobdcd8172011-07-18 00:22:30 +03001083
Kalle Valo10509f92011-12-13 14:52:07 +02001084 /*
1085 * Firmware doesn't return any event when scheduled scan has
1086 * finished, so we need to use a timer to find out when there are
1087 * no more results.
1088 *
1089 * The timer is started from the first bss info received, otherwise
1090 * the timer would not ever fire if the scan interval is short
1091 * enough.
1092 */
1093 if (ar->state == ATH6KL_STATE_SCHED_SCAN &&
1094 !timer_pending(&vif->sched_scan_timer)) {
1095 mod_timer(&vif->sched_scan_timer, jiffies +
1096 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY));
1097 }
1098
Kalle Valobdcd8172011-07-18 00:22:30 +03001099 return 0;
1100}
1101
Kalle Valobdcd8172011-07-18 00:22:30 +03001102/* Inactivity timeout of a fatpipe(pstream) at the target */
1103static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1104 int len)
1105{
1106 struct wmi_pstream_timeout_event *ev;
1107
1108 if (len < sizeof(struct wmi_pstream_timeout_event))
1109 return -EINVAL;
1110
1111 ev = (struct wmi_pstream_timeout_event *) datap;
1112
1113 /*
1114 * When the pstream (fat pipe == AC) timesout, it means there were
1115 * no thinStreams within this pstream & it got implicitly created
1116 * due to data flow on this AC. We start the inactivity timer only
1117 * for implicitly created pstream. Just reset the host state.
1118 */
1119 spin_lock_bh(&wmi->lock);
1120 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1121 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1122 spin_unlock_bh(&wmi->lock);
1123
1124 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1125 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1126
1127 return 0;
1128}
1129
1130static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1131{
1132 struct wmi_bit_rate_reply *reply;
1133 s32 rate;
1134 u32 sgi, index;
1135
1136 if (len < sizeof(struct wmi_bit_rate_reply))
1137 return -EINVAL;
1138
1139 reply = (struct wmi_bit_rate_reply *) datap;
1140
1141 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1142
1143 if (reply->rate_index == (s8) RATE_AUTO) {
1144 rate = RATE_AUTO;
1145 } else {
1146 index = reply->rate_index & 0x7f;
1147 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1148 rate = wmi_rate_tbl[index][sgi];
1149 }
1150
1151 ath6kl_wakeup_event(wmi->parent_dev);
1152
1153 return 0;
1154}
1155
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08001156static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len)
Kalle Valo003353b0d2011-09-01 10:14:21 +03001157{
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08001158 ath6kl_tm_rx_event(wmi->parent_dev, datap, len);
Kalle Valo003353b0d2011-09-01 10:14:21 +03001159
1160 return 0;
1161}
1162
Kalle Valobdcd8172011-07-18 00:22:30 +03001163static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1164{
1165 if (len < sizeof(struct wmi_fix_rates_reply))
1166 return -EINVAL;
1167
1168 ath6kl_wakeup_event(wmi->parent_dev);
1169
1170 return 0;
1171}
1172
1173static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1174{
1175 if (len < sizeof(struct wmi_channel_list_reply))
1176 return -EINVAL;
1177
1178 ath6kl_wakeup_event(wmi->parent_dev);
1179
1180 return 0;
1181}
1182
1183static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1184{
1185 struct wmi_tx_pwr_reply *reply;
1186
1187 if (len < sizeof(struct wmi_tx_pwr_reply))
1188 return -EINVAL;
1189
1190 reply = (struct wmi_tx_pwr_reply *) datap;
1191 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1192
1193 return 0;
1194}
1195
1196static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1197{
1198 if (len < sizeof(struct wmi_get_keepalive_cmd))
1199 return -EINVAL;
1200
1201 ath6kl_wakeup_event(wmi->parent_dev);
1202
1203 return 0;
1204}
1205
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301206static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len,
1207 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001208{
1209 struct wmi_scan_complete_event *ev;
1210
1211 ev = (struct wmi_scan_complete_event *) datap;
1212
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301213 ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status));
Kalle Valobdcd8172011-07-18 00:22:30 +03001214 wmi->is_probe_ssid = false;
1215
1216 return 0;
1217}
1218
Jouni Malinen86512132011-09-21 16:57:29 +03001219static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301220 int len, struct ath6kl_vif *vif)
Jouni Malinen86512132011-09-21 16:57:29 +03001221{
1222 struct wmi_neighbor_report_event *ev;
1223 u8 i;
1224
1225 if (len < sizeof(*ev))
1226 return -EINVAL;
1227 ev = (struct wmi_neighbor_report_event *) datap;
1228 if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info)
1229 > len) {
1230 ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event "
1231 "(num=%d len=%d)\n", ev->num_neighbors, len);
1232 return -EINVAL;
1233 }
1234 for (i = 0; i < ev->num_neighbors; i++) {
1235 ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n",
1236 i + 1, ev->num_neighbors, ev->neighbor[i].bssid,
1237 ev->neighbor[i].bss_flags);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301238 cfg80211_pmksa_candidate_notify(vif->ndev, i,
Jouni Malinen86512132011-09-21 16:57:29 +03001239 ev->neighbor[i].bssid,
1240 !!(ev->neighbor[i].bss_flags &
1241 WMI_PREAUTH_CAPABLE_BSS),
1242 GFP_ATOMIC);
1243 }
1244
1245 return 0;
1246}
1247
Kalle Valobdcd8172011-07-18 00:22:30 +03001248/*
1249 * Target is reporting a programming error. This is for
1250 * developer aid only. Target only checks a few common violations
1251 * and it is responsibility of host to do all error checking.
1252 * Behavior of target after wmi error event is undefined.
1253 * A reset is recommended.
1254 */
1255static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1256{
1257 const char *type = "unknown error";
1258 struct wmi_cmd_error_event *ev;
1259 ev = (struct wmi_cmd_error_event *) datap;
1260
1261 switch (ev->err_code) {
1262 case INVALID_PARAM:
1263 type = "invalid parameter";
1264 break;
1265 case ILLEGAL_STATE:
1266 type = "invalid state";
1267 break;
1268 case INTERNAL_ERROR:
1269 type = "internal error";
1270 break;
1271 }
1272
1273 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1274 ev->cmd_id, type);
1275
1276 return 0;
1277}
1278
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301279static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len,
1280 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001281{
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301282 ath6kl_tgt_stats_event(vif, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03001283
1284 return 0;
1285}
1286
1287static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1288 struct sq_threshold_params *sq_thresh,
1289 u32 size)
1290{
1291 u32 index;
1292 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1293
1294 /* The list is already in sorted order. Get the next lower value */
1295 for (index = 0; index < size; index++) {
1296 if (rssi < sq_thresh->upper_threshold[index]) {
1297 threshold = (u8) sq_thresh->upper_threshold[index];
1298 break;
1299 }
1300 }
1301
1302 return threshold;
1303}
1304
1305static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1306 struct sq_threshold_params *sq_thresh,
1307 u32 size)
1308{
1309 u32 index;
1310 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1311
1312 /* The list is already in sorted order. Get the next lower value */
1313 for (index = 0; index < size; index++) {
1314 if (rssi > sq_thresh->lower_threshold[index]) {
1315 threshold = (u8) sq_thresh->lower_threshold[index];
1316 break;
1317 }
1318 }
1319
1320 return threshold;
1321}
1322
1323static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1324 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1325{
1326 struct sk_buff *skb;
1327 struct wmi_rssi_threshold_params_cmd *cmd;
1328
1329 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1330 if (!skb)
1331 return -ENOMEM;
1332
1333 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1334 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1335
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301336 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001337 NO_SYNC_WMIFLAG);
1338}
1339
1340static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1341 int len)
1342{
1343 struct wmi_rssi_threshold_event *reply;
1344 struct wmi_rssi_threshold_params_cmd cmd;
1345 struct sq_threshold_params *sq_thresh;
1346 enum wmi_rssi_threshold_val new_threshold;
1347 u8 upper_rssi_threshold, lower_rssi_threshold;
1348 s16 rssi;
1349 int ret;
1350
1351 if (len < sizeof(struct wmi_rssi_threshold_event))
1352 return -EINVAL;
1353
1354 reply = (struct wmi_rssi_threshold_event *) datap;
1355 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1356 rssi = a_sle16_to_cpu(reply->rssi);
1357
1358 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1359
1360 /*
1361 * Identify the threshold breached and communicate that to the app.
1362 * After that install a new set of thresholds based on the signal
1363 * quality reported by the target
1364 */
1365 if (new_threshold) {
1366 /* Upper threshold breached */
1367 if (rssi < sq_thresh->upper_threshold[0]) {
1368 ath6kl_dbg(ATH6KL_DBG_WMI,
1369 "spurious upper rssi threshold event: %d\n",
1370 rssi);
1371 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1372 (rssi >= sq_thresh->upper_threshold[0])) {
1373 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1374 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1375 (rssi >= sq_thresh->upper_threshold[1])) {
1376 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1377 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1378 (rssi >= sq_thresh->upper_threshold[2])) {
1379 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1380 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1381 (rssi >= sq_thresh->upper_threshold[3])) {
1382 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1383 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1384 (rssi >= sq_thresh->upper_threshold[4])) {
1385 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1386 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1387 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1388 }
1389 } else {
1390 /* Lower threshold breached */
1391 if (rssi > sq_thresh->lower_threshold[0]) {
1392 ath6kl_dbg(ATH6KL_DBG_WMI,
1393 "spurious lower rssi threshold event: %d %d\n",
1394 rssi, sq_thresh->lower_threshold[0]);
1395 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1396 (rssi <= sq_thresh->lower_threshold[0])) {
1397 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1398 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1399 (rssi <= sq_thresh->lower_threshold[1])) {
1400 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1401 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1402 (rssi <= sq_thresh->lower_threshold[2])) {
1403 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1404 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1405 (rssi <= sq_thresh->lower_threshold[3])) {
1406 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1407 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1408 (rssi <= sq_thresh->lower_threshold[4])) {
1409 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1410 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1411 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1412 }
1413 }
1414
1415 /* Calculate and install the next set of thresholds */
1416 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1417 sq_thresh->lower_threshold_valid_count);
1418 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1419 sq_thresh->upper_threshold_valid_count);
1420
1421 /* Issue a wmi command to install the thresholds */
1422 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1423 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1424 cmd.weight = sq_thresh->weight;
1425 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1426
1427 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1428 if (ret) {
1429 ath6kl_err("unable to configure rssi thresholds\n");
1430 return -EIO;
1431 }
1432
1433 return 0;
1434}
1435
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301436static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1437 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03001438{
1439 struct wmi_cac_event *reply;
1440 struct ieee80211_tspec_ie *ts;
1441 u16 active_tsids, tsinfo;
1442 u8 tsid, index;
1443 u8 ts_id;
1444
1445 if (len < sizeof(struct wmi_cac_event))
1446 return -EINVAL;
1447
1448 reply = (struct wmi_cac_event *) datap;
1449
1450 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1451 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1452
1453 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1454 tsinfo = le16_to_cpu(ts->tsinfo);
1455 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1456 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1457
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301458 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1459 reply->ac, tsid);
Kalle Valobdcd8172011-07-18 00:22:30 +03001460 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1461 /*
1462 * Following assumes that there is only one outstanding
1463 * ADDTS request when this event is received
1464 */
1465 spin_lock_bh(&wmi->lock);
1466 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1467 spin_unlock_bh(&wmi->lock);
1468
1469 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1470 if ((active_tsids >> index) & 1)
1471 break;
1472 }
1473 if (index < (sizeof(active_tsids) * 8))
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301474 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1475 reply->ac, index);
Kalle Valobdcd8172011-07-18 00:22:30 +03001476 }
1477
1478 /*
1479 * Clear active tsids and Add missing handling
1480 * for delete qos stream from AP
1481 */
1482 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1483
1484 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1485 tsinfo = le16_to_cpu(ts->tsinfo);
1486 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1487 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1488
1489 spin_lock_bh(&wmi->lock);
1490 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1491 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1492 spin_unlock_bh(&wmi->lock);
1493
1494 /* Indicate stream inactivity to driver layer only if all tsids
1495 * within this AC are deleted.
1496 */
1497 if (!active_tsids) {
1498 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1499 false);
1500 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1501 }
1502 }
1503
1504 return 0;
1505}
1506
1507static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1508 struct wmi_snr_threshold_params_cmd *snr_cmd)
1509{
1510 struct sk_buff *skb;
1511 struct wmi_snr_threshold_params_cmd *cmd;
1512
1513 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1514 if (!skb)
1515 return -ENOMEM;
1516
1517 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1518 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1519
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301520 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001521 NO_SYNC_WMIFLAG);
1522}
1523
1524static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1525 int len)
1526{
1527 struct wmi_snr_threshold_event *reply;
1528 struct sq_threshold_params *sq_thresh;
1529 struct wmi_snr_threshold_params_cmd cmd;
1530 enum wmi_snr_threshold_val new_threshold;
1531 u8 upper_snr_threshold, lower_snr_threshold;
1532 s16 snr;
1533 int ret;
1534
1535 if (len < sizeof(struct wmi_snr_threshold_event))
1536 return -EINVAL;
1537
1538 reply = (struct wmi_snr_threshold_event *) datap;
1539
1540 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1541 snr = reply->snr;
1542
1543 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1544
1545 /*
1546 * Identify the threshold breached and communicate that to the app.
1547 * After that install a new set of thresholds based on the signal
1548 * quality reported by the target.
1549 */
1550 if (new_threshold) {
1551 /* Upper threshold breached */
1552 if (snr < sq_thresh->upper_threshold[0]) {
1553 ath6kl_dbg(ATH6KL_DBG_WMI,
1554 "spurious upper snr threshold event: %d\n",
1555 snr);
1556 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1557 (snr >= sq_thresh->upper_threshold[0])) {
1558 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1559 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1560 (snr >= sq_thresh->upper_threshold[1])) {
1561 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1562 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1563 (snr >= sq_thresh->upper_threshold[2])) {
1564 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1565 } else if (snr >= sq_thresh->upper_threshold[3]) {
1566 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1567 }
1568 } else {
1569 /* Lower threshold breached */
1570 if (snr > sq_thresh->lower_threshold[0]) {
1571 ath6kl_dbg(ATH6KL_DBG_WMI,
1572 "spurious lower snr threshold event: %d\n",
1573 sq_thresh->lower_threshold[0]);
1574 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1575 (snr <= sq_thresh->lower_threshold[0])) {
1576 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1577 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1578 (snr <= sq_thresh->lower_threshold[1])) {
1579 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1580 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1581 (snr <= sq_thresh->lower_threshold[2])) {
1582 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1583 } else if (snr <= sq_thresh->lower_threshold[3]) {
1584 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1585 }
1586 }
1587
1588 /* Calculate and install the next set of thresholds */
1589 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1590 sq_thresh->lower_threshold_valid_count);
1591 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1592 sq_thresh->upper_threshold_valid_count);
1593
1594 /* Issue a wmi command to install the thresholds */
1595 cmd.thresh_above1_val = upper_snr_threshold;
1596 cmd.thresh_below1_val = lower_snr_threshold;
1597 cmd.weight = sq_thresh->weight;
1598 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1599
1600 ath6kl_dbg(ATH6KL_DBG_WMI,
1601 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1602 snr, new_threshold,
1603 lower_snr_threshold, upper_snr_threshold);
1604
1605 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1606 if (ret) {
1607 ath6kl_err("unable to configure snr threshold\n");
1608 return -EIO;
1609 }
1610
1611 return 0;
1612}
1613
1614static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1615{
1616 u16 ap_info_entry_size;
1617 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1618 struct wmi_ap_info_v1 *ap_info_v1;
1619 u8 index;
1620
1621 if (len < sizeof(struct wmi_aplist_event) ||
1622 ev->ap_list_ver != APLIST_VER1)
1623 return -EINVAL;
1624
1625 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1626 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1627
1628 ath6kl_dbg(ATH6KL_DBG_WMI,
1629 "number of APs in aplist event: %d\n", ev->num_ap);
1630
1631 if (len < (int) (sizeof(struct wmi_aplist_event) +
1632 (ev->num_ap - 1) * ap_info_entry_size))
1633 return -EINVAL;
1634
1635 /* AP list version 1 contents */
1636 for (index = 0; index < ev->num_ap; index++) {
1637 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1638 index, ap_info_v1->bssid, ap_info_v1->channel);
1639 ap_info_v1++;
1640 }
1641
1642 return 0;
1643}
1644
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301645int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb,
Kalle Valobdcd8172011-07-18 00:22:30 +03001646 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1647{
1648 struct wmi_cmd_hdr *cmd_hdr;
1649 enum htc_endpoint_id ep_id = wmi->ep_id;
1650 int ret;
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301651 u16 info1;
Kalle Valobdcd8172011-07-18 00:22:30 +03001652
Kalle Valo71f96ee2011-11-14 19:31:30 +02001653 if (WARN_ON(skb == NULL || (if_idx > (wmi->parent_dev->vif_max - 1))))
Kalle Valobdcd8172011-07-18 00:22:30 +03001654 return -EINVAL;
1655
Kalle Valob9b6ee62011-09-27 14:31:21 +03001656 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n",
1657 cmd_id, skb->len, sync_flag);
1658 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ",
1659 skb->data, skb->len);
1660
Kalle Valobdcd8172011-07-18 00:22:30 +03001661 if (sync_flag >= END_WMIFLAG) {
1662 dev_kfree_skb(skb);
1663 return -EINVAL;
1664 }
1665
1666 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1667 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1668 /*
1669 * Make sure all data currently queued is transmitted before
1670 * the cmd execution. Establish a new sync point.
1671 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301672 ath6kl_wmi_sync_point(wmi, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001673 }
1674
1675 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1676
1677 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1678 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301679 info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK;
1680 cmd_hdr->info1 = cpu_to_le16(info1);
Kalle Valobdcd8172011-07-18 00:22:30 +03001681
1682 /* Only for OPT_TX_CMD, use BE endpoint. */
1683 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1684 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05301685 false, false, 0, NULL, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001686 if (ret) {
1687 dev_kfree_skb(skb);
1688 return ret;
1689 }
1690 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1691 }
1692
1693 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1694
1695 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1696 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1697 /*
1698 * Make sure all new data queued waits for the command to
1699 * execute. Establish a new sync point.
1700 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301701 ath6kl_wmi_sync_point(wmi, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03001702 }
1703
1704 return 0;
1705}
1706
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301707int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx,
1708 enum network_type nw_type,
Kalle Valobdcd8172011-07-18 00:22:30 +03001709 enum dot11_auth_mode dot11_auth_mode,
1710 enum auth_mode auth_mode,
1711 enum crypto_type pairwise_crypto,
1712 u8 pairwise_crypto_len,
1713 enum crypto_type group_crypto,
1714 u8 group_crypto_len, int ssid_len, u8 *ssid,
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001715 u8 *bssid, u16 channel, u32 ctrl_flags,
1716 u8 nw_subtype)
Kalle Valobdcd8172011-07-18 00:22:30 +03001717{
1718 struct sk_buff *skb;
1719 struct wmi_connect_cmd *cc;
1720 int ret;
1721
Kalle Valob9b6ee62011-09-27 14:31:21 +03001722 ath6kl_dbg(ATH6KL_DBG_WMI,
1723 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1724 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1725 bssid, channel, ctrl_flags, ssid_len, nw_type,
1726 dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto);
1727 ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len);
1728
Kalle Valobdcd8172011-07-18 00:22:30 +03001729 wmi->traffic_class = 100;
1730
1731 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1732 return -EINVAL;
1733
1734 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1735 return -EINVAL;
1736
1737 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1738 if (!skb)
1739 return -ENOMEM;
1740
1741 cc = (struct wmi_connect_cmd *) skb->data;
1742
1743 if (ssid_len)
1744 memcpy(cc->ssid, ssid, ssid_len);
1745
1746 cc->ssid_len = ssid_len;
1747 cc->nw_type = nw_type;
1748 cc->dot11_auth_mode = dot11_auth_mode;
1749 cc->auth_mode = auth_mode;
1750 cc->prwise_crypto_type = pairwise_crypto;
1751 cc->prwise_crypto_len = pairwise_crypto_len;
1752 cc->grp_crypto_type = group_crypto;
1753 cc->grp_crypto_len = group_crypto_len;
1754 cc->ch = cpu_to_le16(channel);
1755 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001756 cc->nw_subtype = nw_subtype;
Kalle Valobdcd8172011-07-18 00:22:30 +03001757
1758 if (bssid != NULL)
1759 memcpy(cc->bssid, bssid, ETH_ALEN);
1760
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301761 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID,
1762 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03001763
1764 return ret;
1765}
1766
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301767int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid,
1768 u16 channel)
Kalle Valobdcd8172011-07-18 00:22:30 +03001769{
1770 struct sk_buff *skb;
1771 struct wmi_reconnect_cmd *cc;
1772 int ret;
1773
Kalle Valob9b6ee62011-09-27 14:31:21 +03001774 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n",
1775 bssid, channel);
1776
Kalle Valobdcd8172011-07-18 00:22:30 +03001777 wmi->traffic_class = 100;
1778
1779 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1780 if (!skb)
1781 return -ENOMEM;
1782
1783 cc = (struct wmi_reconnect_cmd *) skb->data;
1784 cc->channel = cpu_to_le16(channel);
1785
1786 if (bssid != NULL)
1787 memcpy(cc->bssid, bssid, ETH_ALEN);
1788
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301789 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001790 NO_SYNC_WMIFLAG);
1791
1792 return ret;
1793}
1794
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301795int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03001796{
1797 int ret;
1798
Kalle Valob9b6ee62011-09-27 14:31:21 +03001799 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n");
1800
Kalle Valobdcd8172011-07-18 00:22:30 +03001801 wmi->traffic_class = 100;
1802
1803 /* Disconnect command does not need to do a SYNC before. */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301804 ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03001805
1806 return ret;
1807}
1808
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08001809int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx,
1810 enum wmi_scan_type scan_type,
1811 u32 force_fgscan, u32 is_legacy,
1812 u32 home_dwell_time, u32 force_scan_interval,
1813 s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
1814{
1815 struct sk_buff *skb;
1816 struct wmi_begin_scan_cmd *sc;
1817 s8 size;
1818 int i, band, ret;
1819 struct ath6kl *ar = wmi->parent_dev;
1820 int num_rates;
1821
1822 size = sizeof(struct wmi_begin_scan_cmd);
1823
1824 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1825 return -EINVAL;
1826
1827 if (num_chan > WMI_MAX_CHANNELS)
1828 return -EINVAL;
1829
1830 if (num_chan)
1831 size += sizeof(u16) * (num_chan - 1);
1832
1833 skb = ath6kl_wmi_get_new_buf(size);
1834 if (!skb)
1835 return -ENOMEM;
1836
1837 sc = (struct wmi_begin_scan_cmd *) skb->data;
1838 sc->scan_type = scan_type;
1839 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1840 sc->is_legacy = cpu_to_le32(is_legacy);
1841 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1842 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1843 sc->no_cck = cpu_to_le32(no_cck);
1844 sc->num_ch = num_chan;
1845
1846 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1847 struct ieee80211_supported_band *sband =
1848 ar->wiphy->bands[band];
1849 u32 ratemask = rates[band];
1850 u8 *supp_rates = sc->supp_rates[band].rates;
1851 num_rates = 0;
1852
1853 for (i = 0; i < sband->n_bitrates; i++) {
1854 if ((BIT(i) & ratemask) == 0)
1855 continue; /* skip rate */
1856 supp_rates[num_rates++] =
1857 (u8) (sband->bitrates[i].bitrate / 5);
1858 }
1859 sc->supp_rates[band].nrates = num_rates;
1860 }
1861
1862 for (i = 0; i < num_chan; i++)
1863 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
1864
1865 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID,
1866 NO_SYNC_WMIFLAG);
1867
1868 return ret;
1869}
1870
1871/* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
1872 * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
1873 * mgmt operations using station interface.
1874 */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301875int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx,
1876 enum wmi_scan_type scan_type,
Kalle Valobdcd8172011-07-18 00:22:30 +03001877 u32 force_fgscan, u32 is_legacy,
1878 u32 home_dwell_time, u32 force_scan_interval,
1879 s8 num_chan, u16 *ch_list)
1880{
1881 struct sk_buff *skb;
1882 struct wmi_start_scan_cmd *sc;
1883 s8 size;
Edward Lu1276c9e2011-08-30 21:58:00 +03001884 int i, ret;
Kalle Valobdcd8172011-07-18 00:22:30 +03001885
1886 size = sizeof(struct wmi_start_scan_cmd);
1887
1888 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1889 return -EINVAL;
1890
1891 if (num_chan > WMI_MAX_CHANNELS)
1892 return -EINVAL;
1893
1894 if (num_chan)
1895 size += sizeof(u16) * (num_chan - 1);
1896
1897 skb = ath6kl_wmi_get_new_buf(size);
1898 if (!skb)
1899 return -ENOMEM;
1900
1901 sc = (struct wmi_start_scan_cmd *) skb->data;
1902 sc->scan_type = scan_type;
1903 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1904 sc->is_legacy = cpu_to_le32(is_legacy);
1905 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1906 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1907 sc->num_ch = num_chan;
1908
Edward Lu1276c9e2011-08-30 21:58:00 +03001909 for (i = 0; i < num_chan; i++)
1910 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
Kalle Valobdcd8172011-07-18 00:22:30 +03001911
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301912 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001913 NO_SYNC_WMIFLAG);
1914
1915 return ret;
1916}
1917
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301918int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx,
1919 u16 fg_start_sec,
Kalle Valobdcd8172011-07-18 00:22:30 +03001920 u16 fg_end_sec, u16 bg_sec,
1921 u16 minact_chdw_msec, u16 maxact_chdw_msec,
1922 u16 pas_chdw_msec, u8 short_scan_ratio,
1923 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
1924 u16 maxact_scan_per_ssid)
1925{
1926 struct sk_buff *skb;
1927 struct wmi_scan_params_cmd *sc;
1928 int ret;
1929
1930 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
1931 if (!skb)
1932 return -ENOMEM;
1933
1934 sc = (struct wmi_scan_params_cmd *) skb->data;
1935 sc->fg_start_period = cpu_to_le16(fg_start_sec);
1936 sc->fg_end_period = cpu_to_le16(fg_end_sec);
1937 sc->bg_period = cpu_to_le16(bg_sec);
1938 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
1939 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
1940 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
1941 sc->short_scan_ratio = short_scan_ratio;
1942 sc->scan_ctrl_flags = scan_ctrl_flag;
1943 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
1944 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
1945
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301946 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001947 NO_SYNC_WMIFLAG);
1948 return ret;
1949}
1950
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301951int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask)
Kalle Valobdcd8172011-07-18 00:22:30 +03001952{
1953 struct sk_buff *skb;
1954 struct wmi_bss_filter_cmd *cmd;
1955 int ret;
1956
1957 if (filter >= LAST_BSS_FILTER)
1958 return -EINVAL;
1959
1960 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1961 if (!skb)
1962 return -ENOMEM;
1963
1964 cmd = (struct wmi_bss_filter_cmd *) skb->data;
1965 cmd->bss_filter = filter;
1966 cmd->ie_mask = cpu_to_le32(ie_mask);
1967
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05301968 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03001969 NO_SYNC_WMIFLAG);
1970 return ret;
1971}
1972
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05301973int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag,
Kalle Valobdcd8172011-07-18 00:22:30 +03001974 u8 ssid_len, u8 *ssid)
1975{
1976 struct sk_buff *skb;
1977 struct wmi_probed_ssid_cmd *cmd;
1978 int ret;
1979
1980 if (index > MAX_PROBED_SSID_INDEX)
1981 return -EINVAL;
1982
1983 if (ssid_len > sizeof(cmd->ssid))
1984 return -EINVAL;
1985
1986 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
1987 return -EINVAL;
1988
1989 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
1990 return -EINVAL;
1991
1992 if (flag & SPECIFIC_SSID_FLAG)
1993 wmi->is_probe_ssid = true;
1994
1995 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1996 if (!skb)
1997 return -ENOMEM;
1998
1999 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
2000 cmd->entry_index = index;
2001 cmd->flag = flag;
2002 cmd->ssid_len = ssid_len;
2003 memcpy(cmd->ssid, ssid, ssid_len);
2004
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302005 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002006 NO_SYNC_WMIFLAG);
2007 return ret;
2008}
2009
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302010int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx,
2011 u16 listen_interval,
Kalle Valobdcd8172011-07-18 00:22:30 +03002012 u16 listen_beacons)
2013{
2014 struct sk_buff *skb;
2015 struct wmi_listen_int_cmd *cmd;
2016 int ret;
2017
2018 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2019 if (!skb)
2020 return -ENOMEM;
2021
2022 cmd = (struct wmi_listen_int_cmd *) skb->data;
2023 cmd->listen_intvl = cpu_to_le16(listen_interval);
2024 cmd->num_beacons = cpu_to_le16(listen_beacons);
2025
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302026 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002027 NO_SYNC_WMIFLAG);
2028 return ret;
2029}
2030
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302031int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode)
Kalle Valobdcd8172011-07-18 00:22:30 +03002032{
2033 struct sk_buff *skb;
2034 struct wmi_power_mode_cmd *cmd;
2035 int ret;
2036
2037 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2038 if (!skb)
2039 return -ENOMEM;
2040
2041 cmd = (struct wmi_power_mode_cmd *) skb->data;
2042 cmd->pwr_mode = pwr_mode;
2043 wmi->pwr_mode = pwr_mode;
2044
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302045 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002046 NO_SYNC_WMIFLAG);
2047 return ret;
2048}
2049
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302050int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period,
Kalle Valobdcd8172011-07-18 00:22:30 +03002051 u16 ps_poll_num, u16 dtim_policy,
2052 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
2053 u16 ps_fail_event_policy)
2054{
2055 struct sk_buff *skb;
2056 struct wmi_power_params_cmd *pm;
2057 int ret;
2058
2059 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
2060 if (!skb)
2061 return -ENOMEM;
2062
2063 pm = (struct wmi_power_params_cmd *)skb->data;
2064 pm->idle_period = cpu_to_le16(idle_period);
2065 pm->pspoll_number = cpu_to_le16(ps_poll_num);
2066 pm->dtim_policy = cpu_to_le16(dtim_policy);
2067 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
2068 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
2069 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
2070
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302071 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002072 NO_SYNC_WMIFLAG);
2073 return ret;
2074}
2075
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302076int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout)
Kalle Valobdcd8172011-07-18 00:22:30 +03002077{
2078 struct sk_buff *skb;
2079 struct wmi_disc_timeout_cmd *cmd;
2080 int ret;
2081
2082 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2083 if (!skb)
2084 return -ENOMEM;
2085
2086 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
2087 cmd->discon_timeout = timeout;
2088
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302089 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002090 NO_SYNC_WMIFLAG);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302091
Jouni Malinenff0b0072011-10-11 17:31:56 +03002092 if (ret == 0)
2093 ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302094
Kalle Valobdcd8172011-07-18 00:22:30 +03002095 return ret;
2096}
2097
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302098int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
Kalle Valobdcd8172011-07-18 00:22:30 +03002099 enum crypto_type key_type,
2100 u8 key_usage, u8 key_len,
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002101 u8 *key_rsc, unsigned int key_rsc_len,
2102 u8 *key_material,
Kalle Valobdcd8172011-07-18 00:22:30 +03002103 u8 key_op_ctrl, u8 *mac_addr,
2104 enum wmi_sync_flag sync_flag)
2105{
2106 struct sk_buff *skb;
2107 struct wmi_add_cipher_key_cmd *cmd;
2108 int ret;
2109
Jouni Malinen9a5b1312011-08-30 21:57:52 +03002110 ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
2111 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
2112 key_index, key_type, key_usage, key_len, key_op_ctrl);
2113
Kalle Valobdcd8172011-07-18 00:22:30 +03002114 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002115 (key_material == NULL) || key_rsc_len > 8)
Kalle Valobdcd8172011-07-18 00:22:30 +03002116 return -EINVAL;
2117
2118 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
2119 return -EINVAL;
2120
2121 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2122 if (!skb)
2123 return -ENOMEM;
2124
2125 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
2126 cmd->key_index = key_index;
2127 cmd->key_type = key_type;
2128 cmd->key_usage = key_usage;
2129 cmd->key_len = key_len;
2130 memcpy(cmd->key, key_material, key_len);
2131
2132 if (key_rsc != NULL)
Jouni Malinenf4bb9a62011-11-02 23:45:55 +02002133 memcpy(cmd->key_rsc, key_rsc, key_rsc_len);
Kalle Valobdcd8172011-07-18 00:22:30 +03002134
2135 cmd->key_op_ctrl = key_op_ctrl;
2136
2137 if (mac_addr)
2138 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
2139
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302140 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002141 sync_flag);
2142
2143 return ret;
2144}
2145
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302146int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk)
Kalle Valobdcd8172011-07-18 00:22:30 +03002147{
2148 struct sk_buff *skb;
2149 struct wmi_add_krk_cmd *cmd;
2150 int ret;
2151
2152 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2153 if (!skb)
2154 return -ENOMEM;
2155
2156 cmd = (struct wmi_add_krk_cmd *) skb->data;
2157 memcpy(cmd->krk, krk, WMI_KRK_LEN);
2158
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302159 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID,
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302160 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002161
2162 return ret;
2163}
2164
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302165int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index)
Kalle Valobdcd8172011-07-18 00:22:30 +03002166{
2167 struct sk_buff *skb;
2168 struct wmi_delete_cipher_key_cmd *cmd;
2169 int ret;
2170
2171 if (key_index > WMI_MAX_KEY_INDEX)
2172 return -EINVAL;
2173
2174 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2175 if (!skb)
2176 return -ENOMEM;
2177
2178 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
2179 cmd->key_index = key_index;
2180
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302181 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002182 NO_SYNC_WMIFLAG);
2183
2184 return ret;
2185}
2186
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302187int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
Kalle Valobdcd8172011-07-18 00:22:30 +03002188 const u8 *pmkid, bool set)
2189{
2190 struct sk_buff *skb;
2191 struct wmi_setpmkid_cmd *cmd;
2192 int ret;
2193
2194 if (bssid == NULL)
2195 return -EINVAL;
2196
2197 if (set && pmkid == NULL)
2198 return -EINVAL;
2199
2200 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2201 if (!skb)
2202 return -ENOMEM;
2203
2204 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2205 memcpy(cmd->bssid, bssid, ETH_ALEN);
2206 if (set) {
2207 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2208 cmd->enable = PMKID_ENABLE;
2209 } else {
2210 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2211 cmd->enable = PMKID_DISABLE;
2212 }
2213
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302214 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002215 NO_SYNC_WMIFLAG);
2216
2217 return ret;
2218}
2219
2220static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302221 enum htc_endpoint_id ep_id, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002222{
2223 struct wmi_data_hdr *data_hdr;
2224 int ret;
2225
2226 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id))
2227 return -EINVAL;
2228
2229 skb_push(skb, sizeof(struct wmi_data_hdr));
2230
2231 data_hdr = (struct wmi_data_hdr *) skb->data;
2232 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302233 data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
Kalle Valobdcd8172011-07-18 00:22:30 +03002234
2235 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2236
2237 return ret;
2238}
2239
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302240static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002241{
2242 struct sk_buff *skb;
2243 struct wmi_sync_cmd *cmd;
2244 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2245 enum htc_endpoint_id ep_id;
2246 u8 index, num_pri_streams = 0;
2247 int ret = 0;
2248
2249 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2250
2251 spin_lock_bh(&wmi->lock);
2252
2253 for (index = 0; index < WMM_NUM_AC; index++) {
2254 if (wmi->fat_pipe_exist & (1 << index)) {
2255 num_pri_streams++;
2256 data_sync_bufs[num_pri_streams - 1].traffic_class =
2257 index;
2258 }
2259 }
2260
2261 spin_unlock_bh(&wmi->lock);
2262
2263 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2264 if (!skb) {
2265 ret = -ENOMEM;
2266 goto free_skb;
2267 }
2268
2269 cmd = (struct wmi_sync_cmd *) skb->data;
2270
2271 /*
2272 * In the SYNC cmd sent on the control Ep, send a bitmap
2273 * of the data eps on which the Data Sync will be sent
2274 */
2275 cmd->data_sync_map = wmi->fat_pipe_exist;
2276
2277 for (index = 0; index < num_pri_streams; index++) {
2278 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2279 if (data_sync_bufs[index].skb == NULL) {
2280 ret = -ENOMEM;
2281 break;
2282 }
2283 }
2284
2285 /*
2286 * If buffer allocation for any of the dataSync fails,
2287 * then do not send the Synchronize cmd on the control ep
2288 */
2289 if (ret)
2290 goto free_skb;
2291
2292 /*
2293 * Send sync cmd followed by sync data messages on all
2294 * endpoints being used
2295 */
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302296 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002297 NO_SYNC_WMIFLAG);
2298
2299 if (ret)
2300 goto free_skb;
2301
2302 /* cmd buffer sent, we no longer own it */
2303 skb = NULL;
2304
2305 for (index = 0; index < num_pri_streams; index++) {
2306
2307 if (WARN_ON(!data_sync_bufs[index].skb))
2308 break;
2309
2310 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2311 data_sync_bufs[index].
2312 traffic_class);
2313 ret =
2314 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
Vasanthakumar Thiagarajan6765d0a2011-10-25 19:34:17 +05302315 ep_id, if_idx);
Kalle Valobdcd8172011-07-18 00:22:30 +03002316
2317 if (ret)
2318 break;
2319
2320 data_sync_bufs[index].skb = NULL;
2321 }
2322
2323free_skb:
2324 /* free up any resources left over (possibly due to an error) */
2325 if (skb)
2326 dev_kfree_skb(skb);
2327
2328 for (index = 0; index < num_pri_streams; index++) {
2329 if (data_sync_bufs[index].skb != NULL) {
2330 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].
2331 skb);
2332 }
2333 }
2334
2335 return ret;
2336}
2337
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302338int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx,
Kalle Valobdcd8172011-07-18 00:22:30 +03002339 struct wmi_create_pstream_cmd *params)
2340{
2341 struct sk_buff *skb;
2342 struct wmi_create_pstream_cmd *cmd;
2343 u8 fatpipe_exist_for_ac = 0;
2344 s32 min_phy = 0;
2345 s32 nominal_phy = 0;
2346 int ret;
2347
2348 if (!((params->user_pri < 8) &&
2349 (params->user_pri <= 0x7) &&
2350 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2351 (params->traffic_direc == UPLINK_TRAFFIC ||
2352 params->traffic_direc == DNLINK_TRAFFIC ||
2353 params->traffic_direc == BIDIR_TRAFFIC) &&
2354 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2355 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2356 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2357 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2358 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2359 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2360 params->tsid <= WMI_MAX_THINSTREAM))) {
2361 return -EINVAL;
2362 }
2363
2364 /*
2365 * Check nominal PHY rate is >= minimalPHY,
2366 * so that DUT can allow TSRS IE
2367 */
2368
2369 /* Get the physical rate (units of bps) */
2370 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2371
2372 /* Check minimal phy < nominal phy rate */
2373 if (params->nominal_phy >= min_phy) {
2374 /* unit of 500 kbps */
2375 nominal_phy = (params->nominal_phy * 1000) / 500;
2376 ath6kl_dbg(ATH6KL_DBG_WMI,
2377 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2378 min_phy, nominal_phy);
2379
2380 params->nominal_phy = nominal_phy;
2381 } else {
2382 params->nominal_phy = 0;
2383 }
2384
2385 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2386 if (!skb)
2387 return -ENOMEM;
2388
2389 ath6kl_dbg(ATH6KL_DBG_WMI,
2390 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2391 params->traffic_class, params->tsid);
2392
2393 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2394 memcpy(cmd, params, sizeof(*cmd));
2395
2396 /* This is an implicitly created Fat pipe */
2397 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2398 spin_lock_bh(&wmi->lock);
2399 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2400 (1 << params->traffic_class));
2401 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2402 spin_unlock_bh(&wmi->lock);
2403 } else {
2404 /* explicitly created thin stream within a fat pipe */
2405 spin_lock_bh(&wmi->lock);
2406 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2407 (1 << params->traffic_class));
2408 wmi->stream_exist_for_ac[params->traffic_class] |=
2409 (1 << params->tsid);
2410 /*
2411 * If a thinstream becomes active, the fat pipe automatically
2412 * becomes active
2413 */
2414 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2415 spin_unlock_bh(&wmi->lock);
2416 }
2417
2418 /*
2419 * Indicate activty change to driver layer only if this is the
2420 * first TSID to get created in this AC explicitly or an implicit
2421 * fat pipe is getting created.
2422 */
2423 if (!fatpipe_exist_for_ac)
2424 ath6kl_indicate_tx_activity(wmi->parent_dev,
2425 params->traffic_class, true);
2426
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302427 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002428 NO_SYNC_WMIFLAG);
2429 return ret;
2430}
2431
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302432int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
2433 u8 tsid)
Kalle Valobdcd8172011-07-18 00:22:30 +03002434{
2435 struct sk_buff *skb;
2436 struct wmi_delete_pstream_cmd *cmd;
2437 u16 active_tsids = 0;
2438 int ret;
2439
2440 if (traffic_class > 3) {
2441 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2442 return -EINVAL;
2443 }
2444
2445 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2446 if (!skb)
2447 return -ENOMEM;
2448
2449 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2450 cmd->traffic_class = traffic_class;
2451 cmd->tsid = tsid;
2452
2453 spin_lock_bh(&wmi->lock);
2454 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2455 spin_unlock_bh(&wmi->lock);
2456
2457 if (!(active_tsids & (1 << tsid))) {
2458 dev_kfree_skb(skb);
2459 ath6kl_dbg(ATH6KL_DBG_WMI,
2460 "TSID %d doesn't exist for traffic class: %d\n",
2461 tsid, traffic_class);
2462 return -ENODATA;
2463 }
2464
2465 ath6kl_dbg(ATH6KL_DBG_WMI,
2466 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2467 traffic_class, tsid);
2468
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302469 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002470 SYNC_BEFORE_WMIFLAG);
2471
2472 spin_lock_bh(&wmi->lock);
2473 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2474 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2475 spin_unlock_bh(&wmi->lock);
2476
2477 /*
2478 * Indicate stream inactivity to driver layer only if all tsids
2479 * within this AC are deleted.
2480 */
2481 if (!active_tsids) {
2482 ath6kl_indicate_tx_activity(wmi->parent_dev,
2483 traffic_class, false);
2484 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2485 }
2486
2487 return ret;
2488}
2489
Raja Manica1d16a2011-12-16 14:24:23 +05302490int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
2491 __be32 ips0, __be32 ips1)
Kalle Valobdcd8172011-07-18 00:22:30 +03002492{
2493 struct sk_buff *skb;
2494 struct wmi_set_ip_cmd *cmd;
2495 int ret;
2496
2497 /* Multicast address are not valid */
Raja Manica1d16a2011-12-16 14:24:23 +05302498 if (ipv4_is_multicast(ips0) ||
2499 ipv4_is_multicast(ips1))
Kalle Valobdcd8172011-07-18 00:22:30 +03002500 return -EINVAL;
2501
2502 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2503 if (!skb)
2504 return -ENOMEM;
2505
2506 cmd = (struct wmi_set_ip_cmd *) skb->data;
Raja Manica1d16a2011-12-16 14:24:23 +05302507 cmd->ips[0] = ips0;
2508 cmd->ips[1] = ips1;
Kalle Valobdcd8172011-07-18 00:22:30 +03002509
Raja Manica1d16a2011-12-16 14:24:23 +05302510 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID,
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302511 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002512 return ret;
2513}
2514
Raja Mani45cf1102011-11-07 22:52:45 +02002515static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
2516{
2517 u16 active_tsids;
2518 u8 stream_exist;
2519 int i;
2520
2521 /*
2522 * Relinquish credits from all implicitly created pstreams
2523 * since when we go to sleep. If user created explicit
2524 * thinstreams exists with in a fatpipe leave them intact
2525 * for the user to delete.
2526 */
2527 spin_lock_bh(&wmi->lock);
2528 stream_exist = wmi->fat_pipe_exist;
2529 spin_unlock_bh(&wmi->lock);
2530
2531 for (i = 0; i < WMM_NUM_AC; i++) {
2532 if (stream_exist & (1 << i)) {
2533
2534 /*
2535 * FIXME: Is this lock & unlock inside
2536 * for loop correct? may need rework.
2537 */
2538 spin_lock_bh(&wmi->lock);
2539 active_tsids = wmi->stream_exist_for_ac[i];
2540 spin_unlock_bh(&wmi->lock);
2541
2542 /*
2543 * If there are no user created thin streams
2544 * delete the fatpipe
2545 */
2546 if (!active_tsids) {
2547 stream_exist &= ~(1 << i);
2548 /*
2549 * Indicate inactivity to driver layer for
2550 * this fatpipe (pstream)
2551 */
2552 ath6kl_indicate_tx_activity(wmi->parent_dev,
2553 i, false);
2554 }
2555 }
2556 }
2557
2558 /* FIXME: Can we do this assignment without locking ? */
2559 spin_lock_bh(&wmi->lock);
2560 wmi->fat_pipe_exist = stream_exist;
2561 spin_unlock_bh(&wmi->lock);
2562}
2563
2564int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
2565 enum ath6kl_host_mode host_mode)
2566{
2567 struct sk_buff *skb;
2568 struct wmi_set_host_sleep_mode_cmd *cmd;
2569 int ret;
2570
2571 if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) &&
2572 (host_mode != ATH6KL_HOST_MODE_AWAKE)) {
2573 ath6kl_err("invalid host sleep mode: %d\n", host_mode);
2574 return -EINVAL;
2575 }
2576
2577 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2578 if (!skb)
2579 return -ENOMEM;
2580
2581 cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data;
2582
2583 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
2584 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
2585 cmd->asleep = cpu_to_le32(1);
2586 } else
2587 cmd->awake = cpu_to_le32(1);
2588
2589 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2590 WMI_SET_HOST_SLEEP_MODE_CMDID,
2591 NO_SYNC_WMIFLAG);
2592 return ret;
2593}
2594
Raja Mani081c7a82012-01-30 17:13:11 +05302595/* This command has zero length payload */
2596static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi,
2597 struct ath6kl_vif *vif)
2598{
2599 struct ath6kl *ar = wmi->parent_dev;
2600
2601 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags);
2602 wake_up(&ar->event_wq);
2603
2604 return 0;
2605}
2606
Raja Mani45cf1102011-11-07 22:52:45 +02002607int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx,
2608 enum ath6kl_wow_mode wow_mode,
2609 u32 filter, u16 host_req_delay)
2610{
2611 struct sk_buff *skb;
2612 struct wmi_set_wow_mode_cmd *cmd;
2613 int ret;
2614
2615 if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) &&
2616 wow_mode != ATH6KL_WOW_MODE_DISABLE) {
2617 ath6kl_err("invalid wow mode: %d\n", wow_mode);
2618 return -EINVAL;
2619 }
2620
2621 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2622 if (!skb)
2623 return -ENOMEM;
2624
2625 cmd = (struct wmi_set_wow_mode_cmd *) skb->data;
2626 cmd->enable_wow = cpu_to_le32(wow_mode);
2627 cmd->filter = cpu_to_le32(filter);
2628 cmd->host_req_delay = cpu_to_le16(host_req_delay);
2629
2630 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID,
2631 NO_SYNC_WMIFLAG);
2632 return ret;
2633}
2634
Raja Mani5c9b4fa2011-11-07 22:52:45 +02002635int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2636 u8 list_id, u8 filter_size,
Raja Manid91e8ee2012-01-30 17:13:10 +05302637 u8 filter_offset, const u8 *filter,
2638 const u8 *mask)
Raja Mani5c9b4fa2011-11-07 22:52:45 +02002639{
2640 struct sk_buff *skb;
2641 struct wmi_add_wow_pattern_cmd *cmd;
2642 u16 size;
2643 u8 *filter_mask;
2644 int ret;
2645
2646 /*
2647 * Allocate additional memory in the buffer to hold
2648 * filter and mask value, which is twice of filter_size.
2649 */
2650 size = sizeof(*cmd) + (2 * filter_size);
2651
2652 skb = ath6kl_wmi_get_new_buf(size);
2653 if (!skb)
2654 return -ENOMEM;
2655
2656 cmd = (struct wmi_add_wow_pattern_cmd *) skb->data;
2657 cmd->filter_list_id = list_id;
2658 cmd->filter_size = filter_size;
2659 cmd->filter_offset = filter_offset;
2660
2661 memcpy(cmd->filter, filter, filter_size);
2662
2663 filter_mask = (u8 *) (cmd->filter + filter_size);
2664 memcpy(filter_mask, mask, filter_size);
2665
2666 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID,
2667 NO_SYNC_WMIFLAG);
2668
2669 return ret;
2670}
2671
2672int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2673 u16 list_id, u16 filter_id)
2674{
2675 struct sk_buff *skb;
2676 struct wmi_del_wow_pattern_cmd *cmd;
2677 int ret;
2678
2679 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2680 if (!skb)
2681 return -ENOMEM;
2682
2683 cmd = (struct wmi_del_wow_pattern_cmd *) skb->data;
2684 cmd->filter_list_id = cpu_to_le16(list_id);
2685 cmd->filter_id = cpu_to_le16(filter_id);
2686
2687 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID,
2688 NO_SYNC_WMIFLAG);
2689 return ret;
2690}
2691
Kalle Valobdcd8172011-07-18 00:22:30 +03002692static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
2693 enum wmix_command_id cmd_id,
2694 enum wmi_sync_flag sync_flag)
2695{
2696 struct wmix_cmd_hdr *cmd_hdr;
2697 int ret;
2698
2699 skb_push(skb, sizeof(struct wmix_cmd_hdr));
2700
2701 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
2702 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
2703
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302704 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag);
Kalle Valobdcd8172011-07-18 00:22:30 +03002705
2706 return ret;
2707}
2708
2709int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
2710{
2711 struct sk_buff *skb;
2712 struct wmix_hb_challenge_resp_cmd *cmd;
2713 int ret;
2714
2715 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2716 if (!skb)
2717 return -ENOMEM;
2718
2719 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
2720 cmd->cookie = cpu_to_le32(cookie);
2721 cmd->source = cpu_to_le32(source);
2722
2723 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
2724 NO_SYNC_WMIFLAG);
2725 return ret;
2726}
2727
Kalle Valo939f1cc2011-09-02 10:32:04 +03002728int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
2729{
2730 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
2731 struct sk_buff *skb;
2732 int ret;
2733
2734 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2735 if (!skb)
2736 return -ENOMEM;
2737
2738 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
2739 cmd->valid = cpu_to_le32(valid);
2740 cmd->config = cpu_to_le32(config);
2741
2742 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
2743 NO_SYNC_WMIFLAG);
2744 return ret;
2745}
2746
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302747int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002748{
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302749 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03002750}
2751
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302752int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM)
Kalle Valobdcd8172011-07-18 00:22:30 +03002753{
2754 struct sk_buff *skb;
2755 struct wmi_set_tx_pwr_cmd *cmd;
2756 int ret;
2757
2758 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
2759 if (!skb)
2760 return -ENOMEM;
2761
2762 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
2763 cmd->dbM = dbM;
2764
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302765 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002766 NO_SYNC_WMIFLAG);
2767
2768 return ret;
2769}
2770
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302771int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx)
Kalle Valobdcd8172011-07-18 00:22:30 +03002772{
Vasanthakumar Thiagarajan990bd912011-10-25 19:34:20 +05302773 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID);
Kalle Valobdcd8172011-07-18 00:22:30 +03002774}
2775
Jouni Malinen4b28a802011-10-11 17:31:54 +03002776int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi)
2777{
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302778 return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID);
Jouni Malinen4b28a802011-10-11 17:31:54 +03002779}
2780
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302781int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status,
2782 u8 preamble_policy)
Kalle Valobdcd8172011-07-18 00:22:30 +03002783{
2784 struct sk_buff *skb;
2785 struct wmi_set_lpreamble_cmd *cmd;
2786 int ret;
2787
2788 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
2789 if (!skb)
2790 return -ENOMEM;
2791
2792 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
2793 cmd->status = status;
2794 cmd->preamble_policy = preamble_policy;
2795
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302796 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002797 NO_SYNC_WMIFLAG);
2798 return ret;
2799}
2800
2801int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
2802{
2803 struct sk_buff *skb;
2804 struct wmi_set_rts_cmd *cmd;
2805 int ret;
2806
2807 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
2808 if (!skb)
2809 return -ENOMEM;
2810
2811 cmd = (struct wmi_set_rts_cmd *) skb->data;
2812 cmd->threshold = cpu_to_le16(threshold);
2813
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302814 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID,
2815 NO_SYNC_WMIFLAG);
Kalle Valobdcd8172011-07-18 00:22:30 +03002816 return ret;
2817}
2818
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302819int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg)
Kalle Valobdcd8172011-07-18 00:22:30 +03002820{
2821 struct sk_buff *skb;
2822 struct wmi_set_wmm_txop_cmd *cmd;
2823 int ret;
2824
2825 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
2826 return -EINVAL;
2827
2828 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
2829 if (!skb)
2830 return -ENOMEM;
2831
2832 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
2833 cmd->txop_enable = cfg;
2834
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302835 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002836 NO_SYNC_WMIFLAG);
2837 return ret;
2838}
2839
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302840int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx,
2841 u8 keep_alive_intvl)
Kalle Valobdcd8172011-07-18 00:22:30 +03002842{
2843 struct sk_buff *skb;
2844 struct wmi_set_keepalive_cmd *cmd;
2845 int ret;
2846
2847 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2848 if (!skb)
2849 return -ENOMEM;
2850
2851 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
2852 cmd->keep_alive_intvl = keep_alive_intvl;
Kalle Valobdcd8172011-07-18 00:22:30 +03002853
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05302854 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03002855 NO_SYNC_WMIFLAG);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302856
Jouni Malinenff0b0072011-10-11 17:31:56 +03002857 if (ret == 0)
2858 ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302859
Kalle Valobdcd8172011-07-18 00:22:30 +03002860 return ret;
2861}
2862
Kalle Valo003353b0d2011-09-01 10:14:21 +03002863int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
2864{
2865 struct sk_buff *skb;
2866 int ret;
2867
2868 skb = ath6kl_wmi_get_new_buf(len);
2869 if (!skb)
2870 return -ENOMEM;
2871
2872 memcpy(skb->data, buf, len);
2873
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302874 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
Kalle Valo003353b0d2011-09-01 10:14:21 +03002875
2876 return ret;
2877}
2878
Vasanthakumar Thiagarajan3f3c4ee2012-01-03 14:41:59 +05302879int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on)
2880{
2881 struct sk_buff *skb;
2882 struct wmi_mcast_filter_cmd *cmd;
2883 int ret;
2884
2885 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2886 if (!skb)
2887 return -ENOMEM;
2888
2889 cmd = (struct wmi_mcast_filter_cmd *) skb->data;
2890 cmd->mcast_all_enable = mc_all_on;
2891
2892 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID,
2893 NO_SYNC_WMIFLAG);
2894 return ret;
2895}
Kalle Valo003353b0d2011-09-01 10:14:21 +03002896
Vasanthakumar Thiagarajanf914edd2012-01-03 14:42:00 +05302897int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx,
2898 u8 *filter, bool add_filter)
2899{
2900 struct sk_buff *skb;
2901 struct wmi_mcast_filter_add_del_cmd *cmd;
2902 int ret;
2903
2904 if ((filter[0] != 0x33 || filter[1] != 0x33) &&
2905 (filter[0] != 0x01 || filter[1] != 0x00 ||
2906 filter[2] != 0x5e || filter[3] > 0x7f)) {
2907 ath6kl_warn("invalid multicast filter address\n");
2908 return -EINVAL;
2909 }
2910
2911 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2912 if (!skb)
2913 return -ENOMEM;
2914
2915 cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data;
2916 memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE);
2917 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2918 add_filter ? WMI_SET_MCAST_FILTER_CMDID :
2919 WMI_DEL_MCAST_FILTER_CMDID,
2920 NO_SYNC_WMIFLAG);
2921
2922 return ret;
2923}
2924
Kalle Valobdcd8172011-07-18 00:22:30 +03002925s32 ath6kl_wmi_get_rate(s8 rate_index)
2926{
2927 if (rate_index == RATE_AUTO)
2928 return 0;
2929
2930 return wmi_rate_tbl[(u32) rate_index][0];
2931}
2932
Kalle Valobdcd8172011-07-18 00:22:30 +03002933static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
2934 u32 len)
2935{
2936 struct wmi_pmkid_list_reply *reply;
2937 u32 expected_len;
2938
2939 if (len < sizeof(struct wmi_pmkid_list_reply))
2940 return -EINVAL;
2941
2942 reply = (struct wmi_pmkid_list_reply *)datap;
2943 expected_len = sizeof(reply->num_pmkid) +
2944 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
2945
2946 if (len < expected_len)
2947 return -EINVAL;
2948
2949 return 0;
2950}
2951
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302952static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
2953 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03002954{
2955 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
2956
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302957 aggr_recv_addba_req_evt(vif, cmd->tid,
Kalle Valobdcd8172011-07-18 00:22:30 +03002958 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
2959
2960 return 0;
2961}
2962
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302963static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
2964 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03002965{
2966 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
2967
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05302968 aggr_recv_delba_req_evt(vif, cmd->tid);
Kalle Valobdcd8172011-07-18 00:22:30 +03002969
2970 return 0;
2971}
2972
2973/* AP mode functions */
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002974
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302975int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx,
2976 struct wmi_connect_cmd *p)
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002977{
2978 struct sk_buff *skb;
2979 struct wmi_connect_cmd *cm;
2980 int res;
2981
2982 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2983 if (!skb)
2984 return -ENOMEM;
2985
2986 cm = (struct wmi_connect_cmd *) skb->data;
2987 memcpy(cm, p, sizeof(*cm));
2988
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302989 res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03002990 NO_SYNC_WMIFLAG);
2991 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
2992 "ctrl_flags=0x%x-> res=%d\n",
2993 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
2994 le32_to_cpu(p->ctrl_flags), res);
2995 return res;
2996}
2997
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05302998int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac,
2999 u16 reason)
Jouni Malinen23875132011-08-30 21:57:53 +03003000{
3001 struct sk_buff *skb;
3002 struct wmi_ap_set_mlme_cmd *cm;
3003
3004 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3005 if (!skb)
3006 return -ENOMEM;
3007
3008 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
3009 memcpy(cm->mac, mac, ETH_ALEN);
3010 cm->reason = cpu_to_le16(reason);
3011 cm->cmd = cmd;
3012
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303013 return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID,
Jouni Malinen23875132011-08-30 21:57:53 +03003014 NO_SYNC_WMIFLAG);
3015}
3016
Thirumalai Pachamuthuc1762a32012-01-12 18:21:39 +05303017/* This command will be used to enable/disable AP uAPSD feature */
3018int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable)
3019{
3020 struct wmi_ap_set_apsd_cmd *cmd;
3021 struct sk_buff *skb;
3022
3023 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3024 if (!skb)
3025 return -ENOMEM;
3026
3027 cmd = (struct wmi_ap_set_apsd_cmd *)skb->data;
3028 cmd->enable = enable;
3029
3030 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID,
3031 NO_SYNC_WMIFLAG);
3032}
3033
3034int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx,
3035 u16 aid, u16 bitmap, u32 flags)
3036{
3037 struct wmi_ap_apsd_buffered_traffic_cmd *cmd;
3038 struct sk_buff *skb;
3039
3040 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3041 if (!skb)
3042 return -ENOMEM;
3043
3044 cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data;
3045 cmd->aid = cpu_to_le16(aid);
3046 cmd->bitmap = cpu_to_le16(bitmap);
3047 cmd->flags = cpu_to_le32(flags);
3048
3049 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3050 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
3051 NO_SYNC_WMIFLAG);
3052}
3053
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303054static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len,
3055 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03003056{
3057 struct wmi_pspoll_event *ev;
3058
3059 if (len < sizeof(struct wmi_pspoll_event))
3060 return -EINVAL;
3061
3062 ev = (struct wmi_pspoll_event *) datap;
3063
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303064 ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid));
Kalle Valobdcd8172011-07-18 00:22:30 +03003065
3066 return 0;
3067}
3068
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303069static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len,
3070 struct ath6kl_vif *vif)
Kalle Valobdcd8172011-07-18 00:22:30 +03003071{
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303072 ath6kl_dtimexpiry_event(vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003073
3074 return 0;
3075}
3076
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303077int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
3078 bool flag)
Kalle Valobdcd8172011-07-18 00:22:30 +03003079{
3080 struct sk_buff *skb;
3081 struct wmi_ap_set_pvb_cmd *cmd;
3082 int ret;
3083
3084 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
3085 if (!skb)
3086 return -ENOMEM;
3087
3088 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
3089 cmd->aid = cpu_to_le16(aid);
Jouni Malinend6e51e62011-09-05 17:38:44 +03003090 cmd->rsvd = cpu_to_le16(0);
Kalle Valobdcd8172011-07-18 00:22:30 +03003091 cmd->flag = cpu_to_le32(flag);
3092
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303093 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03003094 NO_SYNC_WMIFLAG);
3095
3096 return 0;
3097}
3098
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303099int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
3100 u8 rx_meta_ver,
Kalle Valobdcd8172011-07-18 00:22:30 +03003101 bool rx_dot11_hdr, bool defrag_on_host)
3102{
3103 struct sk_buff *skb;
3104 struct wmi_rx_frame_format_cmd *cmd;
3105 int ret;
3106
3107 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3108 if (!skb)
3109 return -ENOMEM;
3110
3111 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
3112 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
3113 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
3114 cmd->meta_ver = rx_meta_ver;
3115
3116 /* Delete the local aggr state, on host */
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303117 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID,
Kalle Valobdcd8172011-07-18 00:22:30 +03003118 NO_SYNC_WMIFLAG);
3119
3120 return ret;
3121}
3122
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303123int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,
3124 const u8 *ie, u8 ie_len)
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03003125{
3126 struct sk_buff *skb;
3127 struct wmi_set_appie_cmd *p;
3128
3129 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3130 if (!skb)
3131 return -ENOMEM;
3132
3133 ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
3134 "ie_len=%u\n", mgmt_frm_type, ie_len);
3135 p = (struct wmi_set_appie_cmd *) skb->data;
3136 p->mgmt_frm_type = mgmt_frm_type;
3137 p->ie_len = ie_len;
Kalle Valo10509f92011-12-13 14:52:07 +02003138
3139 if (ie != NULL && ie_len > 0)
3140 memcpy(p->ie_info, ie, ie_len);
3141
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303142 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID,
Jouni Malinen6a7c9ba2011-08-30 21:57:50 +03003143 NO_SYNC_WMIFLAG);
3144}
3145
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003146int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
3147{
3148 struct sk_buff *skb;
3149 struct wmi_disable_11b_rates_cmd *cmd;
3150
3151 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3152 if (!skb)
3153 return -ENOMEM;
3154
3155 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
3156 disable);
3157 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
3158 cmd->disable = disable ? 1 : 0;
3159
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303160 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003161 NO_SYNC_WMIFLAG);
3162}
3163
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303164int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003165{
3166 struct sk_buff *skb;
3167 struct wmi_remain_on_chnl_cmd *p;
3168
3169 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3170 if (!skb)
3171 return -ENOMEM;
3172
3173 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3174 freq, dur);
3175 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
3176 p->freq = cpu_to_le32(freq);
3177 p->duration = cpu_to_le32(dur);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303178 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003179 NO_SYNC_WMIFLAG);
3180}
3181
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08003182/* ath6kl_wmi_send_action_cmd is to be deprecated. Use
3183 * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
3184 * mgmt operations using station interface.
3185 */
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303186int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3187 u32 wait, const u8 *data, u16 data_len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003188{
3189 struct sk_buff *skb;
3190 struct wmi_send_action_cmd *p;
Jouni Malinena0df5db2011-08-30 21:58:02 +03003191 u8 *buf;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003192
3193 if (wait)
3194 return -EINVAL; /* Offload for wait not supported */
3195
Jouni Malinena0df5db2011-08-30 21:58:02 +03003196 buf = kmalloc(data_len, GFP_KERNEL);
3197 if (!buf)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003198 return -ENOMEM;
3199
Jouni Malinena0df5db2011-08-30 21:58:02 +03003200 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3201 if (!skb) {
3202 kfree(buf);
3203 return -ENOMEM;
3204 }
3205
3206 kfree(wmi->last_mgmt_tx_frame);
Aarthi Thiruvengadam3101ede2011-10-27 09:35:56 -07003207 memcpy(buf, data, data_len);
Jouni Malinena0df5db2011-08-30 21:58:02 +03003208 wmi->last_mgmt_tx_frame = buf;
3209 wmi->last_mgmt_tx_frame_len = data_len;
3210
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003211 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3212 "len=%u\n", id, freq, wait, data_len);
3213 p = (struct wmi_send_action_cmd *) skb->data;
3214 p->id = cpu_to_le32(id);
3215 p->freq = cpu_to_le32(freq);
3216 p->wait = cpu_to_le32(wait);
3217 p->len = cpu_to_le16(data_len);
3218 memcpy(p->data, data, data_len);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303219 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003220 NO_SYNC_WMIFLAG);
3221}
3222
Aarthi Thiruvengadam3ca9d1f2011-12-13 13:32:12 -08003223int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3224 u32 wait, const u8 *data, u16 data_len,
3225 u32 no_cck)
3226{
3227 struct sk_buff *skb;
3228 struct wmi_send_mgmt_cmd *p;
3229 u8 *buf;
3230
3231 if (wait)
3232 return -EINVAL; /* Offload for wait not supported */
3233
3234 buf = kmalloc(data_len, GFP_KERNEL);
3235 if (!buf)
3236 return -ENOMEM;
3237
3238 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3239 if (!skb) {
3240 kfree(buf);
3241 return -ENOMEM;
3242 }
3243
3244 kfree(wmi->last_mgmt_tx_frame);
3245 memcpy(buf, data, data_len);
3246 wmi->last_mgmt_tx_frame = buf;
3247 wmi->last_mgmt_tx_frame_len = data_len;
3248
3249 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3250 "len=%u\n", id, freq, wait, data_len);
3251 p = (struct wmi_send_mgmt_cmd *) skb->data;
3252 p->id = cpu_to_le32(id);
3253 p->freq = cpu_to_le32(freq);
3254 p->wait = cpu_to_le32(wait);
3255 p->no_cck = cpu_to_le32(no_cck);
3256 p->len = cpu_to_le16(data_len);
3257 memcpy(p->data, data, data_len);
3258 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID,
3259 NO_SYNC_WMIFLAG);
3260}
3261
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303262int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq,
3263 const u8 *dst, const u8 *data,
3264 u16 data_len)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003265{
3266 struct sk_buff *skb;
3267 struct wmi_p2p_probe_response_cmd *p;
Aarthi Thiruvengadambd24a502011-11-09 10:05:56 -08003268 size_t cmd_len = sizeof(*p) + data_len;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003269
Aarthi Thiruvengadambd24a502011-11-09 10:05:56 -08003270 if (data_len == 0)
3271 cmd_len++; /* work around target minimum length requirement */
3272
3273 skb = ath6kl_wmi_get_new_buf(cmd_len);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003274 if (!skb)
3275 return -ENOMEM;
3276
3277 ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
3278 "len=%u\n", freq, dst, data_len);
3279 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
3280 p->freq = cpu_to_le32(freq);
3281 memcpy(p->destination_addr, dst, ETH_ALEN);
3282 p->len = cpu_to_le16(data_len);
3283 memcpy(p->data, data, data_len);
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303284 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3285 WMI_SEND_PROBE_RESPONSE_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003286 NO_SYNC_WMIFLAG);
3287}
3288
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303289int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003290{
3291 struct sk_buff *skb;
3292 struct wmi_probe_req_report_cmd *p;
3293
3294 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3295 if (!skb)
3296 return -ENOMEM;
3297
3298 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
3299 enable);
3300 p = (struct wmi_probe_req_report_cmd *) skb->data;
3301 p->enable = enable ? 1 : 0;
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303302 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003303 NO_SYNC_WMIFLAG);
3304}
3305
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303306int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003307{
3308 struct sk_buff *skb;
3309 struct wmi_get_p2p_info *p;
3310
3311 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3312 if (!skb)
3313 return -ENOMEM;
3314
3315 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
3316 info_req_flags);
3317 p = (struct wmi_get_p2p_info *) skb->data;
3318 p->info_req_flags = cpu_to_le32(info_req_flags);
Vasanthakumar Thiagarajan0ce59442011-10-25 19:34:25 +05303319 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID,
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003320 NO_SYNC_WMIFLAG);
3321}
3322
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303323int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx)
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003324{
3325 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
Vasanthakumar Thiagarajan334234b2011-10-25 19:34:12 +05303326 return ath6kl_wmi_simple_cmd(wmi, if_idx,
3327 WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003328}
3329
Kalle Valobdcd8172011-07-18 00:22:30 +03003330static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
3331{
3332 struct wmix_cmd_hdr *cmd;
3333 u32 len;
3334 u16 id;
3335 u8 *datap;
3336 int ret = 0;
3337
3338 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
3339 ath6kl_err("bad packet 1\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003340 return -EINVAL;
3341 }
3342
3343 cmd = (struct wmix_cmd_hdr *) skb->data;
3344 id = le32_to_cpu(cmd->cmd_id);
3345
3346 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
3347
3348 datap = skb->data;
3349 len = skb->len;
3350
3351 switch (id) {
3352 case WMIX_HB_CHALLENGE_RESP_EVENTID:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003353 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003354 break;
3355 case WMIX_DBGLOG_EVENTID:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003356 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len);
Kalle Valobdf53962011-09-02 10:32:04 +03003357 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003358 break;
3359 default:
Kalle Valob9b6ee62011-09-27 14:31:21 +03003360 ath6kl_warn("unknown cmd id 0x%x\n", id);
Kalle Valobdcd8172011-07-18 00:22:30 +03003361 ret = -EINVAL;
3362 break;
3363 }
3364
3365 return ret;
3366}
3367
Jouni Malinen4b28a802011-10-11 17:31:54 +03003368static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len)
3369{
3370 return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len);
3371}
3372
Kalle Valobdcd8172011-07-18 00:22:30 +03003373/* Control Path */
3374int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
3375{
3376 struct wmi_cmd_hdr *cmd;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303377 struct ath6kl_vif *vif;
Kalle Valobdcd8172011-07-18 00:22:30 +03003378 u32 len;
3379 u16 id;
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303380 u8 if_idx;
Kalle Valobdcd8172011-07-18 00:22:30 +03003381 u8 *datap;
3382 int ret = 0;
3383
3384 if (WARN_ON(skb == NULL))
3385 return -EINVAL;
3386
3387 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
3388 ath6kl_err("bad packet 1\n");
3389 dev_kfree_skb(skb);
Kalle Valobdcd8172011-07-18 00:22:30 +03003390 return -EINVAL;
3391 }
3392
3393 cmd = (struct wmi_cmd_hdr *) skb->data;
3394 id = le16_to_cpu(cmd->cmd_id);
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303395 if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK;
Kalle Valobdcd8172011-07-18 00:22:30 +03003396
3397 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
3398
3399 datap = skb->data;
3400 len = skb->len;
3401
Kalle Valob9b6ee62011-09-27 14:31:21 +03003402 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len);
3403 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ",
Kalle Valoef094102011-09-27 14:30:45 +03003404 datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003405
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303406 vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx);
3407 if (!vif) {
3408 ath6kl_dbg(ATH6KL_DBG_WMI,
3409 "Wmi event for unavailable vif, vif_index:%d\n",
3410 if_idx);
3411 dev_kfree_skb(skb);
3412 return -EINVAL;
3413 }
3414
Kalle Valobdcd8172011-07-18 00:22:30 +03003415 switch (id) {
3416 case WMI_GET_BITRATE_CMDID:
3417 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
3418 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
3419 break;
3420 case WMI_GET_CHANNEL_LIST_CMDID:
3421 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
3422 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
3423 break;
3424 case WMI_GET_TX_PWR_CMDID:
3425 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
3426 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
3427 break;
3428 case WMI_READY_EVENTID:
3429 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
3430 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
3431 break;
3432 case WMI_CONNECT_EVENTID:
3433 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303434 ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003435 break;
3436 case WMI_DISCONNECT_EVENTID:
3437 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303438 ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003439 break;
3440 case WMI_PEER_NODE_EVENTID:
3441 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
3442 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
3443 break;
3444 case WMI_TKIP_MICERR_EVENTID:
3445 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303446 ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003447 break;
3448 case WMI_BSSINFO_EVENTID:
3449 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303450 ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003451 break;
3452 case WMI_REGDOMAIN_EVENTID:
3453 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
Vivek Natarajan06033762011-09-06 13:01:36 +05303454 ath6kl_wmi_regdomain_event(wmi, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003455 break;
3456 case WMI_PSTREAM_TIMEOUT_EVENTID:
3457 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
3458 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
3459 break;
3460 case WMI_NEIGHBOR_REPORT_EVENTID:
3461 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303462 ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len,
3463 vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003464 break;
3465 case WMI_SCAN_COMPLETE_EVENTID:
3466 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303467 ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003468 break;
3469 case WMI_CMDERROR_EVENTID:
3470 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
3471 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
3472 break;
3473 case WMI_REPORT_STATISTICS_EVENTID:
3474 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303475 ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003476 break;
3477 case WMI_RSSI_THRESHOLD_EVENTID:
3478 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
3479 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
3480 break;
3481 case WMI_ERROR_REPORT_EVENTID:
3482 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
3483 break;
3484 case WMI_OPT_RX_FRAME_EVENTID:
3485 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
Jouni Malinenf195d502011-09-19 19:15:00 +03003486 /* this event has been deprecated */
Kalle Valobdcd8172011-07-18 00:22:30 +03003487 break;
3488 case WMI_REPORT_ROAM_TBL_EVENTID:
3489 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
Jouni Malinen4b28a802011-10-11 17:31:54 +03003490 ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len);
Kalle Valobdcd8172011-07-18 00:22:30 +03003491 break;
3492 case WMI_EXTENSION_EVENTID:
3493 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
3494 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
3495 break;
3496 case WMI_CAC_EVENTID:
3497 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303498 ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003499 break;
3500 case WMI_CHANNEL_CHANGE_EVENTID:
3501 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
3502 break;
3503 case WMI_REPORT_ROAM_DATA_EVENTID:
3504 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
3505 break;
Kalle Valo003353b0d2011-09-01 10:14:21 +03003506 case WMI_TEST_EVENTID:
3507 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
Thomas Pedersen4f34dac2011-12-30 01:57:00 -08003508 ret = ath6kl_wmi_test_rx(wmi, datap, len);
Kalle Valo003353b0d2011-09-01 10:14:21 +03003509 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003510 case WMI_GET_FIXRATES_CMDID:
3511 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
3512 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
3513 break;
3514 case WMI_TX_RETRY_ERR_EVENTID:
3515 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
3516 break;
3517 case WMI_SNR_THRESHOLD_EVENTID:
3518 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
3519 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
3520 break;
3521 case WMI_LQ_THRESHOLD_EVENTID:
3522 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
3523 break;
3524 case WMI_APLIST_EVENTID:
3525 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
3526 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
3527 break;
3528 case WMI_GET_KEEPALIVE_CMDID:
3529 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
3530 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
3531 break;
3532 case WMI_GET_WOW_LIST_EVENTID:
3533 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
Kalle Valobdcd8172011-07-18 00:22:30 +03003534 break;
3535 case WMI_GET_PMKID_LIST_EVENTID:
3536 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
3537 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
3538 break;
3539 case WMI_PSPOLL_EVENTID:
3540 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303541 ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003542 break;
3543 case WMI_DTIMEXPIRY_EVENTID:
3544 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303545 ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003546 break;
3547 case WMI_SET_PARAMS_REPLY_EVENTID:
3548 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3549 break;
3550 case WMI_ADDBA_REQ_EVENTID:
3551 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303552 ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003553 break;
3554 case WMI_ADDBA_RESP_EVENTID:
3555 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
3556 break;
3557 case WMI_DELBA_REQ_EVENTID:
3558 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303559 ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif);
Kalle Valobdcd8172011-07-18 00:22:30 +03003560 break;
3561 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
3562 ath6kl_dbg(ATH6KL_DBG_WMI,
3563 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3564 break;
3565 case WMI_REPORT_BTCOEX_STATS_EVENTID:
3566 ath6kl_dbg(ATH6KL_DBG_WMI,
3567 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3568 break;
3569 case WMI_TX_COMPLETE_EVENTID:
3570 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
3571 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
3572 break;
Raja Mani081c7a82012-01-30 17:13:11 +05303573 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID:
3574 ath6kl_dbg(ATH6KL_DBG_WMI,
3575 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3576 ret = ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif);
3577 break;
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003578 case WMI_REMAIN_ON_CHNL_EVENTID:
3579 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303580 ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003581 break;
3582 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3583 ath6kl_dbg(ATH6KL_DBG_WMI,
3584 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
Jouni Malinenf9e5f052011-08-30 21:57:58 +03003585 ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303586 len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003587 break;
3588 case WMI_TX_STATUS_EVENTID:
3589 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303590 ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003591 break;
3592 case WMI_RX_PROBE_REQ_EVENTID:
3593 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303594 ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003595 break;
3596 case WMI_P2P_CAPABILITIES_EVENTID:
3597 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
3598 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
3599 break;
3600 case WMI_RX_ACTION_EVENTID:
3601 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
Vasanthakumar Thiagarajan240d2792011-10-25 19:34:13 +05303602 ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif);
Jouni Malinen6465ddc2011-08-30 21:57:54 +03003603 break;
3604 case WMI_P2P_INFO_EVENTID:
3605 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
3606 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
3607 break;
Kalle Valobdcd8172011-07-18 00:22:30 +03003608 default:
3609 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id);
Kalle Valobdcd8172011-07-18 00:22:30 +03003610 ret = -EINVAL;
3611 break;
3612 }
3613
3614 dev_kfree_skb(skb);
3615
3616 return ret;
3617}
3618
Kalle Valoc89c5912011-10-27 18:48:00 +03003619void ath6kl_wmi_reset(struct wmi *wmi)
Kalle Valobdcd8172011-07-18 00:22:30 +03003620{
Kalle Valobdcd8172011-07-18 00:22:30 +03003621 spin_lock_bh(&wmi->lock);
3622
3623 wmi->fat_pipe_exist = 0;
3624 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
3625
3626 spin_unlock_bh(&wmi->lock);
3627}
3628
Vasanthakumar Thiagarajan28657852011-07-21 12:00:49 +05303629void *ath6kl_wmi_init(struct ath6kl *dev)
Kalle Valobdcd8172011-07-18 00:22:30 +03003630{
3631 struct wmi *wmi;
3632
3633 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
3634 if (!wmi)
3635 return NULL;
3636
3637 spin_lock_init(&wmi->lock);
3638
3639 wmi->parent_dev = dev;
3640
Kalle Valobdcd8172011-07-18 00:22:30 +03003641 wmi->pwr_mode = REC_POWER;
Kalle Valobdcd8172011-07-18 00:22:30 +03003642
Kalle Valoc89c5912011-10-27 18:48:00 +03003643 ath6kl_wmi_reset(wmi);
Kalle Valobdcd8172011-07-18 00:22:30 +03003644
3645 return wmi;
3646}
3647
3648void ath6kl_wmi_shutdown(struct wmi *wmi)
3649{
3650 if (!wmi)
3651 return;
3652
Jouni Malinena0df5db2011-08-30 21:58:02 +03003653 kfree(wmi->last_mgmt_tx_frame);
Kalle Valobdcd8172011-07-18 00:22:30 +03003654 kfree(wmi);
3655}