2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2014 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 struct wmi_tlv_policy {
36 static const struct wmi_tlv_policy wmi_tlv_policies[] = {
37 [WMI_TLV_TAG_ARRAY_BYTE]
39 [WMI_TLV_TAG_ARRAY_UINT32]
41 [WMI_TLV_TAG_STRUCT_SCAN_EVENT]
42 = { .min_len = sizeof(struct wmi_scan_event) },
43 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR]
44 = { .min_len = sizeof(struct wmi_tlv_mgmt_rx_ev) },
45 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT]
46 = { .min_len = sizeof(struct wmi_chan_info_event) },
47 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT]
48 = { .min_len = sizeof(struct wmi_vdev_start_response_event) },
49 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT]
50 = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
51 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT]
52 = { .min_len = sizeof(struct wmi_host_swba_event) },
53 [WMI_TLV_TAG_STRUCT_TIM_INFO]
54 = { .min_len = sizeof(struct wmi_tim_info) },
55 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO]
56 = { .min_len = sizeof(struct wmi_p2p_noa_info) },
57 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT]
58 = { .min_len = sizeof(struct wmi_tlv_svc_rdy_ev) },
59 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES]
60 = { .min_len = sizeof(struct hal_reg_capabilities) },
61 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ]
62 = { .min_len = sizeof(struct wlan_host_mem_req) },
63 [WMI_TLV_TAG_STRUCT_READY_EVENT]
64 = { .min_len = sizeof(struct wmi_tlv_rdy_ev) },
65 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT]
66 = { .min_len = sizeof(struct wmi_tlv_bcn_tx_status_ev) },
67 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT]
68 = { .min_len = sizeof(struct wmi_tlv_diag_data_ev) },
69 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT]
70 = { .min_len = sizeof(struct wmi_tlv_p2p_noa_ev) },
71 [WMI_TLV_TAG_STRUCT_ROAM_EVENT]
72 = { .min_len = sizeof(struct wmi_tlv_roam_ev) },
73 [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO]
74 = { .min_len = sizeof(struct wmi_tlv_wow_event_info) },
75 [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT]
76 = { .min_len = sizeof(struct wmi_tlv_tx_pause_ev) },
80 ath10k_wmi_tlv_iter(struct ath10k *ar, const void *ptr, size_t len,
81 int (*iter)(struct ath10k *ar, u16 tag, u16 len,
82 const void *ptr, void *data),
85 const void *begin = ptr;
86 const struct wmi_tlv *tlv;
91 if (len < sizeof(*tlv)) {
92 ath10k_dbg(ar, ATH10K_DBG_WMI,
93 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
94 ptr - begin, len, sizeof(*tlv));
99 tlv_tag = __le16_to_cpu(tlv->tag);
100 tlv_len = __le16_to_cpu(tlv->len);
105 ath10k_dbg(ar, ATH10K_DBG_WMI,
106 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
107 tlv_tag, ptr - begin, len, tlv_len);
111 if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
112 wmi_tlv_policies[tlv_tag].min_len &&
113 wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
114 ath10k_dbg(ar, ATH10K_DBG_WMI,
115 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
116 tlv_tag, ptr - begin, tlv_len,
117 wmi_tlv_policies[tlv_tag].min_len);
121 ret = iter(ar, tlv_tag, tlv_len, ptr, data);
132 static int ath10k_wmi_tlv_iter_parse(struct ath10k *ar, u16 tag, u16 len,
133 const void *ptr, void *data)
135 const void **tb = data;
137 if (tag < WMI_TLV_TAG_MAX)
143 static int ath10k_wmi_tlv_parse(struct ath10k *ar, const void **tb,
144 const void *ptr, size_t len)
146 return ath10k_wmi_tlv_iter(ar, ptr, len, ath10k_wmi_tlv_iter_parse,
151 ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
152 size_t len, gfp_t gfp)
157 tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
159 return ERR_PTR(-ENOMEM);
161 ret = ath10k_wmi_tlv_parse(ar, tb, ptr, len);
170 static u16 ath10k_wmi_tlv_len(const void *ptr)
172 return __le16_to_cpu((((const struct wmi_tlv *)ptr) - 1)->len);
178 static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k *ar,
182 const struct wmi_tlv_bcn_tx_status_ev *ev;
183 struct ath10k_vif *arvif;
184 u32 vdev_id, tx_status;
187 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
190 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
194 ev = tb[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT];
200 tx_status = __le32_to_cpu(ev->tx_status);
201 vdev_id = __le32_to_cpu(ev->vdev_id);
204 case WMI_TLV_BCN_TX_STATUS_OK:
206 case WMI_TLV_BCN_TX_STATUS_XRETRY:
207 case WMI_TLV_BCN_TX_STATUS_DROP:
208 case WMI_TLV_BCN_TX_STATUS_FILTERED:
209 /* FIXME: It's probably worth telling mac80211 to stop the
210 * interface as it is crippled.
212 ath10k_warn(ar, "received bcn tmpl tx status on vdev %i: %d",
217 arvif = ath10k_get_arvif(ar, vdev_id);
218 if (arvif && arvif->is_up && arvif->vif->csa_active)
219 ieee80211_queue_work(ar->hw, &arvif->ap_csa_work);
225 static int ath10k_wmi_tlv_event_diag_data(struct ath10k *ar,
229 const struct wmi_tlv_diag_data_ev *ev;
230 const struct wmi_tlv_diag_item *item;
232 int ret, num_items, len;
234 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
237 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
241 ev = tb[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT];
242 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
248 num_items = __le32_to_cpu(ev->num_items);
249 len = ath10k_wmi_tlv_len(data);
251 while (num_items--) {
254 if (len < sizeof(*item)) {
255 ath10k_warn(ar, "failed to parse diag data: can't fit item header\n");
261 if (len < sizeof(*item) + __le16_to_cpu(item->len)) {
262 ath10k_warn(ar, "failed to parse diag data: item is too long\n");
266 trace_ath10k_wmi_diag_container(ar,
268 __le32_to_cpu(item->timestamp),
269 __le32_to_cpu(item->code),
270 __le16_to_cpu(item->len),
273 len -= sizeof(*item);
274 len -= roundup(__le16_to_cpu(item->len), 4);
276 data += sizeof(*item);
277 data += roundup(__le16_to_cpu(item->len), 4);
280 if (num_items != -1 || len != 0)
281 ath10k_warn(ar, "failed to parse diag data event: num_items %d len %d\n",
288 static int ath10k_wmi_tlv_event_diag(struct ath10k *ar,
295 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
298 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
302 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
307 len = ath10k_wmi_tlv_len(data);
309 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv diag event len %d\n", len);
310 trace_ath10k_wmi_diag(ar, data, len);
316 static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k *ar,
320 const struct wmi_tlv_p2p_noa_ev *ev;
321 const struct wmi_p2p_noa_info *noa;
324 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
327 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
331 ev = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT];
332 noa = tb[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO];
339 vdev_id = __le32_to_cpu(ev->vdev_id);
341 ath10k_dbg(ar, ATH10K_DBG_WMI,
342 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
343 vdev_id, noa->num_descriptors);
345 ath10k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);
350 static int ath10k_wmi_tlv_event_tx_pause(struct ath10k *ar,
354 const struct wmi_tlv_tx_pause_ev *ev;
356 u32 pause_id, action, vdev_map, peer_id, tid_map;
358 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
361 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
365 ev = tb[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT];
371 pause_id = __le32_to_cpu(ev->pause_id);
372 action = __le32_to_cpu(ev->action);
373 vdev_map = __le32_to_cpu(ev->vdev_map);
374 peer_id = __le32_to_cpu(ev->peer_id);
375 tid_map = __le32_to_cpu(ev->tid_map);
377 ath10k_dbg(ar, ATH10K_DBG_WMI,
378 "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n",
379 pause_id, action, vdev_map, peer_id, tid_map);
382 case WMI_TLV_TX_PAUSE_ID_MCC:
383 case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA:
384 case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS:
385 case WMI_TLV_TX_PAUSE_ID_AP_PS:
386 case WMI_TLV_TX_PAUSE_ID_IBSS_PS:
387 for (vdev_id = 0; vdev_map; vdev_id++) {
388 if (!(vdev_map & BIT(vdev_id)))
391 vdev_map &= ~BIT(vdev_id);
392 ath10k_mac_handle_tx_pause_vdev(ar, vdev_id, pause_id,
396 case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS:
397 case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD:
398 case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA:
399 case WMI_TLV_TX_PAUSE_ID_HOST:
400 ath10k_dbg(ar, ATH10K_DBG_MAC,
401 "mac ignoring unsupported tx pause id %d\n",
405 ath10k_dbg(ar, ATH10K_DBG_MAC,
406 "mac ignoring unknown tx pause vdev %d\n",
419 static void ath10k_wmi_tlv_op_rx(struct ath10k *ar, struct sk_buff *skb)
421 struct wmi_cmd_hdr *cmd_hdr;
422 enum wmi_tlv_event_id id;
425 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
426 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
428 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
431 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
433 consumed = ath10k_tm_event_wmi(ar, id, skb);
435 /* Ready event must be handled normally also in UTF mode so that we
436 * know the UTF firmware has booted, others we are just bypass WMI
437 * events to testmode.
439 if (consumed && id != WMI_TLV_READY_EVENTID) {
440 ath10k_dbg(ar, ATH10K_DBG_WMI,
441 "wmi tlv testmode consumed 0x%x\n", id);
446 case WMI_TLV_MGMT_RX_EVENTID:
447 ath10k_wmi_event_mgmt_rx(ar, skb);
448 /* mgmt_rx() owns the skb now! */
450 case WMI_TLV_SCAN_EVENTID:
451 ath10k_wmi_event_scan(ar, skb);
453 case WMI_TLV_CHAN_INFO_EVENTID:
454 ath10k_wmi_event_chan_info(ar, skb);
456 case WMI_TLV_ECHO_EVENTID:
457 ath10k_wmi_event_echo(ar, skb);
459 case WMI_TLV_DEBUG_MESG_EVENTID:
460 ath10k_wmi_event_debug_mesg(ar, skb);
462 case WMI_TLV_UPDATE_STATS_EVENTID:
463 ath10k_wmi_event_update_stats(ar, skb);
465 case WMI_TLV_VDEV_START_RESP_EVENTID:
466 ath10k_wmi_event_vdev_start_resp(ar, skb);
468 case WMI_TLV_VDEV_STOPPED_EVENTID:
469 ath10k_wmi_event_vdev_stopped(ar, skb);
471 case WMI_TLV_PEER_STA_KICKOUT_EVENTID:
472 ath10k_wmi_event_peer_sta_kickout(ar, skb);
474 case WMI_TLV_HOST_SWBA_EVENTID:
475 ath10k_wmi_event_host_swba(ar, skb);
477 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID:
478 ath10k_wmi_event_tbttoffset_update(ar, skb);
480 case WMI_TLV_PHYERR_EVENTID:
481 ath10k_wmi_event_phyerr(ar, skb);
483 case WMI_TLV_ROAM_EVENTID:
484 ath10k_wmi_event_roam(ar, skb);
486 case WMI_TLV_PROFILE_MATCH:
487 ath10k_wmi_event_profile_match(ar, skb);
489 case WMI_TLV_DEBUG_PRINT_EVENTID:
490 ath10k_wmi_event_debug_print(ar, skb);
492 case WMI_TLV_PDEV_QVIT_EVENTID:
493 ath10k_wmi_event_pdev_qvit(ar, skb);
495 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID:
496 ath10k_wmi_event_wlan_profile_data(ar, skb);
498 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID:
499 ath10k_wmi_event_rtt_measurement_report(ar, skb);
501 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID:
502 ath10k_wmi_event_tsf_measurement_report(ar, skb);
504 case WMI_TLV_RTT_ERROR_REPORT_EVENTID:
505 ath10k_wmi_event_rtt_error_report(ar, skb);
507 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID:
508 ath10k_wmi_event_wow_wakeup_host(ar, skb);
510 case WMI_TLV_DCS_INTERFERENCE_EVENTID:
511 ath10k_wmi_event_dcs_interference(ar, skb);
513 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID:
514 ath10k_wmi_event_pdev_tpc_config(ar, skb);
516 case WMI_TLV_PDEV_FTM_INTG_EVENTID:
517 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
519 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID:
520 ath10k_wmi_event_gtk_offload_status(ar, skb);
522 case WMI_TLV_GTK_REKEY_FAIL_EVENTID:
523 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
525 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID:
526 ath10k_wmi_event_delba_complete(ar, skb);
528 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID:
529 ath10k_wmi_event_addba_complete(ar, skb);
531 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
532 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
534 case WMI_TLV_SERVICE_READY_EVENTID:
535 ath10k_wmi_event_service_ready(ar, skb);
537 case WMI_TLV_READY_EVENTID:
538 ath10k_wmi_event_ready(ar, skb);
540 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID:
541 ath10k_wmi_tlv_event_bcn_tx_status(ar, skb);
543 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID:
544 ath10k_wmi_tlv_event_diag_data(ar, skb);
546 case WMI_TLV_DIAG_EVENTID:
547 ath10k_wmi_tlv_event_diag(ar, skb);
549 case WMI_TLV_P2P_NOA_EVENTID:
550 ath10k_wmi_tlv_event_p2p_noa(ar, skb);
552 case WMI_TLV_TX_PAUSE_EVENTID:
553 ath10k_wmi_tlv_event_tx_pause(ar, skb);
556 ath10k_warn(ar, "Unknown eventid: %d\n", id);
564 static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k *ar,
566 struct wmi_scan_ev_arg *arg)
569 const struct wmi_scan_event *ev;
572 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
575 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
579 ev = tb[WMI_TLV_TAG_STRUCT_SCAN_EVENT];
585 arg->event_type = ev->event_type;
586 arg->reason = ev->reason;
587 arg->channel_freq = ev->channel_freq;
588 arg->scan_req_id = ev->scan_req_id;
589 arg->scan_id = ev->scan_id;
590 arg->vdev_id = ev->vdev_id;
596 static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k *ar,
598 struct wmi_mgmt_rx_ev_arg *arg)
601 const struct wmi_tlv_mgmt_rx_ev *ev;
606 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
609 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
613 ev = tb[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR];
614 frame = tb[WMI_TLV_TAG_ARRAY_BYTE];
621 arg->channel = ev->channel;
622 arg->buf_len = ev->buf_len;
623 arg->status = ev->status;
625 arg->phy_mode = ev->phy_mode;
626 arg->rate = ev->rate;
628 msdu_len = __le32_to_cpu(arg->buf_len);
630 if (skb->len < (frame - skb->data) + msdu_len) {
635 /* shift the sk_buff to point to `frame` */
637 skb_put(skb, frame - skb->data);
638 skb_pull(skb, frame - skb->data);
639 skb_put(skb, msdu_len);
645 static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k *ar,
647 struct wmi_ch_info_ev_arg *arg)
650 const struct wmi_chan_info_event *ev;
653 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
656 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
660 ev = tb[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT];
666 arg->err_code = ev->err_code;
667 arg->freq = ev->freq;
668 arg->cmd_flags = ev->cmd_flags;
669 arg->noise_floor = ev->noise_floor;
670 arg->rx_clear_count = ev->rx_clear_count;
671 arg->cycle_count = ev->cycle_count;
678 ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
679 struct wmi_vdev_start_ev_arg *arg)
682 const struct wmi_vdev_start_response_event *ev;
685 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
688 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
692 ev = tb[WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT];
698 skb_pull(skb, sizeof(*ev));
699 arg->vdev_id = ev->vdev_id;
700 arg->req_id = ev->req_id;
701 arg->resp_type = ev->resp_type;
702 arg->status = ev->status;
708 static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k *ar,
710 struct wmi_peer_kick_ev_arg *arg)
713 const struct wmi_peer_sta_kickout_event *ev;
716 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
719 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
723 ev = tb[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT];
729 arg->mac_addr = ev->peer_macaddr.addr;
735 struct wmi_tlv_swba_parse {
736 const struct wmi_host_swba_event *ev;
741 struct wmi_swba_ev_arg *arg;
744 static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k *ar, u16 tag, u16 len,
745 const void *ptr, void *data)
747 struct wmi_tlv_swba_parse *swba = data;
748 struct wmi_tim_info_arg *tim_info_arg;
749 const struct wmi_tim_info *tim_info_ev = ptr;
751 if (tag != WMI_TLV_TAG_STRUCT_TIM_INFO)
754 if (swba->n_tim >= ARRAY_SIZE(swba->arg->tim_info))
757 if (__le32_to_cpu(tim_info_ev->tim_len) >
758 sizeof(tim_info_ev->tim_bitmap)) {
759 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
763 tim_info_arg = &swba->arg->tim_info[swba->n_tim];
764 tim_info_arg->tim_len = tim_info_ev->tim_len;
765 tim_info_arg->tim_mcast = tim_info_ev->tim_mcast;
766 tim_info_arg->tim_bitmap = tim_info_ev->tim_bitmap;
767 tim_info_arg->tim_changed = tim_info_ev->tim_changed;
768 tim_info_arg->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
775 static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k *ar, u16 tag, u16 len,
776 const void *ptr, void *data)
778 struct wmi_tlv_swba_parse *swba = data;
780 if (tag != WMI_TLV_TAG_STRUCT_P2P_NOA_INFO)
783 if (swba->n_noa >= ARRAY_SIZE(swba->arg->noa_info))
786 swba->arg->noa_info[swba->n_noa++] = ptr;
790 static int ath10k_wmi_tlv_swba_parse(struct ath10k *ar, u16 tag, u16 len,
791 const void *ptr, void *data)
793 struct wmi_tlv_swba_parse *swba = data;
797 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT:
800 case WMI_TLV_TAG_ARRAY_STRUCT:
801 if (!swba->tim_done) {
802 swba->tim_done = true;
803 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
804 ath10k_wmi_tlv_swba_tim_parse,
808 } else if (!swba->noa_done) {
809 swba->noa_done = true;
810 ret = ath10k_wmi_tlv_iter(ar, ptr, len,
811 ath10k_wmi_tlv_swba_noa_parse,
823 static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k *ar,
825 struct wmi_swba_ev_arg *arg)
827 struct wmi_tlv_swba_parse swba = { .arg = arg };
832 ret = ath10k_wmi_tlv_iter(ar, skb->data, skb->len,
833 ath10k_wmi_tlv_swba_parse, &swba);
835 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
842 arg->vdev_map = swba.ev->vdev_map;
844 for (map = __le32_to_cpu(arg->vdev_map), n_vdevs = 0; map; map >>= 1)
848 if (n_vdevs != swba.n_tim ||
849 n_vdevs != swba.n_noa)
855 static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k *ar,
857 struct wmi_phyerr_hdr_arg *arg)
860 const struct wmi_tlv_phyerr_ev *ev;
864 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
867 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
871 ev = tb[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR];
872 phyerrs = tb[WMI_TLV_TAG_ARRAY_BYTE];
874 if (!ev || !phyerrs) {
879 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
880 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
881 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
882 arg->buf_len = __le32_to_cpu(ev->buf_len);
883 arg->phyerrs = phyerrs;
889 #define WMI_TLV_ABI_VER_NS0 0x5F414351
890 #define WMI_TLV_ABI_VER_NS1 0x00004C4D
891 #define WMI_TLV_ABI_VER_NS2 0x00000000
892 #define WMI_TLV_ABI_VER_NS3 0x00000000
894 #define WMI_TLV_ABI_VER0_MAJOR 1
895 #define WMI_TLV_ABI_VER0_MINOR 0
896 #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
897 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
898 #define WMI_TLV_ABI_VER1 53
901 ath10k_wmi_tlv_parse_mem_reqs(struct ath10k *ar, u16 tag, u16 len,
902 const void *ptr, void *data)
904 struct wmi_svc_rdy_ev_arg *arg = data;
907 if (tag != WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ)
910 for (i = 0; i < ARRAY_SIZE(arg->mem_reqs); i++) {
911 if (!arg->mem_reqs[i]) {
912 arg->mem_reqs[i] = ptr;
920 static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k *ar,
922 struct wmi_svc_rdy_ev_arg *arg)
925 const struct hal_reg_capabilities *reg;
926 const struct wmi_tlv_svc_rdy_ev *ev;
927 const __le32 *svc_bmap;
928 const struct wlan_host_mem_req *mem_reqs;
931 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
934 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
938 ev = tb[WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT];
939 reg = tb[WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES];
940 svc_bmap = tb[WMI_TLV_TAG_ARRAY_UINT32];
941 mem_reqs = tb[WMI_TLV_TAG_ARRAY_STRUCT];
943 if (!ev || !reg || !svc_bmap || !mem_reqs) {
948 /* This is an internal ABI compatibility check for WMI TLV so check it
949 * here instead of the generic WMI code.
951 ath10k_dbg(ar, ATH10K_DBG_WMI,
952 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
953 __le32_to_cpu(ev->abi.abi_ver0), WMI_TLV_ABI_VER0,
954 __le32_to_cpu(ev->abi.abi_ver_ns0), WMI_TLV_ABI_VER_NS0,
955 __le32_to_cpu(ev->abi.abi_ver_ns1), WMI_TLV_ABI_VER_NS1,
956 __le32_to_cpu(ev->abi.abi_ver_ns2), WMI_TLV_ABI_VER_NS2,
957 __le32_to_cpu(ev->abi.abi_ver_ns3), WMI_TLV_ABI_VER_NS3);
959 if (__le32_to_cpu(ev->abi.abi_ver0) != WMI_TLV_ABI_VER0 ||
960 __le32_to_cpu(ev->abi.abi_ver_ns0) != WMI_TLV_ABI_VER_NS0 ||
961 __le32_to_cpu(ev->abi.abi_ver_ns1) != WMI_TLV_ABI_VER_NS1 ||
962 __le32_to_cpu(ev->abi.abi_ver_ns2) != WMI_TLV_ABI_VER_NS2 ||
963 __le32_to_cpu(ev->abi.abi_ver_ns3) != WMI_TLV_ABI_VER_NS3) {
968 arg->min_tx_power = ev->hw_min_tx_power;
969 arg->max_tx_power = ev->hw_max_tx_power;
970 arg->ht_cap = ev->ht_cap_info;
971 arg->vht_cap = ev->vht_cap_info;
972 arg->sw_ver0 = ev->abi.abi_ver0;
973 arg->sw_ver1 = ev->abi.abi_ver1;
974 arg->fw_build = ev->fw_build_vers;
975 arg->phy_capab = ev->phy_capability;
976 arg->num_rf_chains = ev->num_rf_chains;
977 arg->eeprom_rd = reg->eeprom_rd;
978 arg->num_mem_reqs = ev->num_mem_reqs;
979 arg->service_map = svc_bmap;
980 arg->service_map_len = ath10k_wmi_tlv_len(svc_bmap);
982 ret = ath10k_wmi_tlv_iter(ar, mem_reqs, ath10k_wmi_tlv_len(mem_reqs),
983 ath10k_wmi_tlv_parse_mem_reqs, arg);
986 ath10k_warn(ar, "failed to parse mem_reqs tlv: %d\n", ret);
994 static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k *ar,
996 struct wmi_rdy_ev_arg *arg)
999 const struct wmi_tlv_rdy_ev *ev;
1002 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1005 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1009 ev = tb[WMI_TLV_TAG_STRUCT_READY_EVENT];
1015 arg->sw_version = ev->abi.abi_ver0;
1016 arg->abi_version = ev->abi.abi_ver1;
1017 arg->status = ev->status;
1018 arg->mac_addr = ev->mac_addr.addr;
1024 static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats *src,
1025 struct ath10k_fw_stats_vdev *dst)
1029 dst->vdev_id = __le32_to_cpu(src->vdev_id);
1030 dst->beacon_snr = __le32_to_cpu(src->beacon_snr);
1031 dst->data_snr = __le32_to_cpu(src->data_snr);
1032 dst->num_rx_frames = __le32_to_cpu(src->num_rx_frames);
1033 dst->num_rts_fail = __le32_to_cpu(src->num_rts_fail);
1034 dst->num_rts_success = __le32_to_cpu(src->num_rts_success);
1035 dst->num_rx_err = __le32_to_cpu(src->num_rx_err);
1036 dst->num_rx_discard = __le32_to_cpu(src->num_rx_discard);
1037 dst->num_tx_not_acked = __le32_to_cpu(src->num_tx_not_acked);
1039 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++)
1040 dst->num_tx_frames[i] =
1041 __le32_to_cpu(src->num_tx_frames[i]);
1043 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++)
1044 dst->num_tx_frames_retries[i] =
1045 __le32_to_cpu(src->num_tx_frames_retries[i]);
1047 for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++)
1048 dst->num_tx_frames_failures[i] =
1049 __le32_to_cpu(src->num_tx_frames_failures[i]);
1051 for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++)
1052 dst->tx_rate_history[i] =
1053 __le32_to_cpu(src->tx_rate_history[i]);
1055 for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++)
1056 dst->beacon_rssi_history[i] =
1057 __le32_to_cpu(src->beacon_rssi_history[i]);
1060 static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1061 struct sk_buff *skb,
1062 struct ath10k_fw_stats *stats)
1065 const struct wmi_tlv_stats_ev *ev;
1070 u32 num_bcnflt_stats;
1076 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1079 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1083 ev = tb[WMI_TLV_TAG_STRUCT_STATS_EVENT];
1084 data = tb[WMI_TLV_TAG_ARRAY_BYTE];
1091 data_len = ath10k_wmi_tlv_len(data);
1092 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
1093 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
1094 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
1095 num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
1096 num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
1098 ath10k_dbg(ar, ATH10K_DBG_WMI,
1099 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i\n",
1100 num_pdev_stats, num_vdev_stats, num_peer_stats,
1101 num_bcnflt_stats, num_chan_stats);
1103 for (i = 0; i < num_pdev_stats; i++) {
1104 const struct wmi_pdev_stats *src;
1105 struct ath10k_fw_stats_pdev *dst;
1108 if (data_len < sizeof(*src))
1111 data += sizeof(*src);
1112 data_len -= sizeof(*src);
1114 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1118 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
1119 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
1120 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
1121 list_add_tail(&dst->list, &stats->pdevs);
1124 for (i = 0; i < num_vdev_stats; i++) {
1125 const struct wmi_tlv_vdev_stats *src;
1126 struct ath10k_fw_stats_vdev *dst;
1129 if (data_len < sizeof(*src))
1132 data += sizeof(*src);
1133 data_len -= sizeof(*src);
1135 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1139 ath10k_wmi_tlv_pull_vdev_stats(src, dst);
1140 list_add_tail(&dst->list, &stats->vdevs);
1143 for (i = 0; i < num_peer_stats; i++) {
1144 const struct wmi_10x_peer_stats *src;
1145 struct ath10k_fw_stats_peer *dst;
1148 if (data_len < sizeof(*src))
1151 data += sizeof(*src);
1152 data_len -= sizeof(*src);
1154 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
1158 ath10k_wmi_pull_peer_stats(&src->old, dst);
1159 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
1160 list_add_tail(&dst->list, &stats->peers);
1167 static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k *ar,
1168 struct sk_buff *skb,
1169 struct wmi_roam_ev_arg *arg)
1172 const struct wmi_tlv_roam_ev *ev;
1175 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1178 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1182 ev = tb[WMI_TLV_TAG_STRUCT_ROAM_EVENT];
1188 arg->vdev_id = ev->vdev_id;
1189 arg->reason = ev->reason;
1190 arg->rssi = ev->rssi;
1197 ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k *ar, struct sk_buff *skb,
1198 struct wmi_wow_ev_arg *arg)
1201 const struct wmi_tlv_wow_event_info *ev;
1204 tb = ath10k_wmi_tlv_parse_alloc(ar, skb->data, skb->len, GFP_ATOMIC);
1207 ath10k_warn(ar, "failed to parse tlv: %d\n", ret);
1211 ev = tb[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO];
1217 arg->vdev_id = __le32_to_cpu(ev->vdev_id);
1218 arg->flag = __le32_to_cpu(ev->flag);
1219 arg->wake_reason = __le32_to_cpu(ev->wake_reason);
1220 arg->data_len = __le32_to_cpu(ev->data_len);
1226 static struct sk_buff *
1227 ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k *ar, u32 opt)
1229 struct wmi_tlv_pdev_suspend *cmd;
1230 struct wmi_tlv *tlv;
1231 struct sk_buff *skb;
1233 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1235 return ERR_PTR(-ENOMEM);
1237 tlv = (void *)skb->data;
1238 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD);
1239 tlv->len = __cpu_to_le16(sizeof(*cmd));
1240 cmd = (void *)tlv->value;
1241 cmd->opt = __cpu_to_le32(opt);
1243 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev suspend\n");
1247 static struct sk_buff *
1248 ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k *ar)
1250 struct wmi_tlv_resume_cmd *cmd;
1251 struct wmi_tlv *tlv;
1252 struct sk_buff *skb;
1254 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1256 return ERR_PTR(-ENOMEM);
1258 tlv = (void *)skb->data;
1259 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD);
1260 tlv->len = __cpu_to_le16(sizeof(*cmd));
1261 cmd = (void *)tlv->value;
1262 cmd->reserved = __cpu_to_le32(0);
1264 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev resume\n");
1268 static struct sk_buff *
1269 ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k *ar,
1270 u16 rd, u16 rd2g, u16 rd5g,
1271 u16 ctl2g, u16 ctl5g,
1272 enum wmi_dfs_region dfs_reg)
1274 struct wmi_tlv_pdev_set_rd_cmd *cmd;
1275 struct wmi_tlv *tlv;
1276 struct sk_buff *skb;
1278 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1280 return ERR_PTR(-ENOMEM);
1282 tlv = (void *)skb->data;
1283 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD);
1284 tlv->len = __cpu_to_le16(sizeof(*cmd));
1285 cmd = (void *)tlv->value;
1286 cmd->regd = __cpu_to_le32(rd);
1287 cmd->regd_2ghz = __cpu_to_le32(rd2g);
1288 cmd->regd_5ghz = __cpu_to_le32(rd5g);
1289 cmd->conform_limit_2ghz = __cpu_to_le32(rd2g);
1290 cmd->conform_limit_5ghz = __cpu_to_le32(rd5g);
1292 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set rd\n");
1296 static enum wmi_txbf_conf ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k *ar)
1298 return WMI_TXBF_CONF_AFTER_ASSOC;
1301 static struct sk_buff *
1302 ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k *ar, u32 param_id,
1305 struct wmi_tlv_pdev_set_param_cmd *cmd;
1306 struct wmi_tlv *tlv;
1307 struct sk_buff *skb;
1309 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1311 return ERR_PTR(-ENOMEM);
1313 tlv = (void *)skb->data;
1314 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD);
1315 tlv->len = __cpu_to_le16(sizeof(*cmd));
1316 cmd = (void *)tlv->value;
1317 cmd->param_id = __cpu_to_le32(param_id);
1318 cmd->param_value = __cpu_to_le32(param_value);
1320 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set param\n");
1324 static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
1326 struct sk_buff *skb;
1327 struct wmi_tlv *tlv;
1328 struct wmi_tlv_init_cmd *cmd;
1329 struct wmi_tlv_resource_config *cfg;
1330 struct wmi_host_mem_chunks *chunks;
1331 size_t len, chunks_len;
1334 chunks_len = ar->wmi.num_mem_chunks * sizeof(struct host_memory_chunk);
1335 len = (sizeof(*tlv) + sizeof(*cmd)) +
1336 (sizeof(*tlv) + sizeof(*cfg)) +
1337 (sizeof(*tlv) + chunks_len);
1339 skb = ath10k_wmi_alloc_skb(ar, len);
1341 return ERR_PTR(-ENOMEM);
1346 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD);
1347 tlv->len = __cpu_to_le16(sizeof(*cmd));
1348 cmd = (void *)tlv->value;
1349 ptr += sizeof(*tlv);
1350 ptr += sizeof(*cmd);
1353 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG);
1354 tlv->len = __cpu_to_le16(sizeof(*cfg));
1355 cfg = (void *)tlv->value;
1356 ptr += sizeof(*tlv);
1357 ptr += sizeof(*cfg);
1360 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1361 tlv->len = __cpu_to_le16(chunks_len);
1362 chunks = (void *)tlv->value;
1364 ptr += sizeof(*tlv);
1367 cmd->abi.abi_ver0 = __cpu_to_le32(WMI_TLV_ABI_VER0);
1368 cmd->abi.abi_ver1 = __cpu_to_le32(WMI_TLV_ABI_VER1);
1369 cmd->abi.abi_ver_ns0 = __cpu_to_le32(WMI_TLV_ABI_VER_NS0);
1370 cmd->abi.abi_ver_ns1 = __cpu_to_le32(WMI_TLV_ABI_VER_NS1);
1371 cmd->abi.abi_ver_ns2 = __cpu_to_le32(WMI_TLV_ABI_VER_NS2);
1372 cmd->abi.abi_ver_ns3 = __cpu_to_le32(WMI_TLV_ABI_VER_NS3);
1373 cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
1375 cfg->num_vdevs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1376 cfg->num_peers = __cpu_to_le32(TARGET_TLV_NUM_PEERS);
1378 if (test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)) {
1379 cfg->num_offload_peers = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1380 cfg->num_offload_reorder_bufs = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1382 cfg->num_offload_peers = __cpu_to_le32(0);
1383 cfg->num_offload_reorder_bufs = __cpu_to_le32(0);
1386 cfg->num_peer_keys = __cpu_to_le32(2);
1387 cfg->num_tids = __cpu_to_le32(TARGET_TLV_NUM_TIDS);
1388 cfg->ast_skid_limit = __cpu_to_le32(0x10);
1389 cfg->tx_chain_mask = __cpu_to_le32(0x7);
1390 cfg->rx_chain_mask = __cpu_to_le32(0x7);
1391 cfg->rx_timeout_pri[0] = __cpu_to_le32(0x64);
1392 cfg->rx_timeout_pri[1] = __cpu_to_le32(0x64);
1393 cfg->rx_timeout_pri[2] = __cpu_to_le32(0x64);
1394 cfg->rx_timeout_pri[3] = __cpu_to_le32(0x28);
1395 cfg->rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
1396 cfg->scan_max_pending_reqs = __cpu_to_le32(4);
1397 cfg->bmiss_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1398 cfg->roam_offload_max_vdev = __cpu_to_le32(TARGET_TLV_NUM_VDEVS);
1399 cfg->roam_offload_max_ap_profiles = __cpu_to_le32(8);
1400 cfg->num_mcast_groups = __cpu_to_le32(0);
1401 cfg->num_mcast_table_elems = __cpu_to_le32(0);
1402 cfg->mcast2ucast_mode = __cpu_to_le32(0);
1403 cfg->tx_dbg_log_size = __cpu_to_le32(0x400);
1404 cfg->num_wds_entries = __cpu_to_le32(0x20);
1405 cfg->dma_burst_size = __cpu_to_le32(0);
1406 cfg->mac_aggr_delim = __cpu_to_le32(0);
1407 cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
1408 cfg->vow_config = __cpu_to_le32(0);
1409 cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
1410 cfg->num_msdu_desc = __cpu_to_le32(TARGET_TLV_NUM_MSDU_DESC);
1411 cfg->max_frag_entries = __cpu_to_le32(2);
1412 cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS);
1413 cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
1414 cfg->beacon_tx_offload_max_vdev = __cpu_to_le32(2);
1415 cfg->num_multicast_filter_entries = __cpu_to_le32(5);
1416 cfg->num_wow_filters = __cpu_to_le32(ar->wow.max_num_patterns);
1417 cfg->num_keep_alive_pattern = __cpu_to_le32(6);
1418 cfg->keep_alive_pattern_size = __cpu_to_le32(0);
1419 cfg->max_tdls_concurrent_sleep_sta = __cpu_to_le32(1);
1420 cfg->max_tdls_concurrent_buffer_sta = __cpu_to_le32(1);
1422 ath10k_wmi_put_host_mem_chunks(ar, chunks);
1424 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
1428 static struct sk_buff *
1429 ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
1430 const struct wmi_start_scan_arg *arg)
1432 struct wmi_tlv_start_scan_cmd *cmd;
1433 struct wmi_tlv *tlv;
1434 struct sk_buff *skb;
1435 size_t len, chan_len, ssid_len, bssid_len, ie_len;
1437 struct wmi_ssid *ssids;
1438 struct wmi_mac_addr *addrs;
1442 ret = ath10k_wmi_start_scan_verify(arg);
1444 return ERR_PTR(ret);
1446 chan_len = arg->n_channels * sizeof(__le32);
1447 ssid_len = arg->n_ssids * sizeof(struct wmi_ssid);
1448 bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
1449 ie_len = roundup(arg->ie_len, 4);
1450 len = (sizeof(*tlv) + sizeof(*cmd)) +
1451 (arg->n_channels ? sizeof(*tlv) + chan_len : 0) +
1452 (arg->n_ssids ? sizeof(*tlv) + ssid_len : 0) +
1453 (arg->n_bssids ? sizeof(*tlv) + bssid_len : 0) +
1454 (arg->ie_len ? sizeof(*tlv) + ie_len : 0);
1456 skb = ath10k_wmi_alloc_skb(ar, len);
1458 return ERR_PTR(-ENOMEM);
1460 ptr = (void *)skb->data;
1462 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD);
1463 tlv->len = __cpu_to_le16(sizeof(*cmd));
1464 cmd = (void *)tlv->value;
1466 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
1467 cmd->burst_duration_ms = __cpu_to_le32(arg->burst_duration_ms);
1468 cmd->num_channels = __cpu_to_le32(arg->n_channels);
1469 cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
1470 cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
1471 cmd->ie_len = __cpu_to_le32(arg->ie_len);
1472 cmd->num_probes = __cpu_to_le32(3);
1474 /* FIXME: There are some scan flag inconsistencies across firmwares,
1475 * e.g. WMI-TLV inverts the logic behind the following flag.
1477 cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
1479 ptr += sizeof(*tlv);
1480 ptr += sizeof(*cmd);
1483 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
1484 tlv->len = __cpu_to_le16(chan_len);
1485 chans = (void *)tlv->value;
1486 for (i = 0; i < arg->n_channels; i++)
1487 chans[i] = __cpu_to_le32(arg->channels[i]);
1489 ptr += sizeof(*tlv);
1493 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1494 tlv->len = __cpu_to_le16(ssid_len);
1495 ssids = (void *)tlv->value;
1496 for (i = 0; i < arg->n_ssids; i++) {
1497 ssids[i].ssid_len = __cpu_to_le32(arg->ssids[i].len);
1498 memcpy(ssids[i].ssid, arg->ssids[i].ssid, arg->ssids[i].len);
1501 ptr += sizeof(*tlv);
1505 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT);
1506 tlv->len = __cpu_to_le16(bssid_len);
1507 addrs = (void *)tlv->value;
1508 for (i = 0; i < arg->n_bssids; i++)
1509 ether_addr_copy(addrs[i].addr, arg->bssids[i].bssid);
1511 ptr += sizeof(*tlv);
1515 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1516 tlv->len = __cpu_to_le16(ie_len);
1517 memcpy(tlv->value, arg->ie, arg->ie_len);
1519 ptr += sizeof(*tlv);
1522 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
1526 static struct sk_buff *
1527 ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k *ar,
1528 const struct wmi_stop_scan_arg *arg)
1530 struct wmi_stop_scan_cmd *cmd;
1531 struct wmi_tlv *tlv;
1532 struct sk_buff *skb;
1536 if (arg->req_id > 0xFFF)
1537 return ERR_PTR(-EINVAL);
1538 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
1539 return ERR_PTR(-EINVAL);
1541 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1543 return ERR_PTR(-ENOMEM);
1545 scan_id = arg->u.scan_id;
1546 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
1548 req_id = arg->req_id;
1549 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
1551 tlv = (void *)skb->data;
1552 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD);
1553 tlv->len = __cpu_to_le16(sizeof(*cmd));
1554 cmd = (void *)tlv->value;
1555 cmd->req_type = __cpu_to_le32(arg->req_type);
1556 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
1557 cmd->scan_id = __cpu_to_le32(scan_id);
1558 cmd->scan_req_id = __cpu_to_le32(req_id);
1560 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop scan\n");
1564 static struct sk_buff *
1565 ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k *ar,
1567 enum wmi_vdev_type vdev_type,
1568 enum wmi_vdev_subtype vdev_subtype,
1569 const u8 mac_addr[ETH_ALEN])
1571 struct wmi_vdev_create_cmd *cmd;
1572 struct wmi_tlv *tlv;
1573 struct sk_buff *skb;
1575 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1577 return ERR_PTR(-ENOMEM);
1579 tlv = (void *)skb->data;
1580 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD);
1581 tlv->len = __cpu_to_le16(sizeof(*cmd));
1582 cmd = (void *)tlv->value;
1583 cmd->vdev_id = __cpu_to_le32(vdev_id);
1584 cmd->vdev_type = __cpu_to_le32(vdev_type);
1585 cmd->vdev_subtype = __cpu_to_le32(vdev_subtype);
1586 ether_addr_copy(cmd->vdev_macaddr.addr, mac_addr);
1588 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev create\n");
1592 static struct sk_buff *
1593 ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
1595 struct wmi_vdev_delete_cmd *cmd;
1596 struct wmi_tlv *tlv;
1597 struct sk_buff *skb;
1599 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1601 return ERR_PTR(-ENOMEM);
1603 tlv = (void *)skb->data;
1604 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD);
1605 tlv->len = __cpu_to_le16(sizeof(*cmd));
1606 cmd = (void *)tlv->value;
1607 cmd->vdev_id = __cpu_to_le32(vdev_id);
1609 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev delete\n");
1613 static struct sk_buff *
1614 ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
1615 const struct wmi_vdev_start_request_arg *arg,
1618 struct wmi_tlv_vdev_start_cmd *cmd;
1619 struct wmi_channel *ch;
1620 struct wmi_p2p_noa_descriptor *noa;
1621 struct wmi_tlv *tlv;
1622 struct sk_buff *skb;
1627 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
1628 return ERR_PTR(-EINVAL);
1629 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
1630 return ERR_PTR(-EINVAL);
1632 len = (sizeof(*tlv) + sizeof(*cmd)) +
1633 (sizeof(*tlv) + sizeof(*ch)) +
1635 skb = ath10k_wmi_alloc_skb(ar, len);
1637 return ERR_PTR(-ENOMEM);
1639 if (arg->hidden_ssid)
1640 flags |= WMI_VDEV_START_HIDDEN_SSID;
1641 if (arg->pmf_enabled)
1642 flags |= WMI_VDEV_START_PMF_ENABLED;
1644 ptr = (void *)skb->data;
1647 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD);
1648 tlv->len = __cpu_to_le16(sizeof(*cmd));
1649 cmd = (void *)tlv->value;
1650 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1651 cmd->bcn_intval = __cpu_to_le32(arg->bcn_intval);
1652 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
1653 cmd->flags = __cpu_to_le32(flags);
1654 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
1655 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
1656 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
1659 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
1660 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
1663 ptr += sizeof(*tlv);
1664 ptr += sizeof(*cmd);
1667 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
1668 tlv->len = __cpu_to_le16(sizeof(*ch));
1669 ch = (void *)tlv->value;
1670 ath10k_wmi_put_wmi_channel(ch, &arg->channel);
1672 ptr += sizeof(*tlv);
1676 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1678 noa = (void *)tlv->value;
1680 /* Note: This is a nested TLV containing:
1681 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
1684 ptr += sizeof(*tlv);
1687 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev start\n");
1691 static struct sk_buff *
1692 ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
1694 struct wmi_vdev_stop_cmd *cmd;
1695 struct wmi_tlv *tlv;
1696 struct sk_buff *skb;
1698 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1700 return ERR_PTR(-ENOMEM);
1702 tlv = (void *)skb->data;
1703 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD);
1704 tlv->len = __cpu_to_le16(sizeof(*cmd));
1705 cmd = (void *)tlv->value;
1706 cmd->vdev_id = __cpu_to_le32(vdev_id);
1708 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev stop\n");
1712 static struct sk_buff *
1713 ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
1717 struct wmi_vdev_up_cmd *cmd;
1718 struct wmi_tlv *tlv;
1719 struct sk_buff *skb;
1721 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1723 return ERR_PTR(-ENOMEM);
1725 tlv = (void *)skb->data;
1726 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD);
1727 tlv->len = __cpu_to_le16(sizeof(*cmd));
1728 cmd = (void *)tlv->value;
1729 cmd->vdev_id = __cpu_to_le32(vdev_id);
1730 cmd->vdev_assoc_id = __cpu_to_le32(aid);
1731 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
1733 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev up\n");
1737 static struct sk_buff *
1738 ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
1740 struct wmi_vdev_down_cmd *cmd;
1741 struct wmi_tlv *tlv;
1742 struct sk_buff *skb;
1744 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1746 return ERR_PTR(-ENOMEM);
1748 tlv = (void *)skb->data;
1749 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD);
1750 tlv->len = __cpu_to_le16(sizeof(*cmd));
1751 cmd = (void *)tlv->value;
1752 cmd->vdev_id = __cpu_to_le32(vdev_id);
1754 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev down\n");
1758 static struct sk_buff *
1759 ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
1760 u32 param_id, u32 param_value)
1762 struct wmi_vdev_set_param_cmd *cmd;
1763 struct wmi_tlv *tlv;
1764 struct sk_buff *skb;
1766 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
1768 return ERR_PTR(-ENOMEM);
1770 tlv = (void *)skb->data;
1771 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD);
1772 tlv->len = __cpu_to_le16(sizeof(*cmd));
1773 cmd = (void *)tlv->value;
1774 cmd->vdev_id = __cpu_to_le32(vdev_id);
1775 cmd->param_id = __cpu_to_le32(param_id);
1776 cmd->param_value = __cpu_to_le32(param_value);
1778 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev set param\n");
1782 static struct sk_buff *
1783 ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k *ar,
1784 const struct wmi_vdev_install_key_arg *arg)
1786 struct wmi_vdev_install_key_cmd *cmd;
1787 struct wmi_tlv *tlv;
1788 struct sk_buff *skb;
1792 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
1793 return ERR_PTR(-EINVAL);
1794 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
1795 return ERR_PTR(-EINVAL);
1797 len = sizeof(*tlv) + sizeof(*cmd) +
1798 sizeof(*tlv) + roundup(arg->key_len, sizeof(__le32));
1799 skb = ath10k_wmi_alloc_skb(ar, len);
1801 return ERR_PTR(-ENOMEM);
1803 ptr = (void *)skb->data;
1805 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD);
1806 tlv->len = __cpu_to_le16(sizeof(*cmd));
1807 cmd = (void *)tlv->value;
1808 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1809 cmd->key_idx = __cpu_to_le32(arg->key_idx);
1810 cmd->key_flags = __cpu_to_le32(arg->key_flags);
1811 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
1812 cmd->key_len = __cpu_to_le32(arg->key_len);
1813 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
1814 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
1817 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
1819 ptr += sizeof(*tlv);
1820 ptr += sizeof(*cmd);
1823 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
1824 tlv->len = __cpu_to_le16(roundup(arg->key_len, sizeof(__le32)));
1826 memcpy(tlv->value, arg->key_data, arg->key_len);
1828 ptr += sizeof(*tlv);
1829 ptr += roundup(arg->key_len, sizeof(__le32));
1831 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev install key\n");
1835 static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k *ar, void *ptr,
1836 const struct wmi_sta_uapsd_auto_trig_arg *arg)
1838 struct wmi_sta_uapsd_auto_trig_param *ac;
1839 struct wmi_tlv *tlv;
1842 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM);
1843 tlv->len = __cpu_to_le16(sizeof(*ac));
1844 ac = (void *)tlv->value;
1846 ac->wmm_ac = __cpu_to_le32(arg->wmm_ac);
1847 ac->user_priority = __cpu_to_le32(arg->user_priority);
1848 ac->service_interval = __cpu_to_le32(arg->service_interval);
1849 ac->suspend_interval = __cpu_to_le32(arg->suspend_interval);
1850 ac->delay_interval = __cpu_to_le32(arg->delay_interval);
1852 ath10k_dbg(ar, ATH10K_DBG_WMI,
1853 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
1854 ac->wmm_ac, ac->user_priority, ac->service_interval,
1855 ac->suspend_interval, ac->delay_interval);
1857 return ptr + sizeof(*tlv) + sizeof(*ac);
1860 static struct sk_buff *
1861 ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k *ar, u32 vdev_id,
1862 const u8 peer_addr[ETH_ALEN],
1863 const struct wmi_sta_uapsd_auto_trig_arg *args,
1866 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
1867 struct wmi_sta_uapsd_auto_trig_param *ac;
1868 struct wmi_tlv *tlv;
1869 struct sk_buff *skb;
1875 ac_tlv_len = num_ac * (sizeof(*tlv) + sizeof(*ac));
1876 len = sizeof(*tlv) + sizeof(*cmd) +
1877 sizeof(*tlv) + ac_tlv_len;
1878 skb = ath10k_wmi_alloc_skb(ar, len);
1880 return ERR_PTR(-ENOMEM);
1882 ptr = (void *)skb->data;
1884 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD);
1885 tlv->len = __cpu_to_le16(sizeof(*cmd));
1886 cmd = (void *)tlv->value;
1887 cmd->vdev_id = __cpu_to_le32(vdev_id);
1888 cmd->num_ac = __cpu_to_le32(num_ac);
1889 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
1891 ptr += sizeof(*tlv);
1892 ptr += sizeof(*cmd);
1895 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
1896 tlv->len = __cpu_to_le16(ac_tlv_len);
1897 ac = (void *)tlv->value;
1899 ptr += sizeof(*tlv);
1900 for (i = 0; i < num_ac; i++)
1901 ptr = ath10k_wmi_tlv_put_uapsd_ac(ar, ptr, &args[i]);
1903 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev sta uapsd auto trigger\n");
1907 static void *ath10k_wmi_tlv_put_wmm(void *ptr,
1908 const struct wmi_wmm_params_arg *arg)
1910 struct wmi_wmm_params *wmm;
1911 struct wmi_tlv *tlv;
1914 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS);
1915 tlv->len = __cpu_to_le16(sizeof(*wmm));
1916 wmm = (void *)tlv->value;
1917 ath10k_wmi_set_wmm_param(wmm, arg);
1919 return ptr + sizeof(*tlv) + sizeof(*wmm);
1922 static struct sk_buff *
1923 ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k *ar, u32 vdev_id,
1924 const struct wmi_wmm_params_all_arg *arg)
1926 struct wmi_tlv_vdev_set_wmm_cmd *cmd;
1927 struct wmi_tlv *tlv;
1928 struct sk_buff *skb;
1932 len = sizeof(*tlv) + sizeof(*cmd);
1933 skb = ath10k_wmi_alloc_skb(ar, len);
1935 return ERR_PTR(-ENOMEM);
1937 ptr = (void *)skb->data;
1939 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD);
1940 tlv->len = __cpu_to_le16(sizeof(*cmd));
1941 cmd = (void *)tlv->value;
1942 cmd->vdev_id = __cpu_to_le32(vdev_id);
1944 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[0].params, &arg->ac_be);
1945 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[1].params, &arg->ac_bk);
1946 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[2].params, &arg->ac_vi);
1947 ath10k_wmi_set_wmm_param(&cmd->vdev_wmm_params[3].params, &arg->ac_vo);
1949 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv vdev wmm conf\n");
1953 static struct sk_buff *
1954 ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k *ar,
1955 const struct wmi_sta_keepalive_arg *arg)
1957 struct wmi_tlv_sta_keepalive_cmd *cmd;
1958 struct wmi_sta_keepalive_arp_resp *arp;
1959 struct sk_buff *skb;
1960 struct wmi_tlv *tlv;
1964 len = sizeof(*tlv) + sizeof(*cmd) +
1965 sizeof(*tlv) + sizeof(*arp);
1966 skb = ath10k_wmi_alloc_skb(ar, len);
1968 return ERR_PTR(-ENOMEM);
1970 ptr = (void *)skb->data;
1972 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD);
1973 tlv->len = __cpu_to_le16(sizeof(*cmd));
1974 cmd = (void *)tlv->value;
1975 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
1976 cmd->enabled = __cpu_to_le32(arg->enabled);
1977 cmd->method = __cpu_to_le32(arg->method);
1978 cmd->interval = __cpu_to_le32(arg->interval);
1980 ptr += sizeof(*tlv);
1981 ptr += sizeof(*cmd);
1984 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE);
1985 tlv->len = __cpu_to_le16(sizeof(*arp));
1986 arp = (void *)tlv->value;
1988 arp->src_ip4_addr = arg->src_ip4_addr;
1989 arp->dest_ip4_addr = arg->dest_ip4_addr;
1990 ether_addr_copy(arp->dest_mac_addr.addr, arg->dest_mac_addr);
1992 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv sta keepalive vdev %d enabled %d method %d inverval %d\n",
1993 arg->vdev_id, arg->enabled, arg->method, arg->interval);
1997 static struct sk_buff *
1998 ath10k_wmi_tlv_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
1999 const u8 peer_addr[ETH_ALEN],
2000 enum wmi_peer_type peer_type)
2002 struct wmi_tlv_peer_create_cmd *cmd;
2003 struct wmi_tlv *tlv;
2004 struct sk_buff *skb;
2006 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2008 return ERR_PTR(-ENOMEM);
2010 tlv = (void *)skb->data;
2011 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD);
2012 tlv->len = __cpu_to_le16(sizeof(*cmd));
2013 cmd = (void *)tlv->value;
2014 cmd->vdev_id = __cpu_to_le32(vdev_id);
2015 cmd->peer_type = __cpu_to_le32(peer_type);
2016 ether_addr_copy(cmd->peer_addr.addr, peer_addr);
2018 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer create\n");
2022 static struct sk_buff *
2023 ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
2024 const u8 peer_addr[ETH_ALEN])
2026 struct wmi_peer_delete_cmd *cmd;
2027 struct wmi_tlv *tlv;
2028 struct sk_buff *skb;
2030 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2032 return ERR_PTR(-ENOMEM);
2034 tlv = (void *)skb->data;
2035 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD);
2036 tlv->len = __cpu_to_le16(sizeof(*cmd));
2037 cmd = (void *)tlv->value;
2038 cmd->vdev_id = __cpu_to_le32(vdev_id);
2039 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2041 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer delete\n");
2045 static struct sk_buff *
2046 ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
2047 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
2049 struct wmi_peer_flush_tids_cmd *cmd;
2050 struct wmi_tlv *tlv;
2051 struct sk_buff *skb;
2053 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2055 return ERR_PTR(-ENOMEM);
2057 tlv = (void *)skb->data;
2058 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD);
2059 tlv->len = __cpu_to_le16(sizeof(*cmd));
2060 cmd = (void *)tlv->value;
2061 cmd->vdev_id = __cpu_to_le32(vdev_id);
2062 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
2063 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2065 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer flush\n");
2069 static struct sk_buff *
2070 ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
2071 const u8 *peer_addr,
2072 enum wmi_peer_param param_id,
2075 struct wmi_peer_set_param_cmd *cmd;
2076 struct wmi_tlv *tlv;
2077 struct sk_buff *skb;
2079 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2081 return ERR_PTR(-ENOMEM);
2083 tlv = (void *)skb->data;
2084 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD);
2085 tlv->len = __cpu_to_le16(sizeof(*cmd));
2086 cmd = (void *)tlv->value;
2087 cmd->vdev_id = __cpu_to_le32(vdev_id);
2088 cmd->param_id = __cpu_to_le32(param_id);
2089 cmd->param_value = __cpu_to_le32(param_value);
2090 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
2092 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer set param\n");
2096 static struct sk_buff *
2097 ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k *ar,
2098 const struct wmi_peer_assoc_complete_arg *arg)
2100 struct wmi_tlv_peer_assoc_cmd *cmd;
2101 struct wmi_vht_rate_set *vht_rate;
2102 struct wmi_tlv *tlv;
2103 struct sk_buff *skb;
2104 size_t len, legacy_rate_len, ht_rate_len;
2107 if (arg->peer_mpdu_density > 16)
2108 return ERR_PTR(-EINVAL);
2109 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
2110 return ERR_PTR(-EINVAL);
2111 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
2112 return ERR_PTR(-EINVAL);
2114 legacy_rate_len = roundup(arg->peer_legacy_rates.num_rates,
2116 ht_rate_len = roundup(arg->peer_ht_rates.num_rates, sizeof(__le32));
2117 len = (sizeof(*tlv) + sizeof(*cmd)) +
2118 (sizeof(*tlv) + legacy_rate_len) +
2119 (sizeof(*tlv) + ht_rate_len) +
2120 (sizeof(*tlv) + sizeof(*vht_rate));
2121 skb = ath10k_wmi_alloc_skb(ar, len);
2123 return ERR_PTR(-ENOMEM);
2125 ptr = (void *)skb->data;
2127 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD);
2128 tlv->len = __cpu_to_le16(sizeof(*cmd));
2129 cmd = (void *)tlv->value;
2131 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2132 cmd->new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
2133 cmd->assoc_id = __cpu_to_le32(arg->peer_aid);
2134 cmd->flags = __cpu_to_le32(arg->peer_flags);
2135 cmd->caps = __cpu_to_le32(arg->peer_caps);
2136 cmd->listen_intval = __cpu_to_le32(arg->peer_listen_intval);
2137 cmd->ht_caps = __cpu_to_le32(arg->peer_ht_caps);
2138 cmd->max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
2139 cmd->mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
2140 cmd->rate_caps = __cpu_to_le32(arg->peer_rate_caps);
2141 cmd->nss = __cpu_to_le32(arg->peer_num_spatial_streams);
2142 cmd->vht_caps = __cpu_to_le32(arg->peer_vht_caps);
2143 cmd->phy_mode = __cpu_to_le32(arg->peer_phymode);
2144 cmd->num_legacy_rates = __cpu_to_le32(arg->peer_legacy_rates.num_rates);
2145 cmd->num_ht_rates = __cpu_to_le32(arg->peer_ht_rates.num_rates);
2146 ether_addr_copy(cmd->mac_addr.addr, arg->addr);
2148 ptr += sizeof(*tlv);
2149 ptr += sizeof(*cmd);
2152 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2153 tlv->len = __cpu_to_le16(legacy_rate_len);
2154 memcpy(tlv->value, arg->peer_legacy_rates.rates,
2155 arg->peer_legacy_rates.num_rates);
2157 ptr += sizeof(*tlv);
2158 ptr += legacy_rate_len;
2161 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2162 tlv->len = __cpu_to_le16(ht_rate_len);
2163 memcpy(tlv->value, arg->peer_ht_rates.rates,
2164 arg->peer_ht_rates.num_rates);
2166 ptr += sizeof(*tlv);
2170 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET);
2171 tlv->len = __cpu_to_le16(sizeof(*vht_rate));
2172 vht_rate = (void *)tlv->value;
2174 vht_rate->rx_max_rate = __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
2175 vht_rate->rx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
2176 vht_rate->tx_max_rate = __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
2177 vht_rate->tx_mcs_set = __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
2179 ptr += sizeof(*tlv);
2180 ptr += sizeof(*vht_rate);
2182 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv peer assoc\n");
2186 static struct sk_buff *
2187 ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
2188 enum wmi_sta_ps_mode psmode)
2190 struct wmi_sta_powersave_mode_cmd *cmd;
2191 struct wmi_tlv *tlv;
2192 struct sk_buff *skb;
2194 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2196 return ERR_PTR(-ENOMEM);
2198 tlv = (void *)skb->data;
2199 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD);
2200 tlv->len = __cpu_to_le16(sizeof(*cmd));
2201 cmd = (void *)tlv->value;
2202 cmd->vdev_id = __cpu_to_le32(vdev_id);
2203 cmd->sta_ps_mode = __cpu_to_le32(psmode);
2205 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set psmode\n");
2209 static struct sk_buff *
2210 ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
2211 enum wmi_sta_powersave_param param_id,
2214 struct wmi_sta_powersave_param_cmd *cmd;
2215 struct wmi_tlv *tlv;
2216 struct sk_buff *skb;
2218 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2220 return ERR_PTR(-ENOMEM);
2222 tlv = (void *)skb->data;
2223 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD);
2224 tlv->len = __cpu_to_le16(sizeof(*cmd));
2225 cmd = (void *)tlv->value;
2226 cmd->vdev_id = __cpu_to_le32(vdev_id);
2227 cmd->param_id = __cpu_to_le32(param_id);
2228 cmd->param_value = __cpu_to_le32(param_value);
2230 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv set sta ps\n");
2234 static struct sk_buff *
2235 ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
2236 enum wmi_ap_ps_peer_param param_id, u32 value)
2238 struct wmi_ap_ps_peer_cmd *cmd;
2239 struct wmi_tlv *tlv;
2240 struct sk_buff *skb;
2243 return ERR_PTR(-EINVAL);
2245 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2247 return ERR_PTR(-ENOMEM);
2249 tlv = (void *)skb->data;
2250 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD);
2251 tlv->len = __cpu_to_le16(sizeof(*cmd));
2252 cmd = (void *)tlv->value;
2253 cmd->vdev_id = __cpu_to_le32(vdev_id);
2254 cmd->param_id = __cpu_to_le32(param_id);
2255 cmd->param_value = __cpu_to_le32(value);
2256 ether_addr_copy(cmd->peer_macaddr.addr, mac);
2258 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv ap ps param\n");
2262 static struct sk_buff *
2263 ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k *ar,
2264 const struct wmi_scan_chan_list_arg *arg)
2266 struct wmi_tlv_scan_chan_list_cmd *cmd;
2267 struct wmi_channel *ci;
2268 struct wmi_channel_arg *ch;
2269 struct wmi_tlv *tlv;
2270 struct sk_buff *skb;
2271 size_t chans_len, len;
2275 chans_len = arg->n_channels * (sizeof(*tlv) + sizeof(*ci));
2276 len = (sizeof(*tlv) + sizeof(*cmd)) +
2277 (sizeof(*tlv) + chans_len);
2279 skb = ath10k_wmi_alloc_skb(ar, len);
2281 return ERR_PTR(-ENOMEM);
2283 ptr = (void *)skb->data;
2285 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD);
2286 tlv->len = __cpu_to_le16(sizeof(*cmd));
2287 cmd = (void *)tlv->value;
2288 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
2290 ptr += sizeof(*tlv);
2291 ptr += sizeof(*cmd);
2294 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2295 tlv->len = __cpu_to_le16(chans_len);
2296 chans = (void *)tlv->value;
2298 for (i = 0; i < arg->n_channels; i++) {
2299 ch = &arg->channels[i];
2302 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2303 tlv->len = __cpu_to_le16(sizeof(*ci));
2304 ci = (void *)tlv->value;
2306 ath10k_wmi_put_wmi_channel(ci, ch);
2308 chans += sizeof(*tlv);
2309 chans += sizeof(*ci);
2312 ptr += sizeof(*tlv);
2315 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv scan chan list\n");
2319 static struct sk_buff *
2320 ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id,
2321 const void *bcn, size_t bcn_len,
2322 u32 bcn_paddr, bool dtim_zero,
2326 struct wmi_bcn_tx_ref_cmd *cmd;
2327 struct wmi_tlv *tlv;
2328 struct sk_buff *skb;
2329 struct ieee80211_hdr *hdr;
2332 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2334 return ERR_PTR(-ENOMEM);
2336 hdr = (struct ieee80211_hdr *)bcn;
2337 fc = le16_to_cpu(hdr->frame_control);
2339 tlv = (void *)skb->data;
2340 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD);
2341 tlv->len = __cpu_to_le16(sizeof(*cmd));
2342 cmd = (void *)tlv->value;
2343 cmd->vdev_id = __cpu_to_le32(vdev_id);
2344 cmd->data_len = __cpu_to_le32(bcn_len);
2345 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
2347 cmd->frame_control = __cpu_to_le32(fc);
2351 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
2354 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
2356 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv beacon dma\n");
2360 static struct sk_buff *
2361 ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k *ar,
2362 const struct wmi_wmm_params_all_arg *arg)
2364 struct wmi_tlv_pdev_set_wmm_cmd *cmd;
2365 struct wmi_wmm_params *wmm;
2366 struct wmi_tlv *tlv;
2367 struct sk_buff *skb;
2371 len = (sizeof(*tlv) + sizeof(*cmd)) +
2372 (4 * (sizeof(*tlv) + sizeof(*wmm)));
2373 skb = ath10k_wmi_alloc_skb(ar, len);
2375 return ERR_PTR(-ENOMEM);
2377 ptr = (void *)skb->data;
2380 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD);
2381 tlv->len = __cpu_to_le16(sizeof(*cmd));
2382 cmd = (void *)tlv->value;
2384 /* nothing to set here */
2386 ptr += sizeof(*tlv);
2387 ptr += sizeof(*cmd);
2389 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_be);
2390 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_bk);
2391 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vi);
2392 ptr = ath10k_wmi_tlv_put_wmm(ptr, &arg->ac_vo);
2394 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pdev set wmm\n");
2398 static struct sk_buff *
2399 ath10k_wmi_tlv_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
2401 struct wmi_request_stats_cmd *cmd;
2402 struct wmi_tlv *tlv;
2403 struct sk_buff *skb;
2405 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2407 return ERR_PTR(-ENOMEM);
2409 tlv = (void *)skb->data;
2410 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD);
2411 tlv->len = __cpu_to_le16(sizeof(*cmd));
2412 cmd = (void *)tlv->value;
2413 cmd->stats_id = __cpu_to_le32(stats_mask);
2415 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv request stats\n");
2419 static struct sk_buff *
2420 ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k *ar,
2421 enum wmi_force_fw_hang_type type,
2424 struct wmi_force_fw_hang_cmd *cmd;
2425 struct wmi_tlv *tlv;
2426 struct sk_buff *skb;
2428 skb = ath10k_wmi_alloc_skb(ar, sizeof(*tlv) + sizeof(*cmd));
2430 return ERR_PTR(-ENOMEM);
2432 tlv = (void *)skb->data;
2433 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD);
2434 tlv->len = __cpu_to_le16(sizeof(*cmd));
2435 cmd = (void *)tlv->value;
2436 cmd->type = __cpu_to_le32(type);
2437 cmd->delay_ms = __cpu_to_le32(delay_ms);
2439 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv force fw hang\n");
2443 static struct sk_buff *
2444 ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
2446 struct wmi_tlv_dbglog_cmd *cmd;
2447 struct wmi_tlv *tlv;
2448 struct sk_buff *skb;
2449 size_t len, bmap_len;
2453 if (module_enable) {
2454 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2456 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE);
2458 value = WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
2459 WMI_TLV_DBGLOG_ALL_MODULES,
2460 WMI_TLV_DBGLOG_LOG_LEVEL_WARN);
2464 len = sizeof(*tlv) + sizeof(*cmd) + sizeof(*tlv) + bmap_len;
2465 skb = ath10k_wmi_alloc_skb(ar, len);
2467 return ERR_PTR(-ENOMEM);
2469 ptr = (void *)skb->data;
2472 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD);
2473 tlv->len = __cpu_to_le16(sizeof(*cmd));
2474 cmd = (void *)tlv->value;
2475 cmd->param = __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL);
2476 cmd->value = __cpu_to_le32(value);
2478 ptr += sizeof(*tlv);
2479 ptr += sizeof(*cmd);
2482 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
2483 tlv->len = __cpu_to_le16(bmap_len);
2485 /* nothing to do here */
2487 ptr += sizeof(*tlv);
2488 ptr += sizeof(bmap_len);
2490 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv dbglog value 0x%08x\n", value);
2494 static struct sk_buff *
2495 ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k *ar, u32 filter)
2497 struct wmi_tlv_pktlog_enable *cmd;
2498 struct wmi_tlv *tlv;
2499 struct sk_buff *skb;
2503 len = sizeof(*tlv) + sizeof(*cmd);
2504 skb = ath10k_wmi_alloc_skb(ar, len);
2506 return ERR_PTR(-ENOMEM);
2508 ptr = (void *)skb->data;
2510 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD);
2511 tlv->len = __cpu_to_le16(sizeof(*cmd));
2512 cmd = (void *)tlv->value;
2513 cmd->filter = __cpu_to_le32(filter);
2515 ptr += sizeof(*tlv);
2516 ptr += sizeof(*cmd);
2518 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog enable filter 0x%08x\n",
2523 static struct sk_buff *
2524 ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k *ar)
2526 struct wmi_tlv_pktlog_disable *cmd;
2527 struct wmi_tlv *tlv;
2528 struct sk_buff *skb;
2532 len = sizeof(*tlv) + sizeof(*cmd);
2533 skb = ath10k_wmi_alloc_skb(ar, len);
2535 return ERR_PTR(-ENOMEM);
2537 ptr = (void *)skb->data;
2539 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD);
2540 tlv->len = __cpu_to_le16(sizeof(*cmd));
2541 cmd = (void *)tlv->value;
2543 ptr += sizeof(*tlv);
2544 ptr += sizeof(*cmd);
2546 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv pktlog disable\n");
2550 static struct sk_buff *
2551 ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k *ar, u32 vdev_id,
2552 u32 tim_ie_offset, struct sk_buff *bcn,
2553 u32 prb_caps, u32 prb_erp, void *prb_ies,
2556 struct wmi_tlv_bcn_tmpl_cmd *cmd;
2557 struct wmi_tlv_bcn_prb_info *info;
2558 struct wmi_tlv *tlv;
2559 struct sk_buff *skb;
2563 if (WARN_ON(prb_ies_len > 0 && !prb_ies))
2564 return ERR_PTR(-EINVAL);
2566 len = sizeof(*tlv) + sizeof(*cmd) +
2567 sizeof(*tlv) + sizeof(*info) + prb_ies_len +
2568 sizeof(*tlv) + roundup(bcn->len, 4);
2569 skb = ath10k_wmi_alloc_skb(ar, len);
2571 return ERR_PTR(-ENOMEM);
2573 ptr = (void *)skb->data;
2575 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD);
2576 tlv->len = __cpu_to_le16(sizeof(*cmd));
2577 cmd = (void *)tlv->value;
2578 cmd->vdev_id = __cpu_to_le32(vdev_id);
2579 cmd->tim_ie_offset = __cpu_to_le32(tim_ie_offset);
2580 cmd->buf_len = __cpu_to_le32(bcn->len);
2582 ptr += sizeof(*tlv);
2583 ptr += sizeof(*cmd);
2585 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
2586 * then it is then impossible to pass original ie len.
2587 * This chunk is not used yet so if setting probe resp template yields
2588 * problems with beaconing or crashes firmware look here.
2591 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2592 tlv->len = __cpu_to_le16(sizeof(*info) + prb_ies_len);
2593 info = (void *)tlv->value;
2594 info->caps = __cpu_to_le32(prb_caps);
2595 info->erp = __cpu_to_le32(prb_erp);
2596 memcpy(info->ies, prb_ies, prb_ies_len);
2598 ptr += sizeof(*tlv);
2599 ptr += sizeof(*info);
2603 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2604 tlv->len = __cpu_to_le16(roundup(bcn->len, 4));
2605 memcpy(tlv->value, bcn->data, bcn->len);
2607 /* FIXME: Adjust TSF? */
2609 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv bcn tmpl vdev_id %i\n",
2614 static struct sk_buff *
2615 ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k *ar, u32 vdev_id,
2616 struct sk_buff *prb)
2618 struct wmi_tlv_prb_tmpl_cmd *cmd;
2619 struct wmi_tlv_bcn_prb_info *info;
2620 struct wmi_tlv *tlv;
2621 struct sk_buff *skb;
2625 len = sizeof(*tlv) + sizeof(*cmd) +
2626 sizeof(*tlv) + sizeof(*info) +
2627 sizeof(*tlv) + roundup(prb->len, 4);
2628 skb = ath10k_wmi_alloc_skb(ar, len);
2630 return ERR_PTR(-ENOMEM);
2632 ptr = (void *)skb->data;
2634 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD);
2635 tlv->len = __cpu_to_le16(sizeof(*cmd));
2636 cmd = (void *)tlv->value;
2637 cmd->vdev_id = __cpu_to_le32(vdev_id);
2638 cmd->buf_len = __cpu_to_le32(prb->len);
2640 ptr += sizeof(*tlv);
2641 ptr += sizeof(*cmd);
2644 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO);
2645 tlv->len = __cpu_to_le16(sizeof(*info));
2646 info = (void *)tlv->value;
2650 ptr += sizeof(*tlv);
2651 ptr += sizeof(*info);
2654 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2655 tlv->len = __cpu_to_le16(roundup(prb->len, 4));
2656 memcpy(tlv->value, prb->data, prb->len);
2658 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv prb tmpl vdev_id %i\n",
2663 static struct sk_buff *
2664 ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k *ar, u32 vdev_id,
2667 struct wmi_tlv_p2p_go_bcn_ie *cmd;
2668 struct wmi_tlv *tlv;
2669 struct sk_buff *skb;
2673 len = sizeof(*tlv) + sizeof(*cmd) +
2674 sizeof(*tlv) + roundup(p2p_ie[1] + 2, 4);
2675 skb = ath10k_wmi_alloc_skb(ar, len);
2677 return ERR_PTR(-ENOMEM);
2679 ptr = (void *)skb->data;
2681 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE);
2682 tlv->len = __cpu_to_le16(sizeof(*cmd));
2683 cmd = (void *)tlv->value;
2684 cmd->vdev_id = __cpu_to_le32(vdev_id);
2685 cmd->ie_len = __cpu_to_le32(p2p_ie[1] + 2);
2687 ptr += sizeof(*tlv);
2688 ptr += sizeof(*cmd);
2691 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
2692 tlv->len = __cpu_to_le16(roundup(p2p_ie[1] + 2, 4));
2693 memcpy(tlv->value, p2p_ie, p2p_ie[1] + 2);
2695 ptr += sizeof(*tlv);
2696 ptr += roundup(p2p_ie[1] + 2, 4);
2698 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv p2p go bcn ie for vdev %i\n",
2703 static struct sk_buff *
2704 ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
2705 enum wmi_tdls_state state)
2707 struct wmi_tdls_set_state_cmd *cmd;
2708 struct wmi_tlv *tlv;
2709 struct sk_buff *skb;
2712 /* Set to options from wmi_tlv_tdls_options,
2713 * for now none of them are enabled.
2717 len = sizeof(*tlv) + sizeof(*cmd);
2718 skb = ath10k_wmi_alloc_skb(ar, len);
2720 return ERR_PTR(-ENOMEM);
2722 ptr = (void *)skb->data;
2724 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD);
2725 tlv->len = __cpu_to_le16(sizeof(*cmd));
2727 cmd = (void *)tlv->value;
2728 cmd->vdev_id = __cpu_to_le32(vdev_id);
2729 cmd->state = __cpu_to_le32(state);
2730 cmd->notification_interval_ms = __cpu_to_le32(5000);
2731 cmd->tx_discovery_threshold = __cpu_to_le32(100);
2732 cmd->tx_teardown_threshold = __cpu_to_le32(5);
2733 cmd->rssi_teardown_threshold = __cpu_to_le32(-75);
2734 cmd->rssi_delta = __cpu_to_le32(-20);
2735 cmd->tdls_options = __cpu_to_le32(options);
2736 cmd->tdls_peer_traffic_ind_window = __cpu_to_le32(2);
2737 cmd->tdls_peer_traffic_response_timeout_ms = __cpu_to_le32(5000);
2738 cmd->tdls_puapsd_mask = __cpu_to_le32(0xf);
2739 cmd->tdls_puapsd_inactivity_time_ms = __cpu_to_le32(0);
2740 cmd->tdls_puapsd_rx_frame_threshold = __cpu_to_le32(10);
2742 ptr += sizeof(*tlv);
2743 ptr += sizeof(*cmd);
2745 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv update fw tdls state %d for vdev %i\n",
2750 static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
2754 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
2755 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VO;
2756 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI)
2757 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_VI;
2758 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
2759 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BK;
2760 if (uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
2761 peer_qos |= WMI_TLV_TDLS_PEER_QOS_AC_BE;
2763 peer_qos |= SM(sp, WMI_TLV_TDLS_PEER_SP);
2768 static struct sk_buff *
2769 ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k *ar,
2770 const struct wmi_tdls_peer_update_cmd_arg *arg,
2771 const struct wmi_tdls_peer_capab_arg *cap,
2772 const struct wmi_channel_arg *chan_arg)
2774 struct wmi_tdls_peer_update_cmd *cmd;
2775 struct wmi_tdls_peer_capab *peer_cap;
2776 struct wmi_channel *chan;
2777 struct wmi_tlv *tlv;
2778 struct sk_buff *skb;
2784 len = sizeof(*tlv) + sizeof(*cmd) +
2785 sizeof(*tlv) + sizeof(*peer_cap) +
2786 sizeof(*tlv) + cap->peer_chan_len * sizeof(*chan);
2788 skb = ath10k_wmi_alloc_skb(ar, len);
2790 return ERR_PTR(-ENOMEM);
2792 ptr = (void *)skb->data;
2794 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD);
2795 tlv->len = __cpu_to_le16(sizeof(*cmd));
2797 cmd = (void *)tlv->value;
2798 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
2799 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
2800 cmd->peer_state = __cpu_to_le32(arg->peer_state);
2802 ptr += sizeof(*tlv);
2803 ptr += sizeof(*cmd);
2806 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES);
2807 tlv->len = __cpu_to_le16(sizeof(*peer_cap));
2808 peer_cap = (void *)tlv->value;
2809 peer_qos = ath10k_wmi_tlv_prepare_peer_qos(cap->peer_uapsd_queues,
2811 peer_cap->peer_qos = __cpu_to_le32(peer_qos);
2812 peer_cap->buff_sta_support = __cpu_to_le32(cap->buff_sta_support);
2813 peer_cap->off_chan_support = __cpu_to_le32(cap->off_chan_support);
2814 peer_cap->peer_curr_operclass = __cpu_to_le32(cap->peer_curr_operclass);
2815 peer_cap->self_curr_operclass = __cpu_to_le32(cap->self_curr_operclass);
2816 peer_cap->peer_chan_len = __cpu_to_le32(cap->peer_chan_len);
2817 peer_cap->peer_operclass_len = __cpu_to_le32(cap->peer_operclass_len);
2819 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++)
2820 peer_cap->peer_operclass[i] = cap->peer_operclass[i];
2822 peer_cap->is_peer_responder = __cpu_to_le32(cap->is_peer_responder);
2823 peer_cap->pref_offchan_num = __cpu_to_le32(cap->pref_offchan_num);
2824 peer_cap->pref_offchan_bw = __cpu_to_le32(cap->pref_offchan_bw);
2826 ptr += sizeof(*tlv);
2827 ptr += sizeof(*peer_cap);
2830 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2831 tlv->len = __cpu_to_le16(cap->peer_chan_len * sizeof(*chan));
2833 ptr += sizeof(*tlv);
2835 for (i = 0; i < cap->peer_chan_len; i++) {
2837 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL);
2838 tlv->len = __cpu_to_le16(sizeof(*chan));
2839 chan = (void *)tlv->value;
2840 ath10k_wmi_put_wmi_channel(chan, &chan_arg[i]);
2842 ptr += sizeof(*tlv);
2843 ptr += sizeof(*chan);
2846 ath10k_dbg(ar, ATH10K_DBG_WMI,
2847 "wmi tlv tdls peer update vdev %i state %d n_chans %u\n",
2848 arg->vdev_id, arg->peer_state, cap->peer_chan_len);
2852 static struct sk_buff *
2853 ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k *ar)
2855 struct wmi_tlv_wow_enable_cmd *cmd;
2856 struct wmi_tlv *tlv;
2857 struct sk_buff *skb;
2860 len = sizeof(*tlv) + sizeof(*cmd);
2861 skb = ath10k_wmi_alloc_skb(ar, len);
2863 return ERR_PTR(-ENOMEM);
2865 tlv = (struct wmi_tlv *)skb->data;
2866 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD);
2867 tlv->len = __cpu_to_le16(sizeof(*cmd));
2868 cmd = (void *)tlv->value;
2870 cmd->enable = __cpu_to_le32(1);
2872 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow enable\n");
2876 static struct sk_buff *
2877 ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,
2879 enum wmi_wow_wakeup_event event,
2882 struct wmi_tlv_wow_add_del_event_cmd *cmd;
2883 struct wmi_tlv *tlv;
2884 struct sk_buff *skb;
2887 len = sizeof(*tlv) + sizeof(*cmd);
2888 skb = ath10k_wmi_alloc_skb(ar, len);
2890 return ERR_PTR(-ENOMEM);
2892 tlv = (struct wmi_tlv *)skb->data;
2893 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD);
2894 tlv->len = __cpu_to_le16(sizeof(*cmd));
2895 cmd = (void *)tlv->value;
2897 cmd->vdev_id = __cpu_to_le32(vdev_id);
2898 cmd->is_add = __cpu_to_le32(enable);
2899 cmd->event_bitmap = __cpu_to_le32(1 << event);
2901 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
2902 wow_wakeup_event(event), enable, vdev_id);
2906 static struct sk_buff *
2907 ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k *ar)
2909 struct wmi_tlv_wow_host_wakeup_ind *cmd;
2910 struct wmi_tlv *tlv;
2911 struct sk_buff *skb;
2914 len = sizeof(*tlv) + sizeof(*cmd);
2915 skb = ath10k_wmi_alloc_skb(ar, len);
2917 return ERR_PTR(-ENOMEM);
2919 tlv = (struct wmi_tlv *)skb->data;
2920 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
2921 tlv->len = __cpu_to_le16(sizeof(*cmd));
2922 cmd = (void *)tlv->value;
2924 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
2928 static struct sk_buff *
2929 ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k *ar, u32 vdev_id,
2930 u32 pattern_id, const u8 *pattern,
2931 const u8 *bitmask, int pattern_len,
2934 struct wmi_tlv_wow_add_pattern_cmd *cmd;
2935 struct wmi_tlv_wow_bitmap_pattern *bitmap;
2936 struct wmi_tlv *tlv;
2937 struct sk_buff *skb;
2941 len = sizeof(*tlv) + sizeof(*cmd) +
2942 sizeof(*tlv) + /* array struct */
2943 sizeof(*tlv) + sizeof(*bitmap) + /* bitmap */
2944 sizeof(*tlv) + /* empty ipv4 sync */
2945 sizeof(*tlv) + /* empty ipv6 sync */
2946 sizeof(*tlv) + /* empty magic */
2947 sizeof(*tlv) + /* empty info timeout */
2948 sizeof(*tlv) + sizeof(u32); /* ratelimit interval */
2950 skb = ath10k_wmi_alloc_skb(ar, len);
2952 return ERR_PTR(-ENOMEM);
2955 ptr = (void *)skb->data;
2957 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD);
2958 tlv->len = __cpu_to_le16(sizeof(*cmd));
2959 cmd = (void *)tlv->value;
2961 cmd->vdev_id = __cpu_to_le32(vdev_id);
2962 cmd->pattern_id = __cpu_to_le32(pattern_id);
2963 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
2965 ptr += sizeof(*tlv);
2966 ptr += sizeof(*cmd);
2970 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2971 tlv->len = __cpu_to_le16(sizeof(*tlv) + sizeof(*bitmap));
2973 ptr += sizeof(*tlv);
2976 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T);
2977 tlv->len = __cpu_to_le16(sizeof(*bitmap));
2978 bitmap = (void *)tlv->value;
2980 memcpy(bitmap->patternbuf, pattern, pattern_len);
2981 memcpy(bitmap->bitmaskbuf, bitmask, pattern_len);
2982 bitmap->pattern_offset = __cpu_to_le32(pattern_offset);
2983 bitmap->pattern_len = __cpu_to_le32(pattern_len);
2984 bitmap->bitmask_len = __cpu_to_le32(pattern_len);
2985 bitmap->pattern_id = __cpu_to_le32(pattern_id);
2987 ptr += sizeof(*tlv);
2988 ptr += sizeof(*bitmap);
2992 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
2993 tlv->len = __cpu_to_le16(0);
2995 ptr += sizeof(*tlv);
2999 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3000 tlv->len = __cpu_to_le16(0);
3002 ptr += sizeof(*tlv);
3006 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
3007 tlv->len = __cpu_to_le16(0);
3009 ptr += sizeof(*tlv);
3011 /* pattern info timeout */
3013 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3014 tlv->len = __cpu_to_le16(0);
3016 ptr += sizeof(*tlv);
3018 /* ratelimit interval */
3020 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
3021 tlv->len = __cpu_to_le16(sizeof(u32));
3023 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n",
3024 vdev_id, pattern_id, pattern_offset);
3028 static struct sk_buff *
3029 ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k *ar, u32 vdev_id,
3032 struct wmi_tlv_wow_del_pattern_cmd *cmd;
3033 struct wmi_tlv *tlv;
3034 struct sk_buff *skb;
3037 len = sizeof(*tlv) + sizeof(*cmd);
3038 skb = ath10k_wmi_alloc_skb(ar, len);
3040 return ERR_PTR(-ENOMEM);
3042 tlv = (struct wmi_tlv *)skb->data;
3043 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD);
3044 tlv->len = __cpu_to_le16(sizeof(*cmd));
3045 cmd = (void *)tlv->value;
3047 cmd->vdev_id = __cpu_to_le32(vdev_id);
3048 cmd->pattern_id = __cpu_to_le32(pattern_id);
3049 cmd->pattern_type = __cpu_to_le32(WOW_BITMAP_PATTERN);
3051 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n",
3052 vdev_id, pattern_id);
3056 static struct sk_buff *
3057 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable)
3059 struct wmi_tlv_adaptive_qcs *cmd;
3060 struct wmi_tlv *tlv;
3061 struct sk_buff *skb;
3065 len = sizeof(*tlv) + sizeof(*cmd);
3066 skb = ath10k_wmi_alloc_skb(ar, len);
3068 return ERR_PTR(-ENOMEM);
3070 ptr = (void *)skb->data;
3072 tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD);
3073 tlv->len = __cpu_to_le16(sizeof(*cmd));
3074 cmd = (void *)tlv->value;
3075 cmd->enable = __cpu_to_le32(enable ? 1 : 0);
3077 ptr += sizeof(*tlv);
3078 ptr += sizeof(*cmd);
3080 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv adaptive qcs %d\n", enable);
3088 static struct wmi_cmd_map wmi_tlv_cmd_map = {
3089 .init_cmdid = WMI_TLV_INIT_CMDID,
3090 .start_scan_cmdid = WMI_TLV_START_SCAN_CMDID,
3091 .stop_scan_cmdid = WMI_TLV_STOP_SCAN_CMDID,
3092 .scan_chan_list_cmdid = WMI_TLV_SCAN_CHAN_LIST_CMDID,
3093 .scan_sch_prio_tbl_cmdid = WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID,
3094 .pdev_set_regdomain_cmdid = WMI_TLV_PDEV_SET_REGDOMAIN_CMDID,
3095 .pdev_set_channel_cmdid = WMI_TLV_PDEV_SET_CHANNEL_CMDID,
3096 .pdev_set_param_cmdid = WMI_TLV_PDEV_SET_PARAM_CMDID,
3097 .pdev_pktlog_enable_cmdid = WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID,
3098 .pdev_pktlog_disable_cmdid = WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID,
3099 .pdev_set_wmm_params_cmdid = WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID,
3100 .pdev_set_ht_cap_ie_cmdid = WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID,
3101 .pdev_set_vht_cap_ie_cmdid = WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID,
3102 .pdev_set_dscp_tid_map_cmdid = WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID,
3103 .pdev_set_quiet_mode_cmdid = WMI_TLV_PDEV_SET_QUIET_MODE_CMDID,
3104 .pdev_green_ap_ps_enable_cmdid = WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID,
3105 .pdev_get_tpc_config_cmdid = WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID,
3106 .pdev_set_base_macaddr_cmdid = WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID,
3107 .vdev_create_cmdid = WMI_TLV_VDEV_CREATE_CMDID,
3108 .vdev_delete_cmdid = WMI_TLV_VDEV_DELETE_CMDID,
3109 .vdev_start_request_cmdid = WMI_TLV_VDEV_START_REQUEST_CMDID,
3110 .vdev_restart_request_cmdid = WMI_TLV_VDEV_RESTART_REQUEST_CMDID,
3111 .vdev_up_cmdid = WMI_TLV_VDEV_UP_CMDID,
3112 .vdev_stop_cmdid = WMI_TLV_VDEV_STOP_CMDID,
3113 .vdev_down_cmdid = WMI_TLV_VDEV_DOWN_CMDID,
3114 .vdev_set_param_cmdid = WMI_TLV_VDEV_SET_PARAM_CMDID,
3115 .vdev_install_key_cmdid = WMI_TLV_VDEV_INSTALL_KEY_CMDID,
3116 .peer_create_cmdid = WMI_TLV_PEER_CREATE_CMDID,
3117 .peer_delete_cmdid = WMI_TLV_PEER_DELETE_CMDID,
3118 .peer_flush_tids_cmdid = WMI_TLV_PEER_FLUSH_TIDS_CMDID,
3119 .peer_set_param_cmdid = WMI_TLV_PEER_SET_PARAM_CMDID,
3120 .peer_assoc_cmdid = WMI_TLV_PEER_ASSOC_CMDID,
3121 .peer_add_wds_entry_cmdid = WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID,
3122 .peer_remove_wds_entry_cmdid = WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID,
3123 .peer_mcast_group_cmdid = WMI_TLV_PEER_MCAST_GROUP_CMDID,
3124 .bcn_tx_cmdid = WMI_TLV_BCN_TX_CMDID,
3125 .pdev_send_bcn_cmdid = WMI_TLV_PDEV_SEND_BCN_CMDID,
3126 .bcn_tmpl_cmdid = WMI_TLV_BCN_TMPL_CMDID,
3127 .bcn_filter_rx_cmdid = WMI_TLV_BCN_FILTER_RX_CMDID,
3128 .prb_req_filter_rx_cmdid = WMI_TLV_PRB_REQ_FILTER_RX_CMDID,
3129 .mgmt_tx_cmdid = WMI_TLV_MGMT_TX_CMDID,
3130 .prb_tmpl_cmdid = WMI_TLV_PRB_TMPL_CMDID,
3131 .addba_clear_resp_cmdid = WMI_TLV_ADDBA_CLEAR_RESP_CMDID,
3132 .addba_send_cmdid = WMI_TLV_ADDBA_SEND_CMDID,
3133 .addba_status_cmdid = WMI_TLV_ADDBA_STATUS_CMDID,
3134 .delba_send_cmdid = WMI_TLV_DELBA_SEND_CMDID,
3135 .addba_set_resp_cmdid = WMI_TLV_ADDBA_SET_RESP_CMDID,
3136 .send_singleamsdu_cmdid = WMI_TLV_SEND_SINGLEAMSDU_CMDID,
3137 .sta_powersave_mode_cmdid = WMI_TLV_STA_POWERSAVE_MODE_CMDID,
3138 .sta_powersave_param_cmdid = WMI_TLV_STA_POWERSAVE_PARAM_CMDID,
3139 .sta_mimo_ps_mode_cmdid = WMI_TLV_STA_MIMO_PS_MODE_CMDID,
3140 .pdev_dfs_enable_cmdid = WMI_TLV_PDEV_DFS_ENABLE_CMDID,
3141 .pdev_dfs_disable_cmdid = WMI_TLV_PDEV_DFS_DISABLE_CMDID,
3142 .roam_scan_mode = WMI_TLV_ROAM_SCAN_MODE,
3143 .roam_scan_rssi_threshold = WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD,
3144 .roam_scan_period = WMI_TLV_ROAM_SCAN_PERIOD,
3145 .roam_scan_rssi_change_threshold =
3146 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD,
3147 .roam_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
3148 .ofl_scan_add_ap_profile = WMI_TLV_ROAM_AP_PROFILE,
3149 .ofl_scan_remove_ap_profile = WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE,
3150 .ofl_scan_period = WMI_TLV_OFL_SCAN_PERIOD,
3151 .p2p_dev_set_device_info = WMI_TLV_P2P_DEV_SET_DEVICE_INFO,
3152 .p2p_dev_set_discoverability = WMI_TLV_P2P_DEV_SET_DISCOVERABILITY,
3153 .p2p_go_set_beacon_ie = WMI_TLV_P2P_GO_SET_BEACON_IE,
3154 .p2p_go_set_probe_resp_ie = WMI_TLV_P2P_GO_SET_PROBE_RESP_IE,
3155 .p2p_set_vendor_ie_data_cmdid = WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID,
3156 .ap_ps_peer_param_cmdid = WMI_TLV_AP_PS_PEER_PARAM_CMDID,
3157 .ap_ps_peer_uapsd_coex_cmdid = WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID,
3158 .peer_rate_retry_sched_cmdid = WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID,
3159 .wlan_profile_trigger_cmdid = WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID,
3160 .wlan_profile_set_hist_intvl_cmdid =
3161 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
3162 .wlan_profile_get_profile_data_cmdid =
3163 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
3164 .wlan_profile_enable_profile_id_cmdid =
3165 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
3166 .wlan_profile_list_profile_id_cmdid =
3167 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID,
3168 .pdev_suspend_cmdid = WMI_TLV_PDEV_SUSPEND_CMDID,
3169 .pdev_resume_cmdid = WMI_TLV_PDEV_RESUME_CMDID,
3170 .add_bcn_filter_cmdid = WMI_TLV_ADD_BCN_FILTER_CMDID,
3171 .rmv_bcn_filter_cmdid = WMI_TLV_RMV_BCN_FILTER_CMDID,
3172 .wow_add_wake_pattern_cmdid = WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID,
3173 .wow_del_wake_pattern_cmdid = WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID,
3174 .wow_enable_disable_wake_event_cmdid =
3175 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID,
3176 .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID,
3177 .wow_hostwakeup_from_sleep_cmdid =
3178 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID,
3179 .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID,
3180 .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID,
3181 .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,
3182 .vdev_spectral_scan_enable_cmdid = WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID,
3183 .request_stats_cmdid = WMI_TLV_REQUEST_STATS_CMDID,
3184 .set_arp_ns_offload_cmdid = WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID,
3185 .network_list_offload_config_cmdid =
3186 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID,
3187 .gtk_offload_cmdid = WMI_TLV_GTK_OFFLOAD_CMDID,
3188 .csa_offload_enable_cmdid = WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID,
3189 .csa_offload_chanswitch_cmdid = WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID,
3190 .chatter_set_mode_cmdid = WMI_TLV_CHATTER_SET_MODE_CMDID,
3191 .peer_tid_addba_cmdid = WMI_TLV_PEER_TID_ADDBA_CMDID,
3192 .peer_tid_delba_cmdid = WMI_TLV_PEER_TID_DELBA_CMDID,
3193 .sta_dtim_ps_method_cmdid = WMI_TLV_STA_DTIM_PS_METHOD_CMDID,
3194 .sta_uapsd_auto_trig_cmdid = WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID,
3195 .sta_keepalive_cmd = WMI_TLV_STA_KEEPALIVE_CMDID,
3196 .echo_cmdid = WMI_TLV_ECHO_CMDID,
3197 .pdev_utf_cmdid = WMI_TLV_PDEV_UTF_CMDID,
3198 .dbglog_cfg_cmdid = WMI_TLV_DBGLOG_CFG_CMDID,
3199 .pdev_qvit_cmdid = WMI_TLV_PDEV_QVIT_CMDID,
3200 .pdev_ftm_intg_cmdid = WMI_TLV_PDEV_FTM_INTG_CMDID,
3201 .vdev_set_keepalive_cmdid = WMI_TLV_VDEV_SET_KEEPALIVE_CMDID,
3202 .vdev_get_keepalive_cmdid = WMI_TLV_VDEV_GET_KEEPALIVE_CMDID,
3203 .force_fw_hang_cmdid = WMI_TLV_FORCE_FW_HANG_CMDID,
3204 .gpio_config_cmdid = WMI_TLV_GPIO_CONFIG_CMDID,
3205 .gpio_output_cmdid = WMI_TLV_GPIO_OUTPUT_CMDID,
3206 .pdev_get_temperature_cmdid = WMI_TLV_CMD_UNSUPPORTED,
3207 .vdev_set_wmm_params_cmdid = WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID,
3208 .tdls_set_state_cmdid = WMI_TLV_TDLS_SET_STATE_CMDID,
3209 .tdls_peer_update_cmdid = WMI_TLV_TDLS_PEER_UPDATE_CMDID,
3210 .adaptive_qcs_cmdid = WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID,
3211 .scan_update_request_cmdid = WMI_CMD_UNSUPPORTED,
3212 .vdev_standby_response_cmdid = WMI_CMD_UNSUPPORTED,
3213 .vdev_resume_response_cmdid = WMI_CMD_UNSUPPORTED,
3214 .wlan_peer_caching_add_peer_cmdid = WMI_CMD_UNSUPPORTED,
3215 .wlan_peer_caching_evict_peer_cmdid = WMI_CMD_UNSUPPORTED,
3216 .wlan_peer_caching_restore_peer_cmdid = WMI_CMD_UNSUPPORTED,
3217 .wlan_peer_caching_print_all_peers_info_cmdid = WMI_CMD_UNSUPPORTED,
3218 .peer_update_wds_entry_cmdid = WMI_CMD_UNSUPPORTED,
3219 .peer_add_proxy_sta_entry_cmdid = WMI_CMD_UNSUPPORTED,
3220 .rtt_keepalive_cmdid = WMI_CMD_UNSUPPORTED,
3221 .oem_req_cmdid = WMI_CMD_UNSUPPORTED,
3222 .nan_cmdid = WMI_CMD_UNSUPPORTED,
3223 .vdev_ratemask_cmdid = WMI_CMD_UNSUPPORTED,
3224 .qboost_cfg_cmdid = WMI_CMD_UNSUPPORTED,
3225 .pdev_smart_ant_enable_cmdid = WMI_CMD_UNSUPPORTED,
3226 .pdev_smart_ant_set_rx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
3227 .peer_smart_ant_set_tx_antenna_cmdid = WMI_CMD_UNSUPPORTED,
3228 .peer_smart_ant_set_train_info_cmdid = WMI_CMD_UNSUPPORTED,
3229 .peer_smart_ant_set_node_config_ops_cmdid = WMI_CMD_UNSUPPORTED,
3230 .pdev_set_antenna_switch_table_cmdid = WMI_CMD_UNSUPPORTED,
3231 .pdev_set_ctl_table_cmdid = WMI_CMD_UNSUPPORTED,
3232 .pdev_set_mimogain_table_cmdid = WMI_CMD_UNSUPPORTED,
3233 .pdev_ratepwr_table_cmdid = WMI_CMD_UNSUPPORTED,
3234 .pdev_ratepwr_chainmsk_table_cmdid = WMI_CMD_UNSUPPORTED,
3235 .pdev_fips_cmdid = WMI_CMD_UNSUPPORTED,
3236 .tt_set_conf_cmdid = WMI_CMD_UNSUPPORTED,
3237 .fwtest_cmdid = WMI_CMD_UNSUPPORTED,
3238 .vdev_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
3239 .peer_atf_request_cmdid = WMI_CMD_UNSUPPORTED,
3240 .pdev_get_ani_cck_config_cmdid = WMI_CMD_UNSUPPORTED,
3241 .pdev_get_ani_ofdm_config_cmdid = WMI_CMD_UNSUPPORTED,
3242 .pdev_reserve_ast_entry_cmdid = WMI_CMD_UNSUPPORTED,
3245 static struct wmi_pdev_param_map wmi_tlv_pdev_param_map = {
3246 .tx_chain_mask = WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK,
3247 .rx_chain_mask = WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK,
3248 .txpower_limit2g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G,
3249 .txpower_limit5g = WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G,
3250 .txpower_scale = WMI_TLV_PDEV_PARAM_TXPOWER_SCALE,
3251 .beacon_gen_mode = WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE,
3252 .beacon_tx_mode = WMI_TLV_PDEV_PARAM_BEACON_TX_MODE,
3253 .resmgr_offchan_mode = WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE,
3254 .protection_mode = WMI_TLV_PDEV_PARAM_PROTECTION_MODE,
3255 .dynamic_bw = WMI_TLV_PDEV_PARAM_DYNAMIC_BW,
3256 .non_agg_sw_retry_th = WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH,
3257 .agg_sw_retry_th = WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH,
3258 .sta_kickout_th = WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH,
3259 .ac_aggrsize_scaling = WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING,
3260 .ltr_enable = WMI_TLV_PDEV_PARAM_LTR_ENABLE,
3261 .ltr_ac_latency_be = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE,
3262 .ltr_ac_latency_bk = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK,
3263 .ltr_ac_latency_vi = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI,
3264 .ltr_ac_latency_vo = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO,
3265 .ltr_ac_latency_timeout = WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT,
3266 .ltr_sleep_override = WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE,
3267 .ltr_rx_override = WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE,
3268 .ltr_tx_activity_timeout = WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT,
3269 .l1ss_enable = WMI_TLV_PDEV_PARAM_L1SS_ENABLE,
3270 .dsleep_enable = WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE,
3271 .pcielp_txbuf_flush = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH,
3272 .pcielp_txbuf_watermark = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3273 .pcielp_txbuf_tmo_en = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN,
3274 .pcielp_txbuf_tmo_value = WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE,
3275 .pdev_stats_update_period = WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD,
3276 .vdev_stats_update_period = WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD,
3277 .peer_stats_update_period = WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD,
3278 .bcnflt_stats_update_period =
3279 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD,
3280 .pmf_qos = WMI_TLV_PDEV_PARAM_PMF_QOS,
3281 .arp_ac_override = WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE,
3282 .dcs = WMI_TLV_PDEV_PARAM_DCS,
3283 .ani_enable = WMI_TLV_PDEV_PARAM_ANI_ENABLE,
3284 .ani_poll_period = WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD,
3285 .ani_listen_period = WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD,
3286 .ani_ofdm_level = WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL,
3287 .ani_cck_level = WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL,
3288 .dyntxchain = WMI_TLV_PDEV_PARAM_DYNTXCHAIN,
3289 .proxy_sta = WMI_TLV_PDEV_PARAM_PROXY_STA,
3290 .idle_ps_config = WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG,
3291 .power_gating_sleep = WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP,
3292 .fast_channel_reset = WMI_TLV_PDEV_PARAM_UNSUPPORTED,
3293 .burst_dur = WMI_TLV_PDEV_PARAM_BURST_DUR,
3294 .burst_enable = WMI_TLV_PDEV_PARAM_BURST_ENABLE,
3295 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
3296 .aggr_burst = WMI_PDEV_PARAM_UNSUPPORTED,
3297 .rx_decap_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3298 .smart_antenna_default_antenna = WMI_PDEV_PARAM_UNSUPPORTED,
3299 .igmpmld_override = WMI_PDEV_PARAM_UNSUPPORTED,
3300 .igmpmld_tid = WMI_PDEV_PARAM_UNSUPPORTED,
3301 .antenna_gain = WMI_PDEV_PARAM_UNSUPPORTED,
3302 .rx_filter = WMI_PDEV_PARAM_UNSUPPORTED,
3303 .set_mcast_to_ucast_tid = WMI_PDEV_PARAM_UNSUPPORTED,
3304 .proxy_sta_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3305 .set_mcast2ucast_mode = WMI_PDEV_PARAM_UNSUPPORTED,
3306 .set_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
3307 .remove_mcast2ucast_buffer = WMI_PDEV_PARAM_UNSUPPORTED,
3308 .peer_sta_ps_statechg_enable = WMI_PDEV_PARAM_UNSUPPORTED,
3309 .igmpmld_ac_override = WMI_PDEV_PARAM_UNSUPPORTED,
3310 .block_interbss = WMI_PDEV_PARAM_UNSUPPORTED,
3311 .set_disable_reset_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3312 .set_msdu_ttl_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3313 .set_ppdu_duration_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3314 .txbf_sound_period_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3315 .set_promisc_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3316 .set_burst_mode_cmdid = WMI_PDEV_PARAM_UNSUPPORTED,
3317 .en_stats = WMI_PDEV_PARAM_UNSUPPORTED,
3318 .mu_group_policy = WMI_PDEV_PARAM_UNSUPPORTED,
3319 .noise_detection = WMI_PDEV_PARAM_UNSUPPORTED,
3320 .noise_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
3321 .dpd_enable = WMI_PDEV_PARAM_UNSUPPORTED,
3322 .set_mcast_bcast_echo = WMI_PDEV_PARAM_UNSUPPORTED,
3323 .atf_strict_sch = WMI_PDEV_PARAM_UNSUPPORTED,
3324 .atf_sched_duration = WMI_PDEV_PARAM_UNSUPPORTED,
3325 .ant_plzn = WMI_PDEV_PARAM_UNSUPPORTED,
3326 .mgmt_retry_limit = WMI_PDEV_PARAM_UNSUPPORTED,
3327 .sensitivity_level = WMI_PDEV_PARAM_UNSUPPORTED,
3328 .signed_txpower_2g = WMI_PDEV_PARAM_UNSUPPORTED,
3329 .signed_txpower_5g = WMI_PDEV_PARAM_UNSUPPORTED,
3330 .enable_per_tid_amsdu = WMI_PDEV_PARAM_UNSUPPORTED,
3331 .enable_per_tid_ampdu = WMI_PDEV_PARAM_UNSUPPORTED,
3332 .cca_threshold = WMI_PDEV_PARAM_UNSUPPORTED,
3333 .rts_fixed_rate = WMI_PDEV_PARAM_UNSUPPORTED,
3334 .pdev_reset = WMI_PDEV_PARAM_UNSUPPORTED,
3335 .wapi_mbssid_offset = WMI_PDEV_PARAM_UNSUPPORTED,
3336 .arp_srcaddr = WMI_PDEV_PARAM_UNSUPPORTED,
3337 .arp_dstaddr = WMI_PDEV_PARAM_UNSUPPORTED,
3340 static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = {
3341 .rts_threshold = WMI_TLV_VDEV_PARAM_RTS_THRESHOLD,
3342 .fragmentation_threshold = WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
3343 .beacon_interval = WMI_TLV_VDEV_PARAM_BEACON_INTERVAL,
3344 .listen_interval = WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL,
3345 .multicast_rate = WMI_TLV_VDEV_PARAM_MULTICAST_RATE,
3346 .mgmt_tx_rate = WMI_TLV_VDEV_PARAM_MGMT_TX_RATE,
3347 .slot_time = WMI_TLV_VDEV_PARAM_SLOT_TIME,
3348 .preamble = WMI_TLV_VDEV_PARAM_PREAMBLE,
3349 .swba_time = WMI_TLV_VDEV_PARAM_SWBA_TIME,
3350 .wmi_vdev_stats_update_period = WMI_TLV_VDEV_STATS_UPDATE_PERIOD,
3351 .wmi_vdev_pwrsave_ageout_time = WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME,
3352 .wmi_vdev_host_swba_interval = WMI_TLV_VDEV_HOST_SWBA_INTERVAL,
3353 .dtim_period = WMI_TLV_VDEV_PARAM_DTIM_PERIOD,
3354 .wmi_vdev_oc_scheduler_air_time_limit =
3355 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT,
3356 .wds = WMI_TLV_VDEV_PARAM_WDS,
3357 .atim_window = WMI_TLV_VDEV_PARAM_ATIM_WINDOW,
3358 .bmiss_count_max = WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX,
3359 .bmiss_first_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT,
3360 .bmiss_final_bcnt = WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT,
3361 .feature_wmm = WMI_TLV_VDEV_PARAM_FEATURE_WMM,
3362 .chwidth = WMI_TLV_VDEV_PARAM_CHWIDTH,
3363 .chextoffset = WMI_TLV_VDEV_PARAM_CHEXTOFFSET,
3364 .disable_htprotection = WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION,
3365 .sta_quickkickout = WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT,
3366 .mgmt_rate = WMI_TLV_VDEV_PARAM_MGMT_RATE,
3367 .protection_mode = WMI_TLV_VDEV_PARAM_PROTECTION_MODE,
3368 .fixed_rate = WMI_TLV_VDEV_PARAM_FIXED_RATE,
3369 .sgi = WMI_TLV_VDEV_PARAM_SGI,
3370 .ldpc = WMI_TLV_VDEV_PARAM_LDPC,
3371 .tx_stbc = WMI_TLV_VDEV_PARAM_TX_STBC,
3372 .rx_stbc = WMI_TLV_VDEV_PARAM_RX_STBC,
3373 .intra_bss_fwd = WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD,
3374 .def_keyid = WMI_TLV_VDEV_PARAM_DEF_KEYID,
3375 .nss = WMI_TLV_VDEV_PARAM_NSS,
3376 .bcast_data_rate = WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE,
3377 .mcast_data_rate = WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE,
3378 .mcast_indicate = WMI_TLV_VDEV_PARAM_MCAST_INDICATE,
3379 .dhcp_indicate = WMI_TLV_VDEV_PARAM_DHCP_INDICATE,
3380 .unknown_dest_indicate = WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE,
3381 .ap_keepalive_min_idle_inactive_time_secs =
3382 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS,
3383 .ap_keepalive_max_idle_inactive_time_secs =
3384 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS,
3385 .ap_keepalive_max_unresponsive_time_secs =
3386 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS,
3387 .ap_enable_nawds = WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS,
3388 .mcast2ucast_set = WMI_TLV_VDEV_PARAM_UNSUPPORTED,
3389 .enable_rtscts = WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS,
3390 .txbf = WMI_TLV_VDEV_PARAM_TXBF,
3391 .packet_powersave = WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE,
3392 .drop_unencry = WMI_TLV_VDEV_PARAM_DROP_UNENCRY,
3393 .tx_encap_type = WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE,
3394 .ap_detect_out_of_sync_sleeping_sta_time_secs =
3395 WMI_TLV_VDEV_PARAM_UNSUPPORTED,
3396 .rc_num_retries = WMI_VDEV_PARAM_UNSUPPORTED,
3397 .cabq_maxdur = WMI_VDEV_PARAM_UNSUPPORTED,
3398 .mfptest_set = WMI_VDEV_PARAM_UNSUPPORTED,
3399 .rts_fixed_rate = WMI_VDEV_PARAM_UNSUPPORTED,
3400 .vht_sgimask = WMI_VDEV_PARAM_UNSUPPORTED,
3401 .vht80_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
3402 .early_rx_adjust_enable = WMI_VDEV_PARAM_UNSUPPORTED,
3403 .early_rx_tgt_bmiss_num = WMI_VDEV_PARAM_UNSUPPORTED,
3404 .early_rx_bmiss_sample_cycle = WMI_VDEV_PARAM_UNSUPPORTED,
3405 .early_rx_slop_step = WMI_VDEV_PARAM_UNSUPPORTED,
3406 .early_rx_init_slop = WMI_VDEV_PARAM_UNSUPPORTED,
3407 .early_rx_adjust_pause = WMI_VDEV_PARAM_UNSUPPORTED,
3408 .proxy_sta = WMI_VDEV_PARAM_UNSUPPORTED,
3409 .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED,
3410 .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED,
3411 .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED,
3414 static const struct wmi_ops wmi_tlv_ops = {
3415 .rx = ath10k_wmi_tlv_op_rx,
3416 .map_svc = wmi_tlv_svc_map,
3418 .pull_scan = ath10k_wmi_tlv_op_pull_scan_ev,
3419 .pull_mgmt_rx = ath10k_wmi_tlv_op_pull_mgmt_rx_ev,
3420 .pull_ch_info = ath10k_wmi_tlv_op_pull_ch_info_ev,
3421 .pull_vdev_start = ath10k_wmi_tlv_op_pull_vdev_start_ev,
3422 .pull_peer_kick = ath10k_wmi_tlv_op_pull_peer_kick_ev,
3423 .pull_swba = ath10k_wmi_tlv_op_pull_swba_ev,
3424 .pull_phyerr_hdr = ath10k_wmi_tlv_op_pull_phyerr_ev_hdr,
3425 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
3426 .pull_svc_rdy = ath10k_wmi_tlv_op_pull_svc_rdy_ev,
3427 .pull_rdy = ath10k_wmi_tlv_op_pull_rdy_ev,
3428 .pull_fw_stats = ath10k_wmi_tlv_op_pull_fw_stats,
3429 .pull_roam_ev = ath10k_wmi_tlv_op_pull_roam_ev,
3430 .pull_wow_event = ath10k_wmi_tlv_op_pull_wow_ev,
3431 .get_txbf_conf_scheme = ath10k_wmi_tlv_txbf_conf_scheme,
3433 .gen_pdev_suspend = ath10k_wmi_tlv_op_gen_pdev_suspend,
3434 .gen_pdev_resume = ath10k_wmi_tlv_op_gen_pdev_resume,
3435 .gen_pdev_set_rd = ath10k_wmi_tlv_op_gen_pdev_set_rd,
3436 .gen_pdev_set_param = ath10k_wmi_tlv_op_gen_pdev_set_param,
3437 .gen_init = ath10k_wmi_tlv_op_gen_init,
3438 .gen_start_scan = ath10k_wmi_tlv_op_gen_start_scan,
3439 .gen_stop_scan = ath10k_wmi_tlv_op_gen_stop_scan,
3440 .gen_vdev_create = ath10k_wmi_tlv_op_gen_vdev_create,
3441 .gen_vdev_delete = ath10k_wmi_tlv_op_gen_vdev_delete,
3442 .gen_vdev_start = ath10k_wmi_tlv_op_gen_vdev_start,
3443 .gen_vdev_stop = ath10k_wmi_tlv_op_gen_vdev_stop,
3444 .gen_vdev_up = ath10k_wmi_tlv_op_gen_vdev_up,
3445 .gen_vdev_down = ath10k_wmi_tlv_op_gen_vdev_down,
3446 .gen_vdev_set_param = ath10k_wmi_tlv_op_gen_vdev_set_param,
3447 .gen_vdev_install_key = ath10k_wmi_tlv_op_gen_vdev_install_key,
3448 .gen_vdev_wmm_conf = ath10k_wmi_tlv_op_gen_vdev_wmm_conf,
3449 .gen_peer_create = ath10k_wmi_tlv_op_gen_peer_create,
3450 .gen_peer_delete = ath10k_wmi_tlv_op_gen_peer_delete,
3451 .gen_peer_flush = ath10k_wmi_tlv_op_gen_peer_flush,
3452 .gen_peer_set_param = ath10k_wmi_tlv_op_gen_peer_set_param,
3453 .gen_peer_assoc = ath10k_wmi_tlv_op_gen_peer_assoc,
3454 .gen_set_psmode = ath10k_wmi_tlv_op_gen_set_psmode,
3455 .gen_set_sta_ps = ath10k_wmi_tlv_op_gen_set_sta_ps,
3456 .gen_set_ap_ps = ath10k_wmi_tlv_op_gen_set_ap_ps,
3457 .gen_scan_chan_list = ath10k_wmi_tlv_op_gen_scan_chan_list,
3458 .gen_beacon_dma = ath10k_wmi_tlv_op_gen_beacon_dma,
3459 .gen_pdev_set_wmm = ath10k_wmi_tlv_op_gen_pdev_set_wmm,
3460 .gen_request_stats = ath10k_wmi_tlv_op_gen_request_stats,
3461 .gen_force_fw_hang = ath10k_wmi_tlv_op_gen_force_fw_hang,
3462 /* .gen_mgmt_tx = not implemented; HTT is used */
3463 .gen_dbglog_cfg = ath10k_wmi_tlv_op_gen_dbglog_cfg,
3464 .gen_pktlog_enable = ath10k_wmi_tlv_op_gen_pktlog_enable,
3465 .gen_pktlog_disable = ath10k_wmi_tlv_op_gen_pktlog_disable,
3466 /* .gen_pdev_set_quiet_mode not implemented */
3467 /* .gen_pdev_get_temperature not implemented */
3468 /* .gen_addba_clear_resp not implemented */
3469 /* .gen_addba_send not implemented */
3470 /* .gen_addba_set_resp not implemented */
3471 /* .gen_delba_send not implemented */
3472 .gen_bcn_tmpl = ath10k_wmi_tlv_op_gen_bcn_tmpl,
3473 .gen_prb_tmpl = ath10k_wmi_tlv_op_gen_prb_tmpl,
3474 .gen_p2p_go_bcn_ie = ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie,
3475 .gen_vdev_sta_uapsd = ath10k_wmi_tlv_op_gen_vdev_sta_uapsd,
3476 .gen_sta_keepalive = ath10k_wmi_tlv_op_gen_sta_keepalive,
3477 .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable,
3478 .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event,
3479 .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
3480 .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern,
3481 .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern,
3482 .gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state,
3483 .gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update,
3484 .gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs,
3485 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
3486 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
3489 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
3490 .auth = WMI_TLV_PEER_AUTH,
3491 .qos = WMI_TLV_PEER_QOS,
3492 .need_ptk_4_way = WMI_TLV_PEER_NEED_PTK_4_WAY,
3493 .need_gtk_2_way = WMI_TLV_PEER_NEED_GTK_2_WAY,
3494 .apsd = WMI_TLV_PEER_APSD,
3495 .ht = WMI_TLV_PEER_HT,
3496 .bw40 = WMI_TLV_PEER_40MHZ,
3497 .stbc = WMI_TLV_PEER_STBC,
3498 .ldbc = WMI_TLV_PEER_LDPC,
3499 .dyn_mimops = WMI_TLV_PEER_DYN_MIMOPS,
3500 .static_mimops = WMI_TLV_PEER_STATIC_MIMOPS,
3501 .spatial_mux = WMI_TLV_PEER_SPATIAL_MUX,
3502 .vht = WMI_TLV_PEER_VHT,
3503 .bw80 = WMI_TLV_PEER_80MHZ,
3504 .pmf = WMI_TLV_PEER_PMF,
3511 void ath10k_wmi_tlv_attach(struct ath10k *ar)
3513 ar->wmi.cmd = &wmi_tlv_cmd_map;
3514 ar->wmi.vdev_param = &wmi_tlv_vdev_param_map;
3515 ar->wmi.pdev_param = &wmi_tlv_pdev_param_map;
3516 ar->wmi.ops = &wmi_tlv_ops;
3517 ar->wmi.peer_flags = &wmi_tlv_peer_flags_map;