blob: 939d86bf6ca12289278325f729959cbd325add5b [file] [log] [blame]
Michal Kaziorca996ec2014-12-03 10:11:32 +02001/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2014 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17#include "core.h"
18#include "debug.h"
19#include "hw.h"
Michal Kazior81a9a172015-03-05 16:02:17 +020020#include "mac.h"
Michal Kaziorca996ec2014-12-03 10:11:32 +020021#include "wmi.h"
22#include "wmi-ops.h"
23#include "wmi-tlv.h"
Michal Kaziorfe3cbdf2015-02-26 13:23:18 +010024#include "p2p.h"
Michal Kaziorca996ec2014-12-03 10:11:32 +020025
26/***************/
27/* TLV helpers */
28/**************/
29
30struct wmi_tlv_policy {
31 size_t min_len;
32};
33
34static const struct wmi_tlv_policy wmi_tlv_policies[] = {
35 [WMI_TLV_TAG_ARRAY_BYTE]
36 = { .min_len = sizeof(u8) },
37 [WMI_TLV_TAG_ARRAY_UINT32]
38 = { .min_len = sizeof(u32) },
39 [WMI_TLV_TAG_STRUCT_SCAN_EVENT]
40 = { .min_len = sizeof(struct wmi_scan_event) },
41 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
42 = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) },
43 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]
44 = { .min_len = sizeof(struct wmi_chan_info_event) },
45 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]
46 = { .min_len = sizeof(struct wmi_vdev_start_response_event) },
47 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]
48 = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
49 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT]
50 = { .min_len = sizeof(struct wmi_host_swba_event) },
51 [WMI_TLV_TAG_STRUCT_TIM_INFO]
52 = { .min_len = sizeof(struct wmi_tim_info) },
53 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]
54 = { .min_len = sizeof(struct wmi_p2p_noa_info) },
55 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT]
56 = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) },
57 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES]
58 = { .min_len = sizeof(struct hal_reg_capabilities) },
59 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ]
60 = { .min_len = sizeof(struct wlan_host_mem_req) },
61 [WMI_TLV_TAG_STRUCT_READY_EVENT]
62 = { .min_len = sizeof(struct wmi_tlv_rdy_ev) },
Michal Kazior6bf12062015-01-13 16:30:10 +020063 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]
64 = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
Michal Kazior04de6c62015-01-24 12:14:47 +020065 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
66 = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
Michal Kaziorfe3cbdf2015-02-26 13:23:18 +010067 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
68 = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
Michal Kaziorca996ec2014-12-03 10:11:32 +020069};
70
71static int
72ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len,
73 int (*iter)(struct ath10k *ar, u16 tag, u16 len,
74 const void *ptr, void *data),
75 void *data)
76{
77 const void *begin = ptr;
78 const struct wmi_tlv *tlv;
79 u16 tlv_tag, tlv_len;
80 int ret;
81
82 while (len > 0) {
83 if (len < sizeof(*tlv)) {
84 ath10k_dbg(ar, ATH10K_DBG_WMI,
85 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
86 ptr - begin, len, sizeof(*tlv));
87 return -EINVAL;
88 }
89
90 tlv = ptr;
91 tlv_tag = __le16_to_cpu(tlv->tag);
92 tlv_len = __le16_to_cpu(tlv->len);
93 ptr += sizeof(*tlv);
94 len -= sizeof(*tlv);
95
96 if (tlv_len > len) {
97 ath10k_dbg(ar, ATH10K_DBG_WMI,
98 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
99 tlv_tag, ptr - begin, len, tlv_len);
100 return -EINVAL;
101 }
102
103 if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
104 wmi_tlv_policies[tlv_tag].min_len &&
105 wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
106 ath10k_dbg(ar, ATH10K_DBG_WMI,
107 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
108 tlv_tag, ptr - begin, tlv_len,
109 wmi_tlv_policies[tlv_tag].min_len);
110 return -EINVAL;
111 }
112
113 ret = iter(ar, tlv_tag, tlv_len, ptr, data);
114 if (ret)
115 return ret;
116
117 ptr += tlv_len;
118 len -= tlv_len;
119 }
120
121 return 0;
122}
123
124static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len,
125 const void *ptr, void *data)
126{
127 const void **tb = data;
128
129 if (tag < WMI_TLV_TAG_MAX)
130 tb[tag] = ptr;
131
132 return 0;
133}
134
135static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb,
136 const void *ptr, size_t len)
137{
138 return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse,
139 (void *)tb);
140}
141
142static const void **
143ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
144 size_t len, gfp_t gfp)
145{
146 const void **tb;
147 int ret;
148
149 tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
150 if (!tb)
151 return ERR_PTR(-ENOMEM);
152
153 ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len);
154 if (ret) {
155 kfree(tb);
156 return ERR_PTR(ret);
157 }
158
159 return tb;
160}
161
162static u16 ath10k_wmi_tlv_len(const void *ptr)
163{
164 return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len);
165}
166
Michal Kazior6bf12062015-01-13 16:30:10 +0200167/**************/
168/* TLV events */
169/**************/
170static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar,
171 struct sk_buff *skb)
172{
173 const void **tb;
174 const struct wmi_tlv_bcn_tx_status_ev *ev;
Michal Kazior81a9a172015-03-05 16:02:17 +0200175 struct ath10k_vif *arvif;
Michal Kazior6bf12062015-01-13 16:30:10 +0200176 u32 vdev_id, tx_status;
177 int ret;
178
179 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
180 if (IS_ERR(tb)) {
181 ret = PTR_ERR(tb);
182 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
183 return ret;
184 }
185
186 ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT];
187 if (!ev) {
188 kfree(tb);
189 return -EPROTO;
190 }
191
192 tx_status = __le32_to_cpu(ev->tx_status);
193 vdev_id = __le32_to_cpu(ev->vdev_id);
194
195 switch (tx_status) {
196 case WMI_TLV_BCN_TX_STATUS_OK:
197 break;
198 case WMI_TLV_BCN_TX_STATUS_XRETRY:
199 case WMI_TLV_BCN_TX_STATUS_DROP:
200 case WMI_TLV_BCN_TX_STATUS_FILTERED:
201 /* FIXME: It's probably worth telling mac80211 to stop the
202 * interface as it is crippled.
203 */
204 ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d",
205 vdev_id, tx_status);
206 break;
207 }
208
Michal Kazior81a9a172015-03-05 16:02:17 +0200209 spin_lock_bh(&ar->data_lock);
210 arvif = ath10k_get_arvif(ar, vdev_id);
211 if (arvif && arvif->is_up)
212 ieee80211_queue_work(ar->hw, &arvif->ap_csa_work);
213 spin_unlock_bh(&ar->data_lock);
214
Michal Kazior6bf12062015-01-13 16:30:10 +0200215 kfree(tb);
216 return 0;
217}
218
Michal Kazior04de6c62015-01-24 12:14:47 +0200219static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar,
220 struct sk_buff *skb)
221{
222 const void **tb;
223 const struct wmi_tlv_diag_data_ev *ev;
224 const struct wmi_tlv_diag_item *item;
225 const void *data;
226 int ret, num_items, len;
227
228 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
229 if (IS_ERR(tb)) {
230 ret = PTR_ERR(tb);
231 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
232 return ret;
233 }
234
235 ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT];
236 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
237 if (!ev || !data) {
238 kfree(tb);
239 return -EPROTO;
240 }
241
242 num_items = __le32_to_cpu(ev->num_items);
243 len = ath10k_wmi_tlv_len(data);
244
245 while (num_items--) {
246 if (len == 0)
247 break;
248 if (len < sizeof(*item)) {
249 ath10k_warn(ar, "failed to parse diag data: can't fit item header\n");
250 break;
251 }
252
253 item = data;
254
255 if (len < sizeof(*item) + __le16_to_cpu(item->len)) {
256 ath10k_warn(ar, "failed to parse diag data: item is too long\n");
257 break;
258 }
259
260 trace_ath10k_wmi_diag_container(ar,
261 item->type,
262 __le32_to_cpu(item->timestamp),
263 __le32_to_cpu(item->code),
264 __le16_to_cpu(item->len),
265 item->payload);
266
267 len -= sizeof(*item);
268 len -= roundup(__le16_to_cpu(item->len), 4);
269
270 data += sizeof(*item);
271 data += roundup(__le16_to_cpu(item->len), 4);
272 }
273
274 if (num_items != -1 || len != 0)
275 ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n",
276 num_items, len);
277
278 kfree(tb);
279 return 0;
280}
281
Michal Kaziorc3113c32015-01-24 12:14:47 +0200282static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
283 struct sk_buff *skb)
284{
285 const void **tb;
286 const void *data;
287 int ret, len;
288
289 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
290 if (IS_ERR(tb)) {
291 ret = PTR_ERR(tb);
292 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
293 return ret;
294 }
295
296 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
297 if (!data) {
298 kfree(tb);
299 return -EPROTO;
300 }
301 len = ath10k_wmi_tlv_len(data);
302
303 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len);
304 trace_ath10k_wmi_diag(ar, data, len);
305
306 kfree(tb);
307 return 0;
308}
309
Michal Kaziorfe3cbdf2015-02-26 13:23:18 +0100310static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
311 struct sk_buff *skb)
312{
313 const void **tb;
314 const struct wmi_tlv_p2p_noa_ev *ev;
315 const struct wmi_p2p_noa_info *noa;
316 int ret, vdev_id;
317
318 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
319 if (IS_ERR(tb)) {
320 ret = PTR_ERR(tb);
321 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
322 return ret;
323 }
324
325 ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
326 noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
327
328 if (!ev || !noa) {
329 kfree(tb);
330 return -EPROTO;
331 }
332
333 vdev_id = __le32_to_cpu(ev->vdev_id);
334
335 ath10k_dbg(ar, ATH10K_DBG_WMI,
336 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
337 vdev_id, noa->num_descriptors);
338
339 ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
340
341 kfree(tb);
342 return 0;
343}
344
Michal Kaziorca996ec2014-12-03 10:11:32 +0200345/***********/
346/* TLV ops */
347/***********/
348
349static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
350{
351 struct wmi_cmd_hdr *cmd_hdr;
352 enum wmi_tlv_event_id id;
353
354 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
355 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
356
357 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
358 return;
359
360 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
361
362 switch (id) {
363 case WMI_TLV_MGMT_RX_EVENTID:
364 ath10k_wmi_event_mgmt_rx(ar, skb);
365 /* mgmt_rx() owns the skb now! */
366 return;
367 case WMI_TLV_SCAN_EVENTID:
368 ath10k_wmi_event_scan(ar, skb);
369 break;
370 case WMI_TLV_CHAN_INFO_EVENTID:
371 ath10k_wmi_event_chan_info(ar, skb);
372 break;
373 case WMI_TLV_ECHO_EVENTID:
374 ath10k_wmi_event_echo(ar, skb);
375 break;
376 case WMI_TLV_DEBUG_MESG_EVENTID:
377 ath10k_wmi_event_debug_mesg(ar, skb);
378 break;
379 case WMI_TLV_UPDATE_STATS_EVENTID:
380 ath10k_wmi_event_update_stats(ar, skb);
381 break;
382 case WMI_TLV_VDEV_START_RESP_EVENTID:
383 ath10k_wmi_event_vdev_start_resp(ar, skb);
384 break;
385 case WMI_TLV_VDEV_STOPPED_EVENTID:
386 ath10k_wmi_event_vdev_stopped(ar, skb);
387 break;
388 case WMI_TLV_PEER_STA_KICKOUT_EVENTID:
389 ath10k_wmi_event_peer_sta_kickout(ar, skb);
390 break;
391 case WMI_TLV_HOST_SWBA_EVENTID:
392 ath10k_wmi_event_host_swba(ar, skb);
393 break;
394 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID:
395 ath10k_wmi_event_tbttoffset_update(ar, skb);
396 break;
397 case WMI_TLV_PHYERR_EVENTID:
398 ath10k_wmi_event_phyerr(ar, skb);
399 break;
400 case WMI_TLV_ROAM_EVENTID:
401 ath10k_wmi_event_roam(ar, skb);
402 break;
403 case WMI_TLV_PROFILE_MATCH:
404 ath10k_wmi_event_profile_match(ar, skb);
405 break;
406 case WMI_TLV_DEBUG_PRINT_EVENTID:
407 ath10k_wmi_event_debug_print(ar, skb);
408 break;
409 case WMI_TLV_PDEV_QVIT_EVENTID:
410 ath10k_wmi_event_pdev_qvit(ar, skb);
411 break;
412 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID:
413 ath10k_wmi_event_wlan_profile_data(ar, skb);
414 break;
415 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID:
416 ath10k_wmi_event_rtt_measurement_report(ar, skb);
417 break;
418 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID:
419 ath10k_wmi_event_tsf_measurement_report(ar, skb);
420 break;
421 case WMI_TLV_RTT_ERROR_REPORT_EVENTID:
422 ath10k_wmi_event_rtt_error_report(ar, skb);
423 break;
424 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID:
425 ath10k_wmi_event_wow_wakeup_host(ar, skb);
426 break;
427 case WMI_TLV_DCS_INTERFERENCE_EVENTID:
428 ath10k_wmi_event_dcs_interference(ar, skb);
429 break;
430 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID:
431 ath10k_wmi_event_pdev_tpc_config(ar, skb);
432 break;
433 case WMI_TLV_PDEV_FTM_INTG_EVENTID:
434 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
435 break;
436 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID:
437 ath10k_wmi_event_gtk_offload_status(ar, skb);
438 break;
439 case WMI_TLV_GTK_REKEY_FAIL_EVENTID:
440 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
441 break;
442 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID:
443 ath10k_wmi_event_delba_complete(ar, skb);
444 break;
445 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID:
446 ath10k_wmi_event_addba_complete(ar, skb);
447 break;
448 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
449 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
450 break;
451 case WMI_TLV_SERVICE_READY_EVENTID:
452 ath10k_wmi_event_service_ready(ar, skb);
453 break;
454 case WMI_TLV_READY_EVENTID:
455 ath10k_wmi_event_ready(ar, skb);
456 break;
Michal Kazior6bf12062015-01-13 16:30:10 +0200457 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID:
458 ath10k_wmi_tlv_event_bcn_tx_status(ar, skb);
459 break;
Michal Kazior04de6c62015-01-24 12:14:47 +0200460 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID:
461 ath10k_wmi_tlv_event_diag_data(ar, skb);
462 break;
Michal Kaziorc3113c32015-01-24 12:14:47 +0200463 case WMI_TLV_DIAG_EVENTID:
464 ath10k_wmi_tlv_event_diag(ar, skb);
465 break;
Michal Kaziorfe3cbdf2015-02-26 13:23:18 +0100466 case WMI_TLV_P2P_NOA_EVENTID:
467 ath10k_wmi_tlv_event_p2p_noa(ar, skb);
468 break;
Michal Kaziorca996ec2014-12-03 10:11:32 +0200469 default:
470 ath10k_warn(ar, "Unknown eventid: %d\n", id);
471 break;
472 }
473
474 dev_kfree_skb(skb);
475}
476
477static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar,
478 struct sk_buff *skb,
479 struct wmi_scan_ev_arg *arg)
480{
481 const void **tb;
482 const struct wmi_scan_event *ev;
483 int ret;
484
485 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
486 if (IS_ERR(tb)) {
487 ret = PTR_ERR(tb);
488 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
489 return ret;
490 }
491
492 ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT];
493 if (!ev) {
494 kfree(tb);
495 return -EPROTO;
496 }
497
498 arg->event_type = ev->event_type;
499 arg->reason = ev->reason;
500 arg->channel_freq = ev->channel_freq;
501 arg->scan_req_id = ev->scan_req_id;
502 arg->scan_id = ev->scan_id;
503 arg->vdev_id = ev->vdev_id;
504
505 kfree(tb);
506 return 0;
507}
508
509static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar,
510 struct sk_buff *skb,
511 struct wmi_mgmt_rx_ev_arg *arg)
512{
513 const void **tb;
514 const struct wmi_tlv_mgmt_rx_ev *ev;
515 const u8 *frame;
516 u32 msdu_len;
517 int ret;
518
519 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
520 if (IS_ERR(tb)) {
521 ret = PTR_ERR(tb);
522 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
523 return ret;
524 }
525
526 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR];
527 frame = tb[WMI_TLV_TAG_ARRAY_BYTE];
528
529 if (!ev || !frame) {
530 kfree(tb);
531 return -EPROTO;
532 }
533
534 arg->channel = ev->channel;
535 arg->buf_len = ev->buf_len;
536 arg->status = ev->status;
537 arg->snr = ev->snr;
538 arg->phy_mode = ev->phy_mode;
539 arg->rate = ev->rate;
540
541 msdu_len = __le32_to_cpu(arg->buf_len);
542
543 if (skb->len < (frame - skb->data) + msdu_len) {
544 kfree(tb);
545 return -EPROTO;
546 }
547
548 /* shift the sk_buff to point to `frame` */
549 skb_trim(skb, 0);
550 skb_put(skb, frame - skb->data);
551 skb_pull(skb, frame - skb->data);
552 skb_put(skb, msdu_len);
553
554 kfree(tb);
555 return 0;
556}
557
558static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar,
559 struct sk_buff *skb,
560 struct wmi_ch_info_ev_arg *arg)
561{
562 const void **tb;
563 const struct wmi_chan_info_event *ev;
564 int ret;
565
566 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
567 if (IS_ERR(tb)) {
568 ret = PTR_ERR(tb);
569 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
570 return ret;
571 }
572
573 ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT];
574 if (!ev) {
575 kfree(tb);
576 return -EPROTO;
577 }
578
579 arg->err_code = ev->err_code;
580 arg->freq = ev->freq;
581 arg->cmd_flags = ev->cmd_flags;
582 arg->noise_floor = ev->noise_floor;
583 arg->rx_clear_count = ev->rx_clear_count;
584 arg->cycle_count = ev->cycle_count;
585
586 kfree(tb);
587 return 0;
588}
589
590static int
591ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
592 struct wmi_vdev_start_ev_arg *arg)
593{
594 const void **tb;
595 const struct wmi_vdev_start_response_event *ev;
596 int ret;
597
598 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
599 if (IS_ERR(tb)) {
600 ret = PTR_ERR(tb);
601 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
602 return ret;
603 }
604
605 ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT];
606 if (!ev) {
607 kfree(tb);
608 return -EPROTO;
609 }
610
611 skb_pull(skb, sizeof(*ev));
612 arg->vdev_id = ev->vdev_id;
613 arg->req_id = ev->req_id;
614 arg->resp_type = ev->resp_type;
615 arg->status = ev->status;
616
617 kfree(tb);
618 return 0;
619}
620
621static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar,
622 struct sk_buff *skb,
623 struct wmi_peer_kick_ev_arg *arg)
624{
625 const void **tb;
626 const struct wmi_peer_sta_kickout_event *ev;
627 int ret;
628
629 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
630 if (IS_ERR(tb)) {
631 ret = PTR_ERR(tb);
632 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
633 return ret;
634 }
635
636 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT];
637 if (!ev) {
638 kfree(tb);
639 return -EPROTO;
640 }
641
642 arg->mac_addr = ev->peer_macaddr.addr;
643
644 kfree(tb);
645 return 0;
646}
647
648struct wmi_tlv_swba_parse {
649 const struct wmi_host_swba_event *ev;
650 bool tim_done;
651 bool noa_done;
652 size_t n_tim;
653 size_t n_noa;
654 struct wmi_swba_ev_arg *arg;
655};
656
657static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len,
658 const void *ptr, void *data)
659{
660 struct wmi_tlv_swba_parse *swba = data;
661
662 if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO)
663 return -EPROTO;
664
665 if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info))
666 return -ENOBUFS;
667
668 swba->arg->tim_info[swba->n_tim++] = ptr;
669 return 0;
670}
671
672static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len,
673 const void *ptr, void *data)
674{
675 struct wmi_tlv_swba_parse *swba = data;
676
677 if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO)
678 return -EPROTO;
679
680 if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info))
681 return -ENOBUFS;
682
683 swba->arg->noa_info[swba->n_noa++] = ptr;
684 return 0;
685}
686
687static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len,
688 const void *ptr, void *data)
689{
690 struct wmi_tlv_swba_parse *swba = data;
691 int ret;
692
693 switch (tag) {
694 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT:
695 swba->ev = ptr;
696 break;
697 case WMI_TLV_TAG_ARRAY_STRUCT:
698 if (!swba->tim_done) {
699 swba->tim_done = true;
700 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
701 ath10k_wmi_tlv_swba_tim_parse,
702 swba);
703 if (ret)
704 return ret;
705 } else if (!swba->noa_done) {
706 swba->noa_done = true;
707 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
708 ath10k_wmi_tlv_swba_noa_parse,
709 swba);
710 if (ret)
711 return ret;
712 }
713 break;
714 default:
715 break;
716 }
717 return 0;
718}
719
720static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar,
721 struct sk_buff *skb,
722 struct wmi_swba_ev_arg *arg)
723{
724 struct wmi_tlv_swba_parse swba = { .arg = arg };
725 u32 map;
726 size_t n_vdevs;
727 int ret;
728
729 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
730 ath10k_wmi_tlv_swba_parse, &swba);
731 if (ret) {
732 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
733 return ret;
734 }
735
736 if (!swba.ev)
737 return -EPROTO;
738
739 arg->vdev_map = swba.ev->vdev_map;
740
741 for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1)
742 if (map & BIT(0))
743 n_vdevs++;
744
745 if (n_vdevs != swba.n_tim ||
746 n_vdevs != swba.n_noa)
747 return -EPROTO;
748
749 return 0;
750}
751
752static int ath10k_wmi_tlv_op_pull_phyerr_ev(struct ath10k *ar,
753 struct sk_buff *skb,
754 struct wmi_phyerr_ev_arg *arg)
755{
756 const void **tb;
757 const struct wmi_tlv_phyerr_ev *ev;
758 const void *phyerrs;
759 int ret;
760
761 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
762 if (IS_ERR(tb)) {
763 ret = PTR_ERR(tb);
764 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
765 return ret;
766 }
767
768 ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR];
769 phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE];
770
771 if (!ev || !phyerrs) {
772 kfree(tb);
773 return -EPROTO;
774 }
775
776 arg->num_phyerrs = ev->num_phyerrs;
777 arg->tsf_l32 = ev->tsf_l32;
778 arg->tsf_u32 = ev->tsf_u32;
779 arg->buf_len = ev->buf_len;
780 arg->phyerrs = phyerrs;
781
782 kfree(tb);
783 return 0;
784}
785
786#define WMI_TLV_ABI_VER_NS0 0x5F414351
787#define WMI_TLV_ABI_VER_NS1 0x00004C4D
788#define WMI_TLV_ABI_VER_NS2 0x00000000
789#define WMI_TLV_ABI_VER_NS3 0x00000000
790
791#define WMI_TLV_ABI_VER0_MAJOR 1
792#define WMI_TLV_ABI_VER0_MINOR 0
793#define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
794 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
795#define WMI_TLV_ABI_VER1 53
796
797static int
798ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len,
799 const void *ptr, void *data)
800{
801 struct wmi_svc_rdy_ev_arg *arg = data;
802 int i;
803
804 if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ)
805 return -EPROTO;
806
807 for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) {
808 if (!arg->mem_reqs[i]) {
809 arg->mem_reqs[i] = ptr;
810 return 0;
811 }
812 }
813
814 return -ENOMEM;
815}
816
817static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar,
818 struct sk_buff *skb,
819 struct wmi_svc_rdy_ev_arg *arg)
820{
821 const void **tb;
822 const struct hal_reg_capabilities *reg;
823 const struct wmi_tlv_svc_rdy_ev *ev;
824 const __le32 *svc_bmap;
825 const struct wlan_host_mem_req *mem_reqs;
826 int ret;
827
828 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
829 if (IS_ERR(tb)) {
830 ret = PTR_ERR(tb);
831 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
832 return ret;
833 }
834
835 ev = tb[WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT];
836 reg = tb[WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES];
837 svc_bmap = tb[WMI_TLV_TAG_ARRAY_UINT32];
838 mem_reqs = tb[WMI_TLV_TAG_ARRAY_STRUCT];
839
840 if (!ev || !reg || !svc_bmap || !mem_reqs) {
841 kfree(tb);
842 return -EPROTO;
843 }
844
845 /* This is an internal ABI compatibility check for WMI TLV so check it
846 * here instead of the generic WMI code.
847 */
848 ath10k_dbg(ar, ATH10K_DBG_WMI,
849 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
850 __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0,
851 __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0,
852 __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1,
853 __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2,
854 __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3);
855
856 if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 ||
857 __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 ||
858 __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 ||
859 __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 ||
860 __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) {
861 kfree(tb);
862 return -ENOTSUPP;
863 }
864
865 arg->min_tx_power = ev->hw_min_tx_power;
866 arg->max_tx_power = ev->hw_max_tx_power;
867 arg->ht_cap = ev->ht_cap_info;
868 arg->vht_cap = ev->vht_cap_info;
869 arg->sw_ver0 = ev->abi.abi_ver0;
870 arg->sw_ver1 = ev->abi.abi_ver1;
871 arg->fw_build = ev->fw_build_vers;
872 arg->phy_capab = ev->phy_capability;
873 arg->num_rf_chains = ev->num_rf_chains;
874 arg->eeprom_rd = reg->eeprom_rd;
875 arg->num_mem_reqs = ev->num_mem_reqs;
876 arg->service_map = svc_bmap;
877 arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap);
878
879 ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs),
880 ath10k_wmi_tlv_parse_mem_reqs, arg);
881 if (ret) {
882 kfree(tb);
883 ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret);
884 return ret;
885 }
886
887 kfree(tb);
888 return 0;
889}
890
891static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar,
892 struct sk_buff *skb,
893 struct wmi_rdy_ev_arg *arg)
894{
895 const void **tb;
896 const struct wmi_tlv_rdy_ev *ev;
897 int ret;
898
899 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
900 if (IS_ERR(tb)) {
901 ret = PTR_ERR(tb);
902 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
903 return ret;
904 }
905
906 ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT];
907 if (!ev) {
908 kfree(tb);
909 return -EPROTO;
910 }
911
912 arg->sw_version = ev->abi.abi_ver0;
913 arg->abi_version = ev->abi.abi_ver1;
914 arg->status = ev->status;
915 arg->mac_addr = ev->mac_addr.addr;
916
917 kfree(tb);
918 return 0;
919}
920
Michal Kazior7777d8c2015-02-15 16:50:41 +0200921static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src,
922 struct ath10k_fw_stats_vdev *dst)
923{
924 int i;
925
926 dst->vdev_id = __le32_to_cpu(src->vdev_id);
927 dst->beacon_snr = __le32_to_cpu(src->beacon_snr);
928 dst->data_snr = __le32_to_cpu(src->data_snr);
929 dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames);
930 dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail);
931 dst->num_rts_success = __le32_to_cpu(src->num_rts_success);
932 dst->num_rx_err = __le32_to_cpu(src->num_rx_err);
933 dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard);
934 dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked);
935
936 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++)
937 dst->num_tx_frames[i] =
938 __le32_to_cpu(src->num_tx_frames[i]);
939
940 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++)
941 dst->num_tx_frames_retries[i] =
942 __le32_to_cpu(src->num_tx_frames_retries[i]);
943
944 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++)
945 dst->num_tx_frames_failures[i] =
946 __le32_to_cpu(src->num_tx_frames_failures[i]);
947
948 for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++)
949 dst->tx_rate_history[i] =
950 __le32_to_cpu(src->tx_rate_history[i]);
951
952 for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++)
953 dst->beacon_rssi_history[i] =
954 __le32_to_cpu(src->beacon_rssi_history[i]);
955}
956
Michal Kaziorca996ec2014-12-03 10:11:32 +0200957static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
958 struct sk_buff *skb,
959 struct ath10k_fw_stats *stats)
960{
961 const void **tb;
Michal Kazior7777d8c2015-02-15 16:50:41 +0200962 const struct wmi_tlv_stats_ev *ev;
Michal Kaziorca996ec2014-12-03 10:11:32 +0200963 const void *data;
Michal Kazior7777d8c2015-02-15 16:50:41 +0200964 u32 num_pdev_stats;
965 u32 num_vdev_stats;
966 u32 num_peer_stats;
967 u32 num_bcnflt_stats;
968 u32 num_chan_stats;
Michal Kaziorca996ec2014-12-03 10:11:32 +0200969 size_t data_len;
970 int ret;
Michal Kazior7777d8c2015-02-15 16:50:41 +0200971 int i;
Michal Kaziorca996ec2014-12-03 10:11:32 +0200972
973 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
974 if (IS_ERR(tb)) {
975 ret = PTR_ERR(tb);
976 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
977 return ret;
978 }
979
980 ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT];
981 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
982
983 if (!ev || !data) {
984 kfree(tb);
985 return -EPROTO;
986 }
987
988 data_len = ath10k_wmi_tlv_len(data);
989 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
990 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
991 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
Michal Kazior7777d8c2015-02-15 16:50:41 +0200992 num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
993 num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
Michal Kaziorca996ec2014-12-03 10:11:32 +0200994
Michal Kazior7777d8c2015-02-15 16:50:41 +0200995 ath10k_dbg(ar, ATH10K_DBG_WMI,
996 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i\n",
997 num_pdev_stats, num_vdev_stats, num_peer_stats,
998 num_bcnflt_stats, num_chan_stats);
999
1000 for (i = 0; i < num_pdev_stats; i++) {
1001 const struct wmi_pdev_stats *src;
1002 struct ath10k_fw_stats_pdev *dst;
1003
1004 src = data;
1005 if (data_len < sizeof(*src))
1006 return -EPROTO;
1007
1008 data += sizeof(*src);
1009 data_len -= sizeof(*src);
1010
1011 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1012 if (!dst)
1013 continue;
1014
1015 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1016 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1017 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1018 list_add_tail(&dst->list, &stats->pdevs);
1019 }
1020
1021 for (i = 0; i < num_vdev_stats; i++) {
1022 const struct wmi_tlv_vdev_stats *src;
1023 struct ath10k_fw_stats_vdev *dst;
1024
1025 src = data;
1026 if (data_len < sizeof(*src))
1027 return -EPROTO;
1028
1029 data += sizeof(*src);
1030 data_len -= sizeof(*src);
1031
1032 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1033 if (!dst)
1034 continue;
1035
1036 ath10k_wmi_tlv_pull_vdev_stats(src, dst);
1037 list_add_tail(&dst->list, &stats->vdevs);
1038 }
1039
1040 for (i = 0; i < num_peer_stats; i++) {
1041 const struct wmi_10x_peer_stats *src;
1042 struct ath10k_fw_stats_peer *dst;
1043
1044 src = data;
1045 if (data_len < sizeof(*src))
1046 return -EPROTO;
1047
1048 data += sizeof(*src);
1049 data_len -= sizeof(*src);
1050
1051 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1052 if (!dst)
1053 continue;
1054
1055 ath10k_wmi_pull_peer_stats(&src->old, dst);
1056 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1057 list_add_tail(&dst->list, &stats->peers);
1058 }
Michal Kaziorca996ec2014-12-03 10:11:32 +02001059
1060 kfree(tb);
1061 return 0;
1062}
1063
1064static struct sk_buff *
1065ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
1066{
1067 struct wmi_tlv_pdev_suspend *cmd;
1068 struct wmi_tlv *tlv;
1069 struct sk_buff *skb;
1070
1071 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1072 if (!skb)
1073 return ERR_PTR(-ENOMEM);
1074
1075 tlv = (void *)skb->data;
1076 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD);
1077 tlv->len = __cpu_to_le16(sizeof(*cmd));
1078 cmd = (void *)tlv->value;
1079 cmd->opt = __cpu_to_le32(opt);
1080
1081 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n");
1082 return skb;
1083}
1084
1085static struct sk_buff *
1086ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar)
1087{
1088 struct wmi_tlv_resume_cmd *cmd;
1089 struct wmi_tlv *tlv;
1090 struct sk_buff *skb;
1091
1092 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1093 if (!skb)
1094 return ERR_PTR(-ENOMEM);
1095
1096 tlv = (void *)skb->data;
1097 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD);
1098 tlv->len = __cpu_to_le16(sizeof(*cmd));
1099 cmd = (void *)tlv->value;
1100 cmd->reserved = __cpu_to_le32(0);
1101
1102 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n");
1103 return skb;
1104}
1105
1106static struct sk_buff *
1107ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar,
1108 u16 rd, u16 rd2g, u16 rd5g,
1109 u16 ctl2g, u16 ctl5g,
1110 enum wmi_dfs_region dfs_reg)
1111{
1112 struct wmi_tlv_pdev_set_rd_cmd *cmd;
1113 struct wmi_tlv *tlv;
1114 struct sk_buff *skb;
1115
1116 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1117 if (!skb)
1118 return ERR_PTR(-ENOMEM);
1119
1120 tlv = (void *)skb->data;
1121 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD);
1122 tlv->len = __cpu_to_le16(sizeof(*cmd));
1123 cmd = (void *)tlv->value;
1124 cmd->regd = __cpu_to_le32(rd);
1125 cmd->regd_2ghz = __cpu_to_le32(rd2g);
1126 cmd->regd_5ghz = __cpu_to_le32(rd5g);
1127 cmd->conform_limit_2ghz = __cpu_to_le32(rd2g);
1128 cmd->conform_limit_5ghz = __cpu_to_le32(rd5g);
1129
1130 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n");
1131 return skb;
1132}
1133
1134static struct sk_buff *
1135ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id,
1136 u32 param_value)
1137{
1138 struct wmi_tlv_pdev_set_param_cmd *cmd;
1139 struct wmi_tlv *tlv;
1140 struct sk_buff *skb;
1141
1142 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1143 if (!skb)
1144 return ERR_PTR(-ENOMEM);
1145
1146 tlv = (void *)skb->data;
1147 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD);
1148 tlv->len = __cpu_to_le16(sizeof(*cmd));
1149 cmd = (void *)tlv->value;
1150 cmd->param_id = __cpu_to_le32(param_id);
1151 cmd->param_value = __cpu_to_le32(param_value);
1152
1153 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param\n");
1154 return skb;
1155}
1156
1157static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
1158{
1159 struct sk_buff *skb;
1160 struct wmi_tlv *tlv;
1161 struct wmi_tlv_init_cmd *cmd;
1162 struct wmi_tlv_resource_config *cfg;
1163 struct wmi_host_mem_chunks *chunks;
1164 size_t len, chunks_len;
1165 void *ptr;
1166
1167 chunks_len = ar->wmi.num_mem_chunks * sizeof(struct host_memory_chunk);
1168 len = (sizeof(*tlv) + sizeof(*cmd)) +
1169 (sizeof(*tlv) + sizeof(*cfg)) +
1170 (sizeof(*tlv) + chunks_len);
1171
1172 skb = ath10k_wmi_alloc_skb(ar, len);
1173 if (!skb)
1174 return ERR_PTR(-ENOMEM);
1175
1176 ptr = skb->data;
1177
1178 tlv = ptr;
1179 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD);
1180 tlv->len = __cpu_to_le16(sizeof(*cmd));
1181 cmd = (void *)tlv->value;
1182 ptr += sizeof(*tlv);
1183 ptr += sizeof(*cmd);
1184
1185 tlv = ptr;
1186 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG);
1187 tlv->len = __cpu_to_le16(sizeof(*cfg));
1188 cfg = (void *)tlv->value;
1189 ptr += sizeof(*tlv);
1190 ptr += sizeof(*cfg);
1191
1192 tlv = ptr;
1193 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1194 tlv->len = __cpu_to_le16(chunks_len);
1195 chunks = (void *)tlv->value;
1196
1197 ptr += sizeof(*tlv);
1198 ptr += chunks_len;
1199
1200 cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0);
1201 cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1);
1202 cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0);
1203 cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1);
1204 cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2);
1205 cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3);
1206 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
1207
1208 cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1209 cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS);
Michal Kaziorc5450702015-01-24 12:14:48 +02001210
1211 if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) {
1212 cfg->num_offload_peers = __cpu_to_le32(3);
1213 cfg->num_offload_reorder_bufs = __cpu_to_le32(3);
1214 } else {
1215 cfg->num_offload_peers = __cpu_to_le32(0);
1216 cfg->num_offload_reorder_bufs = __cpu_to_le32(0);
1217 }
1218
Michal Kaziorca996ec2014-12-03 10:11:32 +02001219 cfg->num_peer_keys = __cpu_to_le32(2);
1220 cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS);
1221 cfg->ast_skid_limit = __cpu_to_le32(0x10);
1222 cfg->tx_chain_mask = __cpu_to_le32(0x7);
1223 cfg->rx_chain_mask = __cpu_to_le32(0x7);
1224 cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64);
1225 cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64);
1226 cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64);
1227 cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28);
1228 cfg->rx_decap_mode = __cpu_to_le32(1);
1229 cfg->scan_max_pending_reqs = __cpu_to_le32(4);
1230 cfg->bmiss_offload_max_vdev = __cpu_to_le32(3);
1231 cfg->roam_offload_max_vdev = __cpu_to_le32(3);
1232 cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8);
1233 cfg->num_mcast_groups = __cpu_to_le32(0);
1234 cfg->num_mcast_table_elems = __cpu_to_le32(0);
1235 cfg->mcast2ucast_mode = __cpu_to_le32(0);
1236 cfg->tx_dbg_log_size = __cpu_to_le32(0x400);
1237 cfg->num_wds_entries = __cpu_to_le32(0x20);
1238 cfg->dma_burst_size = __cpu_to_le32(0);
1239 cfg->mac_aggr_delim = __cpu_to_le32(0);
1240 cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
1241 cfg->vow_config = __cpu_to_le32(0);
1242 cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
1243 cfg->num_msdu_desc = __cpu_to_le32(TARGET_TLV_NUM_MSDU_DESC);
1244 cfg->max_frag_entries = __cpu_to_le32(2);
1245 cfg->num_tdls_vdevs = __cpu_to_le32(1);
1246 cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
1247 cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2);
1248 cfg->num_multicast_filter_entries = __cpu_to_le32(5);
1249 cfg->num_wow_filters = __cpu_to_le32(0x16);
1250 cfg->num_keep_alive_pattern = __cpu_to_le32(6);
1251 cfg->keep_alive_pattern_size = __cpu_to_le32(0);
1252 cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1);
1253 cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1);
1254
1255 ath10k_wmi_put_host_mem_chunks(ar, chunks);
1256
1257 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
1258 return skb;
1259}
1260
1261static struct sk_buff *
1262ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
1263 const struct wmi_start_scan_arg *arg)
1264{
1265 struct wmi_tlv_start_scan_cmd *cmd;
1266 struct wmi_tlv *tlv;
1267 struct sk_buff *skb;
1268 size_t len, chan_len, ssid_len, bssid_len, ie_len;
1269 __le32 *chans;
1270 struct wmi_ssid *ssids;
1271 struct wmi_mac_addr *addrs;
1272 void *ptr;
1273 int i, ret;
1274
1275 ret = ath10k_wmi_start_scan_verify(arg);
1276 if (ret)
1277 return ERR_PTR(ret);
1278
1279 chan_len = arg->n_channels * sizeof(__le32);
1280 ssid_len = arg->n_ssids * sizeof(struct wmi_ssid);
1281 bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
1282 ie_len = roundup(arg->ie_len, 4);
1283 len = (sizeof(*tlv) + sizeof(*cmd)) +
1284 (arg->n_channels ? sizeof(*tlv) + chan_len : 0) +
1285 (arg->n_ssids ? sizeof(*tlv) + ssid_len : 0) +
1286 (arg->n_bssids ? sizeof(*tlv) + bssid_len : 0) +
1287 (arg->ie_len ? sizeof(*tlv) + ie_len : 0);
1288
1289 skb = ath10k_wmi_alloc_skb(ar, len);
1290 if (!skb)
1291 return ERR_PTR(-ENOMEM);
1292
1293 ptr = (void *)skb->data;
1294 tlv = ptr;
1295 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD);
1296 tlv->len = __cpu_to_le16(sizeof(*cmd));
1297 cmd = (void *)tlv->value;
1298
1299 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
1300 cmd->burst_duration_ms = __cpu_to_le32(0);
1301 cmd->num_channels = __cpu_to_le32(arg->n_channels);
1302 cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
1303 cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
1304 cmd->ie_len = __cpu_to_le32(arg->ie_len);
1305 cmd->num_probes = __cpu_to_le32(3);
1306
1307 /* FIXME: There are some scan flag inconsistencies across firmwares,
1308 * e.g. WMI-TLV inverts the logic behind the following flag.
1309 */
1310 cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
1311
1312 ptr += sizeof(*tlv);
1313 ptr += sizeof(*cmd);
1314
1315 tlv = ptr;
1316 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
1317 tlv->len = __cpu_to_le16(chan_len);
1318 chans = (void *)tlv->value;
1319 for (i = 0; i < arg->n_channels; i++)
1320 chans[i] = __cpu_to_le32(arg->channels[i]);
1321
1322 ptr += sizeof(*tlv);
1323 ptr += chan_len;
1324
1325 tlv = ptr;
1326 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1327 tlv->len = __cpu_to_le16(ssid_len);
1328 ssids = (void *)tlv->value;
1329 for (i = 0; i < arg->n_ssids; i++) {
1330 ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len);
1331 memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len);
1332 }
1333
1334 ptr += sizeof(*tlv);
1335 ptr += ssid_len;
1336
1337 tlv = ptr;
1338 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1339 tlv->len = __cpu_to_le16(bssid_len);
1340 addrs = (void *)tlv->value;
1341 for (i = 0; i < arg->n_bssids; i++)
1342 ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid);
1343
1344 ptr += sizeof(*tlv);
1345 ptr += bssid_len;
1346
1347 tlv = ptr;
1348 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1349 tlv->len = __cpu_to_le16(ie_len);
1350 memcpy(tlv->value, arg->ie, arg->ie_len);
1351
1352 ptr += sizeof(*tlv);
1353 ptr += ie_len;
1354
1355 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
1356 return skb;
1357}
1358
1359static struct sk_buff *
1360ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar,
1361 const struct wmi_stop_scan_arg *arg)
1362{
1363 struct wmi_stop_scan_cmd *cmd;
1364 struct wmi_tlv *tlv;
1365 struct sk_buff *skb;
1366 u32 scan_id;
1367 u32 req_id;
1368
1369 if (arg->req_id > 0xFFF)
1370 return ERR_PTR(-EINVAL);
1371 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
1372 return ERR_PTR(-EINVAL);
1373
1374 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1375 if (!skb)
1376 return ERR_PTR(-ENOMEM);
1377
1378 scan_id = arg->u.scan_id;
1379 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
1380
1381 req_id = arg->req_id;
1382 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
1383
1384 tlv = (void *)skb->data;
1385 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD);
1386 tlv->len = __cpu_to_le16(sizeof(*cmd));
1387 cmd = (void *)tlv->value;
1388 cmd->req_type = __cpu_to_le32(arg->req_type);
1389 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
1390 cmd->scan_id = __cpu_to_le32(scan_id);
1391 cmd->scan_req_id = __cpu_to_le32(req_id);
1392
1393 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n");
1394 return skb;
1395}
1396
1397static struct sk_buff *
1398ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar,
1399 u32 vdev_id,
1400 enum wmi_vdev_type vdev_type,
1401 enum wmi_vdev_subtype vdev_subtype,
1402 const u8 mac_addr[ETH_ALEN])
1403{
1404 struct wmi_vdev_create_cmd *cmd;
1405 struct wmi_tlv *tlv;
1406 struct sk_buff *skb;
1407
1408 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1409 if (!skb)
1410 return ERR_PTR(-ENOMEM);
1411
1412 tlv = (void *)skb->data;
1413 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD);
1414 tlv->len = __cpu_to_le16(sizeof(*cmd));
1415 cmd = (void *)tlv->value;
1416 cmd->vdev_id = __cpu_to_le32(vdev_id);
1417 cmd->vdev_type = __cpu_to_le32(vdev_type);
1418 cmd->vdev_subtype = __cpu_to_le32(vdev_subtype);
1419 ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr);
1420
1421 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n");
1422 return skb;
1423}
1424
1425static struct sk_buff *
1426ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
1427{
1428 struct wmi_vdev_delete_cmd *cmd;
1429 struct wmi_tlv *tlv;
1430 struct sk_buff *skb;
1431
1432 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1433 if (!skb)
1434 return ERR_PTR(-ENOMEM);
1435
1436 tlv = (void *)skb->data;
1437 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD);
1438 tlv->len = __cpu_to_le16(sizeof(*cmd));
1439 cmd = (void *)tlv->value;
1440 cmd->vdev_id = __cpu_to_le32(vdev_id);
1441
1442 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n");
1443 return skb;
1444}
1445
1446static struct sk_buff *
1447ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
1448 const struct wmi_vdev_start_request_arg *arg,
1449 bool restart)
1450{
1451 struct wmi_tlv_vdev_start_cmd *cmd;
1452 struct wmi_channel *ch;
1453 struct wmi_p2p_noa_descriptor *noa;
1454 struct wmi_tlv *tlv;
1455 struct sk_buff *skb;
1456 size_t len;
1457 void *ptr;
1458 u32 flags = 0;
1459
1460 if (WARN_ON(arg->ssid && arg->ssid_len == 0))
1461 return ERR_PTR(-EINVAL);
1462 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
1463 return ERR_PTR(-EINVAL);
1464 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
1465 return ERR_PTR(-EINVAL);
1466
1467 len = (sizeof(*tlv) + sizeof(*cmd)) +
1468 (sizeof(*tlv) + sizeof(*ch)) +
1469 (sizeof(*tlv) + 0);
1470 skb = ath10k_wmi_alloc_skb(ar, len);
1471 if (!skb)
1472 return ERR_PTR(-ENOMEM);
1473
1474 if (arg->hidden_ssid)
1475 flags |= WMI_VDEV_START_HIDDEN_SSID;
1476 if (arg->pmf_enabled)
1477 flags |= WMI_VDEV_START_PMF_ENABLED;
1478
1479 ptr = (void *)skb->data;
1480
1481 tlv = ptr;
1482 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD);
1483 tlv->len = __cpu_to_le16(sizeof(*cmd));
1484 cmd = (void *)tlv->value;
1485 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1486 cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval);
1487 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
1488 cmd->flags = __cpu_to_le32(flags);
1489 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
1490 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
1491 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
1492
1493 if (arg->ssid) {
1494 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
1495 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
1496 }
1497
1498 ptr += sizeof(*tlv);
1499 ptr += sizeof(*cmd);
1500
1501 tlv = ptr;
1502 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
1503 tlv->len = __cpu_to_le16(sizeof(*ch));
1504 ch = (void *)tlv->value;
1505 ath10k_wmi_put_wmi_channel(ch, &arg->channel);
1506
1507 ptr += sizeof(*tlv);
1508 ptr += sizeof(*ch);
1509
1510 tlv = ptr;
1511 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1512 tlv->len = 0;
1513 noa = (void *)tlv->value;
1514
1515 /* Note: This is a nested TLV containing:
1516 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
1517 */
1518
1519 ptr += sizeof(*tlv);
1520 ptr += 0;
1521
1522 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n");
1523 return skb;
1524}
1525
1526static struct sk_buff *
1527ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
1528{
1529 struct wmi_vdev_stop_cmd *cmd;
1530 struct wmi_tlv *tlv;
1531 struct sk_buff *skb;
1532
1533 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1534 if (!skb)
1535 return ERR_PTR(-ENOMEM);
1536
1537 tlv = (void *)skb->data;
1538 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD);
1539 tlv->len = __cpu_to_le16(sizeof(*cmd));
1540 cmd = (void *)tlv->value;
1541 cmd->vdev_id = __cpu_to_le32(vdev_id);
1542
1543 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n");
1544 return skb;
1545}
1546
1547static struct sk_buff *
1548ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
1549 const u8 *bssid)
1550
1551{
1552 struct wmi_vdev_up_cmd *cmd;
1553 struct wmi_tlv *tlv;
1554 struct sk_buff *skb;
1555
1556 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1557 if (!skb)
1558 return ERR_PTR(-ENOMEM);
1559
1560 tlv = (void *)skb->data;
1561 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD);
1562 tlv->len = __cpu_to_le16(sizeof(*cmd));
1563 cmd = (void *)tlv->value;
1564 cmd->vdev_id = __cpu_to_le32(vdev_id);
1565 cmd->vdev_assoc_id = __cpu_to_le32(aid);
1566 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
1567
1568 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n");
1569 return skb;
1570}
1571
1572static struct sk_buff *
1573ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
1574{
1575 struct wmi_vdev_down_cmd *cmd;
1576 struct wmi_tlv *tlv;
1577 struct sk_buff *skb;
1578
1579 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1580 if (!skb)
1581 return ERR_PTR(-ENOMEM);
1582
1583 tlv = (void *)skb->data;
1584 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD);
1585 tlv->len = __cpu_to_le16(sizeof(*cmd));
1586 cmd = (void *)tlv->value;
1587 cmd->vdev_id = __cpu_to_le32(vdev_id);
1588
1589 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n");
1590 return skb;
1591}
1592
1593static struct sk_buff *
1594ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
1595 u32 param_id, u32 param_value)
1596{
1597 struct wmi_vdev_set_param_cmd *cmd;
1598 struct wmi_tlv *tlv;
1599 struct sk_buff *skb;
1600
1601 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1602 if (!skb)
1603 return ERR_PTR(-ENOMEM);
1604
1605 tlv = (void *)skb->data;
1606 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD);
1607 tlv->len = __cpu_to_le16(sizeof(*cmd));
1608 cmd = (void *)tlv->value;
1609 cmd->vdev_id = __cpu_to_le32(vdev_id);
1610 cmd->param_id = __cpu_to_le32(param_id);
1611 cmd->param_value = __cpu_to_le32(param_value);
1612
1613 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev set param\n");
1614 return skb;
1615}
1616
1617static struct sk_buff *
1618ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar,
1619 const struct wmi_vdev_install_key_arg *arg)
1620{
1621 struct wmi_vdev_install_key_cmd *cmd;
1622 struct wmi_tlv *tlv;
1623 struct sk_buff *skb;
1624 size_t len;
1625 void *ptr;
1626
1627 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
1628 return ERR_PTR(-EINVAL);
1629 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
1630 return ERR_PTR(-EINVAL);
1631
1632 len = sizeof(*tlv) + sizeof(*cmd) +
1633 sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32));
1634 skb = ath10k_wmi_alloc_skb(ar, len);
1635 if (!skb)
1636 return ERR_PTR(-ENOMEM);
1637
1638 ptr = (void *)skb->data;
1639 tlv = ptr;
1640 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD);
1641 tlv->len = __cpu_to_le16(sizeof(*cmd));
1642 cmd = (void *)tlv->value;
1643 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1644 cmd->key_idx = __cpu_to_le32(arg->key_idx);
1645 cmd->key_flags = __cpu_to_le32(arg->key_flags);
1646 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
1647 cmd->key_len = __cpu_to_le32(arg->key_len);
1648 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
1649 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
1650
1651 if (arg->macaddr)
1652 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
1653
1654 ptr += sizeof(*tlv);
1655 ptr += sizeof(*cmd);
1656
1657 tlv = ptr;
1658 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1659 tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32)));
1660 if (arg->key_data)
1661 memcpy(tlv->value, arg->key_data, arg->key_len);
1662
1663 ptr += sizeof(*tlv);
1664 ptr += roundup(arg->key_len, sizeof(__le32));
1665
1666 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n");
1667 return skb;
1668}
1669
Janusz Dziedzic0c7e4772015-01-24 12:14:52 +02001670static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr,
1671 const struct wmi_sta_uapsd_auto_trig_arg *arg)
1672{
1673 struct wmi_sta_uapsd_auto_trig_param *ac;
1674 struct wmi_tlv *tlv;
1675
1676 tlv = ptr;
1677 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM);
1678 tlv->len = __cpu_to_le16(sizeof(*ac));
1679 ac = (void *)tlv->value;
1680
1681 ac->wmm_ac = __cpu_to_le32(arg->wmm_ac);
1682 ac->user_priority = __cpu_to_le32(arg->user_priority);
1683 ac->service_interval = __cpu_to_le32(arg->service_interval);
1684 ac->suspend_interval = __cpu_to_le32(arg->suspend_interval);
1685 ac->delay_interval = __cpu_to_le32(arg->delay_interval);
1686
1687 ath10k_dbg(ar, ATH10K_DBG_WMI,
1688 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
1689 ac->wmm_ac, ac->user_priority, ac->service_interval,
1690 ac->suspend_interval, ac->delay_interval);
1691
1692 return ptr + sizeof(*tlv) + sizeof(*ac);
1693}
1694
1695static struct sk_buff *
1696ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
1697 const u8 peer_addr[ETH_ALEN],
1698 const struct wmi_sta_uapsd_auto_trig_arg *args,
1699 u32 num_ac)
1700{
1701 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
1702 struct wmi_sta_uapsd_auto_trig_param *ac;
1703 struct wmi_tlv *tlv;
1704 struct sk_buff *skb;
1705 size_t len;
1706 size_t ac_tlv_len;
1707 void *ptr;
1708 int i;
1709
1710 ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac));
1711 len = sizeof(*tlv) + sizeof(*cmd) +
1712 sizeof(*tlv) + ac_tlv_len;
1713 skb = ath10k_wmi_alloc_skb(ar, len);
1714 if (!skb)
1715 return ERR_PTR(-ENOMEM);
1716
1717 ptr = (void *)skb->data;
1718 tlv = ptr;
1719 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD);
1720 tlv->len = __cpu_to_le16(sizeof(*cmd));
1721 cmd = (void *)tlv->value;
1722 cmd->vdev_id = __cpu_to_le32(vdev_id);
1723 cmd->num_ac = __cpu_to_le32(num_ac);
1724 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1725
1726 ptr += sizeof(*tlv);
1727 ptr += sizeof(*cmd);
1728
1729 tlv = ptr;
1730 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1731 tlv->len = __cpu_to_le16(ac_tlv_len);
1732 ac = (void *)tlv->value;
1733
1734 ptr += sizeof(*tlv);
1735 for (i = 0; i < num_ac; i++)
1736 ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]);
1737
1738 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n");
1739 return skb;
1740}
1741
Michal Kazior5e752e42015-01-19 09:53:41 +01001742static void *ath10k_wmi_tlv_put_wmm(void *ptr,
1743 const struct wmi_wmm_params_arg *arg)
1744{
1745 struct wmi_wmm_params *wmm;
1746 struct wmi_tlv *tlv;
1747
1748 tlv = ptr;
1749 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS);
1750 tlv->len = __cpu_to_le16(sizeof(*wmm));
1751 wmm = (void *)tlv->value;
1752 ath10k_wmi_set_wmm_param(wmm, arg);
1753
1754 return ptr + sizeof(*tlv) + sizeof(*wmm);
1755}
1756
Michal Kaziorca996ec2014-12-03 10:11:32 +02001757static struct sk_buff *
Michal Kazior6d492fe2015-01-28 09:57:22 +02001758ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
1759 const struct wmi_wmm_params_all_arg *arg)
1760{
1761 struct wmi_tlv_vdev_set_wmm_cmd *cmd;
Michal Kazior6d492fe2015-01-28 09:57:22 +02001762 struct wmi_tlv *tlv;
1763 struct sk_buff *skb;
1764 size_t len;
1765 void *ptr;
1766
Marek Puzyniakc8c60cf2015-02-10 12:38:15 +01001767 len = sizeof(*tlv) + sizeof(*cmd);
Michal Kazior6d492fe2015-01-28 09:57:22 +02001768 skb = ath10k_wmi_alloc_skb(ar, len);
1769 if (!skb)
1770 return ERR_PTR(-ENOMEM);
1771
1772 ptr = (void *)skb->data;
1773 tlv = ptr;
1774 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD);
1775 tlv->len = __cpu_to_le16(sizeof(*cmd));
1776 cmd = (void *)tlv->value;
1777 cmd->vdev_id = __cpu_to_le32(vdev_id);
1778
Marek Puzyniakc8c60cf2015-02-10 12:38:15 +01001779 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be);
1780 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk);
1781 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi);
1782 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo);
Michal Kazior6d492fe2015-01-28 09:57:22 +02001783
1784 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n");
1785 return skb;
1786}
1787
1788static struct sk_buff *
Janusz Dziedzic6e8b1882015-01-28 09:57:39 +02001789ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
1790 const struct wmi_sta_keepalive_arg *arg)
1791{
1792 struct wmi_tlv_sta_keepalive_cmd *cmd;
1793 struct wmi_sta_keepalive_arp_resp *arp;
1794 struct sk_buff *skb;
1795 struct wmi_tlv *tlv;
1796 void *ptr;
1797 size_t len;
1798
1799 len = sizeof(*tlv) + sizeof(*cmd) +
1800 sizeof(*tlv) + sizeof(*arp);
1801 skb = ath10k_wmi_alloc_skb(ar, len);
1802 if (!skb)
1803 return ERR_PTR(-ENOMEM);
1804
1805 ptr = (void *)skb->data;
1806 tlv = ptr;
1807 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD);
1808 tlv->len = __cpu_to_le16(sizeof(*cmd));
1809 cmd = (void *)tlv->value;
1810 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1811 cmd->enabled = __cpu_to_le32(arg->enabled);
1812 cmd->method = __cpu_to_le32(arg->method);
1813 cmd->interval = __cpu_to_le32(arg->interval);
1814
1815 ptr += sizeof(*tlv);
1816 ptr += sizeof(*cmd);
1817
1818 tlv = ptr;
1819 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE);
1820 tlv->len = __cpu_to_le16(sizeof(*arp));
1821 arp = (void *)tlv->value;
1822
1823 arp->src_ip4_addr = arg->src_ip4_addr;
1824 arp->dest_ip4_addr = arg->dest_ip4_addr;
1825 ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
1826
1827 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d inverval %d\n",
1828 arg->vdev_id, arg->enabled, arg->method, arg->interval);
1829 return skb;
1830}
1831
1832static struct sk_buff *
Michal Kaziorca996ec2014-12-03 10:11:32 +02001833ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
1834 const u8 peer_addr[ETH_ALEN])
1835{
1836 struct wmi_tlv_peer_create_cmd *cmd;
1837 struct wmi_tlv *tlv;
1838 struct sk_buff *skb;
1839
1840 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1841 if (!skb)
1842 return ERR_PTR(-ENOMEM);
1843
1844 tlv = (void *)skb->data;
1845 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD);
1846 tlv->len = __cpu_to_le16(sizeof(*cmd));
1847 cmd = (void *)tlv->value;
1848 cmd->vdev_id = __cpu_to_le32(vdev_id);
1849 cmd->peer_type = __cpu_to_le32(WMI_TLV_PEER_TYPE_DEFAULT); /* FIXME */
1850 ether_addr_copy(cmd->peer_addr.addr, peer_addr);
1851
1852 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n");
1853 return skb;
1854}
1855
1856static struct sk_buff *
1857ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
1858 const u8 peer_addr[ETH_ALEN])
1859{
1860 struct wmi_peer_delete_cmd *cmd;
1861 struct wmi_tlv *tlv;
1862 struct sk_buff *skb;
1863
1864 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1865 if (!skb)
1866 return ERR_PTR(-ENOMEM);
1867
1868 tlv = (void *)skb->data;
1869 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD);
1870 tlv->len = __cpu_to_le16(sizeof(*cmd));
1871 cmd = (void *)tlv->value;
1872 cmd->vdev_id = __cpu_to_le32(vdev_id);
1873 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1874
1875 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n");
1876 return skb;
1877}
1878
1879static struct sk_buff *
1880ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
1881 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
1882{
1883 struct wmi_peer_flush_tids_cmd *cmd;
1884 struct wmi_tlv *tlv;
1885 struct sk_buff *skb;
1886
1887 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1888 if (!skb)
1889 return ERR_PTR(-ENOMEM);
1890
1891 tlv = (void *)skb->data;
1892 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD);
1893 tlv->len = __cpu_to_le16(sizeof(*cmd));
1894 cmd = (void *)tlv->value;
1895 cmd->vdev_id = __cpu_to_le32(vdev_id);
1896 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
1897 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1898
1899 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n");
1900 return skb;
1901}
1902
1903static struct sk_buff *
1904ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
1905 const u8 *peer_addr,
1906 enum wmi_peer_param param_id,
1907 u32 param_value)
1908{
1909 struct wmi_peer_set_param_cmd *cmd;
1910 struct wmi_tlv *tlv;
1911 struct sk_buff *skb;
1912
1913 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1914 if (!skb)
1915 return ERR_PTR(-ENOMEM);
1916
1917 tlv = (void *)skb->data;
1918 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD);
1919 tlv->len = __cpu_to_le16(sizeof(*cmd));
1920 cmd = (void *)tlv->value;
1921 cmd->vdev_id = __cpu_to_le32(vdev_id);
1922 cmd->param_id = __cpu_to_le32(param_id);
1923 cmd->param_value = __cpu_to_le32(param_value);
1924 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1925
1926 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer set param\n");
1927 return skb;
1928}
1929
1930static struct sk_buff *
1931ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar,
1932 const struct wmi_peer_assoc_complete_arg *arg)
1933{
1934 struct wmi_tlv_peer_assoc_cmd *cmd;
1935 struct wmi_vht_rate_set *vht_rate;
1936 struct wmi_tlv *tlv;
1937 struct sk_buff *skb;
1938 size_t len, legacy_rate_len, ht_rate_len;
1939 void *ptr;
1940
1941 if (arg->peer_mpdu_density > 16)
1942 return ERR_PTR(-EINVAL);
1943 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
1944 return ERR_PTR(-EINVAL);
1945 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
1946 return ERR_PTR(-EINVAL);
1947
1948 legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates,
1949 sizeof(__le32));
1950 ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32));
1951 len = (sizeof(*tlv) + sizeof(*cmd)) +
1952 (sizeof(*tlv) + legacy_rate_len) +
1953 (sizeof(*tlv) + ht_rate_len) +
1954 (sizeof(*tlv) + sizeof(*vht_rate));
1955 skb = ath10k_wmi_alloc_skb(ar, len);
1956 if (!skb)
1957 return ERR_PTR(-ENOMEM);
1958
1959 ptr = (void *)skb->data;
1960 tlv = ptr;
1961 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD);
1962 tlv->len = __cpu_to_le16(sizeof(*cmd));
1963 cmd = (void *)tlv->value;
1964
1965 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1966 cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
1967 cmd->assoc_id = __cpu_to_le32(arg->peer_aid);
1968 cmd->flags = __cpu_to_le32(arg->peer_flags);
1969 cmd->caps = __cpu_to_le32(arg->peer_caps);
1970 cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval);
1971 cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps);
1972 cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
1973 cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
1974 cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps);
1975 cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams);
1976 cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps);
1977 cmd->phy_mode = __cpu_to_le32(arg->peer_phymode);
1978 cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates);
1979 cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates);
1980 ether_addr_copy(cmd->mac_addr.addr, arg->addr);
1981
1982 ptr += sizeof(*tlv);
1983 ptr += sizeof(*cmd);
1984
1985 tlv = ptr;
1986 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1987 tlv->len = __cpu_to_le16(legacy_rate_len);
1988 memcpy(tlv->value, arg->peer_legacy_rates.rates,
1989 arg->peer_legacy_rates.num_rates);
1990
1991 ptr += sizeof(*tlv);
1992 ptr += legacy_rate_len;
1993
1994 tlv = ptr;
1995 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1996 tlv->len = __cpu_to_le16(ht_rate_len);
1997 memcpy(tlv->value, arg->peer_ht_rates.rates,
1998 arg->peer_ht_rates.num_rates);
1999
2000 ptr += sizeof(*tlv);
2001 ptr += ht_rate_len;
2002
2003 tlv = ptr;
2004 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET);
2005 tlv->len = __cpu_to_le16(sizeof(*vht_rate));
2006 vht_rate = (void *)tlv->value;
2007
2008 vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
2009 vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
2010 vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
2011 vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
2012
2013 ptr += sizeof(*tlv);
2014 ptr += sizeof(*vht_rate);
2015
2016 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n");
2017 return skb;
2018}
2019
2020static struct sk_buff *
2021ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
2022 enum wmi_sta_ps_mode psmode)
2023{
2024 struct wmi_sta_powersave_mode_cmd *cmd;
2025 struct wmi_tlv *tlv;
2026 struct sk_buff *skb;
2027
2028 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2029 if (!skb)
2030 return ERR_PTR(-ENOMEM);
2031
2032 tlv = (void *)skb->data;
2033 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD);
2034 tlv->len = __cpu_to_le16(sizeof(*cmd));
2035 cmd = (void *)tlv->value;
2036 cmd->vdev_id = __cpu_to_le32(vdev_id);
2037 cmd->sta_ps_mode = __cpu_to_le32(psmode);
2038
2039 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n");
2040 return skb;
2041}
2042
2043static struct sk_buff *
2044ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
2045 enum wmi_sta_powersave_param param_id,
2046 u32 param_value)
2047{
2048 struct wmi_sta_powersave_param_cmd *cmd;
2049 struct wmi_tlv *tlv;
2050 struct sk_buff *skb;
2051
2052 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2053 if (!skb)
2054 return ERR_PTR(-ENOMEM);
2055
2056 tlv = (void *)skb->data;
2057 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD);
2058 tlv->len = __cpu_to_le16(sizeof(*cmd));
2059 cmd = (void *)tlv->value;
2060 cmd->vdev_id = __cpu_to_le32(vdev_id);
2061 cmd->param_id = __cpu_to_le32(param_id);
2062 cmd->param_value = __cpu_to_le32(param_value);
2063
2064 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n");
2065 return skb;
2066}
2067
2068static struct sk_buff *
2069ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
2070 enum wmi_ap_ps_peer_param param_id, u32 value)
2071{
2072 struct wmi_ap_ps_peer_cmd *cmd;
2073 struct wmi_tlv *tlv;
2074 struct sk_buff *skb;
2075
2076 if (!mac)
2077 return ERR_PTR(-EINVAL);
2078
Michal Kazior4543ab02015-02-25 11:39:36 +01002079 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
Michal Kaziorca996ec2014-12-03 10:11:32 +02002080 if (!skb)
2081 return ERR_PTR(-ENOMEM);
2082
2083 tlv = (void *)skb->data;
2084 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD);
2085 tlv->len = __cpu_to_le16(sizeof(*cmd));
2086 cmd = (void *)tlv->value;
2087 cmd->vdev_id = __cpu_to_le32(vdev_id);
2088 cmd->param_id = __cpu_to_le32(param_id);
2089 cmd->param_value = __cpu_to_le32(value);
2090 ether_addr_copy(cmd->peer_macaddr.addr, mac);
2091
2092 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n");
2093 return skb;
2094}
2095
2096static struct sk_buff *
2097ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar,
2098 const struct wmi_scan_chan_list_arg *arg)
2099{
2100 struct wmi_tlv_scan_chan_list_cmd *cmd;
2101 struct wmi_channel *ci;
2102 struct wmi_channel_arg *ch;
2103 struct wmi_tlv *tlv;
2104 struct sk_buff *skb;
2105 size_t chans_len, len;
2106 int i;
2107 void *ptr, *chans;
2108
2109 chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci));
2110 len = (sizeof(*tlv) + sizeof(*cmd)) +
2111 (sizeof(*tlv) + chans_len);
2112
2113 skb = ath10k_wmi_alloc_skb(ar, len);
2114 if (!skb)
2115 return ERR_PTR(-ENOMEM);
2116
2117 ptr = (void *)skb->data;
2118 tlv = ptr;
2119 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD);
2120 tlv->len = __cpu_to_le16(sizeof(*cmd));
2121 cmd = (void *)tlv->value;
2122 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
2123
2124 ptr += sizeof(*tlv);
2125 ptr += sizeof(*cmd);
2126
2127 tlv = ptr;
2128 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2129 tlv->len = __cpu_to_le16(chans_len);
2130 chans = (void *)tlv->value;
2131
2132 for (i = 0; i < arg->n_channels; i++) {
2133 ch = &arg->channels[i];
2134
2135 tlv = chans;
2136 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2137 tlv->len = __cpu_to_le16(sizeof(*ci));
2138 ci = (void *)tlv->value;
2139
2140 ath10k_wmi_put_wmi_channel(ci, ch);
2141
2142 chans += sizeof(*tlv);
2143 chans += sizeof(*ci);
2144 }
2145
2146 ptr += sizeof(*tlv);
2147 ptr += chans_len;
2148
2149 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n");
2150 return skb;
2151}
2152
2153static struct sk_buff *
Michal Kazior9ad50182015-01-29 14:29:47 +02002154ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id,
2155 const void *bcn, size_t bcn_len,
2156 u32 bcn_paddr, bool dtim_zero,
2157 bool deliver_cab)
2158
Michal Kaziorca996ec2014-12-03 10:11:32 +02002159{
Michal Kaziorca996ec2014-12-03 10:11:32 +02002160 struct wmi_bcn_tx_ref_cmd *cmd;
2161 struct wmi_tlv *tlv;
2162 struct sk_buff *skb;
Michal Kaziorca996ec2014-12-03 10:11:32 +02002163 struct ieee80211_hdr *hdr;
2164 u16 fc;
2165
2166 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2167 if (!skb)
2168 return ERR_PTR(-ENOMEM);
2169
Michal Kazior9ad50182015-01-29 14:29:47 +02002170 hdr = (struct ieee80211_hdr *)bcn;
Michal Kaziorca996ec2014-12-03 10:11:32 +02002171 fc = le16_to_cpu(hdr->frame_control);
2172
2173 tlv = (void *)skb->data;
2174 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD);
2175 tlv->len = __cpu_to_le16(sizeof(*cmd));
2176 cmd = (void *)tlv->value;
Michal Kazior9ad50182015-01-29 14:29:47 +02002177 cmd->vdev_id = __cpu_to_le32(vdev_id);
2178 cmd->data_len = __cpu_to_le32(bcn_len);
2179 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
Michal Kaziorca996ec2014-12-03 10:11:32 +02002180 cmd->msdu_id = 0;
2181 cmd->frame_control = __cpu_to_le32(fc);
2182 cmd->flags = 0;
2183
Michal Kazior9ad50182015-01-29 14:29:47 +02002184 if (dtim_zero)
Michal Kaziorca996ec2014-12-03 10:11:32 +02002185 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
2186
Michal Kazior9ad50182015-01-29 14:29:47 +02002187 if (deliver_cab)
Michal Kaziorca996ec2014-12-03 10:11:32 +02002188 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
2189
2190 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n");
2191 return skb;
2192}
2193
Michal Kaziorca996ec2014-12-03 10:11:32 +02002194static struct sk_buff *
2195ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar,
Michal Kazior5e752e42015-01-19 09:53:41 +01002196 const struct wmi_wmm_params_all_arg *arg)
Michal Kaziorca996ec2014-12-03 10:11:32 +02002197{
2198 struct wmi_tlv_pdev_set_wmm_cmd *cmd;
2199 struct wmi_wmm_params *wmm;
2200 struct wmi_tlv *tlv;
2201 struct sk_buff *skb;
2202 size_t len;
2203 void *ptr;
2204
2205 len = (sizeof(*tlv) + sizeof(*cmd)) +
2206 (4 * (sizeof(*tlv) + sizeof(*wmm)));
2207 skb = ath10k_wmi_alloc_skb(ar, len);
2208 if (!skb)
2209 return ERR_PTR(-ENOMEM);
2210
2211 ptr = (void *)skb->data;
2212
2213 tlv = ptr;
2214 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD);
2215 tlv->len = __cpu_to_le16(sizeof(*cmd));
2216 cmd = (void *)tlv->value;
2217
2218 /* nothing to set here */
2219
2220 ptr += sizeof(*tlv);
2221 ptr += sizeof(*cmd);
2222
2223 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be);
2224 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk);
2225 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi);
2226 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo);
2227
2228 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n");
2229 return skb;
2230}
2231
2232static struct sk_buff *
Michal Kaziorde23d3e2015-02-15 16:50:41 +02002233ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
Michal Kaziorca996ec2014-12-03 10:11:32 +02002234{
2235 struct wmi_request_stats_cmd *cmd;
2236 struct wmi_tlv *tlv;
2237 struct sk_buff *skb;
2238
2239 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2240 if (!skb)
2241 return ERR_PTR(-ENOMEM);
2242
2243 tlv = (void *)skb->data;
2244 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD);
2245 tlv->len = __cpu_to_le16(sizeof(*cmd));
2246 cmd = (void *)tlv->value;
Michal Kaziorde23d3e2015-02-15 16:50:41 +02002247 cmd->stats_id = __cpu_to_le32(stats_mask);
Michal Kaziorca996ec2014-12-03 10:11:32 +02002248
2249 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n");
2250 return skb;
2251}
2252
2253static struct sk_buff *
2254ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar,
2255 enum wmi_force_fw_hang_type type,
2256 u32 delay_ms)
2257{
2258 struct wmi_force_fw_hang_cmd *cmd;
2259 struct wmi_tlv *tlv;
2260 struct sk_buff *skb;
2261
2262 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2263 if (!skb)
2264 return ERR_PTR(-ENOMEM);
2265
2266 tlv = (void *)skb->data;
2267 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD);
2268 tlv->len = __cpu_to_le16(sizeof(*cmd));
2269 cmd = (void *)tlv->value;
2270 cmd->type = __cpu_to_le32(type);
2271 cmd->delay_ms = __cpu_to_le32(delay_ms);
2272
2273 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n");
2274 return skb;
2275}
2276
2277static struct sk_buff *
SenthilKumar Jegadeesan467210a2015-01-29 14:36:52 +05302278ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
2279 u32 log_level) {
Michal Kaziorca996ec2014-12-03 10:11:32 +02002280 struct wmi_tlv_dbglog_cmd *cmd;
2281 struct wmi_tlv *tlv;
2282 struct sk_buff *skb;
2283 size_t len, bmap_len;
2284 u32 value;
2285 void *ptr;
2286
2287 if (module_enable) {
2288 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2289 module_enable,
2290 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE);
2291 } else {
2292 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2293 WMI_TLV_DBGLOG_ALL_MODULES,
2294 WMI_TLV_DBGLOG_LOG_LEVEL_WARN);
2295 }
2296
2297 bmap_len = 0;
2298 len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len;
2299 skb = ath10k_wmi_alloc_skb(ar, len);
2300 if (!skb)
2301 return ERR_PTR(-ENOMEM);
2302
2303 ptr = (void *)skb->data;
2304
2305 tlv = ptr;
2306 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD);
2307 tlv->len = __cpu_to_le16(sizeof(*cmd));
2308 cmd = (void *)tlv->value;
2309 cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL);
2310 cmd->value = __cpu_to_le32(value);
2311
2312 ptr += sizeof(*tlv);
2313 ptr += sizeof(*cmd);
2314
2315 tlv = ptr;
2316 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
2317 tlv->len = __cpu_to_le16(bmap_len);
2318
2319 /* nothing to do here */
2320
2321 ptr += sizeof(*tlv);
2322 ptr += sizeof(bmap_len);
2323
2324 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value);
2325 return skb;
2326}
2327
2328static struct sk_buff *
2329ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter)
2330{
2331 struct wmi_tlv_pktlog_enable *cmd;
2332 struct wmi_tlv *tlv;
2333 struct sk_buff *skb;
2334 void *ptr;
2335 size_t len;
2336
2337 len = sizeof(*tlv) + sizeof(*cmd);
2338 skb = ath10k_wmi_alloc_skb(ar, len);
2339 if (!skb)
2340 return ERR_PTR(-ENOMEM);
2341
2342 ptr = (void *)skb->data;
2343 tlv = ptr;
2344 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD);
2345 tlv->len = __cpu_to_le16(sizeof(*cmd));
2346 cmd = (void *)tlv->value;
2347 cmd->filter = __cpu_to_le32(filter);
2348
2349 ptr += sizeof(*tlv);
2350 ptr += sizeof(*cmd);
2351
2352 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n",
2353 filter);
2354 return skb;
2355}
2356
2357static struct sk_buff *
2358ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar)
2359{
2360 struct wmi_tlv_pktlog_disable *cmd;
2361 struct wmi_tlv *tlv;
2362 struct sk_buff *skb;
2363 void *ptr;
2364 size_t len;
2365
2366 len = sizeof(*tlv) + sizeof(*cmd);
2367 skb = ath10k_wmi_alloc_skb(ar, len);
2368 if (!skb)
2369 return ERR_PTR(-ENOMEM);
2370
2371 ptr = (void *)skb->data;
2372 tlv = ptr;
2373 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD);
2374 tlv->len = __cpu_to_le16(sizeof(*cmd));
2375 cmd = (void *)tlv->value;
2376
2377 ptr += sizeof(*tlv);
2378 ptr += sizeof(*cmd);
2379
2380 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n");
2381 return skb;
2382}
2383
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02002384static struct sk_buff *
2385ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id,
2386 u32 tim_ie_offset, struct sk_buff *bcn,
2387 u32 prb_caps, u32 prb_erp, void *prb_ies,
2388 size_t prb_ies_len)
2389{
2390 struct wmi_tlv_bcn_tmpl_cmd *cmd;
2391 struct wmi_tlv_bcn_prb_info *info;
2392 struct wmi_tlv *tlv;
2393 struct sk_buff *skb;
2394 void *ptr;
2395 size_t len;
2396
2397 if (WARN_ON(prb_ies_len > 0 && !prb_ies))
2398 return ERR_PTR(-EINVAL);
2399
2400 len = sizeof(*tlv) + sizeof(*cmd) +
2401 sizeof(*tlv) + sizeof(*info) + prb_ies_len +
2402 sizeof(*tlv) + roundup(bcn->len, 4);
2403 skb = ath10k_wmi_alloc_skb(ar, len);
2404 if (!skb)
2405 return ERR_PTR(-ENOMEM);
2406
2407 ptr = (void *)skb->data;
2408 tlv = ptr;
2409 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD);
2410 tlv->len = __cpu_to_le16(sizeof(*cmd));
2411 cmd = (void *)tlv->value;
2412 cmd->vdev_id = __cpu_to_le32(vdev_id);
2413 cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset);
2414 cmd->buf_len = __cpu_to_le32(bcn->len);
2415
2416 ptr += sizeof(*tlv);
2417 ptr += sizeof(*cmd);
2418
2419 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
2420 * then it is then impossible to pass original ie len.
2421 * This chunk is not used yet so if setting probe resp template yields
2422 * problems with beaconing or crashes firmware look here.
2423 */
2424 tlv = ptr;
2425 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2426 tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len);
2427 info = (void *)tlv->value;
2428 info->caps = __cpu_to_le32(prb_caps);
2429 info->erp = __cpu_to_le32(prb_erp);
2430 memcpy(info->ies, prb_ies, prb_ies_len);
2431
2432 ptr += sizeof(*tlv);
2433 ptr += sizeof(*info);
2434 ptr += prb_ies_len;
2435
2436 tlv = ptr;
2437 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2438 tlv->len = __cpu_to_le16(roundup(bcn->len, 4));
2439 memcpy(tlv->value, bcn->data, bcn->len);
2440
2441 /* FIXME: Adjust TSF? */
2442
2443 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n",
2444 vdev_id);
2445 return skb;
2446}
2447
Michal Kazior4c4955f2015-01-13 16:30:11 +02002448static struct sk_buff *
2449ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id,
2450 struct sk_buff *prb)
2451{
2452 struct wmi_tlv_prb_tmpl_cmd *cmd;
2453 struct wmi_tlv_bcn_prb_info *info;
2454 struct wmi_tlv *tlv;
2455 struct sk_buff *skb;
2456 void *ptr;
2457 size_t len;
2458
2459 len = sizeof(*tlv) + sizeof(*cmd) +
2460 sizeof(*tlv) + sizeof(*info) +
2461 sizeof(*tlv) + roundup(prb->len, 4);
2462 skb = ath10k_wmi_alloc_skb(ar, len);
2463 if (!skb)
2464 return ERR_PTR(-ENOMEM);
2465
2466 ptr = (void *)skb->data;
2467 tlv = ptr;
2468 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD);
2469 tlv->len = __cpu_to_le16(sizeof(*cmd));
2470 cmd = (void *)tlv->value;
2471 cmd->vdev_id = __cpu_to_le32(vdev_id);
2472 cmd->buf_len = __cpu_to_le32(prb->len);
2473
2474 ptr += sizeof(*tlv);
2475 ptr += sizeof(*cmd);
2476
2477 tlv = ptr;
2478 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2479 tlv->len = __cpu_to_le16(sizeof(*info));
2480 info = (void *)tlv->value;
2481 info->caps = 0;
2482 info->erp = 0;
2483
2484 ptr += sizeof(*tlv);
2485 ptr += sizeof(*info);
2486
2487 tlv = ptr;
2488 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2489 tlv->len = __cpu_to_le16(roundup(prb->len, 4));
2490 memcpy(tlv->value, prb->data, prb->len);
2491
2492 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n",
2493 vdev_id);
2494 return skb;
2495}
2496
Michal Kazior369242b4e2015-01-13 16:30:11 +02002497static struct sk_buff *
2498ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
2499 const u8 *p2p_ie)
2500{
2501 struct wmi_tlv_p2p_go_bcn_ie *cmd;
2502 struct wmi_tlv *tlv;
2503 struct sk_buff *skb;
2504 void *ptr;
2505 size_t len;
2506
2507 len = sizeof(*tlv) + sizeof(*cmd) +
2508 sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4);
2509 skb = ath10k_wmi_alloc_skb(ar, len);
2510 if (!skb)
2511 return ERR_PTR(-ENOMEM);
2512
2513 ptr = (void *)skb->data;
2514 tlv = ptr;
2515 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE);
2516 tlv->len = __cpu_to_le16(sizeof(*cmd));
2517 cmd = (void *)tlv->value;
2518 cmd->vdev_id = __cpu_to_le32(vdev_id);
2519 cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2);
2520
2521 ptr += sizeof(*tlv);
2522 ptr += sizeof(*cmd);
2523
2524 tlv = ptr;
2525 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2526 tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4));
2527 memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2);
2528
2529 ptr += sizeof(*tlv);
2530 ptr += roundup(p2p_ie[1] + 2, 4);
2531
2532 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n",
2533 vdev_id);
2534 return skb;
2535}
2536
Michal Kaziorca996ec2014-12-03 10:11:32 +02002537/****************/
2538/* TLV mappings */
2539/****************/
2540
2541static struct wmi_cmd_map wmi_tlv_cmd_map = {
2542 .init_cmdid = WMI_TLV_INIT_CMDID,
2543 .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID,
2544 .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID,
2545 .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID,
2546 .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID,
2547 .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID,
2548 .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID,
2549 .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID,
2550 .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID,
2551 .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID,
2552 .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID,
2553 .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID,
2554 .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID,
2555 .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID,
2556 .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID,
2557 .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID,
2558 .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID,
2559 .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID,
2560 .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID,
2561 .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID,
2562 .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID,
2563 .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID,
2564 .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID,
2565 .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID,
2566 .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID,
2567 .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID,
2568 .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID,
2569 .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID,
2570 .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID,
2571 .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID,
2572 .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID,
2573 .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID,
2574 .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID,
2575 .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID,
2576 .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID,
2577 .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID,
2578 .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID,
2579 .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID,
2580 .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID,
2581 .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID,
2582 .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID,
2583 .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID,
2584 .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID,
2585 .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID,
2586 .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID,
2587 .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID,
2588 .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID,
2589 .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID,
2590 .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID,
2591 .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID,
2592 .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID,
2593 .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID,
2594 .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID,
2595 .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE,
2596 .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD,
2597 .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD,
2598 .roam_scan_rssi_change_threshold =
2599 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
2600 .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
2601 .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
2602 .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE,
2603 .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD,
2604 .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO,
2605 .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY,
2606 .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE,
2607 .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE,
2608 .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID,
2609 .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID,
2610 .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID,
2611 .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID,
2612 .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID,
2613 .wlan_profile_set_hist_intvl_cmdid =
2614 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
2615 .wlan_profile_get_profile_data_cmdid =
2616 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
2617 .wlan_profile_enable_profile_id_cmdid =
2618 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
2619 .wlan_profile_list_profile_id_cmdid =
2620 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
2621 .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID,
2622 .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID,
2623 .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID,
2624 .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID,
2625 .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID,
2626 .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID,
2627 .wow_enable_disable_wake_event_cmdid =
2628 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
2629 .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID,
2630 .wow_hostwakeup_from_sleep_cmdid =
2631 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
2632 .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID,
2633 .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID,
2634 .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,
2635 .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID,
2636 .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID,
2637 .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID,
2638 .network_list_offload_config_cmdid =
2639 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
2640 .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID,
2641 .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID,
2642 .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID,
2643 .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID,
2644 .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID,
2645 .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID,
2646 .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID,
2647 .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID,
2648 .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID,
2649 .echo_cmdid = WMI_TLV_ECHO_CMDID,
2650 .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID,
2651 .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID,
2652 .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID,
2653 .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID,
2654 .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID,
2655 .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID,
2656 .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID,
2657 .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID,
2658 .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID,
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02002659 .pdev_get_temperature_cmdid = WMI_TLV_CMD_UNSUPPORTED,
Michal Kazior6d492fe2015-01-28 09:57:22 +02002660 .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID,
Michal Kaziorca996ec2014-12-03 10:11:32 +02002661};
2662
2663static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = {
2664 .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK,
2665 .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK,
2666 .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G,
2667 .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G,
2668 .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE,
2669 .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE,
2670 .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE,
2671 .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
2672 .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE,
2673 .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW,
2674 .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
2675 .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH,
2676 .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH,
2677 .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING,
2678 .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE,
2679 .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE,
2680 .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK,
2681 .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI,
2682 .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO,
2683 .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
2684 .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
2685 .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE,
2686 .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
2687 .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE,
2688 .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE,
2689 .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
2690 .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
2691 .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
2692 .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
2693 .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
2694 .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
2695 .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
2696 .bcnflt_stats_update_period =
2697 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
2698 .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS,
2699 .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE,
2700 .dcs = WMI_TLV_PDEV_PARAM_DCS,
2701 .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE,
2702 .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD,
2703 .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD,
2704 .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL,
2705 .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL,
2706 .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN,
2707 .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA,
2708 .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG,
2709 .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP,
2710 .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED,
2711 .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR,
2712 .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE,
Peter Oha7bd3e92014-12-02 13:07:14 +02002713 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
Michal Kaziorca996ec2014-12-03 10:11:32 +02002714};
2715
2716static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = {
2717 .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD,
2718 .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
2719 .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL,
2720 .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL,
2721 .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE,
2722 .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE,
2723 .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME,
2724 .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE,
2725 .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME,
2726 .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD,
2727 .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME,
2728 .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL,
2729 .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD,
2730 .wmi_vdev_oc_scheduler_air_time_limit =
2731 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
2732 .wds = WMI_TLV_VDEV_PARAM_WDS,
2733 .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW,
2734 .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX,
2735 .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT,
2736 .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT,
2737 .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM,
2738 .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH,
2739 .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET,
2740 .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION,
2741 .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT,
2742 .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE,
2743 .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE,
2744 .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE,
2745 .sgi = WMI_TLV_VDEV_PARAM_SGI,
2746 .ldpc = WMI_TLV_VDEV_PARAM_LDPC,
2747 .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC,
2748 .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC,
2749 .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD,
2750 .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID,
2751 .nss = WMI_TLV_VDEV_PARAM_NSS,
2752 .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE,
2753 .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE,
2754 .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE,
2755 .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE,
2756 .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
2757 .ap_keepalive_min_idle_inactive_time_secs =
2758 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
2759 .ap_keepalive_max_idle_inactive_time_secs =
2760 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
2761 .ap_keepalive_max_unresponsive_time_secs =
2762 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
2763 .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS,
2764 .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED,
2765 .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS,
2766 .txbf = WMI_TLV_VDEV_PARAM_TXBF,
2767 .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE,
2768 .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY,
2769 .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE,
2770 .ap_detect_out_of_sync_sleeping_sta_time_secs =
2771 WMI_TLV_VDEV_PARAM_UNSUPPORTED,
2772};
2773
2774static const struct wmi_ops wmi_tlv_ops = {
2775 .rx = ath10k_wmi_tlv_op_rx,
2776 .map_svc = wmi_tlv_svc_map,
2777
2778 .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev,
2779 .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev,
2780 .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev,
2781 .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev,
2782 .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev,
2783 .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev,
2784 .pull_phyerr = ath10k_wmi_tlv_op_pull_phyerr_ev,
2785 .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev,
2786 .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
2787 .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
2788
2789 .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
2790 .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
2791 .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
2792 .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
2793 .gen_init = ath10k_wmi_tlv_op_gen_init,
2794 .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
2795 .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
2796 .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create,
2797 .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete,
2798 .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start,
2799 .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop,
2800 .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up,
2801 .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down,
2802 .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param,
2803 .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key,
Michal Kazior6d492fe2015-01-28 09:57:22 +02002804 .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf,
Michal Kaziorca996ec2014-12-03 10:11:32 +02002805 .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create,
2806 .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete,
2807 .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush,
2808 .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param,
2809 .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc,
2810 .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode,
2811 .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps,
2812 .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps,
2813 .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list,
2814 .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma,
2815 .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm,
2816 .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats,
2817 .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang,
2818 /* .gen_mgmt_tx = not implemented; HTT is used */
2819 .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg,
2820 .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable,
2821 .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable,
Rajkumar Manoharanffdd7382014-12-17 12:21:40 +02002822 /* .gen_pdev_set_quiet_mode not implemented */
Rajkumar Manoharana57a6a22014-12-17 12:22:17 +02002823 /* .gen_pdev_get_temperature not implemented */
Rajkumar Manoharandc8ab272015-01-12 14:07:25 +02002824 /* .gen_addba_clear_resp not implemented */
Rajkumar Manoharan65c08932015-01-12 14:07:26 +02002825 /* .gen_addba_send not implemented */
Rajkumar Manoharan11597412015-01-12 14:07:26 +02002826 /* .gen_addba_set_resp not implemented */
Rajkumar Manoharan50abef82015-01-12 14:07:26 +02002827 /* .gen_delba_send not implemented */
Michal Kaziorbe9ce9d2015-01-13 16:30:11 +02002828 .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl,
Michal Kazior4c4955f2015-01-13 16:30:11 +02002829 .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl,
Michal Kazior369242b4e2015-01-13 16:30:11 +02002830 .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
Janusz Dziedzic0c7e4772015-01-24 12:14:52 +02002831 .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
Janusz Dziedzic6e8b1882015-01-28 09:57:39 +02002832 .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
Michal Kaziorca996ec2014-12-03 10:11:32 +02002833};
2834
2835/************/
2836/* TLV init */
2837/************/
2838
2839void ath10k_wmi_tlv_attach(struct ath10k *ar)
2840{
2841 ar->wmi.cmd = &wmi_tlv_cmd_map;
2842 ar->wmi.vdev_param = &wmi_tlv_vdev_param_map;
2843 ar->wmi.pdev_param = &wmi_tlv_pdev_param_map;
2844 ar->wmi.ops = &wmi_tlv_ops;
2845}