1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
16 #include <linux/bitfield.h>
22 struct wmi_tlv_policy
{
26 static const struct wmi_tlv_policy wmi_tlv_policies
[] = {
27 [WMI_TLV_TAG_ARRAY_BYTE
]
29 [WMI_TLV_TAG_ARRAY_UINT32
]
31 [WMI_TLV_TAG_STRUCT_SCAN_EVENT
]
32 = { .min_len
= sizeof(struct wmi_scan_event
) },
33 [WMI_TLV_TAG_STRUCT_MGMT_RX_HDR
]
34 = { .min_len
= sizeof(struct wmi_tlv_mgmt_rx_ev
) },
35 [WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT
]
36 = { .min_len
= sizeof(struct wmi_chan_info_event
) },
37 [WMI_TLV_TAG_STRUCT_VDEV_START_RESPONSE_EVENT
]
38 = { .min_len
= sizeof(struct wmi_vdev_start_response_event
) },
39 [WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT
]
40 = { .min_len
= sizeof(struct wmi_peer_sta_kickout_event
) },
41 [WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT
]
42 = { .min_len
= sizeof(struct wmi_host_swba_event
) },
43 [WMI_TLV_TAG_STRUCT_TIM_INFO
]
44 = { .min_len
= sizeof(struct wmi_tim_info
) },
45 [WMI_TLV_TAG_STRUCT_P2P_NOA_INFO
]
46 = { .min_len
= sizeof(struct wmi_p2p_noa_info
) },
47 [WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT
]
48 = { .min_len
= sizeof(struct wmi_tlv_svc_rdy_ev
) },
49 [WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES
]
50 = { .min_len
= sizeof(struct hal_reg_capabilities
) },
51 [WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ
]
52 = { .min_len
= sizeof(struct wlan_host_mem_req
) },
53 [WMI_TLV_TAG_STRUCT_READY_EVENT
]
54 = { .min_len
= sizeof(struct wmi_tlv_rdy_ev
) },
55 [WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT
]
56 = { .min_len
= sizeof(struct wmi_tlv_bcn_tx_status_ev
) },
57 [WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT
]
58 = { .min_len
= sizeof(struct wmi_tlv_diag_data_ev
) },
59 [WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT
]
60 = { .min_len
= sizeof(struct wmi_tlv_p2p_noa_ev
) },
61 [WMI_TLV_TAG_STRUCT_ROAM_EVENT
]
62 = { .min_len
= sizeof(struct wmi_tlv_roam_ev
) },
63 [WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO
]
64 = { .min_len
= sizeof(struct wmi_tlv_wow_event_info
) },
65 [WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT
]
66 = { .min_len
= sizeof(struct wmi_tlv_tx_pause_ev
) },
70 ath10k_wmi_tlv_iter(struct ath10k
*ar
, const void *ptr
, size_t len
,
71 int (*iter
)(struct ath10k
*ar
, u16 tag
, u16 len
,
72 const void *ptr
, void *data
),
75 const void *begin
= ptr
;
76 const struct wmi_tlv
*tlv
;
81 if (len
< sizeof(*tlv
)) {
82 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
83 "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
84 ptr
- begin
, len
, sizeof(*tlv
));
89 tlv_tag
= __le16_to_cpu(tlv
->tag
);
90 tlv_len
= __le16_to_cpu(tlv
->len
);
95 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
96 "wmi tlv parse failure of tag %hhu at byte %zd (%zu bytes left, %hhu expected)\n",
97 tlv_tag
, ptr
- begin
, len
, tlv_len
);
101 if (tlv_tag
< ARRAY_SIZE(wmi_tlv_policies
) &&
102 wmi_tlv_policies
[tlv_tag
].min_len
&&
103 wmi_tlv_policies
[tlv_tag
].min_len
> tlv_len
) {
104 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
105 "wmi tlv parse failure of tag %hhu at byte %zd (%hhu bytes is less than min length %zu)\n",
106 tlv_tag
, ptr
- begin
, tlv_len
,
107 wmi_tlv_policies
[tlv_tag
].min_len
);
111 ret
= iter(ar
, tlv_tag
, tlv_len
, ptr
, data
);
122 static int ath10k_wmi_tlv_iter_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
123 const void *ptr
, void *data
)
125 const void **tb
= data
;
127 if (tag
< WMI_TLV_TAG_MAX
)
133 static int ath10k_wmi_tlv_parse(struct ath10k
*ar
, const void **tb
,
134 const void *ptr
, size_t len
)
136 return ath10k_wmi_tlv_iter(ar
, ptr
, len
, ath10k_wmi_tlv_iter_parse
,
141 ath10k_wmi_tlv_parse_alloc(struct ath10k
*ar
, const void *ptr
,
142 size_t len
, gfp_t gfp
)
147 tb
= kcalloc(WMI_TLV_TAG_MAX
, sizeof(*tb
), gfp
);
149 return ERR_PTR(-ENOMEM
);
151 ret
= ath10k_wmi_tlv_parse(ar
, tb
, ptr
, len
);
160 static u16
ath10k_wmi_tlv_len(const void *ptr
)
162 return __le16_to_cpu((((const struct wmi_tlv
*)ptr
) - 1)->len
);
168 static int ath10k_wmi_tlv_event_bcn_tx_status(struct ath10k
*ar
,
172 const struct wmi_tlv_bcn_tx_status_ev
*ev
;
173 struct ath10k_vif
*arvif
;
174 u32 vdev_id
, tx_status
;
177 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
180 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
184 ev
= tb
[WMI_TLV_TAG_STRUCT_OFFLOAD_BCN_TX_STATUS_EVENT
];
190 tx_status
= __le32_to_cpu(ev
->tx_status
);
191 vdev_id
= __le32_to_cpu(ev
->vdev_id
);
194 case WMI_TLV_BCN_TX_STATUS_OK
:
196 case WMI_TLV_BCN_TX_STATUS_XRETRY
:
197 case WMI_TLV_BCN_TX_STATUS_DROP
:
198 case WMI_TLV_BCN_TX_STATUS_FILTERED
:
199 /* FIXME: It's probably worth telling mac80211 to stop the
200 * interface as it is crippled.
202 ath10k_warn(ar
, "received bcn tmpl tx status on vdev %i: %d",
207 arvif
= ath10k_get_arvif(ar
, vdev_id
);
208 if (arvif
&& arvif
->is_up
&& arvif
->vif
->csa_active
)
209 ieee80211_queue_work(ar
->hw
, &arvif
->ap_csa_work
);
215 static void ath10k_wmi_tlv_event_vdev_delete_resp(struct ath10k
*ar
,
218 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "WMI_VDEV_DELETE_RESP_EVENTID\n");
219 complete(&ar
->vdev_delete_done
);
222 static int ath10k_wmi_tlv_event_diag_data(struct ath10k
*ar
,
226 const struct wmi_tlv_diag_data_ev
*ev
;
227 const struct wmi_tlv_diag_item
*item
;
229 int ret
, num_items
, len
;
231 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
234 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
238 ev
= tb
[WMI_TLV_TAG_STRUCT_DIAG_DATA_CONTAINER_EVENT
];
239 data
= tb
[WMI_TLV_TAG_ARRAY_BYTE
];
245 num_items
= __le32_to_cpu(ev
->num_items
);
246 len
= ath10k_wmi_tlv_len(data
);
248 while (num_items
--) {
251 if (len
< sizeof(*item
)) {
252 ath10k_warn(ar
, "failed to parse diag data: can't fit item header\n");
258 if (len
< sizeof(*item
) + __le16_to_cpu(item
->len
)) {
259 ath10k_warn(ar
, "failed to parse diag data: item is too long\n");
263 trace_ath10k_wmi_diag_container(ar
,
265 __le32_to_cpu(item
->timestamp
),
266 __le32_to_cpu(item
->code
),
267 __le16_to_cpu(item
->len
),
270 len
-= sizeof(*item
);
271 len
-= roundup(__le16_to_cpu(item
->len
), 4);
273 data
+= sizeof(*item
);
274 data
+= roundup(__le16_to_cpu(item
->len
), 4);
277 if (num_items
!= -1 || len
!= 0)
278 ath10k_warn(ar
, "failed to parse diag data event: num_items %d len %d\n",
285 static int ath10k_wmi_tlv_event_diag(struct ath10k
*ar
,
292 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
295 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
299 data
= tb
[WMI_TLV_TAG_ARRAY_BYTE
];
304 len
= ath10k_wmi_tlv_len(data
);
306 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv diag event len %d\n", len
);
307 trace_ath10k_wmi_diag(ar
, data
, len
);
313 static int ath10k_wmi_tlv_event_p2p_noa(struct ath10k
*ar
,
317 const struct wmi_tlv_p2p_noa_ev
*ev
;
318 const struct wmi_p2p_noa_info
*noa
;
321 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
324 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
328 ev
= tb
[WMI_TLV_TAG_STRUCT_P2P_NOA_EVENT
];
329 noa
= tb
[WMI_TLV_TAG_STRUCT_P2P_NOA_INFO
];
336 vdev_id
= __le32_to_cpu(ev
->vdev_id
);
338 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
339 "wmi tlv p2p noa vdev_id %i descriptors %hhu\n",
340 vdev_id
, noa
->num_descriptors
);
342 ath10k_p2p_noa_update_by_vdev_id(ar
, vdev_id
, noa
);
347 static int ath10k_wmi_tlv_event_tx_pause(struct ath10k
*ar
,
351 const struct wmi_tlv_tx_pause_ev
*ev
;
353 u32 pause_id
, action
, vdev_map
, peer_id
, tid_map
;
355 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
358 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
362 ev
= tb
[WMI_TLV_TAG_STRUCT_TX_PAUSE_EVENT
];
368 pause_id
= __le32_to_cpu(ev
->pause_id
);
369 action
= __le32_to_cpu(ev
->action
);
370 vdev_map
= __le32_to_cpu(ev
->vdev_map
);
371 peer_id
= __le32_to_cpu(ev
->peer_id
);
372 tid_map
= __le32_to_cpu(ev
->tid_map
);
374 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
375 "wmi tlv tx pause pause_id %u action %u vdev_map 0x%08x peer_id %u tid_map 0x%08x\n",
376 pause_id
, action
, vdev_map
, peer_id
, tid_map
);
379 case WMI_TLV_TX_PAUSE_ID_MCC
:
380 case WMI_TLV_TX_PAUSE_ID_P2P_CLI_NOA
:
381 case WMI_TLV_TX_PAUSE_ID_P2P_GO_PS
:
382 case WMI_TLV_TX_PAUSE_ID_AP_PS
:
383 case WMI_TLV_TX_PAUSE_ID_IBSS_PS
:
384 for (vdev_id
= 0; vdev_map
; vdev_id
++) {
385 if (!(vdev_map
& BIT(vdev_id
)))
388 vdev_map
&= ~BIT(vdev_id
);
389 ath10k_mac_handle_tx_pause_vdev(ar
, vdev_id
, pause_id
,
393 case WMI_TLV_TX_PAUSE_ID_AP_PEER_PS
:
394 case WMI_TLV_TX_PAUSE_ID_AP_PEER_UAPSD
:
395 case WMI_TLV_TX_PAUSE_ID_STA_ADD_BA
:
396 case WMI_TLV_TX_PAUSE_ID_HOST
:
397 ath10k_dbg(ar
, ATH10K_DBG_MAC
,
398 "mac ignoring unsupported tx pause id %d\n",
402 ath10k_dbg(ar
, ATH10K_DBG_MAC
,
403 "mac ignoring unknown tx pause vdev %d\n",
412 static void ath10k_wmi_tlv_event_rfkill_state_change(struct ath10k
*ar
,
415 const struct wmi_tlv_rfkill_state_change_ev
*ev
;
420 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
424 "failed to parse rfkill state change event: %d\n",
429 ev
= tb
[WMI_TLV_TAG_STRUCT_RFKILL_EVENT
];
435 ath10k_dbg(ar
, ATH10K_DBG_MAC
,
436 "wmi tlv rfkill state change gpio %d type %d radio_state %d\n",
437 __le32_to_cpu(ev
->gpio_pin_num
),
438 __le32_to_cpu(ev
->int_type
),
439 __le32_to_cpu(ev
->radio_state
));
441 radio
= (__le32_to_cpu(ev
->radio_state
) == WMI_TLV_RFKILL_RADIO_STATE_ON
);
443 spin_lock_bh(&ar
->data_lock
);
446 ar
->hw_rfkill_on
= true;
448 spin_unlock_bh(&ar
->data_lock
);
450 /* notify cfg80211 radio state change */
451 ath10k_mac_rfkill_enable_radio(ar
, radio
);
452 wiphy_rfkill_set_hw_state(ar
->hw
->wiphy
, !radio
);
455 static int ath10k_wmi_tlv_event_temperature(struct ath10k
*ar
,
458 const struct wmi_tlv_pdev_temperature_event
*ev
;
460 ev
= (struct wmi_tlv_pdev_temperature_event
*)skb
->data
;
461 if (WARN_ON(skb
->len
< sizeof(*ev
)))
464 ath10k_thermal_event_temperature(ar
, __le32_to_cpu(ev
->temperature
));
468 static void ath10k_wmi_event_tdls_peer(struct ath10k
*ar
, struct sk_buff
*skb
)
470 struct ieee80211_sta
*station
;
471 const struct wmi_tlv_tdls_peer_event
*ev
;
473 struct ath10k_vif
*arvif
;
475 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
477 ath10k_warn(ar
, "tdls peer failed to parse tlv");
480 ev
= tb
[WMI_TLV_TAG_STRUCT_TDLS_PEER_EVENT
];
483 ath10k_warn(ar
, "tdls peer NULL event");
487 switch (__le32_to_cpu(ev
->peer_reason
)) {
488 case WMI_TDLS_TEARDOWN_REASON_TX
:
489 case WMI_TDLS_TEARDOWN_REASON_RSSI
:
490 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT
:
491 station
= ieee80211_find_sta_by_ifaddr(ar
->hw
,
492 ev
->peer_macaddr
.addr
,
495 ath10k_warn(ar
, "did not find station from tdls peer event");
499 arvif
= ath10k_get_arvif(ar
, __le32_to_cpu(ev
->vdev_id
));
500 ieee80211_tdls_oper_request(
501 arvif
->vif
, station
->addr
,
502 NL80211_TDLS_TEARDOWN
,
503 WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE
,
511 static int ath10k_wmi_tlv_event_peer_delete_resp(struct ath10k
*ar
,
514 struct wmi_peer_delete_resp_ev_arg
*arg
;
515 struct wmi_tlv
*tlv_hdr
;
517 tlv_hdr
= (struct wmi_tlv
*)skb
->data
;
518 arg
= (struct wmi_peer_delete_resp_ev_arg
*)tlv_hdr
->value
;
520 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "vdev id %d", arg
->vdev_id
);
521 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "peer mac addr %pM", &arg
->peer_addr
);
522 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv peer delete response\n");
524 complete(&ar
->peer_delete_done
);
533 static void ath10k_wmi_tlv_op_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
535 struct wmi_cmd_hdr
*cmd_hdr
;
536 enum wmi_tlv_event_id id
;
539 cmd_hdr
= (struct wmi_cmd_hdr
*)skb
->data
;
540 id
= MS(__le32_to_cpu(cmd_hdr
->cmd_id
), WMI_CMD_HDR_CMD_ID
);
542 if (skb_pull(skb
, sizeof(struct wmi_cmd_hdr
)) == NULL
)
545 trace_ath10k_wmi_event(ar
, id
, skb
->data
, skb
->len
);
547 consumed
= ath10k_tm_event_wmi(ar
, id
, skb
);
549 /* Ready event must be handled normally also in UTF mode so that we
550 * know the UTF firmware has booted, others we are just bypass WMI
551 * events to testmode.
553 if (consumed
&& id
!= WMI_TLV_READY_EVENTID
) {
554 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
555 "wmi tlv testmode consumed 0x%x\n", id
);
560 case WMI_TLV_MGMT_RX_EVENTID
:
561 ath10k_wmi_event_mgmt_rx(ar
, skb
);
562 /* mgmt_rx() owns the skb now! */
564 case WMI_TLV_SCAN_EVENTID
:
565 ath10k_wmi_event_scan(ar
, skb
);
567 case WMI_TLV_CHAN_INFO_EVENTID
:
568 ath10k_wmi_event_chan_info(ar
, skb
);
570 case WMI_TLV_ECHO_EVENTID
:
571 ath10k_wmi_event_echo(ar
, skb
);
573 case WMI_TLV_DEBUG_MESG_EVENTID
:
574 ath10k_wmi_event_debug_mesg(ar
, skb
);
576 case WMI_TLV_UPDATE_STATS_EVENTID
:
577 ath10k_wmi_event_update_stats(ar
, skb
);
579 case WMI_TLV_VDEV_START_RESP_EVENTID
:
580 ath10k_wmi_event_vdev_start_resp(ar
, skb
);
582 case WMI_TLV_VDEV_STOPPED_EVENTID
:
583 ath10k_wmi_event_vdev_stopped(ar
, skb
);
585 case WMI_TLV_VDEV_DELETE_RESP_EVENTID
:
586 ath10k_wmi_tlv_event_vdev_delete_resp(ar
, skb
);
588 case WMI_TLV_PEER_STA_KICKOUT_EVENTID
:
589 ath10k_wmi_event_peer_sta_kickout(ar
, skb
);
591 case WMI_TLV_HOST_SWBA_EVENTID
:
592 ath10k_wmi_event_host_swba(ar
, skb
);
594 case WMI_TLV_TBTTOFFSET_UPDATE_EVENTID
:
595 ath10k_wmi_event_tbttoffset_update(ar
, skb
);
597 case WMI_TLV_PHYERR_EVENTID
:
598 ath10k_wmi_event_phyerr(ar
, skb
);
600 case WMI_TLV_ROAM_EVENTID
:
601 ath10k_wmi_event_roam(ar
, skb
);
603 case WMI_TLV_PROFILE_MATCH
:
604 ath10k_wmi_event_profile_match(ar
, skb
);
606 case WMI_TLV_DEBUG_PRINT_EVENTID
:
607 ath10k_wmi_event_debug_print(ar
, skb
);
609 case WMI_TLV_PDEV_QVIT_EVENTID
:
610 ath10k_wmi_event_pdev_qvit(ar
, skb
);
612 case WMI_TLV_WLAN_PROFILE_DATA_EVENTID
:
613 ath10k_wmi_event_wlan_profile_data(ar
, skb
);
615 case WMI_TLV_RTT_MEASUREMENT_REPORT_EVENTID
:
616 ath10k_wmi_event_rtt_measurement_report(ar
, skb
);
618 case WMI_TLV_TSF_MEASUREMENT_REPORT_EVENTID
:
619 ath10k_wmi_event_tsf_measurement_report(ar
, skb
);
621 case WMI_TLV_RTT_ERROR_REPORT_EVENTID
:
622 ath10k_wmi_event_rtt_error_report(ar
, skb
);
624 case WMI_TLV_WOW_WAKEUP_HOST_EVENTID
:
625 ath10k_wmi_event_wow_wakeup_host(ar
, skb
);
627 case WMI_TLV_DCS_INTERFERENCE_EVENTID
:
628 ath10k_wmi_event_dcs_interference(ar
, skb
);
630 case WMI_TLV_PDEV_TPC_CONFIG_EVENTID
:
631 ath10k_wmi_event_pdev_tpc_config(ar
, skb
);
633 case WMI_TLV_PDEV_FTM_INTG_EVENTID
:
634 ath10k_wmi_event_pdev_ftm_intg(ar
, skb
);
636 case WMI_TLV_GTK_OFFLOAD_STATUS_EVENTID
:
637 ath10k_wmi_event_gtk_offload_status(ar
, skb
);
639 case WMI_TLV_GTK_REKEY_FAIL_EVENTID
:
640 ath10k_wmi_event_gtk_rekey_fail(ar
, skb
);
642 case WMI_TLV_TX_DELBA_COMPLETE_EVENTID
:
643 ath10k_wmi_event_delba_complete(ar
, skb
);
645 case WMI_TLV_TX_ADDBA_COMPLETE_EVENTID
:
646 ath10k_wmi_event_addba_complete(ar
, skb
);
648 case WMI_TLV_VDEV_INSTALL_KEY_COMPLETE_EVENTID
:
649 ath10k_wmi_event_vdev_install_key_complete(ar
, skb
);
651 case WMI_TLV_SERVICE_READY_EVENTID
:
652 ath10k_wmi_event_service_ready(ar
, skb
);
654 case WMI_TLV_READY_EVENTID
:
655 ath10k_wmi_event_ready(ar
, skb
);
657 case WMI_TLV_SERVICE_AVAILABLE_EVENTID
:
658 ath10k_wmi_event_service_available(ar
, skb
);
660 case WMI_TLV_OFFLOAD_BCN_TX_STATUS_EVENTID
:
661 ath10k_wmi_tlv_event_bcn_tx_status(ar
, skb
);
663 case WMI_TLV_DIAG_DATA_CONTAINER_EVENTID
:
664 ath10k_wmi_tlv_event_diag_data(ar
, skb
);
666 case WMI_TLV_DIAG_EVENTID
:
667 ath10k_wmi_tlv_event_diag(ar
, skb
);
669 case WMI_TLV_P2P_NOA_EVENTID
:
670 ath10k_wmi_tlv_event_p2p_noa(ar
, skb
);
672 case WMI_TLV_TX_PAUSE_EVENTID
:
673 ath10k_wmi_tlv_event_tx_pause(ar
, skb
);
675 case WMI_TLV_RFKILL_STATE_CHANGE_EVENTID
:
676 ath10k_wmi_tlv_event_rfkill_state_change(ar
, skb
);
678 case WMI_TLV_PDEV_TEMPERATURE_EVENTID
:
679 ath10k_wmi_tlv_event_temperature(ar
, skb
);
681 case WMI_TLV_TDLS_PEER_EVENTID
:
682 ath10k_wmi_event_tdls_peer(ar
, skb
);
684 case WMI_TLV_PEER_DELETE_RESP_EVENTID
:
685 ath10k_wmi_tlv_event_peer_delete_resp(ar
, skb
);
687 case WMI_TLV_MGMT_TX_COMPLETION_EVENTID
:
688 ath10k_wmi_event_mgmt_tx_compl(ar
, skb
);
690 case WMI_TLV_MGMT_TX_BUNDLE_COMPLETION_EVENTID
:
691 ath10k_wmi_event_mgmt_tx_bundle_compl(ar
, skb
);
694 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "Unknown eventid: %d\n", id
);
702 static int ath10k_wmi_tlv_op_pull_scan_ev(struct ath10k
*ar
,
704 struct wmi_scan_ev_arg
*arg
)
707 const struct wmi_scan_event
*ev
;
710 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
713 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
717 ev
= tb
[WMI_TLV_TAG_STRUCT_SCAN_EVENT
];
723 arg
->event_type
= ev
->event_type
;
724 arg
->reason
= ev
->reason
;
725 arg
->channel_freq
= ev
->channel_freq
;
726 arg
->scan_req_id
= ev
->scan_req_id
;
727 arg
->scan_id
= ev
->scan_id
;
728 arg
->vdev_id
= ev
->vdev_id
;
735 ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev(struct ath10k
*ar
, struct sk_buff
*skb
,
736 struct wmi_tlv_mgmt_tx_compl_ev_arg
*arg
)
739 const struct wmi_tlv_mgmt_tx_compl_ev
*ev
;
742 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
745 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
749 ev
= tb
[WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_EVENT
];
751 arg
->desc_id
= ev
->desc_id
;
752 arg
->status
= ev
->status
;
753 arg
->pdev_id
= ev
->pdev_id
;
754 arg
->ppdu_id
= ev
->ppdu_id
;
756 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI
, ar
->wmi
.svc_map
))
757 arg
->ack_rssi
= ev
->ack_rssi
;
763 struct wmi_tlv_tx_bundle_compl_parse
{
764 const __le32
*num_reports
;
765 const __le32
*desc_ids
;
766 const __le32
*status
;
767 const __le32
*ppdu_ids
;
768 const __le32
*ack_rssi
;
776 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
777 const void *ptr
, void *data
)
779 struct wmi_tlv_tx_bundle_compl_parse
*bundle_tx_compl
= data
;
782 case WMI_TLV_TAG_STRUCT_MGMT_TX_COMPL_BUNDLE_EVENT
:
783 bundle_tx_compl
->num_reports
= ptr
;
785 case WMI_TLV_TAG_ARRAY_UINT32
:
786 if (!bundle_tx_compl
->desc_ids_done
) {
787 bundle_tx_compl
->desc_ids_done
= true;
788 bundle_tx_compl
->desc_ids
= ptr
;
789 } else if (!bundle_tx_compl
->status_done
) {
790 bundle_tx_compl
->status_done
= true;
791 bundle_tx_compl
->status
= ptr
;
792 } else if (!bundle_tx_compl
->ppdu_ids_done
) {
793 bundle_tx_compl
->ppdu_ids_done
= true;
794 bundle_tx_compl
->ppdu_ids
= ptr
;
795 } else if (!bundle_tx_compl
->ack_rssi_done
) {
796 bundle_tx_compl
->ack_rssi_done
= true;
797 bundle_tx_compl
->ack_rssi
= ptr
;
806 static int ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev(
807 struct ath10k
*ar
, struct sk_buff
*skb
,
808 struct wmi_tlv_mgmt_tx_bundle_compl_ev_arg
*arg
)
810 struct wmi_tlv_tx_bundle_compl_parse bundle_tx_compl
= { };
813 ret
= ath10k_wmi_tlv_iter(ar
, skb
->data
, skb
->len
,
814 ath10k_wmi_tlv_mgmt_tx_bundle_compl_parse
,
817 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
821 if (!bundle_tx_compl
.num_reports
|| !bundle_tx_compl
.desc_ids
||
822 !bundle_tx_compl
.status
)
825 arg
->num_reports
= *bundle_tx_compl
.num_reports
;
826 arg
->desc_ids
= bundle_tx_compl
.desc_ids
;
827 arg
->status
= bundle_tx_compl
.status
;
828 arg
->ppdu_ids
= bundle_tx_compl
.ppdu_ids
;
830 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI
, ar
->wmi
.svc_map
))
831 arg
->ack_rssi
= bundle_tx_compl
.ack_rssi
;
836 static int ath10k_wmi_tlv_op_pull_mgmt_rx_ev(struct ath10k
*ar
,
838 struct wmi_mgmt_rx_ev_arg
*arg
)
841 const struct wmi_tlv_mgmt_rx_ev
*ev
;
846 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
849 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
853 ev
= tb
[WMI_TLV_TAG_STRUCT_MGMT_RX_HDR
];
854 frame
= tb
[WMI_TLV_TAG_ARRAY_BYTE
];
861 arg
->channel
= ev
->channel
;
862 arg
->buf_len
= ev
->buf_len
;
863 arg
->status
= ev
->status
;
865 arg
->phy_mode
= ev
->phy_mode
;
866 arg
->rate
= ev
->rate
;
868 for (i
= 0; i
< ARRAY_SIZE(ev
->rssi
); i
++)
869 arg
->rssi
[i
] = ev
->rssi
[i
];
871 msdu_len
= __le32_to_cpu(arg
->buf_len
);
873 if (skb
->len
< (frame
- skb
->data
) + msdu_len
) {
878 /* shift the sk_buff to point to `frame` */
880 skb_put(skb
, frame
- skb
->data
);
881 skb_pull(skb
, frame
- skb
->data
);
882 skb_put(skb
, msdu_len
);
888 static int ath10k_wmi_tlv_op_pull_ch_info_ev(struct ath10k
*ar
,
890 struct wmi_ch_info_ev_arg
*arg
)
893 const struct wmi_tlv_chan_info_event
*ev
;
896 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
899 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
903 ev
= tb
[WMI_TLV_TAG_STRUCT_CHAN_INFO_EVENT
];
909 arg
->err_code
= ev
->err_code
;
910 arg
->freq
= ev
->freq
;
911 arg
->cmd_flags
= ev
->cmd_flags
;
912 arg
->noise_floor
= ev
->noise_floor
;
913 arg
->rx_clear_count
= ev
->rx_clear_count
;
914 arg
->cycle_count
= ev
->cycle_count
;
915 if (test_bit(ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL
,
916 ar
->running_fw
->fw_file
.fw_features
))
917 arg
->mac_clk_mhz
= ev
->mac_clk_mhz
;
924 ath10k_wmi_tlv_op_pull_vdev_start_ev(struct ath10k
*ar
, struct sk_buff
*skb
,
925 struct wmi_vdev_start_ev_arg
*arg
)
928 const struct wmi_vdev_start_response_event
*ev
;
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_VDEV_START_RESPONSE_EVENT
];
944 skb_pull(skb
, sizeof(*ev
));
945 arg
->vdev_id
= ev
->vdev_id
;
946 arg
->req_id
= ev
->req_id
;
947 arg
->resp_type
= ev
->resp_type
;
948 arg
->status
= ev
->status
;
954 static int ath10k_wmi_tlv_op_pull_peer_kick_ev(struct ath10k
*ar
,
956 struct wmi_peer_kick_ev_arg
*arg
)
959 const struct wmi_peer_sta_kickout_event
*ev
;
962 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
965 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
969 ev
= tb
[WMI_TLV_TAG_STRUCT_PEER_STA_KICKOUT_EVENT
];
975 arg
->mac_addr
= ev
->peer_macaddr
.addr
;
981 struct wmi_tlv_swba_parse
{
982 const struct wmi_host_swba_event
*ev
;
987 struct wmi_swba_ev_arg
*arg
;
990 static int ath10k_wmi_tlv_swba_tim_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
991 const void *ptr
, void *data
)
993 struct wmi_tlv_swba_parse
*swba
= data
;
994 struct wmi_tim_info_arg
*tim_info_arg
;
995 const struct wmi_tim_info
*tim_info_ev
= ptr
;
997 if (tag
!= WMI_TLV_TAG_STRUCT_TIM_INFO
)
1000 if (swba
->n_tim
>= ARRAY_SIZE(swba
->arg
->tim_info
))
1003 if (__le32_to_cpu(tim_info_ev
->tim_len
) >
1004 sizeof(tim_info_ev
->tim_bitmap
)) {
1005 ath10k_warn(ar
, "refusing to parse invalid swba structure\n");
1009 tim_info_arg
= &swba
->arg
->tim_info
[swba
->n_tim
];
1010 tim_info_arg
->tim_len
= tim_info_ev
->tim_len
;
1011 tim_info_arg
->tim_mcast
= tim_info_ev
->tim_mcast
;
1012 tim_info_arg
->tim_bitmap
= tim_info_ev
->tim_bitmap
;
1013 tim_info_arg
->tim_changed
= tim_info_ev
->tim_changed
;
1014 tim_info_arg
->tim_num_ps_pending
= tim_info_ev
->tim_num_ps_pending
;
1021 static int ath10k_wmi_tlv_swba_noa_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
1022 const void *ptr
, void *data
)
1024 struct wmi_tlv_swba_parse
*swba
= data
;
1026 if (tag
!= WMI_TLV_TAG_STRUCT_P2P_NOA_INFO
)
1029 if (swba
->n_noa
>= ARRAY_SIZE(swba
->arg
->noa_info
))
1032 swba
->arg
->noa_info
[swba
->n_noa
++] = ptr
;
1036 static int ath10k_wmi_tlv_swba_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
1037 const void *ptr
, void *data
)
1039 struct wmi_tlv_swba_parse
*swba
= data
;
1043 case WMI_TLV_TAG_STRUCT_HOST_SWBA_EVENT
:
1046 case WMI_TLV_TAG_ARRAY_STRUCT
:
1047 if (!swba
->tim_done
) {
1048 swba
->tim_done
= true;
1049 ret
= ath10k_wmi_tlv_iter(ar
, ptr
, len
,
1050 ath10k_wmi_tlv_swba_tim_parse
,
1054 } else if (!swba
->noa_done
) {
1055 swba
->noa_done
= true;
1056 ret
= ath10k_wmi_tlv_iter(ar
, ptr
, len
,
1057 ath10k_wmi_tlv_swba_noa_parse
,
1069 static int ath10k_wmi_tlv_op_pull_swba_ev(struct ath10k
*ar
,
1070 struct sk_buff
*skb
,
1071 struct wmi_swba_ev_arg
*arg
)
1073 struct wmi_tlv_swba_parse swba
= { .arg
= arg
};
1078 ret
= ath10k_wmi_tlv_iter(ar
, skb
->data
, skb
->len
,
1079 ath10k_wmi_tlv_swba_parse
, &swba
);
1081 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1088 arg
->vdev_map
= swba
.ev
->vdev_map
;
1090 for (map
= __le32_to_cpu(arg
->vdev_map
), n_vdevs
= 0; map
; map
>>= 1)
1094 if (n_vdevs
!= swba
.n_tim
||
1095 n_vdevs
!= swba
.n_noa
)
1101 static int ath10k_wmi_tlv_op_pull_phyerr_ev_hdr(struct ath10k
*ar
,
1102 struct sk_buff
*skb
,
1103 struct wmi_phyerr_hdr_arg
*arg
)
1106 const struct wmi_tlv_phyerr_ev
*ev
;
1107 const void *phyerrs
;
1110 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1113 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1117 ev
= tb
[WMI_TLV_TAG_STRUCT_COMB_PHYERR_RX_HDR
];
1118 phyerrs
= tb
[WMI_TLV_TAG_ARRAY_BYTE
];
1120 if (!ev
|| !phyerrs
) {
1125 arg
->num_phyerrs
= __le32_to_cpu(ev
->num_phyerrs
);
1126 arg
->tsf_l32
= __le32_to_cpu(ev
->tsf_l32
);
1127 arg
->tsf_u32
= __le32_to_cpu(ev
->tsf_u32
);
1128 arg
->buf_len
= __le32_to_cpu(ev
->buf_len
);
1129 arg
->phyerrs
= phyerrs
;
1135 #define WMI_TLV_ABI_VER_NS0 0x5F414351
1136 #define WMI_TLV_ABI_VER_NS1 0x00004C4D
1137 #define WMI_TLV_ABI_VER_NS2 0x00000000
1138 #define WMI_TLV_ABI_VER_NS3 0x00000000
1140 #define WMI_TLV_ABI_VER0_MAJOR 1
1141 #define WMI_TLV_ABI_VER0_MINOR 0
1142 #define WMI_TLV_ABI_VER0 ((((WMI_TLV_ABI_VER0_MAJOR) << 24) & 0xFF000000) | \
1143 (((WMI_TLV_ABI_VER0_MINOR) << 0) & 0x00FFFFFF))
1144 #define WMI_TLV_ABI_VER1 53
1147 ath10k_wmi_tlv_parse_mem_reqs(struct ath10k
*ar
, u16 tag
, u16 len
,
1148 const void *ptr
, void *data
)
1150 struct wmi_svc_rdy_ev_arg
*arg
= data
;
1153 if (tag
!= WMI_TLV_TAG_STRUCT_WLAN_HOST_MEM_REQ
)
1156 for (i
= 0; i
< ARRAY_SIZE(arg
->mem_reqs
); i
++) {
1157 if (!arg
->mem_reqs
[i
]) {
1158 arg
->mem_reqs
[i
] = ptr
;
1166 struct wmi_tlv_svc_rdy_parse
{
1167 const struct hal_reg_capabilities
*reg
;
1168 const struct wmi_tlv_svc_rdy_ev
*ev
;
1169 const __le32
*svc_bmap
;
1170 const struct wlan_host_mem_req
*mem_reqs
;
1172 bool dbs_hw_mode_done
;
1175 static int ath10k_wmi_tlv_svc_rdy_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
1176 const void *ptr
, void *data
)
1178 struct wmi_tlv_svc_rdy_parse
*svc_rdy
= data
;
1181 case WMI_TLV_TAG_STRUCT_SERVICE_READY_EVENT
:
1184 case WMI_TLV_TAG_STRUCT_HAL_REG_CAPABILITIES
:
1187 case WMI_TLV_TAG_ARRAY_STRUCT
:
1188 svc_rdy
->mem_reqs
= ptr
;
1190 case WMI_TLV_TAG_ARRAY_UINT32
:
1191 if (!svc_rdy
->svc_bmap_done
) {
1192 svc_rdy
->svc_bmap_done
= true;
1193 svc_rdy
->svc_bmap
= ptr
;
1194 } else if (!svc_rdy
->dbs_hw_mode_done
) {
1195 svc_rdy
->dbs_hw_mode_done
= true;
1204 static int ath10k_wmi_tlv_op_pull_svc_rdy_ev(struct ath10k
*ar
,
1205 struct sk_buff
*skb
,
1206 struct wmi_svc_rdy_ev_arg
*arg
)
1208 const struct hal_reg_capabilities
*reg
;
1209 const struct wmi_tlv_svc_rdy_ev
*ev
;
1210 const __le32
*svc_bmap
;
1211 const struct wlan_host_mem_req
*mem_reqs
;
1212 struct wmi_tlv_svc_rdy_parse svc_rdy
= { };
1215 ret
= ath10k_wmi_tlv_iter(ar
, skb
->data
, skb
->len
,
1216 ath10k_wmi_tlv_svc_rdy_parse
, &svc_rdy
);
1218 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1224 svc_bmap
= svc_rdy
.svc_bmap
;
1225 mem_reqs
= svc_rdy
.mem_reqs
;
1227 if (!ev
|| !reg
|| !svc_bmap
|| !mem_reqs
)
1230 /* This is an internal ABI compatibility check for WMI TLV so check it
1231 * here instead of the generic WMI code.
1233 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
1234 "wmi tlv abi 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x, 0x%08x ?= 0x%08x\n",
1235 __le32_to_cpu(ev
->abi
.abi_ver0
), WMI_TLV_ABI_VER0
,
1236 __le32_to_cpu(ev
->abi
.abi_ver_ns0
), WMI_TLV_ABI_VER_NS0
,
1237 __le32_to_cpu(ev
->abi
.abi_ver_ns1
), WMI_TLV_ABI_VER_NS1
,
1238 __le32_to_cpu(ev
->abi
.abi_ver_ns2
), WMI_TLV_ABI_VER_NS2
,
1239 __le32_to_cpu(ev
->abi
.abi_ver_ns3
), WMI_TLV_ABI_VER_NS3
);
1241 if (__le32_to_cpu(ev
->abi
.abi_ver0
) != WMI_TLV_ABI_VER0
||
1242 __le32_to_cpu(ev
->abi
.abi_ver_ns0
) != WMI_TLV_ABI_VER_NS0
||
1243 __le32_to_cpu(ev
->abi
.abi_ver_ns1
) != WMI_TLV_ABI_VER_NS1
||
1244 __le32_to_cpu(ev
->abi
.abi_ver_ns2
) != WMI_TLV_ABI_VER_NS2
||
1245 __le32_to_cpu(ev
->abi
.abi_ver_ns3
) != WMI_TLV_ABI_VER_NS3
) {
1249 arg
->min_tx_power
= ev
->hw_min_tx_power
;
1250 arg
->max_tx_power
= ev
->hw_max_tx_power
;
1251 arg
->ht_cap
= ev
->ht_cap_info
;
1252 arg
->vht_cap
= ev
->vht_cap_info
;
1253 arg
->vht_supp_mcs
= ev
->vht_supp_mcs
;
1254 arg
->sw_ver0
= ev
->abi
.abi_ver0
;
1255 arg
->sw_ver1
= ev
->abi
.abi_ver1
;
1256 arg
->fw_build
= ev
->fw_build_vers
;
1257 arg
->phy_capab
= ev
->phy_capability
;
1258 arg
->num_rf_chains
= ev
->num_rf_chains
;
1259 arg
->eeprom_rd
= reg
->eeprom_rd
;
1260 arg
->low_2ghz_chan
= reg
->low_2ghz_chan
;
1261 arg
->high_2ghz_chan
= reg
->high_2ghz_chan
;
1262 arg
->low_5ghz_chan
= reg
->low_5ghz_chan
;
1263 arg
->high_5ghz_chan
= reg
->high_5ghz_chan
;
1264 arg
->num_mem_reqs
= ev
->num_mem_reqs
;
1265 arg
->service_map
= svc_bmap
;
1266 arg
->service_map_len
= ath10k_wmi_tlv_len(svc_bmap
);
1267 arg
->sys_cap_info
= ev
->sys_cap_info
;
1269 ret
= ath10k_wmi_tlv_iter(ar
, mem_reqs
, ath10k_wmi_tlv_len(mem_reqs
),
1270 ath10k_wmi_tlv_parse_mem_reqs
, arg
);
1272 ath10k_warn(ar
, "failed to parse mem_reqs tlv: %d\n", ret
);
1279 static int ath10k_wmi_tlv_op_pull_rdy_ev(struct ath10k
*ar
,
1280 struct sk_buff
*skb
,
1281 struct wmi_rdy_ev_arg
*arg
)
1284 const struct wmi_tlv_rdy_ev
*ev
;
1287 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1290 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1294 ev
= tb
[WMI_TLV_TAG_STRUCT_READY_EVENT
];
1300 arg
->sw_version
= ev
->abi
.abi_ver0
;
1301 arg
->abi_version
= ev
->abi
.abi_ver1
;
1302 arg
->status
= ev
->status
;
1303 arg
->mac_addr
= ev
->mac_addr
.addr
;
1309 static int ath10k_wmi_tlv_svc_avail_parse(struct ath10k
*ar
, u16 tag
, u16 len
,
1310 const void *ptr
, void *data
)
1312 struct wmi_svc_avail_ev_arg
*arg
= data
;
1315 case WMI_TLV_TAG_STRUCT_SERVICE_AVAILABLE_EVENT
:
1316 arg
->service_map_ext_len
= *(__le32
*)ptr
;
1317 arg
->service_map_ext
= ptr
+ sizeof(__le32
);
1325 static int ath10k_wmi_tlv_op_pull_svc_avail(struct ath10k
*ar
,
1326 struct sk_buff
*skb
,
1327 struct wmi_svc_avail_ev_arg
*arg
)
1331 ret
= ath10k_wmi_tlv_iter(ar
, skb
->data
, skb
->len
,
1332 ath10k_wmi_tlv_svc_avail_parse
, arg
);
1335 ath10k_warn(ar
, "failed to parse svc_avail tlv: %d\n", ret
);
1342 static void ath10k_wmi_tlv_pull_vdev_stats(const struct wmi_tlv_vdev_stats
*src
,
1343 struct ath10k_fw_stats_vdev
*dst
)
1347 dst
->vdev_id
= __le32_to_cpu(src
->vdev_id
);
1348 dst
->beacon_snr
= __le32_to_cpu(src
->beacon_snr
);
1349 dst
->data_snr
= __le32_to_cpu(src
->data_snr
);
1350 dst
->num_rx_frames
= __le32_to_cpu(src
->num_rx_frames
);
1351 dst
->num_rts_fail
= __le32_to_cpu(src
->num_rts_fail
);
1352 dst
->num_rts_success
= __le32_to_cpu(src
->num_rts_success
);
1353 dst
->num_rx_err
= __le32_to_cpu(src
->num_rx_err
);
1354 dst
->num_rx_discard
= __le32_to_cpu(src
->num_rx_discard
);
1355 dst
->num_tx_not_acked
= __le32_to_cpu(src
->num_tx_not_acked
);
1357 for (i
= 0; i
< ARRAY_SIZE(src
->num_tx_frames
); i
++)
1358 dst
->num_tx_frames
[i
] =
1359 __le32_to_cpu(src
->num_tx_frames
[i
]);
1361 for (i
= 0; i
< ARRAY_SIZE(src
->num_tx_frames_retries
); i
++)
1362 dst
->num_tx_frames_retries
[i
] =
1363 __le32_to_cpu(src
->num_tx_frames_retries
[i
]);
1365 for (i
= 0; i
< ARRAY_SIZE(src
->num_tx_frames_failures
); i
++)
1366 dst
->num_tx_frames_failures
[i
] =
1367 __le32_to_cpu(src
->num_tx_frames_failures
[i
]);
1369 for (i
= 0; i
< ARRAY_SIZE(src
->tx_rate_history
); i
++)
1370 dst
->tx_rate_history
[i
] =
1371 __le32_to_cpu(src
->tx_rate_history
[i
]);
1373 for (i
= 0; i
< ARRAY_SIZE(src
->beacon_rssi_history
); i
++)
1374 dst
->beacon_rssi_history
[i
] =
1375 __le32_to_cpu(src
->beacon_rssi_history
[i
]);
1378 static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k
*ar
,
1379 struct sk_buff
*skb
,
1380 struct ath10k_fw_stats
*stats
)
1383 const struct wmi_tlv_stats_ev
*ev
;
1384 u32 num_peer_stats_extd
;
1389 u32 num_bcnflt_stats
;
1396 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1399 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1403 ev
= tb
[WMI_TLV_TAG_STRUCT_STATS_EVENT
];
1404 data
= tb
[WMI_TLV_TAG_ARRAY_BYTE
];
1411 data_len
= ath10k_wmi_tlv_len(data
);
1412 num_pdev_stats
= __le32_to_cpu(ev
->num_pdev_stats
);
1413 num_vdev_stats
= __le32_to_cpu(ev
->num_vdev_stats
);
1414 num_peer_stats
= __le32_to_cpu(ev
->num_peer_stats
);
1415 num_bcnflt_stats
= __le32_to_cpu(ev
->num_bcnflt_stats
);
1416 num_chan_stats
= __le32_to_cpu(ev
->num_chan_stats
);
1417 stats_id
= __le32_to_cpu(ev
->stats_id
);
1418 num_peer_stats_extd
= __le32_to_cpu(ev
->num_peer_stats_extd
);
1420 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
1421 "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i peer_extd %i\n",
1422 num_pdev_stats
, num_vdev_stats
, num_peer_stats
,
1423 num_bcnflt_stats
, num_chan_stats
, num_peer_stats_extd
);
1425 for (i
= 0; i
< num_pdev_stats
; i
++) {
1426 const struct wmi_pdev_stats
*src
;
1427 struct ath10k_fw_stats_pdev
*dst
;
1430 if (data_len
< sizeof(*src
)) {
1435 data
+= sizeof(*src
);
1436 data_len
-= sizeof(*src
);
1438 dst
= kzalloc(sizeof(*dst
), GFP_ATOMIC
);
1442 ath10k_wmi_pull_pdev_stats_base(&src
->base
, dst
);
1443 ath10k_wmi_pull_pdev_stats_tx(&src
->tx
, dst
);
1444 ath10k_wmi_pull_pdev_stats_rx(&src
->rx
, dst
);
1445 list_add_tail(&dst
->list
, &stats
->pdevs
);
1448 for (i
= 0; i
< num_vdev_stats
; i
++) {
1449 const struct wmi_tlv_vdev_stats
*src
;
1450 struct ath10k_fw_stats_vdev
*dst
;
1453 if (data_len
< sizeof(*src
)) {
1458 data
+= sizeof(*src
);
1459 data_len
-= sizeof(*src
);
1461 dst
= kzalloc(sizeof(*dst
), GFP_ATOMIC
);
1465 ath10k_wmi_tlv_pull_vdev_stats(src
, dst
);
1466 list_add_tail(&dst
->list
, &stats
->vdevs
);
1469 for (i
= 0; i
< num_peer_stats
; i
++) {
1470 const struct wmi_10x_peer_stats
*src
;
1471 struct ath10k_fw_stats_peer
*dst
;
1474 if (data_len
< sizeof(*src
)) {
1479 data
+= sizeof(*src
);
1480 data_len
-= sizeof(*src
);
1482 dst
= kzalloc(sizeof(*dst
), GFP_ATOMIC
);
1486 ath10k_wmi_pull_peer_stats(&src
->old
, dst
);
1487 dst
->peer_rx_rate
= __le32_to_cpu(src
->peer_rx_rate
);
1489 if (stats_id
& WMI_TLV_STAT_PEER_EXTD
) {
1490 const struct wmi_tlv_peer_stats_extd
*extd
;
1491 unsigned long rx_duration_high
;
1493 extd
= data
+ sizeof(*src
) * (num_peer_stats
- i
- 1)
1494 + sizeof(*extd
) * i
;
1496 dst
->rx_duration
= __le32_to_cpu(extd
->rx_duration
);
1497 rx_duration_high
= __le32_to_cpu
1498 (extd
->rx_duration_high
);
1500 if (test_bit(WMI_TLV_PEER_RX_DURATION_HIGH_VALID_BIT
,
1501 &rx_duration_high
)) {
1503 FIELD_GET(WMI_TLV_PEER_RX_DURATION_HIGH_MASK
,
1505 dst
->rx_duration
|= (u64
)rx_duration_high
<<
1506 WMI_TLV_PEER_RX_DURATION_SHIFT
;
1510 list_add_tail(&dst
->list
, &stats
->peers
);
1517 static int ath10k_wmi_tlv_op_pull_roam_ev(struct ath10k
*ar
,
1518 struct sk_buff
*skb
,
1519 struct wmi_roam_ev_arg
*arg
)
1522 const struct wmi_tlv_roam_ev
*ev
;
1525 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1528 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1532 ev
= tb
[WMI_TLV_TAG_STRUCT_ROAM_EVENT
];
1538 arg
->vdev_id
= ev
->vdev_id
;
1539 arg
->reason
= ev
->reason
;
1540 arg
->rssi
= ev
->rssi
;
1547 ath10k_wmi_tlv_op_pull_wow_ev(struct ath10k
*ar
, struct sk_buff
*skb
,
1548 struct wmi_wow_ev_arg
*arg
)
1551 const struct wmi_tlv_wow_event_info
*ev
;
1554 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1557 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1561 ev
= tb
[WMI_TLV_TAG_STRUCT_WOW_EVENT_INFO
];
1567 arg
->vdev_id
= __le32_to_cpu(ev
->vdev_id
);
1568 arg
->flag
= __le32_to_cpu(ev
->flag
);
1569 arg
->wake_reason
= __le32_to_cpu(ev
->wake_reason
);
1570 arg
->data_len
= __le32_to_cpu(ev
->data_len
);
1576 static int ath10k_wmi_tlv_op_pull_echo_ev(struct ath10k
*ar
,
1577 struct sk_buff
*skb
,
1578 struct wmi_echo_ev_arg
*arg
)
1581 const struct wmi_echo_event
*ev
;
1584 tb
= ath10k_wmi_tlv_parse_alloc(ar
, skb
->data
, skb
->len
, GFP_ATOMIC
);
1587 ath10k_warn(ar
, "failed to parse tlv: %d\n", ret
);
1591 ev
= tb
[WMI_TLV_TAG_STRUCT_ECHO_EVENT
];
1597 arg
->value
= ev
->value
;
1603 static struct sk_buff
*
1604 ath10k_wmi_tlv_op_gen_pdev_suspend(struct ath10k
*ar
, u32 opt
)
1606 struct wmi_tlv_pdev_suspend
*cmd
;
1607 struct wmi_tlv
*tlv
;
1608 struct sk_buff
*skb
;
1610 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
1612 return ERR_PTR(-ENOMEM
);
1614 tlv
= (void *)skb
->data
;
1615 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SUSPEND_CMD
);
1616 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1617 cmd
= (void *)tlv
->value
;
1618 cmd
->opt
= __cpu_to_le32(opt
);
1620 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pdev suspend\n");
1624 static struct sk_buff
*
1625 ath10k_wmi_tlv_op_gen_pdev_resume(struct ath10k
*ar
)
1627 struct wmi_tlv_resume_cmd
*cmd
;
1628 struct wmi_tlv
*tlv
;
1629 struct sk_buff
*skb
;
1631 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
1633 return ERR_PTR(-ENOMEM
);
1635 tlv
= (void *)skb
->data
;
1636 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_RESUME_CMD
);
1637 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1638 cmd
= (void *)tlv
->value
;
1639 cmd
->reserved
= __cpu_to_le32(0);
1641 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pdev resume\n");
1645 static struct sk_buff
*
1646 ath10k_wmi_tlv_op_gen_pdev_set_rd(struct ath10k
*ar
,
1647 u16 rd
, u16 rd2g
, u16 rd5g
,
1648 u16 ctl2g
, u16 ctl5g
,
1649 enum wmi_dfs_region dfs_reg
)
1651 struct wmi_tlv_pdev_set_rd_cmd
*cmd
;
1652 struct wmi_tlv
*tlv
;
1653 struct sk_buff
*skb
;
1655 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
1657 return ERR_PTR(-ENOMEM
);
1659 tlv
= (void *)skb
->data
;
1660 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_REGDOMAIN_CMD
);
1661 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1662 cmd
= (void *)tlv
->value
;
1663 cmd
->regd
= __cpu_to_le32(rd
);
1664 cmd
->regd_2ghz
= __cpu_to_le32(rd2g
);
1665 cmd
->regd_5ghz
= __cpu_to_le32(rd5g
);
1666 cmd
->conform_limit_2ghz
= __cpu_to_le32(ctl2g
);
1667 cmd
->conform_limit_5ghz
= __cpu_to_le32(ctl5g
);
1669 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pdev set rd\n");
1673 static enum wmi_txbf_conf
ath10k_wmi_tlv_txbf_conf_scheme(struct ath10k
*ar
)
1675 return WMI_TXBF_CONF_AFTER_ASSOC
;
1678 static struct sk_buff
*
1679 ath10k_wmi_tlv_op_gen_pdev_set_param(struct ath10k
*ar
, u32 param_id
,
1682 struct wmi_tlv_pdev_set_param_cmd
*cmd
;
1683 struct wmi_tlv
*tlv
;
1684 struct sk_buff
*skb
;
1686 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
1688 return ERR_PTR(-ENOMEM
);
1690 tlv
= (void *)skb
->data
;
1691 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_PARAM_CMD
);
1692 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1693 cmd
= (void *)tlv
->value
;
1694 cmd
->param_id
= __cpu_to_le32(param_id
);
1695 cmd
->param_value
= __cpu_to_le32(param_value
);
1697 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pdev set param %d value 0x%x\n",
1698 param_id
, param_value
);
1703 ath10k_wmi_tlv_put_host_mem_chunks(struct ath10k
*ar
, void *host_mem_chunks
)
1705 struct host_memory_chunk_tlv
*chunk
;
1706 struct wmi_tlv
*tlv
;
1709 __le16 tlv_len
, tlv_tag
;
1711 tlv_tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WLAN_HOST_MEMORY_CHUNK
);
1712 tlv_len
= __cpu_to_le16(sizeof(*chunk
));
1713 for (i
= 0; i
< ar
->wmi
.num_mem_chunks
; i
++) {
1714 tlv
= host_mem_chunks
;
1717 chunk
= (void *)tlv
->value
;
1719 chunk
->ptr
= __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].paddr
);
1720 chunk
->size
= __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].len
);
1721 chunk
->req_id
= __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].req_id
);
1723 if (test_bit(WMI_SERVICE_SUPPORT_EXTEND_ADDRESS
,
1725 paddr
= ar
->wmi
.mem_chunks
[i
].paddr
;
1726 chunk
->ptr_high
= __cpu_to_le32(upper_32_bits(paddr
));
1729 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
1730 "wmi-tlv chunk %d len %d, addr 0x%llx, id 0x%x\n",
1732 ar
->wmi
.mem_chunks
[i
].len
,
1733 (unsigned long long)ar
->wmi
.mem_chunks
[i
].paddr
,
1734 ar
->wmi
.mem_chunks
[i
].req_id
);
1736 host_mem_chunks
+= sizeof(*tlv
);
1737 host_mem_chunks
+= sizeof(*chunk
);
1741 static struct sk_buff
*ath10k_wmi_tlv_op_gen_init(struct ath10k
*ar
)
1743 struct sk_buff
*skb
;
1744 struct wmi_tlv
*tlv
;
1745 struct wmi_tlv_init_cmd
*cmd
;
1746 struct wmi_tlv_resource_config
*cfg
;
1748 size_t len
, chunks_len
;
1751 chunks_len
= ar
->wmi
.num_mem_chunks
*
1752 (sizeof(struct host_memory_chunk_tlv
) + sizeof(*tlv
));
1753 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
1754 (sizeof(*tlv
) + sizeof(*cfg
)) +
1755 (sizeof(*tlv
) + chunks_len
);
1757 skb
= ath10k_wmi_alloc_skb(ar
, len
);
1759 return ERR_PTR(-ENOMEM
);
1764 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_INIT_CMD
);
1765 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1766 cmd
= (void *)tlv
->value
;
1767 ptr
+= sizeof(*tlv
);
1768 ptr
+= sizeof(*cmd
);
1771 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESOURCE_CONFIG
);
1772 tlv
->len
= __cpu_to_le16(sizeof(*cfg
));
1773 cfg
= (void *)tlv
->value
;
1774 ptr
+= sizeof(*tlv
);
1775 ptr
+= sizeof(*cfg
);
1778 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
1779 tlv
->len
= __cpu_to_le16(chunks_len
);
1780 chunks
= (void *)tlv
->value
;
1782 ptr
+= sizeof(*tlv
);
1785 cmd
->abi
.abi_ver0
= __cpu_to_le32(WMI_TLV_ABI_VER0
);
1786 cmd
->abi
.abi_ver1
= __cpu_to_le32(WMI_TLV_ABI_VER1
);
1787 cmd
->abi
.abi_ver_ns0
= __cpu_to_le32(WMI_TLV_ABI_VER_NS0
);
1788 cmd
->abi
.abi_ver_ns1
= __cpu_to_le32(WMI_TLV_ABI_VER_NS1
);
1789 cmd
->abi
.abi_ver_ns2
= __cpu_to_le32(WMI_TLV_ABI_VER_NS2
);
1790 cmd
->abi
.abi_ver_ns3
= __cpu_to_le32(WMI_TLV_ABI_VER_NS3
);
1791 cmd
->num_host_mem_chunks
= __cpu_to_le32(ar
->wmi
.num_mem_chunks
);
1793 cfg
->num_vdevs
= __cpu_to_le32(TARGET_TLV_NUM_VDEVS
);
1795 if (ar
->hw_params
.num_peers
)
1796 cfg
->num_peers
= __cpu_to_le32(ar
->hw_params
.num_peers
);
1798 cfg
->num_peers
= __cpu_to_le32(TARGET_TLV_NUM_PEERS
);
1799 cfg
->ast_skid_limit
= __cpu_to_le32(ar
->hw_params
.ast_skid_limit
);
1800 cfg
->num_wds_entries
= __cpu_to_le32(ar
->hw_params
.num_wds_entries
);
1802 if (test_bit(WMI_SERVICE_RX_FULL_REORDER
, ar
->wmi
.svc_map
)) {
1803 cfg
->num_offload_peers
= __cpu_to_le32(TARGET_TLV_NUM_VDEVS
);
1804 cfg
->num_offload_reorder_bufs
= __cpu_to_le32(TARGET_TLV_NUM_VDEVS
);
1806 cfg
->num_offload_peers
= __cpu_to_le32(0);
1807 cfg
->num_offload_reorder_bufs
= __cpu_to_le32(0);
1810 cfg
->num_peer_keys
= __cpu_to_le32(2);
1811 if (ar
->hw_params
.num_peers
)
1812 cfg
->num_tids
= __cpu_to_le32(ar
->hw_params
.num_peers
* 2);
1814 cfg
->num_tids
= __cpu_to_le32(TARGET_TLV_NUM_TIDS
);
1815 cfg
->tx_chain_mask
= __cpu_to_le32(0x7);
1816 cfg
->rx_chain_mask
= __cpu_to_le32(0x7);
1817 cfg
->rx_timeout_pri
[0] = __cpu_to_le32(0x64);
1818 cfg
->rx_timeout_pri
[1] = __cpu_to_le32(0x64);
1819 cfg
->rx_timeout_pri
[2] = __cpu_to_le32(0x64);
1820 cfg
->rx_timeout_pri
[3] = __cpu_to_le32(0x28);
1821 cfg
->rx_decap_mode
= __cpu_to_le32(ar
->wmi
.rx_decap_mode
);
1822 cfg
->scan_max_pending_reqs
= __cpu_to_le32(4);
1823 cfg
->bmiss_offload_max_vdev
= __cpu_to_le32(TARGET_TLV_NUM_VDEVS
);
1824 cfg
->roam_offload_max_vdev
= __cpu_to_le32(TARGET_TLV_NUM_VDEVS
);
1825 cfg
->roam_offload_max_ap_profiles
= __cpu_to_le32(8);
1826 cfg
->num_mcast_groups
= __cpu_to_le32(0);
1827 cfg
->num_mcast_table_elems
= __cpu_to_le32(0);
1828 cfg
->mcast2ucast_mode
= __cpu_to_le32(0);
1829 cfg
->tx_dbg_log_size
= __cpu_to_le32(0x400);
1830 cfg
->dma_burst_size
= __cpu_to_le32(0);
1831 cfg
->mac_aggr_delim
= __cpu_to_le32(0);
1832 cfg
->rx_skip_defrag_timeout_dup_detection_check
= __cpu_to_le32(0);
1833 cfg
->vow_config
= __cpu_to_le32(0);
1834 cfg
->gtk_offload_max_vdev
= __cpu_to_le32(2);
1835 cfg
->num_msdu_desc
= __cpu_to_le32(ar
->htt
.max_num_pending_tx
);
1836 cfg
->max_frag_entries
= __cpu_to_le32(2);
1837 cfg
->num_tdls_vdevs
= __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS
);
1838 cfg
->num_tdls_conn_table_entries
= __cpu_to_le32(0x20);
1839 cfg
->beacon_tx_offload_max_vdev
= __cpu_to_le32(2);
1840 cfg
->num_multicast_filter_entries
= __cpu_to_le32(5);
1841 cfg
->num_wow_filters
= __cpu_to_le32(ar
->wow
.max_num_patterns
);
1842 cfg
->num_keep_alive_pattern
= __cpu_to_le32(6);
1843 cfg
->keep_alive_pattern_size
= __cpu_to_le32(0);
1844 cfg
->max_tdls_concurrent_sleep_sta
= __cpu_to_le32(1);
1845 cfg
->max_tdls_concurrent_buffer_sta
= __cpu_to_le32(1);
1846 cfg
->wmi_send_separate
= __cpu_to_le32(0);
1847 cfg
->num_ocb_vdevs
= __cpu_to_le32(0);
1848 cfg
->num_ocb_channels
= __cpu_to_le32(0);
1849 cfg
->num_ocb_schedules
= __cpu_to_le32(0);
1850 cfg
->host_capab
= __cpu_to_le32(WMI_TLV_FLAG_MGMT_BUNDLE_TX_COMPL
);
1852 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI
, ar
->wmi
.svc_map
))
1853 cfg
->host_capab
|= __cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_ACK_RSSI
);
1855 ath10k_wmi_tlv_put_host_mem_chunks(ar
, chunks
);
1857 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv init\n");
1861 static struct sk_buff
*
1862 ath10k_wmi_tlv_op_gen_start_scan(struct ath10k
*ar
,
1863 const struct wmi_start_scan_arg
*arg
)
1865 struct wmi_tlv_start_scan_cmd
*cmd
;
1866 struct wmi_tlv
*tlv
;
1867 struct sk_buff
*skb
;
1868 size_t len
, chan_len
, ssid_len
, bssid_len
, ie_len
;
1870 struct wmi_ssid
*ssids
;
1871 struct wmi_mac_addr
*addrs
;
1875 ret
= ath10k_wmi_start_scan_verify(arg
);
1877 return ERR_PTR(ret
);
1879 chan_len
= arg
->n_channels
* sizeof(__le32
);
1880 ssid_len
= arg
->n_ssids
* sizeof(struct wmi_ssid
);
1881 bssid_len
= arg
->n_bssids
* sizeof(struct wmi_mac_addr
);
1882 ie_len
= roundup(arg
->ie_len
, 4);
1883 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
1884 sizeof(*tlv
) + chan_len
+
1885 sizeof(*tlv
) + ssid_len
+
1886 sizeof(*tlv
) + bssid_len
+
1887 sizeof(*tlv
) + ie_len
;
1889 skb
= ath10k_wmi_alloc_skb(ar
, len
);
1891 return ERR_PTR(-ENOMEM
);
1893 ptr
= (void *)skb
->data
;
1895 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_START_SCAN_CMD
);
1896 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1897 cmd
= (void *)tlv
->value
;
1899 ath10k_wmi_put_start_scan_common(&cmd
->common
, arg
);
1900 cmd
->burst_duration_ms
= __cpu_to_le32(arg
->burst_duration_ms
);
1901 cmd
->num_channels
= __cpu_to_le32(arg
->n_channels
);
1902 cmd
->num_ssids
= __cpu_to_le32(arg
->n_ssids
);
1903 cmd
->num_bssids
= __cpu_to_le32(arg
->n_bssids
);
1904 cmd
->ie_len
= __cpu_to_le32(arg
->ie_len
);
1905 cmd
->num_probes
= __cpu_to_le32(3);
1906 ether_addr_copy(cmd
->mac_addr
.addr
, arg
->mac_addr
.addr
);
1907 ether_addr_copy(cmd
->mac_mask
.addr
, arg
->mac_mask
.addr
);
1909 /* FIXME: There are some scan flag inconsistencies across firmwares,
1910 * e.g. WMI-TLV inverts the logic behind the following flag.
1912 cmd
->common
.scan_ctrl_flags
^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ
);
1914 ptr
+= sizeof(*tlv
);
1915 ptr
+= sizeof(*cmd
);
1918 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
1919 tlv
->len
= __cpu_to_le16(chan_len
);
1920 chans
= (void *)tlv
->value
;
1921 for (i
= 0; i
< arg
->n_channels
; i
++)
1922 chans
[i
] = __cpu_to_le32(arg
->channels
[i
]);
1924 ptr
+= sizeof(*tlv
);
1928 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT
);
1929 tlv
->len
= __cpu_to_le16(ssid_len
);
1930 ssids
= (void *)tlv
->value
;
1931 for (i
= 0; i
< arg
->n_ssids
; i
++) {
1932 ssids
[i
].ssid_len
= __cpu_to_le32(arg
->ssids
[i
].len
);
1933 memcpy(ssids
[i
].ssid
, arg
->ssids
[i
].ssid
, arg
->ssids
[i
].len
);
1936 ptr
+= sizeof(*tlv
);
1940 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_FIXED_STRUCT
);
1941 tlv
->len
= __cpu_to_le16(bssid_len
);
1942 addrs
= (void *)tlv
->value
;
1943 for (i
= 0; i
< arg
->n_bssids
; i
++)
1944 ether_addr_copy(addrs
[i
].addr
, arg
->bssids
[i
].bssid
);
1946 ptr
+= sizeof(*tlv
);
1950 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
1951 tlv
->len
= __cpu_to_le16(ie_len
);
1952 memcpy(tlv
->value
, arg
->ie
, arg
->ie_len
);
1954 ptr
+= sizeof(*tlv
);
1957 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv start scan\n");
1961 static struct sk_buff
*
1962 ath10k_wmi_tlv_op_gen_stop_scan(struct ath10k
*ar
,
1963 const struct wmi_stop_scan_arg
*arg
)
1965 struct wmi_stop_scan_cmd
*cmd
;
1966 struct wmi_tlv
*tlv
;
1967 struct sk_buff
*skb
;
1971 if (arg
->req_id
> 0xFFF)
1972 return ERR_PTR(-EINVAL
);
1973 if (arg
->req_type
== WMI_SCAN_STOP_ONE
&& arg
->u
.scan_id
> 0xFFF)
1974 return ERR_PTR(-EINVAL
);
1976 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
1978 return ERR_PTR(-ENOMEM
);
1980 scan_id
= arg
->u
.scan_id
;
1981 scan_id
|= WMI_HOST_SCAN_REQ_ID_PREFIX
;
1983 req_id
= arg
->req_id
;
1984 req_id
|= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX
;
1986 tlv
= (void *)skb
->data
;
1987 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STOP_SCAN_CMD
);
1988 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
1989 cmd
= (void *)tlv
->value
;
1990 cmd
->req_type
= __cpu_to_le32(arg
->req_type
);
1991 cmd
->vdev_id
= __cpu_to_le32(arg
->u
.vdev_id
);
1992 cmd
->scan_id
= __cpu_to_le32(scan_id
);
1993 cmd
->scan_req_id
= __cpu_to_le32(req_id
);
1995 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv stop scan\n");
1999 static int ath10k_wmi_tlv_op_get_vdev_subtype(struct ath10k
*ar
,
2000 enum wmi_vdev_subtype subtype
)
2003 case WMI_VDEV_SUBTYPE_NONE
:
2004 return WMI_TLV_VDEV_SUBTYPE_NONE
;
2005 case WMI_VDEV_SUBTYPE_P2P_DEVICE
:
2006 return WMI_TLV_VDEV_SUBTYPE_P2P_DEV
;
2007 case WMI_VDEV_SUBTYPE_P2P_CLIENT
:
2008 return WMI_TLV_VDEV_SUBTYPE_P2P_CLI
;
2009 case WMI_VDEV_SUBTYPE_P2P_GO
:
2010 return WMI_TLV_VDEV_SUBTYPE_P2P_GO
;
2011 case WMI_VDEV_SUBTYPE_PROXY_STA
:
2012 return WMI_TLV_VDEV_SUBTYPE_PROXY_STA
;
2013 case WMI_VDEV_SUBTYPE_MESH_11S
:
2014 return WMI_TLV_VDEV_SUBTYPE_MESH_11S
;
2015 case WMI_VDEV_SUBTYPE_MESH_NON_11S
:
2021 static struct sk_buff
*
2022 ath10k_wmi_tlv_op_gen_vdev_create(struct ath10k
*ar
,
2024 enum wmi_vdev_type vdev_type
,
2025 enum wmi_vdev_subtype vdev_subtype
,
2026 const u8 mac_addr
[ETH_ALEN
])
2028 struct wmi_vdev_create_cmd
*cmd
;
2029 struct wmi_tlv
*tlv
;
2030 struct sk_buff
*skb
;
2032 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2034 return ERR_PTR(-ENOMEM
);
2036 tlv
= (void *)skb
->data
;
2037 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_CREATE_CMD
);
2038 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2039 cmd
= (void *)tlv
->value
;
2040 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2041 cmd
->vdev_type
= __cpu_to_le32(vdev_type
);
2042 cmd
->vdev_subtype
= __cpu_to_le32(vdev_subtype
);
2043 ether_addr_copy(cmd
->vdev_macaddr
.addr
, mac_addr
);
2045 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev create\n");
2049 static struct sk_buff
*
2050 ath10k_wmi_tlv_op_gen_vdev_delete(struct ath10k
*ar
, u32 vdev_id
)
2052 struct wmi_vdev_delete_cmd
*cmd
;
2053 struct wmi_tlv
*tlv
;
2054 struct sk_buff
*skb
;
2056 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2058 return ERR_PTR(-ENOMEM
);
2060 tlv
= (void *)skb
->data
;
2061 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DELETE_CMD
);
2062 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2063 cmd
= (void *)tlv
->value
;
2064 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2066 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev delete\n");
2070 static struct sk_buff
*
2071 ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k
*ar
,
2072 const struct wmi_vdev_start_request_arg
*arg
,
2075 struct wmi_tlv_vdev_start_cmd
*cmd
;
2076 struct wmi_channel
*ch
;
2077 struct wmi_tlv
*tlv
;
2078 struct sk_buff
*skb
;
2083 if (WARN_ON(arg
->hidden_ssid
&& !arg
->ssid
))
2084 return ERR_PTR(-EINVAL
);
2085 if (WARN_ON(arg
->ssid_len
> sizeof(cmd
->ssid
.ssid
)))
2086 return ERR_PTR(-EINVAL
);
2088 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
2089 (sizeof(*tlv
) + sizeof(*ch
)) +
2091 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2093 return ERR_PTR(-ENOMEM
);
2095 if (arg
->hidden_ssid
)
2096 flags
|= WMI_VDEV_START_HIDDEN_SSID
;
2097 if (arg
->pmf_enabled
)
2098 flags
|= WMI_VDEV_START_PMF_ENABLED
;
2100 ptr
= (void *)skb
->data
;
2103 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_START_REQUEST_CMD
);
2104 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2105 cmd
= (void *)tlv
->value
;
2106 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2107 cmd
->bcn_intval
= __cpu_to_le32(arg
->bcn_intval
);
2108 cmd
->dtim_period
= __cpu_to_le32(arg
->dtim_period
);
2109 cmd
->flags
= __cpu_to_le32(flags
);
2110 cmd
->bcn_tx_rate
= __cpu_to_le32(arg
->bcn_tx_rate
);
2111 cmd
->bcn_tx_power
= __cpu_to_le32(arg
->bcn_tx_power
);
2112 cmd
->disable_hw_ack
= __cpu_to_le32(arg
->disable_hw_ack
);
2115 cmd
->ssid
.ssid_len
= __cpu_to_le32(arg
->ssid_len
);
2116 memcpy(cmd
->ssid
.ssid
, arg
->ssid
, arg
->ssid_len
);
2119 ptr
+= sizeof(*tlv
);
2120 ptr
+= sizeof(*cmd
);
2123 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL
);
2124 tlv
->len
= __cpu_to_le16(sizeof(*ch
));
2125 ch
= (void *)tlv
->value
;
2126 ath10k_wmi_put_wmi_channel(ch
, &arg
->channel
);
2128 ptr
+= sizeof(*tlv
);
2132 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
2135 /* Note: This is a nested TLV containing:
2136 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
2139 ptr
+= sizeof(*tlv
);
2142 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev start\n");
2146 static struct sk_buff
*
2147 ath10k_wmi_tlv_op_gen_vdev_stop(struct ath10k
*ar
, u32 vdev_id
)
2149 struct wmi_vdev_stop_cmd
*cmd
;
2150 struct wmi_tlv
*tlv
;
2151 struct sk_buff
*skb
;
2153 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2155 return ERR_PTR(-ENOMEM
);
2157 tlv
= (void *)skb
->data
;
2158 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_STOP_CMD
);
2159 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2160 cmd
= (void *)tlv
->value
;
2161 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2163 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev stop\n");
2167 static struct sk_buff
*
2168 ath10k_wmi_tlv_op_gen_vdev_up(struct ath10k
*ar
, u32 vdev_id
, u32 aid
,
2172 struct wmi_vdev_up_cmd
*cmd
;
2173 struct wmi_tlv
*tlv
;
2174 struct sk_buff
*skb
;
2176 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2178 return ERR_PTR(-ENOMEM
);
2180 tlv
= (void *)skb
->data
;
2181 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_UP_CMD
);
2182 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2183 cmd
= (void *)tlv
->value
;
2184 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2185 cmd
->vdev_assoc_id
= __cpu_to_le32(aid
);
2186 ether_addr_copy(cmd
->vdev_bssid
.addr
, bssid
);
2188 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev up\n");
2192 static struct sk_buff
*
2193 ath10k_wmi_tlv_op_gen_vdev_down(struct ath10k
*ar
, u32 vdev_id
)
2195 struct wmi_vdev_down_cmd
*cmd
;
2196 struct wmi_tlv
*tlv
;
2197 struct sk_buff
*skb
;
2199 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2201 return ERR_PTR(-ENOMEM
);
2203 tlv
= (void *)skb
->data
;
2204 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_DOWN_CMD
);
2205 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2206 cmd
= (void *)tlv
->value
;
2207 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2209 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev down\n");
2213 static struct sk_buff
*
2214 ath10k_wmi_tlv_op_gen_vdev_set_param(struct ath10k
*ar
, u32 vdev_id
,
2215 u32 param_id
, u32 param_value
)
2217 struct wmi_vdev_set_param_cmd
*cmd
;
2218 struct wmi_tlv
*tlv
;
2219 struct sk_buff
*skb
;
2221 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2223 return ERR_PTR(-ENOMEM
);
2225 tlv
= (void *)skb
->data
;
2226 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_PARAM_CMD
);
2227 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2228 cmd
= (void *)tlv
->value
;
2229 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2230 cmd
->param_id
= __cpu_to_le32(param_id
);
2231 cmd
->param_value
= __cpu_to_le32(param_value
);
2233 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev %d set param %d value 0x%x\n",
2234 vdev_id
, param_id
, param_value
);
2238 static struct sk_buff
*
2239 ath10k_wmi_tlv_op_gen_vdev_install_key(struct ath10k
*ar
,
2240 const struct wmi_vdev_install_key_arg
*arg
)
2242 struct wmi_vdev_install_key_cmd
*cmd
;
2243 struct wmi_tlv
*tlv
;
2244 struct sk_buff
*skb
;
2248 if (arg
->key_cipher
== ar
->wmi_key_cipher
[WMI_CIPHER_NONE
] &&
2250 return ERR_PTR(-EINVAL
);
2251 if (arg
->key_cipher
!= ar
->wmi_key_cipher
[WMI_CIPHER_NONE
] &&
2253 return ERR_PTR(-EINVAL
);
2255 len
= sizeof(*tlv
) + sizeof(*cmd
) +
2256 sizeof(*tlv
) + roundup(arg
->key_len
, sizeof(__le32
));
2257 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2259 return ERR_PTR(-ENOMEM
);
2261 ptr
= (void *)skb
->data
;
2263 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_INSTALL_KEY_CMD
);
2264 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2265 cmd
= (void *)tlv
->value
;
2266 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2267 cmd
->key_idx
= __cpu_to_le32(arg
->key_idx
);
2268 cmd
->key_flags
= __cpu_to_le32(arg
->key_flags
);
2269 cmd
->key_cipher
= __cpu_to_le32(arg
->key_cipher
);
2270 cmd
->key_len
= __cpu_to_le32(arg
->key_len
);
2271 cmd
->key_txmic_len
= __cpu_to_le32(arg
->key_txmic_len
);
2272 cmd
->key_rxmic_len
= __cpu_to_le32(arg
->key_rxmic_len
);
2275 ether_addr_copy(cmd
->peer_macaddr
.addr
, arg
->macaddr
);
2277 ptr
+= sizeof(*tlv
);
2278 ptr
+= sizeof(*cmd
);
2281 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
2282 tlv
->len
= __cpu_to_le16(roundup(arg
->key_len
, sizeof(__le32
)));
2284 memcpy(tlv
->value
, arg
->key_data
, arg
->key_len
);
2286 ptr
+= sizeof(*tlv
);
2287 ptr
+= roundup(arg
->key_len
, sizeof(__le32
));
2289 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev install key\n");
2293 static void *ath10k_wmi_tlv_put_uapsd_ac(struct ath10k
*ar
, void *ptr
,
2294 const struct wmi_sta_uapsd_auto_trig_arg
*arg
)
2296 struct wmi_sta_uapsd_auto_trig_param
*ac
;
2297 struct wmi_tlv
*tlv
;
2300 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_PARAM
);
2301 tlv
->len
= __cpu_to_le16(sizeof(*ac
));
2302 ac
= (void *)tlv
->value
;
2304 ac
->wmm_ac
= __cpu_to_le32(arg
->wmm_ac
);
2305 ac
->user_priority
= __cpu_to_le32(arg
->user_priority
);
2306 ac
->service_interval
= __cpu_to_le32(arg
->service_interval
);
2307 ac
->suspend_interval
= __cpu_to_le32(arg
->suspend_interval
);
2308 ac
->delay_interval
= __cpu_to_le32(arg
->delay_interval
);
2310 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
2311 "wmi tlv vdev sta uapsd auto trigger ac %d prio %d svc int %d susp int %d delay int %d\n",
2312 ac
->wmm_ac
, ac
->user_priority
, ac
->service_interval
,
2313 ac
->suspend_interval
, ac
->delay_interval
);
2315 return ptr
+ sizeof(*tlv
) + sizeof(*ac
);
2318 static struct sk_buff
*
2319 ath10k_wmi_tlv_op_gen_vdev_sta_uapsd(struct ath10k
*ar
, u32 vdev_id
,
2320 const u8 peer_addr
[ETH_ALEN
],
2321 const struct wmi_sta_uapsd_auto_trig_arg
*args
,
2324 struct wmi_sta_uapsd_auto_trig_cmd_fixed_param
*cmd
;
2325 struct wmi_sta_uapsd_auto_trig_param
*ac
;
2326 struct wmi_tlv
*tlv
;
2327 struct sk_buff
*skb
;
2333 ac_tlv_len
= num_ac
* (sizeof(*tlv
) + sizeof(*ac
));
2334 len
= sizeof(*tlv
) + sizeof(*cmd
) +
2335 sizeof(*tlv
) + ac_tlv_len
;
2336 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2338 return ERR_PTR(-ENOMEM
);
2340 ptr
= (void *)skb
->data
;
2342 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_UAPSD_AUTO_TRIG_CMD
);
2343 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2344 cmd
= (void *)tlv
->value
;
2345 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2346 cmd
->num_ac
= __cpu_to_le32(num_ac
);
2347 ether_addr_copy(cmd
->peer_macaddr
.addr
, peer_addr
);
2349 ptr
+= sizeof(*tlv
);
2350 ptr
+= sizeof(*cmd
);
2353 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
2354 tlv
->len
= __cpu_to_le16(ac_tlv_len
);
2355 ac
= (void *)tlv
->value
;
2357 ptr
+= sizeof(*tlv
);
2358 for (i
= 0; i
< num_ac
; i
++)
2359 ptr
= ath10k_wmi_tlv_put_uapsd_ac(ar
, ptr
, &args
[i
]);
2361 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev sta uapsd auto trigger\n");
2365 static void *ath10k_wmi_tlv_put_wmm(void *ptr
,
2366 const struct wmi_wmm_params_arg
*arg
)
2368 struct wmi_wmm_params
*wmm
;
2369 struct wmi_tlv
*tlv
;
2372 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WMM_PARAMS
);
2373 tlv
->len
= __cpu_to_le16(sizeof(*wmm
));
2374 wmm
= (void *)tlv
->value
;
2375 ath10k_wmi_set_wmm_param(wmm
, arg
);
2377 return ptr
+ sizeof(*tlv
) + sizeof(*wmm
);
2380 static struct sk_buff
*
2381 ath10k_wmi_tlv_op_gen_vdev_wmm_conf(struct ath10k
*ar
, u32 vdev_id
,
2382 const struct wmi_wmm_params_all_arg
*arg
)
2384 struct wmi_tlv_vdev_set_wmm_cmd
*cmd
;
2385 struct wmi_tlv
*tlv
;
2386 struct sk_buff
*skb
;
2390 len
= sizeof(*tlv
) + sizeof(*cmd
);
2391 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2393 return ERR_PTR(-ENOMEM
);
2395 ptr
= (void *)skb
->data
;
2397 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SET_WMM_PARAMS_CMD
);
2398 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2399 cmd
= (void *)tlv
->value
;
2400 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2402 ath10k_wmi_set_wmm_param(&cmd
->vdev_wmm_params
[0].params
, &arg
->ac_be
);
2403 ath10k_wmi_set_wmm_param(&cmd
->vdev_wmm_params
[1].params
, &arg
->ac_bk
);
2404 ath10k_wmi_set_wmm_param(&cmd
->vdev_wmm_params
[2].params
, &arg
->ac_vi
);
2405 ath10k_wmi_set_wmm_param(&cmd
->vdev_wmm_params
[3].params
, &arg
->ac_vo
);
2407 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv vdev wmm conf\n");
2411 static struct sk_buff
*
2412 ath10k_wmi_tlv_op_gen_sta_keepalive(struct ath10k
*ar
,
2413 const struct wmi_sta_keepalive_arg
*arg
)
2415 struct wmi_tlv_sta_keepalive_cmd
*cmd
;
2416 struct wmi_sta_keepalive_arp_resp
*arp
;
2417 struct sk_buff
*skb
;
2418 struct wmi_tlv
*tlv
;
2422 len
= sizeof(*tlv
) + sizeof(*cmd
) +
2423 sizeof(*tlv
) + sizeof(*arp
);
2424 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2426 return ERR_PTR(-ENOMEM
);
2428 ptr
= (void *)skb
->data
;
2430 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALIVE_CMD
);
2431 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2432 cmd
= (void *)tlv
->value
;
2433 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2434 cmd
->enabled
= __cpu_to_le32(arg
->enabled
);
2435 cmd
->method
= __cpu_to_le32(arg
->method
);
2436 cmd
->interval
= __cpu_to_le32(arg
->interval
);
2438 ptr
+= sizeof(*tlv
);
2439 ptr
+= sizeof(*cmd
);
2442 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_KEEPALVE_ARP_RESPONSE
);
2443 tlv
->len
= __cpu_to_le16(sizeof(*arp
));
2444 arp
= (void *)tlv
->value
;
2446 arp
->src_ip4_addr
= arg
->src_ip4_addr
;
2447 arp
->dest_ip4_addr
= arg
->dest_ip4_addr
;
2448 ether_addr_copy(arp
->dest_mac_addr
.addr
, arg
->dest_mac_addr
);
2450 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv sta keepalive vdev %d enabled %d method %d interval %d\n",
2451 arg
->vdev_id
, arg
->enabled
, arg
->method
, arg
->interval
);
2455 static struct sk_buff
*
2456 ath10k_wmi_tlv_op_gen_peer_create(struct ath10k
*ar
, u32 vdev_id
,
2457 const u8 peer_addr
[ETH_ALEN
],
2458 enum wmi_peer_type peer_type
)
2460 struct wmi_tlv_peer_create_cmd
*cmd
;
2461 struct wmi_tlv
*tlv
;
2462 struct sk_buff
*skb
;
2464 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2466 return ERR_PTR(-ENOMEM
);
2468 tlv
= (void *)skb
->data
;
2469 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_CREATE_CMD
);
2470 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2471 cmd
= (void *)tlv
->value
;
2472 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2473 cmd
->peer_type
= __cpu_to_le32(peer_type
);
2474 ether_addr_copy(cmd
->peer_addr
.addr
, peer_addr
);
2476 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv peer create\n");
2480 static struct sk_buff
*
2481 ath10k_wmi_tlv_op_gen_peer_delete(struct ath10k
*ar
, u32 vdev_id
,
2482 const u8 peer_addr
[ETH_ALEN
])
2484 struct wmi_peer_delete_cmd
*cmd
;
2485 struct wmi_tlv
*tlv
;
2486 struct sk_buff
*skb
;
2488 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2490 return ERR_PTR(-ENOMEM
);
2492 tlv
= (void *)skb
->data
;
2493 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_DELETE_CMD
);
2494 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2495 cmd
= (void *)tlv
->value
;
2496 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2497 ether_addr_copy(cmd
->peer_macaddr
.addr
, peer_addr
);
2499 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv peer delete\n");
2503 static struct sk_buff
*
2504 ath10k_wmi_tlv_op_gen_peer_flush(struct ath10k
*ar
, u32 vdev_id
,
2505 const u8 peer_addr
[ETH_ALEN
], u32 tid_bitmap
)
2507 struct wmi_peer_flush_tids_cmd
*cmd
;
2508 struct wmi_tlv
*tlv
;
2509 struct sk_buff
*skb
;
2511 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2513 return ERR_PTR(-ENOMEM
);
2515 tlv
= (void *)skb
->data
;
2516 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_FLUSH_TIDS_CMD
);
2517 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2518 cmd
= (void *)tlv
->value
;
2519 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2520 cmd
->peer_tid_bitmap
= __cpu_to_le32(tid_bitmap
);
2521 ether_addr_copy(cmd
->peer_macaddr
.addr
, peer_addr
);
2523 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv peer flush\n");
2527 static struct sk_buff
*
2528 ath10k_wmi_tlv_op_gen_peer_set_param(struct ath10k
*ar
, u32 vdev_id
,
2529 const u8
*peer_addr
,
2530 enum wmi_peer_param param_id
,
2533 struct wmi_peer_set_param_cmd
*cmd
;
2534 struct wmi_tlv
*tlv
;
2535 struct sk_buff
*skb
;
2537 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2539 return ERR_PTR(-ENOMEM
);
2541 tlv
= (void *)skb
->data
;
2542 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_SET_PARAM_CMD
);
2543 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2544 cmd
= (void *)tlv
->value
;
2545 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2546 cmd
->param_id
= __cpu_to_le32(param_id
);
2547 cmd
->param_value
= __cpu_to_le32(param_value
);
2548 ether_addr_copy(cmd
->peer_macaddr
.addr
, peer_addr
);
2550 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
2551 "wmi tlv vdev %d peer %pM set param %d value 0x%x\n",
2552 vdev_id
, peer_addr
, param_id
, param_value
);
2556 static struct sk_buff
*
2557 ath10k_wmi_tlv_op_gen_peer_assoc(struct ath10k
*ar
,
2558 const struct wmi_peer_assoc_complete_arg
*arg
)
2560 struct wmi_tlv_peer_assoc_cmd
*cmd
;
2561 struct wmi_vht_rate_set
*vht_rate
;
2562 struct wmi_tlv
*tlv
;
2563 struct sk_buff
*skb
;
2564 size_t len
, legacy_rate_len
, ht_rate_len
;
2567 if (arg
->peer_mpdu_density
> 16)
2568 return ERR_PTR(-EINVAL
);
2569 if (arg
->peer_legacy_rates
.num_rates
> MAX_SUPPORTED_RATES
)
2570 return ERR_PTR(-EINVAL
);
2571 if (arg
->peer_ht_rates
.num_rates
> MAX_SUPPORTED_RATES
)
2572 return ERR_PTR(-EINVAL
);
2574 legacy_rate_len
= roundup(arg
->peer_legacy_rates
.num_rates
,
2576 ht_rate_len
= roundup(arg
->peer_ht_rates
.num_rates
, sizeof(__le32
));
2577 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
2578 (sizeof(*tlv
) + legacy_rate_len
) +
2579 (sizeof(*tlv
) + ht_rate_len
) +
2580 (sizeof(*tlv
) + sizeof(*vht_rate
));
2581 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2583 return ERR_PTR(-ENOMEM
);
2585 ptr
= (void *)skb
->data
;
2587 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PEER_ASSOC_COMPLETE_CMD
);
2588 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2589 cmd
= (void *)tlv
->value
;
2591 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2592 cmd
->new_assoc
= __cpu_to_le32(arg
->peer_reassoc
? 0 : 1);
2593 cmd
->assoc_id
= __cpu_to_le32(arg
->peer_aid
);
2594 cmd
->flags
= __cpu_to_le32(arg
->peer_flags
);
2595 cmd
->caps
= __cpu_to_le32(arg
->peer_caps
);
2596 cmd
->listen_intval
= __cpu_to_le32(arg
->peer_listen_intval
);
2597 cmd
->ht_caps
= __cpu_to_le32(arg
->peer_ht_caps
);
2598 cmd
->max_mpdu
= __cpu_to_le32(arg
->peer_max_mpdu
);
2599 cmd
->mpdu_density
= __cpu_to_le32(arg
->peer_mpdu_density
);
2600 cmd
->rate_caps
= __cpu_to_le32(arg
->peer_rate_caps
);
2601 cmd
->nss
= __cpu_to_le32(arg
->peer_num_spatial_streams
);
2602 cmd
->vht_caps
= __cpu_to_le32(arg
->peer_vht_caps
);
2603 cmd
->phy_mode
= __cpu_to_le32(arg
->peer_phymode
);
2604 cmd
->num_legacy_rates
= __cpu_to_le32(arg
->peer_legacy_rates
.num_rates
);
2605 cmd
->num_ht_rates
= __cpu_to_le32(arg
->peer_ht_rates
.num_rates
);
2606 ether_addr_copy(cmd
->mac_addr
.addr
, arg
->addr
);
2608 ptr
+= sizeof(*tlv
);
2609 ptr
+= sizeof(*cmd
);
2612 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
2613 tlv
->len
= __cpu_to_le16(legacy_rate_len
);
2614 memcpy(tlv
->value
, arg
->peer_legacy_rates
.rates
,
2615 arg
->peer_legacy_rates
.num_rates
);
2617 ptr
+= sizeof(*tlv
);
2618 ptr
+= legacy_rate_len
;
2621 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
2622 tlv
->len
= __cpu_to_le16(ht_rate_len
);
2623 memcpy(tlv
->value
, arg
->peer_ht_rates
.rates
,
2624 arg
->peer_ht_rates
.num_rates
);
2626 ptr
+= sizeof(*tlv
);
2630 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VHT_RATE_SET
);
2631 tlv
->len
= __cpu_to_le16(sizeof(*vht_rate
));
2632 vht_rate
= (void *)tlv
->value
;
2634 vht_rate
->rx_max_rate
= __cpu_to_le32(arg
->peer_vht_rates
.rx_max_rate
);
2635 vht_rate
->rx_mcs_set
= __cpu_to_le32(arg
->peer_vht_rates
.rx_mcs_set
);
2636 vht_rate
->tx_max_rate
= __cpu_to_le32(arg
->peer_vht_rates
.tx_max_rate
);
2637 vht_rate
->tx_mcs_set
= __cpu_to_le32(arg
->peer_vht_rates
.tx_mcs_set
);
2639 ptr
+= sizeof(*tlv
);
2640 ptr
+= sizeof(*vht_rate
);
2642 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv peer assoc\n");
2646 static struct sk_buff
*
2647 ath10k_wmi_tlv_op_gen_set_psmode(struct ath10k
*ar
, u32 vdev_id
,
2648 enum wmi_sta_ps_mode psmode
)
2650 struct wmi_sta_powersave_mode_cmd
*cmd
;
2651 struct wmi_tlv
*tlv
;
2652 struct sk_buff
*skb
;
2654 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2656 return ERR_PTR(-ENOMEM
);
2658 tlv
= (void *)skb
->data
;
2659 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_MODE_CMD
);
2660 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2661 cmd
= (void *)tlv
->value
;
2662 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2663 cmd
->sta_ps_mode
= __cpu_to_le32(psmode
);
2665 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv set psmode\n");
2669 static struct sk_buff
*
2670 ath10k_wmi_tlv_op_gen_set_sta_ps(struct ath10k
*ar
, u32 vdev_id
,
2671 enum wmi_sta_powersave_param param_id
,
2674 struct wmi_sta_powersave_param_cmd
*cmd
;
2675 struct wmi_tlv
*tlv
;
2676 struct sk_buff
*skb
;
2678 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2680 return ERR_PTR(-ENOMEM
);
2682 tlv
= (void *)skb
->data
;
2683 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_STA_POWERSAVE_PARAM_CMD
);
2684 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2685 cmd
= (void *)tlv
->value
;
2686 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2687 cmd
->param_id
= __cpu_to_le32(param_id
);
2688 cmd
->param_value
= __cpu_to_le32(param_value
);
2690 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv set sta ps\n");
2694 static struct sk_buff
*
2695 ath10k_wmi_tlv_op_gen_set_ap_ps(struct ath10k
*ar
, u32 vdev_id
, const u8
*mac
,
2696 enum wmi_ap_ps_peer_param param_id
, u32 value
)
2698 struct wmi_ap_ps_peer_cmd
*cmd
;
2699 struct wmi_tlv
*tlv
;
2700 struct sk_buff
*skb
;
2703 return ERR_PTR(-EINVAL
);
2705 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2707 return ERR_PTR(-ENOMEM
);
2709 tlv
= (void *)skb
->data
;
2710 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_AP_PS_PEER_CMD
);
2711 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2712 cmd
= (void *)tlv
->value
;
2713 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2714 cmd
->param_id
= __cpu_to_le32(param_id
);
2715 cmd
->param_value
= __cpu_to_le32(value
);
2716 ether_addr_copy(cmd
->peer_macaddr
.addr
, mac
);
2718 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv ap ps param\n");
2722 static struct sk_buff
*
2723 ath10k_wmi_tlv_op_gen_scan_chan_list(struct ath10k
*ar
,
2724 const struct wmi_scan_chan_list_arg
*arg
)
2726 struct wmi_tlv_scan_chan_list_cmd
*cmd
;
2727 struct wmi_channel
*ci
;
2728 struct wmi_channel_arg
*ch
;
2729 struct wmi_tlv
*tlv
;
2730 struct sk_buff
*skb
;
2731 size_t chans_len
, len
;
2735 chans_len
= arg
->n_channels
* (sizeof(*tlv
) + sizeof(*ci
));
2736 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
2737 (sizeof(*tlv
) + chans_len
);
2739 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2741 return ERR_PTR(-ENOMEM
);
2743 ptr
= (void *)skb
->data
;
2745 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_CHAN_LIST_CMD
);
2746 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2747 cmd
= (void *)tlv
->value
;
2748 cmd
->num_scan_chans
= __cpu_to_le32(arg
->n_channels
);
2750 ptr
+= sizeof(*tlv
);
2751 ptr
+= sizeof(*cmd
);
2754 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
2755 tlv
->len
= __cpu_to_le16(chans_len
);
2756 chans
= (void *)tlv
->value
;
2758 for (i
= 0; i
< arg
->n_channels
; i
++) {
2759 ch
= &arg
->channels
[i
];
2762 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL
);
2763 tlv
->len
= __cpu_to_le16(sizeof(*ci
));
2764 ci
= (void *)tlv
->value
;
2766 ath10k_wmi_put_wmi_channel(ci
, ch
);
2768 chans
+= sizeof(*tlv
);
2769 chans
+= sizeof(*ci
);
2772 ptr
+= sizeof(*tlv
);
2775 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv scan chan list\n");
2779 static struct sk_buff
*
2780 ath10k_wmi_tlv_op_gen_scan_prob_req_oui(struct ath10k
*ar
, u32 prob_req_oui
)
2782 struct wmi_scan_prob_req_oui_cmd
*cmd
;
2783 struct wmi_tlv
*tlv
;
2784 struct sk_buff
*skb
;
2786 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2788 return ERR_PTR(-ENOMEM
);
2790 tlv
= (void *)skb
->data
;
2791 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_SCAN_PROB_REQ_OUI_CMD
);
2792 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2793 cmd
= (void *)tlv
->value
;
2794 cmd
->prob_req_oui
= __cpu_to_le32(prob_req_oui
);
2796 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv scan prob req oui\n");
2800 static struct sk_buff
*
2801 ath10k_wmi_tlv_op_gen_beacon_dma(struct ath10k
*ar
, u32 vdev_id
,
2802 const void *bcn
, size_t bcn_len
,
2803 u32 bcn_paddr
, bool dtim_zero
,
2807 struct wmi_bcn_tx_ref_cmd
*cmd
;
2808 struct wmi_tlv
*tlv
;
2809 struct sk_buff
*skb
;
2810 struct ieee80211_hdr
*hdr
;
2813 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2815 return ERR_PTR(-ENOMEM
);
2817 hdr
= (struct ieee80211_hdr
*)bcn
;
2818 fc
= le16_to_cpu(hdr
->frame_control
);
2820 tlv
= (void *)skb
->data
;
2821 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_SEND_FROM_HOST_CMD
);
2822 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2823 cmd
= (void *)tlv
->value
;
2824 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2825 cmd
->data_len
= __cpu_to_le32(bcn_len
);
2826 cmd
->data_ptr
= __cpu_to_le32(bcn_paddr
);
2828 cmd
->frame_control
= __cpu_to_le32(fc
);
2832 cmd
->flags
|= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO
);
2835 cmd
->flags
|= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB
);
2837 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv beacon dma\n");
2841 static struct sk_buff
*
2842 ath10k_wmi_tlv_op_gen_pdev_set_wmm(struct ath10k
*ar
,
2843 const struct wmi_wmm_params_all_arg
*arg
)
2845 struct wmi_tlv_pdev_set_wmm_cmd
*cmd
;
2846 struct wmi_wmm_params
*wmm
;
2847 struct wmi_tlv
*tlv
;
2848 struct sk_buff
*skb
;
2852 len
= (sizeof(*tlv
) + sizeof(*cmd
)) +
2853 (4 * (sizeof(*tlv
) + sizeof(*wmm
)));
2854 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2856 return ERR_PTR(-ENOMEM
);
2858 ptr
= (void *)skb
->data
;
2861 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_WMM_PARAMS_CMD
);
2862 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2863 cmd
= (void *)tlv
->value
;
2865 /* nothing to set here */
2867 ptr
+= sizeof(*tlv
);
2868 ptr
+= sizeof(*cmd
);
2870 ptr
= ath10k_wmi_tlv_put_wmm(ptr
, &arg
->ac_be
);
2871 ptr
= ath10k_wmi_tlv_put_wmm(ptr
, &arg
->ac_bk
);
2872 ptr
= ath10k_wmi_tlv_put_wmm(ptr
, &arg
->ac_vi
);
2873 ptr
= ath10k_wmi_tlv_put_wmm(ptr
, &arg
->ac_vo
);
2875 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pdev set wmm\n");
2879 static struct sk_buff
*
2880 ath10k_wmi_tlv_op_gen_request_stats(struct ath10k
*ar
, u32 stats_mask
)
2882 struct wmi_request_stats_cmd
*cmd
;
2883 struct wmi_tlv
*tlv
;
2884 struct sk_buff
*skb
;
2886 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
2888 return ERR_PTR(-ENOMEM
);
2890 tlv
= (void *)skb
->data
;
2891 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_REQUEST_STATS_CMD
);
2892 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2893 cmd
= (void *)tlv
->value
;
2894 cmd
->stats_id
= __cpu_to_le32(stats_mask
);
2896 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv request stats\n");
2901 ath10k_wmi_mgmt_tx_alloc_msdu_id(struct ath10k
*ar
, struct sk_buff
*skb
,
2904 struct ath10k_wmi
*wmi
= &ar
->wmi
;
2905 struct ath10k_mgmt_tx_pkt_addr
*pkt_addr
;
2908 pkt_addr
= kmalloc(sizeof(*pkt_addr
), GFP_ATOMIC
);
2912 pkt_addr
->vaddr
= skb
;
2913 pkt_addr
->paddr
= paddr
;
2915 spin_lock_bh(&ar
->data_lock
);
2916 ret
= idr_alloc(&wmi
->mgmt_pending_tx
, pkt_addr
, 0,
2917 wmi
->mgmt_max_num_pending_tx
, GFP_ATOMIC
);
2918 spin_unlock_bh(&ar
->data_lock
);
2920 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi mgmt tx alloc msdu_id ret %d\n", ret
);
2924 static struct sk_buff
*
2925 ath10k_wmi_tlv_op_gen_mgmt_tx_send(struct ath10k
*ar
, struct sk_buff
*msdu
,
2928 struct ath10k_skb_cb
*cb
= ATH10K_SKB_CB(msdu
);
2929 struct wmi_tlv_mgmt_tx_cmd
*cmd
;
2930 struct ieee80211_hdr
*hdr
;
2931 struct ath10k_vif
*arvif
;
2932 u32 buf_len
= msdu
->len
;
2933 struct wmi_tlv
*tlv
;
2934 struct sk_buff
*skb
;
2940 return ERR_PTR(-EINVAL
);
2942 hdr
= (struct ieee80211_hdr
*)msdu
->data
;
2943 arvif
= (void *)cb
->vif
->drv_priv
;
2944 vdev_id
= arvif
->vdev_id
;
2946 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr
->frame_control
) &&
2947 (!(ieee80211_is_nullfunc(hdr
->frame_control
) ||
2948 ieee80211_is_qos_nullfunc(hdr
->frame_control
)))))
2949 return ERR_PTR(-EINVAL
);
2951 len
= sizeof(*cmd
) + 2 * sizeof(*tlv
);
2953 if ((ieee80211_is_action(hdr
->frame_control
) ||
2954 ieee80211_is_deauth(hdr
->frame_control
) ||
2955 ieee80211_is_disassoc(hdr
->frame_control
)) &&
2956 ieee80211_has_protected(hdr
->frame_control
)) {
2957 skb_put(msdu
, IEEE80211_CCMP_MIC_LEN
);
2958 buf_len
+= IEEE80211_CCMP_MIC_LEN
;
2961 buf_len
= min_t(u32
, buf_len
, WMI_TLV_MGMT_TX_FRAME_MAX_LEN
);
2962 buf_len
= round_up(buf_len
, 4);
2965 len
= round_up(len
, 4);
2966 skb
= ath10k_wmi_alloc_skb(ar
, len
);
2968 return ERR_PTR(-ENOMEM
);
2970 desc_id
= ath10k_wmi_mgmt_tx_alloc_msdu_id(ar
, msdu
, paddr
);
2974 ptr
= (void *)skb
->data
;
2976 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_MGMT_TX_CMD
);
2977 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
2978 cmd
= (void *)tlv
->value
;
2979 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2980 cmd
->desc_id
= __cpu_to_le32(desc_id
);
2982 cmd
->buf_len
= __cpu_to_le32(buf_len
);
2983 cmd
->frame_len
= __cpu_to_le32(msdu
->len
);
2984 cmd
->paddr
= __cpu_to_le64(paddr
);
2986 ptr
+= sizeof(*tlv
);
2987 ptr
+= sizeof(*cmd
);
2990 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
2991 tlv
->len
= __cpu_to_le16(buf_len
);
2993 ptr
+= sizeof(*tlv
);
2994 memcpy(ptr
, msdu
->data
, buf_len
);
3000 return ERR_PTR(desc_id
);
3003 static struct sk_buff
*
3004 ath10k_wmi_tlv_op_gen_force_fw_hang(struct ath10k
*ar
,
3005 enum wmi_force_fw_hang_type type
,
3008 struct wmi_force_fw_hang_cmd
*cmd
;
3009 struct wmi_tlv
*tlv
;
3010 struct sk_buff
*skb
;
3012 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
3014 return ERR_PTR(-ENOMEM
);
3016 tlv
= (void *)skb
->data
;
3017 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_FORCE_FW_HANG_CMD
);
3018 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3019 cmd
= (void *)tlv
->value
;
3020 cmd
->type
= __cpu_to_le32(type
);
3021 cmd
->delay_ms
= __cpu_to_le32(delay_ms
);
3023 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv force fw hang\n");
3027 static struct sk_buff
*
3028 ath10k_wmi_tlv_op_gen_dbglog_cfg(struct ath10k
*ar
, u64 module_enable
,
3031 struct wmi_tlv_dbglog_cmd
*cmd
;
3032 struct wmi_tlv
*tlv
;
3033 struct sk_buff
*skb
;
3034 size_t len
, bmap_len
;
3038 if (module_enable
) {
3039 value
= WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
3041 WMI_TLV_DBGLOG_LOG_LEVEL_VERBOSE
);
3043 value
= WMI_TLV_DBGLOG_LOG_LEVEL_VALUE(
3044 WMI_TLV_DBGLOG_ALL_MODULES
,
3045 WMI_TLV_DBGLOG_LOG_LEVEL_WARN
);
3049 len
= sizeof(*tlv
) + sizeof(*cmd
) + sizeof(*tlv
) + bmap_len
;
3050 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3052 return ERR_PTR(-ENOMEM
);
3054 ptr
= (void *)skb
->data
;
3057 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_DEBUG_LOG_CONFIG_CMD
);
3058 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3059 cmd
= (void *)tlv
->value
;
3060 cmd
->param
= __cpu_to_le32(WMI_TLV_DBGLOG_PARAM_LOG_LEVEL
);
3061 cmd
->value
= __cpu_to_le32(value
);
3063 ptr
+= sizeof(*tlv
);
3064 ptr
+= sizeof(*cmd
);
3067 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
3068 tlv
->len
= __cpu_to_le16(bmap_len
);
3070 /* nothing to do here */
3072 ptr
+= sizeof(*tlv
);
3073 ptr
+= sizeof(bmap_len
);
3075 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv dbglog value 0x%08x\n", value
);
3079 static struct sk_buff
*
3080 ath10k_wmi_tlv_op_gen_pktlog_enable(struct ath10k
*ar
, u32 filter
)
3082 struct wmi_tlv_pktlog_enable
*cmd
;
3083 struct wmi_tlv
*tlv
;
3084 struct sk_buff
*skb
;
3088 len
= sizeof(*tlv
) + sizeof(*cmd
);
3089 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3091 return ERR_PTR(-ENOMEM
);
3093 ptr
= (void *)skb
->data
;
3095 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_ENABLE_CMD
);
3096 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3097 cmd
= (void *)tlv
->value
;
3098 cmd
->filter
= __cpu_to_le32(filter
);
3100 ptr
+= sizeof(*tlv
);
3101 ptr
+= sizeof(*cmd
);
3103 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pktlog enable filter 0x%08x\n",
3108 static struct sk_buff
*
3109 ath10k_wmi_tlv_op_gen_pdev_get_temperature(struct ath10k
*ar
)
3111 struct wmi_tlv_pdev_get_temp_cmd
*cmd
;
3112 struct wmi_tlv
*tlv
;
3113 struct sk_buff
*skb
;
3115 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
3117 return ERR_PTR(-ENOMEM
);
3119 tlv
= (void *)skb
->data
;
3120 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_GET_TEMPERATURE_CMD
);
3121 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3122 cmd
= (void *)tlv
->value
;
3123 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi pdev get temperature tlv\n");
3127 static struct sk_buff
*
3128 ath10k_wmi_tlv_op_gen_pktlog_disable(struct ath10k
*ar
)
3130 struct wmi_tlv_pktlog_disable
*cmd
;
3131 struct wmi_tlv
*tlv
;
3132 struct sk_buff
*skb
;
3136 len
= sizeof(*tlv
) + sizeof(*cmd
);
3137 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3139 return ERR_PTR(-ENOMEM
);
3141 ptr
= (void *)skb
->data
;
3143 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_PKTLOG_DISABLE_CMD
);
3144 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3145 cmd
= (void *)tlv
->value
;
3147 ptr
+= sizeof(*tlv
);
3148 ptr
+= sizeof(*cmd
);
3150 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv pktlog disable\n");
3154 static struct sk_buff
*
3155 ath10k_wmi_tlv_op_gen_bcn_tmpl(struct ath10k
*ar
, u32 vdev_id
,
3156 u32 tim_ie_offset
, struct sk_buff
*bcn
,
3157 u32 prb_caps
, u32 prb_erp
, void *prb_ies
,
3160 struct wmi_tlv_bcn_tmpl_cmd
*cmd
;
3161 struct wmi_tlv_bcn_prb_info
*info
;
3162 struct wmi_tlv
*tlv
;
3163 struct sk_buff
*skb
;
3167 if (WARN_ON(prb_ies_len
> 0 && !prb_ies
))
3168 return ERR_PTR(-EINVAL
);
3170 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3171 sizeof(*tlv
) + sizeof(*info
) + prb_ies_len
+
3172 sizeof(*tlv
) + roundup(bcn
->len
, 4);
3173 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3175 return ERR_PTR(-ENOMEM
);
3177 ptr
= (void *)skb
->data
;
3179 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_TMPL_CMD
);
3180 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3181 cmd
= (void *)tlv
->value
;
3182 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3183 cmd
->tim_ie_offset
= __cpu_to_le32(tim_ie_offset
);
3184 cmd
->buf_len
= __cpu_to_le32(bcn
->len
);
3186 ptr
+= sizeof(*tlv
);
3187 ptr
+= sizeof(*cmd
);
3189 /* FIXME: prb_ies_len should be probably aligned to 4byte boundary but
3190 * then it is then impossible to pass original ie len.
3191 * This chunk is not used yet so if setting probe resp template yields
3192 * problems with beaconing or crashes firmware look here.
3195 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO
);
3196 tlv
->len
= __cpu_to_le16(sizeof(*info
) + prb_ies_len
);
3197 info
= (void *)tlv
->value
;
3198 info
->caps
= __cpu_to_le32(prb_caps
);
3199 info
->erp
= __cpu_to_le32(prb_erp
);
3200 memcpy(info
->ies
, prb_ies
, prb_ies_len
);
3202 ptr
+= sizeof(*tlv
);
3203 ptr
+= sizeof(*info
);
3207 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
3208 tlv
->len
= __cpu_to_le16(roundup(bcn
->len
, 4));
3209 memcpy(tlv
->value
, bcn
->data
, bcn
->len
);
3211 /* FIXME: Adjust TSF? */
3213 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv bcn tmpl vdev_id %i\n",
3218 static struct sk_buff
*
3219 ath10k_wmi_tlv_op_gen_prb_tmpl(struct ath10k
*ar
, u32 vdev_id
,
3220 struct sk_buff
*prb
)
3222 struct wmi_tlv_prb_tmpl_cmd
*cmd
;
3223 struct wmi_tlv_bcn_prb_info
*info
;
3224 struct wmi_tlv
*tlv
;
3225 struct sk_buff
*skb
;
3229 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3230 sizeof(*tlv
) + sizeof(*info
) +
3231 sizeof(*tlv
) + roundup(prb
->len
, 4);
3232 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3234 return ERR_PTR(-ENOMEM
);
3236 ptr
= (void *)skb
->data
;
3238 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PRB_TMPL_CMD
);
3239 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3240 cmd
= (void *)tlv
->value
;
3241 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3242 cmd
->buf_len
= __cpu_to_le32(prb
->len
);
3244 ptr
+= sizeof(*tlv
);
3245 ptr
+= sizeof(*cmd
);
3248 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_BCN_PRB_INFO
);
3249 tlv
->len
= __cpu_to_le16(sizeof(*info
));
3250 info
= (void *)tlv
->value
;
3254 ptr
+= sizeof(*tlv
);
3255 ptr
+= sizeof(*info
);
3258 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
3259 tlv
->len
= __cpu_to_le16(roundup(prb
->len
, 4));
3260 memcpy(tlv
->value
, prb
->data
, prb
->len
);
3262 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv prb tmpl vdev_id %i\n",
3267 static struct sk_buff
*
3268 ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie(struct ath10k
*ar
, u32 vdev_id
,
3271 struct wmi_tlv_p2p_go_bcn_ie
*cmd
;
3272 struct wmi_tlv
*tlv
;
3273 struct sk_buff
*skb
;
3277 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3278 sizeof(*tlv
) + roundup(p2p_ie
[1] + 2, 4);
3279 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3281 return ERR_PTR(-ENOMEM
);
3283 ptr
= (void *)skb
->data
;
3285 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_P2P_GO_SET_BEACON_IE
);
3286 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3287 cmd
= (void *)tlv
->value
;
3288 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3289 cmd
->ie_len
= __cpu_to_le32(p2p_ie
[1] + 2);
3291 ptr
+= sizeof(*tlv
);
3292 ptr
+= sizeof(*cmd
);
3295 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
3296 tlv
->len
= __cpu_to_le16(roundup(p2p_ie
[1] + 2, 4));
3297 memcpy(tlv
->value
, p2p_ie
, p2p_ie
[1] + 2);
3299 ptr
+= sizeof(*tlv
);
3300 ptr
+= roundup(p2p_ie
[1] + 2, 4);
3302 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv p2p go bcn ie for vdev %i\n",
3307 static struct sk_buff
*
3308 ath10k_wmi_tlv_op_gen_update_fw_tdls_state(struct ath10k
*ar
, u32 vdev_id
,
3309 enum wmi_tdls_state state
)
3311 struct wmi_tdls_set_state_cmd
*cmd
;
3312 struct wmi_tlv
*tlv
;
3313 struct sk_buff
*skb
;
3316 /* Set to options from wmi_tlv_tdls_options,
3317 * for now none of them are enabled.
3321 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA
, ar
->wmi
.svc_map
))
3322 options
|= WMI_TLV_TDLS_BUFFER_STA_EN
;
3324 /* WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL means firm will handle TDLS
3325 * link inactivity detecting logic.
3327 if (state
== WMI_TDLS_ENABLE_ACTIVE
)
3328 state
= WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL
;
3330 len
= sizeof(*tlv
) + sizeof(*cmd
);
3331 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3333 return ERR_PTR(-ENOMEM
);
3335 ptr
= (void *)skb
->data
;
3337 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_SET_STATE_CMD
);
3338 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3340 cmd
= (void *)tlv
->value
;
3341 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3342 cmd
->state
= __cpu_to_le32(state
);
3343 cmd
->notification_interval_ms
= __cpu_to_le32(5000);
3344 cmd
->tx_discovery_threshold
= __cpu_to_le32(100);
3345 cmd
->tx_teardown_threshold
= __cpu_to_le32(5);
3346 cmd
->rssi_teardown_threshold
= __cpu_to_le32(-75);
3347 cmd
->rssi_delta
= __cpu_to_le32(-20);
3348 cmd
->tdls_options
= __cpu_to_le32(options
);
3349 cmd
->tdls_peer_traffic_ind_window
= __cpu_to_le32(2);
3350 cmd
->tdls_peer_traffic_response_timeout_ms
= __cpu_to_le32(5000);
3351 cmd
->tdls_puapsd_mask
= __cpu_to_le32(0xf);
3352 cmd
->tdls_puapsd_inactivity_time_ms
= __cpu_to_le32(0);
3353 cmd
->tdls_puapsd_rx_frame_threshold
= __cpu_to_le32(10);
3355 ptr
+= sizeof(*tlv
);
3356 ptr
+= sizeof(*cmd
);
3358 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv update fw tdls state %d for vdev %i\n",
3363 static u32
ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues
, u8 sp
)
3367 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_VO
)
3368 peer_qos
|= WMI_TLV_TDLS_PEER_QOS_AC_VO
;
3369 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_VI
)
3370 peer_qos
|= WMI_TLV_TDLS_PEER_QOS_AC_VI
;
3371 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_BK
)
3372 peer_qos
|= WMI_TLV_TDLS_PEER_QOS_AC_BK
;
3373 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_BE
)
3374 peer_qos
|= WMI_TLV_TDLS_PEER_QOS_AC_BE
;
3376 peer_qos
|= SM(sp
, WMI_TLV_TDLS_PEER_SP
);
3381 static struct sk_buff
*
3382 ath10k_wmi_tlv_op_gen_tdls_peer_update(struct ath10k
*ar
,
3383 const struct wmi_tdls_peer_update_cmd_arg
*arg
,
3384 const struct wmi_tdls_peer_capab_arg
*cap
,
3385 const struct wmi_channel_arg
*chan_arg
)
3387 struct wmi_tdls_peer_update_cmd
*cmd
;
3388 struct wmi_tdls_peer_capab
*peer_cap
;
3389 struct wmi_channel
*chan
;
3390 struct wmi_tlv
*tlv
;
3391 struct sk_buff
*skb
;
3397 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3398 sizeof(*tlv
) + sizeof(*peer_cap
) +
3399 sizeof(*tlv
) + cap
->peer_chan_len
* sizeof(*chan
);
3401 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3403 return ERR_PTR(-ENOMEM
);
3405 ptr
= (void *)skb
->data
;
3407 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_UPDATE_CMD
);
3408 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3410 cmd
= (void *)tlv
->value
;
3411 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
3412 ether_addr_copy(cmd
->peer_macaddr
.addr
, arg
->addr
);
3413 cmd
->peer_state
= __cpu_to_le32(arg
->peer_state
);
3415 ptr
+= sizeof(*tlv
);
3416 ptr
+= sizeof(*cmd
);
3419 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_TDLS_PEER_CAPABILITIES
);
3420 tlv
->len
= __cpu_to_le16(sizeof(*peer_cap
));
3421 peer_cap
= (void *)tlv
->value
;
3422 peer_qos
= ath10k_wmi_tlv_prepare_peer_qos(cap
->peer_uapsd_queues
,
3424 peer_cap
->peer_qos
= __cpu_to_le32(peer_qos
);
3425 peer_cap
->buff_sta_support
= __cpu_to_le32(cap
->buff_sta_support
);
3426 peer_cap
->off_chan_support
= __cpu_to_le32(cap
->off_chan_support
);
3427 peer_cap
->peer_curr_operclass
= __cpu_to_le32(cap
->peer_curr_operclass
);
3428 peer_cap
->self_curr_operclass
= __cpu_to_le32(cap
->self_curr_operclass
);
3429 peer_cap
->peer_chan_len
= __cpu_to_le32(cap
->peer_chan_len
);
3430 peer_cap
->peer_operclass_len
= __cpu_to_le32(cap
->peer_operclass_len
);
3432 for (i
= 0; i
< WMI_TDLS_MAX_SUPP_OPER_CLASSES
; i
++)
3433 peer_cap
->peer_operclass
[i
] = cap
->peer_operclass
[i
];
3435 peer_cap
->is_peer_responder
= __cpu_to_le32(cap
->is_peer_responder
);
3436 peer_cap
->pref_offchan_num
= __cpu_to_le32(cap
->pref_offchan_num
);
3437 peer_cap
->pref_offchan_bw
= __cpu_to_le32(cap
->pref_offchan_bw
);
3439 ptr
+= sizeof(*tlv
);
3440 ptr
+= sizeof(*peer_cap
);
3443 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3444 tlv
->len
= __cpu_to_le16(cap
->peer_chan_len
* sizeof(*chan
));
3446 ptr
+= sizeof(*tlv
);
3448 for (i
= 0; i
< cap
->peer_chan_len
; i
++) {
3450 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_CHANNEL
);
3451 tlv
->len
= __cpu_to_le16(sizeof(*chan
));
3452 chan
= (void *)tlv
->value
;
3453 ath10k_wmi_put_wmi_channel(chan
, &chan_arg
[i
]);
3455 ptr
+= sizeof(*tlv
);
3456 ptr
+= sizeof(*chan
);
3459 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
3460 "wmi tlv tdls peer update vdev %i state %d n_chans %u\n",
3461 arg
->vdev_id
, arg
->peer_state
, cap
->peer_chan_len
);
3465 static struct sk_buff
*
3466 ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode(struct ath10k
*ar
, u32 period
,
3467 u32 duration
, u32 next_offset
,
3470 struct wmi_tlv_set_quiet_cmd
*cmd
;
3471 struct wmi_tlv
*tlv
;
3472 struct sk_buff
*skb
;
3474 skb
= ath10k_wmi_alloc_skb(ar
, sizeof(*tlv
) + sizeof(*cmd
));
3476 return ERR_PTR(-ENOMEM
);
3478 tlv
= (void *)skb
->data
;
3479 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_PDEV_SET_QUIET_CMD
);
3480 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3481 cmd
= (void *)tlv
->value
;
3483 /* vdev_id is not in use, set to 0 */
3484 cmd
->vdev_id
= __cpu_to_le32(0);
3485 cmd
->period
= __cpu_to_le32(period
);
3486 cmd
->duration
= __cpu_to_le32(duration
);
3487 cmd
->next_start
= __cpu_to_le32(next_offset
);
3488 cmd
->enabled
= __cpu_to_le32(enabled
);
3490 ath10k_dbg(ar
, ATH10K_DBG_WMI
,
3491 "wmi tlv quiet param: period %u duration %u enabled %d\n",
3492 period
, duration
, enabled
);
3496 static struct sk_buff
*
3497 ath10k_wmi_tlv_op_gen_wow_enable(struct ath10k
*ar
)
3499 struct wmi_tlv_wow_enable_cmd
*cmd
;
3500 struct wmi_tlv
*tlv
;
3501 struct sk_buff
*skb
;
3504 len
= sizeof(*tlv
) + sizeof(*cmd
);
3505 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3507 return ERR_PTR(-ENOMEM
);
3509 tlv
= (struct wmi_tlv
*)skb
->data
;
3510 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ENABLE_CMD
);
3511 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3512 cmd
= (void *)tlv
->value
;
3514 cmd
->enable
= __cpu_to_le32(1);
3515 if (!ar
->bus_param
.link_can_suspend
)
3516 cmd
->pause_iface_config
= __cpu_to_le32(WOW_IFACE_PAUSE_DISABLED
);
3518 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv wow enable\n");
3522 static struct sk_buff
*
3523 ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k
*ar
,
3525 enum wmi_wow_wakeup_event event
,
3528 struct wmi_tlv_wow_add_del_event_cmd
*cmd
;
3529 struct wmi_tlv
*tlv
;
3530 struct sk_buff
*skb
;
3533 len
= sizeof(*tlv
) + sizeof(*cmd
);
3534 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3536 return ERR_PTR(-ENOMEM
);
3538 tlv
= (struct wmi_tlv
*)skb
->data
;
3539 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_DEL_EVT_CMD
);
3540 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3541 cmd
= (void *)tlv
->value
;
3543 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3544 cmd
->is_add
= __cpu_to_le32(enable
);
3545 cmd
->event_bitmap
= __cpu_to_le32(1 << event
);
3547 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv wow add wakeup event %s enable %d vdev_id %d\n",
3548 wow_wakeup_event(event
), enable
, vdev_id
);
3552 static struct sk_buff
*
3553 ath10k_wmi_tlv_gen_wow_host_wakeup_ind(struct ath10k
*ar
)
3555 struct wmi_tlv_wow_host_wakeup_ind
*cmd
;
3556 struct wmi_tlv
*tlv
;
3557 struct sk_buff
*skb
;
3560 len
= sizeof(*tlv
) + sizeof(*cmd
);
3561 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3563 return ERR_PTR(-ENOMEM
);
3565 tlv
= (struct wmi_tlv
*)skb
->data
;
3566 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD
);
3567 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3568 cmd
= (void *)tlv
->value
;
3570 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv wow host wakeup ind\n");
3574 static struct sk_buff
*
3575 ath10k_wmi_tlv_op_gen_wow_add_pattern(struct ath10k
*ar
, u32 vdev_id
,
3576 u32 pattern_id
, const u8
*pattern
,
3577 const u8
*bitmask
, int pattern_len
,
3580 struct wmi_tlv_wow_add_pattern_cmd
*cmd
;
3581 struct wmi_tlv_wow_bitmap_pattern
*bitmap
;
3582 struct wmi_tlv
*tlv
;
3583 struct sk_buff
*skb
;
3587 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3588 sizeof(*tlv
) + /* array struct */
3589 sizeof(*tlv
) + sizeof(*bitmap
) + /* bitmap */
3590 sizeof(*tlv
) + /* empty ipv4 sync */
3591 sizeof(*tlv
) + /* empty ipv6 sync */
3592 sizeof(*tlv
) + /* empty magic */
3593 sizeof(*tlv
) + /* empty info timeout */
3594 sizeof(*tlv
) + sizeof(u32
); /* ratelimit interval */
3596 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3598 return ERR_PTR(-ENOMEM
);
3601 ptr
= (void *)skb
->data
;
3603 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_ADD_PATTERN_CMD
);
3604 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3605 cmd
= (void *)tlv
->value
;
3607 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3608 cmd
->pattern_id
= __cpu_to_le32(pattern_id
);
3609 cmd
->pattern_type
= __cpu_to_le32(WOW_BITMAP_PATTERN
);
3611 ptr
+= sizeof(*tlv
);
3612 ptr
+= sizeof(*cmd
);
3616 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3617 tlv
->len
= __cpu_to_le16(sizeof(*tlv
) + sizeof(*bitmap
));
3619 ptr
+= sizeof(*tlv
);
3622 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_BITMAP_PATTERN_T
);
3623 tlv
->len
= __cpu_to_le16(sizeof(*bitmap
));
3624 bitmap
= (void *)tlv
->value
;
3626 memcpy(bitmap
->patternbuf
, pattern
, pattern_len
);
3627 memcpy(bitmap
->bitmaskbuf
, bitmask
, pattern_len
);
3628 bitmap
->pattern_offset
= __cpu_to_le32(pattern_offset
);
3629 bitmap
->pattern_len
= __cpu_to_le32(pattern_len
);
3630 bitmap
->bitmask_len
= __cpu_to_le32(pattern_len
);
3631 bitmap
->pattern_id
= __cpu_to_le32(pattern_id
);
3633 ptr
+= sizeof(*tlv
);
3634 ptr
+= sizeof(*bitmap
);
3638 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3639 tlv
->len
= __cpu_to_le16(0);
3641 ptr
+= sizeof(*tlv
);
3645 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3646 tlv
->len
= __cpu_to_le16(0);
3648 ptr
+= sizeof(*tlv
);
3652 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3653 tlv
->len
= __cpu_to_le16(0);
3655 ptr
+= sizeof(*tlv
);
3657 /* pattern info timeout */
3659 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
3660 tlv
->len
= __cpu_to_le16(0);
3662 ptr
+= sizeof(*tlv
);
3664 /* ratelimit interval */
3666 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
3667 tlv
->len
= __cpu_to_le16(sizeof(u32
));
3669 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv wow add pattern vdev_id %d pattern_id %d, pattern_offset %d\n",
3670 vdev_id
, pattern_id
, pattern_offset
);
3674 static struct sk_buff
*
3675 ath10k_wmi_tlv_op_gen_wow_del_pattern(struct ath10k
*ar
, u32 vdev_id
,
3678 struct wmi_tlv_wow_del_pattern_cmd
*cmd
;
3679 struct wmi_tlv
*tlv
;
3680 struct sk_buff
*skb
;
3683 len
= sizeof(*tlv
) + sizeof(*cmd
);
3684 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3686 return ERR_PTR(-ENOMEM
);
3688 tlv
= (struct wmi_tlv
*)skb
->data
;
3689 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_DEL_PATTERN_CMD
);
3690 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3691 cmd
= (void *)tlv
->value
;
3693 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3694 cmd
->pattern_id
= __cpu_to_le32(pattern_id
);
3695 cmd
->pattern_type
= __cpu_to_le32(WOW_BITMAP_PATTERN
);
3697 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv wow del pattern vdev_id %d pattern_id %d\n",
3698 vdev_id
, pattern_id
);
3702 /* Request FW to start PNO operation */
3703 static struct sk_buff
*
3704 ath10k_wmi_tlv_op_gen_config_pno_start(struct ath10k
*ar
,
3706 struct wmi_pno_scan_req
*pno
)
3708 struct nlo_configured_parameters
*nlo_list
;
3709 struct wmi_tlv_wow_nlo_config_cmd
*cmd
;
3710 struct wmi_tlv
*tlv
;
3711 struct sk_buff
*skb
;
3712 __le32
*channel_list
;
3718 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3720 /* TLV place holder for array of structures
3721 * nlo_configured_parameters(nlo_list)
3724 /* TLV place holder for array of uint32 channel_list */
3726 len
+= sizeof(u32
) * min_t(u8
, pno
->a_networks
[0].channel_count
,
3728 len
+= sizeof(struct nlo_configured_parameters
) *
3729 min_t(u8
, pno
->uc_networks_count
, WMI_NLO_MAX_SSIDS
);
3731 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3733 return ERR_PTR(-ENOMEM
);
3735 ptr
= (void *)skb
->data
;
3737 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD
);
3738 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3739 cmd
= (void *)tlv
->value
;
3741 /* wmi_tlv_wow_nlo_config_cmd parameters*/
3742 cmd
->vdev_id
= __cpu_to_le32(pno
->vdev_id
);
3743 cmd
->flags
= __cpu_to_le32(WMI_NLO_CONFIG_START
| WMI_NLO_CONFIG_SSID_HIDE_EN
);
3745 /* current FW does not support min-max range for dwell time */
3746 cmd
->active_dwell_time
= __cpu_to_le32(pno
->active_max_time
);
3747 cmd
->passive_dwell_time
= __cpu_to_le32(pno
->passive_max_time
);
3749 if (pno
->do_passive_scan
)
3750 cmd
->flags
|= __cpu_to_le32(WMI_NLO_CONFIG_SCAN_PASSIVE
);
3752 /* copy scan interval */
3753 cmd
->fast_scan_period
= __cpu_to_le32(pno
->fast_scan_period
);
3754 cmd
->slow_scan_period
= __cpu_to_le32(pno
->slow_scan_period
);
3755 cmd
->fast_scan_max_cycles
= __cpu_to_le32(pno
->fast_scan_max_cycles
);
3756 cmd
->delay_start_time
= __cpu_to_le32(pno
->delay_start_time
);
3758 if (pno
->enable_pno_scan_randomization
) {
3759 cmd
->flags
|= __cpu_to_le32(WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ
|
3760 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ
);
3761 ether_addr_copy(cmd
->mac_addr
.addr
, pno
->mac_addr
);
3762 ether_addr_copy(cmd
->mac_mask
.addr
, pno
->mac_addr_mask
);
3765 ptr
+= sizeof(*tlv
);
3766 ptr
+= sizeof(*cmd
);
3768 /* nlo_configured_parameters(nlo_list) */
3769 cmd
->no_of_ssids
= __cpu_to_le32(min_t(u8
, pno
->uc_networks_count
,
3770 WMI_NLO_MAX_SSIDS
));
3771 tlv_len
= __le32_to_cpu(cmd
->no_of_ssids
) *
3772 sizeof(struct nlo_configured_parameters
);
3775 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3776 tlv
->len
= __cpu_to_le16(tlv_len
);
3778 ptr
+= sizeof(*tlv
);
3780 for (i
= 0; i
< __le32_to_cpu(cmd
->no_of_ssids
); i
++) {
3781 tlv
= (struct wmi_tlv
*)(&nlo_list
[i
].tlv_header
);
3782 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE
);
3783 tlv
->len
= __cpu_to_le16(sizeof(struct nlo_configured_parameters
) -
3786 /* copy ssid and it's length */
3787 nlo_list
[i
].ssid
.valid
= __cpu_to_le32(true);
3788 nlo_list
[i
].ssid
.ssid
.ssid_len
= pno
->a_networks
[i
].ssid
.ssid_len
;
3789 memcpy(nlo_list
[i
].ssid
.ssid
.ssid
,
3790 pno
->a_networks
[i
].ssid
.ssid
,
3791 __le32_to_cpu(nlo_list
[i
].ssid
.ssid
.ssid_len
));
3793 /* copy rssi threshold */
3794 if (pno
->a_networks
[i
].rssi_threshold
&&
3795 pno
->a_networks
[i
].rssi_threshold
> -300) {
3796 nlo_list
[i
].rssi_cond
.valid
= __cpu_to_le32(true);
3797 nlo_list
[i
].rssi_cond
.rssi
=
3798 __cpu_to_le32(pno
->a_networks
[i
].rssi_threshold
);
3801 nlo_list
[i
].bcast_nw_type
.valid
= __cpu_to_le32(true);
3802 nlo_list
[i
].bcast_nw_type
.bcast_nw_type
=
3803 __cpu_to_le32(pno
->a_networks
[i
].bcast_nw_type
);
3806 ptr
+= __le32_to_cpu(cmd
->no_of_ssids
) * sizeof(struct nlo_configured_parameters
);
3808 /* copy channel info */
3809 cmd
->num_of_channels
= __cpu_to_le32(min_t(u8
,
3810 pno
->a_networks
[0].channel_count
,
3814 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
3815 tlv
->len
= __cpu_to_le16(__le32_to_cpu(cmd
->num_of_channels
) *
3817 ptr
+= sizeof(*tlv
);
3819 channel_list
= (__le32
*)ptr
;
3820 for (i
= 0; i
< __le32_to_cpu(cmd
->num_of_channels
); i
++)
3821 channel_list
[i
] = __cpu_to_le32(pno
->a_networks
[0].channels
[i
]);
3823 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv start pno config vdev_id %d\n",
3829 /* Request FW to stop ongoing PNO operation */
3830 static struct sk_buff
*ath10k_wmi_tlv_op_gen_config_pno_stop(struct ath10k
*ar
,
3833 struct wmi_tlv_wow_nlo_config_cmd
*cmd
;
3834 struct wmi_tlv
*tlv
;
3835 struct sk_buff
*skb
;
3839 len
= sizeof(*tlv
) + sizeof(*cmd
) +
3841 /* TLV place holder for array of structures
3842 * nlo_configured_parameters(nlo_list)
3845 /* TLV place holder for array of uint32 channel_list */
3846 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3848 return ERR_PTR(-ENOMEM
);
3850 ptr
= (void *)skb
->data
;
3852 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD
);
3853 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3854 cmd
= (void *)tlv
->value
;
3856 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3857 cmd
->flags
= __cpu_to_le32(WMI_NLO_CONFIG_STOP
);
3859 ptr
+= sizeof(*tlv
);
3860 ptr
+= sizeof(*cmd
);
3862 /* nlo_configured_parameters(nlo_list) */
3864 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT
);
3865 tlv
->len
= __cpu_to_le16(0);
3867 ptr
+= sizeof(*tlv
);
3871 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32
);
3872 tlv
->len
= __cpu_to_le16(0);
3874 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv stop pno config vdev_id %d\n", vdev_id
);
3878 static struct sk_buff
*
3879 ath10k_wmi_tlv_op_gen_config_pno(struct ath10k
*ar
, u32 vdev_id
,
3880 struct wmi_pno_scan_req
*pno_scan
)
3882 if (pno_scan
->enable
)
3883 return ath10k_wmi_tlv_op_gen_config_pno_start(ar
, vdev_id
, pno_scan
);
3885 return ath10k_wmi_tlv_op_gen_config_pno_stop(ar
, vdev_id
);
3888 static struct sk_buff
*
3889 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k
*ar
, bool enable
)
3891 struct wmi_tlv_adaptive_qcs
*cmd
;
3892 struct wmi_tlv
*tlv
;
3893 struct sk_buff
*skb
;
3897 len
= sizeof(*tlv
) + sizeof(*cmd
);
3898 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3900 return ERR_PTR(-ENOMEM
);
3902 ptr
= (void *)skb
->data
;
3904 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_RESMGR_ADAPTIVE_OCS_CMD
);
3905 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3906 cmd
= (void *)tlv
->value
;
3907 cmd
->enable
= __cpu_to_le32(enable
? 1 : 0);
3909 ptr
+= sizeof(*tlv
);
3910 ptr
+= sizeof(*cmd
);
3912 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv adaptive qcs %d\n", enable
);
3916 static struct sk_buff
*
3917 ath10k_wmi_tlv_op_gen_echo(struct ath10k
*ar
, u32 value
)
3919 struct wmi_echo_cmd
*cmd
;
3920 struct wmi_tlv
*tlv
;
3921 struct sk_buff
*skb
;
3925 len
= sizeof(*tlv
) + sizeof(*cmd
);
3926 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3928 return ERR_PTR(-ENOMEM
);
3930 ptr
= (void *)skb
->data
;
3932 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_ECHO_CMD
);
3933 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3934 cmd
= (void *)tlv
->value
;
3935 cmd
->value
= cpu_to_le32(value
);
3937 ptr
+= sizeof(*tlv
);
3938 ptr
+= sizeof(*cmd
);
3940 ath10k_dbg(ar
, ATH10K_DBG_WMI
, "wmi tlv echo value 0x%08x\n", value
);
3944 static struct sk_buff
*
3945 ath10k_wmi_tlv_op_gen_vdev_spectral_conf(struct ath10k
*ar
,
3946 const struct wmi_vdev_spectral_conf_arg
*arg
)
3948 struct wmi_vdev_spectral_conf_cmd
*cmd
;
3949 struct sk_buff
*skb
;
3950 struct wmi_tlv
*tlv
;
3954 len
= sizeof(*tlv
) + sizeof(*cmd
);
3955 skb
= ath10k_wmi_alloc_skb(ar
, len
);
3957 return ERR_PTR(-ENOMEM
);
3959 ptr
= (void *)skb
->data
;
3961 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_CONFIGURE_CMD
);
3962 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
3963 cmd
= (void *)tlv
->value
;
3964 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
3965 cmd
->scan_count
= __cpu_to_le32(arg
->scan_count
);
3966 cmd
->scan_period
= __cpu_to_le32(arg
->scan_period
);
3967 cmd
->scan_priority
= __cpu_to_le32(arg
->scan_priority
);
3968 cmd
->scan_fft_size
= __cpu_to_le32(arg
->scan_fft_size
);
3969 cmd
->scan_gc_ena
= __cpu_to_le32(arg
->scan_gc_ena
);
3970 cmd
->scan_restart_ena
= __cpu_to_le32(arg
->scan_restart_ena
);
3971 cmd
->scan_noise_floor_ref
= __cpu_to_le32(arg
->scan_noise_floor_ref
);
3972 cmd
->scan_init_delay
= __cpu_to_le32(arg
->scan_init_delay
);
3973 cmd
->scan_nb_tone_thr
= __cpu_to_le32(arg
->scan_nb_tone_thr
);
3974 cmd
->scan_str_bin_thr
= __cpu_to_le32(arg
->scan_str_bin_thr
);
3975 cmd
->scan_wb_rpt_mode
= __cpu_to_le32(arg
->scan_wb_rpt_mode
);
3976 cmd
->scan_rssi_rpt_mode
= __cpu_to_le32(arg
->scan_rssi_rpt_mode
);
3977 cmd
->scan_rssi_thr
= __cpu_to_le32(arg
->scan_rssi_thr
);
3978 cmd
->scan_pwr_format
= __cpu_to_le32(arg
->scan_pwr_format
);
3979 cmd
->scan_rpt_mode
= __cpu_to_le32(arg
->scan_rpt_mode
);
3980 cmd
->scan_bin_scale
= __cpu_to_le32(arg
->scan_bin_scale
);
3981 cmd
->scan_dbm_adj
= __cpu_to_le32(arg
->scan_dbm_adj
);
3982 cmd
->scan_chn_mask
= __cpu_to_le32(arg
->scan_chn_mask
);
3987 static struct sk_buff
*
3988 ath10k_wmi_tlv_op_gen_vdev_spectral_enable(struct ath10k
*ar
, u32 vdev_id
,
3989 u32 trigger
, u32 enable
)
3991 struct wmi_vdev_spectral_enable_cmd
*cmd
;
3992 struct sk_buff
*skb
;
3993 struct wmi_tlv
*tlv
;
3997 len
= sizeof(*tlv
) + sizeof(*cmd
);
3998 skb
= ath10k_wmi_alloc_skb(ar
, len
);
4000 return ERR_PTR(-ENOMEM
);
4002 ptr
= (void *)skb
->data
;
4004 tlv
->tag
= __cpu_to_le16(WMI_TLV_TAG_STRUCT_VDEV_SPECTRAL_ENABLE_CMD
);
4005 tlv
->len
= __cpu_to_le16(sizeof(*cmd
));
4006 cmd
= (void *)tlv
->value
;
4007 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
4008 cmd
->trigger_cmd
= __cpu_to_le32(trigger
);
4009 cmd
->enable_cmd
= __cpu_to_le32(enable
);
4018 static struct wmi_cmd_map wmi_tlv_cmd_map
= {
4019 .init_cmdid
= WMI_TLV_INIT_CMDID
,
4020 .start_scan_cmdid
= WMI_TLV_START_SCAN_CMDID
,
4021 .stop_scan_cmdid
= WMI_TLV_STOP_SCAN_CMDID
,
4022 .scan_chan_list_cmdid
= WMI_TLV_SCAN_CHAN_LIST_CMDID
,
4023 .scan_sch_prio_tbl_cmdid
= WMI_TLV_SCAN_SCH_PRIO_TBL_CMDID
,
4024 .scan_prob_req_oui_cmdid
= WMI_TLV_SCAN_PROB_REQ_OUI_CMDID
,
4025 .pdev_set_regdomain_cmdid
= WMI_TLV_PDEV_SET_REGDOMAIN_CMDID
,
4026 .pdev_set_channel_cmdid
= WMI_TLV_PDEV_SET_CHANNEL_CMDID
,
4027 .pdev_set_param_cmdid
= WMI_TLV_PDEV_SET_PARAM_CMDID
,
4028 .pdev_pktlog_enable_cmdid
= WMI_TLV_PDEV_PKTLOG_ENABLE_CMDID
,
4029 .pdev_pktlog_disable_cmdid
= WMI_TLV_PDEV_PKTLOG_DISABLE_CMDID
,
4030 .pdev_set_wmm_params_cmdid
= WMI_TLV_PDEV_SET_WMM_PARAMS_CMDID
,
4031 .pdev_set_ht_cap_ie_cmdid
= WMI_TLV_PDEV_SET_HT_CAP_IE_CMDID
,
4032 .pdev_set_vht_cap_ie_cmdid
= WMI_TLV_PDEV_SET_VHT_CAP_IE_CMDID
,
4033 .pdev_set_dscp_tid_map_cmdid
= WMI_TLV_PDEV_SET_DSCP_TID_MAP_CMDID
,
4034 .pdev_set_quiet_mode_cmdid
= WMI_TLV_PDEV_SET_QUIET_MODE_CMDID
,
4035 .pdev_green_ap_ps_enable_cmdid
= WMI_TLV_PDEV_GREEN_AP_PS_ENABLE_CMDID
,
4036 .pdev_get_tpc_config_cmdid
= WMI_TLV_PDEV_GET_TPC_CONFIG_CMDID
,
4037 .pdev_set_base_macaddr_cmdid
= WMI_TLV_PDEV_SET_BASE_MACADDR_CMDID
,
4038 .vdev_create_cmdid
= WMI_TLV_VDEV_CREATE_CMDID
,
4039 .vdev_delete_cmdid
= WMI_TLV_VDEV_DELETE_CMDID
,
4040 .vdev_start_request_cmdid
= WMI_TLV_VDEV_START_REQUEST_CMDID
,
4041 .vdev_restart_request_cmdid
= WMI_TLV_VDEV_RESTART_REQUEST_CMDID
,
4042 .vdev_up_cmdid
= WMI_TLV_VDEV_UP_CMDID
,
4043 .vdev_stop_cmdid
= WMI_TLV_VDEV_STOP_CMDID
,
4044 .vdev_down_cmdid
= WMI_TLV_VDEV_DOWN_CMDID
,
4045 .vdev_set_param_cmdid
= WMI_TLV_VDEV_SET_PARAM_CMDID
,
4046 .vdev_install_key_cmdid
= WMI_TLV_VDEV_INSTALL_KEY_CMDID
,
4047 .peer_create_cmdid
= WMI_TLV_PEER_CREATE_CMDID
,
4048 .peer_delete_cmdid
= WMI_TLV_PEER_DELETE_CMDID
,
4049 .peer_flush_tids_cmdid
= WMI_TLV_PEER_FLUSH_TIDS_CMDID
,
4050 .peer_set_param_cmdid
= WMI_TLV_PEER_SET_PARAM_CMDID
,
4051 .peer_assoc_cmdid
= WMI_TLV_PEER_ASSOC_CMDID
,
4052 .peer_add_wds_entry_cmdid
= WMI_TLV_PEER_ADD_WDS_ENTRY_CMDID
,
4053 .peer_remove_wds_entry_cmdid
= WMI_TLV_PEER_REMOVE_WDS_ENTRY_CMDID
,
4054 .peer_mcast_group_cmdid
= WMI_TLV_PEER_MCAST_GROUP_CMDID
,
4055 .bcn_tx_cmdid
= WMI_TLV_BCN_TX_CMDID
,
4056 .pdev_send_bcn_cmdid
= WMI_TLV_PDEV_SEND_BCN_CMDID
,
4057 .bcn_tmpl_cmdid
= WMI_TLV_BCN_TMPL_CMDID
,
4058 .bcn_filter_rx_cmdid
= WMI_TLV_BCN_FILTER_RX_CMDID
,
4059 .prb_req_filter_rx_cmdid
= WMI_TLV_PRB_REQ_FILTER_RX_CMDID
,
4060 .mgmt_tx_cmdid
= WMI_TLV_MGMT_TX_CMDID
,
4061 .mgmt_tx_send_cmdid
= WMI_TLV_MGMT_TX_SEND_CMD
,
4062 .prb_tmpl_cmdid
= WMI_TLV_PRB_TMPL_CMDID
,
4063 .addba_clear_resp_cmdid
= WMI_TLV_ADDBA_CLEAR_RESP_CMDID
,
4064 .addba_send_cmdid
= WMI_TLV_ADDBA_SEND_CMDID
,
4065 .addba_status_cmdid
= WMI_TLV_ADDBA_STATUS_CMDID
,
4066 .delba_send_cmdid
= WMI_TLV_DELBA_SEND_CMDID
,
4067 .addba_set_resp_cmdid
= WMI_TLV_ADDBA_SET_RESP_CMDID
,
4068 .send_singleamsdu_cmdid
= WMI_TLV_SEND_SINGLEAMSDU_CMDID
,
4069 .sta_powersave_mode_cmdid
= WMI_TLV_STA_POWERSAVE_MODE_CMDID
,
4070 .sta_powersave_param_cmdid
= WMI_TLV_STA_POWERSAVE_PARAM_CMDID
,
4071 .sta_mimo_ps_mode_cmdid
= WMI_TLV_STA_MIMO_PS_MODE_CMDID
,
4072 .pdev_dfs_enable_cmdid
= WMI_TLV_PDEV_DFS_ENABLE_CMDID
,
4073 .pdev_dfs_disable_cmdid
= WMI_TLV_PDEV_DFS_DISABLE_CMDID
,
4074 .roam_scan_mode
= WMI_TLV_ROAM_SCAN_MODE
,
4075 .roam_scan_rssi_threshold
= WMI_TLV_ROAM_SCAN_RSSI_THRESHOLD
,
4076 .roam_scan_period
= WMI_TLV_ROAM_SCAN_PERIOD
,
4077 .roam_scan_rssi_change_threshold
=
4078 WMI_TLV_ROAM_SCAN_RSSI_CHANGE_THRESHOLD
,
4079 .roam_ap_profile
= WMI_TLV_ROAM_AP_PROFILE
,
4080 .ofl_scan_add_ap_profile
= WMI_TLV_ROAM_AP_PROFILE
,
4081 .ofl_scan_remove_ap_profile
= WMI_TLV_OFL_SCAN_REMOVE_AP_PROFILE
,
4082 .ofl_scan_period
= WMI_TLV_OFL_SCAN_PERIOD
,
4083 .p2p_dev_set_device_info
= WMI_TLV_P2P_DEV_SET_DEVICE_INFO
,
4084 .p2p_dev_set_discoverability
= WMI_TLV_P2P_DEV_SET_DISCOVERABILITY
,
4085 .p2p_go_set_beacon_ie
= WMI_TLV_P2P_GO_SET_BEACON_IE
,
4086 .p2p_go_set_probe_resp_ie
= WMI_TLV_P2P_GO_SET_PROBE_RESP_IE
,
4087 .p2p_set_vendor_ie_data_cmdid
= WMI_TLV_P2P_SET_VENDOR_IE_DATA_CMDID
,
4088 .ap_ps_peer_param_cmdid
= WMI_TLV_AP_PS_PEER_PARAM_CMDID
,
4089 .ap_ps_peer_uapsd_coex_cmdid
= WMI_TLV_AP_PS_PEER_UAPSD_COEX_CMDID
,
4090 .peer_rate_retry_sched_cmdid
= WMI_TLV_PEER_RATE_RETRY_SCHED_CMDID
,
4091 .wlan_profile_trigger_cmdid
= WMI_TLV_WLAN_PROFILE_TRIGGER_CMDID
,
4092 .wlan_profile_set_hist_intvl_cmdid
=
4093 WMI_TLV_WLAN_PROFILE_SET_HIST_INTVL_CMDID
,
4094 .wlan_profile_get_profile_data_cmdid
=
4095 WMI_TLV_WLAN_PROFILE_GET_PROFILE_DATA_CMDID
,
4096 .wlan_profile_enable_profile_id_cmdid
=
4097 WMI_TLV_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID
,
4098 .wlan_profile_list_profile_id_cmdid
=
4099 WMI_TLV_WLAN_PROFILE_LIST_PROFILE_ID_CMDID
,
4100 .pdev_suspend_cmdid
= WMI_TLV_PDEV_SUSPEND_CMDID
,
4101 .pdev_resume_cmdid
= WMI_TLV_PDEV_RESUME_CMDID
,
4102 .add_bcn_filter_cmdid
= WMI_TLV_ADD_BCN_FILTER_CMDID
,
4103 .rmv_bcn_filter_cmdid
= WMI_TLV_RMV_BCN_FILTER_CMDID
,
4104 .wow_add_wake_pattern_cmdid
= WMI_TLV_WOW_ADD_WAKE_PATTERN_CMDID
,
4105 .wow_del_wake_pattern_cmdid
= WMI_TLV_WOW_DEL_WAKE_PATTERN_CMDID
,
4106 .wow_enable_disable_wake_event_cmdid
=
4107 WMI_TLV_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID
,
4108 .wow_enable_cmdid
= WMI_TLV_WOW_ENABLE_CMDID
,
4109 .wow_hostwakeup_from_sleep_cmdid
=
4110 WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID
,
4111 .rtt_measreq_cmdid
= WMI_TLV_RTT_MEASREQ_CMDID
,
4112 .rtt_tsf_cmdid
= WMI_TLV_RTT_TSF_CMDID
,
4113 .vdev_spectral_scan_configure_cmdid
= WMI_TLV_SPECTRAL_SCAN_CONF_CMDID
,
4114 .vdev_spectral_scan_enable_cmdid
= WMI_TLV_SPECTRAL_SCAN_ENABLE_CMDID
,
4115 .request_stats_cmdid
= WMI_TLV_REQUEST_STATS_CMDID
,
4116 .set_arp_ns_offload_cmdid
= WMI_TLV_SET_ARP_NS_OFFLOAD_CMDID
,
4117 .network_list_offload_config_cmdid
=
4118 WMI_TLV_NETWORK_LIST_OFFLOAD_CONFIG_CMDID
,
4119 .gtk_offload_cmdid
= WMI_TLV_GTK_OFFLOAD_CMDID
,
4120 .csa_offload_enable_cmdid
= WMI_TLV_CSA_OFFLOAD_ENABLE_CMDID
,
4121 .csa_offload_chanswitch_cmdid
= WMI_TLV_CSA_OFFLOAD_CHANSWITCH_CMDID
,
4122 .chatter_set_mode_cmdid
= WMI_TLV_CHATTER_SET_MODE_CMDID
,
4123 .peer_tid_addba_cmdid
= WMI_TLV_PEER_TID_ADDBA_CMDID
,
4124 .peer_tid_delba_cmdid
= WMI_TLV_PEER_TID_DELBA_CMDID
,
4125 .sta_dtim_ps_method_cmdid
= WMI_TLV_STA_DTIM_PS_METHOD_CMDID
,
4126 .sta_uapsd_auto_trig_cmdid
= WMI_TLV_STA_UAPSD_AUTO_TRIG_CMDID
,
4127 .sta_keepalive_cmd
= WMI_TLV_STA_KEEPALIVE_CMDID
,
4128 .echo_cmdid
= WMI_TLV_ECHO_CMDID
,
4129 .pdev_utf_cmdid
= WMI_TLV_PDEV_UTF_CMDID
,
4130 .dbglog_cfg_cmdid
= WMI_TLV_DBGLOG_CFG_CMDID
,
4131 .pdev_qvit_cmdid
= WMI_TLV_PDEV_QVIT_CMDID
,
4132 .pdev_ftm_intg_cmdid
= WMI_TLV_PDEV_FTM_INTG_CMDID
,
4133 .vdev_set_keepalive_cmdid
= WMI_TLV_VDEV_SET_KEEPALIVE_CMDID
,
4134 .vdev_get_keepalive_cmdid
= WMI_TLV_VDEV_GET_KEEPALIVE_CMDID
,
4135 .force_fw_hang_cmdid
= WMI_TLV_FORCE_FW_HANG_CMDID
,
4136 .gpio_config_cmdid
= WMI_TLV_GPIO_CONFIG_CMDID
,
4137 .gpio_output_cmdid
= WMI_TLV_GPIO_OUTPUT_CMDID
,
4138 .pdev_get_temperature_cmdid
= WMI_TLV_PDEV_GET_TEMPERATURE_CMDID
,
4139 .vdev_set_wmm_params_cmdid
= WMI_TLV_VDEV_SET_WMM_PARAMS_CMDID
,
4140 .tdls_set_state_cmdid
= WMI_TLV_TDLS_SET_STATE_CMDID
,
4141 .tdls_peer_update_cmdid
= WMI_TLV_TDLS_PEER_UPDATE_CMDID
,
4142 .adaptive_qcs_cmdid
= WMI_TLV_RESMGR_ADAPTIVE_OCS_CMDID
,
4143 .scan_update_request_cmdid
= WMI_CMD_UNSUPPORTED
,
4144 .vdev_standby_response_cmdid
= WMI_CMD_UNSUPPORTED
,
4145 .vdev_resume_response_cmdid
= WMI_CMD_UNSUPPORTED
,
4146 .wlan_peer_caching_add_peer_cmdid
= WMI_CMD_UNSUPPORTED
,
4147 .wlan_peer_caching_evict_peer_cmdid
= WMI_CMD_UNSUPPORTED
,
4148 .wlan_peer_caching_restore_peer_cmdid
= WMI_CMD_UNSUPPORTED
,
4149 .wlan_peer_caching_print_all_peers_info_cmdid
= WMI_CMD_UNSUPPORTED
,
4150 .peer_update_wds_entry_cmdid
= WMI_CMD_UNSUPPORTED
,
4151 .peer_add_proxy_sta_entry_cmdid
= WMI_CMD_UNSUPPORTED
,
4152 .rtt_keepalive_cmdid
= WMI_CMD_UNSUPPORTED
,
4153 .oem_req_cmdid
= WMI_CMD_UNSUPPORTED
,
4154 .nan_cmdid
= WMI_CMD_UNSUPPORTED
,
4155 .vdev_ratemask_cmdid
= WMI_CMD_UNSUPPORTED
,
4156 .qboost_cfg_cmdid
= WMI_CMD_UNSUPPORTED
,
4157 .pdev_smart_ant_enable_cmdid
= WMI_CMD_UNSUPPORTED
,
4158 .pdev_smart_ant_set_rx_antenna_cmdid
= WMI_CMD_UNSUPPORTED
,
4159 .peer_smart_ant_set_tx_antenna_cmdid
= WMI_CMD_UNSUPPORTED
,
4160 .peer_smart_ant_set_train_info_cmdid
= WMI_CMD_UNSUPPORTED
,
4161 .peer_smart_ant_set_node_config_ops_cmdid
= WMI_CMD_UNSUPPORTED
,
4162 .pdev_set_antenna_switch_table_cmdid
= WMI_CMD_UNSUPPORTED
,
4163 .pdev_set_ctl_table_cmdid
= WMI_CMD_UNSUPPORTED
,
4164 .pdev_set_mimogain_table_cmdid
= WMI_CMD_UNSUPPORTED
,
4165 .pdev_ratepwr_table_cmdid
= WMI_CMD_UNSUPPORTED
,
4166 .pdev_ratepwr_chainmsk_table_cmdid
= WMI_CMD_UNSUPPORTED
,
4167 .pdev_fips_cmdid
= WMI_CMD_UNSUPPORTED
,
4168 .tt_set_conf_cmdid
= WMI_CMD_UNSUPPORTED
,
4169 .fwtest_cmdid
= WMI_CMD_UNSUPPORTED
,
4170 .vdev_atf_request_cmdid
= WMI_CMD_UNSUPPORTED
,
4171 .peer_atf_request_cmdid
= WMI_CMD_UNSUPPORTED
,
4172 .pdev_get_ani_cck_config_cmdid
= WMI_CMD_UNSUPPORTED
,
4173 .pdev_get_ani_ofdm_config_cmdid
= WMI_CMD_UNSUPPORTED
,
4174 .pdev_reserve_ast_entry_cmdid
= WMI_CMD_UNSUPPORTED
,
4177 static struct wmi_pdev_param_map wmi_tlv_pdev_param_map
= {
4178 .tx_chain_mask
= WMI_TLV_PDEV_PARAM_TX_CHAIN_MASK
,
4179 .rx_chain_mask
= WMI_TLV_PDEV_PARAM_RX_CHAIN_MASK
,
4180 .txpower_limit2g
= WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT2G
,
4181 .txpower_limit5g
= WMI_TLV_PDEV_PARAM_TXPOWER_LIMIT5G
,
4182 .txpower_scale
= WMI_TLV_PDEV_PARAM_TXPOWER_SCALE
,
4183 .beacon_gen_mode
= WMI_TLV_PDEV_PARAM_BEACON_GEN_MODE
,
4184 .beacon_tx_mode
= WMI_TLV_PDEV_PARAM_BEACON_TX_MODE
,
4185 .resmgr_offchan_mode
= WMI_TLV_PDEV_PARAM_RESMGR_OFFCHAN_MODE
,
4186 .protection_mode
= WMI_TLV_PDEV_PARAM_PROTECTION_MODE
,
4187 .dynamic_bw
= WMI_TLV_PDEV_PARAM_DYNAMIC_BW
,
4188 .non_agg_sw_retry_th
= WMI_TLV_PDEV_PARAM_NON_AGG_SW_RETRY_TH
,
4189 .agg_sw_retry_th
= WMI_TLV_PDEV_PARAM_AGG_SW_RETRY_TH
,
4190 .sta_kickout_th
= WMI_TLV_PDEV_PARAM_STA_KICKOUT_TH
,
4191 .ac_aggrsize_scaling
= WMI_TLV_PDEV_PARAM_AC_AGGRSIZE_SCALING
,
4192 .ltr_enable
= WMI_TLV_PDEV_PARAM_LTR_ENABLE
,
4193 .ltr_ac_latency_be
= WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BE
,
4194 .ltr_ac_latency_bk
= WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_BK
,
4195 .ltr_ac_latency_vi
= WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VI
,
4196 .ltr_ac_latency_vo
= WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_VO
,
4197 .ltr_ac_latency_timeout
= WMI_TLV_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT
,
4198 .ltr_sleep_override
= WMI_TLV_PDEV_PARAM_LTR_SLEEP_OVERRIDE
,
4199 .ltr_rx_override
= WMI_TLV_PDEV_PARAM_LTR_RX_OVERRIDE
,
4200 .ltr_tx_activity_timeout
= WMI_TLV_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT
,
4201 .l1ss_enable
= WMI_TLV_PDEV_PARAM_L1SS_ENABLE
,
4202 .dsleep_enable
= WMI_TLV_PDEV_PARAM_DSLEEP_ENABLE
,
4203 .pcielp_txbuf_flush
= WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_FLUSH
,
4204 .pcielp_txbuf_watermark
= WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN
,
4205 .pcielp_txbuf_tmo_en
= WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_EN
,
4206 .pcielp_txbuf_tmo_value
= WMI_TLV_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE
,
4207 .pdev_stats_update_period
= WMI_TLV_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD
,
4208 .vdev_stats_update_period
= WMI_TLV_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD
,
4209 .peer_stats_update_period
= WMI_TLV_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD
,
4210 .bcnflt_stats_update_period
=
4211 WMI_TLV_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD
,
4212 .pmf_qos
= WMI_TLV_PDEV_PARAM_PMF_QOS
,
4213 .arp_ac_override
= WMI_TLV_PDEV_PARAM_ARP_AC_OVERRIDE
,
4214 .dcs
= WMI_TLV_PDEV_PARAM_DCS
,
4215 .ani_enable
= WMI_TLV_PDEV_PARAM_ANI_ENABLE
,
4216 .ani_poll_period
= WMI_TLV_PDEV_PARAM_ANI_POLL_PERIOD
,
4217 .ani_listen_period
= WMI_TLV_PDEV_PARAM_ANI_LISTEN_PERIOD
,
4218 .ani_ofdm_level
= WMI_TLV_PDEV_PARAM_ANI_OFDM_LEVEL
,
4219 .ani_cck_level
= WMI_TLV_PDEV_PARAM_ANI_CCK_LEVEL
,
4220 .dyntxchain
= WMI_TLV_PDEV_PARAM_DYNTXCHAIN
,
4221 .proxy_sta
= WMI_TLV_PDEV_PARAM_PROXY_STA
,
4222 .idle_ps_config
= WMI_TLV_PDEV_PARAM_IDLE_PS_CONFIG
,
4223 .power_gating_sleep
= WMI_TLV_PDEV_PARAM_POWER_GATING_SLEEP
,
4224 .fast_channel_reset
= WMI_TLV_PDEV_PARAM_UNSUPPORTED
,
4225 .burst_dur
= WMI_TLV_PDEV_PARAM_BURST_DUR
,
4226 .burst_enable
= WMI_TLV_PDEV_PARAM_BURST_ENABLE
,
4227 .cal_period
= WMI_PDEV_PARAM_UNSUPPORTED
,
4228 .aggr_burst
= WMI_PDEV_PARAM_UNSUPPORTED
,
4229 .rx_decap_mode
= WMI_PDEV_PARAM_UNSUPPORTED
,
4230 .smart_antenna_default_antenna
= WMI_PDEV_PARAM_UNSUPPORTED
,
4231 .igmpmld_override
= WMI_PDEV_PARAM_UNSUPPORTED
,
4232 .igmpmld_tid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4233 .antenna_gain
= WMI_PDEV_PARAM_UNSUPPORTED
,
4234 .rx_filter
= WMI_PDEV_PARAM_UNSUPPORTED
,
4235 .set_mcast_to_ucast_tid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4236 .proxy_sta_mode
= WMI_PDEV_PARAM_UNSUPPORTED
,
4237 .set_mcast2ucast_mode
= WMI_PDEV_PARAM_UNSUPPORTED
,
4238 .set_mcast2ucast_buffer
= WMI_PDEV_PARAM_UNSUPPORTED
,
4239 .remove_mcast2ucast_buffer
= WMI_PDEV_PARAM_UNSUPPORTED
,
4240 .peer_sta_ps_statechg_enable
= WMI_PDEV_PARAM_UNSUPPORTED
,
4241 .igmpmld_ac_override
= WMI_PDEV_PARAM_UNSUPPORTED
,
4242 .block_interbss
= WMI_PDEV_PARAM_UNSUPPORTED
,
4243 .set_disable_reset_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4244 .set_msdu_ttl_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4245 .set_ppdu_duration_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4246 .txbf_sound_period_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4247 .set_promisc_mode_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4248 .set_burst_mode_cmdid
= WMI_PDEV_PARAM_UNSUPPORTED
,
4249 .en_stats
= WMI_PDEV_PARAM_UNSUPPORTED
,
4250 .mu_group_policy
= WMI_PDEV_PARAM_UNSUPPORTED
,
4251 .noise_detection
= WMI_PDEV_PARAM_UNSUPPORTED
,
4252 .noise_threshold
= WMI_PDEV_PARAM_UNSUPPORTED
,
4253 .dpd_enable
= WMI_PDEV_PARAM_UNSUPPORTED
,
4254 .set_mcast_bcast_echo
= WMI_PDEV_PARAM_UNSUPPORTED
,
4255 .atf_strict_sch
= WMI_PDEV_PARAM_UNSUPPORTED
,
4256 .atf_sched_duration
= WMI_PDEV_PARAM_UNSUPPORTED
,
4257 .ant_plzn
= WMI_PDEV_PARAM_UNSUPPORTED
,
4258 .mgmt_retry_limit
= WMI_PDEV_PARAM_UNSUPPORTED
,
4259 .sensitivity_level
= WMI_PDEV_PARAM_UNSUPPORTED
,
4260 .signed_txpower_2g
= WMI_PDEV_PARAM_UNSUPPORTED
,
4261 .signed_txpower_5g
= WMI_PDEV_PARAM_UNSUPPORTED
,
4262 .enable_per_tid_amsdu
= WMI_PDEV_PARAM_UNSUPPORTED
,
4263 .enable_per_tid_ampdu
= WMI_PDEV_PARAM_UNSUPPORTED
,
4264 .cca_threshold
= WMI_PDEV_PARAM_UNSUPPORTED
,
4265 .rts_fixed_rate
= WMI_PDEV_PARAM_UNSUPPORTED
,
4266 .pdev_reset
= WMI_PDEV_PARAM_UNSUPPORTED
,
4267 .wapi_mbssid_offset
= WMI_PDEV_PARAM_UNSUPPORTED
,
4268 .arp_srcaddr
= WMI_PDEV_PARAM_UNSUPPORTED
,
4269 .arp_dstaddr
= WMI_PDEV_PARAM_UNSUPPORTED
,
4270 .rfkill_config
= WMI_TLV_PDEV_PARAM_HW_RFKILL_CONFIG
,
4271 .rfkill_enable
= WMI_TLV_PDEV_PARAM_RFKILL_ENABLE
,
4274 static struct wmi_peer_param_map wmi_tlv_peer_param_map
= {
4275 .smps_state
= WMI_TLV_PEER_SMPS_STATE
,
4276 .ampdu
= WMI_TLV_PEER_AMPDU
,
4277 .authorize
= WMI_TLV_PEER_AUTHORIZE
,
4278 .chan_width
= WMI_TLV_PEER_CHAN_WIDTH
,
4279 .nss
= WMI_TLV_PEER_NSS
,
4280 .use_4addr
= WMI_TLV_PEER_USE_4ADDR
,
4281 .membership
= WMI_TLV_PEER_MEMBERSHIP
,
4282 .user_pos
= WMI_TLV_PEER_USERPOS
,
4283 .crit_proto_hint_enabled
= WMI_TLV_PEER_CRIT_PROTO_HINT_ENABLED
,
4284 .tx_fail_cnt_thr
= WMI_TLV_PEER_TX_FAIL_CNT_THR
,
4285 .set_hw_retry_cts2s
= WMI_TLV_PEER_SET_HW_RETRY_CTS2S
,
4286 .ibss_atim_win_len
= WMI_TLV_PEER_IBSS_ATIM_WINDOW_LENGTH
,
4287 .phymode
= WMI_TLV_PEER_PHYMODE
,
4288 .use_fixed_power
= WMI_TLV_PEER_USE_FIXED_PWR
,
4289 .dummy_var
= WMI_TLV_PEER_DUMMY_VAR
,
4292 static struct wmi_vdev_param_map wmi_tlv_vdev_param_map
= {
4293 .rts_threshold
= WMI_TLV_VDEV_PARAM_RTS_THRESHOLD
,
4294 .fragmentation_threshold
= WMI_TLV_VDEV_PARAM_FRAGMENTATION_THRESHOLD
,
4295 .beacon_interval
= WMI_TLV_VDEV_PARAM_BEACON_INTERVAL
,
4296 .listen_interval
= WMI_TLV_VDEV_PARAM_LISTEN_INTERVAL
,
4297 .multicast_rate
= WMI_TLV_VDEV_PARAM_MULTICAST_RATE
,
4298 .mgmt_tx_rate
= WMI_TLV_VDEV_PARAM_MGMT_TX_RATE
,
4299 .slot_time
= WMI_TLV_VDEV_PARAM_SLOT_TIME
,
4300 .preamble
= WMI_TLV_VDEV_PARAM_PREAMBLE
,
4301 .swba_time
= WMI_TLV_VDEV_PARAM_SWBA_TIME
,
4302 .wmi_vdev_stats_update_period
= WMI_TLV_VDEV_STATS_UPDATE_PERIOD
,
4303 .wmi_vdev_pwrsave_ageout_time
= WMI_TLV_VDEV_PWRSAVE_AGEOUT_TIME
,
4304 .wmi_vdev_host_swba_interval
= WMI_TLV_VDEV_HOST_SWBA_INTERVAL
,
4305 .dtim_period
= WMI_TLV_VDEV_PARAM_DTIM_PERIOD
,
4306 .wmi_vdev_oc_scheduler_air_time_limit
=
4307 WMI_TLV_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT
,
4308 .wds
= WMI_TLV_VDEV_PARAM_WDS
,
4309 .atim_window
= WMI_TLV_VDEV_PARAM_ATIM_WINDOW
,
4310 .bmiss_count_max
= WMI_TLV_VDEV_PARAM_BMISS_COUNT_MAX
,
4311 .bmiss_first_bcnt
= WMI_TLV_VDEV_PARAM_BMISS_FIRST_BCNT
,
4312 .bmiss_final_bcnt
= WMI_TLV_VDEV_PARAM_BMISS_FINAL_BCNT
,
4313 .feature_wmm
= WMI_TLV_VDEV_PARAM_FEATURE_WMM
,
4314 .chwidth
= WMI_TLV_VDEV_PARAM_CHWIDTH
,
4315 .chextoffset
= WMI_TLV_VDEV_PARAM_CHEXTOFFSET
,
4316 .disable_htprotection
= WMI_TLV_VDEV_PARAM_DISABLE_HTPROTECTION
,
4317 .sta_quickkickout
= WMI_TLV_VDEV_PARAM_STA_QUICKKICKOUT
,
4318 .mgmt_rate
= WMI_TLV_VDEV_PARAM_MGMT_RATE
,
4319 .protection_mode
= WMI_TLV_VDEV_PARAM_PROTECTION_MODE
,
4320 .fixed_rate
= WMI_TLV_VDEV_PARAM_FIXED_RATE
,
4321 .sgi
= WMI_TLV_VDEV_PARAM_SGI
,
4322 .ldpc
= WMI_TLV_VDEV_PARAM_LDPC
,
4323 .tx_stbc
= WMI_TLV_VDEV_PARAM_TX_STBC
,
4324 .rx_stbc
= WMI_TLV_VDEV_PARAM_RX_STBC
,
4325 .intra_bss_fwd
= WMI_TLV_VDEV_PARAM_INTRA_BSS_FWD
,
4326 .def_keyid
= WMI_TLV_VDEV_PARAM_DEF_KEYID
,
4327 .nss
= WMI_TLV_VDEV_PARAM_NSS
,
4328 .bcast_data_rate
= WMI_TLV_VDEV_PARAM_BCAST_DATA_RATE
,
4329 .mcast_data_rate
= WMI_TLV_VDEV_PARAM_MCAST_DATA_RATE
,
4330 .mcast_indicate
= WMI_TLV_VDEV_PARAM_MCAST_INDICATE
,
4331 .dhcp_indicate
= WMI_TLV_VDEV_PARAM_DHCP_INDICATE
,
4332 .unknown_dest_indicate
= WMI_TLV_VDEV_PARAM_UNKNOWN_DEST_INDICATE
,
4333 .ap_keepalive_min_idle_inactive_time_secs
=
4334 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS
,
4335 .ap_keepalive_max_idle_inactive_time_secs
=
4336 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS
,
4337 .ap_keepalive_max_unresponsive_time_secs
=
4338 WMI_TLV_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS
,
4339 .ap_enable_nawds
= WMI_TLV_VDEV_PARAM_AP_ENABLE_NAWDS
,
4340 .mcast2ucast_set
= WMI_TLV_VDEV_PARAM_UNSUPPORTED
,
4341 .enable_rtscts
= WMI_TLV_VDEV_PARAM_ENABLE_RTSCTS
,
4342 .txbf
= WMI_TLV_VDEV_PARAM_TXBF
,
4343 .packet_powersave
= WMI_TLV_VDEV_PARAM_PACKET_POWERSAVE
,
4344 .drop_unencry
= WMI_TLV_VDEV_PARAM_DROP_UNENCRY
,
4345 .tx_encap_type
= WMI_TLV_VDEV_PARAM_TX_ENCAP_TYPE
,
4346 .ap_detect_out_of_sync_sleeping_sta_time_secs
=
4347 WMI_TLV_VDEV_PARAM_UNSUPPORTED
,
4348 .rc_num_retries
= WMI_VDEV_PARAM_UNSUPPORTED
,
4349 .cabq_maxdur
= WMI_VDEV_PARAM_UNSUPPORTED
,
4350 .mfptest_set
= WMI_VDEV_PARAM_UNSUPPORTED
,
4351 .rts_fixed_rate
= WMI_VDEV_PARAM_UNSUPPORTED
,
4352 .vht_sgimask
= WMI_VDEV_PARAM_UNSUPPORTED
,
4353 .vht80_ratemask
= WMI_VDEV_PARAM_UNSUPPORTED
,
4354 .early_rx_adjust_enable
= WMI_VDEV_PARAM_UNSUPPORTED
,
4355 .early_rx_tgt_bmiss_num
= WMI_VDEV_PARAM_UNSUPPORTED
,
4356 .early_rx_bmiss_sample_cycle
= WMI_VDEV_PARAM_UNSUPPORTED
,
4357 .early_rx_slop_step
= WMI_VDEV_PARAM_UNSUPPORTED
,
4358 .early_rx_init_slop
= WMI_VDEV_PARAM_UNSUPPORTED
,
4359 .early_rx_adjust_pause
= WMI_VDEV_PARAM_UNSUPPORTED
,
4360 .proxy_sta
= WMI_VDEV_PARAM_UNSUPPORTED
,
4361 .meru_vc
= WMI_VDEV_PARAM_UNSUPPORTED
,
4362 .rx_decap_type
= WMI_VDEV_PARAM_UNSUPPORTED
,
4363 .bw_nss_ratemask
= WMI_VDEV_PARAM_UNSUPPORTED
,
4366 static const struct wmi_ops wmi_tlv_ops
= {
4367 .rx
= ath10k_wmi_tlv_op_rx
,
4368 .map_svc
= wmi_tlv_svc_map
,
4369 .map_svc_ext
= wmi_tlv_svc_map_ext
,
4371 .pull_scan
= ath10k_wmi_tlv_op_pull_scan_ev
,
4372 .pull_mgmt_rx
= ath10k_wmi_tlv_op_pull_mgmt_rx_ev
,
4373 .pull_mgmt_tx_compl
= ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev
,
4374 .pull_mgmt_tx_bundle_compl
= ath10k_wmi_tlv_op_pull_mgmt_tx_bundle_compl_ev
,
4375 .pull_ch_info
= ath10k_wmi_tlv_op_pull_ch_info_ev
,
4376 .pull_vdev_start
= ath10k_wmi_tlv_op_pull_vdev_start_ev
,
4377 .pull_peer_kick
= ath10k_wmi_tlv_op_pull_peer_kick_ev
,
4378 .pull_swba
= ath10k_wmi_tlv_op_pull_swba_ev
,
4379 .pull_phyerr_hdr
= ath10k_wmi_tlv_op_pull_phyerr_ev_hdr
,
4380 .pull_phyerr
= ath10k_wmi_op_pull_phyerr_ev
,
4381 .pull_svc_rdy
= ath10k_wmi_tlv_op_pull_svc_rdy_ev
,
4382 .pull_rdy
= ath10k_wmi_tlv_op_pull_rdy_ev
,
4383 .pull_svc_avail
= ath10k_wmi_tlv_op_pull_svc_avail
,
4384 .pull_fw_stats
= ath10k_wmi_tlv_op_pull_fw_stats
,
4385 .pull_roam_ev
= ath10k_wmi_tlv_op_pull_roam_ev
,
4386 .pull_wow_event
= ath10k_wmi_tlv_op_pull_wow_ev
,
4387 .pull_echo_ev
= ath10k_wmi_tlv_op_pull_echo_ev
,
4388 .get_txbf_conf_scheme
= ath10k_wmi_tlv_txbf_conf_scheme
,
4390 .gen_pdev_suspend
= ath10k_wmi_tlv_op_gen_pdev_suspend
,
4391 .gen_pdev_resume
= ath10k_wmi_tlv_op_gen_pdev_resume
,
4392 .gen_pdev_set_rd
= ath10k_wmi_tlv_op_gen_pdev_set_rd
,
4393 .gen_pdev_set_param
= ath10k_wmi_tlv_op_gen_pdev_set_param
,
4394 .gen_init
= ath10k_wmi_tlv_op_gen_init
,
4395 .gen_start_scan
= ath10k_wmi_tlv_op_gen_start_scan
,
4396 .gen_stop_scan
= ath10k_wmi_tlv_op_gen_stop_scan
,
4397 .gen_vdev_create
= ath10k_wmi_tlv_op_gen_vdev_create
,
4398 .gen_vdev_delete
= ath10k_wmi_tlv_op_gen_vdev_delete
,
4399 .gen_vdev_start
= ath10k_wmi_tlv_op_gen_vdev_start
,
4400 .gen_vdev_stop
= ath10k_wmi_tlv_op_gen_vdev_stop
,
4401 .gen_vdev_up
= ath10k_wmi_tlv_op_gen_vdev_up
,
4402 .gen_vdev_down
= ath10k_wmi_tlv_op_gen_vdev_down
,
4403 .gen_vdev_set_param
= ath10k_wmi_tlv_op_gen_vdev_set_param
,
4404 .gen_vdev_install_key
= ath10k_wmi_tlv_op_gen_vdev_install_key
,
4405 .gen_vdev_wmm_conf
= ath10k_wmi_tlv_op_gen_vdev_wmm_conf
,
4406 .gen_peer_create
= ath10k_wmi_tlv_op_gen_peer_create
,
4407 .gen_peer_delete
= ath10k_wmi_tlv_op_gen_peer_delete
,
4408 .gen_peer_flush
= ath10k_wmi_tlv_op_gen_peer_flush
,
4409 .gen_peer_set_param
= ath10k_wmi_tlv_op_gen_peer_set_param
,
4410 .gen_peer_assoc
= ath10k_wmi_tlv_op_gen_peer_assoc
,
4411 .gen_set_psmode
= ath10k_wmi_tlv_op_gen_set_psmode
,
4412 .gen_set_sta_ps
= ath10k_wmi_tlv_op_gen_set_sta_ps
,
4413 .gen_set_ap_ps
= ath10k_wmi_tlv_op_gen_set_ap_ps
,
4414 .gen_scan_chan_list
= ath10k_wmi_tlv_op_gen_scan_chan_list
,
4415 .gen_scan_prob_req_oui
= ath10k_wmi_tlv_op_gen_scan_prob_req_oui
,
4416 .gen_beacon_dma
= ath10k_wmi_tlv_op_gen_beacon_dma
,
4417 .gen_pdev_set_wmm
= ath10k_wmi_tlv_op_gen_pdev_set_wmm
,
4418 .gen_request_stats
= ath10k_wmi_tlv_op_gen_request_stats
,
4419 .gen_force_fw_hang
= ath10k_wmi_tlv_op_gen_force_fw_hang
,
4420 /* .gen_mgmt_tx = not implemented; HTT is used */
4421 .gen_mgmt_tx_send
= ath10k_wmi_tlv_op_gen_mgmt_tx_send
,
4422 .gen_dbglog_cfg
= ath10k_wmi_tlv_op_gen_dbglog_cfg
,
4423 .gen_pktlog_enable
= ath10k_wmi_tlv_op_gen_pktlog_enable
,
4424 .gen_pktlog_disable
= ath10k_wmi_tlv_op_gen_pktlog_disable
,
4425 .gen_pdev_set_quiet_mode
= ath10k_wmi_tlv_op_gen_pdev_set_quiet_mode
,
4426 .gen_pdev_get_temperature
= ath10k_wmi_tlv_op_gen_pdev_get_temperature
,
4427 /* .gen_addba_clear_resp not implemented */
4428 /* .gen_addba_send not implemented */
4429 /* .gen_addba_set_resp not implemented */
4430 /* .gen_delba_send not implemented */
4431 .gen_bcn_tmpl
= ath10k_wmi_tlv_op_gen_bcn_tmpl
,
4432 .gen_prb_tmpl
= ath10k_wmi_tlv_op_gen_prb_tmpl
,
4433 .gen_p2p_go_bcn_ie
= ath10k_wmi_tlv_op_gen_p2p_go_bcn_ie
,
4434 .gen_vdev_sta_uapsd
= ath10k_wmi_tlv_op_gen_vdev_sta_uapsd
,
4435 .gen_sta_keepalive
= ath10k_wmi_tlv_op_gen_sta_keepalive
,
4436 .gen_wow_enable
= ath10k_wmi_tlv_op_gen_wow_enable
,
4437 .gen_wow_add_wakeup_event
= ath10k_wmi_tlv_op_gen_wow_add_wakeup_event
,
4438 .gen_wow_host_wakeup_ind
= ath10k_wmi_tlv_gen_wow_host_wakeup_ind
,
4439 .gen_wow_add_pattern
= ath10k_wmi_tlv_op_gen_wow_add_pattern
,
4440 .gen_wow_del_pattern
= ath10k_wmi_tlv_op_gen_wow_del_pattern
,
4441 .gen_wow_config_pno
= ath10k_wmi_tlv_op_gen_config_pno
,
4442 .gen_update_fw_tdls_state
= ath10k_wmi_tlv_op_gen_update_fw_tdls_state
,
4443 .gen_tdls_peer_update
= ath10k_wmi_tlv_op_gen_tdls_peer_update
,
4444 .gen_adaptive_qcs
= ath10k_wmi_tlv_op_gen_adaptive_qcs
,
4445 .fw_stats_fill
= ath10k_wmi_main_op_fw_stats_fill
,
4446 .get_vdev_subtype
= ath10k_wmi_tlv_op_get_vdev_subtype
,
4447 .gen_echo
= ath10k_wmi_tlv_op_gen_echo
,
4448 .gen_vdev_spectral_conf
= ath10k_wmi_tlv_op_gen_vdev_spectral_conf
,
4449 .gen_vdev_spectral_enable
= ath10k_wmi_tlv_op_gen_vdev_spectral_enable
,
4452 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map
= {
4453 .auth
= WMI_TLV_PEER_AUTH
,
4454 .qos
= WMI_TLV_PEER_QOS
,
4455 .need_ptk_4_way
= WMI_TLV_PEER_NEED_PTK_4_WAY
,
4456 .need_gtk_2_way
= WMI_TLV_PEER_NEED_GTK_2_WAY
,
4457 .apsd
= WMI_TLV_PEER_APSD
,
4458 .ht
= WMI_TLV_PEER_HT
,
4459 .bw40
= WMI_TLV_PEER_40MHZ
,
4460 .stbc
= WMI_TLV_PEER_STBC
,
4461 .ldbc
= WMI_TLV_PEER_LDPC
,
4462 .dyn_mimops
= WMI_TLV_PEER_DYN_MIMOPS
,
4463 .static_mimops
= WMI_TLV_PEER_STATIC_MIMOPS
,
4464 .spatial_mux
= WMI_TLV_PEER_SPATIAL_MUX
,
4465 .vht
= WMI_TLV_PEER_VHT
,
4466 .bw80
= WMI_TLV_PEER_80MHZ
,
4467 .pmf
= WMI_TLV_PEER_PMF
,
4468 .bw160
= WMI_TLV_PEER_160MHZ
,
4475 void ath10k_wmi_tlv_attach(struct ath10k
*ar
)
4477 ar
->wmi
.cmd
= &wmi_tlv_cmd_map
;
4478 ar
->wmi
.vdev_param
= &wmi_tlv_vdev_param_map
;
4479 ar
->wmi
.pdev_param
= &wmi_tlv_pdev_param_map
;
4480 ar
->wmi
.peer_param
= &wmi_tlv_peer_param_map
;
4481 ar
->wmi
.ops
= &wmi_tlv_ops
;
4482 ar
->wmi
.peer_flags
= &wmi_tlv_peer_flags_map
;