Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / net / wireless / ath / ath10k / wmi-tlv.c
blob7b5834157fe51239e627985a96cc751796f70aa5
1 // SPDX-License-Identifier: ISC
2 /*
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
6 */
7 #include "core.h"
8 #include "debug.h"
9 #include "mac.h"
10 #include "hw.h"
11 #include "wmi.h"
12 #include "wmi-ops.h"
13 #include "wmi-tlv.h"
14 #include "p2p.h"
15 #include "testmode.h"
16 #include <linux/bitfield.h>
18 /***************/
19 /* TLV helpers */
20 /**************/
22 struct wmi_tlv_policy {
23 size_t min_len;
26 static const struct wmi_tlv_policy wmi_tlv_policies[] = {
27 [WMI_TLV_TAG_ARRAY_BYTE]
28 = { .min_len = 0 },
29 [WMI_TLV_TAG_ARRAY_UINT32]
30 = { .min_len = 0 },
31 [WMI_TLV_TAG_STRUCT_SCAN_EVENT]
32 = { .min_len = sizeof(struct wmi_scan_event) },
33 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
34 = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) },
35 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]
36 = { .min_len = sizeof(struct wmi_chan_info_event) },
37 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]
38 = { .min_len = sizeof(struct wmi_vdev_start_response_event) },
39 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]
40 = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
41 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT]
42 = { .min_len = sizeof(struct wmi_host_swba_event) },
43 [WMI_TLV_TAG_STRUCT_TIM_INFO]
44 = { .min_len = sizeof(struct wmi_tim_info) },
45 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]
46 = { .min_len = sizeof(struct wmi_p2p_noa_info) },
47 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT]
48 = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) },
49 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES]
50 = { .min_len = sizeof(struct hal_reg_capabilities) },
51 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ]
52 = { .min_len = sizeof(struct wlan_host_mem_req) },
53 [WMI_TLV_TAG_STRUCT_READY_EVENT]
54 = { .min_len = sizeof(struct wmi_tlv_rdy_ev) },
55 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]
56 = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
57 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
58 = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
59 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
60 = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
61 [WMI_TLV_TAG_STRUCT_ROAM_EVENT]
62 = { .min_len = sizeof(struct wmi_tlv_roam_ev) },
63 [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]
64 = { .min_len = sizeof(struct wmi_tlv_wow_event_info) },
65 [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT]
66 = { .min_len = sizeof(struct wmi_tlv_tx_pause_ev) },
69 static int
70 ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len,
71 int (*iter)(struct ath10k *ar, u16 tag, u16 len,
72 const void *ptr, void *data),
73 void *data)
75 const void *begin = ptr;
76 const struct wmi_tlv *tlv;
77 u16 tlv_tag, tlv_len;
78 int ret;
80 while (len > 0) {
81 if (len < sizeof(*tlv)) {
82 ath10k_dbg(ar, ATH10K_DBG_WMI,
83 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
84 ptr - begin, len, sizeof(*tlv));
85 return -EINVAL;
88 tlv = ptr;
89 tlv_tag = __le16_to_cpu(tlv->tag);
90 tlv_len = __le16_to_cpu(tlv->len);
91 ptr += sizeof(*tlv);
92 len -= sizeof(*tlv);
94 if (tlv_len > len) {
95 ath10k_dbg(ar, ATH10K_DBG_WMI,
96 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
97 tlv_tag, ptr - begin, len, tlv_len);
98 return -EINVAL;
101 if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
102 wmi_tlv_policies[tlv_tag].min_len &&
103 wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
104 ath10k_dbg(ar, ATH10K_DBG_WMI,
105 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
106 tlv_tag, ptr - begin, tlv_len,
107 wmi_tlv_policies[tlv_tag].min_len);
108 return -EINVAL;
111 ret = iter(ar, tlv_tag, tlv_len, ptr, data);
112 if (ret)
113 return ret;
115 ptr += tlv_len;
116 len -= tlv_len;
119 return 0;
122 static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len,
123 const void *ptr, void *data)
125 const void **tb = data;
127 if (tag < WMI_TLV_TAG_MAX)
128 tb[tag] = ptr;
130 return 0;
133 static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb,
134 const void *ptr, size_t len)
136 return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse,
137 (void *)tb);
140 static const void **
141 ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
142 size_t len, gfp_t gfp)
144 const void **tb;
145 int ret;
147 tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp);
148 if (!tb)
149 return ERR_PTR(-ENOMEM);
151 ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len);
152 if (ret) {
153 kfree(tb);
154 return ERR_PTR(ret);
157 return tb;
160 static u16 ath10k_wmi_tlv_len(const void *ptr)
162 return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len);
165 /**************/
166 /* TLV events */
167 /**************/
168 static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar,
169 struct sk_buff *skb)
171 const void **tb;
172 const struct wmi_tlv_bcn_tx_status_ev *ev;
173 struct ath10k_vif *arvif;
174 u32 vdev_id, tx_status;
175 int ret;
177 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
178 if (IS_ERR(tb)) {
179 ret = PTR_ERR(tb);
180 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
181 return ret;
184 ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT];
185 if (!ev) {
186 kfree(tb);
187 return -EPROTO;
190 tx_status = __le32_to_cpu(ev->tx_status);
191 vdev_id = __le32_to_cpu(ev->vdev_id);
193 switch (tx_status) {
194 case WMI_TLV_BCN_TX_STATUS_OK:
195 break;
196 case WMI_TLV_BCN_TX_STATUS_XRETRY:
197 case WMI_TLV_BCN_TX_STATUS_DROP:
198 case WMI_TLV_BCN_TX_STATUS_FILTERED:
199 /* FIXME: It's probably worth telling mac80211 to stop the
200 * interface as it is crippled.
202 ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d",
203 vdev_id, tx_status);
204 break;
207 arvif = ath10k_get_arvif(ar, vdev_id);
208 if (arvif && arvif->is_up && arvif->vif->csa_active)
209 ieee80211_queue_work(ar->hw, &arvif->ap_csa_work);
211 kfree(tb);
212 return 0;
215 static void ath10k_wmi_tlv_event_vdev_delete_resp(struct ath10k *ar,
216 struct sk_buff *skb)
218 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_DELETE_RESP_EVENTID\n");
219 complete(&ar->vdev_delete_done);
222 static int ath10k_wmi_tlv_parse_peer_stats_info(struct ath10k *ar, u16 tag, u16 len,
223 const void *ptr, void *data)
225 const struct wmi_tlv_peer_stats_info *stat = ptr;
226 struct ieee80211_sta *sta;
227 struct ath10k_sta *arsta;
229 if (tag != WMI_TLV_TAG_STRUCT_PEER_STATS_INFO)
230 return -EPROTO;
232 ath10k_dbg(ar, ATH10K_DBG_WMI,
233 "wmi tlv stats peer addr %pMF rx rate code 0x%x bit rate %d kbps\n",
234 stat->peer_macaddr.addr,
235 __le32_to_cpu(stat->last_rx_rate_code),
236 __le32_to_cpu(stat->last_rx_bitrate_kbps));
238 ath10k_dbg(ar, ATH10K_DBG_WMI,
239 "wmi tlv stats tx rate code 0x%x bit rate %d kbps\n",
240 __le32_to_cpu(stat->last_tx_rate_code),
241 __le32_to_cpu(stat->last_tx_bitrate_kbps));
243 sta = ieee80211_find_sta_by_ifaddr(ar->hw, stat->peer_macaddr.addr, NULL);
244 if (!sta) {
245 ath10k_warn(ar, "not found station for peer stats\n");
246 return -EINVAL;
249 arsta = (struct ath10k_sta *)sta->drv_priv;
250 arsta->rx_rate_code = __le32_to_cpu(stat->last_rx_rate_code);
251 arsta->rx_bitrate_kbps = __le32_to_cpu(stat->last_rx_bitrate_kbps);
252 arsta->tx_rate_code = __le32_to_cpu(stat->last_tx_rate_code);
253 arsta->tx_bitrate_kbps = __le32_to_cpu(stat->last_tx_bitrate_kbps);
255 return 0;
258 static int ath10k_wmi_tlv_op_pull_peer_stats_info(struct ath10k *ar,
259 struct sk_buff *skb)
261 const void **tb;
262 const struct wmi_tlv_peer_stats_info_ev *ev;
263 const void *data;
264 u32 num_peer_stats;
265 int ret;
267 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
268 if (IS_ERR(tb)) {
269 ret = PTR_ERR(tb);
270 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
271 return ret;
274 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STATS_INFO_EVENT];
275 data = tb[WMI_TLV_TAG_ARRAY_STRUCT];
277 if (!ev || !data) {
278 kfree(tb);
279 return -EPROTO;
282 num_peer_stats = __le32_to_cpu(ev->num_peers);
284 ath10k_dbg(ar, ATH10K_DBG_WMI,
285 "wmi tlv peer stats info update peer vdev id %d peers %i more data %d\n",
286 __le32_to_cpu(ev->vdev_id),
287 num_peer_stats,
288 __le32_to_cpu(ev->more_data));
290 ret = ath10k_wmi_tlv_iter(ar, data, ath10k_wmi_tlv_len(data),
291 ath10k_wmi_tlv_parse_peer_stats_info, NULL);
292 if (ret)
293 ath10k_warn(ar, "failed to parse stats info tlv: %d\n", ret);
295 kfree(tb);
296 return 0;
299 static void ath10k_wmi_tlv_event_peer_stats_info(struct ath10k *ar,
300 struct sk_buff *skb)
302 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PEER_STATS_INFO_EVENTID\n");
303 ath10k_wmi_tlv_op_pull_peer_stats_info(ar, skb);
304 complete(&ar->peer_stats_info_complete);
307 static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar,
308 struct sk_buff *skb)
310 const void **tb;
311 const struct wmi_tlv_diag_data_ev *ev;
312 const struct wmi_tlv_diag_item *item;
313 const void *data;
314 int ret, num_items, len;
316 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
317 if (IS_ERR(tb)) {
318 ret = PTR_ERR(tb);
319 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
320 return ret;
323 ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT];
324 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
325 if (!ev || !data) {
326 kfree(tb);
327 return -EPROTO;
330 num_items = __le32_to_cpu(ev->num_items);
331 len = ath10k_wmi_tlv_len(data);
333 while (num_items--) {
334 if (len == 0)
335 break;
336 if (len < sizeof(*item)) {
337 ath10k_warn(ar, "failed to parse diag data: can't fit item header\n");
338 break;
341 item = data;
343 if (len < sizeof(*item) + __le16_to_cpu(item->len)) {
344 ath10k_warn(ar, "failed to parse diag data: item is too long\n");
345 break;
348 trace_ath10k_wmi_diag_container(ar,
349 item->type,
350 __le32_to_cpu(item->timestamp),
351 __le32_to_cpu(item->code),
352 __le16_to_cpu(item->len),
353 item->payload);
355 len -= sizeof(*item);
356 len -= roundup(__le16_to_cpu(item->len), 4);
358 data += sizeof(*item);
359 data += roundup(__le16_to_cpu(item->len), 4);
362 if (num_items != -1 || len != 0)
363 ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n",
364 num_items, len);
366 kfree(tb);
367 return 0;
370 static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
371 struct sk_buff *skb)
373 const void **tb;
374 const void *data;
375 int ret, len;
377 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
378 if (IS_ERR(tb)) {
379 ret = PTR_ERR(tb);
380 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
381 return ret;
384 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
385 if (!data) {
386 kfree(tb);
387 return -EPROTO;
389 len = ath10k_wmi_tlv_len(data);
391 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len);
392 trace_ath10k_wmi_diag(ar, data, len);
394 kfree(tb);
395 return 0;
398 static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
399 struct sk_buff *skb)
401 const void **tb;
402 const struct wmi_tlv_p2p_noa_ev *ev;
403 const struct wmi_p2p_noa_info *noa;
404 int ret, vdev_id;
406 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
407 if (IS_ERR(tb)) {
408 ret = PTR_ERR(tb);
409 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
410 return ret;
413 ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
414 noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
416 if (!ev || !noa) {
417 kfree(tb);
418 return -EPROTO;
421 vdev_id = __le32_to_cpu(ev->vdev_id);
423 ath10k_dbg(ar, ATH10K_DBG_WMI,
424 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
425 vdev_id, noa->num_descriptors);
427 ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
428 kfree(tb);
429 return 0;
432 static int ath10k_wmi_tlv_event_tx_pause(struct ath10k *ar,
433 struct sk_buff *skb)
435 const void **tb;
436 const struct wmi_tlv_tx_pause_ev *ev;
437 int ret, vdev_id;
438 u32 pause_id, action, vdev_map, peer_id, tid_map;
440 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
441 if (IS_ERR(tb)) {
442 ret = PTR_ERR(tb);
443 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
444 return ret;
447 ev = tb[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT];
448 if (!ev) {
449 kfree(tb);
450 return -EPROTO;
453 pause_id = __le32_to_cpu(ev->pause_id);
454 action = __le32_to_cpu(ev->action);
455 vdev_map = __le32_to_cpu(ev->vdev_map);
456 peer_id = __le32_to_cpu(ev->peer_id);
457 tid_map = __le32_to_cpu(ev->tid_map);
459 ath10k_dbg(ar, ATH10K_DBG_WMI,
460 "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n",
461 pause_id, action, vdev_map, peer_id, tid_map);
463 switch (pause_id) {
464 case WMI_TLV_TX_PAUSE_ID_MCC:
465 case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA:
466 case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS:
467 case WMI_TLV_TX_PAUSE_ID_AP_PS:
468 case WMI_TLV_TX_PAUSE_ID_IBSS_PS:
469 for (vdev_id = 0; vdev_map; vdev_id++) {
470 if (!(vdev_map & BIT(vdev_id)))
471 continue;
473 vdev_map &= ~BIT(vdev_id);
474 ath10k_mac_handle_tx_pause_vdev(ar, vdev_id, pause_id,
475 action);
477 break;
478 case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS:
479 case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD:
480 case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA:
481 case WMI_TLV_TX_PAUSE_ID_HOST:
482 ath10k_dbg(ar, ATH10K_DBG_MAC,
483 "mac ignoring unsupported tx pause id %d\n",
484 pause_id);
485 break;
486 default:
487 ath10k_dbg(ar, ATH10K_DBG_MAC,
488 "mac ignoring unknown tx pause vdev %d\n",
489 pause_id);
490 break;
493 kfree(tb);
494 return 0;
497 static void ath10k_wmi_tlv_event_rfkill_state_change(struct ath10k *ar,
498 struct sk_buff *skb)
500 const struct wmi_tlv_rfkill_state_change_ev *ev;
501 const void **tb;
502 bool radio;
503 int ret;
505 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
506 if (IS_ERR(tb)) {
507 ret = PTR_ERR(tb);
508 ath10k_warn(ar,
509 "failed to parse rfkill state change event: %d\n",
510 ret);
511 return;
514 ev = tb[WMI_TLV_TAG_STRUCT_RFKILL_EVENT];
515 if (!ev) {
516 kfree(tb);
517 return;
520 ath10k_dbg(ar, ATH10K_DBG_MAC,
521 "wmi tlv rfkill state change gpio %d type %d radio_state %d\n",
522 __le32_to_cpu(ev->gpio_pin_num),
523 __le32_to_cpu(ev->int_type),
524 __le32_to_cpu(ev->radio_state));
526 radio = (__le32_to_cpu(ev->radio_state) == WMI_TLV_RFKILL_RADIO_STATE_ON);
528 spin_lock_bh(&ar->data_lock);
530 if (!radio)
531 ar->hw_rfkill_on = true;
533 spin_unlock_bh(&ar->data_lock);
535 /* notify cfg80211 radio state change */
536 ath10k_mac_rfkill_enable_radio(ar, radio);
537 wiphy_rfkill_set_hw_state(ar->hw->wiphy, !radio);
540 static int ath10k_wmi_tlv_event_temperature(struct ath10k *ar,
541 struct sk_buff *skb)
543 const struct wmi_tlv_pdev_temperature_event *ev;
545 ev = (struct wmi_tlv_pdev_temperature_event *)skb->data;
546 if (WARN_ON(skb->len < sizeof(*ev)))
547 return -EPROTO;
549 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
550 return 0;
553 static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb)
555 struct ieee80211_sta *station;
556 const struct wmi_tlv_tdls_peer_event *ev;
557 const void **tb;
558 struct ath10k_vif *arvif;
560 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
561 if (IS_ERR(tb)) {
562 ath10k_warn(ar, "tdls peer failed to parse tlv");
563 return;
565 ev = tb[WMI_TLV_TAG_STRUCT_TDLS_PEER_EVENT];
566 if (!ev) {
567 kfree(tb);
568 ath10k_warn(ar, "tdls peer NULL event");
569 return;
572 switch (__le32_to_cpu(ev->peer_reason)) {
573 case WMI_TDLS_TEARDOWN_REASON_TX:
574 case WMI_TDLS_TEARDOWN_REASON_RSSI:
575 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
576 station = ieee80211_find_sta_by_ifaddr(ar->hw,
577 ev->peer_macaddr.addr,
578 NULL);
579 if (!station) {
580 ath10k_warn(ar, "did not find station from tdls peer event");
581 kfree(tb);
582 return;
584 arvif = ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id));
585 ieee80211_tdls_oper_request(
586 arvif->vif, station->addr,
587 NL80211_TDLS_TEARDOWN,
588 WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE,
589 GFP_ATOMIC
591 break;
593 kfree(tb);
596 static int ath10k_wmi_tlv_event_peer_delete_resp(struct ath10k *ar,
597 struct sk_buff *skb)
599 struct wmi_peer_delete_resp_ev_arg *arg;
600 struct wmi_tlv *tlv_hdr;
602 tlv_hdr = (struct wmi_tlv *)skb->data;
603 arg = (struct wmi_peer_delete_resp_ev_arg *)tlv_hdr->value;
605 ath10k_dbg(ar, ATH10K_DBG_WMI, "vdev id %d", arg->vdev_id);
606 ath10k_dbg(ar, ATH10K_DBG_WMI, "peer mac addr %pM", &arg->peer_addr);
607 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete response\n");
609 complete(&ar->peer_delete_done);
611 return 0;
614 /***********/
615 /* TLV ops */
616 /***********/
618 static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
620 struct wmi_cmd_hdr *cmd_hdr;
621 enum wmi_tlv_event_id id;
622 bool consumed;
624 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
625 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
627 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
628 goto out;
630 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
632 consumed = ath10k_tm_event_wmi(ar, id, skb);
634 /* Ready event must be handled normally also in UTF mode so that we
635 * know the UTF firmware has booted, others we are just bypass WMI
636 * events to testmode.
638 if (consumed && id != WMI_TLV_READY_EVENTID) {
639 ath10k_dbg(ar, ATH10K_DBG_WMI,
640 "wmi tlv testmode consumed 0x%x\n", id);
641 goto out;
644 switch (id) {
645 case WMI_TLV_MGMT_RX_EVENTID:
646 ath10k_wmi_event_mgmt_rx(ar, skb);
647 /* mgmt_rx() owns the skb now! */
648 return;
649 case WMI_TLV_SCAN_EVENTID:
650 ath10k_wmi_event_scan(ar, skb);
651 break;
652 case WMI_TLV_CHAN_INFO_EVENTID:
653 ath10k_wmi_event_chan_info(ar, skb);
654 break;
655 case WMI_TLV_ECHO_EVENTID:
656 ath10k_wmi_event_echo(ar, skb);
657 break;
658 case WMI_TLV_DEBUG_MESG_EVENTID:
659 ath10k_wmi_event_debug_mesg(ar, skb);
660 break;
661 case WMI_TLV_UPDATE_STATS_EVENTID:
662 ath10k_wmi_event_update_stats(ar, skb);
663 break;
664 case WMI_TLV_PEER_STATS_INFO_EVENTID:
665 ath10k_wmi_tlv_event_peer_stats_info(ar, skb);
666 break;
667 case WMI_TLV_VDEV_START_RESP_EVENTID:
668 ath10k_wmi_event_vdev_start_resp(ar, skb);
669 break;
670 case WMI_TLV_VDEV_STOPPED_EVENTID:
671 ath10k_wmi_event_vdev_stopped(ar, skb);
672 break;
673 case WMI_TLV_VDEV_DELETE_RESP_EVENTID:
674 ath10k_wmi_tlv_event_vdev_delete_resp(ar, skb);
675 break;
676 case WMI_TLV_PEER_STA_KICKOUT_EVENTID:
677 ath10k_wmi_event_peer_sta_kickout(ar, skb);
678 break;
679 case WMI_TLV_HOST_SWBA_EVENTID:
680 ath10k_wmi_event_host_swba(ar, skb);
681 break;
682 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID:
683 ath10k_wmi_event_tbttoffset_update(ar, skb);
684 break;
685 case WMI_TLV_PHYERR_EVENTID:
686 ath10k_wmi_event_phyerr(ar, skb);
687 break;
688 case WMI_TLV_ROAM_EVENTID:
689 ath10k_wmi_event_roam(ar, skb);
690 break;
691 case WMI_TLV_PROFILE_MATCH:
692 ath10k_wmi_event_profile_match(ar, skb);
693 break;
694 case WMI_TLV_DEBUG_PRINT_EVENTID:
695 ath10k_wmi_event_debug_print(ar, skb);
696 break;
697 case WMI_TLV_PDEV_QVIT_EVENTID:
698 ath10k_wmi_event_pdev_qvit(ar, skb);
699 break;
700 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID:
701 ath10k_wmi_event_wlan_profile_data(ar, skb);
702 break;
703 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID:
704 ath10k_wmi_event_rtt_measurement_report(ar, skb);
705 break;
706 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID:
707 ath10k_wmi_event_tsf_measurement_report(ar, skb);
708 break;
709 case WMI_TLV_RTT_ERROR_REPORT_EVENTID:
710 ath10k_wmi_event_rtt_error_report(ar, skb);
711 break;
712 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID:
713 ath10k_wmi_event_wow_wakeup_host(ar, skb);
714 break;
715 case WMI_TLV_DCS_INTERFERENCE_EVENTID:
716 ath10k_wmi_event_dcs_interference(ar, skb);
717 break;
718 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID:
719 ath10k_wmi_event_pdev_tpc_config(ar, skb);
720 break;
721 case WMI_TLV_PDEV_FTM_INTG_EVENTID:
722 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
723 break;
724 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID:
725 ath10k_wmi_event_gtk_offload_status(ar, skb);
726 break;
727 case WMI_TLV_GTK_REKEY_FAIL_EVENTID:
728 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
729 break;
730 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID:
731 ath10k_wmi_event_delba_complete(ar, skb);
732 break;
733 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID:
734 ath10k_wmi_event_addba_complete(ar, skb);
735 break;
736 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
737 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
738 break;
739 case WMI_TLV_SERVICE_READY_EVENTID:
740 ath10k_wmi_event_service_ready(ar, skb);
741 return;
742 case WMI_TLV_READY_EVENTID:
743 ath10k_wmi_event_ready(ar, skb);
744 break;
745 case WMI_TLV_SERVICE_AVAILABLE_EVENTID:
746 ath10k_wmi_event_service_available(ar, skb);
747 break;
748 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID:
749 ath10k_wmi_tlv_event_bcn_tx_status(ar, skb);
750 break;
751 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID:
752 ath10k_wmi_tlv_event_diag_data(ar, skb);
753 break;
754 case WMI_TLV_DIAG_EVENTID:
755 ath10k_wmi_tlv_event_diag(ar, skb);
756 break;
757 case WMI_TLV_P2P_NOA_EVENTID:
758 ath10k_wmi_tlv_event_p2p_noa(ar, skb);
759 break;
760 case WMI_TLV_TX_PAUSE_EVENTID:
761 ath10k_wmi_tlv_event_tx_pause(ar, skb);
762 break;
763 case WMI_TLV_RFKILL_STATE_CHANGE_EVENTID:
764 ath10k_wmi_tlv_event_rfkill_state_change(ar, skb);
765 break;
766 case WMI_TLV_PDEV_TEMPERATURE_EVENTID:
767 ath10k_wmi_tlv_event_temperature(ar, skb);
768 break;
769 case WMI_TLV_TDLS_PEER_EVENTID:
770 ath10k_wmi_event_tdls_peer(ar, skb);
771 break;
772 case WMI_TLV_PEER_DELETE_RESP_EVENTID:
773 ath10k_wmi_tlv_event_peer_delete_resp(ar, skb);
774 break;
775 case WMI_TLV_MGMT_TX_COMPLETION_EVENTID:
776 ath10k_wmi_event_mgmt_tx_compl(ar, skb);
777 break;
778 case WMI_TLV_MGMT_TX_BUNDLE_COMPLETION_EVENTID:
779 ath10k_wmi_event_mgmt_tx_bundle_compl(ar, skb);
780 break;
781 default:
782 ath10k_dbg(ar, ATH10K_DBG_WMI, "Unknown eventid: %d\n", id);
783 break;
786 out:
787 dev_kfree_skb(skb);
790 static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar,
791 struct sk_buff *skb,
792 struct wmi_scan_ev_arg *arg)
794 const void **tb;
795 const struct wmi_scan_event *ev;
796 int ret;
798 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
799 if (IS_ERR(tb)) {
800 ret = PTR_ERR(tb);
801 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
802 return ret;
805 ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT];
806 if (!ev) {
807 kfree(tb);
808 return -EPROTO;
811 arg->event_type = ev->event_type;
812 arg->reason = ev->reason;
813 arg->channel_freq = ev->channel_freq;
814 arg->scan_req_id = ev->scan_req_id;
815 arg->scan_id = ev->scan_id;
816 arg->vdev_id = ev->vdev_id;
818 kfree(tb);
819 return 0;
822 static int
823 ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev(struct ath10k *ar, struct sk_buff *skb,
824 struct wmi_tlv_mgmt_tx_compl_ev_arg *arg)
826 const void **tb;
827 const struct wmi_tlv_mgmt_tx_compl_ev *ev;
828 int ret;
830 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
831 if (IS_ERR(tb)) {
832 ret = PTR_ERR(tb);
833 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
834 return ret;
837 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_EVENT];
839 arg->desc_id = ev->desc_id;
840 arg->status = ev->status;
841 arg->pdev_id = ev->pdev_id;
842 arg->ppdu_id = ev->ppdu_id;
844 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map))
845 arg->ack_rssi = ev->ack_rssi;
847 kfree(tb);
848 return 0;
851 struct wmi_tlv_tx_bundle_compl_parse {
852 const __le32 *num_reports;
853 const __le32 *desc_ids;
854 const __le32 *status;
855 const __le32 *ppdu_ids;
856 const __le32 *ack_rssi;
857 bool desc_ids_done;
858 bool status_done;
859 bool ppdu_ids_done;
860 bool ack_rssi_done;
863 static int
864 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse(struct ath10k *ar, u16 tag, u16 len,
865 const void *ptr, void *data)
867 struct wmi_tlv_tx_bundle_compl_parse *bundle_tx_compl = data;
869 switch (tag) {
870 case WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_BUNDLE_EVENT:
871 bundle_tx_compl->num_reports = ptr;
872 break;
873 case WMI_TLV_TAG_ARRAY_UINT32:
874 if (!bundle_tx_compl->desc_ids_done) {
875 bundle_tx_compl->desc_ids_done = true;
876 bundle_tx_compl->desc_ids = ptr;
877 } else if (!bundle_tx_compl->status_done) {
878 bundle_tx_compl->status_done = true;
879 bundle_tx_compl->status = ptr;
880 } else if (!bundle_tx_compl->ppdu_ids_done) {
881 bundle_tx_compl->ppdu_ids_done = true;
882 bundle_tx_compl->ppdu_ids = ptr;
883 } else if (!bundle_tx_compl->ack_rssi_done) {
884 bundle_tx_compl->ack_rssi_done = true;
885 bundle_tx_compl->ack_rssi = ptr;
887 break;
888 default:
889 break;
891 return 0;
894 static int ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev(
895 struct ath10k *ar, struct sk_buff *skb,
896 struct wmi_tlv_mgmt_tx_bundle_compl_ev_arg *arg)
898 struct wmi_tlv_tx_bundle_compl_parse bundle_tx_compl = { };
899 int ret;
901 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
902 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse,
903 &bundle_tx_compl);
904 if (ret) {
905 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
906 return ret;
909 if (!bundle_tx_compl.num_reports || !bundle_tx_compl.desc_ids ||
910 !bundle_tx_compl.status)
911 return -EPROTO;
913 arg->num_reports = *bundle_tx_compl.num_reports;
914 arg->desc_ids = bundle_tx_compl.desc_ids;
915 arg->status = bundle_tx_compl.status;
916 arg->ppdu_ids = bundle_tx_compl.ppdu_ids;
918 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map))
919 arg->ack_rssi = bundle_tx_compl.ack_rssi;
921 return 0;
924 static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar,
925 struct sk_buff *skb,
926 struct wmi_mgmt_rx_ev_arg *arg)
928 const void **tb;
929 const struct wmi_tlv_mgmt_rx_ev *ev;
930 const u8 *frame;
931 u32 msdu_len;
932 int ret, i;
934 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
935 if (IS_ERR(tb)) {
936 ret = PTR_ERR(tb);
937 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
938 return ret;
941 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR];
942 frame = tb[WMI_TLV_TAG_ARRAY_BYTE];
944 if (!ev || !frame) {
945 kfree(tb);
946 return -EPROTO;
949 arg->channel = ev->channel;
950 arg->buf_len = ev->buf_len;
951 arg->status = ev->status;
952 arg->snr = ev->snr;
953 arg->phy_mode = ev->phy_mode;
954 arg->rate = ev->rate;
956 for (i = 0; i < ARRAY_SIZE(ev->rssi); i++)
957 arg->rssi[i] = ev->rssi[i];
959 msdu_len = __le32_to_cpu(arg->buf_len);
961 if (skb->len < (frame - skb->data) + msdu_len) {
962 kfree(tb);
963 return -EPROTO;
966 /* shift the sk_buff to point to `frame` */
967 skb_trim(skb, 0);
968 skb_put(skb, frame - skb->data);
969 skb_pull(skb, frame - skb->data);
970 skb_put(skb, msdu_len);
972 kfree(tb);
973 return 0;
976 static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar,
977 struct sk_buff *skb,
978 struct wmi_ch_info_ev_arg *arg)
980 const void **tb;
981 const struct wmi_tlv_chan_info_event *ev;
982 int ret;
984 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
985 if (IS_ERR(tb)) {
986 ret = PTR_ERR(tb);
987 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
988 return ret;
991 ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT];
992 if (!ev) {
993 kfree(tb);
994 return -EPROTO;
997 arg->err_code = ev->err_code;
998 arg->freq = ev->freq;
999 arg->cmd_flags = ev->cmd_flags;
1000 arg->noise_floor = ev->noise_floor;
1001 arg->rx_clear_count = ev->rx_clear_count;
1002 arg->cycle_count = ev->cycle_count;
1003 if (test_bit(ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL,
1004 ar->running_fw->fw_file.fw_features))
1005 arg->mac_clk_mhz = ev->mac_clk_mhz;
1007 kfree(tb);
1008 return 0;
1011 static int
1012 ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
1013 struct wmi_vdev_start_ev_arg *arg)
1015 const void **tb;
1016 const struct wmi_vdev_start_response_event *ev;
1017 int ret;
1019 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1020 if (IS_ERR(tb)) {
1021 ret = PTR_ERR(tb);
1022 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1023 return ret;
1026 ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT];
1027 if (!ev) {
1028 kfree(tb);
1029 return -EPROTO;
1032 skb_pull(skb, sizeof(*ev));
1033 arg->vdev_id = ev->vdev_id;
1034 arg->req_id = ev->req_id;
1035 arg->resp_type = ev->resp_type;
1036 arg->status = ev->status;
1038 kfree(tb);
1039 return 0;
1042 static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar,
1043 struct sk_buff *skb,
1044 struct wmi_peer_kick_ev_arg *arg)
1046 const void **tb;
1047 const struct wmi_peer_sta_kickout_event *ev;
1048 int ret;
1050 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1051 if (IS_ERR(tb)) {
1052 ret = PTR_ERR(tb);
1053 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1054 return ret;
1057 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT];
1058 if (!ev) {
1059 kfree(tb);
1060 return -EPROTO;
1063 arg->mac_addr = ev->peer_macaddr.addr;
1065 kfree(tb);
1066 return 0;
1069 struct wmi_tlv_swba_parse {
1070 const struct wmi_host_swba_event *ev;
1071 bool tim_done;
1072 bool noa_done;
1073 size_t n_tim;
1074 size_t n_noa;
1075 struct wmi_swba_ev_arg *arg;
1078 static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len,
1079 const void *ptr, void *data)
1081 struct wmi_tlv_swba_parse *swba = data;
1082 struct wmi_tim_info_arg *tim_info_arg;
1083 const struct wmi_tim_info *tim_info_ev = ptr;
1085 if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO)
1086 return -EPROTO;
1088 if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info))
1089 return -ENOBUFS;
1091 if (__le32_to_cpu(tim_info_ev->tim_len) >
1092 sizeof(tim_info_ev->tim_bitmap)) {
1093 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
1094 return -EPROTO;
1097 tim_info_arg = &swba->arg->tim_info[swba->n_tim];
1098 tim_info_arg->tim_len = tim_info_ev->tim_len;
1099 tim_info_arg->tim_mcast = tim_info_ev->tim_mcast;
1100 tim_info_arg->tim_bitmap = tim_info_ev->tim_bitmap;
1101 tim_info_arg->tim_changed = tim_info_ev->tim_changed;
1102 tim_info_arg->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
1104 swba->n_tim++;
1106 return 0;
1109 static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len,
1110 const void *ptr, void *data)
1112 struct wmi_tlv_swba_parse *swba = data;
1114 if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO)
1115 return -EPROTO;
1117 if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info))
1118 return -ENOBUFS;
1120 swba->arg->noa_info[swba->n_noa++] = ptr;
1121 return 0;
1124 static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len,
1125 const void *ptr, void *data)
1127 struct wmi_tlv_swba_parse *swba = data;
1128 int ret;
1130 switch (tag) {
1131 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT:
1132 swba->ev = ptr;
1133 break;
1134 case WMI_TLV_TAG_ARRAY_STRUCT:
1135 if (!swba->tim_done) {
1136 swba->tim_done = true;
1137 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
1138 ath10k_wmi_tlv_swba_tim_parse,
1139 swba);
1140 if (ret)
1141 return ret;
1142 } else if (!swba->noa_done) {
1143 swba->noa_done = true;
1144 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
1145 ath10k_wmi_tlv_swba_noa_parse,
1146 swba);
1147 if (ret)
1148 return ret;
1150 break;
1151 default:
1152 break;
1154 return 0;
1157 static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar,
1158 struct sk_buff *skb,
1159 struct wmi_swba_ev_arg *arg)
1161 struct wmi_tlv_swba_parse swba = { .arg = arg };
1162 u32 map;
1163 size_t n_vdevs;
1164 int ret;
1166 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
1167 ath10k_wmi_tlv_swba_parse, &swba);
1168 if (ret) {
1169 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1170 return ret;
1173 if (!swba.ev)
1174 return -EPROTO;
1176 arg->vdev_map = swba.ev->vdev_map;
1178 for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1)
1179 if (map & BIT(0))
1180 n_vdevs++;
1182 if (n_vdevs != swba.n_tim ||
1183 n_vdevs != swba.n_noa)
1184 return -EPROTO;
1186 return 0;
1189 static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k *ar,
1190 struct sk_buff *skb,
1191 struct wmi_phyerr_hdr_arg *arg)
1193 const void **tb;
1194 const struct wmi_tlv_phyerr_ev *ev;
1195 const void *phyerrs;
1196 int ret;
1198 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1199 if (IS_ERR(tb)) {
1200 ret = PTR_ERR(tb);
1201 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1202 return ret;
1205 ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR];
1206 phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE];
1208 if (!ev || !phyerrs) {
1209 kfree(tb);
1210 return -EPROTO;
1213 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
1214 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
1215 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
1216 arg->buf_len = __le32_to_cpu(ev->buf_len);
1217 arg->phyerrs = phyerrs;
1219 kfree(tb);
1220 return 0;
1223 #define WMI_TLV_ABI_VER_NS0 0x5F414351
1224 #define WMI_TLV_ABI_VER_NS1 0x00004C4D
1225 #define WMI_TLV_ABI_VER_NS2 0x00000000
1226 #define WMI_TLV_ABI_VER_NS3 0x00000000
1228 #define WMI_TLV_ABI_VER0_MAJOR 1
1229 #define WMI_TLV_ABI_VER0_MINOR 0
1230 #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
1231 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
1232 #define WMI_TLV_ABI_VER1 53
1234 static int
1235 ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len,
1236 const void *ptr, void *data)
1238 struct wmi_svc_rdy_ev_arg *arg = data;
1239 int i;
1241 if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ)
1242 return -EPROTO;
1244 for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) {
1245 if (!arg->mem_reqs[i]) {
1246 arg->mem_reqs[i] = ptr;
1247 return 0;
1251 return -ENOMEM;
1254 struct wmi_tlv_svc_rdy_parse {
1255 const struct hal_reg_capabilities *reg;
1256 const struct wmi_tlv_svc_rdy_ev *ev;
1257 const __le32 *svc_bmap;
1258 const struct wlan_host_mem_req *mem_reqs;
1259 bool svc_bmap_done;
1260 bool dbs_hw_mode_done;
1263 static int ath10k_wmi_tlv_svc_rdy_parse(struct ath10k *ar, u16 tag, u16 len,
1264 const void *ptr, void *data)
1266 struct wmi_tlv_svc_rdy_parse *svc_rdy = data;
1268 switch (tag) {
1269 case WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT:
1270 svc_rdy->ev = ptr;
1271 break;
1272 case WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES:
1273 svc_rdy->reg = ptr;
1274 break;
1275 case WMI_TLV_TAG_ARRAY_STRUCT:
1276 svc_rdy->mem_reqs = ptr;
1277 break;
1278 case WMI_TLV_TAG_ARRAY_UINT32:
1279 if (!svc_rdy->svc_bmap_done) {
1280 svc_rdy->svc_bmap_done = true;
1281 svc_rdy->svc_bmap = ptr;
1282 } else if (!svc_rdy->dbs_hw_mode_done) {
1283 svc_rdy->dbs_hw_mode_done = true;
1285 break;
1286 default:
1287 break;
1289 return 0;
1292 static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar,
1293 struct sk_buff *skb,
1294 struct wmi_svc_rdy_ev_arg *arg)
1296 const struct hal_reg_capabilities *reg;
1297 const struct wmi_tlv_svc_rdy_ev *ev;
1298 const __le32 *svc_bmap;
1299 const struct wlan_host_mem_req *mem_reqs;
1300 struct wmi_tlv_svc_rdy_parse svc_rdy = { };
1301 int ret;
1303 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
1304 ath10k_wmi_tlv_svc_rdy_parse, &svc_rdy);
1305 if (ret) {
1306 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1307 return ret;
1310 ev = svc_rdy.ev;
1311 reg = svc_rdy.reg;
1312 svc_bmap = svc_rdy.svc_bmap;
1313 mem_reqs = svc_rdy.mem_reqs;
1315 if (!ev || !reg || !svc_bmap || !mem_reqs)
1316 return -EPROTO;
1318 /* This is an internal ABI compatibility check for WMI TLV so check it
1319 * here instead of the generic WMI code.
1321 ath10k_dbg(ar, ATH10K_DBG_WMI,
1322 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
1323 __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0,
1324 __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0,
1325 __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1,
1326 __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2,
1327 __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3);
1329 if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 ||
1330 __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 ||
1331 __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 ||
1332 __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 ||
1333 __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) {
1334 return -ENOTSUPP;
1337 arg->min_tx_power = ev->hw_min_tx_power;
1338 arg->max_tx_power = ev->hw_max_tx_power;
1339 arg->ht_cap = ev->ht_cap_info;
1340 arg->vht_cap = ev->vht_cap_info;
1341 arg->vht_supp_mcs = ev->vht_supp_mcs;
1342 arg->sw_ver0 = ev->abi.abi_ver0;
1343 arg->sw_ver1 = ev->abi.abi_ver1;
1344 arg->fw_build = ev->fw_build_vers;
1345 arg->phy_capab = ev->phy_capability;
1346 arg->num_rf_chains = ev->num_rf_chains;
1347 arg->eeprom_rd = reg->eeprom_rd;
1348 arg->low_2ghz_chan = reg->low_2ghz_chan;
1349 arg->high_2ghz_chan = reg->high_2ghz_chan;
1350 arg->low_5ghz_chan = reg->low_5ghz_chan;
1351 arg->high_5ghz_chan = reg->high_5ghz_chan;
1352 arg->num_mem_reqs = ev->num_mem_reqs;
1353 arg->service_map = svc_bmap;
1354 arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap);
1355 arg->sys_cap_info = ev->sys_cap_info;
1357 ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs),
1358 ath10k_wmi_tlv_parse_mem_reqs, arg);
1359 if (ret) {
1360 ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret);
1361 return ret;
1364 return 0;
1367 static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar,
1368 struct sk_buff *skb,
1369 struct wmi_rdy_ev_arg *arg)
1371 const void **tb;
1372 const struct wmi_tlv_rdy_ev *ev;
1373 int ret;
1375 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1376 if (IS_ERR(tb)) {
1377 ret = PTR_ERR(tb);
1378 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1379 return ret;
1382 ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT];
1383 if (!ev) {
1384 kfree(tb);
1385 return -EPROTO;
1388 arg->sw_version = ev->abi.abi_ver0;
1389 arg->abi_version = ev->abi.abi_ver1;
1390 arg->status = ev->status;
1391 arg->mac_addr = ev->mac_addr.addr;
1393 kfree(tb);
1394 return 0;
1397 static int ath10k_wmi_tlv_svc_avail_parse(struct ath10k *ar, u16 tag, u16 len,
1398 const void *ptr, void *data)
1400 struct wmi_svc_avail_ev_arg *arg = data;
1402 switch (tag) {
1403 case WMI_TLV_TAG_STRUCT_SERVICE_AVAILABLE_EVENT:
1404 arg->service_map_ext_valid = true;
1405 arg->service_map_ext_len = *(__le32 *)ptr;
1406 arg->service_map_ext = ptr + sizeof(__le32);
1407 return 0;
1408 default:
1409 break;
1412 return 0;
1415 static int ath10k_wmi_tlv_op_pull_svc_avail(struct ath10k *ar,
1416 struct sk_buff *skb,
1417 struct wmi_svc_avail_ev_arg *arg)
1419 int ret;
1421 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
1422 ath10k_wmi_tlv_svc_avail_parse, arg);
1424 if (ret) {
1425 ath10k_warn(ar, "failed to parse svc_avail tlv: %d\n", ret);
1426 return ret;
1429 return 0;
1432 static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src,
1433 struct ath10k_fw_stats_vdev *dst)
1435 int i;
1437 dst->vdev_id = __le32_to_cpu(src->vdev_id);
1438 dst->beacon_snr = __le32_to_cpu(src->beacon_snr);
1439 dst->data_snr = __le32_to_cpu(src->data_snr);
1440 dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames);
1441 dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail);
1442 dst->num_rts_success = __le32_to_cpu(src->num_rts_success);
1443 dst->num_rx_err = __le32_to_cpu(src->num_rx_err);
1444 dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard);
1445 dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked);
1447 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++)
1448 dst->num_tx_frames[i] =
1449 __le32_to_cpu(src->num_tx_frames[i]);
1451 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++)
1452 dst->num_tx_frames_retries[i] =
1453 __le32_to_cpu(src->num_tx_frames_retries[i]);
1455 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++)
1456 dst->num_tx_frames_failures[i] =
1457 __le32_to_cpu(src->num_tx_frames_failures[i]);
1459 for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++)
1460 dst->tx_rate_history[i] =
1461 __le32_to_cpu(src->tx_rate_history[i]);
1463 for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++)
1464 dst->beacon_rssi_history[i] =
1465 __le32_to_cpu(src->beacon_rssi_history[i]);
1468 static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1469 struct sk_buff *skb,
1470 struct ath10k_fw_stats *stats)
1472 const void **tb;
1473 const struct wmi_tlv_stats_ev *ev;
1474 u32 num_peer_stats_extd;
1475 const void *data;
1476 u32 num_pdev_stats;
1477 u32 num_vdev_stats;
1478 u32 num_peer_stats;
1479 u32 num_bcnflt_stats;
1480 u32 num_chan_stats;
1481 size_t data_len;
1482 u32 stats_id;
1483 int ret;
1484 int i;
1486 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1487 if (IS_ERR(tb)) {
1488 ret = PTR_ERR(tb);
1489 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1490 return ret;
1493 ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT];
1494 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
1496 if (!ev || !data) {
1497 kfree(tb);
1498 return -EPROTO;
1501 data_len = ath10k_wmi_tlv_len(data);
1502 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1503 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1504 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1505 num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
1506 num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
1507 stats_id = __le32_to_cpu(ev->stats_id);
1508 num_peer_stats_extd = __le32_to_cpu(ev->num_peer_stats_extd);
1510 ath10k_dbg(ar, ATH10K_DBG_WMI,
1511 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i peer_extd %i\n",
1512 num_pdev_stats, num_vdev_stats, num_peer_stats,
1513 num_bcnflt_stats, num_chan_stats, num_peer_stats_extd);
1515 for (i = 0; i < num_pdev_stats; i++) {
1516 const struct wmi_pdev_stats *src;
1517 struct ath10k_fw_stats_pdev *dst;
1519 src = data;
1520 if (data_len < sizeof(*src)) {
1521 kfree(tb);
1522 return -EPROTO;
1525 data += sizeof(*src);
1526 data_len -= sizeof(*src);
1528 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1529 if (!dst)
1530 continue;
1532 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1533 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1534 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1535 list_add_tail(&dst->list, &stats->pdevs);
1538 for (i = 0; i < num_vdev_stats; i++) {
1539 const struct wmi_tlv_vdev_stats *src;
1540 struct ath10k_fw_stats_vdev *dst;
1542 src = data;
1543 if (data_len < sizeof(*src)) {
1544 kfree(tb);
1545 return -EPROTO;
1548 data += sizeof(*src);
1549 data_len -= sizeof(*src);
1551 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1552 if (!dst)
1553 continue;
1555 ath10k_wmi_tlv_pull_vdev_stats(src, dst);
1556 list_add_tail(&dst->list, &stats->vdevs);
1559 for (i = 0; i < num_peer_stats; i++) {
1560 const struct wmi_10x_peer_stats *src;
1561 struct ath10k_fw_stats_peer *dst;
1563 src = data;
1564 if (data_len < sizeof(*src)) {
1565 kfree(tb);
1566 return -EPROTO;
1569 data += sizeof(*src);
1570 data_len -= sizeof(*src);
1572 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1573 if (!dst)
1574 continue;
1576 ath10k_wmi_pull_peer_stats(&src->old, dst);
1577 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1579 if (stats_id & WMI_TLV_STAT_PEER_EXTD) {
1580 const struct wmi_tlv_peer_stats_extd *extd;
1581 unsigned long rx_duration_high;
1583 extd = data + sizeof(*src) * (num_peer_stats - i - 1)
1584 + sizeof(*extd) * i;
1586 dst->rx_duration = __le32_to_cpu(extd->rx_duration);
1587 rx_duration_high = __le32_to_cpu
1588 (extd->rx_duration_high);
1590 if (test_bit(WMI_TLV_PEER_RX_DURATION_HIGH_VALID_BIT,
1591 &rx_duration_high)) {
1592 rx_duration_high =
1593 FIELD_GET(WMI_TLV_PEER_RX_DURATION_HIGH_MASK,
1594 rx_duration_high);
1595 dst->rx_duration |= (u64)rx_duration_high <<
1596 WMI_TLV_PEER_RX_DURATION_SHIFT;
1600 list_add_tail(&dst->list, &stats->peers);
1603 kfree(tb);
1604 return 0;
1607 static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar,
1608 struct sk_buff *skb,
1609 struct wmi_roam_ev_arg *arg)
1611 const void **tb;
1612 const struct wmi_tlv_roam_ev *ev;
1613 int ret;
1615 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1616 if (IS_ERR(tb)) {
1617 ret = PTR_ERR(tb);
1618 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1619 return ret;
1622 ev = tb[WMI_TLV_TAG_STRUCT_ROAM_EVENT];
1623 if (!ev) {
1624 kfree(tb);
1625 return -EPROTO;
1628 arg->vdev_id = ev->vdev_id;
1629 arg->reason = ev->reason;
1630 arg->rssi = ev->rssi;
1632 kfree(tb);
1633 return 0;
1636 static int
1637 ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb,
1638 struct wmi_wow_ev_arg *arg)
1640 const void **tb;
1641 const struct wmi_tlv_wow_event_info *ev;
1642 int ret;
1644 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1645 if (IS_ERR(tb)) {
1646 ret = PTR_ERR(tb);
1647 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1648 return ret;
1651 ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO];
1652 if (!ev) {
1653 kfree(tb);
1654 return -EPROTO;
1657 arg->vdev_id = __le32_to_cpu(ev->vdev_id);
1658 arg->flag = __le32_to_cpu(ev->flag);
1659 arg->wake_reason = __le32_to_cpu(ev->wake_reason);
1660 arg->data_len = __le32_to_cpu(ev->data_len);
1662 kfree(tb);
1663 return 0;
1666 static int ath10k_wmi_tlv_op_pull_echo_ev(struct ath10k *ar,
1667 struct sk_buff *skb,
1668 struct wmi_echo_ev_arg *arg)
1670 const void **tb;
1671 const struct wmi_echo_event *ev;
1672 int ret;
1674 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1675 if (IS_ERR(tb)) {
1676 ret = PTR_ERR(tb);
1677 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1678 return ret;
1681 ev = tb[WMI_TLV_TAG_STRUCT_ECHO_EVENT];
1682 if (!ev) {
1683 kfree(tb);
1684 return -EPROTO;
1687 arg->value = ev->value;
1689 kfree(tb);
1690 return 0;
1693 static struct sk_buff *
1694 ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
1696 struct wmi_tlv_pdev_suspend *cmd;
1697 struct wmi_tlv *tlv;
1698 struct sk_buff *skb;
1700 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1701 if (!skb)
1702 return ERR_PTR(-ENOMEM);
1704 tlv = (void *)skb->data;
1705 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD);
1706 tlv->len = __cpu_to_le16(sizeof(*cmd));
1707 cmd = (void *)tlv->value;
1708 cmd->opt = __cpu_to_le32(opt);
1710 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n");
1711 return skb;
1714 static struct sk_buff *
1715 ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar)
1717 struct wmi_tlv_resume_cmd *cmd;
1718 struct wmi_tlv *tlv;
1719 struct sk_buff *skb;
1721 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1722 if (!skb)
1723 return ERR_PTR(-ENOMEM);
1725 tlv = (void *)skb->data;
1726 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD);
1727 tlv->len = __cpu_to_le16(sizeof(*cmd));
1728 cmd = (void *)tlv->value;
1729 cmd->reserved = __cpu_to_le32(0);
1731 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n");
1732 return skb;
1735 static struct sk_buff *
1736 ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar,
1737 u16 rd, u16 rd2g, u16 rd5g,
1738 u16 ctl2g, u16 ctl5g,
1739 enum wmi_dfs_region dfs_reg)
1741 struct wmi_tlv_pdev_set_rd_cmd *cmd;
1742 struct wmi_tlv *tlv;
1743 struct sk_buff *skb;
1745 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1746 if (!skb)
1747 return ERR_PTR(-ENOMEM);
1749 tlv = (void *)skb->data;
1750 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD);
1751 tlv->len = __cpu_to_le16(sizeof(*cmd));
1752 cmd = (void *)tlv->value;
1753 cmd->regd = __cpu_to_le32(rd);
1754 cmd->regd_2ghz = __cpu_to_le32(rd2g);
1755 cmd->regd_5ghz = __cpu_to_le32(rd5g);
1756 cmd->conform_limit_2ghz = __cpu_to_le32(ctl2g);
1757 cmd->conform_limit_5ghz = __cpu_to_le32(ctl5g);
1759 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n");
1760 return skb;
1763 static enum wmi_txbf_conf ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k *ar)
1765 return WMI_TXBF_CONF_AFTER_ASSOC;
1768 static struct sk_buff *
1769 ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id,
1770 u32 param_value)
1772 struct wmi_tlv_pdev_set_param_cmd *cmd;
1773 struct wmi_tlv *tlv;
1774 struct sk_buff *skb;
1776 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1777 if (!skb)
1778 return ERR_PTR(-ENOMEM);
1780 tlv = (void *)skb->data;
1781 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD);
1782 tlv->len = __cpu_to_le16(sizeof(*cmd));
1783 cmd = (void *)tlv->value;
1784 cmd->param_id = __cpu_to_le32(param_id);
1785 cmd->param_value = __cpu_to_le32(param_value);
1787 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param %d value 0x%x\n",
1788 param_id, param_value);
1789 return skb;
1792 static void
1793 ath10k_wmi_tlv_put_host_mem_chunks(struct ath10k *ar, void *host_mem_chunks)
1795 struct host_memory_chunk_tlv *chunk;
1796 struct wmi_tlv *tlv;
1797 dma_addr_t paddr;
1798 int i;
1799 __le16 tlv_len, tlv_tag;
1801 tlv_tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WLAN_HOST_MEMORY_CHUNK);
1802 tlv_len = __cpu_to_le16(sizeof(*chunk));
1803 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
1804 tlv = host_mem_chunks;
1805 tlv->tag = tlv_tag;
1806 tlv->len = tlv_len;
1807 chunk = (void *)tlv->value;
1809 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
1810 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
1811 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
1813 if (test_bit(WMI_SERVICE_SUPPORT_EXTEND_ADDRESS,
1814 ar->wmi.svc_map)) {
1815 paddr = ar->wmi.mem_chunks[i].paddr;
1816 chunk->ptr_high = __cpu_to_le32(upper_32_bits(paddr));
1819 ath10k_dbg(ar, ATH10K_DBG_WMI,
1820 "wmi-tlv chunk %d len %d, addr 0x%llx, id 0x%x\n",
1822 ar->wmi.mem_chunks[i].len,
1823 (unsigned long long)ar->wmi.mem_chunks[i].paddr,
1824 ar->wmi.mem_chunks[i].req_id);
1826 host_mem_chunks += sizeof(*tlv);
1827 host_mem_chunks += sizeof(*chunk);
1831 static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
1833 struct sk_buff *skb;
1834 struct wmi_tlv *tlv;
1835 struct wmi_tlv_init_cmd *cmd;
1836 struct wmi_tlv_resource_config *cfg;
1837 void *chunks;
1838 size_t len, chunks_len;
1839 void *ptr;
1841 chunks_len = ar->wmi.num_mem_chunks *
1842 (sizeof(struct host_memory_chunk_tlv) + sizeof(*tlv));
1843 len = (sizeof(*tlv) + sizeof(*cmd)) +
1844 (sizeof(*tlv) + sizeof(*cfg)) +
1845 (sizeof(*tlv) + chunks_len);
1847 skb = ath10k_wmi_alloc_skb(ar, len);
1848 if (!skb)
1849 return ERR_PTR(-ENOMEM);
1851 ptr = skb->data;
1853 tlv = ptr;
1854 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD);
1855 tlv->len = __cpu_to_le16(sizeof(*cmd));
1856 cmd = (void *)tlv->value;
1857 ptr += sizeof(*tlv);
1858 ptr += sizeof(*cmd);
1860 tlv = ptr;
1861 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG);
1862 tlv->len = __cpu_to_le16(sizeof(*cfg));
1863 cfg = (void *)tlv->value;
1864 ptr += sizeof(*tlv);
1865 ptr += sizeof(*cfg);
1867 tlv = ptr;
1868 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1869 tlv->len = __cpu_to_le16(chunks_len);
1870 chunks = (void *)tlv->value;
1872 ptr += sizeof(*tlv);
1873 ptr += chunks_len;
1875 cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0);
1876 cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1);
1877 cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0);
1878 cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1);
1879 cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2);
1880 cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3);
1881 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
1883 cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1885 if (ar->hw_params.num_peers)
1886 cfg->num_peers = __cpu_to_le32(ar->hw_params.num_peers);
1887 else
1888 cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS);
1889 cfg->ast_skid_limit = __cpu_to_le32(ar->hw_params.ast_skid_limit);
1890 cfg->num_wds_entries = __cpu_to_le32(ar->hw_params.num_wds_entries);
1892 if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) {
1893 cfg->num_offload_peers = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1894 cfg->num_offload_reorder_bufs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1895 } else {
1896 cfg->num_offload_peers = __cpu_to_le32(0);
1897 cfg->num_offload_reorder_bufs = __cpu_to_le32(0);
1900 cfg->num_peer_keys = __cpu_to_le32(2);
1901 if (ar->hw_params.num_peers)
1902 cfg->num_tids = __cpu_to_le32(ar->hw_params.num_peers * 2);
1903 else
1904 cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS);
1905 cfg->tx_chain_mask = __cpu_to_le32(0x7);
1906 cfg->rx_chain_mask = __cpu_to_le32(0x7);
1907 cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64);
1908 cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64);
1909 cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64);
1910 cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28);
1911 cfg->rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
1912 cfg->scan_max_pending_reqs = __cpu_to_le32(4);
1913 cfg->bmiss_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1914 cfg->roam_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1915 cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8);
1916 cfg->num_mcast_groups = __cpu_to_le32(0);
1917 cfg->num_mcast_table_elems = __cpu_to_le32(0);
1918 cfg->mcast2ucast_mode = __cpu_to_le32(0);
1919 cfg->tx_dbg_log_size = __cpu_to_le32(0x400);
1920 cfg->dma_burst_size = __cpu_to_le32(0);
1921 cfg->mac_aggr_delim = __cpu_to_le32(0);
1922 cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
1923 cfg->vow_config = __cpu_to_le32(0);
1924 cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
1925 cfg->num_msdu_desc = __cpu_to_le32(ar->htt.max_num_pending_tx);
1926 cfg->max_frag_entries = __cpu_to_le32(2);
1927 cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS);
1928 cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
1929 cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2);
1930 cfg->num_multicast_filter_entries = __cpu_to_le32(5);
1931 cfg->num_wow_filters = __cpu_to_le32(ar->wow.max_num_patterns);
1932 cfg->num_keep_alive_pattern = __cpu_to_le32(6);
1933 cfg->keep_alive_pattern_size = __cpu_to_le32(0);
1934 cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1);
1935 cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1);
1936 cfg->wmi_send_separate = __cpu_to_le32(0);
1937 cfg->num_ocb_vdevs = __cpu_to_le32(0);
1938 cfg->num_ocb_channels = __cpu_to_le32(0);
1939 cfg->num_ocb_schedules = __cpu_to_le32(0);
1940 cfg->host_capab = __cpu_to_le32(WMI_TLV_FLAG_MGMT_BUNDLE_TX_COMPL);
1942 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map))
1943 cfg->host_capab |= __cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_ACK_RSSI);
1945 ath10k_wmi_tlv_put_host_mem_chunks(ar, chunks);
1947 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
1948 return skb;
1951 static struct sk_buff *
1952 ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
1953 const struct wmi_start_scan_arg *arg)
1955 struct wmi_tlv_start_scan_cmd *cmd;
1956 struct wmi_tlv *tlv;
1957 struct sk_buff *skb;
1958 size_t len, chan_len, ssid_len, bssid_len, ie_len;
1959 __le32 *chans;
1960 struct wmi_ssid *ssids;
1961 struct wmi_mac_addr *addrs;
1962 void *ptr;
1963 int i, ret;
1965 ret = ath10k_wmi_start_scan_verify(arg);
1966 if (ret)
1967 return ERR_PTR(ret);
1969 chan_len = arg->n_channels * sizeof(__le32);
1970 ssid_len = arg->n_ssids * sizeof(struct wmi_ssid);
1971 bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
1972 ie_len = roundup(arg->ie_len, 4);
1973 len = (sizeof(*tlv) + sizeof(*cmd)) +
1974 sizeof(*tlv) + chan_len +
1975 sizeof(*tlv) + ssid_len +
1976 sizeof(*tlv) + bssid_len +
1977 sizeof(*tlv) + ie_len;
1979 skb = ath10k_wmi_alloc_skb(ar, len);
1980 if (!skb)
1981 return ERR_PTR(-ENOMEM);
1983 ptr = (void *)skb->data;
1984 tlv = ptr;
1985 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD);
1986 tlv->len = __cpu_to_le16(sizeof(*cmd));
1987 cmd = (void *)tlv->value;
1989 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
1990 cmd->burst_duration_ms = __cpu_to_le32(arg->burst_duration_ms);
1991 cmd->num_channels = __cpu_to_le32(arg->n_channels);
1992 cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
1993 cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
1994 cmd->ie_len = __cpu_to_le32(arg->ie_len);
1995 cmd->num_probes = __cpu_to_le32(3);
1996 ether_addr_copy(cmd->mac_addr.addr, arg->mac_addr.addr);
1997 ether_addr_copy(cmd->mac_mask.addr, arg->mac_mask.addr);
1999 /* FIXME: There are some scan flag inconsistencies across firmwares,
2000 * e.g. WMI-TLV inverts the logic behind the following flag.
2002 cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
2004 ptr += sizeof(*tlv);
2005 ptr += sizeof(*cmd);
2007 tlv = ptr;
2008 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
2009 tlv->len = __cpu_to_le16(chan_len);
2010 chans = (void *)tlv->value;
2011 for (i = 0; i < arg->n_channels; i++)
2012 chans[i] = __cpu_to_le32(arg->channels[i]);
2014 ptr += sizeof(*tlv);
2015 ptr += chan_len;
2017 tlv = ptr;
2018 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
2019 tlv->len = __cpu_to_le16(ssid_len);
2020 ssids = (void *)tlv->value;
2021 for (i = 0; i < arg->n_ssids; i++) {
2022 ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len);
2023 memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len);
2026 ptr += sizeof(*tlv);
2027 ptr += ssid_len;
2029 tlv = ptr;
2030 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
2031 tlv->len = __cpu_to_le16(bssid_len);
2032 addrs = (void *)tlv->value;
2033 for (i = 0; i < arg->n_bssids; i++)
2034 ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid);
2036 ptr += sizeof(*tlv);
2037 ptr += bssid_len;
2039 tlv = ptr;
2040 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2041 tlv->len = __cpu_to_le16(ie_len);
2042 memcpy(tlv->value, arg->ie, arg->ie_len);
2044 ptr += sizeof(*tlv);
2045 ptr += ie_len;
2047 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
2048 return skb;
2051 static struct sk_buff *
2052 ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar,
2053 const struct wmi_stop_scan_arg *arg)
2055 struct wmi_stop_scan_cmd *cmd;
2056 struct wmi_tlv *tlv;
2057 struct sk_buff *skb;
2058 u32 scan_id;
2059 u32 req_id;
2061 if (arg->req_id > 0xFFF)
2062 return ERR_PTR(-EINVAL);
2063 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
2064 return ERR_PTR(-EINVAL);
2066 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2067 if (!skb)
2068 return ERR_PTR(-ENOMEM);
2070 scan_id = arg->u.scan_id;
2071 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
2073 req_id = arg->req_id;
2074 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
2076 tlv = (void *)skb->data;
2077 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD);
2078 tlv->len = __cpu_to_le16(sizeof(*cmd));
2079 cmd = (void *)tlv->value;
2080 cmd->req_type = __cpu_to_le32(arg->req_type);
2081 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
2082 cmd->scan_id = __cpu_to_le32(scan_id);
2083 cmd->scan_req_id = __cpu_to_le32(req_id);
2085 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n");
2086 return skb;
2089 static int ath10k_wmi_tlv_op_get_vdev_subtype(struct ath10k *ar,
2090 enum wmi_vdev_subtype subtype)
2092 switch (subtype) {
2093 case WMI_VDEV_SUBTYPE_NONE:
2094 return WMI_TLV_VDEV_SUBTYPE_NONE;
2095 case WMI_VDEV_SUBTYPE_P2P_DEVICE:
2096 return WMI_TLV_VDEV_SUBTYPE_P2P_DEV;
2097 case WMI_VDEV_SUBTYPE_P2P_CLIENT:
2098 return WMI_TLV_VDEV_SUBTYPE_P2P_CLI;
2099 case WMI_VDEV_SUBTYPE_P2P_GO:
2100 return WMI_TLV_VDEV_SUBTYPE_P2P_GO;
2101 case WMI_VDEV_SUBTYPE_PROXY_STA:
2102 return WMI_TLV_VDEV_SUBTYPE_PROXY_STA;
2103 case WMI_VDEV_SUBTYPE_MESH_11S:
2104 return WMI_TLV_VDEV_SUBTYPE_MESH_11S;
2105 case WMI_VDEV_SUBTYPE_MESH_NON_11S:
2106 return -ENOTSUPP;
2108 return -ENOTSUPP;
2111 static struct sk_buff *
2112 ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar,
2113 u32 vdev_id,
2114 enum wmi_vdev_type vdev_type,
2115 enum wmi_vdev_subtype vdev_subtype,
2116 const u8 mac_addr[ETH_ALEN])
2118 struct wmi_vdev_create_cmd *cmd;
2119 struct wmi_tlv *tlv;
2120 struct sk_buff *skb;
2122 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2123 if (!skb)
2124 return ERR_PTR(-ENOMEM);
2126 tlv = (void *)skb->data;
2127 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD);
2128 tlv->len = __cpu_to_le16(sizeof(*cmd));
2129 cmd = (void *)tlv->value;
2130 cmd->vdev_id = __cpu_to_le32(vdev_id);
2131 cmd->vdev_type = __cpu_to_le32(vdev_type);
2132 cmd->vdev_subtype = __cpu_to_le32(vdev_subtype);
2133 ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr);
2135 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n");
2136 return skb;
2139 static struct sk_buff *
2140 ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
2142 struct wmi_vdev_delete_cmd *cmd;
2143 struct wmi_tlv *tlv;
2144 struct sk_buff *skb;
2146 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2147 if (!skb)
2148 return ERR_PTR(-ENOMEM);
2150 tlv = (void *)skb->data;
2151 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD);
2152 tlv->len = __cpu_to_le16(sizeof(*cmd));
2153 cmd = (void *)tlv->value;
2154 cmd->vdev_id = __cpu_to_le32(vdev_id);
2156 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n");
2157 return skb;
2160 static struct sk_buff *
2161 ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
2162 const struct wmi_vdev_start_request_arg *arg,
2163 bool restart)
2165 struct wmi_tlv_vdev_start_cmd *cmd;
2166 struct wmi_channel *ch;
2167 struct wmi_tlv *tlv;
2168 struct sk_buff *skb;
2169 size_t len;
2170 void *ptr;
2171 u32 flags = 0;
2173 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
2174 return ERR_PTR(-EINVAL);
2175 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
2176 return ERR_PTR(-EINVAL);
2178 len = (sizeof(*tlv) + sizeof(*cmd)) +
2179 (sizeof(*tlv) + sizeof(*ch)) +
2180 (sizeof(*tlv) + 0);
2181 skb = ath10k_wmi_alloc_skb(ar, len);
2182 if (!skb)
2183 return ERR_PTR(-ENOMEM);
2185 if (arg->hidden_ssid)
2186 flags |= WMI_VDEV_START_HIDDEN_SSID;
2187 if (arg->pmf_enabled)
2188 flags |= WMI_VDEV_START_PMF_ENABLED;
2190 ptr = (void *)skb->data;
2192 tlv = ptr;
2193 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD);
2194 tlv->len = __cpu_to_le16(sizeof(*cmd));
2195 cmd = (void *)tlv->value;
2196 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2197 cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval);
2198 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
2199 cmd->flags = __cpu_to_le32(flags);
2200 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
2201 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
2202 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
2204 if (arg->ssid) {
2205 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
2206 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
2209 ptr += sizeof(*tlv);
2210 ptr += sizeof(*cmd);
2212 tlv = ptr;
2213 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2214 tlv->len = __cpu_to_le16(sizeof(*ch));
2215 ch = (void *)tlv->value;
2216 ath10k_wmi_put_wmi_channel(ar, ch, &arg->channel);
2218 ptr += sizeof(*tlv);
2219 ptr += sizeof(*ch);
2221 tlv = ptr;
2222 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2223 tlv->len = 0;
2225 /* Note: This is a nested TLV containing:
2226 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
2229 ptr += sizeof(*tlv);
2230 ptr += 0;
2232 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n");
2233 return skb;
2236 static struct sk_buff *
2237 ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
2239 struct wmi_vdev_stop_cmd *cmd;
2240 struct wmi_tlv *tlv;
2241 struct sk_buff *skb;
2243 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2244 if (!skb)
2245 return ERR_PTR(-ENOMEM);
2247 tlv = (void *)skb->data;
2248 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD);
2249 tlv->len = __cpu_to_le16(sizeof(*cmd));
2250 cmd = (void *)tlv->value;
2251 cmd->vdev_id = __cpu_to_le32(vdev_id);
2253 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n");
2254 return skb;
2257 static struct sk_buff *
2258 ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
2259 const u8 *bssid)
2262 struct wmi_vdev_up_cmd *cmd;
2263 struct wmi_tlv *tlv;
2264 struct sk_buff *skb;
2266 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2267 if (!skb)
2268 return ERR_PTR(-ENOMEM);
2270 tlv = (void *)skb->data;
2271 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD);
2272 tlv->len = __cpu_to_le16(sizeof(*cmd));
2273 cmd = (void *)tlv->value;
2274 cmd->vdev_id = __cpu_to_le32(vdev_id);
2275 cmd->vdev_assoc_id = __cpu_to_le32(aid);
2276 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
2278 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n");
2279 return skb;
2282 static struct sk_buff *
2283 ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
2285 struct wmi_vdev_down_cmd *cmd;
2286 struct wmi_tlv *tlv;
2287 struct sk_buff *skb;
2289 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2290 if (!skb)
2291 return ERR_PTR(-ENOMEM);
2293 tlv = (void *)skb->data;
2294 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD);
2295 tlv->len = __cpu_to_le16(sizeof(*cmd));
2296 cmd = (void *)tlv->value;
2297 cmd->vdev_id = __cpu_to_le32(vdev_id);
2299 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n");
2300 return skb;
2303 static struct sk_buff *
2304 ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
2305 u32 param_id, u32 param_value)
2307 struct wmi_vdev_set_param_cmd *cmd;
2308 struct wmi_tlv *tlv;
2309 struct sk_buff *skb;
2311 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2312 if (!skb)
2313 return ERR_PTR(-ENOMEM);
2315 tlv = (void *)skb->data;
2316 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD);
2317 tlv->len = __cpu_to_le16(sizeof(*cmd));
2318 cmd = (void *)tlv->value;
2319 cmd->vdev_id = __cpu_to_le32(vdev_id);
2320 cmd->param_id = __cpu_to_le32(param_id);
2321 cmd->param_value = __cpu_to_le32(param_value);
2323 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev %d set param %d value 0x%x\n",
2324 vdev_id, param_id, param_value);
2325 return skb;
2328 static struct sk_buff *
2329 ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar,
2330 const struct wmi_vdev_install_key_arg *arg)
2332 struct wmi_vdev_install_key_cmd *cmd;
2333 struct wmi_tlv *tlv;
2334 struct sk_buff *skb;
2335 size_t len;
2336 void *ptr;
2338 if (arg->key_cipher == ar->wmi_key_cipher[WMI_CIPHER_NONE] &&
2339 arg->key_data)
2340 return ERR_PTR(-EINVAL);
2341 if (arg->key_cipher != ar->wmi_key_cipher[WMI_CIPHER_NONE] &&
2342 !arg->key_data)
2343 return ERR_PTR(-EINVAL);
2345 len = sizeof(*tlv) + sizeof(*cmd) +
2346 sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32));
2347 skb = ath10k_wmi_alloc_skb(ar, len);
2348 if (!skb)
2349 return ERR_PTR(-ENOMEM);
2351 ptr = (void *)skb->data;
2352 tlv = ptr;
2353 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD);
2354 tlv->len = __cpu_to_le16(sizeof(*cmd));
2355 cmd = (void *)tlv->value;
2356 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2357 cmd->key_idx = __cpu_to_le32(arg->key_idx);
2358 cmd->key_flags = __cpu_to_le32(arg->key_flags);
2359 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
2360 cmd->key_len = __cpu_to_le32(arg->key_len);
2361 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
2362 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
2364 if (arg->macaddr)
2365 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
2367 ptr += sizeof(*tlv);
2368 ptr += sizeof(*cmd);
2370 tlv = ptr;
2371 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2372 tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32)));
2373 if (arg->key_data)
2374 memcpy(tlv->value, arg->key_data, arg->key_len);
2376 ptr += sizeof(*tlv);
2377 ptr += roundup(arg->key_len, sizeof(__le32));
2379 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n");
2380 return skb;
2383 static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr,
2384 const struct wmi_sta_uapsd_auto_trig_arg *arg)
2386 struct wmi_sta_uapsd_auto_trig_param *ac;
2387 struct wmi_tlv *tlv;
2389 tlv = ptr;
2390 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM);
2391 tlv->len = __cpu_to_le16(sizeof(*ac));
2392 ac = (void *)tlv->value;
2394 ac->wmm_ac = __cpu_to_le32(arg->wmm_ac);
2395 ac->user_priority = __cpu_to_le32(arg->user_priority);
2396 ac->service_interval = __cpu_to_le32(arg->service_interval);
2397 ac->suspend_interval = __cpu_to_le32(arg->suspend_interval);
2398 ac->delay_interval = __cpu_to_le32(arg->delay_interval);
2400 ath10k_dbg(ar, ATH10K_DBG_WMI,
2401 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
2402 ac->wmm_ac, ac->user_priority, ac->service_interval,
2403 ac->suspend_interval, ac->delay_interval);
2405 return ptr + sizeof(*tlv) + sizeof(*ac);
2408 static struct sk_buff *
2409 ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
2410 const u8 peer_addr[ETH_ALEN],
2411 const struct wmi_sta_uapsd_auto_trig_arg *args,
2412 u32 num_ac)
2414 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
2415 struct wmi_sta_uapsd_auto_trig_param *ac;
2416 struct wmi_tlv *tlv;
2417 struct sk_buff *skb;
2418 size_t len;
2419 size_t ac_tlv_len;
2420 void *ptr;
2421 int i;
2423 ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac));
2424 len = sizeof(*tlv) + sizeof(*cmd) +
2425 sizeof(*tlv) + ac_tlv_len;
2426 skb = ath10k_wmi_alloc_skb(ar, len);
2427 if (!skb)
2428 return ERR_PTR(-ENOMEM);
2430 ptr = (void *)skb->data;
2431 tlv = ptr;
2432 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD);
2433 tlv->len = __cpu_to_le16(sizeof(*cmd));
2434 cmd = (void *)tlv->value;
2435 cmd->vdev_id = __cpu_to_le32(vdev_id);
2436 cmd->num_ac = __cpu_to_le32(num_ac);
2437 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2439 ptr += sizeof(*tlv);
2440 ptr += sizeof(*cmd);
2442 tlv = ptr;
2443 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2444 tlv->len = __cpu_to_le16(ac_tlv_len);
2445 ac = (void *)tlv->value;
2447 ptr += sizeof(*tlv);
2448 for (i = 0; i < num_ac; i++)
2449 ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]);
2451 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n");
2452 return skb;
2455 static void *ath10k_wmi_tlv_put_wmm(void *ptr,
2456 const struct wmi_wmm_params_arg *arg)
2458 struct wmi_wmm_params *wmm;
2459 struct wmi_tlv *tlv;
2461 tlv = ptr;
2462 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS);
2463 tlv->len = __cpu_to_le16(sizeof(*wmm));
2464 wmm = (void *)tlv->value;
2465 ath10k_wmi_set_wmm_param(wmm, arg);
2467 return ptr + sizeof(*tlv) + sizeof(*wmm);
2470 static struct sk_buff *
2471 ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
2472 const struct wmi_wmm_params_all_arg *arg)
2474 struct wmi_tlv_vdev_set_wmm_cmd *cmd;
2475 struct wmi_tlv *tlv;
2476 struct sk_buff *skb;
2477 size_t len;
2478 void *ptr;
2480 len = sizeof(*tlv) + sizeof(*cmd);
2481 skb = ath10k_wmi_alloc_skb(ar, len);
2482 if (!skb)
2483 return ERR_PTR(-ENOMEM);
2485 ptr = (void *)skb->data;
2486 tlv = ptr;
2487 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD);
2488 tlv->len = __cpu_to_le16(sizeof(*cmd));
2489 cmd = (void *)tlv->value;
2490 cmd->vdev_id = __cpu_to_le32(vdev_id);
2492 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be);
2493 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk);
2494 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi);
2495 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo);
2497 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n");
2498 return skb;
2501 static struct sk_buff *
2502 ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
2503 const struct wmi_sta_keepalive_arg *arg)
2505 struct wmi_tlv_sta_keepalive_cmd *cmd;
2506 struct wmi_sta_keepalive_arp_resp *arp;
2507 struct sk_buff *skb;
2508 struct wmi_tlv *tlv;
2509 void *ptr;
2510 size_t len;
2512 len = sizeof(*tlv) + sizeof(*cmd) +
2513 sizeof(*tlv) + sizeof(*arp);
2514 skb = ath10k_wmi_alloc_skb(ar, len);
2515 if (!skb)
2516 return ERR_PTR(-ENOMEM);
2518 ptr = (void *)skb->data;
2519 tlv = ptr;
2520 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD);
2521 tlv->len = __cpu_to_le16(sizeof(*cmd));
2522 cmd = (void *)tlv->value;
2523 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2524 cmd->enabled = __cpu_to_le32(arg->enabled);
2525 cmd->method = __cpu_to_le32(arg->method);
2526 cmd->interval = __cpu_to_le32(arg->interval);
2528 ptr += sizeof(*tlv);
2529 ptr += sizeof(*cmd);
2531 tlv = ptr;
2532 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE);
2533 tlv->len = __cpu_to_le16(sizeof(*arp));
2534 arp = (void *)tlv->value;
2536 arp->src_ip4_addr = arg->src_ip4_addr;
2537 arp->dest_ip4_addr = arg->dest_ip4_addr;
2538 ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
2540 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d interval %d\n",
2541 arg->vdev_id, arg->enabled, arg->method, arg->interval);
2542 return skb;
2545 static struct sk_buff *
2546 ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
2547 const u8 peer_addr[ETH_ALEN],
2548 enum wmi_peer_type peer_type)
2550 struct wmi_tlv_peer_create_cmd *cmd;
2551 struct wmi_tlv *tlv;
2552 struct sk_buff *skb;
2554 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2555 if (!skb)
2556 return ERR_PTR(-ENOMEM);
2558 tlv = (void *)skb->data;
2559 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD);
2560 tlv->len = __cpu_to_le16(sizeof(*cmd));
2561 cmd = (void *)tlv->value;
2562 cmd->vdev_id = __cpu_to_le32(vdev_id);
2563 cmd->peer_type = __cpu_to_le32(peer_type);
2564 ether_addr_copy(cmd->peer_addr.addr, peer_addr);
2566 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n");
2567 return skb;
2570 static struct sk_buff *
2571 ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
2572 const u8 peer_addr[ETH_ALEN])
2574 struct wmi_peer_delete_cmd *cmd;
2575 struct wmi_tlv *tlv;
2576 struct sk_buff *skb;
2578 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2579 if (!skb)
2580 return ERR_PTR(-ENOMEM);
2582 tlv = (void *)skb->data;
2583 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD);
2584 tlv->len = __cpu_to_le16(sizeof(*cmd));
2585 cmd = (void *)tlv->value;
2586 cmd->vdev_id = __cpu_to_le32(vdev_id);
2587 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2589 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n");
2590 return skb;
2593 static struct sk_buff *
2594 ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
2595 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
2597 struct wmi_peer_flush_tids_cmd *cmd;
2598 struct wmi_tlv *tlv;
2599 struct sk_buff *skb;
2601 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2602 if (!skb)
2603 return ERR_PTR(-ENOMEM);
2605 tlv = (void *)skb->data;
2606 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD);
2607 tlv->len = __cpu_to_le16(sizeof(*cmd));
2608 cmd = (void *)tlv->value;
2609 cmd->vdev_id = __cpu_to_le32(vdev_id);
2610 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
2611 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2613 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n");
2614 return skb;
2617 static struct sk_buff *
2618 ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
2619 const u8 *peer_addr,
2620 enum wmi_peer_param param_id,
2621 u32 param_value)
2623 struct wmi_peer_set_param_cmd *cmd;
2624 struct wmi_tlv *tlv;
2625 struct sk_buff *skb;
2627 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2628 if (!skb)
2629 return ERR_PTR(-ENOMEM);
2631 tlv = (void *)skb->data;
2632 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD);
2633 tlv->len = __cpu_to_le16(sizeof(*cmd));
2634 cmd = (void *)tlv->value;
2635 cmd->vdev_id = __cpu_to_le32(vdev_id);
2636 cmd->param_id = __cpu_to_le32(param_id);
2637 cmd->param_value = __cpu_to_le32(param_value);
2638 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2640 ath10k_dbg(ar, ATH10K_DBG_WMI,
2641 "wmi tlv vdev %d peer %pM set param %d value 0x%x\n",
2642 vdev_id, peer_addr, param_id, param_value);
2643 return skb;
2646 static struct sk_buff *
2647 ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar,
2648 const struct wmi_peer_assoc_complete_arg *arg)
2650 struct wmi_tlv_peer_assoc_cmd *cmd;
2651 struct wmi_vht_rate_set *vht_rate;
2652 struct wmi_tlv *tlv;
2653 struct sk_buff *skb;
2654 size_t len, legacy_rate_len, ht_rate_len;
2655 void *ptr;
2657 if (arg->peer_mpdu_density > 16)
2658 return ERR_PTR(-EINVAL);
2659 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
2660 return ERR_PTR(-EINVAL);
2661 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
2662 return ERR_PTR(-EINVAL);
2664 legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates,
2665 sizeof(__le32));
2666 ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32));
2667 len = (sizeof(*tlv) + sizeof(*cmd)) +
2668 (sizeof(*tlv) + legacy_rate_len) +
2669 (sizeof(*tlv) + ht_rate_len) +
2670 (sizeof(*tlv) + sizeof(*vht_rate));
2671 skb = ath10k_wmi_alloc_skb(ar, len);
2672 if (!skb)
2673 return ERR_PTR(-ENOMEM);
2675 ptr = (void *)skb->data;
2676 tlv = ptr;
2677 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD);
2678 tlv->len = __cpu_to_le16(sizeof(*cmd));
2679 cmd = (void *)tlv->value;
2681 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2682 cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
2683 cmd->assoc_id = __cpu_to_le32(arg->peer_aid);
2684 cmd->flags = __cpu_to_le32(arg->peer_flags);
2685 cmd->caps = __cpu_to_le32(arg->peer_caps);
2686 cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval);
2687 cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps);
2688 cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
2689 cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
2690 cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps);
2691 cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams);
2692 cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps);
2693 cmd->phy_mode = __cpu_to_le32(arg->peer_phymode);
2694 cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates);
2695 cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates);
2696 ether_addr_copy(cmd->mac_addr.addr, arg->addr);
2698 ptr += sizeof(*tlv);
2699 ptr += sizeof(*cmd);
2701 tlv = ptr;
2702 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2703 tlv->len = __cpu_to_le16(legacy_rate_len);
2704 memcpy(tlv->value, arg->peer_legacy_rates.rates,
2705 arg->peer_legacy_rates.num_rates);
2707 ptr += sizeof(*tlv);
2708 ptr += legacy_rate_len;
2710 tlv = ptr;
2711 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2712 tlv->len = __cpu_to_le16(ht_rate_len);
2713 memcpy(tlv->value, arg->peer_ht_rates.rates,
2714 arg->peer_ht_rates.num_rates);
2716 ptr += sizeof(*tlv);
2717 ptr += ht_rate_len;
2719 tlv = ptr;
2720 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET);
2721 tlv->len = __cpu_to_le16(sizeof(*vht_rate));
2722 vht_rate = (void *)tlv->value;
2724 vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
2725 vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
2726 vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
2727 vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
2729 ptr += sizeof(*tlv);
2730 ptr += sizeof(*vht_rate);
2732 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n");
2733 return skb;
2736 static struct sk_buff *
2737 ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
2738 enum wmi_sta_ps_mode psmode)
2740 struct wmi_sta_powersave_mode_cmd *cmd;
2741 struct wmi_tlv *tlv;
2742 struct sk_buff *skb;
2744 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2745 if (!skb)
2746 return ERR_PTR(-ENOMEM);
2748 tlv = (void *)skb->data;
2749 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD);
2750 tlv->len = __cpu_to_le16(sizeof(*cmd));
2751 cmd = (void *)tlv->value;
2752 cmd->vdev_id = __cpu_to_le32(vdev_id);
2753 cmd->sta_ps_mode = __cpu_to_le32(psmode);
2755 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n");
2756 return skb;
2759 static struct sk_buff *
2760 ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
2761 enum wmi_sta_powersave_param param_id,
2762 u32 param_value)
2764 struct wmi_sta_powersave_param_cmd *cmd;
2765 struct wmi_tlv *tlv;
2766 struct sk_buff *skb;
2768 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2769 if (!skb)
2770 return ERR_PTR(-ENOMEM);
2772 tlv = (void *)skb->data;
2773 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD);
2774 tlv->len = __cpu_to_le16(sizeof(*cmd));
2775 cmd = (void *)tlv->value;
2776 cmd->vdev_id = __cpu_to_le32(vdev_id);
2777 cmd->param_id = __cpu_to_le32(param_id);
2778 cmd->param_value = __cpu_to_le32(param_value);
2780 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n");
2781 return skb;
2784 static struct sk_buff *
2785 ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
2786 enum wmi_ap_ps_peer_param param_id, u32 value)
2788 struct wmi_ap_ps_peer_cmd *cmd;
2789 struct wmi_tlv *tlv;
2790 struct sk_buff *skb;
2792 if (!mac)
2793 return ERR_PTR(-EINVAL);
2795 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2796 if (!skb)
2797 return ERR_PTR(-ENOMEM);
2799 tlv = (void *)skb->data;
2800 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD);
2801 tlv->len = __cpu_to_le16(sizeof(*cmd));
2802 cmd = (void *)tlv->value;
2803 cmd->vdev_id = __cpu_to_le32(vdev_id);
2804 cmd->param_id = __cpu_to_le32(param_id);
2805 cmd->param_value = __cpu_to_le32(value);
2806 ether_addr_copy(cmd->peer_macaddr.addr, mac);
2808 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n");
2809 return skb;
2812 static struct sk_buff *
2813 ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar,
2814 const struct wmi_scan_chan_list_arg *arg)
2816 struct wmi_tlv_scan_chan_list_cmd *cmd;
2817 struct wmi_channel *ci;
2818 struct wmi_channel_arg *ch;
2819 struct wmi_tlv *tlv;
2820 struct sk_buff *skb;
2821 size_t chans_len, len;
2822 int i;
2823 void *ptr, *chans;
2825 chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci));
2826 len = (sizeof(*tlv) + sizeof(*cmd)) +
2827 (sizeof(*tlv) + chans_len);
2829 skb = ath10k_wmi_alloc_skb(ar, len);
2830 if (!skb)
2831 return ERR_PTR(-ENOMEM);
2833 ptr = (void *)skb->data;
2834 tlv = ptr;
2835 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD);
2836 tlv->len = __cpu_to_le16(sizeof(*cmd));
2837 cmd = (void *)tlv->value;
2838 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
2840 ptr += sizeof(*tlv);
2841 ptr += sizeof(*cmd);
2843 tlv = ptr;
2844 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2845 tlv->len = __cpu_to_le16(chans_len);
2846 chans = (void *)tlv->value;
2848 for (i = 0; i < arg->n_channels; i++) {
2849 ch = &arg->channels[i];
2851 tlv = chans;
2852 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2853 tlv->len = __cpu_to_le16(sizeof(*ci));
2854 ci = (void *)tlv->value;
2856 ath10k_wmi_put_wmi_channel(ar, ci, ch);
2858 chans += sizeof(*tlv);
2859 chans += sizeof(*ci);
2862 ptr += sizeof(*tlv);
2863 ptr += chans_len;
2865 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n");
2866 return skb;
2869 static struct sk_buff *
2870 ath10k_wmi_tlv_op_gen_scan_prob_req_oui(struct ath10k *ar, u32 prob_req_oui)
2872 struct wmi_scan_prob_req_oui_cmd *cmd;
2873 struct wmi_tlv *tlv;
2874 struct sk_buff *skb;
2876 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2877 if (!skb)
2878 return ERR_PTR(-ENOMEM);
2880 tlv = (void *)skb->data;
2881 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_PROB_REQ_OUI_CMD);
2882 tlv->len = __cpu_to_le16(sizeof(*cmd));
2883 cmd = (void *)tlv->value;
2884 cmd->prob_req_oui = __cpu_to_le32(prob_req_oui);
2886 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan prob req oui\n");
2887 return skb;
2890 static struct sk_buff *
2891 ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id,
2892 const void *bcn, size_t bcn_len,
2893 u32 bcn_paddr, bool dtim_zero,
2894 bool deliver_cab)
2897 struct wmi_bcn_tx_ref_cmd *cmd;
2898 struct wmi_tlv *tlv;
2899 struct sk_buff *skb;
2900 struct ieee80211_hdr *hdr;
2901 u16 fc;
2903 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2904 if (!skb)
2905 return ERR_PTR(-ENOMEM);
2907 hdr = (struct ieee80211_hdr *)bcn;
2908 fc = le16_to_cpu(hdr->frame_control);
2910 tlv = (void *)skb->data;
2911 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD);
2912 tlv->len = __cpu_to_le16(sizeof(*cmd));
2913 cmd = (void *)tlv->value;
2914 cmd->vdev_id = __cpu_to_le32(vdev_id);
2915 cmd->data_len = __cpu_to_le32(bcn_len);
2916 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
2917 cmd->msdu_id = 0;
2918 cmd->frame_control = __cpu_to_le32(fc);
2919 cmd->flags = 0;
2921 if (dtim_zero)
2922 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
2924 if (deliver_cab)
2925 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
2927 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n");
2928 return skb;
2931 static struct sk_buff *
2932 ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar,
2933 const struct wmi_wmm_params_all_arg *arg)
2935 struct wmi_tlv_pdev_set_wmm_cmd *cmd;
2936 struct wmi_wmm_params *wmm;
2937 struct wmi_tlv *tlv;
2938 struct sk_buff *skb;
2939 size_t len;
2940 void *ptr;
2942 len = (sizeof(*tlv) + sizeof(*cmd)) +
2943 (4 * (sizeof(*tlv) + sizeof(*wmm)));
2944 skb = ath10k_wmi_alloc_skb(ar, len);
2945 if (!skb)
2946 return ERR_PTR(-ENOMEM);
2948 ptr = (void *)skb->data;
2950 tlv = ptr;
2951 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD);
2952 tlv->len = __cpu_to_le16(sizeof(*cmd));
2953 cmd = (void *)tlv->value;
2955 /* nothing to set here */
2957 ptr += sizeof(*tlv);
2958 ptr += sizeof(*cmd);
2960 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be);
2961 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk);
2962 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi);
2963 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo);
2965 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n");
2966 return skb;
2969 static struct sk_buff *
2970 ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
2972 struct wmi_request_stats_cmd *cmd;
2973 struct wmi_tlv *tlv;
2974 struct sk_buff *skb;
2976 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2977 if (!skb)
2978 return ERR_PTR(-ENOMEM);
2980 tlv = (void *)skb->data;
2981 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD);
2982 tlv->len = __cpu_to_le16(sizeof(*cmd));
2983 cmd = (void *)tlv->value;
2984 cmd->stats_id = __cpu_to_le32(stats_mask);
2986 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n");
2987 return skb;
2990 static struct sk_buff *
2991 ath10k_wmi_tlv_op_gen_request_peer_stats_info(struct ath10k *ar,
2992 u32 vdev_id,
2993 enum wmi_peer_stats_info_request_type type,
2994 u8 *addr,
2995 u32 reset)
2997 struct wmi_tlv_request_peer_stats_info *cmd;
2998 struct wmi_tlv *tlv;
2999 struct sk_buff *skb;
3001 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
3002 if (!skb)
3003 return ERR_PTR(-ENOMEM);
3005 tlv = (void *)skb->data;
3006 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_PEER_STATS_INFO_CMD);
3007 tlv->len = __cpu_to_le16(sizeof(*cmd));
3008 cmd = (void *)tlv->value;
3009 cmd->vdev_id = __cpu_to_le32(vdev_id);
3010 cmd->request_type = __cpu_to_le32(type);
3012 if (type == WMI_REQUEST_ONE_PEER_STATS_INFO)
3013 ether_addr_copy(cmd->peer_macaddr.addr, addr);
3015 cmd->reset_after_request = __cpu_to_le32(reset);
3016 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request peer stats info\n");
3017 return skb;
3020 static int
3021 ath10k_wmi_tlv_op_cleanup_mgmt_tx_send(struct ath10k *ar,
3022 struct sk_buff *msdu)
3024 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(msdu);
3025 struct ath10k_wmi *wmi = &ar->wmi;
3027 idr_remove(&wmi->mgmt_pending_tx, cb->msdu_id);
3029 return 0;
3032 static int
3033 ath10k_wmi_mgmt_tx_alloc_msdu_id(struct ath10k *ar, struct sk_buff *skb,
3034 dma_addr_t paddr)
3036 struct ath10k_wmi *wmi = &ar->wmi;
3037 struct ath10k_mgmt_tx_pkt_addr *pkt_addr;
3038 int ret;
3040 pkt_addr = kmalloc(sizeof(*pkt_addr), GFP_ATOMIC);
3041 if (!pkt_addr)
3042 return -ENOMEM;
3044 pkt_addr->vaddr = skb;
3045 pkt_addr->paddr = paddr;
3047 spin_lock_bh(&ar->data_lock);
3048 ret = idr_alloc(&wmi->mgmt_pending_tx, pkt_addr, 0,
3049 wmi->mgmt_max_num_pending_tx, GFP_ATOMIC);
3050 spin_unlock_bh(&ar->data_lock);
3052 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx alloc msdu_id ret %d\n", ret);
3053 return ret;
3056 static struct sk_buff *
3057 ath10k_wmi_tlv_op_gen_mgmt_tx_send(struct ath10k *ar, struct sk_buff *msdu,
3058 dma_addr_t paddr)
3060 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(msdu);
3061 struct wmi_tlv_mgmt_tx_cmd *cmd;
3062 struct ieee80211_hdr *hdr;
3063 struct ath10k_vif *arvif;
3064 u32 buf_len = msdu->len;
3065 struct wmi_tlv *tlv;
3066 struct sk_buff *skb;
3067 int len, desc_id;
3068 u32 vdev_id;
3069 void *ptr;
3071 if (!cb->vif)
3072 return ERR_PTR(-EINVAL);
3074 hdr = (struct ieee80211_hdr *)msdu->data;
3075 arvif = (void *)cb->vif->drv_priv;
3076 vdev_id = arvif->vdev_id;
3078 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control) &&
3079 (!(ieee80211_is_nullfunc(hdr->frame_control) ||
3080 ieee80211_is_qos_nullfunc(hdr->frame_control)))))
3081 return ERR_PTR(-EINVAL);
3083 len = sizeof(*cmd) + 2 * sizeof(*tlv);
3085 if ((ieee80211_is_action(hdr->frame_control) ||
3086 ieee80211_is_deauth(hdr->frame_control) ||
3087 ieee80211_is_disassoc(hdr->frame_control)) &&
3088 ieee80211_has_protected(hdr->frame_control)) {
3089 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
3090 buf_len += IEEE80211_CCMP_MIC_LEN;
3093 buf_len = min_t(u32, buf_len, WMI_TLV_MGMT_TX_FRAME_MAX_LEN);
3094 buf_len = round_up(buf_len, 4);
3096 len += buf_len;
3097 len = round_up(len, 4);
3098 skb = ath10k_wmi_alloc_skb(ar, len);
3099 if (!skb)
3100 return ERR_PTR(-ENOMEM);
3102 desc_id = ath10k_wmi_mgmt_tx_alloc_msdu_id(ar, msdu, paddr);
3103 if (desc_id < 0)
3104 goto err_free_skb;
3106 cb->msdu_id = desc_id;
3108 ptr = (void *)skb->data;
3109 tlv = ptr;
3110 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_MGMT_TX_CMD);
3111 tlv->len = __cpu_to_le16(sizeof(*cmd));
3112 cmd = (void *)tlv->value;
3113 cmd->vdev_id = __cpu_to_le32(vdev_id);
3114 cmd->desc_id = __cpu_to_le32(desc_id);
3115 cmd->chanfreq = 0;
3116 cmd->buf_len = __cpu_to_le32(buf_len);
3117 cmd->frame_len = __cpu_to_le32(msdu->len);
3118 cmd->paddr = __cpu_to_le64(paddr);
3120 ptr += sizeof(*tlv);
3121 ptr += sizeof(*cmd);
3123 tlv = ptr;
3124 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
3125 tlv->len = __cpu_to_le16(buf_len);
3127 ptr += sizeof(*tlv);
3128 memcpy(ptr, msdu->data, buf_len);
3130 return skb;
3132 err_free_skb:
3133 dev_kfree_skb(skb);
3134 return ERR_PTR(desc_id);
3137 static struct sk_buff *
3138 ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar,
3139 enum wmi_force_fw_hang_type type,
3140 u32 delay_ms)
3142 struct wmi_force_fw_hang_cmd *cmd;
3143 struct wmi_tlv *tlv;
3144 struct sk_buff *skb;
3146 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
3147 if (!skb)
3148 return ERR_PTR(-ENOMEM);
3150 tlv = (void *)skb->data;
3151 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD);
3152 tlv->len = __cpu_to_le16(sizeof(*cmd));
3153 cmd = (void *)tlv->value;
3154 cmd->type = __cpu_to_le32(type);
3155 cmd->delay_ms = __cpu_to_le32(delay_ms);
3157 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n");
3158 return skb;
3161 static struct sk_buff *
3162 ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u64 module_enable,
3163 u32 log_level)
3165 struct wmi_tlv_dbglog_cmd *cmd;
3166 struct wmi_tlv *tlv;
3167 struct sk_buff *skb;
3168 size_t len, bmap_len;
3169 u32 value;
3170 void *ptr;
3172 if (module_enable) {
3173 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
3174 module_enable,
3175 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE);
3176 } else {
3177 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
3178 WMI_TLV_DBGLOG_ALL_MODULES,
3179 WMI_TLV_DBGLOG_LOG_LEVEL_WARN);
3182 bmap_len = 0;
3183 len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len;
3184 skb = ath10k_wmi_alloc_skb(ar, len);
3185 if (!skb)
3186 return ERR_PTR(-ENOMEM);
3188 ptr = (void *)skb->data;
3190 tlv = ptr;
3191 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD);
3192 tlv->len = __cpu_to_le16(sizeof(*cmd));
3193 cmd = (void *)tlv->value;
3194 cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL);
3195 cmd->value = __cpu_to_le32(value);
3197 ptr += sizeof(*tlv);
3198 ptr += sizeof(*cmd);
3200 tlv = ptr;
3201 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3202 tlv->len = __cpu_to_le16(bmap_len);
3204 /* nothing to do here */
3206 ptr += sizeof(*tlv);
3207 ptr += sizeof(bmap_len);
3209 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value);
3210 return skb;
3213 static struct sk_buff *
3214 ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter)
3216 struct wmi_tlv_pktlog_enable *cmd;
3217 struct wmi_tlv *tlv;
3218 struct sk_buff *skb;
3219 void *ptr;
3220 size_t len;
3222 len = sizeof(*tlv) + sizeof(*cmd);
3223 skb = ath10k_wmi_alloc_skb(ar, len);
3224 if (!skb)
3225 return ERR_PTR(-ENOMEM);
3227 ptr = (void *)skb->data;
3228 tlv = ptr;
3229 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD);
3230 tlv->len = __cpu_to_le16(sizeof(*cmd));
3231 cmd = (void *)tlv->value;
3232 cmd->filter = __cpu_to_le32(filter);
3234 ptr += sizeof(*tlv);
3235 ptr += sizeof(*cmd);
3237 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n",
3238 filter);
3239 return skb;
3242 static struct sk_buff *
3243 ath10k_wmi_tlv_op_gen_pdev_get_temperature(struct ath10k *ar)
3245 struct wmi_tlv_pdev_get_temp_cmd *cmd;
3246 struct wmi_tlv *tlv;
3247 struct sk_buff *skb;
3249 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
3250 if (!skb)
3251 return ERR_PTR(-ENOMEM);
3253 tlv = (void *)skb->data;
3254 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_GET_TEMPERATURE_CMD);
3255 tlv->len = __cpu_to_le16(sizeof(*cmd));
3256 cmd = (void *)tlv->value;
3257 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature tlv\n");
3258 return skb;
3261 static struct sk_buff *
3262 ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar)
3264 struct wmi_tlv_pktlog_disable *cmd;
3265 struct wmi_tlv *tlv;
3266 struct sk_buff *skb;
3267 void *ptr;
3268 size_t len;
3270 len = sizeof(*tlv) + sizeof(*cmd);
3271 skb = ath10k_wmi_alloc_skb(ar, len);
3272 if (!skb)
3273 return ERR_PTR(-ENOMEM);
3275 ptr = (void *)skb->data;
3276 tlv = ptr;
3277 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD);
3278 tlv->len = __cpu_to_le16(sizeof(*cmd));
3279 cmd = (void *)tlv->value;
3281 ptr += sizeof(*tlv);
3282 ptr += sizeof(*cmd);
3284 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n");
3285 return skb;
3288 static struct sk_buff *
3289 ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id,
3290 u32 tim_ie_offset, struct sk_buff *bcn,
3291 u32 prb_caps, u32 prb_erp, void *prb_ies,
3292 size_t prb_ies_len)
3294 struct wmi_tlv_bcn_tmpl_cmd *cmd;
3295 struct wmi_tlv_bcn_prb_info *info;
3296 struct wmi_tlv *tlv;
3297 struct sk_buff *skb;
3298 void *ptr;
3299 size_t len;
3301 if (WARN_ON(prb_ies_len > 0 && !prb_ies))
3302 return ERR_PTR(-EINVAL);
3304 len = sizeof(*tlv) + sizeof(*cmd) +
3305 sizeof(*tlv) + sizeof(*info) + prb_ies_len +
3306 sizeof(*tlv) + roundup(bcn->len, 4);
3307 skb = ath10k_wmi_alloc_skb(ar, len);
3308 if (!skb)
3309 return ERR_PTR(-ENOMEM);
3311 ptr = (void *)skb->data;
3312 tlv = ptr;
3313 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD);
3314 tlv->len = __cpu_to_le16(sizeof(*cmd));
3315 cmd = (void *)tlv->value;
3316 cmd->vdev_id = __cpu_to_le32(vdev_id);
3317 cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset);
3318 cmd->buf_len = __cpu_to_le32(bcn->len);
3320 ptr += sizeof(*tlv);
3321 ptr += sizeof(*cmd);
3323 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
3324 * then it is then impossible to pass original ie len.
3325 * This chunk is not used yet so if setting probe resp template yields
3326 * problems with beaconing or crashes firmware look here.
3328 tlv = ptr;
3329 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
3330 tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len);
3331 info = (void *)tlv->value;
3332 info->caps = __cpu_to_le32(prb_caps);
3333 info->erp = __cpu_to_le32(prb_erp);
3334 memcpy(info->ies, prb_ies, prb_ies_len);
3336 ptr += sizeof(*tlv);
3337 ptr += sizeof(*info);
3338 ptr += prb_ies_len;
3340 tlv = ptr;
3341 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
3342 tlv->len = __cpu_to_le16(roundup(bcn->len, 4));
3343 memcpy(tlv->value, bcn->data, bcn->len);
3345 /* FIXME: Adjust TSF? */
3347 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n",
3348 vdev_id);
3349 return skb;
3352 static struct sk_buff *
3353 ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id,
3354 struct sk_buff *prb)
3356 struct wmi_tlv_prb_tmpl_cmd *cmd;
3357 struct wmi_tlv_bcn_prb_info *info;
3358 struct wmi_tlv *tlv;
3359 struct sk_buff *skb;
3360 void *ptr;
3361 size_t len;
3363 len = sizeof(*tlv) + sizeof(*cmd) +
3364 sizeof(*tlv) + sizeof(*info) +
3365 sizeof(*tlv) + roundup(prb->len, 4);
3366 skb = ath10k_wmi_alloc_skb(ar, len);
3367 if (!skb)
3368 return ERR_PTR(-ENOMEM);
3370 ptr = (void *)skb->data;
3371 tlv = ptr;
3372 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD);
3373 tlv->len = __cpu_to_le16(sizeof(*cmd));
3374 cmd = (void *)tlv->value;
3375 cmd->vdev_id = __cpu_to_le32(vdev_id);
3376 cmd->buf_len = __cpu_to_le32(prb->len);
3378 ptr += sizeof(*tlv);
3379 ptr += sizeof(*cmd);
3381 tlv = ptr;
3382 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
3383 tlv->len = __cpu_to_le16(sizeof(*info));
3384 info = (void *)tlv->value;
3385 info->caps = 0;
3386 info->erp = 0;
3388 ptr += sizeof(*tlv);
3389 ptr += sizeof(*info);
3391 tlv = ptr;
3392 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
3393 tlv->len = __cpu_to_le16(roundup(prb->len, 4));
3394 memcpy(tlv->value, prb->data, prb->len);
3396 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n",
3397 vdev_id);
3398 return skb;
3401 static struct sk_buff *
3402 ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
3403 const u8 *p2p_ie)
3405 struct wmi_tlv_p2p_go_bcn_ie *cmd;
3406 struct wmi_tlv *tlv;
3407 struct sk_buff *skb;
3408 void *ptr;
3409 size_t len;
3411 len = sizeof(*tlv) + sizeof(*cmd) +
3412 sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4);
3413 skb = ath10k_wmi_alloc_skb(ar, len);
3414 if (!skb)
3415 return ERR_PTR(-ENOMEM);
3417 ptr = (void *)skb->data;
3418 tlv = ptr;
3419 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE);
3420 tlv->len = __cpu_to_le16(sizeof(*cmd));
3421 cmd = (void *)tlv->value;
3422 cmd->vdev_id = __cpu_to_le32(vdev_id);
3423 cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2);
3425 ptr += sizeof(*tlv);
3426 ptr += sizeof(*cmd);
3428 tlv = ptr;
3429 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
3430 tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4));
3431 memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2);
3433 ptr += sizeof(*tlv);
3434 ptr += roundup(p2p_ie[1] + 2, 4);
3436 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n",
3437 vdev_id);
3438 return skb;
3441 static struct sk_buff *
3442 ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
3443 enum wmi_tdls_state state)
3445 struct wmi_tdls_set_state_cmd *cmd;
3446 struct wmi_tlv *tlv;
3447 struct sk_buff *skb;
3448 void *ptr;
3449 size_t len;
3450 /* Set to options from wmi_tlv_tdls_options,
3451 * for now none of them are enabled.
3453 u32 options = 0;
3455 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA, ar->wmi.svc_map))
3456 options |= WMI_TLV_TDLS_BUFFER_STA_EN;
3458 /* WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL means firm will handle TDLS
3459 * link inactivity detecting logic.
3461 if (state == WMI_TDLS_ENABLE_ACTIVE)
3462 state = WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL;
3464 len = sizeof(*tlv) + sizeof(*cmd);
3465 skb = ath10k_wmi_alloc_skb(ar, len);
3466 if (!skb)
3467 return ERR_PTR(-ENOMEM);
3469 ptr = (void *)skb->data;
3470 tlv = ptr;
3471 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD);
3472 tlv->len = __cpu_to_le16(sizeof(*cmd));
3474 cmd = (void *)tlv->value;
3475 cmd->vdev_id = __cpu_to_le32(vdev_id);
3476 cmd->state = __cpu_to_le32(state);
3477 cmd->notification_interval_ms = __cpu_to_le32(5000);
3478 cmd->tx_discovery_threshold = __cpu_to_le32(100);
3479 cmd->tx_teardown_threshold = __cpu_to_le32(5);
3480 cmd->rssi_teardown_threshold = __cpu_to_le32(-75);
3481 cmd->rssi_delta = __cpu_to_le32(-20);
3482 cmd->tdls_options = __cpu_to_le32(options);
3483 cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2);
3484 cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000);
3485 cmd->tdls_puapsd_mask = __cpu_to_le32(0xf);
3486 cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0);
3487 cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10);
3489 ptr += sizeof(*tlv);
3490 ptr += sizeof(*cmd);
3492 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv update fw tdls state %d for vdev %i\n",
3493 state, vdev_id);
3494 return skb;
3497 static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
3499 u32 peer_qos = 0;
3501 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
3502 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VO;
3503 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
3504 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VI;
3505 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
3506 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BK;
3507 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
3508 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BE;
3510 peer_qos |= SM(sp, WMI_TLV_TDLS_PEER_SP);
3512 return peer_qos;
3515 static struct sk_buff *
3516 ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k *ar,
3517 const struct wmi_tdls_peer_update_cmd_arg *arg,
3518 const struct wmi_tdls_peer_capab_arg *cap,
3519 const struct wmi_channel_arg *chan_arg)
3521 struct wmi_tdls_peer_update_cmd *cmd;
3522 struct wmi_tdls_peer_capab *peer_cap;
3523 struct wmi_channel *chan;
3524 struct wmi_tlv *tlv;
3525 struct sk_buff *skb;
3526 u32 peer_qos;
3527 void *ptr;
3528 int len;
3529 int i;
3531 len = sizeof(*tlv) + sizeof(*cmd) +
3532 sizeof(*tlv) + sizeof(*peer_cap) +
3533 sizeof(*tlv) + cap->peer_chan_len * sizeof(*chan);
3535 skb = ath10k_wmi_alloc_skb(ar, len);
3536 if (!skb)
3537 return ERR_PTR(-ENOMEM);
3539 ptr = (void *)skb->data;
3540 tlv = ptr;
3541 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD);
3542 tlv->len = __cpu_to_le16(sizeof(*cmd));
3544 cmd = (void *)tlv->value;
3545 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
3546 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
3547 cmd->peer_state = __cpu_to_le32(arg->peer_state);
3549 ptr += sizeof(*tlv);
3550 ptr += sizeof(*cmd);
3552 tlv = ptr;
3553 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES);
3554 tlv->len = __cpu_to_le16(sizeof(*peer_cap));
3555 peer_cap = (void *)tlv->value;
3556 peer_qos = ath10k_wmi_tlv_prepare_peer_qos(cap->peer_uapsd_queues,
3557 cap->peer_max_sp);
3558 peer_cap->peer_qos = __cpu_to_le32(peer_qos);
3559 peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support);
3560 peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support);
3561 peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass);
3562 peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass);
3563 peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len);
3564 peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len);
3566 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++)
3567 peer_cap->peer_operclass[i] = cap->peer_operclass[i];
3569 peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder);
3570 peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num);
3571 peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw);
3573 ptr += sizeof(*tlv);
3574 ptr += sizeof(*peer_cap);
3576 tlv = ptr;
3577 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3578 tlv->len = __cpu_to_le16(cap->peer_chan_len * sizeof(*chan));
3580 ptr += sizeof(*tlv);
3582 for (i = 0; i < cap->peer_chan_len; i++) {
3583 tlv = ptr;
3584 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
3585 tlv->len = __cpu_to_le16(sizeof(*chan));
3586 chan = (void *)tlv->value;
3587 ath10k_wmi_put_wmi_channel(ar, chan, &chan_arg[i]);
3589 ptr += sizeof(*tlv);
3590 ptr += sizeof(*chan);
3593 ath10k_dbg(ar, ATH10K_DBG_WMI,
3594 "wmi tlv tdls peer update vdev %i state %d n_chans %u\n",
3595 arg->vdev_id, arg->peer_state, cap->peer_chan_len);
3596 return skb;
3599 static struct sk_buff *
3600 ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
3601 u32 duration, u32 next_offset,
3602 u32 enabled)
3604 struct wmi_tlv_set_quiet_cmd *cmd;
3605 struct wmi_tlv *tlv;
3606 struct sk_buff *skb;
3608 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
3609 if (!skb)
3610 return ERR_PTR(-ENOMEM);
3612 tlv = (void *)skb->data;
3613 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_QUIET_CMD);
3614 tlv->len = __cpu_to_le16(sizeof(*cmd));
3615 cmd = (void *)tlv->value;
3617 /* vdev_id is not in use, set to 0 */
3618 cmd->vdev_id = __cpu_to_le32(0);
3619 cmd->period = __cpu_to_le32(period);
3620 cmd->duration = __cpu_to_le32(duration);
3621 cmd->next_start = __cpu_to_le32(next_offset);
3622 cmd->enabled = __cpu_to_le32(enabled);
3624 ath10k_dbg(ar, ATH10K_DBG_WMI,
3625 "wmi tlv quiet param: period %u duration %u enabled %d\n",
3626 period, duration, enabled);
3627 return skb;
3630 static struct sk_buff *
3631 ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar)
3633 struct wmi_tlv_wow_enable_cmd *cmd;
3634 struct wmi_tlv *tlv;
3635 struct sk_buff *skb;
3636 size_t len;
3638 len = sizeof(*tlv) + sizeof(*cmd);
3639 skb = ath10k_wmi_alloc_skb(ar, len);
3640 if (!skb)
3641 return ERR_PTR(-ENOMEM);
3643 tlv = (struct wmi_tlv *)skb->data;
3644 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD);
3645 tlv->len = __cpu_to_le16(sizeof(*cmd));
3646 cmd = (void *)tlv->value;
3648 cmd->enable = __cpu_to_le32(1);
3649 if (!ar->bus_param.link_can_suspend)
3650 cmd->pause_iface_config = __cpu_to_le32(WOW_IFACE_PAUSE_DISABLED);
3652 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n");
3653 return skb;
3656 static struct sk_buff *
3657 ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,
3658 u32 vdev_id,
3659 enum wmi_wow_wakeup_event event,
3660 u32 enable)
3662 struct wmi_tlv_wow_add_del_event_cmd *cmd;
3663 struct wmi_tlv *tlv;
3664 struct sk_buff *skb;
3665 size_t len;
3667 len = sizeof(*tlv) + sizeof(*cmd);
3668 skb = ath10k_wmi_alloc_skb(ar, len);
3669 if (!skb)
3670 return ERR_PTR(-ENOMEM);
3672 tlv = (struct wmi_tlv *)skb->data;
3673 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD);
3674 tlv->len = __cpu_to_le16(sizeof(*cmd));
3675 cmd = (void *)tlv->value;
3677 cmd->vdev_id = __cpu_to_le32(vdev_id);
3678 cmd->is_add = __cpu_to_le32(enable);
3679 cmd->event_bitmap = __cpu_to_le32(1 << event);
3681 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
3682 wow_wakeup_event(event), enable, vdev_id);
3683 return skb;
3686 static struct sk_buff *
3687 ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar)
3689 struct wmi_tlv_wow_host_wakeup_ind *cmd;
3690 struct wmi_tlv *tlv;
3691 struct sk_buff *skb;
3692 size_t len;
3694 len = sizeof(*tlv) + sizeof(*cmd);
3695 skb = ath10k_wmi_alloc_skb(ar, len);
3696 if (!skb)
3697 return ERR_PTR(-ENOMEM);
3699 tlv = (struct wmi_tlv *)skb->data;
3700 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
3701 tlv->len = __cpu_to_le16(sizeof(*cmd));
3702 cmd = (void *)tlv->value;
3704 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
3705 return skb;
3708 static struct sk_buff *
3709 ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k *ar, u32 vdev_id,
3710 u32 pattern_id, const u8 *pattern,
3711 const u8 *bitmask, int pattern_len,
3712 int pattern_offset)
3714 struct wmi_tlv_wow_add_pattern_cmd *cmd;
3715 struct wmi_tlv_wow_bitmap_pattern *bitmap;
3716 struct wmi_tlv *tlv;
3717 struct sk_buff *skb;
3718 void *ptr;
3719 size_t len;
3721 len = sizeof(*tlv) + sizeof(*cmd) +
3722 sizeof(*tlv) + /* array struct */
3723 sizeof(*tlv) + sizeof(*bitmap) + /* bitmap */
3724 sizeof(*tlv) + /* empty ipv4 sync */
3725 sizeof(*tlv) + /* empty ipv6 sync */
3726 sizeof(*tlv) + /* empty magic */
3727 sizeof(*tlv) + /* empty info timeout */
3728 sizeof(*tlv) + sizeof(u32); /* ratelimit interval */
3730 skb = ath10k_wmi_alloc_skb(ar, len);
3731 if (!skb)
3732 return ERR_PTR(-ENOMEM);
3734 /* cmd */
3735 ptr = (void *)skb->data;
3736 tlv = ptr;
3737 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD);
3738 tlv->len = __cpu_to_le16(sizeof(*cmd));
3739 cmd = (void *)tlv->value;
3741 cmd->vdev_id = __cpu_to_le32(vdev_id);
3742 cmd->pattern_id = __cpu_to_le32(pattern_id);
3743 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
3745 ptr += sizeof(*tlv);
3746 ptr += sizeof(*cmd);
3748 /* bitmap */
3749 tlv = ptr;
3750 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3751 tlv->len = __cpu_to_le16(sizeof(*tlv) + sizeof(*bitmap));
3753 ptr += sizeof(*tlv);
3755 tlv = ptr;
3756 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T);
3757 tlv->len = __cpu_to_le16(sizeof(*bitmap));
3758 bitmap = (void *)tlv->value;
3760 memcpy(bitmap->patternbuf, pattern, pattern_len);
3761 memcpy(bitmap->bitmaskbuf, bitmask, pattern_len);
3762 bitmap->pattern_offset = __cpu_to_le32(pattern_offset);
3763 bitmap->pattern_len = __cpu_to_le32(pattern_len);
3764 bitmap->bitmask_len = __cpu_to_le32(pattern_len);
3765 bitmap->pattern_id = __cpu_to_le32(pattern_id);
3767 ptr += sizeof(*tlv);
3768 ptr += sizeof(*bitmap);
3770 /* ipv4 sync */
3771 tlv = ptr;
3772 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3773 tlv->len = __cpu_to_le16(0);
3775 ptr += sizeof(*tlv);
3777 /* ipv6 sync */
3778 tlv = ptr;
3779 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3780 tlv->len = __cpu_to_le16(0);
3782 ptr += sizeof(*tlv);
3784 /* magic */
3785 tlv = ptr;
3786 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3787 tlv->len = __cpu_to_le16(0);
3789 ptr += sizeof(*tlv);
3791 /* pattern info timeout */
3792 tlv = ptr;
3793 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3794 tlv->len = __cpu_to_le16(0);
3796 ptr += sizeof(*tlv);
3798 /* ratelimit interval */
3799 tlv = ptr;
3800 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3801 tlv->len = __cpu_to_le16(sizeof(u32));
3803 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n",
3804 vdev_id, pattern_id, pattern_offset);
3805 return skb;
3808 static struct sk_buff *
3809 ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k *ar, u32 vdev_id,
3810 u32 pattern_id)
3812 struct wmi_tlv_wow_del_pattern_cmd *cmd;
3813 struct wmi_tlv *tlv;
3814 struct sk_buff *skb;
3815 size_t len;
3817 len = sizeof(*tlv) + sizeof(*cmd);
3818 skb = ath10k_wmi_alloc_skb(ar, len);
3819 if (!skb)
3820 return ERR_PTR(-ENOMEM);
3822 tlv = (struct wmi_tlv *)skb->data;
3823 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD);
3824 tlv->len = __cpu_to_le16(sizeof(*cmd));
3825 cmd = (void *)tlv->value;
3827 cmd->vdev_id = __cpu_to_le32(vdev_id);
3828 cmd->pattern_id = __cpu_to_le32(pattern_id);
3829 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
3831 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n",
3832 vdev_id, pattern_id);
3833 return skb;
3836 /* Request FW to start PNO operation */
3837 static struct sk_buff *
3838 ath10k_wmi_tlv_op_gen_config_pno_start(struct ath10k *ar,
3839 u32 vdev_id,
3840 struct wmi_pno_scan_req *pno)
3842 struct nlo_configured_parameters *nlo_list;
3843 struct wmi_tlv_wow_nlo_config_cmd *cmd;
3844 struct wmi_tlv *tlv;
3845 struct sk_buff *skb;
3846 __le32 *channel_list;
3847 u16 tlv_len;
3848 size_t len;
3849 void *ptr;
3850 u32 i;
3852 len = sizeof(*tlv) + sizeof(*cmd) +
3853 sizeof(*tlv) +
3854 /* TLV place holder for array of structures
3855 * nlo_configured_parameters(nlo_list)
3857 sizeof(*tlv);
3858 /* TLV place holder for array of uint32 channel_list */
3860 len += sizeof(u32) * min_t(u8, pno->a_networks[0].channel_count,
3861 WMI_NLO_MAX_CHAN);
3862 len += sizeof(struct nlo_configured_parameters) *
3863 min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS);
3865 skb = ath10k_wmi_alloc_skb(ar, len);
3866 if (!skb)
3867 return ERR_PTR(-ENOMEM);
3869 ptr = (void *)skb->data;
3870 tlv = ptr;
3871 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD);
3872 tlv->len = __cpu_to_le16(sizeof(*cmd));
3873 cmd = (void *)tlv->value;
3875 /* wmi_tlv_wow_nlo_config_cmd parameters*/
3876 cmd->vdev_id = __cpu_to_le32(pno->vdev_id);
3877 cmd->flags = __cpu_to_le32(WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN);
3879 /* current FW does not support min-max range for dwell time */
3880 cmd->active_dwell_time = __cpu_to_le32(pno->active_max_time);
3881 cmd->passive_dwell_time = __cpu_to_le32(pno->passive_max_time);
3883 if (pno->do_passive_scan)
3884 cmd->flags |= __cpu_to_le32(WMI_NLO_CONFIG_SCAN_PASSIVE);
3886 /* copy scan interval */
3887 cmd->fast_scan_period = __cpu_to_le32(pno->fast_scan_period);
3888 cmd->slow_scan_period = __cpu_to_le32(pno->slow_scan_period);
3889 cmd->fast_scan_max_cycles = __cpu_to_le32(pno->fast_scan_max_cycles);
3890 cmd->delay_start_time = __cpu_to_le32(pno->delay_start_time);
3892 if (pno->enable_pno_scan_randomization) {
3893 cmd->flags |= __cpu_to_le32(WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
3894 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ);
3895 ether_addr_copy(cmd->mac_addr.addr, pno->mac_addr);
3896 ether_addr_copy(cmd->mac_mask.addr, pno->mac_addr_mask);
3899 ptr += sizeof(*tlv);
3900 ptr += sizeof(*cmd);
3902 /* nlo_configured_parameters(nlo_list) */
3903 cmd->no_of_ssids = __cpu_to_le32(min_t(u8, pno->uc_networks_count,
3904 WMI_NLO_MAX_SSIDS));
3905 tlv_len = __le32_to_cpu(cmd->no_of_ssids) *
3906 sizeof(struct nlo_configured_parameters);
3908 tlv = ptr;
3909 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3910 tlv->len = __cpu_to_le16(tlv_len);
3912 ptr += sizeof(*tlv);
3913 nlo_list = ptr;
3914 for (i = 0; i < __le32_to_cpu(cmd->no_of_ssids); i++) {
3915 tlv = (struct wmi_tlv *)(&nlo_list[i].tlv_header);
3916 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
3917 tlv->len = __cpu_to_le16(sizeof(struct nlo_configured_parameters) -
3918 sizeof(*tlv));
3920 /* copy ssid and it's length */
3921 nlo_list[i].ssid.valid = __cpu_to_le32(true);
3922 nlo_list[i].ssid.ssid.ssid_len = pno->a_networks[i].ssid.ssid_len;
3923 memcpy(nlo_list[i].ssid.ssid.ssid,
3924 pno->a_networks[i].ssid.ssid,
3925 __le32_to_cpu(nlo_list[i].ssid.ssid.ssid_len));
3927 /* copy rssi threshold */
3928 if (pno->a_networks[i].rssi_threshold &&
3929 pno->a_networks[i].rssi_threshold > -300) {
3930 nlo_list[i].rssi_cond.valid = __cpu_to_le32(true);
3931 nlo_list[i].rssi_cond.rssi =
3932 __cpu_to_le32(pno->a_networks[i].rssi_threshold);
3935 nlo_list[i].bcast_nw_type.valid = __cpu_to_le32(true);
3936 nlo_list[i].bcast_nw_type.bcast_nw_type =
3937 __cpu_to_le32(pno->a_networks[i].bcast_nw_type);
3940 ptr += __le32_to_cpu(cmd->no_of_ssids) * sizeof(struct nlo_configured_parameters);
3942 /* copy channel info */
3943 cmd->num_of_channels = __cpu_to_le32(min_t(u8,
3944 pno->a_networks[0].channel_count,
3945 WMI_NLO_MAX_CHAN));
3947 tlv = ptr;
3948 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3949 tlv->len = __cpu_to_le16(__le32_to_cpu(cmd->num_of_channels) *
3950 sizeof(u_int32_t));
3951 ptr += sizeof(*tlv);
3953 channel_list = (__le32 *)ptr;
3954 for (i = 0; i < __le32_to_cpu(cmd->num_of_channels); i++)
3955 channel_list[i] = __cpu_to_le32(pno->a_networks[0].channels[i]);
3957 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start pno config vdev_id %d\n",
3958 vdev_id);
3960 return skb;
3963 /* Request FW to stop ongoing PNO operation */
3964 static struct sk_buff *ath10k_wmi_tlv_op_gen_config_pno_stop(struct ath10k *ar,
3965 u32 vdev_id)
3967 struct wmi_tlv_wow_nlo_config_cmd *cmd;
3968 struct wmi_tlv *tlv;
3969 struct sk_buff *skb;
3970 void *ptr;
3971 size_t len;
3973 len = sizeof(*tlv) + sizeof(*cmd) +
3974 sizeof(*tlv) +
3975 /* TLV place holder for array of structures
3976 * nlo_configured_parameters(nlo_list)
3978 sizeof(*tlv);
3979 /* TLV place holder for array of uint32 channel_list */
3980 skb = ath10k_wmi_alloc_skb(ar, len);
3981 if (!skb)
3982 return ERR_PTR(-ENOMEM);
3984 ptr = (void *)skb->data;
3985 tlv = ptr;
3986 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD);
3987 tlv->len = __cpu_to_le16(sizeof(*cmd));
3988 cmd = (void *)tlv->value;
3990 cmd->vdev_id = __cpu_to_le32(vdev_id);
3991 cmd->flags = __cpu_to_le32(WMI_NLO_CONFIG_STOP);
3993 ptr += sizeof(*tlv);
3994 ptr += sizeof(*cmd);
3996 /* nlo_configured_parameters(nlo_list) */
3997 tlv = ptr;
3998 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3999 tlv->len = __cpu_to_le16(0);
4001 ptr += sizeof(*tlv);
4003 /* channel list */
4004 tlv = ptr;
4005 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
4006 tlv->len = __cpu_to_le16(0);
4008 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop pno config vdev_id %d\n", vdev_id);
4009 return skb;
4012 static struct sk_buff *
4013 ath10k_wmi_tlv_op_gen_config_pno(struct ath10k *ar, u32 vdev_id,
4014 struct wmi_pno_scan_req *pno_scan)
4016 if (pno_scan->enable)
4017 return ath10k_wmi_tlv_op_gen_config_pno_start(ar, vdev_id, pno_scan);
4018 else
4019 return ath10k_wmi_tlv_op_gen_config_pno_stop(ar, vdev_id);
4022 static struct sk_buff *
4023 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable)
4025 struct wmi_tlv_adaptive_qcs *cmd;
4026 struct wmi_tlv *tlv;
4027 struct sk_buff *skb;
4028 void *ptr;
4029 size_t len;
4031 len = sizeof(*tlv) + sizeof(*cmd);
4032 skb = ath10k_wmi_alloc_skb(ar, len);
4033 if (!skb)
4034 return ERR_PTR(-ENOMEM);
4036 ptr = (void *)skb->data;
4037 tlv = ptr;
4038 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD);
4039 tlv->len = __cpu_to_le16(sizeof(*cmd));
4040 cmd = (void *)tlv->value;
4041 cmd->enable = __cpu_to_le32(enable ? 1 : 0);
4043 ptr += sizeof(*tlv);
4044 ptr += sizeof(*cmd);
4046 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv adaptive qcs %d\n", enable);
4047 return skb;
4050 static struct sk_buff *
4051 ath10k_wmi_tlv_op_gen_echo(struct ath10k *ar, u32 value)
4053 struct wmi_echo_cmd *cmd;
4054 struct wmi_tlv *tlv;
4055 struct sk_buff *skb;
4056 void *ptr;
4057 size_t len;
4059 len = sizeof(*tlv) + sizeof(*cmd);
4060 skb = ath10k_wmi_alloc_skb(ar, len);
4061 if (!skb)
4062 return ERR_PTR(-ENOMEM);
4064 ptr = (void *)skb->data;
4065 tlv = ptr;
4066 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_ECHO_CMD);
4067 tlv->len = __cpu_to_le16(sizeof(*cmd));
4068 cmd = (void *)tlv->value;
4069 cmd->value = cpu_to_le32(value);
4071 ptr += sizeof(*tlv);
4072 ptr += sizeof(*cmd);
4074 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv echo value 0x%08x\n", value);
4075 return skb;
4078 static struct sk_buff *
4079 ath10k_wmi_tlv_op_gen_vdev_spectral_conf(struct ath10k *ar,
4080 const struct wmi_vdev_spectral_conf_arg *arg)
4082 struct wmi_vdev_spectral_conf_cmd *cmd;
4083 struct sk_buff *skb;
4084 struct wmi_tlv *tlv;
4085 void *ptr;
4086 size_t len;
4088 len = sizeof(*tlv) + sizeof(*cmd);
4089 skb = ath10k_wmi_alloc_skb(ar, len);
4090 if (!skb)
4091 return ERR_PTR(-ENOMEM);
4093 ptr = (void *)skb->data;
4094 tlv = ptr;
4095 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_CONFIGURE_CMD);
4096 tlv->len = __cpu_to_le16(sizeof(*cmd));
4097 cmd = (void *)tlv->value;
4098 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
4099 cmd->scan_count = __cpu_to_le32(arg->scan_count);
4100 cmd->scan_period = __cpu_to_le32(arg->scan_period);
4101 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
4102 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
4103 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
4104 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
4105 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
4106 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
4107 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
4108 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
4109 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
4110 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
4111 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
4112 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
4113 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
4114 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
4115 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
4116 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
4118 return skb;
4121 static struct sk_buff *
4122 ath10k_wmi_tlv_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
4123 u32 trigger, u32 enable)
4125 struct wmi_vdev_spectral_enable_cmd *cmd;
4126 struct sk_buff *skb;
4127 struct wmi_tlv *tlv;
4128 void *ptr;
4129 size_t len;
4131 len = sizeof(*tlv) + sizeof(*cmd);
4132 skb = ath10k_wmi_alloc_skb(ar, len);
4133 if (!skb)
4134 return ERR_PTR(-ENOMEM);
4136 ptr = (void *)skb->data;
4137 tlv = ptr;
4138 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_ENABLE_CMD);
4139 tlv->len = __cpu_to_le16(sizeof(*cmd));
4140 cmd = (void *)tlv->value;
4141 cmd->vdev_id = __cpu_to_le32(vdev_id);
4142 cmd->trigger_cmd = __cpu_to_le32(trigger);
4143 cmd->enable_cmd = __cpu_to_le32(enable);
4145 return skb;
4148 /****************/
4149 /* TLV mappings */
4150 /****************/
4152 static struct wmi_cmd_map wmi_tlv_cmd_map = {
4153 .init_cmdid = WMI_TLV_INIT_CMDID,
4154 .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID,
4155 .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID,
4156 .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID,
4157 .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID,
4158 .scan_prob_req_oui_cmdid = WMI_TLV_SCAN_PROB_REQ_OUI_CMDID,
4159 .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID,
4160 .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID,
4161 .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID,
4162 .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID,
4163 .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID,
4164 .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID,
4165 .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID,
4166 .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID,
4167 .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID,
4168 .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID,
4169 .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID,
4170 .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID,
4171 .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID,
4172 .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID,
4173 .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID,
4174 .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID,
4175 .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID,
4176 .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID,
4177 .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID,
4178 .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID,
4179 .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID,
4180 .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID,
4181 .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID,
4182 .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID,
4183 .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID,
4184 .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID,
4185 .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID,
4186 .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID,
4187 .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID,
4188 .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID,
4189 .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID,
4190 .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID,
4191 .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID,
4192 .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID,
4193 .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID,
4194 .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID,
4195 .mgmt_tx_send_cmdid = WMI_TLV_MGMT_TX_SEND_CMD,
4196 .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID,
4197 .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID,
4198 .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID,
4199 .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID,
4200 .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID,
4201 .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID,
4202 .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID,
4203 .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID,
4204 .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID,
4205 .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID,
4206 .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID,
4207 .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID,
4208 .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE,
4209 .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD,
4210 .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD,
4211 .roam_scan_rssi_change_threshold =
4212 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
4213 .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
4214 .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
4215 .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE,
4216 .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD,
4217 .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO,
4218 .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY,
4219 .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE,
4220 .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE,
4221 .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID,
4222 .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID,
4223 .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID,
4224 .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID,
4225 .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID,
4226 .wlan_profile_set_hist_intvl_cmdid =
4227 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
4228 .wlan_profile_get_profile_data_cmdid =
4229 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
4230 .wlan_profile_enable_profile_id_cmdid =
4231 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
4232 .wlan_profile_list_profile_id_cmdid =
4233 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
4234 .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID,
4235 .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID,
4236 .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID,
4237 .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID,
4238 .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID,
4239 .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID,
4240 .wow_enable_disable_wake_event_cmdid =
4241 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
4242 .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID,
4243 .wow_hostwakeup_from_sleep_cmdid =
4244 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
4245 .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID,
4246 .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID,
4247 .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,
4248 .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID,
4249 .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID,
4250 .request_peer_stats_info_cmdid = WMI_TLV_REQUEST_PEER_STATS_INFO_CMDID,
4251 .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID,
4252 .network_list_offload_config_cmdid =
4253 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
4254 .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID,
4255 .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID,
4256 .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID,
4257 .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID,
4258 .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID,
4259 .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID,
4260 .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID,
4261 .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID,
4262 .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID,
4263 .echo_cmdid = WMI_TLV_ECHO_CMDID,
4264 .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID,
4265 .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID,
4266 .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID,
4267 .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID,
4268 .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID,
4269 .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID,
4270 .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID,
4271 .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID,
4272 .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID,
4273 .pdev_get_temperature_cmdid = WMI_TLV_PDEV_GET_TEMPERATURE_CMDID,
4274 .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID,
4275 .tdls_set_state_cmdid = WMI_TLV_TDLS_SET_STATE_CMDID,
4276 .tdls_peer_update_cmdid = WMI_TLV_TDLS_PEER_UPDATE_CMDID,
4277 .adaptive_qcs_cmdid = WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID,
4278 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
4279 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
4280 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
4281 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
4282 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
4283 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
4284 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
4285 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
4286 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
4287 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
4288 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
4289 .nan_cmdid = WMI_CMD_UNSUPPORTED,
4290 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
4291 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
4292 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
4293 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
4294 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
4295 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
4296 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
4297 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
4298 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
4299 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
4300 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
4301 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
4302 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
4303 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
4304 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
4305 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
4306 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
4307 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
4308 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
4309 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
4312 static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = {
4313 .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK,
4314 .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK,
4315 .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G,
4316 .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G,
4317 .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE,
4318 .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE,
4319 .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE,
4320 .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
4321 .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE,
4322 .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW,
4323 .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
4324 .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH,
4325 .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH,
4326 .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING,
4327 .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE,
4328 .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE,
4329 .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK,
4330 .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI,
4331 .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO,
4332 .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
4333 .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
4334 .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE,
4335 .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
4336 .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE,
4337 .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE,
4338 .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
4339 .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
4340 .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
4341 .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
4342 .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
4343 .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
4344 .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
4345 .bcnflt_stats_update_period =
4346 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
4347 .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS,
4348 .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE,
4349 .dcs = WMI_TLV_PDEV_PARAM_DCS,
4350 .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE,
4351 .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD,
4352 .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD,
4353 .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL,
4354 .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL,
4355 .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN,
4356 .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA,
4357 .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG,
4358 .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP,
4359 .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED,
4360 .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR,
4361 .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE,
4362 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
4363 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
4364 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
4365 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
4366 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
4367 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
4368 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
4369 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
4370 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
4371 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
4372 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
4373 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
4374 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
4375 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
4376 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
4377 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
4378 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4379 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4380 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4381 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4382 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4383 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
4384 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
4385 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
4386 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
4387 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
4388 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
4389 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
4390 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
4391 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
4392 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
4393 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
4394 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
4395 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
4396 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
4397 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
4398 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
4399 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
4400 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
4401 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
4402 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
4403 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
4404 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
4405 .rfkill_config = WMI_TLV_PDEV_PARAM_HW_RFKILL_CONFIG,
4406 .rfkill_enable = WMI_TLV_PDEV_PARAM_RFKILL_ENABLE,
4407 .peer_stats_info_enable = WMI_TLV_PDEV_PARAM_PEER_STATS_INFO_ENABLE,
4410 static struct wmi_peer_param_map wmi_tlv_peer_param_map = {
4411 .smps_state = WMI_TLV_PEER_SMPS_STATE,
4412 .ampdu = WMI_TLV_PEER_AMPDU,
4413 .authorize = WMI_TLV_PEER_AUTHORIZE,
4414 .chan_width = WMI_TLV_PEER_CHAN_WIDTH,
4415 .nss = WMI_TLV_PEER_NSS,
4416 .use_4addr = WMI_TLV_PEER_USE_4ADDR,
4417 .membership = WMI_TLV_PEER_MEMBERSHIP,
4418 .user_pos = WMI_TLV_PEER_USERPOS,
4419 .crit_proto_hint_enabled = WMI_TLV_PEER_CRIT_PROTO_HINT_ENABLED,
4420 .tx_fail_cnt_thr = WMI_TLV_PEER_TX_FAIL_CNT_THR,
4421 .set_hw_retry_cts2s = WMI_TLV_PEER_SET_HW_RETRY_CTS2S,
4422 .ibss_atim_win_len = WMI_TLV_PEER_IBSS_ATIM_WINDOW_LENGTH,
4423 .phymode = WMI_TLV_PEER_PHYMODE,
4424 .use_fixed_power = WMI_TLV_PEER_USE_FIXED_PWR,
4425 .dummy_var = WMI_TLV_PEER_DUMMY_VAR,
4428 static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = {
4429 .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD,
4430 .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
4431 .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL,
4432 .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL,
4433 .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE,
4434 .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE,
4435 .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME,
4436 .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE,
4437 .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME,
4438 .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD,
4439 .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME,
4440 .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL,
4441 .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD,
4442 .wmi_vdev_oc_scheduler_air_time_limit =
4443 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
4444 .wds = WMI_TLV_VDEV_PARAM_WDS,
4445 .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW,
4446 .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX,
4447 .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT,
4448 .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT,
4449 .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM,
4450 .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH,
4451 .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET,
4452 .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION,
4453 .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT,
4454 .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE,
4455 .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE,
4456 .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE,
4457 .sgi = WMI_TLV_VDEV_PARAM_SGI,
4458 .ldpc = WMI_TLV_VDEV_PARAM_LDPC,
4459 .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC,
4460 .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC,
4461 .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD,
4462 .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID,
4463 .nss = WMI_TLV_VDEV_PARAM_NSS,
4464 .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE,
4465 .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE,
4466 .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE,
4467 .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE,
4468 .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
4469 .ap_keepalive_min_idle_inactive_time_secs =
4470 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
4471 .ap_keepalive_max_idle_inactive_time_secs =
4472 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
4473 .ap_keepalive_max_unresponsive_time_secs =
4474 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
4475 .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS,
4476 .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED,
4477 .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS,
4478 .txbf = WMI_TLV_VDEV_PARAM_TXBF,
4479 .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE,
4480 .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY,
4481 .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE,
4482 .ap_detect_out_of_sync_sleeping_sta_time_secs =
4483 WMI_TLV_VDEV_PARAM_UNSUPPORTED,
4484 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
4485 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
4486 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
4487 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
4488 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
4489 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
4490 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
4491 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
4492 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
4493 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
4494 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
4495 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
4496 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
4497 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
4498 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
4499 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
4502 static const struct wmi_ops wmi_tlv_ops = {
4503 .rx = ath10k_wmi_tlv_op_rx,
4504 .map_svc = wmi_tlv_svc_map,
4505 .map_svc_ext = wmi_tlv_svc_map_ext,
4507 .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev,
4508 .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev,
4509 .pull_mgmt_tx_compl = ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev,
4510 .pull_mgmt_tx_bundle_compl = ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev,
4511 .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev,
4512 .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev,
4513 .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev,
4514 .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev,
4515 .pull_phyerr_hdr = ath10k_wmi_tlv_op_pull_phyerr_ev_hdr,
4516 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
4517 .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev,
4518 .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
4519 .pull_svc_avail = ath10k_wmi_tlv_op_pull_svc_avail,
4520 .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
4521 .pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev,
4522 .pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev,
4523 .pull_echo_ev = ath10k_wmi_tlv_op_pull_echo_ev,
4524 .get_txbf_conf_scheme = ath10k_wmi_tlv_txbf_conf_scheme,
4526 .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
4527 .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
4528 .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
4529 .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
4530 .gen_init = ath10k_wmi_tlv_op_gen_init,
4531 .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
4532 .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
4533 .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create,
4534 .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete,
4535 .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start,
4536 .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop,
4537 .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up,
4538 .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down,
4539 .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param,
4540 .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key,
4541 .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf,
4542 .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create,
4543 .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete,
4544 .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush,
4545 .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param,
4546 .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc,
4547 .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode,
4548 .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps,
4549 .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps,
4550 .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list,
4551 .gen_scan_prob_req_oui = ath10k_wmi_tlv_op_gen_scan_prob_req_oui,
4552 .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma,
4553 .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm,
4554 .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats,
4555 .gen_request_peer_stats_info = ath10k_wmi_tlv_op_gen_request_peer_stats_info,
4556 .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang,
4557 /* .gen_mgmt_tx = not implemented; HTT is used */
4558 .gen_mgmt_tx_send = ath10k_wmi_tlv_op_gen_mgmt_tx_send,
4559 .cleanup_mgmt_tx_send = ath10k_wmi_tlv_op_cleanup_mgmt_tx_send,
4560 .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg,
4561 .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable,
4562 .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable,
4563 .gen_pdev_set_quiet_mode = ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode,
4564 .gen_pdev_get_temperature = ath10k_wmi_tlv_op_gen_pdev_get_temperature,
4565 /* .gen_addba_clear_resp not implemented */
4566 /* .gen_addba_send not implemented */
4567 /* .gen_addba_set_resp not implemented */
4568 /* .gen_delba_send not implemented */
4569 .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl,
4570 .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl,
4571 .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
4572 .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
4573 .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
4574 .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable,
4575 .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event,
4576 .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
4577 .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern,
4578 .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern,
4579 .gen_wow_config_pno = ath10k_wmi_tlv_op_gen_config_pno,
4580 .gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state,
4581 .gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update,
4582 .gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs,
4583 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
4584 .get_vdev_subtype = ath10k_wmi_tlv_op_get_vdev_subtype,
4585 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
4586 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
4587 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
4590 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
4591 .auth = WMI_TLV_PEER_AUTH,
4592 .qos = WMI_TLV_PEER_QOS,
4593 .need_ptk_4_way = WMI_TLV_PEER_NEED_PTK_4_WAY,
4594 .need_gtk_2_way = WMI_TLV_PEER_NEED_GTK_2_WAY,
4595 .apsd = WMI_TLV_PEER_APSD,
4596 .ht = WMI_TLV_PEER_HT,
4597 .bw40 = WMI_TLV_PEER_40MHZ,
4598 .stbc = WMI_TLV_PEER_STBC,
4599 .ldbc = WMI_TLV_PEER_LDPC,
4600 .dyn_mimops = WMI_TLV_PEER_DYN_MIMOPS,
4601 .static_mimops = WMI_TLV_PEER_STATIC_MIMOPS,
4602 .spatial_mux = WMI_TLV_PEER_SPATIAL_MUX,
4603 .vht = WMI_TLV_PEER_VHT,
4604 .bw80 = WMI_TLV_PEER_80MHZ,
4605 .pmf = WMI_TLV_PEER_PMF,
4606 .bw160 = WMI_TLV_PEER_160MHZ,
4609 /************/
4610 /* TLV init */
4611 /************/
4613 void ath10k_wmi_tlv_attach(struct ath10k *ar)
4615 ar->wmi.cmd = &wmi_tlv_cmd_map;
4616 ar->wmi.vdev_param = &wmi_tlv_vdev_param_map;
4617 ar->wmi.pdev_param = &wmi_tlv_pdev_param_map;
4618 ar->wmi.peer_param = &wmi_tlv_peer_param_map;
4619 ar->wmi.ops = &wmi_tlv_ops;
4620 ar->wmi.peer_flags = &wmi_tlv_peer_flags_map;