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