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