Linux 4.4.145
[linux/fpc-iii.git] / drivers / net / wireless / ath / ath10k / wmi-tlv.c
blob02eea3c3b5d30da1a1776a219b36b8300ce9d7b0
1 /*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2014 Qualcomm Atheros, Inc.
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.
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.
17 #include "core.h"
18 #include "debug.h"
19 #include "mac.h"
20 #include "hw.h"
21 #include "mac.h"
22 #include "wmi.h"
23 #include "wmi-ops.h"
24 #include "wmi-tlv.h"
25 #include "p2p.h"
26 #include "testmode.h"
28 /***************/
29 /* TLV helpers */
30 /**************/
32 struct wmi_tlv_policy {
33 size_t min_len;
36 static const struct wmi_tlv_policy wmi_tlv_policies[] = {
37 [WMI_TLV_TAG_ARRAY_BYTE]
38 = { .min_len = 0 },
39 [WMI_TLV_TAG_ARRAY_UINT32]
40 = { .min_len = 0 },
41 [WMI_TLV_TAG_STRUCT_SCAN_EVENT]
42 = { .min_len = sizeof(struct wmi_scan_event) },
43 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
44 = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) },
45 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]
46 = { .min_len = sizeof(struct wmi_chan_info_event) },
47 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]
48 = { .min_len = sizeof(struct wmi_vdev_start_response_event) },
49 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]
50 = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
51 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT]
52 = { .min_len = sizeof(struct wmi_host_swba_event) },
53 [WMI_TLV_TAG_STRUCT_TIM_INFO]
54 = { .min_len = sizeof(struct wmi_tim_info) },
55 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]
56 = { .min_len = sizeof(struct wmi_p2p_noa_info) },
57 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT]
58 = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) },
59 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES]
60 = { .min_len = sizeof(struct hal_reg_capabilities) },
61 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ]
62 = { .min_len = sizeof(struct wlan_host_mem_req) },
63 [WMI_TLV_TAG_STRUCT_READY_EVENT]
64 = { .min_len = sizeof(struct wmi_tlv_rdy_ev) },
65 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]
66 = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
67 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
68 = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
69 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
70 = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
71 [WMI_TLV_TAG_STRUCT_ROAM_EVENT]
72 = { .min_len = sizeof(struct wmi_tlv_roam_ev) },
73 [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]
74 = { .min_len = sizeof(struct wmi_tlv_wow_event_info) },
75 [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT]
76 = { .min_len = sizeof(struct wmi_tlv_tx_pause_ev) },
79 static int
80 ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len,
81 int (*iter)(struct ath10k *ar, u16 tag, u16 len,
82 const void *ptr, void *data),
83 void *data)
85 const void *begin = ptr;
86 const struct wmi_tlv *tlv;
87 u16 tlv_tag, tlv_len;
88 int ret;
90 while (len > 0) {
91 if (len < sizeof(*tlv)) {
92 ath10k_dbg(ar, ATH10K_DBG_WMI,
93 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
94 ptr - begin, len, sizeof(*tlv));
95 return -EINVAL;
98 tlv = ptr;
99 tlv_tag = __le16_to_cpu(tlv->tag);
100 tlv_len = __le16_to_cpu(tlv->len);
101 ptr += sizeof(*tlv);
102 len -= sizeof(*tlv);
104 if (tlv_len > len) {
105 ath10k_dbg(ar, ATH10K_DBG_WMI,
106 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
107 tlv_tag, ptr - begin, len, tlv_len);
108 return -EINVAL;
111 if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
112 wmi_tlv_policies[tlv_tag].min_len &&
113 wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
114 ath10k_dbg(ar, ATH10K_DBG_WMI,
115 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
116 tlv_tag, ptr - begin, tlv_len,
117 wmi_tlv_policies[tlv_tag].min_len);
118 return -EINVAL;
121 ret = iter(ar, tlv_tag, tlv_len, ptr, data);
122 if (ret)
123 return ret;
125 ptr += tlv_len;
126 len -= tlv_len;
129 return 0;
132 static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len,
133 const void *ptr, void *data)
135 const void **tb = data;
137 if (tag < WMI_TLV_TAG_MAX)
138 tb[tag] = ptr;
140 return 0;
143 static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb,
144 const void *ptr, size_t len)
146 return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse,
147 (void *)tb);
150 static const void **
151 ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
152 size_t len, gfp_t gfp)
154 const void **tb;
155 int ret;
157 tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
158 if (!tb)
159 return ERR_PTR(-ENOMEM);
161 ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len);
162 if (ret) {
163 kfree(tb);
164 return ERR_PTR(ret);
167 return tb;
170 static u16 ath10k_wmi_tlv_len(const void *ptr)
172 return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len);
175 /**************/
176 /* TLV events */
177 /**************/
178 static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar,
179 struct sk_buff *skb)
181 const void **tb;
182 const struct wmi_tlv_bcn_tx_status_ev *ev;
183 struct ath10k_vif *arvif;
184 u32 vdev_id, tx_status;
185 int ret;
187 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
188 if (IS_ERR(tb)) {
189 ret = PTR_ERR(tb);
190 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
191 return ret;
194 ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT];
195 if (!ev) {
196 kfree(tb);
197 return -EPROTO;
200 tx_status = __le32_to_cpu(ev->tx_status);
201 vdev_id = __le32_to_cpu(ev->vdev_id);
203 switch (tx_status) {
204 case WMI_TLV_BCN_TX_STATUS_OK:
205 break;
206 case WMI_TLV_BCN_TX_STATUS_XRETRY:
207 case WMI_TLV_BCN_TX_STATUS_DROP:
208 case WMI_TLV_BCN_TX_STATUS_FILTERED:
209 /* FIXME: It's probably worth telling mac80211 to stop the
210 * interface as it is crippled.
212 ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d",
213 vdev_id, tx_status);
214 break;
217 arvif = ath10k_get_arvif(ar, vdev_id);
218 if (arvif && arvif->is_up && arvif->vif->csa_active)
219 ieee80211_queue_work(ar->hw, &arvif->ap_csa_work);
221 kfree(tb);
222 return 0;
225 static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar,
226 struct sk_buff *skb)
228 const void **tb;
229 const struct wmi_tlv_diag_data_ev *ev;
230 const struct wmi_tlv_diag_item *item;
231 const void *data;
232 int ret, num_items, len;
234 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
235 if (IS_ERR(tb)) {
236 ret = PTR_ERR(tb);
237 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
238 return ret;
241 ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT];
242 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
243 if (!ev || !data) {
244 kfree(tb);
245 return -EPROTO;
248 num_items = __le32_to_cpu(ev->num_items);
249 len = ath10k_wmi_tlv_len(data);
251 while (num_items--) {
252 if (len == 0)
253 break;
254 if (len < sizeof(*item)) {
255 ath10k_warn(ar, "failed to parse diag data: can't fit item header\n");
256 break;
259 item = data;
261 if (len < sizeof(*item) + __le16_to_cpu(item->len)) {
262 ath10k_warn(ar, "failed to parse diag data: item is too long\n");
263 break;
266 trace_ath10k_wmi_diag_container(ar,
267 item->type,
268 __le32_to_cpu(item->timestamp),
269 __le32_to_cpu(item->code),
270 __le16_to_cpu(item->len),
271 item->payload);
273 len -= sizeof(*item);
274 len -= roundup(__le16_to_cpu(item->len), 4);
276 data += sizeof(*item);
277 data += roundup(__le16_to_cpu(item->len), 4);
280 if (num_items != -1 || len != 0)
281 ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n",
282 num_items, len);
284 kfree(tb);
285 return 0;
288 static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
289 struct sk_buff *skb)
291 const void **tb;
292 const void *data;
293 int ret, len;
295 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
296 if (IS_ERR(tb)) {
297 ret = PTR_ERR(tb);
298 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
299 return ret;
302 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
303 if (!data) {
304 kfree(tb);
305 return -EPROTO;
307 len = ath10k_wmi_tlv_len(data);
309 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len);
310 trace_ath10k_wmi_diag(ar, data, len);
312 kfree(tb);
313 return 0;
316 static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
317 struct sk_buff *skb)
319 const void **tb;
320 const struct wmi_tlv_p2p_noa_ev *ev;
321 const struct wmi_p2p_noa_info *noa;
322 int ret, vdev_id;
324 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
325 if (IS_ERR(tb)) {
326 ret = PTR_ERR(tb);
327 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
328 return ret;
331 ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
332 noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
334 if (!ev || !noa) {
335 kfree(tb);
336 return -EPROTO;
339 vdev_id = __le32_to_cpu(ev->vdev_id);
341 ath10k_dbg(ar, ATH10K_DBG_WMI,
342 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
343 vdev_id, noa->num_descriptors);
345 ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
346 kfree(tb);
347 return 0;
350 static int ath10k_wmi_tlv_event_tx_pause(struct ath10k *ar,
351 struct sk_buff *skb)
353 const void **tb;
354 const struct wmi_tlv_tx_pause_ev *ev;
355 int ret, vdev_id;
356 u32 pause_id, action, vdev_map, peer_id, tid_map;
358 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
359 if (IS_ERR(tb)) {
360 ret = PTR_ERR(tb);
361 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
362 return ret;
365 ev = tb[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT];
366 if (!ev) {
367 kfree(tb);
368 return -EPROTO;
371 pause_id = __le32_to_cpu(ev->pause_id);
372 action = __le32_to_cpu(ev->action);
373 vdev_map = __le32_to_cpu(ev->vdev_map);
374 peer_id = __le32_to_cpu(ev->peer_id);
375 tid_map = __le32_to_cpu(ev->tid_map);
377 ath10k_dbg(ar, ATH10K_DBG_WMI,
378 "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n",
379 pause_id, action, vdev_map, peer_id, tid_map);
381 switch (pause_id) {
382 case WMI_TLV_TX_PAUSE_ID_MCC:
383 case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA:
384 case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS:
385 case WMI_TLV_TX_PAUSE_ID_AP_PS:
386 case WMI_TLV_TX_PAUSE_ID_IBSS_PS:
387 for (vdev_id = 0; vdev_map; vdev_id++) {
388 if (!(vdev_map & BIT(vdev_id)))
389 continue;
391 vdev_map &= ~BIT(vdev_id);
392 ath10k_mac_handle_tx_pause_vdev(ar, vdev_id, pause_id,
393 action);
395 break;
396 case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS:
397 case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD:
398 case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA:
399 case WMI_TLV_TX_PAUSE_ID_HOST:
400 ath10k_dbg(ar, ATH10K_DBG_MAC,
401 "mac ignoring unsupported tx pause id %d\n",
402 pause_id);
403 break;
404 default:
405 ath10k_dbg(ar, ATH10K_DBG_MAC,
406 "mac ignoring unknown tx pause vdev %d\n",
407 pause_id);
408 break;
411 kfree(tb);
412 return 0;
415 /***********/
416 /* TLV ops */
417 /***********/
419 static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
421 struct wmi_cmd_hdr *cmd_hdr;
422 enum wmi_tlv_event_id id;
423 bool consumed;
425 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
426 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
428 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
429 goto out;
431 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
433 consumed = ath10k_tm_event_wmi(ar, id, skb);
435 /* Ready event must be handled normally also in UTF mode so that we
436 * know the UTF firmware has booted, others we are just bypass WMI
437 * events to testmode.
439 if (consumed && id != WMI_TLV_READY_EVENTID) {
440 ath10k_dbg(ar, ATH10K_DBG_WMI,
441 "wmi tlv testmode consumed 0x%x\n", id);
442 goto out;
445 switch (id) {
446 case WMI_TLV_MGMT_RX_EVENTID:
447 ath10k_wmi_event_mgmt_rx(ar, skb);
448 /* mgmt_rx() owns the skb now! */
449 return;
450 case WMI_TLV_SCAN_EVENTID:
451 ath10k_wmi_event_scan(ar, skb);
452 break;
453 case WMI_TLV_CHAN_INFO_EVENTID:
454 ath10k_wmi_event_chan_info(ar, skb);
455 break;
456 case WMI_TLV_ECHO_EVENTID:
457 ath10k_wmi_event_echo(ar, skb);
458 break;
459 case WMI_TLV_DEBUG_MESG_EVENTID:
460 ath10k_wmi_event_debug_mesg(ar, skb);
461 break;
462 case WMI_TLV_UPDATE_STATS_EVENTID:
463 ath10k_wmi_event_update_stats(ar, skb);
464 break;
465 case WMI_TLV_VDEV_START_RESP_EVENTID:
466 ath10k_wmi_event_vdev_start_resp(ar, skb);
467 break;
468 case WMI_TLV_VDEV_STOPPED_EVENTID:
469 ath10k_wmi_event_vdev_stopped(ar, skb);
470 break;
471 case WMI_TLV_PEER_STA_KICKOUT_EVENTID:
472 ath10k_wmi_event_peer_sta_kickout(ar, skb);
473 break;
474 case WMI_TLV_HOST_SWBA_EVENTID:
475 ath10k_wmi_event_host_swba(ar, skb);
476 break;
477 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID:
478 ath10k_wmi_event_tbttoffset_update(ar, skb);
479 break;
480 case WMI_TLV_PHYERR_EVENTID:
481 ath10k_wmi_event_phyerr(ar, skb);
482 break;
483 case WMI_TLV_ROAM_EVENTID:
484 ath10k_wmi_event_roam(ar, skb);
485 break;
486 case WMI_TLV_PROFILE_MATCH:
487 ath10k_wmi_event_profile_match(ar, skb);
488 break;
489 case WMI_TLV_DEBUG_PRINT_EVENTID:
490 ath10k_wmi_event_debug_print(ar, skb);
491 break;
492 case WMI_TLV_PDEV_QVIT_EVENTID:
493 ath10k_wmi_event_pdev_qvit(ar, skb);
494 break;
495 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID:
496 ath10k_wmi_event_wlan_profile_data(ar, skb);
497 break;
498 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID:
499 ath10k_wmi_event_rtt_measurement_report(ar, skb);
500 break;
501 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID:
502 ath10k_wmi_event_tsf_measurement_report(ar, skb);
503 break;
504 case WMI_TLV_RTT_ERROR_REPORT_EVENTID:
505 ath10k_wmi_event_rtt_error_report(ar, skb);
506 break;
507 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID:
508 ath10k_wmi_event_wow_wakeup_host(ar, skb);
509 break;
510 case WMI_TLV_DCS_INTERFERENCE_EVENTID:
511 ath10k_wmi_event_dcs_interference(ar, skb);
512 break;
513 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID:
514 ath10k_wmi_event_pdev_tpc_config(ar, skb);
515 break;
516 case WMI_TLV_PDEV_FTM_INTG_EVENTID:
517 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
518 break;
519 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID:
520 ath10k_wmi_event_gtk_offload_status(ar, skb);
521 break;
522 case WMI_TLV_GTK_REKEY_FAIL_EVENTID:
523 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
524 break;
525 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID:
526 ath10k_wmi_event_delba_complete(ar, skb);
527 break;
528 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID:
529 ath10k_wmi_event_addba_complete(ar, skb);
530 break;
531 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
532 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
533 break;
534 case WMI_TLV_SERVICE_READY_EVENTID:
535 ath10k_wmi_event_service_ready(ar, skb);
536 return;
537 case WMI_TLV_READY_EVENTID:
538 ath10k_wmi_event_ready(ar, skb);
539 break;
540 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID:
541 ath10k_wmi_tlv_event_bcn_tx_status(ar, skb);
542 break;
543 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID:
544 ath10k_wmi_tlv_event_diag_data(ar, skb);
545 break;
546 case WMI_TLV_DIAG_EVENTID:
547 ath10k_wmi_tlv_event_diag(ar, skb);
548 break;
549 case WMI_TLV_P2P_NOA_EVENTID:
550 ath10k_wmi_tlv_event_p2p_noa(ar, skb);
551 break;
552 case WMI_TLV_TX_PAUSE_EVENTID:
553 ath10k_wmi_tlv_event_tx_pause(ar, skb);
554 break;
555 default:
556 ath10k_warn(ar, "Unknown eventid: %d\n", id);
557 break;
560 out:
561 dev_kfree_skb(skb);
564 static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar,
565 struct sk_buff *skb,
566 struct wmi_scan_ev_arg *arg)
568 const void **tb;
569 const struct wmi_scan_event *ev;
570 int ret;
572 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
573 if (IS_ERR(tb)) {
574 ret = PTR_ERR(tb);
575 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
576 return ret;
579 ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT];
580 if (!ev) {
581 kfree(tb);
582 return -EPROTO;
585 arg->event_type = ev->event_type;
586 arg->reason = ev->reason;
587 arg->channel_freq = ev->channel_freq;
588 arg->scan_req_id = ev->scan_req_id;
589 arg->scan_id = ev->scan_id;
590 arg->vdev_id = ev->vdev_id;
592 kfree(tb);
593 return 0;
596 static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar,
597 struct sk_buff *skb,
598 struct wmi_mgmt_rx_ev_arg *arg)
600 const void **tb;
601 const struct wmi_tlv_mgmt_rx_ev *ev;
602 const u8 *frame;
603 u32 msdu_len;
604 int ret;
606 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
607 if (IS_ERR(tb)) {
608 ret = PTR_ERR(tb);
609 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
610 return ret;
613 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR];
614 frame = tb[WMI_TLV_TAG_ARRAY_BYTE];
616 if (!ev || !frame) {
617 kfree(tb);
618 return -EPROTO;
621 arg->channel = ev->channel;
622 arg->buf_len = ev->buf_len;
623 arg->status = ev->status;
624 arg->snr = ev->snr;
625 arg->phy_mode = ev->phy_mode;
626 arg->rate = ev->rate;
628 msdu_len = __le32_to_cpu(arg->buf_len);
630 if (skb->len < (frame - skb->data) + msdu_len) {
631 kfree(tb);
632 return -EPROTO;
635 /* shift the sk_buff to point to `frame` */
636 skb_trim(skb, 0);
637 skb_put(skb, frame - skb->data);
638 skb_pull(skb, frame - skb->data);
639 skb_put(skb, msdu_len);
641 kfree(tb);
642 return 0;
645 static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar,
646 struct sk_buff *skb,
647 struct wmi_ch_info_ev_arg *arg)
649 const void **tb;
650 const struct wmi_chan_info_event *ev;
651 int ret;
653 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
654 if (IS_ERR(tb)) {
655 ret = PTR_ERR(tb);
656 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
657 return ret;
660 ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT];
661 if (!ev) {
662 kfree(tb);
663 return -EPROTO;
666 arg->err_code = ev->err_code;
667 arg->freq = ev->freq;
668 arg->cmd_flags = ev->cmd_flags;
669 arg->noise_floor = ev->noise_floor;
670 arg->rx_clear_count = ev->rx_clear_count;
671 arg->cycle_count = ev->cycle_count;
673 kfree(tb);
674 return 0;
677 static int
678 ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
679 struct wmi_vdev_start_ev_arg *arg)
681 const void **tb;
682 const struct wmi_vdev_start_response_event *ev;
683 int ret;
685 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
686 if (IS_ERR(tb)) {
687 ret = PTR_ERR(tb);
688 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
689 return ret;
692 ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT];
693 if (!ev) {
694 kfree(tb);
695 return -EPROTO;
698 skb_pull(skb, sizeof(*ev));
699 arg->vdev_id = ev->vdev_id;
700 arg->req_id = ev->req_id;
701 arg->resp_type = ev->resp_type;
702 arg->status = ev->status;
704 kfree(tb);
705 return 0;
708 static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar,
709 struct sk_buff *skb,
710 struct wmi_peer_kick_ev_arg *arg)
712 const void **tb;
713 const struct wmi_peer_sta_kickout_event *ev;
714 int ret;
716 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
717 if (IS_ERR(tb)) {
718 ret = PTR_ERR(tb);
719 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
720 return ret;
723 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT];
724 if (!ev) {
725 kfree(tb);
726 return -EPROTO;
729 arg->mac_addr = ev->peer_macaddr.addr;
731 kfree(tb);
732 return 0;
735 struct wmi_tlv_swba_parse {
736 const struct wmi_host_swba_event *ev;
737 bool tim_done;
738 bool noa_done;
739 size_t n_tim;
740 size_t n_noa;
741 struct wmi_swba_ev_arg *arg;
744 static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len,
745 const void *ptr, void *data)
747 struct wmi_tlv_swba_parse *swba = data;
748 struct wmi_tim_info_arg *tim_info_arg;
749 const struct wmi_tim_info *tim_info_ev = ptr;
751 if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO)
752 return -EPROTO;
754 if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info))
755 return -ENOBUFS;
757 if (__le32_to_cpu(tim_info_ev->tim_len) >
758 sizeof(tim_info_ev->tim_bitmap)) {
759 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
760 return -EPROTO;
763 tim_info_arg = &swba->arg->tim_info[swba->n_tim];
764 tim_info_arg->tim_len = tim_info_ev->tim_len;
765 tim_info_arg->tim_mcast = tim_info_ev->tim_mcast;
766 tim_info_arg->tim_bitmap = tim_info_ev->tim_bitmap;
767 tim_info_arg->tim_changed = tim_info_ev->tim_changed;
768 tim_info_arg->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
770 swba->n_tim++;
772 return 0;
775 static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len,
776 const void *ptr, void *data)
778 struct wmi_tlv_swba_parse *swba = data;
780 if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO)
781 return -EPROTO;
783 if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info))
784 return -ENOBUFS;
786 swba->arg->noa_info[swba->n_noa++] = ptr;
787 return 0;
790 static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len,
791 const void *ptr, void *data)
793 struct wmi_tlv_swba_parse *swba = data;
794 int ret;
796 switch (tag) {
797 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT:
798 swba->ev = ptr;
799 break;
800 case WMI_TLV_TAG_ARRAY_STRUCT:
801 if (!swba->tim_done) {
802 swba->tim_done = true;
803 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
804 ath10k_wmi_tlv_swba_tim_parse,
805 swba);
806 if (ret)
807 return ret;
808 } else if (!swba->noa_done) {
809 swba->noa_done = true;
810 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
811 ath10k_wmi_tlv_swba_noa_parse,
812 swba);
813 if (ret)
814 return ret;
816 break;
817 default:
818 break;
820 return 0;
823 static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar,
824 struct sk_buff *skb,
825 struct wmi_swba_ev_arg *arg)
827 struct wmi_tlv_swba_parse swba = { .arg = arg };
828 u32 map;
829 size_t n_vdevs;
830 int ret;
832 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
833 ath10k_wmi_tlv_swba_parse, &swba);
834 if (ret) {
835 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
836 return ret;
839 if (!swba.ev)
840 return -EPROTO;
842 arg->vdev_map = swba.ev->vdev_map;
844 for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1)
845 if (map & BIT(0))
846 n_vdevs++;
848 if (n_vdevs != swba.n_tim ||
849 n_vdevs != swba.n_noa)
850 return -EPROTO;
852 return 0;
855 static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k *ar,
856 struct sk_buff *skb,
857 struct wmi_phyerr_hdr_arg *arg)
859 const void **tb;
860 const struct wmi_tlv_phyerr_ev *ev;
861 const void *phyerrs;
862 int ret;
864 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
865 if (IS_ERR(tb)) {
866 ret = PTR_ERR(tb);
867 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
868 return ret;
871 ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR];
872 phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE];
874 if (!ev || !phyerrs) {
875 kfree(tb);
876 return -EPROTO;
879 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
880 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
881 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
882 arg->buf_len = __le32_to_cpu(ev->buf_len);
883 arg->phyerrs = phyerrs;
885 kfree(tb);
886 return 0;
889 #define WMI_TLV_ABI_VER_NS0 0x5F414351
890 #define WMI_TLV_ABI_VER_NS1 0x00004C4D
891 #define WMI_TLV_ABI_VER_NS2 0x00000000
892 #define WMI_TLV_ABI_VER_NS3 0x00000000
894 #define WMI_TLV_ABI_VER0_MAJOR 1
895 #define WMI_TLV_ABI_VER0_MINOR 0
896 #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
897 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
898 #define WMI_TLV_ABI_VER1 53
900 static int
901 ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len,
902 const void *ptr, void *data)
904 struct wmi_svc_rdy_ev_arg *arg = data;
905 int i;
907 if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ)
908 return -EPROTO;
910 for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) {
911 if (!arg->mem_reqs[i]) {
912 arg->mem_reqs[i] = ptr;
913 return 0;
917 return -ENOMEM;
920 static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar,
921 struct sk_buff *skb,
922 struct wmi_svc_rdy_ev_arg *arg)
924 const void **tb;
925 const struct hal_reg_capabilities *reg;
926 const struct wmi_tlv_svc_rdy_ev *ev;
927 const __le32 *svc_bmap;
928 const struct wlan_host_mem_req *mem_reqs;
929 int ret;
931 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
932 if (IS_ERR(tb)) {
933 ret = PTR_ERR(tb);
934 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
935 return ret;
938 ev = tb[WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT];
939 reg = tb[WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES];
940 svc_bmap = tb[WMI_TLV_TAG_ARRAY_UINT32];
941 mem_reqs = tb[WMI_TLV_TAG_ARRAY_STRUCT];
943 if (!ev || !reg || !svc_bmap || !mem_reqs) {
944 kfree(tb);
945 return -EPROTO;
948 /* This is an internal ABI compatibility check for WMI TLV so check it
949 * here instead of the generic WMI code.
951 ath10k_dbg(ar, ATH10K_DBG_WMI,
952 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
953 __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0,
954 __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0,
955 __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1,
956 __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2,
957 __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3);
959 if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 ||
960 __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 ||
961 __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 ||
962 __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 ||
963 __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) {
964 kfree(tb);
965 return -ENOTSUPP;
968 arg->min_tx_power = ev->hw_min_tx_power;
969 arg->max_tx_power = ev->hw_max_tx_power;
970 arg->ht_cap = ev->ht_cap_info;
971 arg->vht_cap = ev->vht_cap_info;
972 arg->sw_ver0 = ev->abi.abi_ver0;
973 arg->sw_ver1 = ev->abi.abi_ver1;
974 arg->fw_build = ev->fw_build_vers;
975 arg->phy_capab = ev->phy_capability;
976 arg->num_rf_chains = ev->num_rf_chains;
977 arg->eeprom_rd = reg->eeprom_rd;
978 arg->num_mem_reqs = ev->num_mem_reqs;
979 arg->service_map = svc_bmap;
980 arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap);
982 ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs),
983 ath10k_wmi_tlv_parse_mem_reqs, arg);
984 if (ret) {
985 kfree(tb);
986 ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret);
987 return ret;
990 kfree(tb);
991 return 0;
994 static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar,
995 struct sk_buff *skb,
996 struct wmi_rdy_ev_arg *arg)
998 const void **tb;
999 const struct wmi_tlv_rdy_ev *ev;
1000 int ret;
1002 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1003 if (IS_ERR(tb)) {
1004 ret = PTR_ERR(tb);
1005 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1006 return ret;
1009 ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT];
1010 if (!ev) {
1011 kfree(tb);
1012 return -EPROTO;
1015 arg->sw_version = ev->abi.abi_ver0;
1016 arg->abi_version = ev->abi.abi_ver1;
1017 arg->status = ev->status;
1018 arg->mac_addr = ev->mac_addr.addr;
1020 kfree(tb);
1021 return 0;
1024 static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src,
1025 struct ath10k_fw_stats_vdev *dst)
1027 int i;
1029 dst->vdev_id = __le32_to_cpu(src->vdev_id);
1030 dst->beacon_snr = __le32_to_cpu(src->beacon_snr);
1031 dst->data_snr = __le32_to_cpu(src->data_snr);
1032 dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames);
1033 dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail);
1034 dst->num_rts_success = __le32_to_cpu(src->num_rts_success);
1035 dst->num_rx_err = __le32_to_cpu(src->num_rx_err);
1036 dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard);
1037 dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked);
1039 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++)
1040 dst->num_tx_frames[i] =
1041 __le32_to_cpu(src->num_tx_frames[i]);
1043 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++)
1044 dst->num_tx_frames_retries[i] =
1045 __le32_to_cpu(src->num_tx_frames_retries[i]);
1047 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++)
1048 dst->num_tx_frames_failures[i] =
1049 __le32_to_cpu(src->num_tx_frames_failures[i]);
1051 for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++)
1052 dst->tx_rate_history[i] =
1053 __le32_to_cpu(src->tx_rate_history[i]);
1055 for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++)
1056 dst->beacon_rssi_history[i] =
1057 __le32_to_cpu(src->beacon_rssi_history[i]);
1060 static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1061 struct sk_buff *skb,
1062 struct ath10k_fw_stats *stats)
1064 const void **tb;
1065 const struct wmi_tlv_stats_ev *ev;
1066 const void *data;
1067 u32 num_pdev_stats;
1068 u32 num_vdev_stats;
1069 u32 num_peer_stats;
1070 u32 num_bcnflt_stats;
1071 u32 num_chan_stats;
1072 size_t data_len;
1073 int ret;
1074 int i;
1076 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1077 if (IS_ERR(tb)) {
1078 ret = PTR_ERR(tb);
1079 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1080 return ret;
1083 ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT];
1084 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
1086 if (!ev || !data) {
1087 kfree(tb);
1088 return -EPROTO;
1091 data_len = ath10k_wmi_tlv_len(data);
1092 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1093 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1094 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1095 num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
1096 num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
1098 ath10k_dbg(ar, ATH10K_DBG_WMI,
1099 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i\n",
1100 num_pdev_stats, num_vdev_stats, num_peer_stats,
1101 num_bcnflt_stats, num_chan_stats);
1103 for (i = 0; i < num_pdev_stats; i++) {
1104 const struct wmi_pdev_stats *src;
1105 struct ath10k_fw_stats_pdev *dst;
1107 src = data;
1108 if (data_len < sizeof(*src)) {
1109 kfree(tb);
1110 return -EPROTO;
1113 data += sizeof(*src);
1114 data_len -= sizeof(*src);
1116 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1117 if (!dst)
1118 continue;
1120 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1121 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1122 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1123 list_add_tail(&dst->list, &stats->pdevs);
1126 for (i = 0; i < num_vdev_stats; i++) {
1127 const struct wmi_tlv_vdev_stats *src;
1128 struct ath10k_fw_stats_vdev *dst;
1130 src = data;
1131 if (data_len < sizeof(*src)) {
1132 kfree(tb);
1133 return -EPROTO;
1136 data += sizeof(*src);
1137 data_len -= sizeof(*src);
1139 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1140 if (!dst)
1141 continue;
1143 ath10k_wmi_tlv_pull_vdev_stats(src, dst);
1144 list_add_tail(&dst->list, &stats->vdevs);
1147 for (i = 0; i < num_peer_stats; i++) {
1148 const struct wmi_10x_peer_stats *src;
1149 struct ath10k_fw_stats_peer *dst;
1151 src = data;
1152 if (data_len < sizeof(*src)) {
1153 kfree(tb);
1154 return -EPROTO;
1157 data += sizeof(*src);
1158 data_len -= sizeof(*src);
1160 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1161 if (!dst)
1162 continue;
1164 ath10k_wmi_pull_peer_stats(&src->old, dst);
1165 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1166 list_add_tail(&dst->list, &stats->peers);
1169 kfree(tb);
1170 return 0;
1173 static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar,
1174 struct sk_buff *skb,
1175 struct wmi_roam_ev_arg *arg)
1177 const void **tb;
1178 const struct wmi_tlv_roam_ev *ev;
1179 int ret;
1181 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1182 if (IS_ERR(tb)) {
1183 ret = PTR_ERR(tb);
1184 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1185 return ret;
1188 ev = tb[WMI_TLV_TAG_STRUCT_ROAM_EVENT];
1189 if (!ev) {
1190 kfree(tb);
1191 return -EPROTO;
1194 arg->vdev_id = ev->vdev_id;
1195 arg->reason = ev->reason;
1196 arg->rssi = ev->rssi;
1198 kfree(tb);
1199 return 0;
1202 static int
1203 ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb,
1204 struct wmi_wow_ev_arg *arg)
1206 const void **tb;
1207 const struct wmi_tlv_wow_event_info *ev;
1208 int ret;
1210 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1211 if (IS_ERR(tb)) {
1212 ret = PTR_ERR(tb);
1213 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1214 return ret;
1217 ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO];
1218 if (!ev) {
1219 kfree(tb);
1220 return -EPROTO;
1223 arg->vdev_id = __le32_to_cpu(ev->vdev_id);
1224 arg->flag = __le32_to_cpu(ev->flag);
1225 arg->wake_reason = __le32_to_cpu(ev->wake_reason);
1226 arg->data_len = __le32_to_cpu(ev->data_len);
1228 kfree(tb);
1229 return 0;
1232 static struct sk_buff *
1233 ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
1235 struct wmi_tlv_pdev_suspend *cmd;
1236 struct wmi_tlv *tlv;
1237 struct sk_buff *skb;
1239 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1240 if (!skb)
1241 return ERR_PTR(-ENOMEM);
1243 tlv = (void *)skb->data;
1244 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD);
1245 tlv->len = __cpu_to_le16(sizeof(*cmd));
1246 cmd = (void *)tlv->value;
1247 cmd->opt = __cpu_to_le32(opt);
1249 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n");
1250 return skb;
1253 static struct sk_buff *
1254 ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar)
1256 struct wmi_tlv_resume_cmd *cmd;
1257 struct wmi_tlv *tlv;
1258 struct sk_buff *skb;
1260 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1261 if (!skb)
1262 return ERR_PTR(-ENOMEM);
1264 tlv = (void *)skb->data;
1265 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD);
1266 tlv->len = __cpu_to_le16(sizeof(*cmd));
1267 cmd = (void *)tlv->value;
1268 cmd->reserved = __cpu_to_le32(0);
1270 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n");
1271 return skb;
1274 static struct sk_buff *
1275 ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar,
1276 u16 rd, u16 rd2g, u16 rd5g,
1277 u16 ctl2g, u16 ctl5g,
1278 enum wmi_dfs_region dfs_reg)
1280 struct wmi_tlv_pdev_set_rd_cmd *cmd;
1281 struct wmi_tlv *tlv;
1282 struct sk_buff *skb;
1284 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1285 if (!skb)
1286 return ERR_PTR(-ENOMEM);
1288 tlv = (void *)skb->data;
1289 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD);
1290 tlv->len = __cpu_to_le16(sizeof(*cmd));
1291 cmd = (void *)tlv->value;
1292 cmd->regd = __cpu_to_le32(rd);
1293 cmd->regd_2ghz = __cpu_to_le32(rd2g);
1294 cmd->regd_5ghz = __cpu_to_le32(rd5g);
1295 cmd->conform_limit_2ghz = __cpu_to_le32(rd2g);
1296 cmd->conform_limit_5ghz = __cpu_to_le32(rd5g);
1298 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n");
1299 return skb;
1302 static enum wmi_txbf_conf ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k *ar)
1304 return WMI_TXBF_CONF_AFTER_ASSOC;
1307 static struct sk_buff *
1308 ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id,
1309 u32 param_value)
1311 struct wmi_tlv_pdev_set_param_cmd *cmd;
1312 struct wmi_tlv *tlv;
1313 struct sk_buff *skb;
1315 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1316 if (!skb)
1317 return ERR_PTR(-ENOMEM);
1319 tlv = (void *)skb->data;
1320 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD);
1321 tlv->len = __cpu_to_le16(sizeof(*cmd));
1322 cmd = (void *)tlv->value;
1323 cmd->param_id = __cpu_to_le32(param_id);
1324 cmd->param_value = __cpu_to_le32(param_value);
1326 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param\n");
1327 return skb;
1330 static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
1332 struct sk_buff *skb;
1333 struct wmi_tlv *tlv;
1334 struct wmi_tlv_init_cmd *cmd;
1335 struct wmi_tlv_resource_config *cfg;
1336 struct wmi_host_mem_chunks *chunks;
1337 size_t len, chunks_len;
1338 void *ptr;
1340 chunks_len = ar->wmi.num_mem_chunks * sizeof(struct host_memory_chunk);
1341 len = (sizeof(*tlv) + sizeof(*cmd)) +
1342 (sizeof(*tlv) + sizeof(*cfg)) +
1343 (sizeof(*tlv) + chunks_len);
1345 skb = ath10k_wmi_alloc_skb(ar, len);
1346 if (!skb)
1347 return ERR_PTR(-ENOMEM);
1349 ptr = skb->data;
1351 tlv = ptr;
1352 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD);
1353 tlv->len = __cpu_to_le16(sizeof(*cmd));
1354 cmd = (void *)tlv->value;
1355 ptr += sizeof(*tlv);
1356 ptr += sizeof(*cmd);
1358 tlv = ptr;
1359 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG);
1360 tlv->len = __cpu_to_le16(sizeof(*cfg));
1361 cfg = (void *)tlv->value;
1362 ptr += sizeof(*tlv);
1363 ptr += sizeof(*cfg);
1365 tlv = ptr;
1366 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1367 tlv->len = __cpu_to_le16(chunks_len);
1368 chunks = (void *)tlv->value;
1370 ptr += sizeof(*tlv);
1371 ptr += chunks_len;
1373 cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0);
1374 cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1);
1375 cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0);
1376 cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1);
1377 cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2);
1378 cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3);
1379 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
1381 cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1382 cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS);
1384 if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) {
1385 cfg->num_offload_peers = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1386 cfg->num_offload_reorder_bufs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1387 } else {
1388 cfg->num_offload_peers = __cpu_to_le32(0);
1389 cfg->num_offload_reorder_bufs = __cpu_to_le32(0);
1392 cfg->num_peer_keys = __cpu_to_le32(2);
1393 cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS);
1394 cfg->ast_skid_limit = __cpu_to_le32(0x10);
1395 cfg->tx_chain_mask = __cpu_to_le32(0x7);
1396 cfg->rx_chain_mask = __cpu_to_le32(0x7);
1397 cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64);
1398 cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64);
1399 cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64);
1400 cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28);
1401 cfg->rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
1402 cfg->scan_max_pending_reqs = __cpu_to_le32(4);
1403 cfg->bmiss_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1404 cfg->roam_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1405 cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8);
1406 cfg->num_mcast_groups = __cpu_to_le32(0);
1407 cfg->num_mcast_table_elems = __cpu_to_le32(0);
1408 cfg->mcast2ucast_mode = __cpu_to_le32(0);
1409 cfg->tx_dbg_log_size = __cpu_to_le32(0x400);
1410 cfg->num_wds_entries = __cpu_to_le32(0x20);
1411 cfg->dma_burst_size = __cpu_to_le32(0);
1412 cfg->mac_aggr_delim = __cpu_to_le32(0);
1413 cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
1414 cfg->vow_config = __cpu_to_le32(0);
1415 cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
1416 cfg->num_msdu_desc = __cpu_to_le32(TARGET_TLV_NUM_MSDU_DESC);
1417 cfg->max_frag_entries = __cpu_to_le32(2);
1418 cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS);
1419 cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
1420 cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2);
1421 cfg->num_multicast_filter_entries = __cpu_to_le32(5);
1422 cfg->num_wow_filters = __cpu_to_le32(ar->wow.max_num_patterns);
1423 cfg->num_keep_alive_pattern = __cpu_to_le32(6);
1424 cfg->keep_alive_pattern_size = __cpu_to_le32(0);
1425 cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1);
1426 cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1);
1428 ath10k_wmi_put_host_mem_chunks(ar, chunks);
1430 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
1431 return skb;
1434 static struct sk_buff *
1435 ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
1436 const struct wmi_start_scan_arg *arg)
1438 struct wmi_tlv_start_scan_cmd *cmd;
1439 struct wmi_tlv *tlv;
1440 struct sk_buff *skb;
1441 size_t len, chan_len, ssid_len, bssid_len, ie_len;
1442 __le32 *chans;
1443 struct wmi_ssid *ssids;
1444 struct wmi_mac_addr *addrs;
1445 void *ptr;
1446 int i, ret;
1448 ret = ath10k_wmi_start_scan_verify(arg);
1449 if (ret)
1450 return ERR_PTR(ret);
1452 chan_len = arg->n_channels * sizeof(__le32);
1453 ssid_len = arg->n_ssids * sizeof(struct wmi_ssid);
1454 bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
1455 ie_len = roundup(arg->ie_len, 4);
1456 len = (sizeof(*tlv) + sizeof(*cmd)) +
1457 (arg->n_channels ? sizeof(*tlv) + chan_len : 0) +
1458 (arg->n_ssids ? sizeof(*tlv) + ssid_len : 0) +
1459 (arg->n_bssids ? sizeof(*tlv) + bssid_len : 0) +
1460 (arg->ie_len ? sizeof(*tlv) + ie_len : 0);
1462 skb = ath10k_wmi_alloc_skb(ar, len);
1463 if (!skb)
1464 return ERR_PTR(-ENOMEM);
1466 ptr = (void *)skb->data;
1467 tlv = ptr;
1468 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD);
1469 tlv->len = __cpu_to_le16(sizeof(*cmd));
1470 cmd = (void *)tlv->value;
1472 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
1473 cmd->burst_duration_ms = __cpu_to_le32(arg->burst_duration_ms);
1474 cmd->num_channels = __cpu_to_le32(arg->n_channels);
1475 cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
1476 cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
1477 cmd->ie_len = __cpu_to_le32(arg->ie_len);
1478 cmd->num_probes = __cpu_to_le32(3);
1480 /* FIXME: There are some scan flag inconsistencies across firmwares,
1481 * e.g. WMI-TLV inverts the logic behind the following flag.
1483 cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
1485 ptr += sizeof(*tlv);
1486 ptr += sizeof(*cmd);
1488 tlv = ptr;
1489 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
1490 tlv->len = __cpu_to_le16(chan_len);
1491 chans = (void *)tlv->value;
1492 for (i = 0; i < arg->n_channels; i++)
1493 chans[i] = __cpu_to_le32(arg->channels[i]);
1495 ptr += sizeof(*tlv);
1496 ptr += chan_len;
1498 tlv = ptr;
1499 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1500 tlv->len = __cpu_to_le16(ssid_len);
1501 ssids = (void *)tlv->value;
1502 for (i = 0; i < arg->n_ssids; i++) {
1503 ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len);
1504 memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len);
1507 ptr += sizeof(*tlv);
1508 ptr += ssid_len;
1510 tlv = ptr;
1511 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1512 tlv->len = __cpu_to_le16(bssid_len);
1513 addrs = (void *)tlv->value;
1514 for (i = 0; i < arg->n_bssids; i++)
1515 ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid);
1517 ptr += sizeof(*tlv);
1518 ptr += bssid_len;
1520 tlv = ptr;
1521 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1522 tlv->len = __cpu_to_le16(ie_len);
1523 memcpy(tlv->value, arg->ie, arg->ie_len);
1525 ptr += sizeof(*tlv);
1526 ptr += ie_len;
1528 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
1529 return skb;
1532 static struct sk_buff *
1533 ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar,
1534 const struct wmi_stop_scan_arg *arg)
1536 struct wmi_stop_scan_cmd *cmd;
1537 struct wmi_tlv *tlv;
1538 struct sk_buff *skb;
1539 u32 scan_id;
1540 u32 req_id;
1542 if (arg->req_id > 0xFFF)
1543 return ERR_PTR(-EINVAL);
1544 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
1545 return ERR_PTR(-EINVAL);
1547 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1548 if (!skb)
1549 return ERR_PTR(-ENOMEM);
1551 scan_id = arg->u.scan_id;
1552 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
1554 req_id = arg->req_id;
1555 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
1557 tlv = (void *)skb->data;
1558 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD);
1559 tlv->len = __cpu_to_le16(sizeof(*cmd));
1560 cmd = (void *)tlv->value;
1561 cmd->req_type = __cpu_to_le32(arg->req_type);
1562 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
1563 cmd->scan_id = __cpu_to_le32(scan_id);
1564 cmd->scan_req_id = __cpu_to_le32(req_id);
1566 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n");
1567 return skb;
1570 static struct sk_buff *
1571 ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar,
1572 u32 vdev_id,
1573 enum wmi_vdev_type vdev_type,
1574 enum wmi_vdev_subtype vdev_subtype,
1575 const u8 mac_addr[ETH_ALEN])
1577 struct wmi_vdev_create_cmd *cmd;
1578 struct wmi_tlv *tlv;
1579 struct sk_buff *skb;
1581 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1582 if (!skb)
1583 return ERR_PTR(-ENOMEM);
1585 tlv = (void *)skb->data;
1586 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD);
1587 tlv->len = __cpu_to_le16(sizeof(*cmd));
1588 cmd = (void *)tlv->value;
1589 cmd->vdev_id = __cpu_to_le32(vdev_id);
1590 cmd->vdev_type = __cpu_to_le32(vdev_type);
1591 cmd->vdev_subtype = __cpu_to_le32(vdev_subtype);
1592 ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr);
1594 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n");
1595 return skb;
1598 static struct sk_buff *
1599 ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
1601 struct wmi_vdev_delete_cmd *cmd;
1602 struct wmi_tlv *tlv;
1603 struct sk_buff *skb;
1605 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1606 if (!skb)
1607 return ERR_PTR(-ENOMEM);
1609 tlv = (void *)skb->data;
1610 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD);
1611 tlv->len = __cpu_to_le16(sizeof(*cmd));
1612 cmd = (void *)tlv->value;
1613 cmd->vdev_id = __cpu_to_le32(vdev_id);
1615 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n");
1616 return skb;
1619 static struct sk_buff *
1620 ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
1621 const struct wmi_vdev_start_request_arg *arg,
1622 bool restart)
1624 struct wmi_tlv_vdev_start_cmd *cmd;
1625 struct wmi_channel *ch;
1626 struct wmi_p2p_noa_descriptor *noa;
1627 struct wmi_tlv *tlv;
1628 struct sk_buff *skb;
1629 size_t len;
1630 void *ptr;
1631 u32 flags = 0;
1633 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
1634 return ERR_PTR(-EINVAL);
1635 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
1636 return ERR_PTR(-EINVAL);
1638 len = (sizeof(*tlv) + sizeof(*cmd)) +
1639 (sizeof(*tlv) + sizeof(*ch)) +
1640 (sizeof(*tlv) + 0);
1641 skb = ath10k_wmi_alloc_skb(ar, len);
1642 if (!skb)
1643 return ERR_PTR(-ENOMEM);
1645 if (arg->hidden_ssid)
1646 flags |= WMI_VDEV_START_HIDDEN_SSID;
1647 if (arg->pmf_enabled)
1648 flags |= WMI_VDEV_START_PMF_ENABLED;
1650 ptr = (void *)skb->data;
1652 tlv = ptr;
1653 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD);
1654 tlv->len = __cpu_to_le16(sizeof(*cmd));
1655 cmd = (void *)tlv->value;
1656 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1657 cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval);
1658 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
1659 cmd->flags = __cpu_to_le32(flags);
1660 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
1661 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
1662 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
1664 if (arg->ssid) {
1665 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
1666 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
1669 ptr += sizeof(*tlv);
1670 ptr += sizeof(*cmd);
1672 tlv = ptr;
1673 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
1674 tlv->len = __cpu_to_le16(sizeof(*ch));
1675 ch = (void *)tlv->value;
1676 ath10k_wmi_put_wmi_channel(ch, &arg->channel);
1678 ptr += sizeof(*tlv);
1679 ptr += sizeof(*ch);
1681 tlv = ptr;
1682 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1683 tlv->len = 0;
1684 noa = (void *)tlv->value;
1686 /* Note: This is a nested TLV containing:
1687 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
1690 ptr += sizeof(*tlv);
1691 ptr += 0;
1693 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n");
1694 return skb;
1697 static struct sk_buff *
1698 ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
1700 struct wmi_vdev_stop_cmd *cmd;
1701 struct wmi_tlv *tlv;
1702 struct sk_buff *skb;
1704 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1705 if (!skb)
1706 return ERR_PTR(-ENOMEM);
1708 tlv = (void *)skb->data;
1709 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD);
1710 tlv->len = __cpu_to_le16(sizeof(*cmd));
1711 cmd = (void *)tlv->value;
1712 cmd->vdev_id = __cpu_to_le32(vdev_id);
1714 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n");
1715 return skb;
1718 static struct sk_buff *
1719 ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
1720 const u8 *bssid)
1723 struct wmi_vdev_up_cmd *cmd;
1724 struct wmi_tlv *tlv;
1725 struct sk_buff *skb;
1727 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1728 if (!skb)
1729 return ERR_PTR(-ENOMEM);
1731 tlv = (void *)skb->data;
1732 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD);
1733 tlv->len = __cpu_to_le16(sizeof(*cmd));
1734 cmd = (void *)tlv->value;
1735 cmd->vdev_id = __cpu_to_le32(vdev_id);
1736 cmd->vdev_assoc_id = __cpu_to_le32(aid);
1737 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
1739 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n");
1740 return skb;
1743 static struct sk_buff *
1744 ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
1746 struct wmi_vdev_down_cmd *cmd;
1747 struct wmi_tlv *tlv;
1748 struct sk_buff *skb;
1750 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1751 if (!skb)
1752 return ERR_PTR(-ENOMEM);
1754 tlv = (void *)skb->data;
1755 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD);
1756 tlv->len = __cpu_to_le16(sizeof(*cmd));
1757 cmd = (void *)tlv->value;
1758 cmd->vdev_id = __cpu_to_le32(vdev_id);
1760 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n");
1761 return skb;
1764 static struct sk_buff *
1765 ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
1766 u32 param_id, u32 param_value)
1768 struct wmi_vdev_set_param_cmd *cmd;
1769 struct wmi_tlv *tlv;
1770 struct sk_buff *skb;
1772 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1773 if (!skb)
1774 return ERR_PTR(-ENOMEM);
1776 tlv = (void *)skb->data;
1777 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD);
1778 tlv->len = __cpu_to_le16(sizeof(*cmd));
1779 cmd = (void *)tlv->value;
1780 cmd->vdev_id = __cpu_to_le32(vdev_id);
1781 cmd->param_id = __cpu_to_le32(param_id);
1782 cmd->param_value = __cpu_to_le32(param_value);
1784 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev set param\n");
1785 return skb;
1788 static struct sk_buff *
1789 ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar,
1790 const struct wmi_vdev_install_key_arg *arg)
1792 struct wmi_vdev_install_key_cmd *cmd;
1793 struct wmi_tlv *tlv;
1794 struct sk_buff *skb;
1795 size_t len;
1796 void *ptr;
1798 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
1799 return ERR_PTR(-EINVAL);
1800 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
1801 return ERR_PTR(-EINVAL);
1803 len = sizeof(*tlv) + sizeof(*cmd) +
1804 sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32));
1805 skb = ath10k_wmi_alloc_skb(ar, len);
1806 if (!skb)
1807 return ERR_PTR(-ENOMEM);
1809 ptr = (void *)skb->data;
1810 tlv = ptr;
1811 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD);
1812 tlv->len = __cpu_to_le16(sizeof(*cmd));
1813 cmd = (void *)tlv->value;
1814 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1815 cmd->key_idx = __cpu_to_le32(arg->key_idx);
1816 cmd->key_flags = __cpu_to_le32(arg->key_flags);
1817 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
1818 cmd->key_len = __cpu_to_le32(arg->key_len);
1819 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
1820 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
1822 if (arg->macaddr)
1823 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
1825 ptr += sizeof(*tlv);
1826 ptr += sizeof(*cmd);
1828 tlv = ptr;
1829 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1830 tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32)));
1831 if (arg->key_data)
1832 memcpy(tlv->value, arg->key_data, arg->key_len);
1834 ptr += sizeof(*tlv);
1835 ptr += roundup(arg->key_len, sizeof(__le32));
1837 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n");
1838 return skb;
1841 static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr,
1842 const struct wmi_sta_uapsd_auto_trig_arg *arg)
1844 struct wmi_sta_uapsd_auto_trig_param *ac;
1845 struct wmi_tlv *tlv;
1847 tlv = ptr;
1848 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM);
1849 tlv->len = __cpu_to_le16(sizeof(*ac));
1850 ac = (void *)tlv->value;
1852 ac->wmm_ac = __cpu_to_le32(arg->wmm_ac);
1853 ac->user_priority = __cpu_to_le32(arg->user_priority);
1854 ac->service_interval = __cpu_to_le32(arg->service_interval);
1855 ac->suspend_interval = __cpu_to_le32(arg->suspend_interval);
1856 ac->delay_interval = __cpu_to_le32(arg->delay_interval);
1858 ath10k_dbg(ar, ATH10K_DBG_WMI,
1859 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
1860 ac->wmm_ac, ac->user_priority, ac->service_interval,
1861 ac->suspend_interval, ac->delay_interval);
1863 return ptr + sizeof(*tlv) + sizeof(*ac);
1866 static struct sk_buff *
1867 ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
1868 const u8 peer_addr[ETH_ALEN],
1869 const struct wmi_sta_uapsd_auto_trig_arg *args,
1870 u32 num_ac)
1872 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
1873 struct wmi_sta_uapsd_auto_trig_param *ac;
1874 struct wmi_tlv *tlv;
1875 struct sk_buff *skb;
1876 size_t len;
1877 size_t ac_tlv_len;
1878 void *ptr;
1879 int i;
1881 ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac));
1882 len = sizeof(*tlv) + sizeof(*cmd) +
1883 sizeof(*tlv) + ac_tlv_len;
1884 skb = ath10k_wmi_alloc_skb(ar, len);
1885 if (!skb)
1886 return ERR_PTR(-ENOMEM);
1888 ptr = (void *)skb->data;
1889 tlv = ptr;
1890 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD);
1891 tlv->len = __cpu_to_le16(sizeof(*cmd));
1892 cmd = (void *)tlv->value;
1893 cmd->vdev_id = __cpu_to_le32(vdev_id);
1894 cmd->num_ac = __cpu_to_le32(num_ac);
1895 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1897 ptr += sizeof(*tlv);
1898 ptr += sizeof(*cmd);
1900 tlv = ptr;
1901 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1902 tlv->len = __cpu_to_le16(ac_tlv_len);
1903 ac = (void *)tlv->value;
1905 ptr += sizeof(*tlv);
1906 for (i = 0; i < num_ac; i++)
1907 ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]);
1909 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n");
1910 return skb;
1913 static void *ath10k_wmi_tlv_put_wmm(void *ptr,
1914 const struct wmi_wmm_params_arg *arg)
1916 struct wmi_wmm_params *wmm;
1917 struct wmi_tlv *tlv;
1919 tlv = ptr;
1920 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS);
1921 tlv->len = __cpu_to_le16(sizeof(*wmm));
1922 wmm = (void *)tlv->value;
1923 ath10k_wmi_set_wmm_param(wmm, arg);
1925 return ptr + sizeof(*tlv) + sizeof(*wmm);
1928 static struct sk_buff *
1929 ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
1930 const struct wmi_wmm_params_all_arg *arg)
1932 struct wmi_tlv_vdev_set_wmm_cmd *cmd;
1933 struct wmi_tlv *tlv;
1934 struct sk_buff *skb;
1935 size_t len;
1936 void *ptr;
1938 len = sizeof(*tlv) + sizeof(*cmd);
1939 skb = ath10k_wmi_alloc_skb(ar, len);
1940 if (!skb)
1941 return ERR_PTR(-ENOMEM);
1943 ptr = (void *)skb->data;
1944 tlv = ptr;
1945 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD);
1946 tlv->len = __cpu_to_le16(sizeof(*cmd));
1947 cmd = (void *)tlv->value;
1948 cmd->vdev_id = __cpu_to_le32(vdev_id);
1950 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be);
1951 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk);
1952 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi);
1953 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo);
1955 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n");
1956 return skb;
1959 static struct sk_buff *
1960 ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
1961 const struct wmi_sta_keepalive_arg *arg)
1963 struct wmi_tlv_sta_keepalive_cmd *cmd;
1964 struct wmi_sta_keepalive_arp_resp *arp;
1965 struct sk_buff *skb;
1966 struct wmi_tlv *tlv;
1967 void *ptr;
1968 size_t len;
1970 len = sizeof(*tlv) + sizeof(*cmd) +
1971 sizeof(*tlv) + sizeof(*arp);
1972 skb = ath10k_wmi_alloc_skb(ar, len);
1973 if (!skb)
1974 return ERR_PTR(-ENOMEM);
1976 ptr = (void *)skb->data;
1977 tlv = ptr;
1978 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD);
1979 tlv->len = __cpu_to_le16(sizeof(*cmd));
1980 cmd = (void *)tlv->value;
1981 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1982 cmd->enabled = __cpu_to_le32(arg->enabled);
1983 cmd->method = __cpu_to_le32(arg->method);
1984 cmd->interval = __cpu_to_le32(arg->interval);
1986 ptr += sizeof(*tlv);
1987 ptr += sizeof(*cmd);
1989 tlv = ptr;
1990 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE);
1991 tlv->len = __cpu_to_le16(sizeof(*arp));
1992 arp = (void *)tlv->value;
1994 arp->src_ip4_addr = arg->src_ip4_addr;
1995 arp->dest_ip4_addr = arg->dest_ip4_addr;
1996 ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
1998 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d inverval %d\n",
1999 arg->vdev_id, arg->enabled, arg->method, arg->interval);
2000 return skb;
2003 static struct sk_buff *
2004 ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
2005 const u8 peer_addr[ETH_ALEN],
2006 enum wmi_peer_type peer_type)
2008 struct wmi_tlv_peer_create_cmd *cmd;
2009 struct wmi_tlv *tlv;
2010 struct sk_buff *skb;
2012 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2013 if (!skb)
2014 return ERR_PTR(-ENOMEM);
2016 tlv = (void *)skb->data;
2017 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD);
2018 tlv->len = __cpu_to_le16(sizeof(*cmd));
2019 cmd = (void *)tlv->value;
2020 cmd->vdev_id = __cpu_to_le32(vdev_id);
2021 cmd->peer_type = __cpu_to_le32(peer_type);
2022 ether_addr_copy(cmd->peer_addr.addr, peer_addr);
2024 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n");
2025 return skb;
2028 static struct sk_buff *
2029 ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
2030 const u8 peer_addr[ETH_ALEN])
2032 struct wmi_peer_delete_cmd *cmd;
2033 struct wmi_tlv *tlv;
2034 struct sk_buff *skb;
2036 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2037 if (!skb)
2038 return ERR_PTR(-ENOMEM);
2040 tlv = (void *)skb->data;
2041 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD);
2042 tlv->len = __cpu_to_le16(sizeof(*cmd));
2043 cmd = (void *)tlv->value;
2044 cmd->vdev_id = __cpu_to_le32(vdev_id);
2045 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2047 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n");
2048 return skb;
2051 static struct sk_buff *
2052 ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
2053 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
2055 struct wmi_peer_flush_tids_cmd *cmd;
2056 struct wmi_tlv *tlv;
2057 struct sk_buff *skb;
2059 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2060 if (!skb)
2061 return ERR_PTR(-ENOMEM);
2063 tlv = (void *)skb->data;
2064 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD);
2065 tlv->len = __cpu_to_le16(sizeof(*cmd));
2066 cmd = (void *)tlv->value;
2067 cmd->vdev_id = __cpu_to_le32(vdev_id);
2068 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
2069 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2071 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n");
2072 return skb;
2075 static struct sk_buff *
2076 ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
2077 const u8 *peer_addr,
2078 enum wmi_peer_param param_id,
2079 u32 param_value)
2081 struct wmi_peer_set_param_cmd *cmd;
2082 struct wmi_tlv *tlv;
2083 struct sk_buff *skb;
2085 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2086 if (!skb)
2087 return ERR_PTR(-ENOMEM);
2089 tlv = (void *)skb->data;
2090 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD);
2091 tlv->len = __cpu_to_le16(sizeof(*cmd));
2092 cmd = (void *)tlv->value;
2093 cmd->vdev_id = __cpu_to_le32(vdev_id);
2094 cmd->param_id = __cpu_to_le32(param_id);
2095 cmd->param_value = __cpu_to_le32(param_value);
2096 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2098 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer set param\n");
2099 return skb;
2102 static struct sk_buff *
2103 ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar,
2104 const struct wmi_peer_assoc_complete_arg *arg)
2106 struct wmi_tlv_peer_assoc_cmd *cmd;
2107 struct wmi_vht_rate_set *vht_rate;
2108 struct wmi_tlv *tlv;
2109 struct sk_buff *skb;
2110 size_t len, legacy_rate_len, ht_rate_len;
2111 void *ptr;
2113 if (arg->peer_mpdu_density > 16)
2114 return ERR_PTR(-EINVAL);
2115 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
2116 return ERR_PTR(-EINVAL);
2117 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
2118 return ERR_PTR(-EINVAL);
2120 legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates,
2121 sizeof(__le32));
2122 ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32));
2123 len = (sizeof(*tlv) + sizeof(*cmd)) +
2124 (sizeof(*tlv) + legacy_rate_len) +
2125 (sizeof(*tlv) + ht_rate_len) +
2126 (sizeof(*tlv) + sizeof(*vht_rate));
2127 skb = ath10k_wmi_alloc_skb(ar, len);
2128 if (!skb)
2129 return ERR_PTR(-ENOMEM);
2131 ptr = (void *)skb->data;
2132 tlv = ptr;
2133 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD);
2134 tlv->len = __cpu_to_le16(sizeof(*cmd));
2135 cmd = (void *)tlv->value;
2137 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2138 cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
2139 cmd->assoc_id = __cpu_to_le32(arg->peer_aid);
2140 cmd->flags = __cpu_to_le32(arg->peer_flags);
2141 cmd->caps = __cpu_to_le32(arg->peer_caps);
2142 cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval);
2143 cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps);
2144 cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
2145 cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
2146 cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps);
2147 cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams);
2148 cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps);
2149 cmd->phy_mode = __cpu_to_le32(arg->peer_phymode);
2150 cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates);
2151 cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates);
2152 ether_addr_copy(cmd->mac_addr.addr, arg->addr);
2154 ptr += sizeof(*tlv);
2155 ptr += sizeof(*cmd);
2157 tlv = ptr;
2158 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2159 tlv->len = __cpu_to_le16(legacy_rate_len);
2160 memcpy(tlv->value, arg->peer_legacy_rates.rates,
2161 arg->peer_legacy_rates.num_rates);
2163 ptr += sizeof(*tlv);
2164 ptr += legacy_rate_len;
2166 tlv = ptr;
2167 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2168 tlv->len = __cpu_to_le16(ht_rate_len);
2169 memcpy(tlv->value, arg->peer_ht_rates.rates,
2170 arg->peer_ht_rates.num_rates);
2172 ptr += sizeof(*tlv);
2173 ptr += ht_rate_len;
2175 tlv = ptr;
2176 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET);
2177 tlv->len = __cpu_to_le16(sizeof(*vht_rate));
2178 vht_rate = (void *)tlv->value;
2180 vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
2181 vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
2182 vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
2183 vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
2185 ptr += sizeof(*tlv);
2186 ptr += sizeof(*vht_rate);
2188 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n");
2189 return skb;
2192 static struct sk_buff *
2193 ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
2194 enum wmi_sta_ps_mode psmode)
2196 struct wmi_sta_powersave_mode_cmd *cmd;
2197 struct wmi_tlv *tlv;
2198 struct sk_buff *skb;
2200 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2201 if (!skb)
2202 return ERR_PTR(-ENOMEM);
2204 tlv = (void *)skb->data;
2205 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD);
2206 tlv->len = __cpu_to_le16(sizeof(*cmd));
2207 cmd = (void *)tlv->value;
2208 cmd->vdev_id = __cpu_to_le32(vdev_id);
2209 cmd->sta_ps_mode = __cpu_to_le32(psmode);
2211 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n");
2212 return skb;
2215 static struct sk_buff *
2216 ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
2217 enum wmi_sta_powersave_param param_id,
2218 u32 param_value)
2220 struct wmi_sta_powersave_param_cmd *cmd;
2221 struct wmi_tlv *tlv;
2222 struct sk_buff *skb;
2224 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2225 if (!skb)
2226 return ERR_PTR(-ENOMEM);
2228 tlv = (void *)skb->data;
2229 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD);
2230 tlv->len = __cpu_to_le16(sizeof(*cmd));
2231 cmd = (void *)tlv->value;
2232 cmd->vdev_id = __cpu_to_le32(vdev_id);
2233 cmd->param_id = __cpu_to_le32(param_id);
2234 cmd->param_value = __cpu_to_le32(param_value);
2236 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n");
2237 return skb;
2240 static struct sk_buff *
2241 ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
2242 enum wmi_ap_ps_peer_param param_id, u32 value)
2244 struct wmi_ap_ps_peer_cmd *cmd;
2245 struct wmi_tlv *tlv;
2246 struct sk_buff *skb;
2248 if (!mac)
2249 return ERR_PTR(-EINVAL);
2251 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2252 if (!skb)
2253 return ERR_PTR(-ENOMEM);
2255 tlv = (void *)skb->data;
2256 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD);
2257 tlv->len = __cpu_to_le16(sizeof(*cmd));
2258 cmd = (void *)tlv->value;
2259 cmd->vdev_id = __cpu_to_le32(vdev_id);
2260 cmd->param_id = __cpu_to_le32(param_id);
2261 cmd->param_value = __cpu_to_le32(value);
2262 ether_addr_copy(cmd->peer_macaddr.addr, mac);
2264 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n");
2265 return skb;
2268 static struct sk_buff *
2269 ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar,
2270 const struct wmi_scan_chan_list_arg *arg)
2272 struct wmi_tlv_scan_chan_list_cmd *cmd;
2273 struct wmi_channel *ci;
2274 struct wmi_channel_arg *ch;
2275 struct wmi_tlv *tlv;
2276 struct sk_buff *skb;
2277 size_t chans_len, len;
2278 int i;
2279 void *ptr, *chans;
2281 chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci));
2282 len = (sizeof(*tlv) + sizeof(*cmd)) +
2283 (sizeof(*tlv) + chans_len);
2285 skb = ath10k_wmi_alloc_skb(ar, len);
2286 if (!skb)
2287 return ERR_PTR(-ENOMEM);
2289 ptr = (void *)skb->data;
2290 tlv = ptr;
2291 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD);
2292 tlv->len = __cpu_to_le16(sizeof(*cmd));
2293 cmd = (void *)tlv->value;
2294 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
2296 ptr += sizeof(*tlv);
2297 ptr += sizeof(*cmd);
2299 tlv = ptr;
2300 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2301 tlv->len = __cpu_to_le16(chans_len);
2302 chans = (void *)tlv->value;
2304 for (i = 0; i < arg->n_channels; i++) {
2305 ch = &arg->channels[i];
2307 tlv = chans;
2308 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2309 tlv->len = __cpu_to_le16(sizeof(*ci));
2310 ci = (void *)tlv->value;
2312 ath10k_wmi_put_wmi_channel(ci, ch);
2314 chans += sizeof(*tlv);
2315 chans += sizeof(*ci);
2318 ptr += sizeof(*tlv);
2319 ptr += chans_len;
2321 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n");
2322 return skb;
2325 static struct sk_buff *
2326 ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id,
2327 const void *bcn, size_t bcn_len,
2328 u32 bcn_paddr, bool dtim_zero,
2329 bool deliver_cab)
2332 struct wmi_bcn_tx_ref_cmd *cmd;
2333 struct wmi_tlv *tlv;
2334 struct sk_buff *skb;
2335 struct ieee80211_hdr *hdr;
2336 u16 fc;
2338 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2339 if (!skb)
2340 return ERR_PTR(-ENOMEM);
2342 hdr = (struct ieee80211_hdr *)bcn;
2343 fc = le16_to_cpu(hdr->frame_control);
2345 tlv = (void *)skb->data;
2346 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD);
2347 tlv->len = __cpu_to_le16(sizeof(*cmd));
2348 cmd = (void *)tlv->value;
2349 cmd->vdev_id = __cpu_to_le32(vdev_id);
2350 cmd->data_len = __cpu_to_le32(bcn_len);
2351 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
2352 cmd->msdu_id = 0;
2353 cmd->frame_control = __cpu_to_le32(fc);
2354 cmd->flags = 0;
2356 if (dtim_zero)
2357 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
2359 if (deliver_cab)
2360 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
2362 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n");
2363 return skb;
2366 static struct sk_buff *
2367 ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar,
2368 const struct wmi_wmm_params_all_arg *arg)
2370 struct wmi_tlv_pdev_set_wmm_cmd *cmd;
2371 struct wmi_wmm_params *wmm;
2372 struct wmi_tlv *tlv;
2373 struct sk_buff *skb;
2374 size_t len;
2375 void *ptr;
2377 len = (sizeof(*tlv) + sizeof(*cmd)) +
2378 (4 * (sizeof(*tlv) + sizeof(*wmm)));
2379 skb = ath10k_wmi_alloc_skb(ar, len);
2380 if (!skb)
2381 return ERR_PTR(-ENOMEM);
2383 ptr = (void *)skb->data;
2385 tlv = ptr;
2386 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD);
2387 tlv->len = __cpu_to_le16(sizeof(*cmd));
2388 cmd = (void *)tlv->value;
2390 /* nothing to set here */
2392 ptr += sizeof(*tlv);
2393 ptr += sizeof(*cmd);
2395 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be);
2396 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk);
2397 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi);
2398 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo);
2400 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n");
2401 return skb;
2404 static struct sk_buff *
2405 ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
2407 struct wmi_request_stats_cmd *cmd;
2408 struct wmi_tlv *tlv;
2409 struct sk_buff *skb;
2411 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2412 if (!skb)
2413 return ERR_PTR(-ENOMEM);
2415 tlv = (void *)skb->data;
2416 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD);
2417 tlv->len = __cpu_to_le16(sizeof(*cmd));
2418 cmd = (void *)tlv->value;
2419 cmd->stats_id = __cpu_to_le32(stats_mask);
2421 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n");
2422 return skb;
2425 static struct sk_buff *
2426 ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar,
2427 enum wmi_force_fw_hang_type type,
2428 u32 delay_ms)
2430 struct wmi_force_fw_hang_cmd *cmd;
2431 struct wmi_tlv *tlv;
2432 struct sk_buff *skb;
2434 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2435 if (!skb)
2436 return ERR_PTR(-ENOMEM);
2438 tlv = (void *)skb->data;
2439 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD);
2440 tlv->len = __cpu_to_le16(sizeof(*cmd));
2441 cmd = (void *)tlv->value;
2442 cmd->type = __cpu_to_le32(type);
2443 cmd->delay_ms = __cpu_to_le32(delay_ms);
2445 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n");
2446 return skb;
2449 static struct sk_buff *
2450 ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
2451 u32 log_level) {
2452 struct wmi_tlv_dbglog_cmd *cmd;
2453 struct wmi_tlv *tlv;
2454 struct sk_buff *skb;
2455 size_t len, bmap_len;
2456 u32 value;
2457 void *ptr;
2459 if (module_enable) {
2460 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2461 module_enable,
2462 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE);
2463 } else {
2464 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2465 WMI_TLV_DBGLOG_ALL_MODULES,
2466 WMI_TLV_DBGLOG_LOG_LEVEL_WARN);
2469 bmap_len = 0;
2470 len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len;
2471 skb = ath10k_wmi_alloc_skb(ar, len);
2472 if (!skb)
2473 return ERR_PTR(-ENOMEM);
2475 ptr = (void *)skb->data;
2477 tlv = ptr;
2478 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD);
2479 tlv->len = __cpu_to_le16(sizeof(*cmd));
2480 cmd = (void *)tlv->value;
2481 cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL);
2482 cmd->value = __cpu_to_le32(value);
2484 ptr += sizeof(*tlv);
2485 ptr += sizeof(*cmd);
2487 tlv = ptr;
2488 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
2489 tlv->len = __cpu_to_le16(bmap_len);
2491 /* nothing to do here */
2493 ptr += sizeof(*tlv);
2494 ptr += sizeof(bmap_len);
2496 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value);
2497 return skb;
2500 static struct sk_buff *
2501 ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter)
2503 struct wmi_tlv_pktlog_enable *cmd;
2504 struct wmi_tlv *tlv;
2505 struct sk_buff *skb;
2506 void *ptr;
2507 size_t len;
2509 len = sizeof(*tlv) + sizeof(*cmd);
2510 skb = ath10k_wmi_alloc_skb(ar, len);
2511 if (!skb)
2512 return ERR_PTR(-ENOMEM);
2514 ptr = (void *)skb->data;
2515 tlv = ptr;
2516 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD);
2517 tlv->len = __cpu_to_le16(sizeof(*cmd));
2518 cmd = (void *)tlv->value;
2519 cmd->filter = __cpu_to_le32(filter);
2521 ptr += sizeof(*tlv);
2522 ptr += sizeof(*cmd);
2524 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n",
2525 filter);
2526 return skb;
2529 static struct sk_buff *
2530 ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar)
2532 struct wmi_tlv_pktlog_disable *cmd;
2533 struct wmi_tlv *tlv;
2534 struct sk_buff *skb;
2535 void *ptr;
2536 size_t len;
2538 len = sizeof(*tlv) + sizeof(*cmd);
2539 skb = ath10k_wmi_alloc_skb(ar, len);
2540 if (!skb)
2541 return ERR_PTR(-ENOMEM);
2543 ptr = (void *)skb->data;
2544 tlv = ptr;
2545 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD);
2546 tlv->len = __cpu_to_le16(sizeof(*cmd));
2547 cmd = (void *)tlv->value;
2549 ptr += sizeof(*tlv);
2550 ptr += sizeof(*cmd);
2552 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n");
2553 return skb;
2556 static struct sk_buff *
2557 ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id,
2558 u32 tim_ie_offset, struct sk_buff *bcn,
2559 u32 prb_caps, u32 prb_erp, void *prb_ies,
2560 size_t prb_ies_len)
2562 struct wmi_tlv_bcn_tmpl_cmd *cmd;
2563 struct wmi_tlv_bcn_prb_info *info;
2564 struct wmi_tlv *tlv;
2565 struct sk_buff *skb;
2566 void *ptr;
2567 size_t len;
2569 if (WARN_ON(prb_ies_len > 0 && !prb_ies))
2570 return ERR_PTR(-EINVAL);
2572 len = sizeof(*tlv) + sizeof(*cmd) +
2573 sizeof(*tlv) + sizeof(*info) + prb_ies_len +
2574 sizeof(*tlv) + roundup(bcn->len, 4);
2575 skb = ath10k_wmi_alloc_skb(ar, len);
2576 if (!skb)
2577 return ERR_PTR(-ENOMEM);
2579 ptr = (void *)skb->data;
2580 tlv = ptr;
2581 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD);
2582 tlv->len = __cpu_to_le16(sizeof(*cmd));
2583 cmd = (void *)tlv->value;
2584 cmd->vdev_id = __cpu_to_le32(vdev_id);
2585 cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset);
2586 cmd->buf_len = __cpu_to_le32(bcn->len);
2588 ptr += sizeof(*tlv);
2589 ptr += sizeof(*cmd);
2591 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
2592 * then it is then impossible to pass original ie len.
2593 * This chunk is not used yet so if setting probe resp template yields
2594 * problems with beaconing or crashes firmware look here.
2596 tlv = ptr;
2597 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2598 tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len);
2599 info = (void *)tlv->value;
2600 info->caps = __cpu_to_le32(prb_caps);
2601 info->erp = __cpu_to_le32(prb_erp);
2602 memcpy(info->ies, prb_ies, prb_ies_len);
2604 ptr += sizeof(*tlv);
2605 ptr += sizeof(*info);
2606 ptr += prb_ies_len;
2608 tlv = ptr;
2609 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2610 tlv->len = __cpu_to_le16(roundup(bcn->len, 4));
2611 memcpy(tlv->value, bcn->data, bcn->len);
2613 /* FIXME: Adjust TSF? */
2615 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n",
2616 vdev_id);
2617 return skb;
2620 static struct sk_buff *
2621 ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id,
2622 struct sk_buff *prb)
2624 struct wmi_tlv_prb_tmpl_cmd *cmd;
2625 struct wmi_tlv_bcn_prb_info *info;
2626 struct wmi_tlv *tlv;
2627 struct sk_buff *skb;
2628 void *ptr;
2629 size_t len;
2631 len = sizeof(*tlv) + sizeof(*cmd) +
2632 sizeof(*tlv) + sizeof(*info) +
2633 sizeof(*tlv) + roundup(prb->len, 4);
2634 skb = ath10k_wmi_alloc_skb(ar, len);
2635 if (!skb)
2636 return ERR_PTR(-ENOMEM);
2638 ptr = (void *)skb->data;
2639 tlv = ptr;
2640 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD);
2641 tlv->len = __cpu_to_le16(sizeof(*cmd));
2642 cmd = (void *)tlv->value;
2643 cmd->vdev_id = __cpu_to_le32(vdev_id);
2644 cmd->buf_len = __cpu_to_le32(prb->len);
2646 ptr += sizeof(*tlv);
2647 ptr += sizeof(*cmd);
2649 tlv = ptr;
2650 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2651 tlv->len = __cpu_to_le16(sizeof(*info));
2652 info = (void *)tlv->value;
2653 info->caps = 0;
2654 info->erp = 0;
2656 ptr += sizeof(*tlv);
2657 ptr += sizeof(*info);
2659 tlv = ptr;
2660 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2661 tlv->len = __cpu_to_le16(roundup(prb->len, 4));
2662 memcpy(tlv->value, prb->data, prb->len);
2664 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n",
2665 vdev_id);
2666 return skb;
2669 static struct sk_buff *
2670 ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
2671 const u8 *p2p_ie)
2673 struct wmi_tlv_p2p_go_bcn_ie *cmd;
2674 struct wmi_tlv *tlv;
2675 struct sk_buff *skb;
2676 void *ptr;
2677 size_t len;
2679 len = sizeof(*tlv) + sizeof(*cmd) +
2680 sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4);
2681 skb = ath10k_wmi_alloc_skb(ar, len);
2682 if (!skb)
2683 return ERR_PTR(-ENOMEM);
2685 ptr = (void *)skb->data;
2686 tlv = ptr;
2687 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE);
2688 tlv->len = __cpu_to_le16(sizeof(*cmd));
2689 cmd = (void *)tlv->value;
2690 cmd->vdev_id = __cpu_to_le32(vdev_id);
2691 cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2);
2693 ptr += sizeof(*tlv);
2694 ptr += sizeof(*cmd);
2696 tlv = ptr;
2697 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2698 tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4));
2699 memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2);
2701 ptr += sizeof(*tlv);
2702 ptr += roundup(p2p_ie[1] + 2, 4);
2704 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n",
2705 vdev_id);
2706 return skb;
2709 static struct sk_buff *
2710 ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
2711 enum wmi_tdls_state state)
2713 struct wmi_tdls_set_state_cmd *cmd;
2714 struct wmi_tlv *tlv;
2715 struct sk_buff *skb;
2716 void *ptr;
2717 size_t len;
2718 /* Set to options from wmi_tlv_tdls_options,
2719 * for now none of them are enabled.
2721 u32 options = 0;
2723 len = sizeof(*tlv) + sizeof(*cmd);
2724 skb = ath10k_wmi_alloc_skb(ar, len);
2725 if (!skb)
2726 return ERR_PTR(-ENOMEM);
2728 ptr = (void *)skb->data;
2729 tlv = ptr;
2730 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD);
2731 tlv->len = __cpu_to_le16(sizeof(*cmd));
2733 cmd = (void *)tlv->value;
2734 cmd->vdev_id = __cpu_to_le32(vdev_id);
2735 cmd->state = __cpu_to_le32(state);
2736 cmd->notification_interval_ms = __cpu_to_le32(5000);
2737 cmd->tx_discovery_threshold = __cpu_to_le32(100);
2738 cmd->tx_teardown_threshold = __cpu_to_le32(5);
2739 cmd->rssi_teardown_threshold = __cpu_to_le32(-75);
2740 cmd->rssi_delta = __cpu_to_le32(-20);
2741 cmd->tdls_options = __cpu_to_le32(options);
2742 cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2);
2743 cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000);
2744 cmd->tdls_puapsd_mask = __cpu_to_le32(0xf);
2745 cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0);
2746 cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10);
2748 ptr += sizeof(*tlv);
2749 ptr += sizeof(*cmd);
2751 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv update fw tdls state %d for vdev %i\n",
2752 state, vdev_id);
2753 return skb;
2756 static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
2758 u32 peer_qos = 0;
2760 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
2761 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VO;
2762 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
2763 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VI;
2764 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
2765 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BK;
2766 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
2767 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BE;
2769 peer_qos |= SM(sp, WMI_TLV_TDLS_PEER_SP);
2771 return peer_qos;
2774 static struct sk_buff *
2775 ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k *ar,
2776 const struct wmi_tdls_peer_update_cmd_arg *arg,
2777 const struct wmi_tdls_peer_capab_arg *cap,
2778 const struct wmi_channel_arg *chan_arg)
2780 struct wmi_tdls_peer_update_cmd *cmd;
2781 struct wmi_tdls_peer_capab *peer_cap;
2782 struct wmi_channel *chan;
2783 struct wmi_tlv *tlv;
2784 struct sk_buff *skb;
2785 u32 peer_qos;
2786 void *ptr;
2787 int len;
2788 int i;
2790 len = sizeof(*tlv) + sizeof(*cmd) +
2791 sizeof(*tlv) + sizeof(*peer_cap) +
2792 sizeof(*tlv) + cap->peer_chan_len * sizeof(*chan);
2794 skb = ath10k_wmi_alloc_skb(ar, len);
2795 if (!skb)
2796 return ERR_PTR(-ENOMEM);
2798 ptr = (void *)skb->data;
2799 tlv = ptr;
2800 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD);
2801 tlv->len = __cpu_to_le16(sizeof(*cmd));
2803 cmd = (void *)tlv->value;
2804 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2805 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
2806 cmd->peer_state = __cpu_to_le32(arg->peer_state);
2808 ptr += sizeof(*tlv);
2809 ptr += sizeof(*cmd);
2811 tlv = ptr;
2812 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES);
2813 tlv->len = __cpu_to_le16(sizeof(*peer_cap));
2814 peer_cap = (void *)tlv->value;
2815 peer_qos = ath10k_wmi_tlv_prepare_peer_qos(cap->peer_uapsd_queues,
2816 cap->peer_max_sp);
2817 peer_cap->peer_qos = __cpu_to_le32(peer_qos);
2818 peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support);
2819 peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support);
2820 peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass);
2821 peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass);
2822 peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len);
2823 peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len);
2825 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++)
2826 peer_cap->peer_operclass[i] = cap->peer_operclass[i];
2828 peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder);
2829 peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num);
2830 peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw);
2832 ptr += sizeof(*tlv);
2833 ptr += sizeof(*peer_cap);
2835 tlv = ptr;
2836 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2837 tlv->len = __cpu_to_le16(cap->peer_chan_len * sizeof(*chan));
2839 ptr += sizeof(*tlv);
2841 for (i = 0; i < cap->peer_chan_len; i++) {
2842 tlv = ptr;
2843 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2844 tlv->len = __cpu_to_le16(sizeof(*chan));
2845 chan = (void *)tlv->value;
2846 ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
2848 ptr += sizeof(*tlv);
2849 ptr += sizeof(*chan);
2852 ath10k_dbg(ar, ATH10K_DBG_WMI,
2853 "wmi tlv tdls peer update vdev %i state %d n_chans %u\n",
2854 arg->vdev_id, arg->peer_state, cap->peer_chan_len);
2855 return skb;
2858 static struct sk_buff *
2859 ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar)
2861 struct wmi_tlv_wow_enable_cmd *cmd;
2862 struct wmi_tlv *tlv;
2863 struct sk_buff *skb;
2864 size_t len;
2866 len = sizeof(*tlv) + sizeof(*cmd);
2867 skb = ath10k_wmi_alloc_skb(ar, len);
2868 if (!skb)
2869 return ERR_PTR(-ENOMEM);
2871 tlv = (struct wmi_tlv *)skb->data;
2872 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD);
2873 tlv->len = __cpu_to_le16(sizeof(*cmd));
2874 cmd = (void *)tlv->value;
2876 cmd->enable = __cpu_to_le32(1);
2878 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n");
2879 return skb;
2882 static struct sk_buff *
2883 ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,
2884 u32 vdev_id,
2885 enum wmi_wow_wakeup_event event,
2886 u32 enable)
2888 struct wmi_tlv_wow_add_del_event_cmd *cmd;
2889 struct wmi_tlv *tlv;
2890 struct sk_buff *skb;
2891 size_t len;
2893 len = sizeof(*tlv) + sizeof(*cmd);
2894 skb = ath10k_wmi_alloc_skb(ar, len);
2895 if (!skb)
2896 return ERR_PTR(-ENOMEM);
2898 tlv = (struct wmi_tlv *)skb->data;
2899 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD);
2900 tlv->len = __cpu_to_le16(sizeof(*cmd));
2901 cmd = (void *)tlv->value;
2903 cmd->vdev_id = __cpu_to_le32(vdev_id);
2904 cmd->is_add = __cpu_to_le32(enable);
2905 cmd->event_bitmap = __cpu_to_le32(1 << event);
2907 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
2908 wow_wakeup_event(event), enable, vdev_id);
2909 return skb;
2912 static struct sk_buff *
2913 ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar)
2915 struct wmi_tlv_wow_host_wakeup_ind *cmd;
2916 struct wmi_tlv *tlv;
2917 struct sk_buff *skb;
2918 size_t len;
2920 len = sizeof(*tlv) + sizeof(*cmd);
2921 skb = ath10k_wmi_alloc_skb(ar, len);
2922 if (!skb)
2923 return ERR_PTR(-ENOMEM);
2925 tlv = (struct wmi_tlv *)skb->data;
2926 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
2927 tlv->len = __cpu_to_le16(sizeof(*cmd));
2928 cmd = (void *)tlv->value;
2930 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
2931 return skb;
2934 static struct sk_buff *
2935 ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k *ar, u32 vdev_id,
2936 u32 pattern_id, const u8 *pattern,
2937 const u8 *bitmask, int pattern_len,
2938 int pattern_offset)
2940 struct wmi_tlv_wow_add_pattern_cmd *cmd;
2941 struct wmi_tlv_wow_bitmap_pattern *bitmap;
2942 struct wmi_tlv *tlv;
2943 struct sk_buff *skb;
2944 void *ptr;
2945 size_t len;
2947 len = sizeof(*tlv) + sizeof(*cmd) +
2948 sizeof(*tlv) + /* array struct */
2949 sizeof(*tlv) + sizeof(*bitmap) + /* bitmap */
2950 sizeof(*tlv) + /* empty ipv4 sync */
2951 sizeof(*tlv) + /* empty ipv6 sync */
2952 sizeof(*tlv) + /* empty magic */
2953 sizeof(*tlv) + /* empty info timeout */
2954 sizeof(*tlv) + sizeof(u32); /* ratelimit interval */
2956 skb = ath10k_wmi_alloc_skb(ar, len);
2957 if (!skb)
2958 return ERR_PTR(-ENOMEM);
2960 /* cmd */
2961 ptr = (void *)skb->data;
2962 tlv = ptr;
2963 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD);
2964 tlv->len = __cpu_to_le16(sizeof(*cmd));
2965 cmd = (void *)tlv->value;
2967 cmd->vdev_id = __cpu_to_le32(vdev_id);
2968 cmd->pattern_id = __cpu_to_le32(pattern_id);
2969 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
2971 ptr += sizeof(*tlv);
2972 ptr += sizeof(*cmd);
2974 /* bitmap */
2975 tlv = ptr;
2976 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2977 tlv->len = __cpu_to_le16(sizeof(*tlv) + sizeof(*bitmap));
2979 ptr += sizeof(*tlv);
2981 tlv = ptr;
2982 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T);
2983 tlv->len = __cpu_to_le16(sizeof(*bitmap));
2984 bitmap = (void *)tlv->value;
2986 memcpy(bitmap->patternbuf, pattern, pattern_len);
2987 memcpy(bitmap->bitmaskbuf, bitmask, pattern_len);
2988 bitmap->pattern_offset = __cpu_to_le32(pattern_offset);
2989 bitmap->pattern_len = __cpu_to_le32(pattern_len);
2990 bitmap->bitmask_len = __cpu_to_le32(pattern_len);
2991 bitmap->pattern_id = __cpu_to_le32(pattern_id);
2993 ptr += sizeof(*tlv);
2994 ptr += sizeof(*bitmap);
2996 /* ipv4 sync */
2997 tlv = ptr;
2998 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2999 tlv->len = __cpu_to_le16(0);
3001 ptr += sizeof(*tlv);
3003 /* ipv6 sync */
3004 tlv = ptr;
3005 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3006 tlv->len = __cpu_to_le16(0);
3008 ptr += sizeof(*tlv);
3010 /* magic */
3011 tlv = ptr;
3012 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3013 tlv->len = __cpu_to_le16(0);
3015 ptr += sizeof(*tlv);
3017 /* pattern info timeout */
3018 tlv = ptr;
3019 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3020 tlv->len = __cpu_to_le16(0);
3022 ptr += sizeof(*tlv);
3024 /* ratelimit interval */
3025 tlv = ptr;
3026 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3027 tlv->len = __cpu_to_le16(sizeof(u32));
3029 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n",
3030 vdev_id, pattern_id, pattern_offset);
3031 return skb;
3034 static struct sk_buff *
3035 ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k *ar, u32 vdev_id,
3036 u32 pattern_id)
3038 struct wmi_tlv_wow_del_pattern_cmd *cmd;
3039 struct wmi_tlv *tlv;
3040 struct sk_buff *skb;
3041 size_t len;
3043 len = sizeof(*tlv) + sizeof(*cmd);
3044 skb = ath10k_wmi_alloc_skb(ar, len);
3045 if (!skb)
3046 return ERR_PTR(-ENOMEM);
3048 tlv = (struct wmi_tlv *)skb->data;
3049 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD);
3050 tlv->len = __cpu_to_le16(sizeof(*cmd));
3051 cmd = (void *)tlv->value;
3053 cmd->vdev_id = __cpu_to_le32(vdev_id);
3054 cmd->pattern_id = __cpu_to_le32(pattern_id);
3055 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
3057 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n",
3058 vdev_id, pattern_id);
3059 return skb;
3062 static struct sk_buff *
3063 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable)
3065 struct wmi_tlv_adaptive_qcs *cmd;
3066 struct wmi_tlv *tlv;
3067 struct sk_buff *skb;
3068 void *ptr;
3069 size_t len;
3071 len = sizeof(*tlv) + sizeof(*cmd);
3072 skb = ath10k_wmi_alloc_skb(ar, len);
3073 if (!skb)
3074 return ERR_PTR(-ENOMEM);
3076 ptr = (void *)skb->data;
3077 tlv = ptr;
3078 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD);
3079 tlv->len = __cpu_to_le16(sizeof(*cmd));
3080 cmd = (void *)tlv->value;
3081 cmd->enable = __cpu_to_le32(enable ? 1 : 0);
3083 ptr += sizeof(*tlv);
3084 ptr += sizeof(*cmd);
3086 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv adaptive qcs %d\n", enable);
3087 return skb;
3090 /****************/
3091 /* TLV mappings */
3092 /****************/
3094 static struct wmi_cmd_map wmi_tlv_cmd_map = {
3095 .init_cmdid = WMI_TLV_INIT_CMDID,
3096 .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID,
3097 .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID,
3098 .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID,
3099 .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID,
3100 .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID,
3101 .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID,
3102 .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID,
3103 .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID,
3104 .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID,
3105 .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID,
3106 .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID,
3107 .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID,
3108 .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID,
3109 .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID,
3110 .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID,
3111 .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID,
3112 .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID,
3113 .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID,
3114 .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID,
3115 .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID,
3116 .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID,
3117 .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID,
3118 .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID,
3119 .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID,
3120 .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID,
3121 .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID,
3122 .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID,
3123 .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID,
3124 .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID,
3125 .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID,
3126 .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID,
3127 .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID,
3128 .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID,
3129 .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID,
3130 .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID,
3131 .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID,
3132 .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID,
3133 .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID,
3134 .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID,
3135 .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID,
3136 .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID,
3137 .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID,
3138 .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID,
3139 .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID,
3140 .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID,
3141 .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID,
3142 .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID,
3143 .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID,
3144 .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID,
3145 .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID,
3146 .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID,
3147 .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID,
3148 .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE,
3149 .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD,
3150 .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD,
3151 .roam_scan_rssi_change_threshold =
3152 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
3153 .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
3154 .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
3155 .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE,
3156 .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD,
3157 .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO,
3158 .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY,
3159 .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE,
3160 .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE,
3161 .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID,
3162 .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID,
3163 .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID,
3164 .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID,
3165 .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID,
3166 .wlan_profile_set_hist_intvl_cmdid =
3167 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
3168 .wlan_profile_get_profile_data_cmdid =
3169 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
3170 .wlan_profile_enable_profile_id_cmdid =
3171 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
3172 .wlan_profile_list_profile_id_cmdid =
3173 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
3174 .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID,
3175 .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID,
3176 .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID,
3177 .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID,
3178 .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID,
3179 .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID,
3180 .wow_enable_disable_wake_event_cmdid =
3181 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
3182 .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID,
3183 .wow_hostwakeup_from_sleep_cmdid =
3184 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
3185 .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID,
3186 .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID,
3187 .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,
3188 .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID,
3189 .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID,
3190 .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID,
3191 .network_list_offload_config_cmdid =
3192 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
3193 .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID,
3194 .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID,
3195 .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID,
3196 .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID,
3197 .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID,
3198 .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID,
3199 .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID,
3200 .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID,
3201 .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID,
3202 .echo_cmdid = WMI_TLV_ECHO_CMDID,
3203 .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID,
3204 .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID,
3205 .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID,
3206 .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID,
3207 .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID,
3208 .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID,
3209 .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID,
3210 .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID,
3211 .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID,
3212 .pdev_get_temperature_cmdid = WMI_TLV_CMD_UNSUPPORTED,
3213 .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID,
3214 .tdls_set_state_cmdid = WMI_TLV_TDLS_SET_STATE_CMDID,
3215 .tdls_peer_update_cmdid = WMI_TLV_TDLS_PEER_UPDATE_CMDID,
3216 .adaptive_qcs_cmdid = WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID,
3217 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
3218 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
3219 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
3220 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
3221 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
3222 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
3223 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
3224 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
3225 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
3226 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
3227 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
3228 .nan_cmdid = WMI_CMD_UNSUPPORTED,
3229 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
3230 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
3231 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
3232 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
3233 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
3234 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
3235 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
3236 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
3237 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
3238 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
3239 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
3240 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
3241 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
3242 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
3243 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
3244 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
3245 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
3246 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
3247 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
3248 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
3251 static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = {
3252 .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK,
3253 .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK,
3254 .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G,
3255 .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G,
3256 .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE,
3257 .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE,
3258 .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE,
3259 .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
3260 .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE,
3261 .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW,
3262 .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
3263 .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH,
3264 .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH,
3265 .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING,
3266 .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE,
3267 .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE,
3268 .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK,
3269 .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI,
3270 .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO,
3271 .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
3272 .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
3273 .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE,
3274 .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
3275 .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE,
3276 .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE,
3277 .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
3278 .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3279 .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3280 .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
3281 .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
3282 .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
3283 .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
3284 .bcnflt_stats_update_period =
3285 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
3286 .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS,
3287 .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE,
3288 .dcs = WMI_TLV_PDEV_PARAM_DCS,
3289 .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE,
3290 .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD,
3291 .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD,
3292 .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL,
3293 .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL,
3294 .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN,
3295 .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA,
3296 .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG,
3297 .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP,
3298 .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED,
3299 .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR,
3300 .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE,
3301 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
3302 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
3303 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3304 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
3305 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
3306 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
3307 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
3308 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
3309 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
3310 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3311 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3312 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
3313 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
3314 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
3315 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
3316 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
3317 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3318 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3319 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3320 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3321 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3322 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3323 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
3324 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
3325 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
3326 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
3327 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
3328 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
3329 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
3330 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
3331 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
3332 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
3333 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
3334 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
3335 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
3336 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
3337 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
3338 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
3339 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
3340 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
3341 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
3342 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
3343 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
3346 static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = {
3347 .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD,
3348 .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
3349 .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL,
3350 .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL,
3351 .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE,
3352 .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE,
3353 .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME,
3354 .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE,
3355 .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME,
3356 .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD,
3357 .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME,
3358 .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL,
3359 .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD,
3360 .wmi_vdev_oc_scheduler_air_time_limit =
3361 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
3362 .wds = WMI_TLV_VDEV_PARAM_WDS,
3363 .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW,
3364 .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX,
3365 .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT,
3366 .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT,
3367 .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM,
3368 .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH,
3369 .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET,
3370 .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION,
3371 .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT,
3372 .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE,
3373 .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE,
3374 .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE,
3375 .sgi = WMI_TLV_VDEV_PARAM_SGI,
3376 .ldpc = WMI_TLV_VDEV_PARAM_LDPC,
3377 .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC,
3378 .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC,
3379 .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD,
3380 .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID,
3381 .nss = WMI_TLV_VDEV_PARAM_NSS,
3382 .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE,
3383 .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE,
3384 .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE,
3385 .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE,
3386 .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
3387 .ap_keepalive_min_idle_inactive_time_secs =
3388 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
3389 .ap_keepalive_max_idle_inactive_time_secs =
3390 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
3391 .ap_keepalive_max_unresponsive_time_secs =
3392 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
3393 .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS,
3394 .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED,
3395 .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS,
3396 .txbf = WMI_TLV_VDEV_PARAM_TXBF,
3397 .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE,
3398 .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY,
3399 .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE,
3400 .ap_detect_out_of_sync_sleeping_sta_time_secs =
3401 WMI_TLV_VDEV_PARAM_UNSUPPORTED,
3402 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
3403 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
3404 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
3405 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
3406 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
3407 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
3408 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
3409 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
3410 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
3411 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
3412 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
3413 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
3414 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
3415 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
3416 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
3417 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
3420 static const struct wmi_ops wmi_tlv_ops = {
3421 .rx = ath10k_wmi_tlv_op_rx,
3422 .map_svc = wmi_tlv_svc_map,
3424 .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev,
3425 .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev,
3426 .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev,
3427 .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev,
3428 .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev,
3429 .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev,
3430 .pull_phyerr_hdr = ath10k_wmi_tlv_op_pull_phyerr_ev_hdr,
3431 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
3432 .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev,
3433 .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
3434 .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
3435 .pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev,
3436 .pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev,
3437 .get_txbf_conf_scheme = ath10k_wmi_tlv_txbf_conf_scheme,
3439 .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
3440 .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
3441 .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
3442 .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
3443 .gen_init = ath10k_wmi_tlv_op_gen_init,
3444 .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
3445 .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
3446 .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create,
3447 .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete,
3448 .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start,
3449 .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop,
3450 .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up,
3451 .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down,
3452 .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param,
3453 .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key,
3454 .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf,
3455 .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create,
3456 .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete,
3457 .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush,
3458 .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param,
3459 .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc,
3460 .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode,
3461 .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps,
3462 .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps,
3463 .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list,
3464 .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma,
3465 .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm,
3466 .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats,
3467 .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang,
3468 /* .gen_mgmt_tx = not implemented; HTT is used */
3469 .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg,
3470 .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable,
3471 .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable,
3472 /* .gen_pdev_set_quiet_mode not implemented */
3473 /* .gen_pdev_get_temperature not implemented */
3474 /* .gen_addba_clear_resp not implemented */
3475 /* .gen_addba_send not implemented */
3476 /* .gen_addba_set_resp not implemented */
3477 /* .gen_delba_send not implemented */
3478 .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl,
3479 .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl,
3480 .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
3481 .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
3482 .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
3483 .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable,
3484 .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event,
3485 .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
3486 .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern,
3487 .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern,
3488 .gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state,
3489 .gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update,
3490 .gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs,
3491 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
3494 /************/
3495 /* TLV init */
3496 /************/
3498 void ath10k_wmi_tlv_attach(struct ath10k *ar)
3500 ar->wmi.cmd = &wmi_tlv_cmd_map;
3501 ar->wmi.vdev_param = &wmi_tlv_vdev_param_map;
3502 ar->wmi.pdev_param = &wmi_tlv_pdev_param_map;
3503 ar->wmi.ops = &wmi_tlv_ops;